Skip to content

Commit

Permalink
Merge pull request #1166 from NREL-Sienna/rh/update_ipc_struct
Browse files Browse the repository at this point in the history
[WIP] Update InterconnectingConverter and HVDC structs
  • Loading branch information
jd-lara authored Oct 1, 2024
2 parents 627078a + 4eb1bea commit 54e11af
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 19 deletions.
21 changes: 18 additions & 3 deletions src/descriptors/power_system_structs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1070,9 +1070,10 @@
},
{
"name": "loss",
"comment": "Linear loss model coefficients, where `l0` = constant loss (MW) and `l1` = linearly proportional loss rate (MW of loss per MW of flow)",
"null_value": "(l0=0.0, l1=0.0)",
"data_type": "NamedTuple{(:l0, :l1), Tuple{Float64, Float64}}"
"comment": "Loss model coefficients. It accepts a linear model with a constant loss (MW) and a proportional loss rate (MW of loss per MW of flow). It also accepts a Piecewise loss, with N segments to specify different proportional losses for different segments.",
"null_value": "LinearCurve(0.0)",
"data_type": "Union{LinearCurve, PiecewiseIncrementalCurve}",
"default": "LinearCurve(0.0)"
},
{
"name": "services",
Expand Down Expand Up @@ -2600,6 +2601,20 @@
},
"validation_action": "warn"
},
{
"name": "dc_current",
"comment": "DC current (A) on the converter",
"null_value": "0.0",
"data_type": "Float64",
"default": "0.0"
},
{
"name": "max_dc_current",
"comment": "Maximum stable dc current limits (A)",
"null_value": "0.0",
"data_type": "Float64",
"default": "1e8"
},
{
"name": "loss_function",
"comment": "Linear or quadratic loss function with respect to the converter current",
Expand Down
26 changes: 22 additions & 4 deletions src/models/generated/InterconnectingConverter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ This file is auto-generated. Do not edit.
rating::Float64
active_power_limits::MinMax
base_power::Float64
dc_current::Float64
max_dc_current::Float64
loss_function::Union{LinearCurve, QuadraticCurve}
services::Vector{Service}
dynamic_injector::Union{Nothing, DynamicInjection}
Expand All @@ -32,6 +34,8 @@ Interconnecting Power Converter (IPC) for transforming power from an ACBus to a
- `rating::Float64`: Maximum output power rating of the converter (MVA), validation range: `(0, nothing)`
- `active_power_limits::MinMax`: Minimum and maximum stable active power levels (MW)
- `base_power::Float64`: Base power of the converter in MVA, validation range: `(0, nothing)`
- `dc_current::Float64`: (default: `0.0`) DC current (A) on the converter
- `max_dc_current::Float64`: (default: `1e8`) Maximum stable dc current limits (A)
- `loss_function::Union{LinearCurve, QuadraticCurve}`: (default: `LinearCurve(0.0)`) Linear or quadratic loss function with respect to the converter current
- `services::Vector{Service}`: (default: `Device[]`) Services that this device contributes to
- `dynamic_injector::Union{Nothing, DynamicInjection}`: (default: `nothing`) corresponding dynamic injection device
Expand All @@ -55,6 +59,10 @@ mutable struct InterconnectingConverter <: StaticInjection
active_power_limits::MinMax
"Base power of the converter in MVA"
base_power::Float64
"DC current (A) on the converter"
dc_current::Float64
"Maximum stable dc current limits (A)"
max_dc_current::Float64
"Linear or quadratic loss function with respect to the converter current"
loss_function::Union{LinearCurve, QuadraticCurve}
"Services that this device contributes to"
Expand All @@ -67,12 +75,12 @@ mutable struct InterconnectingConverter <: StaticInjection
internal::InfrastructureSystemsInternal
end

function InterconnectingConverter(name, available, bus, dc_bus, active_power, rating, active_power_limits, base_power, loss_function=LinearCurve(0.0), services=Device[], dynamic_injector=nothing, ext=Dict{String, Any}(), )
InterconnectingConverter(name, available, bus, dc_bus, active_power, rating, active_power_limits, base_power, loss_function, services, dynamic_injector, ext, InfrastructureSystemsInternal(), )
function InterconnectingConverter(name, available, bus, dc_bus, active_power, rating, active_power_limits, base_power, dc_current=0.0, max_dc_current=1e8, loss_function=LinearCurve(0.0), services=Device[], dynamic_injector=nothing, ext=Dict{String, Any}(), )
InterconnectingConverter(name, available, bus, dc_bus, active_power, rating, active_power_limits, base_power, dc_current, max_dc_current, loss_function, services, dynamic_injector, ext, InfrastructureSystemsInternal(), )
end

function InterconnectingConverter(; name, available, bus, dc_bus, active_power, rating, active_power_limits, base_power, loss_function=LinearCurve(0.0), services=Device[], dynamic_injector=nothing, ext=Dict{String, Any}(), internal=InfrastructureSystemsInternal(), )
InterconnectingConverter(name, available, bus, dc_bus, active_power, rating, active_power_limits, base_power, loss_function, services, dynamic_injector, ext, internal, )
function InterconnectingConverter(; name, available, bus, dc_bus, active_power, rating, active_power_limits, base_power, dc_current=0.0, max_dc_current=1e8, loss_function=LinearCurve(0.0), services=Device[], dynamic_injector=nothing, ext=Dict{String, Any}(), internal=InfrastructureSystemsInternal(), )
InterconnectingConverter(name, available, bus, dc_bus, active_power, rating, active_power_limits, base_power, dc_current, max_dc_current, loss_function, services, dynamic_injector, ext, internal, )
end

# Constructor for demo purposes; non-functional.
Expand All @@ -86,6 +94,8 @@ function InterconnectingConverter(::Nothing)
rating=0.0,
active_power_limits=(min=0.0, max=0.0),
base_power=0.0,
dc_current=0.0,
max_dc_current=0.0,
loss_function=LinearCurve(0.0),
services=Device[],
dynamic_injector=nothing,
Expand All @@ -109,6 +119,10 @@ get_rating(value::InterconnectingConverter) = get_value(value, value.rating)
get_active_power_limits(value::InterconnectingConverter) = get_value(value, value.active_power_limits)
"""Get [`InterconnectingConverter`](@ref) `base_power`."""
get_base_power(value::InterconnectingConverter) = value.base_power
"""Get [`InterconnectingConverter`](@ref) `dc_current`."""
get_dc_current(value::InterconnectingConverter) = value.dc_current
"""Get [`InterconnectingConverter`](@ref) `max_dc_current`."""
get_max_dc_current(value::InterconnectingConverter) = value.max_dc_current
"""Get [`InterconnectingConverter`](@ref) `loss_function`."""
get_loss_function(value::InterconnectingConverter) = value.loss_function
"""Get [`InterconnectingConverter`](@ref) `services`."""
Expand All @@ -134,6 +148,10 @@ set_rating!(value::InterconnectingConverter, val) = value.rating = set_value(val
set_active_power_limits!(value::InterconnectingConverter, val) = value.active_power_limits = set_value(value, val)
"""Set [`InterconnectingConverter`](@ref) `base_power`."""
set_base_power!(value::InterconnectingConverter, val) = value.base_power = val
"""Set [`InterconnectingConverter`](@ref) `dc_current`."""
set_dc_current!(value::InterconnectingConverter, val) = value.dc_current = val
"""Set [`InterconnectingConverter`](@ref) `max_dc_current`."""
set_max_dc_current!(value::InterconnectingConverter, val) = value.max_dc_current = val
"""Set [`InterconnectingConverter`](@ref) `loss_function`."""
set_loss_function!(value::InterconnectingConverter, val) = value.loss_function = val
"""Set [`InterconnectingConverter`](@ref) `services`."""
Expand Down
14 changes: 7 additions & 7 deletions src/models/generated/TwoTerminalHVDCLine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This file is auto-generated. Do not edit.
active_power_limits_to::MinMax
reactive_power_limits_from::MinMax
reactive_power_limits_to::MinMax
loss::NamedTuple{(:l0, :l1), Tuple{Float64, Float64}}
loss::Union{LinearCurve, PiecewiseIncrementalCurve}
services::Vector{Service}
ext::Dict{String, Any}
internal::InfrastructureSystemsInternal
Expand All @@ -33,7 +33,7 @@ This model is appropriate for operational simulations with a linearized DC power
- `active_power_limits_to::MinMax`: Minimum and maximum active power flows to the TO node (MW)
- `reactive_power_limits_from::MinMax`: Minimum and maximum reactive power limits to the FROM node (MVAR)
- `reactive_power_limits_to::MinMax`: Minimum and maximum reactive power limits to the TO node (MVAR)
- `loss::NamedTuple{(:l0, :l1), Tuple{Float64, Float64}}`: Linear loss model coefficients, where `l0` = constant loss (MW) and `l1` = linearly proportional loss rate (MW of loss per MW of flow)
- `loss::Union{LinearCurve, PiecewiseIncrementalCurve}`: (default: `LinearCurve(0.0)`) Loss model coefficients. It accepts a linear model with a constant loss (MW) and a proportional loss rate (MW of loss per MW of flow). It also accepts a Piecewise loss, with N segments to specify different proportional losses for different segments.
- `services::Vector{Service}`: (default: `Device[]`) Services that this device contributes to
- `ext::Dict{String, Any}`: (default: `Dict{String, Any}()`) An [*ext*ra dictionary](@ref additional_fields) for users to add metadata that are not used in simulation, such as latitude and longitude.
- `internal::InfrastructureSystemsInternal`: (**Do not modify.**) PowerSystems.jl internal reference
Expand All @@ -55,8 +55,8 @@ mutable struct TwoTerminalHVDCLine <: ACBranch
reactive_power_limits_from::MinMax
"Minimum and maximum reactive power limits to the TO node (MVAR)"
reactive_power_limits_to::MinMax
"Linear loss model coefficients, where `l0` = constant loss (MW) and `l1` = linearly proportional loss rate (MW of loss per MW of flow)"
loss::NamedTuple{(:l0, :l1), Tuple{Float64, Float64}}
"Loss model coefficients. It accepts a linear model with a constant loss (MW) and a proportional loss rate (MW of loss per MW of flow). It also accepts a Piecewise loss, with N segments to specify different proportional losses for different segments."
loss::Union{LinearCurve, PiecewiseIncrementalCurve}
"Services that this device contributes to"
services::Vector{Service}
"An [*ext*ra dictionary](@ref additional_fields) for users to add metadata that are not used in simulation, such as latitude and longitude."
Expand All @@ -65,11 +65,11 @@ mutable struct TwoTerminalHVDCLine <: ACBranch
internal::InfrastructureSystemsInternal
end

function TwoTerminalHVDCLine(name, available, active_power_flow, arc, active_power_limits_from, active_power_limits_to, reactive_power_limits_from, reactive_power_limits_to, loss, services=Device[], ext=Dict{String, Any}(), )
function TwoTerminalHVDCLine(name, available, active_power_flow, arc, active_power_limits_from, active_power_limits_to, reactive_power_limits_from, reactive_power_limits_to, loss=LinearCurve(0.0), services=Device[], ext=Dict{String, Any}(), )
TwoTerminalHVDCLine(name, available, active_power_flow, arc, active_power_limits_from, active_power_limits_to, reactive_power_limits_from, reactive_power_limits_to, loss, services, ext, InfrastructureSystemsInternal(), )
end

function TwoTerminalHVDCLine(; name, available, active_power_flow, arc, active_power_limits_from, active_power_limits_to, reactive_power_limits_from, reactive_power_limits_to, loss, services=Device[], ext=Dict{String, Any}(), internal=InfrastructureSystemsInternal(), )
function TwoTerminalHVDCLine(; name, available, active_power_flow, arc, active_power_limits_from, active_power_limits_to, reactive_power_limits_from, reactive_power_limits_to, loss=LinearCurve(0.0), services=Device[], ext=Dict{String, Any}(), internal=InfrastructureSystemsInternal(), )
TwoTerminalHVDCLine(name, available, active_power_flow, arc, active_power_limits_from, active_power_limits_to, reactive_power_limits_from, reactive_power_limits_to, loss, services, ext, internal, )
end

Expand All @@ -84,7 +84,7 @@ function TwoTerminalHVDCLine(::Nothing)
active_power_limits_to=(min=0.0, max=0.0),
reactive_power_limits_from=(min=0.0, max=0.0),
reactive_power_limits_to=(min=0.0, max=0.0),
loss=(l0=0.0, l1=0.0),
loss=LinearCurve(0.0),
services=Device[],
ext=Dict{String, Any}(),
)
Expand Down
4 changes: 4 additions & 0 deletions src/models/generated/includes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ export get_d_t
export get_db
export get_dbd_pnts
export get_dc_bus
export get_dc_current
export get_dc_dc_inductor
export get_dc_link_capacitance
export get_delta_t
Expand Down Expand Up @@ -591,6 +592,7 @@ export get_max_constant_active_power
export get_max_constant_reactive_power
export get_max_current_active_power
export get_max_current_reactive_power
export get_max_dc_current
export get_max_impedance_active_power
export get_max_impedance_reactive_power
export get_max_output_fraction
Expand Down Expand Up @@ -1074,6 +1076,7 @@ export set_d_t!
export set_db!
export set_dbd_pnts!
export set_dc_bus!
export set_dc_current!
export set_dc_dc_inductor!
export set_dc_link_capacitance!
export set_delta_t!
Expand Down Expand Up @@ -1159,6 +1162,7 @@ export set_max_constant_active_power!
export set_max_constant_reactive_power!
export set_max_current_active_power!
export set_max_current_reactive_power!
export set_max_dc_current!
export set_max_impedance_active_power!
export set_max_impedance_reactive_power!
export set_max_output_fraction!
Expand Down
64 changes: 64 additions & 0 deletions src/models/supplemental_constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,67 @@ function EnergyReservoirStorage(
internal = internal,
)
end

"""
Deprecated method for TwoTerminalHVDCLine
"""
function TwoTerminalHVDCLine(
name,
available,
active_power_flow,
arc,
active_power_limits_from,
active_power_limits_to,
reactive_power_limits_from,
reactive_power_limits_to,
loss::NamedTuple{(:l0, :l1), Tuple{Float64, Float64}},
services,
ext,
internal,
)
new_loss = LinearCurve(loss.l0, loss.l1)
TwoTerminalHVDCLine(
name,
available,
active_power_flow,
arc,
active_power_limits_from,
active_power_limits_to,
reactive_power_limits_from,
reactive_power_limits_to,
new_loss,
services,
ext,
internal,
)
end

function TwoTerminalHVDCLine(
name,
available,
active_power_flow,
arc,
active_power_limits_from,
active_power_limits_to,
reactive_power_limits_from,
reactive_power_limits_to,
loss::NamedTuple{(:l0, :l1), Tuple{Float64, Float64}},
services = Device[],
ext = Dict{String, Any}(),
)
new_loss = LinearCurve(loss.l0, loss.l1)
TwoTerminalHVDCLine(
name,
available,
active_power_flow,
arc,
active_power_limits_from,
active_power_limits_to,
reactive_power_limits_from,
reactive_power_limits_to,
new_loss,
services,
ext,
InfrastructureSystemsInternal(),
)
end
2 changes: 1 addition & 1 deletion src/parsers/power_models_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ function make_dcline(name::String, d::Dict, bus_f::ACBus, bus_t::ACBus)
active_power_limits_to = (min = d["pmint"], max = d["pmaxt"]),
reactive_power_limits_from = (min = d["qminf"], max = d["qmaxf"]),
reactive_power_limits_to = (min = d["qmint"], max = d["qmaxt"]),
loss = (l0 = d["loss0"], l1 = d["loss1"]),
loss = LinearCurve(d["loss1"], d["loss0"]),
)
end

