Skip to content

Commit

Permalink
add expressions for AC power
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigomha committed Nov 6, 2024
1 parent b92b651 commit 03fac9b
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
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
45 changes: 45 additions & 0 deletions src/devices_models/device_constructors/branch_constructor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
30 changes: 30 additions & 0 deletions src/devices_models/devices/common/add_to_expression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down

0 comments on commit 03fac9b

Please sign in to comment.