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 VSC Two Terminal Loss Model #1167

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c1c4aae
add vars and constraints
rodrigomha Oct 22, 2024
b24e022
add constructors
rodrigomha Oct 22, 2024
ca75343
update constructor with from and to vars
rodrigomha Oct 24, 2024
a53150a
add bounds for variables
rodrigomha Oct 24, 2024
62f59d3
add constraints
rodrigomha Oct 24, 2024
fdd267d
add pwl variables
rodrigomha Oct 29, 2024
46ccb06
update name to VSC loss
rodrigomha Oct 29, 2024
9ba6e4c
remove comments
rodrigomha Oct 29, 2024
fc0acc5
add interpolation methods
rodrigomha Oct 30, 2024
70c9ce9
add constraints names for interpolation
rodrigomha Oct 30, 2024
91786f0
remove writing of interpolation vars
rodrigomha Oct 30, 2024
1352eb7
add interpolation constraints
rodrigomha Oct 30, 2024
84b8aa0
add converter and losses constraints
rodrigomha Nov 4, 2024
5dc59d1
update name of variable to DC send
rodrigomha Nov 5, 2024
8446e26
add exports
rodrigomha Nov 5, 2024
c67f721
add tests
rodrigomha Nov 5, 2024
b92b651
add losses to power balance
rodrigomha Nov 6, 2024
03fac9b
add expressions for AC power
rodrigomha Nov 6, 2024
bf97f1f
add Bilinear Formulation
rodrigomha Dec 16, 2024
feadaef
add constructor for bilinear method
rodrigomha Dec 16, 2024
5ca5287
add new constraints and expressions for bilinear
rodrigomha Dec 16, 2024
8fb3a8f
update powermodels translator
rodrigomha Dec 16, 2024
78584b8
update bilinear test
rodrigomha Dec 16, 2024
3d972ac
add quadratic formulation
rodrigomha Dec 16, 2024
f66f138
add constructor for quadratic model
rodrigomha Dec 16, 2024
391a45a
add constraints and expressions for quadratic hvdc model
rodrigomha Dec 16, 2024
ead0aef
update power models parser for quadratic vsc
rodrigomha Dec 16, 2024
82682d0
update tests
rodrigomha Dec 16, 2024
ed7c2d8
update exports
rodrigomha Dec 16, 2024
a9e6fa3
fix docstrings typos
rodrigomha Dec 20, 2024
789a383
update converting results of hvdc vars
rodrigomha Dec 20, 2024
16385db
update direction of loss balance
rodrigomha Dec 20, 2024
4bbd086
update docs for hvdc formulations
rodrigomha Dec 20, 2024
63fbdf6
formatter
rodrigomha Dec 20, 2024
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
34 changes: 34 additions & 0 deletions docs/src/api/PowerSimulations.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,28 @@ FlowReactivePowerToFromVariable
PhaseShifterAngle
HVDCLosses
HVDCFlowDirectionVariable
HVDCActivePowerReceivedFromVariable
HVDCActivePowerReceivedToVariable
HVDCPiecewiseLossVariable
HVDCPiecewiseBinaryLossVariable
HVDCActiveDCPowerSentFromVariable
HVDCActiveDCPowerSentToVariable
HVDCReactivePowerSentFromVariable
HVDCReactivePowerSentToVariable
ConverterPowerDirection
DCVoltageFrom
DCVoltageTo
SquaredDCVoltageFrom
SquaredDCVoltageTo
ConverterCurrent
SquaredConverterCurrent
ConverterPositiveCurrent
ConverterNegativeCurrent
ConverterCurrentDirection
AuxBilinearConverterVariableFrom
AuxBilinearSquaredConverterVariableFrom
AuxBilinearConverterVariableTo
AuxBilinearSquaredConverterVariableTo
VoltageMagnitude
VoltageAngle
```
Expand Down Expand Up @@ -281,6 +303,18 @@ FlowRateConstraintFromTo
FlowRateConstraintToFrom
HVDCPowerBalance
NetworkFlowConstraint
ConverterPowerCalculationConstraint
ConverterDirectionConstraint
ConverterCurrentBalanceConstraint
ConverterMcCormickEnvelopes
InterpolationVoltageConstraints
InterpolationCurrentConstraints
InterpolationBilinearConstraints
CurrentAbsoluteValueConstraint
ConverterLossesCalculationConstraint
ConverterPowerBalanceConstraint
ConverterACPowerCalculationConstraint
FlowApparentPowerLimitConstraint
RateLimitConstraint
PhaseAngleControlLimit
```
Expand Down
430 changes: 428 additions & 2 deletions docs/src/formulation_library/Branch.md

