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 authored and jd-lara committed Nov 29, 2024
1 parent d3ffc08 commit d68c408
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,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

if haskey(get_time_series_names(model), FuelCostParameter)
add_parameters!(container, FuelCostParameter, devices, model)
Expand Down Expand Up @@ -1010,16 +1013,14 @@ function construct_device!(
model,
network_model,
)
#TODO: Implement for AbovePowerMinimum
#=

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

add_to_expression!(
container,
Expand Down Expand Up @@ -1133,6 +1134,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

if haskey(get_time_series_names(model), FuelCostParameter)
add_parameters!(container, FuelCostParameter, devices, model)
Expand Down Expand Up @@ -1175,16 +1179,14 @@ function construct_device!(
model,
network_model,
)
#TODO: Implement for AbovePowerMinimum
#=

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

add_to_expression!(
container,
Expand Down Expand Up @@ -1297,6 +1299,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

if haskey(get_time_series_names(model), FuelCostParameter)
add_parameters!(container, FuelCostParameter, devices, model)
Expand Down Expand Up @@ -1338,16 +1343,14 @@ function construct_device!(
model,
network_model,
)
#TODO: Implement for AbovePowerMinimum
#=

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

add_to_expression!(
container,
Expand Down Expand Up @@ -1444,6 +1447,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

if haskey(get_time_series_names(model), FuelCostParameter)
add_parameters!(container, FuelCostParameter, devices, model)
Expand Down Expand Up @@ -1576,6 +1582,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

if haskey(get_time_series_names(model), FuelCostParameter)
add_parameters!(container, FuelCostParameter, devices, model)
Expand Down Expand Up @@ -1617,16 +1626,14 @@ function construct_device!(
model,
network_model,
)
#TODO: Implement for AbovePowerMinimum
#=

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

add_to_expression!(
container,
Expand Down Expand Up @@ -1719,6 +1726,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

if haskey(get_time_series_names(model), FuelCostParameter)
add_parameters!(container, FuelCostParameter, devices, model)
Expand Down
48 changes: 17 additions & 31 deletions src/devices_models/devices/common/add_to_expression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,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 @@ -1732,46 +1733,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 d68c408

Please sign in to comment.