diff --git a/src/core/expressions.jl b/src/core/expressions.jl index f5ad354a7..5b957cc7b 100644 --- a/src/core/expressions.jl +++ b/src/core/expressions.jl @@ -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 @@ -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 diff --git a/src/devices_models/device_constructors/branch_constructor.jl b/src/devices_models/device_constructors/branch_constructor.jl index 6cf32a5c6..de6b3e9e8 100644 --- a/src/devices_models/device_constructors/branch_constructor.jl +++ b/src/devices_models/device_constructors/branch_constructor.jl @@ -961,6 +961,51 @@ function construct_device!( ##################### #### Expressions #### ##################### + add_expressions!( + container, + ReceivedHVDCActivePowerFromExpression, + devices, + model, + ) + add_expressions!( + container, + ReceivedHVDCActivePowerToExpression, + devices, + model, + ) + + add_to_expression!( + container, + ReceivedHVDCActivePowerFromExpression, + HVDCActiveDCPowerSentFromVariable, + devices, + model, + network_model, + ) + add_to_expression!( + container, + ReceivedHVDCActivePowerFromExpression, + HVDCLosses, + devices, + model, + network_model, + ) + add_to_expression!( + container, + ReceivedHVDCActivePowerToExpression, + HVDCActiveDCPowerSentToVariable, + devices, + model, + network_model, + ) + add_to_expression!( + container, + ReceivedHVDCActivePowerToExpression, + HVDCLosses, + devices, + model, + network_model, + ) # HVDCActivePowerReceivedFromVariable: DC Power Received on From Bus add_to_expression!( diff --git a/src/devices_models/devices/common/add_to_expression.jl b/src/devices_models/devices/common/add_to_expression.jl index fd8ef08b8..172abcda0 100644 --- a/src/devices_models/devices/common/add_to_expression.jl +++ b/src/devices_models/devices/common/add_to_expression.jl @@ -565,6 +565,36 @@ function add_to_expression!( return end +function add_to_expression!( + container::OptimizationContainer, + ::Type{T}, + ::Type{U}, + devices::IS.FlattenIteratorWrapper{V}, + ::DeviceModel{V, W}, + network_model::NetworkModel{X}, +) where { + T <: Union{ReceivedHVDCActivePowerFromExpression, ReceivedHVDCActivePowerToExpression}, + U <: + Union{HVDCActiveDCPowerSentFromVariable, HVDCActiveDCPowerSentToVariable, HVDCLosses}, + V <: TwoTerminalHVDCTypes, + W <: HVDCTwoTerminalVSCLoss, + X <: AbstractPTDFModel, +} + variable = get_variable(container, U(), V) + expression = get_expression(container, T(), V) + for d in devices + name = PSY.get_name(d) + for t in get_time_steps(container) + _add_to_jump_expression!( + expression[name, t], + variable[name, t], + -1.0, + ) + end + end + return +end + """ Default implementation to add branch variables to SystemBalanceExpressions """