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

Add pwl TwoTerminalHVDC loss model #1132

Merged
merged 22 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ LinearAlgebra = "1"
Logging = "1"
MathOptInterface = "1"
PowerModels = "^0.21"
PowerNetworkMatrices = "^0.11.1"
PowerSystems = "4"
PowerNetworkMatrices = "^0.11"
PowerSystems = "^4.4"
PrettyTables = "2"
ProgressMeter = "^1.5"
Serialization = "1"
Expand Down
17 changes: 1 addition & 16 deletions src/core/constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -332,23 +332,8 @@ The specified constraint is formulated as:
```
"""
struct PhaseAngleControlLimit <: ConstraintType end
"""
Struct to create the constraints that set the losses through a lossy HVDC two-terminal line.

For more information check [Branch Formulations](@ref PowerSystems.Branch-Formulations).

The specified constraints are formulated as:

```math
\\begin{align*}
& f_t^\\text{to-from} - f_t^\\text{from-to} \\le \\ell_t,\\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
& f_t^\\text{from-to} - f_t^\\text{to-from} \\le \\ell_t,\\quad \\forall t \\in \\{1,\\dots, T\\}
\\end{align*}
```
"""
struct HVDCLossesAbsoluteValue <: ConstraintType end
struct HVDCDirection <: ConstraintType end
struct InterfaceFlowLimit <: ConstraintType end
struct HVDCFlowCalculationConstraint <: ConstraintType end

abstract type PowerVariableLimitsConstraint <: ConstraintType end
"""
Expand Down
5 changes: 5 additions & 0 deletions src/core/formulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ struct HVDCTwoTerminalLossless <: AbstractTwoTerminalDCLineFormulation end
Branch type to represent lossy power flow on DC lines
"""
struct HVDCTwoTerminalDispatch <: AbstractTwoTerminalDCLineFormulation end
"""
Branch type to represent piecewise lossy power flow on two terminal DC lines
"""
struct HVDCTwoTerminalPiecewiseLoss <: AbstractTwoTerminalDCLineFormulation end

# Not Implemented
# struct VoltageSourceDC <: AbstractTwoTerminalDCLineFormulation end

Expand Down
30 changes: 30 additions & 0 deletions src/core/variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,36 @@ Docs abbreviation: ``u^\\text{dir}``
"""
struct HVDCFlowDirectionVariable <: VariableType end

"""
Struct to dispatch the creation of HVDC Received Flow at From Bus Variables for PWL formulations

Docs abbreviation: ``x``
"""
struct HVDCActivePowerReceivedFromVariable <: VariableType end

"""
Struct to dispatch the creation of HVDC Received Flow at To Bus Variables for PWL formulations

Docs abbreviation: ``y``
"""
struct HVDCActivePowerReceivedToVariable <: VariableType end

abstract type SparseVariableType <: VariableType end

"""
Struct to dispatch the creation of HVDC Piecewise Loss Variables

Docs abbreviation: ``h`` or ``w``
"""
struct HVDCPiecewiseLossVariable <: SparseVariableType end

"""
Struct to dispatch the creation of HVDC Piecewise Binary Loss Variables

Docs abbreviation: ``z``
"""
struct HVDCPiecewiseBinaryLossVariable <: SparseVariableType end

"""
Struct to dispatch the creation of piecewise linear cost variables for objective function

Expand Down Expand Up @@ -274,6 +302,8 @@ const START_VARIABLES = (HotStartVariable, WarmStartVariable, ColdStartVariable)

should_write_resulting_value(::Type{PieceWiseLinearCostVariable}) = false
should_write_resulting_value(::Type{PieceWiseLinearBlockOffer}) = false
should_write_resulting_value(::Type{HVDCPiecewiseLossVariable}) = false
should_write_resulting_value(::Type{HVDCPiecewiseBinaryLossVariable}) = false
convert_result_to_natural_units(::Type{ActivePowerVariable}) = true
convert_result_to_natural_units(::Type{PowerAboveMinimumVariable}) = true
convert_result_to_natural_units(::Type{ActivePowerInVariable}) = true
Expand Down
132 changes: 130 additions & 2 deletions src/devices_models/device_constructors/branch_constructor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,6 @@ function construct_device!(
add_constraints!(container, FlowRateConstraintFromTo, devices, model, network_model)
add_constraints!(container, FlowRateConstraintToFrom, devices, model, network_model)
add_constraints!(container, HVDCPowerBalance, devices, model, network_model)
add_constraints!(container, HVDCLossesAbsoluteValue, devices, model, network_model)
return
end

Expand All @@ -719,6 +718,7 @@ function construct_device!(
HVDCTwoTerminalDispatch(),
)
add_variables!(container, HVDCFlowDirectionVariable, devices, HVDCTwoTerminalDispatch())
add_variables!(container, HVDCLosses, devices, HVDCTwoTerminalDispatch())
add_to_expression!(
container,
ActivePowerBalance,
Expand Down Expand Up @@ -754,6 +754,135 @@ function construct_device!(
return
end

function construct_device!(
container::OptimizationContainer,
sys::PSY.System,
::ArgumentConstructStage,
model::DeviceModel{T, U},
network_model::NetworkModel{<:AbstractPTDFModel},
) where {
T <: TwoTerminalHVDCTypes,
U <: HVDCTwoTerminalPiecewiseLoss,
}
devices =
get_available_components(model, sys)
add_variables!(
container,
HVDCActivePowerReceivedFromVariable,
devices,
HVDCTwoTerminalPiecewiseLoss(),
)
add_variables!(
container,
HVDCActivePowerReceivedToVariable,
devices,
HVDCTwoTerminalPiecewiseLoss(),
)
_add_sparse_pwl_loss_variables!(container, devices, model)
add_to_expression!(
container,
ActivePowerBalance,
HVDCActivePowerReceivedFromVariable,
devices,
model,
network_model,
)
add_to_expression!(
container,
ActivePowerBalance,
HVDCActivePowerReceivedToVariable,
devices,
model,
network_model,
)
return
end

function construct_device!(
container::OptimizationContainer,
sys::PSY.System,
::ModelConstructStage,
model::DeviceModel{T, U},
network_model::NetworkModel{<:AbstractPTDFModel},
) where {
T <: TwoTerminalHVDCTypes,
U <: HVDCTwoTerminalPiecewiseLoss,
}
devices =
get_available_components(model, sys)
add_constraints!(container, FlowRateConstraintFromTo, devices, model, network_model)
add_constraints!(container, FlowRateConstraintToFrom, devices, model, network_model)
add_constraints!(
container,
HVDCFlowCalculationConstraint,
devices,
model,
network_model,
)
return
end

# TODO: Other models besides PTDF
#=
function construct_device!(
container::OptimizationContainer,
sys::PSY.System,
::ArgumentConstructStage,
model::DeviceModel{T, HVDCTwoTerminalPiecewiseLoss},
network_model::NetworkModel{<:PM.AbstractActivePowerModel},
) where {T <: TwoTerminalHVDCTypes}
devices =
get_available_components(model, sys)
add_variables!(
container,
FlowActivePowerToFromVariable,
devices,
HVDCTwoTerminalDispatch(),
)
add_variables!(
container,
FlowActivePowerFromToVariable,
devices,
HVDCTwoTerminalDispatch(),
)
add_variables!(container, HVDCFlowDirectionVariable, devices, HVDCTwoTerminalDispatch())
add_to_expression!(
container,
ActivePowerBalance,
FlowActivePowerToFromVariable,
devices,
model,
network_model,
)
add_to_expression!(
container,
ActivePowerBalance,
FlowActivePowerFromToVariable,
devices,
model,
network_model,
)
add_feedforward_arguments!(container, model, devices)
return
end

function construct_device!(
container::OptimizationContainer,
sys::PSY.System,
::ModelConstructStage,
model::DeviceModel{T, HVDCTwoTerminalPiecewiseLoss},
network_model::NetworkModel{CopperPlatePowerModel},
) where {T <: TwoTerminalHVDCTypes}
devices =
get_available_components(model, sys)
@warn "CopperPlatePowerModel models with HVDC ignores inter-area losses"
add_constraints!(container, FlowRateConstraintFromTo, devices, model, network_model)
add_constraints!(container, FlowRateConstraintToFrom, devices, model, network_model)
add_constraint_dual!(container, sys, model)
return
end
=#

function construct_device!(
container::OptimizationContainer,
sys::PSY.System,
Expand All @@ -765,7 +894,6 @@ function construct_device!(
add_constraints!(container, FlowRateConstraintFromTo, devices, model, network_model)
add_constraints!(container, FlowRateConstraintToFrom, devices, model, network_model)
add_constraints!(container, HVDCPowerBalance, devices, model, network_model)
add_constraints!(container, HVDCDirection, devices, model, network_model)
add_constraint_dual!(container, sys, model)
add_feedforward_constraints!(container, model, devices)
return
Expand Down
Loading
Loading