Skip to content

Commit

Permalink
add variables to HVDC models
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigomha committed Jul 27, 2024
1 parent ee17425 commit bfb5a1d
Show file tree
Hide file tree
Showing 4 changed files with 265 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/core/auxiliary_variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,18 @@ Auxiliary Variable for Thermal Generation Models that solve for power above min
"""
struct PowerOutput <: AuxVariableType end

"""
Auxiliary Variable of DC Current Variables for DC Lines formulations
Docs abbreviation: ``i_l^{dc}``
"""
struct DCLineCurrent <: AuxVariableType end

"""
Auxiliary Variable of DC Current Variables for DC Lines formulations
Docs abbreviation: ``p_l^{loss}``
"""
struct DCLineLosses <: AuxVariableType end

convert_result_to_natural_units(::Type{PowerOutput}) = true
2 changes: 1 addition & 1 deletion src/core/formulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ struct LossLessLine <: AbstractBranchFormulation end
"""
DC Loss Line Abstract Model
"""
struct DCLossLine <: AbstractBranchFormulation end
struct DCLossyLine <: AbstractBranchFormulation end

############################## Network Model Formulations ##################################
# These formulations are taken directly from PowerModels
Expand Down
112 changes: 112 additions & 0 deletions src/core/variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,118 @@ Docs abbreviation: ``\\theta``
"""
struct VoltageAngle <: VariableType end

"""
Struct to dispatch the creation of Voltage Variables for DC formulations
Docs abbreviation: ``v^{dc}``
"""
struct DCVoltage <: VariableType end

"""
Struct to dispatch the creation of Squared Voltage Variables for DC formulations
Docs abbreviation: ``v^{sq,dc}``
"""
struct SquaredDCVoltage <: VariableType end

"""
Struct to dispatch the creation of DC Converter Current Variables for DC formulations
Docs abbreviation: ``i_c^{dc}``
"""
struct ConverterCurrent <: VariableType end

"""
Struct to dispatch the creation of Squared DC Converter Current Variables for DC formulations
Docs abbreviation: ``i_c^{sq,dc}``
"""
struct SquaredConverterCurrent <: VariableType end

"""
Struct to dispatch the creation of DC Converter Positive Term Current Variables for DC formulations
Docs abbreviation: ``i_c^{+,dc}``
"""
struct ConverterPositiveCurrent <: VariableType end

"""
Struct to dispatch the creation of DC Converter Negative Term Current Variables for DC formulations
Docs abbreviation: ``i_c^{-,dc}``
"""
struct ConverterNegativeCurrent <: VariableType end

"""
Struct to dispatch the creation of DC Converter Binary for Absolute Value Current Variables for DC formulations
Docs abbreviation: `\\nu_c``
"""
struct ConverterBinaryAbsoluteValueCurrent <: VariableType end

"""
Struct to dispatch the creation of Binary Variable for Converter Power Direction
Docs abbreviation: ``\\kappa_c^{dc}``
"""
struct ConverterPowerDirection <: VariableType end

"""
Struct to dispatch the creation of Auxiliary Variable for Converter Bilinear term: v * i
Docs abbreviation: ``\\gamma_c^{dc}``
"""
struct AuxBilinearConverterVariable <: VariableType end

"""
Struct to dispatch the creation of Auxiliary Variable for Squared Converter Bilinear term: v * i
Docs abbreviation: ``\\gamma_c^{sq,dc}``
"""
struct AuxBilinearSquaredConverterVariable <: VariableType end

"""
Struct to dispatch the creation of Continuous Interpolation Variable for Squared Converter Voltage
Docs abbreviation: ``\\delta_c^{v}``
"""
struct InterpolationSquaredVoltageVariable <: VariableType end

"""
Struct to dispatch the creation of Binary Interpolation Variable for Squared Converter Voltage
Docs abbreviation: ``z_c^{v}``
"""
struct InterpolationBinarySquaredVoltageVariable <: VariableType end

"""
Struct to dispatch the creation of Continuous Interpolation Variable for Squared Converter Current
Docs abbreviation: ``\\delta_c^{i}``
"""
struct InterpolationSquaredCurrentVariable <: VariableType end

"""
Struct to dispatch the creation of Binary Interpolation Variable for Squared Converter Current
Docs abbreviation: ``z_c^{i}``
"""
struct InterpolationBinarySquaredCurrentVariable <: VariableType end

"""
Struct to dispatch the creation of Continuous Interpolation Variable for Squared Converter AuxVar
Docs abbreviation: ``\\delta_c^{\\gamma}``
"""
struct InterpolationSquaredBilinearVariable <: VariableType end

"""
Struct to dispatch the creation of Binary Interpolation Variable for Squared Converter AuxVar
Docs abbreviation: ``z_c^{\\gamma}``
"""
struct InterpolationBinarySquaredBilinearVariable <: VariableType end