Large diffs are not rendered by default.

42 changes: 41 additions & 1 deletion src/PowerSimulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export HVDCTwoTerminalLossless
export HVDCTwoTerminalDispatch
export HVDCTwoTerminalUnbounded
export PhaseAngleControl
export HVDCTwoTerminalPiecewiseLoss
export HVDCTwoTerminalVSCLoss
export HVDCTwoTerminalVSCLossBilinear
export HVDCTwoTerminalVSCLossQuadratic
# export VoltageSourceDC

######## HVDC models ########
Expand Down Expand Up @@ -233,6 +237,29 @@ export LowerBoundFeedForwardSlack
export InterfaceFlowSlackUp
export InterfaceFlowSlackDown
export PieceWiseLinearCostVariable
export HVDCActivePowerReceivedFromVariable
export HVDCActivePowerReceivedToVariable
export HVDCPiecewiseLossVariable
export HVDCPiecewiseBinaryLossVariable
export HVDCActiveDCPowerSentFromVariable
export HVDCActiveDCPowerSentToVariable
export HVDCReactivePowerSentFromVariable
export HVDCReactivePowerSentToVariable
export ConverterPowerDirection
export DCVoltageFrom
export DCVoltageTo
export SquaredDCVoltageFrom
export SquaredDCVoltageTo
export ConverterCurrent
export SquaredConverterCurrent
export ConverterPositiveCurrent
export ConverterNegativeCurrent
export ConverterCurrentDirection
export HVDCLosses
export AuxBilinearConverterVariableFrom
export AuxBilinearSquaredConverterVariableFrom
export AuxBilinearConverterVariableTo
export AuxBilinearSquaredConverterVariableTo

# Auxiliary variables
export TimeDurationOn
Expand Down Expand Up @@ -270,8 +297,19 @@ export FlowReactivePowerFromToConstraint
export FlowReactivePowerToFromConstraint
export FrequencyResponseConstraint
export HVDCPowerBalance
export HVDCLosses
export HVDCFlowDirectionVariable
export ConverterACPowerCalculationConstraint
export ConverterCurrentBalanceConstraint
export ConverterLossesCalculationConstraint
export FlowApparentPowerLimitConstraint
export ConverterPowerBalanceConstraint
export ConverterPowerCalculationConstraint
export ConverterDirectionConstraint
export ConverterMcCormickEnvelopes
export InterpolationVoltageConstraints
export InterpolationCurrentConstraints
export InterpolationBilinearConstraints
export CurrentAbsoluteValueConstraint
export InputActivePowerVariableLimitsConstraint
export NetworkFlowConstraint
export NodalBalanceActiveConstraint
Expand Down Expand Up @@ -325,6 +363,8 @@ export RawACE
export ProductionCostExpression
export ActivePowerRangeExpressionLB
export ActivePowerRangeExpressionUB
export ReceivedHVDCActivePowerFromExpression
export ReceivedHVDCActivePowerToExpression

#################################################################################
# Imports
Expand Down
187 changes: 187 additions & 0 deletions src/core/constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ struct InterfaceFlowLimit <: ConstraintType end
struct HVDCFlowCalculationConstraint <: ConstraintType end

