Skip to content

Commit

Permalink
update inverter models dispatch to include limiter
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigomha committed Dec 4, 2023
1 parent 129c4f1 commit a4e4f4f
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 27 deletions.
5 changes: 4 additions & 1 deletion src/initialization/inverter_components/init_DCside.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
function initialize_DCside!(
device_states,
static::PSY.StaticInjection,
dynamic_device::DynamicWrapper{PSY.DynamicInverter{C, O, IC, PSY.FixedDCSource, P, F}},
dynamic_device::DynamicWrapper{
PSY.DynamicInverter{C, O, IC, PSY.FixedDCSource, P, F, L},
},
inner_vars::AbstractVector,
) where {
C <: PSY.Converter,
O <: PSY.OuterControl,
IC <: PSY.InnerControl,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
}

#Update inner_vars
Expand Down
9 changes: 6 additions & 3 deletions src/initialization/inverter_components/init_converter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function initialize_converter!(
device_states,
static::PSY.StaticInjection,
dynamic_device::DynamicWrapper{
PSY.DynamicInverter{PSY.AverageConverter, O, IC, DC, P, F},
PSY.DynamicInverter{PSY.AverageConverter, O, IC, DC, P, F, L},
},
inner_vars::AbstractVector,
) where {
Expand All @@ -11,13 +11,14 @@ function initialize_converter!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
} end

function initialize_converter!(
device_states,
static::PSY.StaticInjection,
dynamic_device::DynamicWrapper{
PSY.DynamicInverter{PSY.RenewableEnergyConverterTypeA, O, IC, DC, P, F},
PSY.DynamicInverter{PSY.RenewableEnergyConverterTypeA, O, IC, DC, P, F, L},
},
inner_vars::AbstractVector,
) where {
Expand All @@ -26,6 +27,7 @@ function initialize_converter!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
}
#Get inner vars
V_R = inner_vars[Vr_cnv_var]
Expand Down Expand Up @@ -71,7 +73,7 @@ function initialize_converter!(
device_states,
static::PSY.StaticInjection,
dynamic_device::DynamicWrapper{
PSY.DynamicInverter{PSY.RenewableEnergyVoltageConverterTypeA, O, IC, DC, P, F},
PSY.DynamicInverter{PSY.RenewableEnergyVoltageConverterTypeA, O, IC, DC, P, F, L},
},
inner_vars::AbstractVector,
) where {
Expand All @@ -80,6 +82,7 @@ function initialize_converter!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
}
#Get inner vars
Vr_filter = inner_vars[Vr_filter_var]
Expand Down
6 changes: 4 additions & 2 deletions src/initialization/inverter_components/init_filter.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
function initialize_filter!(
device_states,
static::PSY.StaticInjection,
dynamic_device::DynamicWrapper{PSY.DynamicInverter{C, O, IC, DC, P, PSY.LCLFilter}},
dynamic_device::DynamicWrapper{PSY.DynamicInverter{C, O, IC, DC, P, PSY.LCLFilter, L}},
inner_vars::AbstractVector,
) where {
C <: PSY.Converter,
O <: PSY.OuterControl,
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
L <: Union{Nothing, PSY.InverterLimiter},
}
#PowerFlow Data
P0 = PSY.get_active_power(static)
Expand Down Expand Up @@ -92,14 +93,15 @@ end
function initialize_filter!(
device_states,
static::PSY.StaticInjection,
dynamic_device::DynamicWrapper{PSY.DynamicInverter{C, O, IC, DC, P, PSY.RLFilter}},
dynamic_device::DynamicWrapper{PSY.DynamicInverter{C, O, IC, DC, P, PSY.RLFilter, L}},
inner_vars::AbstractVector,
) where {
C <: PSY.Converter,
O <: PSY.OuterControl,
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
L <: Union{Nothing, PSY.InverterLimiter},
}
#PowerFlow Data
P0 = PSY.get_active_power(static)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
function initialize_frequency_estimator!(
device_states,
static::PSY.StaticInjection,
dynamic_device::DynamicWrapper{PSY.DynamicInverter{C, O, IC, DC, PSY.KauraPLL, F}},
dynamic_device::DynamicWrapper{PSY.DynamicInverter{C, O, IC, DC, PSY.KauraPLL, F, L}},
inner_vars::AbstractVector,
) where {
C <: PSY.Converter,
O <: PSY.OuterControl,
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
}
Vr_filter = inner_vars[Vr_filter_var]
Vi_filter = inner_vars[Vi_filter_var]
Expand Down Expand Up @@ -66,7 +67,7 @@ function initialize_frequency_estimator!(
device_states,
static::PSY.StaticInjection,
dynamic_device::DynamicWrapper{
PSY.DynamicInverter{C, O, IC, DC, PSY.ReducedOrderPLL, F},
PSY.DynamicInverter{C, O, IC, DC, PSY.ReducedOrderPLL, F, L},
},
inner_vars::AbstractVector,
) where {
Expand All @@ -75,6 +76,7 @@ function initialize_frequency_estimator!(
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
}
Vr_filter = inner_vars[Vr_filter_var]
Vi_filter = inner_vars[Vi_filter_var]
Expand Down Expand Up @@ -128,7 +130,7 @@ function initialize_frequency_estimator!(
device_states,
static::PSY.StaticInjection,
dynamic_device::DynamicWrapper{
PSY.DynamicInverter{C, O, IC, DC, PSY.FixedFrequency, F},
PSY.DynamicInverter{C, O, IC, DC, PSY.FixedFrequency, F, L},
},
inner_vars::AbstractVector,
) where {
Expand All @@ -137,6 +139,7 @@ function initialize_frequency_estimator!(
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
}
#Get parameters
pll_control = PSY.get_freq_estimator(dynamic_device)
Expand Down
9 changes: 6 additions & 3 deletions src/initialization/inverter_components/init_inner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function initialize_inner!(
device_states,
static::PSY.StaticInjection,
dynamic_device::DynamicWrapper{
PSY.DynamicInverter{C, O, PSY.VoltageModeControl, DC, P, F},
PSY.DynamicInverter{C, O, PSY.VoltageModeControl, DC, P, F, L},
},
inner_vars::AbstractVector,
) where {
Expand All @@ -11,6 +11,7 @@ function initialize_inner!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
}

#Obtain external states inputs for component
Expand Down Expand Up @@ -146,7 +147,7 @@ function initialize_inner!(
device_states,
static::PSY.StaticInjection,
dynamic_device::DynamicWrapper{
PSY.DynamicInverter{C, O, PSY.CurrentModeControl, DC, P, F},
PSY.DynamicInverter{C, O, PSY.CurrentModeControl, DC, P, F, L},
},
inner_vars::AbstractVector,
) where {
Expand All @@ -155,6 +156,7 @@ function initialize_inner!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
}

#Obtain external states inputs for component
Expand Down Expand Up @@ -231,7 +233,7 @@ function initialize_inner!(
device_states,
static::PSY.StaticInjection,
dynamic_device::DynamicWrapper{
PSY.DynamicInverter{C, O, PSY.RECurrentControlB, DC, P, F},
PSY.DynamicInverter{C, O, PSY.RECurrentControlB, DC, P, F, L},
},
inner_vars::AbstractVector,
) where {
Expand All @@ -240,6 +242,7 @@ function initialize_inner!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
}
# Obtain inner variables for component
Vr_filter = inner_vars[Vr_filter_var]
Expand Down
10 changes: 10 additions & 0 deletions src/initialization/inverter_components/init_outer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function initialize_outer!(
DC,
P,
F,
L,
},
},
inner_vars::AbstractVector,
Expand All @@ -18,6 +19,7 @@ function initialize_outer!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
}

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

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

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