"""
Struct to dispatch the creation of bidirectional Active Power Flow Variables
Expand Down
138 changes: 138 additions & 0 deletions src/devices_models/device_constructors/hvdcsystems_constructor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,112 @@ function construct_device!(
return
end

function construct_device!(

Check warning on line 42 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L42

Added line #L42 was not covered by tests
container::OptimizationContainer,
sys::PSY.System,
::ArgumentConstructStage,
model::DeviceModel{PSY.InterconnectingConverter, QuadraticLossConverter},
network_model::NetworkModel{<:PM.AbstractActivePowerModel},
)
devices = get_available_components(

Check warning on line 49 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L49

Added line #L49 was not covered by tests
model,
sys,
)
# Add Power Variable
add_variables!(container, ActivePowerVariable, devices, QuadraticLossConverter()) # p_c
add_variables!(container, ConverterPowerDirection, devices, QuadraticLossConverter()) #κ

Check warning on line 55 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L54-L55

Added lines #L54 - L55 were not covered by tests
# Add Current Variables: i, δ^i, z^i, i+, i-
add_variables!(container, ConverterCurrent, devices, QuadraticLossConverter()) # i
add_variables!(container, SquaredConverterCurrent, devices, QuadraticLossConverter()) # i^sq
add_variables!(

Check warning on line 59 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L57-L59

Added lines #L57 - L59 were not covered by tests
container,
InterpolationSquaredCurrentVariable,
devices,
QuadraticLossConverter(),
) # δ^i
add_variables!(

Check warning on line 65 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L65

Added line #L65 was not covered by tests
container,
InterpolationBinarySquaredCurrentVariable,
devices,
QuadraticLossConverter(),
) # z^i
add_variables!(container, ConverterPositiveCurrent, devices, QuadraticLossConverter()) # i^+
add_variables!(container, ConverterNegativeCurrent, devices, QuadraticLossConverter()) # i^-
add_variables!(

Check warning on line 73 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L71-L73

Added lines #L71 - L73 were not covered by tests
container,
ConverterBinaryAbsoluteValueCurrent,
devices,
QuadraticLossConverter(),
) # ν
# Add Voltage Variables: v^sq, δ^v, z^v
add_variables!(container, SquaredDCVoltage, devices, QuadraticLossConverter())
add_variables!(

Check warning on line 81 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L80-L81

Added lines #L80 - L81 were not covered by tests
container,
InterpolationSquaredVoltageVariable,
devices,
QuadraticLossConverter(),
) # δ^v
add_variables!(

Check warning on line 87 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L87

Added line #L87 was not covered by tests
container,
InterpolationBinarySquaredVoltageVariable,
devices,
QuadraticLossConverter(),
) # z^v
# Add Bilinear Variables: γ, γ^{sq}
add_variables!(

Check warning on line 94 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L94

Added line #L94 was not covered by tests
container,
AuxBilinearConverterVariable,
devices,
QuadraticLossConverter(),
) # γ
add_variables!(

Check warning on line 100 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L100

Added line #L100 was not covered by tests
container,
AuxBilinearSquaredConverterVariable,
devices,
QuadraticLossConverter(),
) # γ^{sq}
add_variables!(

Check warning on line 106 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L106

Added line #L106 was not covered by tests
container,
InterpolationSquaredBilinearVariable,
devices,
QuadraticLossConverter(),
) # δ^γ
add_variables!(

Check warning on line 112 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L112

Added line #L112 was not covered by tests
container,
InterpolationBinarySquaredBilinearVariable,
devices,
QuadraticLossConverter(),
) # z^γ
add_to_expression!(

Check warning on line 118 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L118

Added line #L118 was not covered by tests
container,
ActivePowerBalance,
ActivePowerVariable,
devices,
model,
network_model,
)
add_feedforward_arguments!(container, model, devices)
return

Check warning on line 127 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L126-L127

Added lines #L126 - L127 were not covered by tests
end

function construct_device!(

Check warning on line 130 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L130

Added line #L130 was not covered by tests
container::OptimizationContainer,
sys::PSY.System,
::ModelConstructStage,
model::DeviceModel{PSY.InterconnectingConverter, QuadraticLossConverter},
network_model::NetworkModel{<:PM.AbstractActivePowerModel},
)
devices = get_available_components(

Check warning on line 137 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L137

Added line #L137 was not covered by tests
model,
sys,
)
# TODO Constraints
add_feedforward_constraints!(container, model, devices)
objective_function!(container, devices, model, get_network_formulation(network_model))
add_constraint_dual!(container, sys, model)
return

Check warning on line 145 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L142-L145

Added lines #L142 - L145 were not covered by tests
end

function construct_device!(
container::OptimizationContainer,
sys::PSY.System,
Expand Down Expand Up @@ -71,3 +177,35 @@ function construct_device!(
::NetworkModel{<:PM.AbstractActivePowerModel},
)
end

function construct_device!(

Check warning on line 181 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L181

Added line #L181 was not covered by tests
container::OptimizationContainer,
sys::PSY.System,
::ArgumentConstructStage,
model::DeviceModel{PSY.TModelHVDCLine, DCLossyLine},
network_model::NetworkModel{<:PM.AbstractActivePowerModel},
)
devices = get_available_components(

Check warning on line 188 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L188

Added line #L188 was not covered by tests
model,
sys,
)

dc_buses = PSY.get_components(

Check warning on line 193 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L193

Added line #L193 was not covered by tests
DCBus,
sys,
)
add_variables!(container, DCVoltage, dc_buses, DCLossyLine())
add_variables!(container, DCLineCurrent, devices, DCLossyLine())
add_variables!(container, DCLineLosses, devices, DCLossyLine())
add_feedforward_arguments!(container, model, devices)
return

Check warning on line 201 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L197-L201

Added lines #L197 - L201 were not covered by tests
end

function construct_device!(
::OptimizationContainer,
sys::PSY.System,
::ModelConstructStage,
model::DeviceModel{PSY.TModelHVDCLine, LossLessLine},
::NetworkModel{<:PM.AbstractActivePowerModel},
)

Check warning on line 210 in src/devices_models/device_constructors/hvdcsystems_constructor.jl

View check run for this annotation

Codecov / codecov/patch

src/devices_models/device_constructors/hvdcsystems_constructor.jl#L210

Added line #L210 was not covered by tests
end

0 comments on commit bfb5a1d

Please sign in to comment.