Expand Down
2 changes: 1 addition & 1 deletion src/parsers/power_system_table_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ function dc_branch_csv_parser!(sys::System, data::PowerSystemTableData)
:max_reactive_power_limit_to,
)

loss = (l0 = 0.0, l1 = dc_branch.loss) #TODO: Can we infer this from the other data?,
loss = LinearCurve(dc_branch.loss) #TODO: Can we infer this from the other data?,

value = TwoTerminalHVDCLine(;
name = dc_branch.name,
Expand Down
4 changes: 2 additions & 2 deletions test/data_14bus_pu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ branches14_dc(nodes14) = [
(min = -600.0, max = 600),
(min = -600.0, max = 600),
(min = -600.0, max = 600),
(l0 = 0.01, l1 = 0.001),
LinearCurve(0.001, 0.01),
),
TwoTerminalHVDCLine(
"DCLine4",
Expand All @@ -200,7 +200,7 @@ branches14_dc(nodes14) = [
(min = -600.0, max = 600),
(min = -600.0, max = 600),
(min = -600.0, max = 600),
(l0 = 0.01, l1 = 0.001),
LinearCurve(0.001, 0.01),
),
#Line("Line3", true, 0.0, 0.0, Arc(from=nodes14[2],to=nodes14[3]), 0.04699, 0.19797, (from=0.0219, to=0.0219), 5.522, 1.04),
#Line("Line4", true, 0.0, 0.0, Arc(from=nodes14[2],to=nodes14[4]), 0.05811, 0.17632, (from=0.017, to=0.017), 6.052, 1.04),
Expand Down
2 changes: 1 addition & 1 deletion test/data_5bus_pu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ branches5_dc(nodes5) = [
(min = -3000, max = 3000),
(min = -3000.0, max = 3000.0),
(min = -3000.0, max = 3000.0),
(l0 = 0.0, l1 = 0.01),
LinearCurve(0.01),
),
Line(
"3",
Expand Down

0 comments on commit 54e11af

Please sign in to comment.