#Obtain external states inputs for component
Expand Down Expand Up @@ -283,6 +291,7 @@ function initialize_outer!(
DC,
P,
F,
L,
},
},
inner_vars::AbstractVector,
Expand All @@ -292,6 +301,7 @@ function initialize_outer!(
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
}
# Read inner vars
Vr_filter = inner_vars[Vr_filter_var]
Expand Down
16 changes: 14 additions & 2 deletions src/models/device.jl
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,15 @@ function _update_inner_vars!(
::AbstractArray{<:ACCEPTED_REAL_TYPES},
ω_sys::ACCEPTED_REAL_TYPES,
::AbstractArray{<:ACCEPTED_REAL_TYPES},
dynamic_device::DynamicWrapper{PSY.DynamicInverter{C, O, IC, DC, P, F}},
dynamic_device::DynamicWrapper{PSY.DynamicInverter{C, O, IC, DC, P, F, L}},
) where {
C <: PSY.Converter,
O <: PSY.OuterControl,
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
}
return
end
Expand All @@ -459,13 +460,22 @@ function _update_inner_vars!(
ω_sys::ACCEPTED_REAL_TYPES,
inner_vars::AbstractArray{<:ACCEPTED_REAL_TYPES},
dynamic_device::DynamicWrapper{
PSY.DynamicInverter{PSY.RenewableEnergyConverterTypeA, O, IC, DC, P, PSY.RLFilter},
PSY.DynamicInverter{
PSY.RenewableEnergyConverterTypeA,
O,
IC,
DC,
P,
PSY.RLFilter,
L,
},
},
) where {
O <: PSY.OuterControl,
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
L <: Union{Nothing, PSY.InverterLimiter},
}
V_R = inner_vars[Vr_inv_var]
V_I = inner_vars[Vi_inv_var]
Expand Down Expand Up @@ -578,13 +588,15 @@ function _update_inner_vars!(
DC,
P,
PSY.LCLFilter,
L,
},
},
) where {
O <: PSY.OuterControl,
IC <: PSY.InnerControl,
DC <: PSY.DCSource,
P <: PSY.FrequencyEstimator,
L <: Union{Nothing, PSY.InverterLimiter},
}
filter_ix = get_local_state_ix(dynamic_device, PSY.LCLFilter)
filter_states = @view device_states[filter_ix]
Expand Down
5 changes: 4 additions & 1 deletion src/models/inverter_models/DCside_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ function mdl_DCside_ode!(
::AbstractArray{<:ACCEPTED_REAL_TYPES},
ω_sys::ACCEPTED_REAL_TYPES,
inner_vars::AbstractArray{<:ACCEPTED_REAL_TYPES},
dynamic_device::DynamicWrapper{PSY.DynamicInverter{C, O, IC, PSY.FixedDCSource, P, F}},
dynamic_device::DynamicWrapper{
PSY.DynamicInverter{C, O, IC, PSY.FixedDCSource, P, F, L},
},
) where {
C <: PSY.Converter,
O <: PSY.OuterControl,
IC <: PSY.InnerControl,
P <: PSY.FrequencyEstimator,
F <: PSY.Filter,
L <: Union{Nothing, PSY.InverterLimiter},
}

#Update inner_vars
Expand Down
Loading

0 comments on commit a4e4f4f

Please sign in to comment.