Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to psy4 #383

Merged
merged 18 commits into from
Jul 8, 2024
Merged
10 changes: 5 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PowerSimulationsDynamics"
uuid = "398b2ede-47ed-4edc-b52e-69e4a48b4336"
authors = ["Jose Daniel Lara, Rodrigo Henriquez"]
version = "0.14.2"
version = "0.15.0"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand All @@ -28,11 +28,11 @@ DataStructures = "~0.18"
DocStringExtensions = "~0.9"
FastClosures = "^0.3"
ForwardDiff = "~v0.10"
InfrastructureSystems = "^1.21"
InfrastructureSystems = "2"
NLsolve = "4"
PowerSystems = "^3.1.2"
PowerFlows = "^0.6"
PowerNetworkMatrices = "^0.10"
PowerSystems = "4"
PowerFlows = "^0.7"
PowerNetworkMatrices = "^0.11"
PrettyTables = "1, 2"
SciMLBase = "2"
TimerOutputs = "~0.5"
Expand Down
4 changes: 2 additions & 2 deletions docs/src/tutorials/tutorial_activeload.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ Since the load is an exponential load model we can change the exponent coefficie
```@repl tutorial_load
# Update load coefficients to 2.0
load = first(get_components(PSY.ExponentialLoad, sys));
PSY.set_active_power_coefficient!(load, 2.0);
PSY.set_reactive_power_coefficient!(load, 2.0);
PSY.set_α!(load, 2.0);
PSY.set_β!(load, 2.0);
```

We then re-run the small-signal analysis:
Expand Down
1 change: 1 addition & 0 deletions src/PowerSimulationsDynamics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ include("models/inverter_models/frequency_estimator_models.jl")
include("models/inverter_models/outer_control_models.jl")
include("models/inverter_models/inner_control_models.jl")
include("models/inverter_models/converter_models.jl")
include("models/inverter_models/output_current_limiter_models.jl")

#Injection Models
include("models/load_models.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/base/branch_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ PSY.get_arc(wrapper::BranchWrapper) = PSY.get_arc(wrapper.branch)
PSY.get_r(wrapper::BranchWrapper) = PSY.get_r(wrapper.branch)
PSY.get_x(wrapper::BranchWrapper) = PSY.get_x(wrapper.branch)
PSY.get_b(wrapper::BranchWrapper) = PSY.get_b(wrapper.branch)
PSY.get_rate(wrapper::BranchWrapper) = PSY.get_rate(wrapper.branch)
PSY.get_rating(wrapper::BranchWrapper) = PSY.get_rating(wrapper.branch)
PSY.get_angle_limits(wrapper::BranchWrapper) = PSY.get_angle_limits(wrapper.branch)
PSY.get_ext(wrapper::BranchWrapper) = PSY.get_ext(wrapper.branch)
PSY.get_states(wrapper::BranchWrapper) = PSY.get_states(wrapper.branch)
Expand Down
2 changes: 1 addition & 1 deletion src/base/caches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,5 @@ get_current_balance(sc::SimCache, ::Type{Float64}) = sc.current_balance
get_inner_vars(sc::SimCache, ::Type{Float64}) = sc.inner_vars
get_global_vars(sc::SimCache, ::Type{Float64}) = sc.global_vars

get_ω_sys(cache::Cache, T::Type{<:Union{Float64, ForwardDiff.Dual}}) =
get_ω_sys(cache::Cache, T::Type{<:ACCEPTED_REAL_TYPES}) =
get_global_vars(cache, T)[GLOBAL_VAR_SYS_FREQ_INDEX]
9 changes: 7 additions & 2 deletions src/base/device_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ function state_port_mappings(
component_state_mapping = Dict{Int, Vector{Int}}()
input_port_mapping = Dict{Int, Vector{Int}}()
for c in PSY.get_dynamic_components(dynamic_device)
if c isa PSY.OutputCurrentLimiter
continue
end
ix = index(typeof(c))
component_state_mapping[ix] = _index_local_states(c, device_states)
input_port_mapping[ix] = _index_port_mapping!(c, device_states)
Expand Down Expand Up @@ -331,6 +334,8 @@ PSY.get_freq_estimator(wrapper::DynamicWrapper{T}) where {T <: PSY.DynamicInvert
wrapper.device.freq_estimator
PSY.get_filter(wrapper::DynamicWrapper{T}) where {T <: PSY.DynamicInverter} =
wrapper.device.filter
PSY.get_limiter(wrapper::DynamicWrapper{T}) where {T <: PSY.DynamicInverter} =
PSY.get_limiter(wrapper.device)

# PSY overloads of specific Dynamic Injectors

Expand Down Expand Up @@ -487,9 +492,9 @@ function StaticLoadWrapper(
dict_names[PSY.get_name(ld)] = ix
exp_params[ix] = ExpLoadParams(
PSY.get_active_power(ld) * base_power_conversion,
PSY.get_active_power_coefficient(ld),
PSY.get_α(ld),
PSY.get_reactive_power(ld) * base_power_conversion,
PSY.get_reactive_power_coefficient(ld),
PSY.get_β(ld),
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/initialization/inverter_components/init_DCside.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function initialize_DCside!(
IC <: PSY.InnerControl,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}

#Update inner_vars
Expand Down
6 changes: 3 additions & 3 deletions src/initialization/inverter_components/init_converter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function initialize_converter!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
} end

function initialize_converter!(
Expand All @@ -27,7 +27,7 @@ function initialize_converter!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}
#Get inner vars
V_R = inner_vars[Vr_cnv_var]
Expand Down Expand Up @@ -82,7 +82,7 @@ function initialize_converter!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}
#Get inner vars
Vr_filter = inner_vars[Vr_filter_var]
Expand Down
4 changes: 2 additions & 2 deletions src/initialization/inverter_components/init_filter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function initialize_filter!(
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}
#PowerFlow Data
P0 = PSY.get_active_power(static)
Expand Down Expand Up @@ -101,7 +101,7 @@ function initialize_filter!(
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}
#PowerFlow Data
P0 = PSY.get_active_power(static)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function initialize_frequency_estimator!(
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}
Vr_filter = inner_vars[Vr_filter_var]
Vi_filter = inner_vars[Vi_filter_var]
Expand Down Expand Up @@ -76,7 +76,7 @@ function initialize_frequency_estimator!(
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}
Vr_filter = inner_vars[Vr_filter_var]
Vi_filter = inner_vars[Vi_filter_var]
Expand Down Expand Up @@ -139,7 +139,7 @@ function initialize_frequency_estimator!(
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}
#Get parameters
pll_control = PSY.get_freq_estimator(dynamic_device)
Expand Down
6 changes: 3 additions & 3 deletions src/initialization/inverter_components/init_inner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function initialize_inner!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}

#Obtain external states inputs for component
Expand Down Expand Up @@ -156,7 +156,7 @@ function initialize_inner!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}

#Obtain external states inputs for component
Expand Down Expand Up @@ -242,7 +242,7 @@ function initialize_inner!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}
# Obtain inner variables for component
Vr_filter = inner_vars[Vr_filter_var]
Expand Down
10 changes: 5 additions & 5 deletions src/initialization/inverter_components/init_outer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function initialize_outer!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}

