Skip to content

Commit

Permalink
update add to expression for fuel consumption using compact model
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigomha committed Nov 5, 2024
1 parent 1108b6b commit e7ab9a4
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,9 @@ function construct_device!(
if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)
end
if haskey(get_time_series_names(model), FuelCostParameter)
add_parameters!(container, FuelCostParameter, devices, model)
end

add_to_expression!(
container,
Expand Down Expand Up @@ -1004,16 +1007,14 @@ function construct_device!(
model,
network_model,
)
#TODO: Implement for AbovePowerMinimum
#=

add_to_expression!(
container,
FuelConsumptionExpression,
PowerAboveMinimumVariable,,
PowerAboveMinimumVariable,
devices,
model,
)
=#

add_feedforward_arguments!(container, model, devices)
return
Expand Down Expand Up @@ -1119,6 +1120,9 @@ function construct_device!(
if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)
end
if haskey(get_time_series_names(model), FuelCostParameter)
add_parameters!(container, FuelCostParameter, devices, model)
end

add_to_expression!(
container,
Expand Down Expand Up @@ -1157,16 +1161,14 @@ function construct_device!(
model,
network_model,
)
#TODO: Implement for AbovePowerMinimum
#=

add_to_expression!(
container,
FuelConsumptionExpression,
PowerAboveMinimumVariable,,
PowerAboveMinimumVariable,
devices,
model,
)
=#

add_feedforward_arguments!(container, model, devices)
return
Expand Down Expand Up @@ -1271,6 +1273,9 @@ function construct_device!(
if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)
end
if haskey(get_time_series_names(model), FuelCostParameter)
add_parameters!(container, FuelCostParameter, devices, model)
end

add_to_expression!(
container,
Expand Down Expand Up @@ -1308,16 +1313,14 @@ function construct_device!(
model,
network_model,
)
#TODO: Implement for AbovePowerMinimum
#=

add_to_expression!(
container,
FuelConsumptionExpression,
PowerAboveMinimumVariable,,
PowerAboveMinimumVariable,
devices,
model,
)
=#

add_feedforward_arguments!(container, model, devices)
return
Expand Down Expand Up @@ -1406,6 +1409,9 @@ function construct_device!(
if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)
end
if haskey(get_time_series_names(model), FuelCostParameter)
add_parameters!(container, FuelCostParameter, devices, model)
end

add_to_expression!(
container,
Expand Down Expand Up @@ -1443,16 +1449,14 @@ function construct_device!(
model,
network_model,
)
#TODO: Implement for AbovePowerMinimum
#=

add_to_expression!(
container,
FuelConsumptionExpression,
PowerAboveMinimumVariable,,
PowerAboveMinimumVariable,
devices,
model,
)
=#
add_feedforward_arguments!(container, model, devices)
return
end
Expand Down Expand Up @@ -1536,6 +1540,9 @@ function construct_device!(
if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)
end
if haskey(get_time_series_names(model), FuelCostParameter)
add_parameters!(container, FuelCostParameter, devices, model)
end

add_to_expression!(
container,
Expand Down Expand Up @@ -1573,16 +1580,14 @@ function construct_device!(
model,
network_model,
)
#TODO: Implement for AbovePowerMinimum
#=

add_to_expression!(
container,
FuelConsumptionExpression,
PowerAboveMinimumVariable,,
PowerAboveMinimumVariable,
devices,
model,
)
=#

add_feedforward_arguments!(container, model, devices)
return
Expand Down Expand Up @@ -1667,6 +1672,9 @@ function construct_device!(
if haskey(get_time_series_names(model), ActivePowerTimeSeriesParameter)
add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model)
end
if haskey(get_time_series_names(model), FuelCostParameter)
add_parameters!(container, FuelCostParameter, devices, model)
end

add_to_expression!(
container,
Expand Down Expand Up @@ -1704,16 +1712,15 @@ function construct_device!(
model,
network_model,
)
#TODO: Implement for AbovePowerMinimum
#=

add_to_expression!(
container,
FuelConsumptionExpression,
PowerAboveMinimumVariable,,
PowerAboveMinimumVariable,
devices,
model,
)
=#

add_feedforward_arguments!(container, model, devices)
return
end
Expand Down Expand Up @@ -1778,6 +1785,9 @@ function construct_device!(
add_variables!(container, PowerOutput, devices, ThermalCompactDispatch())

add_parameters!(container, OnStatusParameter, devices, model)
if haskey(get_time_series_names(model), FuelCostParameter)
add_parameters!(container, FuelCostParameter, devices, model)
end

add_feedforward_arguments!(container, model, devices)

Expand Down Expand Up @@ -1827,16 +1837,15 @@ function construct_device!(
model,
network_model,
)
#TODO: Implement for AbovePowerMinimum
#=

add_to_expression!(
container,
FuelConsumptionExpression,
PowerAboveMinimumVariable,,
PowerAboveMinimumVariable,
devices,
model,
)
=#

return
end

Expand Down Expand Up @@ -1897,6 +1906,9 @@ function construct_device!(
add_variables!(container, PowerOutput, devices, ThermalCompactDispatch())

add_parameters!(container, OnStatusParameter, devices, model)
if haskey(get_time_series_names(model), FuelCostParameter)
add_parameters!(container, FuelCostParameter, devices, model)
end

add_feedforward_arguments!(container, model, devices)

Expand Down Expand Up @@ -1939,16 +1951,14 @@ function construct_device!(
model,
network_model,
)
#TODO: Implement for AbovePowerMinimum
#=

add_to_expression!(
container,
FuelConsumptionExpression,
PowerAboveMinimumVariable,,
PowerAboveMinimumVariable,
devices,
model,
)
=#
return
end

Expand Down
50 changes: 17 additions & 33 deletions src/devices_models/devices/common/add_to_expression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1630,8 +1630,6 @@ function add_to_expression!(
end
end

#TODO: FuelConsumption for PowerAboveMinimumVariable
#=
function add_to_expression!(
container::OptimizationContainer,
::Type{T},
Expand All @@ -1658,6 +1656,7 @@ function add_to_expression!(
name = PSY.get_name(d)
device_base_power = PSY.get_base_power(d)
value_curve = PSY.get_value_curve(var_cost)
P_min = PSY.get_active_power_limits(d).min
if value_curve isa PSY.LinearCurve
power_units = PSY.get_power_units(var_cost)
proportional_term = PSY.get_proportional_term(value_curve)
Expand All @@ -1668,46 +1667,31 @@ function add_to_expression!(
device_base_power,
)
for t in time_steps
fuel_expr = variable[name, t] * prop_term_per_unit * dt
JuMP.add_to_expression!(
expression[name, t],
fuel_expr,
)
end
elseif value_curve isa PSY.QuadraticCurve
power_units = PSY.get_power_units(var_cost)
proportional_term = PSY.get_proportional_term(value_curve)
quadratic_term = PSY.get_quadratic_term(value_curve)
prop_term_per_unit = get_proportional_cost_per_system_unit(
proportional_term,
power_units,
base_power,
device_base_power,
)
quad_term_per_unit = get_quadratic_cost_per_system_unit(
quadratic_term,
power_units,
base_power,
device_base_power,
)
# TODO: Fix this FuelConsumptionExpression AffExpr to QuadExpr
#=
for t in time_steps
sos_status = _get_sos_value(container, W, d)
if sos_status == SOSStatusVariable.NO_VARIABLE
bin = 1.0
elseif sos_status == SOSStatusVariable.PARAMETER
param = get_default_on_parameter(d)
bin = get_parameter(container, param, V).parameter_array[name, t]
elseif sos_status == SOSStatusVariable.VARIABLE
var = get_default_on_variable(d)
bin = get_variable(container, var, V)[name, t]
else
@assert false
end
fuel_expr =
(
variable[name, t] .^ 2 * quad_term_per_unit +
variable[name, t] * prop_term_per_unit
) * dt
variable[name, t] * prop_term_per_unit * dt +
P_min * bin * prop_term_per_unit * dt
JuMP.add_to_expression!(
expression[name, t],
fuel_expr,
)
end
=#
elseif value_curve isa PSY.QuadraticCurve
error("Quadratic Curves are not accepted with Compact Formulation: $W")
end
end
end
=#

#=
function add_to_expression!(
Expand Down

0 comments on commit e7ab9a4

Please sign in to comment.