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 fuel cost time series parameters methods #1164

Closed
wants to merge 166 commits into from
Closed
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
e5a9870
update fuelcost param changes
rodrigomha Oct 15, 2024
677a8a3
change file name to avoid confussion
jd-lara Oct 13, 2024
e74a139
add ts parameter calls in constructor
jd-lara Oct 13, 2024
a8d9f28
add constraint call
jd-lara Oct 13, 2024
4c29c68
add checks for ts property
jd-lara Oct 13, 2024
9324ae7
improve error print
jd-lara Oct 13, 2024
b4ac3d6
add multiplier function
jd-lara Oct 13, 2024
f409dcf
add constructor test
jd-lara Oct 13, 2024
5bd5dff
fix test
jd-lara Oct 13, 2024
792e547
comment out unrelated broken method
jd-lara Oct 13, 2024
46085e7
add missing ts check
jd-lara Oct 13, 2024
4ba5a3b
update fuelcost param changes
rodrigomha Oct 15, 2024
f69b942
add new params and exprs
rodrigomha Oct 15, 2024
27d80fc
update device model to take any parameter type
rodrigomha Oct 15, 2024
93a8fa2
[WIP] update abstract thermal dispatch to include fuel expressions
rodrigomha Oct 15, 2024
deef888
update thermal time series
rodrigomha Oct 15, 2024
10d60f3
update expression for fuel consumption
rodrigomha Oct 15, 2024
97156f5
add fuel cost timeseries for linear
rodrigomha Oct 15, 2024
8ecdd21
add fuel cost params methods
rodrigomha Oct 15, 2024
8d7eab2
Merge branch 'jd/add_thermal_time_series' into rhjd/add_fuelcost_para…
rodrigomha Oct 15, 2024
73528eb
remove commented error
rodrigomha Oct 15, 2024
06a4253
add export
rodrigomha Oct 16, 2024
3582a85
add write result
rodrigomha Oct 16, 2024
97f6de3
avoid mutation of invariant terms
rodrigomha Oct 16, 2024
2aecfd5
add quadratic and dt to fuel consumption
rodrigomha Oct 16, 2024
04b4dc4
Add parameter for fuel cost
rodrigomha Oct 16, 2024
50f7ed4
update getter for fuel cost pwl
rodrigomha Oct 16, 2024
3d74a48
update linear and quadratic methods to use new function
rodrigomha Oct 16, 2024
d20061c
add expressions for all formulations
rodrigomha Oct 17, 2024
33017ab
add fuel cost test
rodrigomha Oct 17, 2024
1108b6b
move cost term around to update objective function with variable fuel…
rodrigomha Nov 5, 2024
e7ab9a4
update add to expression for fuel consumption using compact model
rodrigomha Nov 5, 2024
a6aae9d
update function call for onvar cost
rodrigomha Nov 5, 2024
8cf452d
add test quad + pwl
rodrigomha Nov 6, 2024
f481ae3
update fuelcost param changes
rodrigomha Oct 15, 2024
04611f7
add checks for ts property
jd-lara Oct 13, 2024
c89a618
add multiplier function
jd-lara Oct 13, 2024
cbc0dea
update fuelcost param changes
rodrigomha Oct 15, 2024
8492c1e
add new params and exprs
rodrigomha Oct 15, 2024
c1a183e
update device model to take any parameter type
rodrigomha Oct 15, 2024
5e99091
[WIP] update abstract thermal dispatch to include fuel expressions
rodrigomha Oct 15, 2024
570d40a
update thermal time series
rodrigomha Oct 15, 2024
07db443
update expression for fuel consumption
rodrigomha Oct 15, 2024
1e551fc
add fuel cost timeseries for linear
rodrigomha Oct 15, 2024
a558a7c
add fuel cost params methods
rodrigomha Oct 15, 2024
77ffe6a
remove commented error
rodrigomha Oct 15, 2024
dd52f07
add export
rodrigomha Oct 16, 2024
9d40def
add write result
rodrigomha Oct 16, 2024
f6a354f
avoid mutation of invariant terms
rodrigomha Oct 16, 2024
601552f
add quadratic and dt to fuel consumption
rodrigomha Oct 16, 2024
7021b68
Add parameter for fuel cost
rodrigomha Oct 16, 2024
04ba101
update getter for fuel cost pwl
rodrigomha Oct 16, 2024
2f48f70
update linear and quadratic methods to use new function
rodrigomha Oct 16, 2024
56f50fc
add expressions for all formulations
rodrigomha Oct 17, 2024
87b37f6
add fuel cost test
rodrigomha Oct 17, 2024
9bb2825
move cost term around to update objective function with variable fuel…
rodrigomha Nov 5, 2024
0d379e3
update add to expression for fuel consumption using compact model
rodrigomha Nov 5, 2024
5bd6c5c
update function call for onvar cost
rodrigomha Nov 5, 2024
271a08f
add test quad + pwl
rodrigomha Nov 6, 2024
4aaa44d
Merge branch 'rhjd/add_fuelcost_parameter' of https://github.com/NREL…
jd-lara Nov 29, 2024
30e2477
change time variant check
jd-lara Nov 29, 2024
cc0fae3
update fuelcost param changes
rodrigomha Oct 15, 2024
0dbadb5
add checks for ts property
jd-lara Oct 13, 2024
cf14b5f
add multiplier function
jd-lara Oct 13, 2024
00e31dc
update fuelcost param changes
rodrigomha Oct 15, 2024
b79192d
add new params and exprs
rodrigomha Oct 15, 2024
edac1fb
update device model to take any parameter type
rodrigomha Oct 15, 2024
aef24c3
[WIP] update abstract thermal dispatch to include fuel expressions
rodrigomha Oct 15, 2024
fc8a812
update thermal time series
rodrigomha Oct 15, 2024
1c5d06a
update expression for fuel consumption
rodrigomha Oct 15, 2024
5c65714
add fuel cost timeseries for linear
rodrigomha Oct 15, 2024
52806cc
add fuel cost params methods
rodrigomha Oct 15, 2024
832843a
remove commented error
rodrigomha Oct 15, 2024
cbf0ce5
add export
rodrigomha Oct 16, 2024
cfb6b21
add write result
rodrigomha Oct 16, 2024
206ebf9
avoid mutation of invariant terms
rodrigomha Oct 16, 2024
6f3db17
add quadratic and dt to fuel consumption
rodrigomha Oct 16, 2024
ea427fd
Add parameter for fuel cost
rodrigomha Oct 16, 2024
2c858be
update getter for fuel cost pwl
rodrigomha Oct 16, 2024
d09adbb
update linear and quadratic methods to use new function
rodrigomha Oct 16, 2024
bf741f6
add expressions for all formulations
rodrigomha Oct 17, 2024
4036189
add fuel cost test
rodrigomha Oct 17, 2024
14dd6ad
move cost term around to update objective function with variable fuel…
rodrigomha Nov 5, 2024
d1e3c16
update add to expression for fuel consumption using compact model
rodrigomha Nov 5, 2024
2f97e2b
update function call for onvar cost
rodrigomha Nov 5, 2024
74fca02
add test quad + pwl
rodrigomha Nov 6, 2024
2920c61
update fuelcost param changes
rodrigomha Oct 15, 2024
9a2f870
add ts parameter calls in constructor
jd-lara Oct 13, 2024
1e2a3ad
fix test
jd-lara Oct 13, 2024
922b4c8
comment out unrelated broken method
jd-lara Oct 13, 2024
067d29a
add new params and exprs
rodrigomha Oct 15, 2024
6615a86
[WIP] update abstract thermal dispatch to include fuel expressions
rodrigomha Oct 15, 2024
9c6434f
update thermal time series
rodrigomha Oct 15, 2024
d3ffc08
add expressions for all formulations
rodrigomha Oct 17, 2024
d68c408
update add to expression for fuel consumption using compact model
rodrigomha Nov 5, 2024
43f6048
change time variant check
jd-lara Nov 29, 2024
2c19c7b
Merge branch 'rhjd/add_fuelcost_parameter' of https://github.com/NREL…
jd-lara Nov 29, 2024
84f1624
remove duplicate call
jd-lara Nov 29, 2024
c992da5
change variable name
jd-lara Nov 29, 2024
1e2bdab
change expression addition dispatch
jd-lara Nov 29, 2024
04b7d07
remove unused parameter call
jd-lara Nov 29, 2024
bf76d05
formatter
jd-lara Nov 29, 2024
8f13a5a
add missing parameter additions
jd-lara Nov 30, 2024
5e7a3cb
update test
jd-lara Nov 30, 2024
ed6210d
update test
jd-lara Nov 30, 2024
f57fb0d
update has series checks
jd-lara Nov 30, 2024
8f82b1b
update fuelcost param changes
rodrigomha Oct 15, 2024
31b80a8
add checks for ts property
jd-lara Oct 13, 2024
cc043ba
add multiplier function
jd-lara Oct 13, 2024
5dec088
update fuelcost param changes
rodrigomha Oct 15, 2024
c6ede7f
add new params and exprs
rodrigomha Oct 15, 2024
66f8e4e
update device model to take any parameter type
rodrigomha Oct 15, 2024
3665812
[WIP] update abstract thermal dispatch to include fuel expressions
rodrigomha Oct 15, 2024
6e0cdee
update thermal time series
rodrigomha Oct 15, 2024
2d62272
update expression for fuel consumption
rodrigomha Oct 15, 2024
0266fcb
add fuel cost timeseries for linear
rodrigomha Oct 15, 2024
f70978f
add fuel cost params methods
rodrigomha Oct 15, 2024
043392f
remove commented error
rodrigomha Oct 15, 2024
5bba013
add export
rodrigomha Oct 16, 2024
2c6936e
add write result
rodrigomha Oct 16, 2024
1a30308
avoid mutation of invariant terms
rodrigomha Oct 16, 2024
ab5e77e
add quadratic and dt to fuel consumption
rodrigomha Oct 16, 2024
bda36e6
Add parameter for fuel cost
rodrigomha Oct 16, 2024
e684e7b
update getter for fuel cost pwl
rodrigomha Oct 16, 2024
7e21890
update linear and quadratic methods to use new function
rodrigomha Oct 16, 2024
d501061
add expressions for all formulations
rodrigomha Oct 17, 2024
ef7d41b
add fuel cost test
rodrigomha Oct 17, 2024
15eb3bb
move cost term around to update objective function with variable fuel…
rodrigomha Nov 5, 2024
1bf2525
update add to expression for fuel consumption using compact model
rodrigomha Nov 5, 2024
b06ab22
update function call for onvar cost
rodrigomha Nov 5, 2024
09ed67e
add test quad + pwl
rodrigomha Nov 6, 2024
5afd716
update fuelcost param changes
rodrigomha Oct 15, 2024
21dc6ae
add ts parameter calls in constructor
jd-lara Oct 13, 2024
0d9c443
fix test
jd-lara Oct 13, 2024
4b0cb8e
comment out unrelated broken method
jd-lara Oct 13, 2024
9b3a774
add new params and exprs
rodrigomha Oct 15, 2024
53f15c9
[WIP] update abstract thermal dispatch to include fuel expressions
rodrigomha Oct 15, 2024
38bb16d
update thermal time series
rodrigomha Oct 15, 2024
0ea26a2
add expressions for all formulations
rodrigomha Oct 17, 2024
40d0920
update add to expression for fuel consumption using compact model
rodrigomha Nov 5, 2024
170d4b0
change time variant check
jd-lara Nov 29, 2024
9254592
update fuelcost param changes
rodrigomha Oct 15, 2024
a24db57
add checks for ts property
jd-lara Oct 13, 2024
c916e23
add new params and exprs
rodrigomha Oct 15, 2024
2f4c56a
[WIP] update abstract thermal dispatch to include fuel expressions
rodrigomha Oct 15, 2024
1e9f0e9
update thermal time series
rodrigomha Oct 15, 2024
bdd4957
add expressions for all formulations
rodrigomha Oct 17, 2024
faeeb29
update add to expression for fuel consumption using compact model
rodrigomha Nov 5, 2024
0139381
update fuelcost param changes
rodrigomha Oct 15, 2024
7511abe
fix test
jd-lara Oct 13, 2024
a233ea9
comment out unrelated broken method
jd-lara Oct 13, 2024
9c07202
add new params and exprs
rodrigomha Oct 15, 2024
90c9751
[WIP] update abstract thermal dispatch to include fuel expressions
rodrigomha Oct 15, 2024
d10613b
update thermal time series
rodrigomha Oct 15, 2024
d9d06e0
add expressions for all formulations
rodrigomha Oct 17, 2024
f984b61
update add to expression for fuel consumption using compact model
rodrigomha Nov 5, 2024
4341277
change variable name
jd-lara Nov 29, 2024
8e25260
change expression addition dispatch
jd-lara Nov 29, 2024
f30e8c1
remove unused parameter call
jd-lara Nov 29, 2024
b9db7c7
formatter
jd-lara Nov 29, 2024
4e1ffbb
add missing parameter additions
jd-lara Nov 30, 2024
f902467
update test
jd-lara Nov 30, 2024
78d7410
update test
jd-lara Nov 30, 2024
96641ef
update has series checks
jd-lara Nov 30, 2024
f839665
remove stale code
rodrigomha Dec 4, 2024
5555932
Merge branch 'rhjd/add_fuelcost_parameter' of https://github.com/NREL…
rodrigomha Dec 4, 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
2 changes: 1 addition & 1 deletion src/core/device_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ mutable struct DeviceModel{D <: PSY.Device, B <: AbstractDeviceFormulation}
use_slacks::Bool
duals::Vector{DataType}
services::Vector{ServiceModel}
time_series_names::Dict{Type{<:TimeSeriesParameter}, String}
time_series_names::Dict{Type{<:PSI.ParameterType}, String}
attributes::Dict{String, Any}
subsystem::Union{Nothing, String}