#Obtain external states inputs for component
Expand Down Expand Up @@ -86,7 +86,7 @@ function initialize_outer!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}

#Obtain external states inputs for component
Expand Down Expand Up @@ -152,7 +152,7 @@ function initialize_outer!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}

#Obtain external states inputs for component
Expand Down Expand Up @@ -217,7 +217,7 @@ function initialize_outer!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}

#Obtain external states inputs for component
Expand Down Expand Up @@ -301,7 +301,7 @@ function initialize_outer!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}
# Read inner vars
Vr_filter = inner_vars[Vr_filter_var]
Expand Down
6 changes: 3 additions & 3 deletions src/models/device.jl
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ function _update_inner_vars!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}
return
end
Expand All @@ -490,7 +490,7 @@ function _update_inner_vars!(
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}
V_R = inner_vars[Vr_inv_var]
V_I = inner_vars[Vi_inv_var]
Expand Down Expand Up @@ -611,7 +611,7 @@ function _update_inner_vars!(
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}
filter_ix = get_local_state_ix(dynamic_device, PSY.LCLFilter)
filter_states = @view device_states[filter_ix]
Expand Down
2 changes: 1 addition & 1 deletion src/models/inverter_models/DCside_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function mdl_DCside_ode!(
IC <: PSY.InnerControl,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}

#Update inner_vars
Expand Down
6 changes: 3 additions & 3 deletions src/models/inverter_models/converter_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function mdl_converter_ode!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}

#Obtain inner variables for component
Expand Down Expand Up @@ -61,7 +61,7 @@ function mdl_converter_ode!(
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}
#Obtain inner variables for component
V_R = inner_vars[Vr_filter_var]
Expand Down Expand Up @@ -196,7 +196,7 @@ function mdl_converter_ode!(
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}
#Obtain inner variables for component
V_R = inner_vars[Vr_filter_var]
Expand Down
4 changes: 2 additions & 2 deletions src/models/inverter_models/filter_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function mdl_filter_ode!(
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}

#external_ix = get_input_port_ix(dynamic_device, PSY.LCLFilter)
Expand Down Expand Up @@ -132,7 +132,7 @@ function mdl_filter_ode!(
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}
#Obtain inner variables for component
basepower = PSY.get_base_power(dynamic_device)
Expand Down
6 changes: 3 additions & 3 deletions src/models/inverter_models/frequency_estimator_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function mdl_freq_estimator_ode!(
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}

#Obtain external states inputs for component
Expand Down Expand Up @@ -88,7 +88,7 @@ function mdl_freq_estimator_ode!(
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}

#Obtain external states inputs for component
Expand Down Expand Up @@ -151,7 +151,7 @@ function mdl_freq_estimator_ode!(
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
L <: Union{Nothing, PSY.OutputCurrentLimiter},
}

#Get parameters
Expand Down
Loading
Loading