Skip to content

Commit

Permalink
Merge pull request #1014 from NREL-Sienna/rh/add_currentlims_to_psy3
Browse files Browse the repository at this point in the history
Add current lims to psy3
  • Loading branch information
jd-lara committed Sep 12, 2023
2 parents 1454cf0 + 871b134 commit 3fff8dc
Show file tree
Hide file tree
Showing 10 changed files with 336 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/PowerSystems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ export VoltageModeControl
export CurrentModeControl
export RECurrentControlB

# InverterLimiters Export
export MagnitudeCurrentLimiter
export InstantaneousCurrentLimiter
export PriorityCurrentLimiter

export Source
export PeriodicVariableSource

Expand Down
89 changes: 89 additions & 0 deletions src/descriptors/power_system_structs.json
Original file line number Diff line number Diff line change
Expand Up @@ -15039,6 +15039,95 @@
],
"supertype": "InnerControl"
},
{
"struct_name": "MagnitudeCurrentLimiter",
"docstring": "Parameters of Magnitude (Circular) Current Controller Limiter",
"fields": [
{
"name": "I_max",
"comment": "Maximum limit on current controller input current (device base)",
"null_value": 0,
"data_type": "Float64",
"valid_range": {
"min": 0,
"max": null
}
},
{
"name": "ext",
"data_type": "Dict{String, Any}",
"null_value": "Dict{String, Any}()",
"default": "Dict{String, Any}()"
}
],
"supertype": "InverterLimiter"
},
{
"struct_name": "InstantaneousCurrentLimiter",
"docstring": "Parameters of Instantaneous (Square) Current Controller Limiter",
"fields": [
{
"name": "Id_max",
"comment": "Maximum limit on d-axis current controller input current (device base)",
"null_value": 0,
"data_type": "Float64",
"valid_range": {
"min": 0,
"max": null
}
},
{
"name": "Iq_max",
"comment": "Maximum limit on d-axis current controller input current (device base)",
"null_value": 0,
"data_type": "Float64",
"valid_range": {
"min": 0,
"max": null
}
},
{
"name": "ext",
"data_type": "Dict{String, Any}",
"null_value": "Dict{String, Any}()",
"default": "Dict{String, Any}()"
}
],
"supertype": "InverterLimiter"
},
{
"struct_name": "PriorityCurrentLimiter",
"docstring": "Parameters of Priority-Based Current Controller Limiter",
"fields": [
{
"name": "I_max",
"comment": "Maximum limit on current controller input current (device base)",
"null_value": 0,
"data_type": "Float64",
"valid_range": {
"min": 0,
"max": null
}
},
{
"name": "ϕ_I",
"comment": "Pre-defined angle (measured against the d-axis) for Iref once limit is hit",
"null_value": 0,
"data_type": "Float64",
"valid_range": {
"min": -1.571,
"max": 1.571
}
},
{
"name": "ext",
"data_type": "Dict{String, Any}",
"null_value": "Dict{String, Any}()",
"default": "Dict{String, Any}()"
}
],
"supertype": "InverterLimiter"
},
{
"struct_name": "AggregateDistributedGenerationA",
"docstring": "Parameters of the DERA1 model in PSS/E",
Expand Down
12 changes: 11 additions & 1 deletion src/models/dynamic_inverter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ abstract type InverterComponent <: DynamicComponent end
dc_source::DC
freq_estimator::P
filter::F
limiter::Union{nothing, InverterLimiter}
base_power::Float64
n_states::Int
states::Vector{Symbol}
Expand All @@ -36,6 +37,7 @@ a DC Source, a Frequency Estimator and a Filter. It requires a Static Injection
- `dc_source <: DCSource`: DC Source model.
- `freq_estimator <: FrequencyEstimator`: Frequency Estimator (typically a PLL) model.
- `filter <: Filter`: Filter model.
- `limiter <: Union{nothing, InverterLimiter}`: Inverter Inner Control Limiter model
- `base_power::Float64`: Base power
- `n_states::Int`: Number of states (will depend on the components).
- `states::Vector{Symbol}`: Vector of states (will depend on the components).
Expand All @@ -49,6 +51,7 @@ mutable struct DynamicInverter{
DC <: DCSource,
P <: FrequencyEstimator,
F <: Filter,
L <: Union{Nothing, InverterLimiter},
} <: DynamicInjection
name::String
ω_ref::Float64
Expand All @@ -58,6 +61,7 @@ mutable struct DynamicInverter{
dc_source::DC
freq_estimator::P
filter::F
limiter::L
base_power::Float64
n_states::Int
states::Vector{Symbol}
Expand All @@ -74,6 +78,7 @@ function DynamicInverter(
dc_source::DC,
freq_estimator::P,
filter::F,
limiter::L = nothing,
base_power::Float64 = 100.0,
ext::Dict{String, Any} = Dict{String, Any}(),
) where {
Expand All @@ -83,6 +88,7 @@ function DynamicInverter(
DC <: DCSource,
P <: FrequencyEstimator,
F <: Filter,
L <: Union{Nothing, InverterLimiter},
}
n_states = _calc_n_states(
converter,
Expand All @@ -101,7 +107,7 @@ function DynamicInverter(
filter,
)

return DynamicInverter{C, O, IC, DC, P, F}(
return DynamicInverter{C, O, IC, DC, P, F, L}(
name,
ω_ref,
converter,
Expand All @@ -110,6 +116,7 @@ function DynamicInverter(
dc_source,
freq_estimator,
filter,
limiter,
base_power,
n_states,
states,
Expand All @@ -127,6 +134,7 @@ function DynamicInverter(;
dc_source::DC,
freq_estimator::P,
filter::F,
limiter::L = nothing,
base_power::Float64 = 100.0,
n_states = _calc_n_states(
converter,
Expand All @@ -153,6 +161,7 @@ function DynamicInverter(;
DC <: DCSource,
P <: FrequencyEstimator,
F <: Filter,
L <: Union{Nothing, InverterLimiter},
}
return DynamicInverter(
name,
Expand All @@ -163,6 +172,7 @@ function DynamicInverter(;
dc_source,
freq_estimator,
filter,
limiter,
base_power,
n_states,
states,
Expand Down
1 change: 1 addition & 0 deletions src/models/dynamic_inverter_components.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ abstract type DCSource <: DynamicInverterComponent end
abstract type Filter <: DynamicInverterComponent end
abstract type FrequencyEstimator <: DynamicInverterComponent end
abstract type InnerControl <: DynamicInverterComponent end
abstract type InverterLimiter <: DynamicInverterComponent end

abstract type ActivePowerControl <: DeviceParameter end
abstract type ReactivePowerControl <: DeviceParameter end
55 changes: 55 additions & 0 deletions src/models/generated/InstantaneousCurrentLimiter.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#=
This file is auto-generated. Do not edit.
=#

#! format: off

"""
mutable struct InstantaneousCurrentLimiter <: InverterLimiter
Id_max::Float64
Iq_max::Float64
ext::Dict{String, Any}
end
Parameters of Instantaneous (Square) Current Controller Limiter
# Arguments
- `Id_max::Float64`: Maximum limit on d-axis current controller input current (device base), validation range: `(0, nothing)`
- `Iq_max::Float64`: Maximum limit on d-axis current controller input current (device base), validation range: `(0, nothing)`
- `ext::Dict{String, Any}`
"""
mutable struct InstantaneousCurrentLimiter <: InverterLimiter
"Maximum limit on d-axis current controller input current (device base)"
Id_max::Float64
"Maximum limit on d-axis current controller input current (device base)"
Iq_max::Float64
ext::Dict{String, Any}
end


function InstantaneousCurrentLimiter(; Id_max, Iq_max, ext=Dict{String, Any}(), )
InstantaneousCurrentLimiter(Id_max, Iq_max, ext, )
end

# Constructor for demo purposes; non-functional.
function InstantaneousCurrentLimiter(::Nothing)
InstantaneousCurrentLimiter(;
Id_max=0,
Iq_max=0,
ext=Dict{String, Any}(),
)
end

"""Get [`InstantaneousCurrentLimiter`](@ref) `Id_max`."""
get_Id_max(value::InstantaneousCurrentLimiter) = value.Id_max
"""Get [`InstantaneousCurrentLimiter`](@ref) `Iq_max`."""
get_Iq_max(value::InstantaneousCurrentLimiter) = value.Iq_max
"""Get [`InstantaneousCurrentLimiter`](@ref) `ext`."""
get_ext(value::InstantaneousCurrentLimiter) = value.ext

"""Set [`InstantaneousCurrentLimiter`](@ref) `Id_max`."""
set_Id_max!(value::InstantaneousCurrentLimiter, val) = value.Id_max = val
"""Set [`InstantaneousCurrentLimiter`](@ref) `Iq_max`."""
set_Iq_max!(value::InstantaneousCurrentLimiter, val) = value.Iq_max = val
"""Set [`InstantaneousCurrentLimiter`](@ref) `ext`."""
set_ext!(value::InstantaneousCurrentLimiter, val) = value.ext = val
46 changes: 46 additions & 0 deletions src/models/generated/MagnitudeCurrentLimiter.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#=
This file is auto-generated. Do not edit.
=#

#! format: off

"""
mutable struct MagnitudeCurrentLimiter <: InverterLimiter
I_max::Float64
ext::Dict{String, Any}
end
Parameters of Magnitude (Circular) Current Controller Limiter
# Arguments
- `I_max::Float64`: Maximum limit on current controller input current (device base), validation range: `(0, nothing)`
- `ext::Dict{String, Any}`
"""
mutable struct MagnitudeCurrentLimiter <: InverterLimiter
"Maximum limit on current controller input current (device base)"
I_max::Float64
ext::Dict{String, Any}
end


function MagnitudeCurrentLimiter(; I_max, ext=Dict{String, Any}(), )
MagnitudeCurrentLimiter(I_max, ext, )
end

# Constructor for demo purposes; non-functional.
function MagnitudeCurrentLimiter(::Nothing)
MagnitudeCurrentLimiter(;
I_max=0,
ext=Dict{String, Any}(),
)
end

"""Get [`MagnitudeCurrentLimiter`](@ref) `I_max`."""
get_I_max(value::MagnitudeCurrentLimiter) = value.I_max
"""Get [`MagnitudeCurrentLimiter`](@ref) `ext`."""
get_ext(value::MagnitudeCurrentLimiter) = value.ext

"""Set [`MagnitudeCurrentLimiter`](@ref) `I_max`."""
set_I_max!(value::MagnitudeCurrentLimiter, val) = value.I_max = val
"""Set [`MagnitudeCurrentLimiter`](@ref) `ext`."""
set_ext!(value::MagnitudeCurrentLimiter, val) = value.ext = val
55 changes: 55 additions & 0 deletions src/models/generated/PriorityCurrentLimiter.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#=
This file is auto-generated. Do not edit.
=#

#! format: off

"""
mutable struct PriorityCurrentLimiter <: InverterLimiter
I_max::Float64
ϕ_I::Float64
ext::Dict{String, Any}
end
Parameters of Priority-Based Current Controller Limiter
# Arguments
- `I_max::Float64`: Maximum limit on current controller input current (device base), validation range: `(0, nothing)`
- `ϕ_I::Float64`: Pre-defined angle (measured against the d-axis) for Iref once limit is hit, validation range: `(-1.571, 1.571)`
- `ext::Dict{String, Any}`
"""
mutable struct PriorityCurrentLimiter <: InverterLimiter
"Maximum limit on current controller input current (device base)"
I_max::Float64
"Pre-defined angle (measured against the d-axis) for Iref once limit is hit"
ϕ_I::Float64
ext::Dict{String, Any}
end


function PriorityCurrentLimiter(; I_max, ϕ_I, ext=Dict{String, Any}(), )
PriorityCurrentLimiter(I_max, ϕ_I, ext, )
end

# Constructor for demo purposes; non-functional.
function PriorityCurrentLimiter(::Nothing)
PriorityCurrentLimiter(;
I_max=0,
ϕ_I=0,
ext=Dict{String, Any}(),
)
end

"""Get [`PriorityCurrentLimiter`](@ref) `I_max`."""
get_I_max(value::PriorityCurrentLimiter) = value.I_max
"""Get [`PriorityCurrentLimiter`](@ref) `ϕ_I`."""
get_ϕ_I(value::PriorityCurrentLimiter) = value.ϕ_I
"""Get [`PriorityCurrentLimiter`](@ref) `ext`."""
get_ext(value::PriorityCurrentLimiter) = value.ext

"""Set [`PriorityCurrentLimiter`](@ref) `I_max`."""
set_I_max!(value::PriorityCurrentLimiter, val) = value.I_max = val
"""Set [`PriorityCurrentLimiter`](@ref) `ϕ_I`."""
set_ϕ_I!(value::PriorityCurrentLimiter, val) = value.ϕ_I = val
"""Set [`PriorityCurrentLimiter`](@ref) `ext`."""
set_ext!(value::PriorityCurrentLimiter, val) = value.ext = val
Loading

0 comments on commit 3fff8dc

Please sign in to comment.