abstract type PowerVariableLimitsConstraint <: ConstraintType end

"""
Struct to create the constraint to limit active power input expressions.
For more information check [Device Formulations](@ref formulation_intro).
Expand Down Expand Up @@ -401,3 +402,189 @@ struct LineFlowBoundConstraint <: ConstraintType end

abstract type EventConstraint <: ConstraintType end
struct OutageConstraint <: EventConstraint end

################ HVDC VSC McCormick Model ##################

"""
Struct to create the constraints that set the losses through a lossy Interconnecting Power Converter.

The specified constraint is formulated as:
```math
\\begin{align*}
& i_c^{dc} = \\sum_{j \\in \\mathcal{B}^{DC}} \\frac{1}{r_{i,j}} (v_i - v_j), \\quad \\forall t \\in \\{1,\\dots, T\\}
\\end{align*}
```
"""
struct ConverterCurrentBalanceConstraint <: ConstraintType end

"""
Struct to create the constraints that compute the converter DC power based on current and voltage.

The specified constraints are formulated as:
```math
\\begin{align*}
& p_c = 0.5 \\cdot (γ^{sq} - v^{sq} - i^{sq}), \\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
& γ_c = v_c + i_c, \\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
\\end{align*}
```
"""
struct ConverterPowerCalculationConstraint <: ConstraintType end

"""
Struct to create the constraints that decide the operation direction of the converter.

The specified constraints are formulated as:
```math
\\begin{align*}
& I_c^{min} (1 - κ_c) \\le i_c \\le κ_c * I_c^{max}, \\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
& P_c^{min} (1 - κ_c) \\le p_c \\le κ_c * P_c^{max}, \\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
\\end{align*}
```
"""
struct ConverterDirectionConstraint <: ConstraintType end

"""
Struct to create the McCormick envelopes constraints that decide the bounds on the DC active power.

The specified constraints are formulated as:
```math
\\begin{align*}
& p_c \\ge V^{min} i_c + v_c I^{min} - I^{min}V^{min}, \\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
& p_c \\ge V^{max} i_c + v_c I^{max} - I^{max}V^{max}, \\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
& p_c \\le V^{max} i_c + v_c I^{min} - I^{min}V^{max}, \\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
& p_c \\le V^{min} i_c + v_c I^{max} - I^{max}V^{min}, \\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
\\end{align*}
```
"""
struct ConverterMcCormickEnvelopes <: ConstraintType end

"""
Struct to create the Quadratic PWL interpolation constraints that decide square value of the voltage.
In this case x = voltage and y = squared_voltage.

The specified constraints are formulated as:
```math
\\begin{align*}
& x = x_0 + \\sum_{k=1}^K (x_{k} - x_{k-1}) \\delta_k, \\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
& y = y_0 + \\sum_{k=1}^K (x_{k} - x_{k-1}) \\delta_k, \\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
& z_k \\le \\delta_k, \\quad \\forall t \\in \\{1,\\dots, T\\}, \\forall k \\in \\{1,\\dots, K-1\\} \\\\
& z_k \\ge \\delta_{k+1}, \\quad \\forall t \\in \\{1,\\dots, T\\}, \\forall k \\in \\{1,\\dots, K-1\\} \\\\
\\end{align*}
```
"""
struct InterpolationVoltageConstraints <: ConstraintType end

"""
Struct to create the Quadratic PWL interpolation constraints that decide square value of the current.
In this case x = current and y = squared_current.