Expand Down
1 change: 1 addition & 0 deletions src/core/expressions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct EmergencyUp <: ExpressionType end
struct EmergencyDown <: ExpressionType end
struct RawACE <: ExpressionType end
struct ProductionCostExpression <: CostExpressions end
struct FuelConsumptionExpression <: ExpressionType end
struct ActivePowerRangeExpressionLB <: RangeConstraintLBExpressions end
struct ActivePowerRangeExpressionUB <: RangeConstraintUBExpressions end
struct ComponentReserveUpBalanceExpression <: ExpressionType end
Expand Down
5 changes: 5 additions & 0 deletions src/core/parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ Parameter to define cost function coefficient
"""
struct CostFunctionParameter <: ObjectiveFunctionParameter end

"""
Parameter to define fuel cost time series
"""
struct FuelCostParameter <: ObjectiveFunctionParameter end

abstract type AuxVariableValueParameter <: RightHandSideParameter end

struct EventParameter <: ParameterType end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,10 @@ function construct_device!(

add_variables!(container, ActivePowerVariable, devices, D())

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

add_to_expression!(
container,
ActivePowerBalance,
Expand All @@ -800,6 +804,8 @@ function construct_device!(

add_expressions!(container, ProductionCostExpression, devices, model)

add_expressions!(container, FuelConsumptionExpression, devices, model)

add_to_expression!(
container,
ActivePowerRangeExpressionLB,
Expand All @@ -816,6 +822,13 @@ function construct_device!(
model,
network_model,
)
add_to_expression!(
container,
FuelConsumptionExpression,
ActivePowerVariable,
devices,
model,
)

add_feedforward_arguments!(container, model, devices)
return
Expand Down
65 changes: 65 additions & 0 deletions src/devices_models/devices/common/add_to_expression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ function add_expressions!(
return
end

function add_expressions!(
container::OptimizationContainer,
::Type{T},
devices::U,
model::DeviceModel{D, W},
) where {
T <: FuelConsumptionExpression,
U <: Union{Vector{D}, IS.FlattenIteratorWrapper{D}},
W <: AbstractDeviceFormulation,
} where {D <: PSY.Component}
time_steps = get_time_steps(container)
names = [
PSY.get_name(d) for
d in devices if PSY.get_variable(PSY.get_operation_cost(d)) isa PSY.FuelCurve
]
add_expression_container!(container, T(), D, names, time_steps)
return
end

function add_expressions!(
container::OptimizationContainer,
::Type{T},
Expand Down Expand Up @@ -1533,6 +1552,52 @@ function add_to_expression!(
return
end

function add_to_expression!(
container::OptimizationContainer,
::Type{T},
::Type{U},
devices::IS.FlattenIteratorWrapper{V},
model::DeviceModel{V, W},
) where {
T <: FuelConsumptionExpression,
U <: ActivePowerVariable,
V <: PSY.ThermalGen,
W <: AbstractThermalDispatchFormulation,
}
expression = get_expression(container, T(), V)
variable = get_variable(container, U(), V)
time_steps = get_time_steps(container)
base_power = get_base_power(container)
for d in devices
var_cost = PSY.get_variable(PSY.get_operation_cost(d))
if !(var_cost isa PSY.FuelCurve)
continue
end
name = PSY.get_name(d)
device_base_power = PSY.get_base_power(d)
value_curve = PSY.get_value_curve(var_cost)
if value_curve isa PSY.LinearCurve
power_units = PSY.get_power_units(var_cost)
proportional_term = PSY.get_proportional_term(value_curve)
prop_term_per_unit = get_proportional_cost_per_system_unit(
proportional_term,
power_units,
base_power,
device_base_power,
)
for t in time_steps
fuel_expr = variable[name, t] * prop_term_per_unit
JuMP.add_to_expression!(
expression[name, t],
fuel_expr,
)
end
else
error("Not implemented yet")
end
end
end

#=
function add_to_expression!(
container::OptimizationContainer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,26 @@ end
function _add_fuel_linear_variable_cost!(
container::OptimizationContainer,
::T,
component::PSY.Component,
fuel_curve::Float64,
component::V,
heat_rate::Float64, # already normalized in MMBTU/p.u.
fuel_cost::IS.TimeSeriesKey,
) where {T <: VariableType}
error("Not implemented yet")
_add_linearcurve_variable_cost!(container, T(), component, fuel_curve)
) where {T <: VariableType, V <: PSY.Component}
parameter = get_parameter_array(container, FuelCostParameter(), V)
multiplier = get_parameter_multiplier_array(container, FuelCostParameter(), V)
expression = get_expression(container, FuelConsumptionExpression(), V)
name = PSY.get_name(component)
for t in get_time_steps(container)
cost_expr = expression[name, t] * parameter[name, t] * multiplier[name, t]
add_to_expression!(
container,
ProductionCostExpression,
cost_expr,
component,
t,
)
add_to_objective_variant_expression!(container, cost_expr)
end
return
end

"""
Expand Down
5 changes: 4 additions & 1 deletion src/devices_models/devices/thermal_generation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ get_variable_binary(::Union{ColdStartVariable, WarmStartVariable, HotStartVariab

########################### Parameter related set functions ################################
get_multiplier_value(::ActivePowerTimeSeriesParameter, d::PSY.ThermalGen, ::AbstractThermalFormulation) = PSY.get_max_active_power(d)
get_multiplier_value(::FuelCostParameter, d::PSY.ThermalGen, ::AbstractThermalFormulation) = 1.0
get_parameter_multiplier(::VariableValueParameter, d::PSY.ThermalGen, ::AbstractThermalFormulation) = 1.0
get_initial_parameter_value(::VariableValueParameter, d::PSY.ThermalGen, ::AbstractThermalFormulation) = 1.0
get_expression_multiplier(::OnStatusParameter, ::ActivePowerRangeExpressionUB, d::PSY.ThermalGen, ::AbstractThermalFormulation) = PSY.get_active_power_limits(d).max
Expand Down Expand Up @@ -194,7 +195,9 @@ function get_default_time_series_names(
::Type{U},
::Type{V},
) where {U <: PSY.ThermalGen, V <: Union{FixedOutput, AbstractThermalFormulation}}
return Dict{Type{<:TimeSeriesParameter}, String}()
return Dict{Any, String}(
FuelCostParameter => "fuel_cost",
)
end

function get_default_attributes(
Expand Down
63 changes: 62 additions & 1 deletion src/parameters/add_parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ function add_parameters!(
return
end

function add_parameters!(
container::OptimizationContainer,
::Type{T},
devices::U,
model::DeviceModel{D, W},
) where {
T <: FuelCostParameter,
U <: Union{Vector{D}, IS.FlattenIteratorWrapper{D}},
W <: AbstractDeviceFormulation,
} where {D <: PSY.Component}
if get_rebuild_model(get_settings(container)) && has_container_key(container, T, D)
return
end
_add_parameters!(container, T(), devices, model)
return
end

function add_parameters!(
container::OptimizationContainer,
::Type{T},
Expand Down Expand Up @@ -256,7 +273,51 @@ function _add_parameters!(
U <: Union{Vector{D}, IS.FlattenIteratorWrapper{D}},
W <: AbstractDeviceFormulation,
} where {D <: PSY.Component}
_add_time_series_parameters!(container, param, devices, model)
ts_type = get_default_time_series_type(container)
if !(ts_type <: Union{PSY.AbstractDeterministic, PSY.StaticTimeSeries})
error("add_parameters! for TimeSeriesParameter is not compatible with $ts_type")
jd-lara marked this conversation as resolved.
Show resolved Hide resolved
end
time_steps = get_time_steps(container)
# TODO: Check for timeseries only for fuel cost
device_names = [PSY.get_name(x) for x in devices if PSY.has_time_series(x)]
jump_model = get_jump_model(container)

param_container = add_param_container!(
container,
param,
D,
ActivePowerVariable,
PSI.SOSStatusVariable.NO_VARIABLE,
false,
Float64,
device_names,
time_steps,
)

ts_name = get_time_series_names(model)[T]

for device in devices
if !PSY.has_time_series(device)
continue
end
ts_vals = get_time_series_initial_values!(container, ts_type, device, ts_name)
name = PSY.get_name(device)
for step in time_steps
PSI.set_parameter!(
param_container,
jump_model,
ts_vals[step],
name,
step,
)
PSI.set_multiplier!(
param_container,
get_multiplier_value(T(), device, W()),
name,
step,
)
end
end
return
end

Expand Down
Loading