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

Hr/add limiters #376

Merged
merged 15 commits into from
Jul 8, 2024
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
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 @@ -228,8 +231,8 @@ function DynamicWrapper(
sys_base_freq,
) where {D <: PSY.DynamicInjection}
device_states = PSY.get_states(dynamic_device)
IS.@assert_op PSY.get_X_th(dynamic_device) == PSY.get_X_th(device)
IS.@assert_op PSY.get_R_th(dynamic_device) == PSY.get_R_th(device)
# IS.@assert_op PSY.get_X_th(dynamic_device) == PSY.get_X_th(device)
# IS.@assert_op PSY.get_R_th(dynamic_device) == PSY.get_R_th(device)

return DynamicWrapper(
dynamic_device,
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
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