The specified constraints are formulated as:
```math
\\begin{align*}
& x = x_0 + \\sum_{k=1}^K (x_{k} - x_{k-1}) \\delta_k, \\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
& y = y_0 + \\sum_{k=1}^K (x_{k} - x_{k-1}) \\delta_k, \\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
& z_k \\le \\delta_k, \\quad \\forall t \\in \\{1,\\dots, T\\}, \\forall k \\in \\{1,\\dots, K-1\\} \\\\
& z_k \\ge \\delta_{k+1}, \\quad \\forall t \\in \\{1,\\dots, T\\}, \\forall k \\in \\{1,\\dots, K-1\\} \\\\
\\end{align*}
```
"""
struct InterpolationCurrentConstraints <: ConstraintType end

"""
Struct to create the Quadratic PWL interpolation constraints that decide square value of the bilinear variable γ.
In this case x = γ and y = squared_γ.

The specified constraints are formulated as:
```math
\\begin{align*}
& x = x_0 + \\sum_{k=1}^K (x_{k} - x_{k-1}) \\delta_k, \\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
& y = y_0 + \\sum_{k=1}^K (x_{k} - x_{k-1}) \\delta_k, \\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
& z_k \\le \\delta_k, \\quad \\forall t \\in \\{1,\\dots, T\\}, \\forall k \\in \\{1,\\dots, K-1\\} \\\\
& z_k \\ge \\delta_{k+1}, \\quad \\forall t \\in \\{1,\\dots, T\\}, \\forall k \\in \\{1,\\dots, K-1\\} \\\\
\\end{align*}
```
"""
struct InterpolationBilinearConstraints <: ConstraintType end

"""
Struct to create the constraints that set the absolute value for the current to use in losses through a lossy Interconnecting Power Converter.

The specified constraint is formulated as:
```math
\\begin{align*}
& i_c^{dc} = i_c^+ - i_c^-, \\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
& i_c^+ \\le I_{max} \\cdot \\nu_c, \\quad \\forall t \\in \\{1,\\dots, T\\} \\\\
& i_c^+ \\le I_{max} \\cdot (1 - \\nu_c), \\quad \\forall t \\in \\{1,\\dots, T\\}
\\end{align*}
```
"""
struct CurrentAbsoluteValueConstraint <: ConstraintType end

"""
Struct to create the constraints that set the losses for the converter to use in losses through a lossy Interconnecting Power Converter.

The specified constraint for the bilinear model is formulated as:
```math
\\begin{align*}
& p_c^{loss} = a_c + b_c |i_c| + c_c i_c^2, \\quad \\forall t \\in \\{1,\\dots, T\\}
\\end{align*}
```

For the quadratic model is formulated as:
```math
\\begin{align*}
& p_c^{loss} = a_c + b_c |p_c^{from}| + c_c (p_c^{from})^2, \\quad \\forall t \\in \\{1,\\dots, T\\}
\\end{align*}
```
"""
struct ConverterLossesCalculationConstraint <: ConstraintType end

################ HVDC VSC AC Bilinear Model ##################

"""
Struct to create the constraints that compute the converter DC power based on current and voltage.

The specified constraints are formulated as:
```math
\\begin{align*}
& p_c = v_c \\cdot i_c, \\quad \\forall t \\in \\{1,\\dots, T\\}
\\end{align*}
```
"""
struct ConverterACPowerCalculationConstraint <: ConstraintType end

"""
Struct to create the constraints that decide the operation direction of the converter.

The specified constraints are formulated as:
```math
\\begin{align*}
& p_c * i_c \\ge 0.0, \\quad \\forall t \\in \\{1,\\dots, T\\}
\\end{align*}
```
"""
struct ConverterACDirectionConstraint <: ConstraintType end

"""
Struct to create the constraints that decide the flow apparent power limits to the VSC Line.

The specified constraints are formulated as:
```math
\\begin{align*}
& p_c^2 + q_c^2 \\le rating^2, \\quad \\forall t \\in \\{1,\\dots, T\\}
\\end{align*}
```
"""
struct FlowApparentPowerLimitConstraint <: ConstraintType end

"""
Struct to create the constraints that balance the DC Power to the VSC Line.

The specified constraints are formulated as:
```math
\\begin{align*}
& p_c^{from} = - p_c^{to} - p_c^{loss}, \\quad \\forall t \\in \\{1,\\dots, T\\}
\\end{align*}
```
"""
struct ConverterPowerBalanceConstraint <: ConstraintType end
7 changes: 6 additions & 1 deletion src/core/definitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ const JuMPFloatMatrix = DenseAxisArray{Float64, 2}
const JuMPFloatArray = DenseAxisArray{Float64}
const JuMPVariableArray = DenseAxisArray{JuMP.VariableRef}

const TwoTerminalHVDCTypes = Union{PSY.TwoTerminalHVDCLine, PSY.TwoTerminalVSCDCLine}
const TwoTerminalHVDCTypes = Union{
PSY.TwoTerminalHVDCLine,
PSY.TwoTerminalVSCDCLine,
PSY.TwoTerminalVSCLine,
}
# Settings constants
const UNSET_HORIZON = Dates.Millisecond(0)
const UNSET_RESOLUTION = Dates.Millisecond(0)
Expand All @@ -61,6 +65,7 @@ const OBJECTIVE_FUNCTION_NEGATIVE = -1.0
const INITIALIZATION_PROBLEM_HORIZON_COUNT = 3
# The DEFAULT_RESERVE_COST value is used to avoid degeneracy of the solutions, reserve cost isn't provided.
const DEFAULT_RESERVE_COST = 1.0
const DEFAULT_INTERPOLATION_LENGTH = 4
const KiB = 1024
const MiB = KiB * KiB
const GiB = MiB * KiB
Expand Down
4 changes: 4 additions & 0 deletions src/core/expressions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ struct ActivePowerRangeExpressionLB <: RangeConstraintLBExpressions end
struct ActivePowerRangeExpressionUB <: RangeConstraintUBExpressions end
struct ComponentReserveUpBalanceExpression <: ExpressionType end
struct ComponentReserveDownBalanceExpression <: ExpressionType end
struct ReceivedHVDCActivePowerFromExpression <: ExpressionType end
struct ReceivedHVDCActivePowerToExpression <: ExpressionType end
struct InterfaceTotalFlow <: ExpressionType end
struct PTDFBranchFlow <: ExpressionType end

Expand All @@ -20,5 +22,7 @@ should_write_resulting_value(::Type{InterfaceTotalFlow}) = true
should_write_resulting_value(::Type{RawACE}) = true
should_write_resulting_value(::Type{ActivePowerBalance}) = true
should_write_resulting_value(::Type{ReactivePowerBalance}) = true
should_write_resulting_value(::Type{ReceivedHVDCActivePowerFromExpression}) = true
should_write_resulting_value(::Type{ReceivedHVDCActivePowerToExpression}) = true

convert_result_to_natural_units(::Type{InterfaceTotalFlow}) = true
14 changes: 13 additions & 1 deletion src/core/formulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,21 @@ 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
Branch type to represent piecewise lossy power flow (with respect to power) on two terminal DC lines
"""
struct HVDCTwoTerminalPiecewiseLoss <: AbstractTwoTerminalDCLineFormulation end
"""
Branch type to represent physical lossy model on two terminal DC lines using interpolation methods for quadratic losses
"""
struct HVDCTwoTerminalVSCLoss <: AbstractTwoTerminalDCLineFormulation end
"""
Branch type to represent physical lossy model using a bilinear model. Only usable with AC Network Models.
"""
struct HVDCTwoTerminalVSCLossBilinear <: AbstractTwoTerminalDCLineFormulation end
"""
Branch type to represent physical lossy model using a quadratic loss model with respect to power. Only usable with AC Network Models.
"""
struct HVDCTwoTerminalVSCLossQuadratic <: AbstractTwoTerminalDCLineFormulation end

# Not Implemented
# struct VoltageSourceDC <: AbstractTwoTerminalDCLineFormulation end
Expand Down
Loading
Loading