-
Notifications
You must be signed in to change notification settings - Fork 74
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
Initial refactor of cost functions #1071
Merged
Merged
Changes from 5 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
5818ed1
delete old cost data
jd-lara 23c6e0d
add ProductionVariableCosts
jd-lara f7c1aab
add ThermalGenerationCost
jd-lara 4f1a34a
delete old exports
jd-lara 1fc21fb
delete outdated setter
jd-lara a39cff7
partially update the structs
jd-lara 771b98b
add new cost functions
jd-lara 779f537
format run
jd-lara f8c28fe
some updates
jd-lara 6a267a6
Fix typos; minor refactors for legibility
GabrielKS 6d19398
Add LoadCost
GabrielKS 6ed554b
Add cost function includes
GabrielKS ddd5d08
Eliminate TwoPartCost in generated structs
GabrielKS 2d434dd
Refine usage of `LoadCost`
GabrielKS 3032e2d
Fix serialization, typos
GabrielKS cdfd673
Fix `OperationalCost` constructors, test
GabrielKS 0156734
Make `OperationalCost` structs take the right kind of `ProductionVari…
GabrielKS 7af370b
Remove `PolynomialFunctionData`
GabrielKS d7ff445
Accommodate `FunctionData` refactors
GabrielKS 44e5f1a
Add `ValueCurve` for input-output, incremental, average rate curves
GabrielKS d9f1e1d
`ValueCurves`: add documentation, support serialization
GabrielKS 652d09c
Redefine `CostCurve`, `FuelCurve` in terms of `ValueCurve`
GabrielKS d63dae6
Add some `zero` methods
GabrielKS 31b848a
Standardize `OperationalCost` naming
GabrielKS f0fdd47
Make `test_cost_functions` pass
GabrielKS d055875
Export new cost structs
GabrielKS 2d82421
Refine cost struct constructors
GabrielKS a292ca0
Make further use of new cost structs throughout PSY
GabrielKS 3db189b
Fix cost struct parameterized type specifications
GabrielKS ccd9145
Revert `power_system_table_data` math, update accessors in test
GabrielKS 187bdc0
Move `operational_cost.jl`
GabrielKS b824da4
Fine-tune exports
GabrielKS b114f59
Fix operational cost field types
GabrielKS 5923544
Remove more references to old cost structs
GabrielKS 28220f1
Add x-axis units in `CostCurve` and `FuelCurve`
GabrielKS dd537cb
Update Project.toml
jd-lara 982861b
Add rough draft of cost function aliases and documentation
GabrielKS 9346083
Add operational cost conversion logic
GabrielKS a25c586
Fine-tune cost structs
GabrielKS a49da75
Add cost aliases docs and tests
GabrielKS 259b6cb
Rename `PiecewiseSlopeCurve`, revert ill-advised constructor refactor
GabrielKS 0afc7bc
Save `MarketBidCost` refactor progress before HDF5 transformations work
GabrielKS bd1cfeb
Implement HDF serialization properly for `ValueCurve`s
GabrielKS d758391
Wrap up high-level cost structs in time series for MarketBidCost
GabrielKS b26d639
Run formatter
GabrielKS e8193dd
Update test for new cost structs
GabrielKS f524e21
Rename `MarketBidCost.ancillary_services` -> `ancillary_service_offers
GabrielKS 234936e
Use cost function aliases
GabrielKS b0f4f60
Fix typo
GabrielKS 39c87fb
Merge branch 'psy4' into jdgk/cost_functions
GabrielKS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
abstract type CostCurve <: ProductionVariableCost end | ||
|
||
get_function_data(curve::CostCurve) = curve.function_data | ||
|
||
""" | ||
Representation of the variable operation cost of a power plant in $/time at a particular power output level. | ||
|
||
# Arguments | ||
- `function_data::FunctionData`: Functional representation of the cost curve | ||
""" | ||
struct InputOutputCostCurve <: FuelCurve | ||
function_data::FunctionData | ||
end | ||
|
||
""" | ||
First derivative of the Input/Output cost curve. | ||
|
||
# Arguments | ||
- `function_data::FunctionData`: Functional representation of the incremental cost. | ||
- `no_load_cost::Float64`: The estimated cost needed to theoretically operate a unit at zero power. This is not the cost of operating at mininum stable levels | ||
""" | ||
struct IncrementalCostCurve <: FuelCurve | ||
function_data::FunctionData | ||
no_load_cost::Float64 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
abstract type FuelCurve <: VariableProductionCost end | ||
|
||
get_function_data(curve::FuelCurve) = curve.function_data | ||
get_fixed_fuel_cost(curve::FuelCurve) = curve.fixed_fuel_cost | ||
get_fuel_cost_time_series(curve::FuelCurve) = curve.fuel_cost_time_series | ||
|
||
""" | ||
Fuel consumption representation fuel input in Fuel/hr as a function of the power output. | ||
This function indicates how much fuel rate is required to produce a power level. It can be used | ||
for any generator like gas (MBTU/hr/MW), oil (Liters/hr/MW) or hydro (m^3/hr/MW). | ||
|
||
# Arguments | ||
- `function_data::FunctionData`: Functional representation of the input/output curve. | ||
- `fixed_fuel_cost::Union{Nothing Float64}`: Fixed value for fuel cost for the total cost calculation. | ||
- `fuel_cost_time_series::Union{Nothing, String}`: Fuel cost time series name for the total cost calculation. | ||
""" | ||
struct InputOutputFuelCurve <: FuelCurve | ||
function_data::FunctionData | ||
fixed_fuel_cost::Union{Nothing, Float64} | ||
fuel_cost_time_series::Union{Nothing, String} | ||
end | ||
|
||
""" | ||
Fuel usage representation of the amount of input energy required to produce an electric energy amount (e.g., MWhr) | ||
at a given generation level. Usually calculated by dividing absolute values of fuel input rate by absolute values of electric output power | ||
|
||
# Arguments | ||
- `function_data::FunctionData`: Functional representation of the average heat rate for the unit | ||
- `fixed_fuel_cost::Union{Nothing Float64}`: Fixed value for fuel cost for the total cost calculation. | ||
- `fuel_cost_time_series::Union{Nothing, String}`: Fuel cost time series name for the total cost calculation. | ||
""" | ||
struct AverageHeatRateCurve <: FuelCurve | ||
function_data::FunctionData | ||
fixed_fuel_cost::Union{Nothing, Float64} | ||
fuel_cost_time_series::Union{Nothing, String} | ||
end | ||
|
||
""" | ||
First derivative of the Input/Output curve | ||
|
||
# Arguments | ||
- `function_data::FunctionData`: Functional representation of the heat rate. | ||
- `no_load_heat::Float64`: The estimated amount of fuel needed to theoretically operate a unit at zero power. This is not the fuel required to operate at mininum stable levels. | ||
- `fixed_fuel_cost::Union{Nothing Float64}`: Fixed value for fuel cost for the total cost calculation. | ||
- `fuel_cost_time_series::Union{Nothing, String}`: Fuel cost time series name for the total cost calculation. | ||
""" | ||
struct IncrementalHeatRateCurve <: FuelCurve | ||
function_data::FunctionData | ||
no_load_heat::Float64 | ||
fixed_fuel_cost::Union{Nothing, Float64} | ||
fuel_cost_time_series::Union{Nothing, String} | ||
end | ||
|
||
get_no_load_heat(curve::IncrementalHeatRateCurve) = curve.no_load_heat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const HEAT_STAGES = NamedTuple{(:hot, :warm, :cold), NTuple{3, Float64}} | ||
""" | ||
mutable struct ThermalGenerationCost <: OperationalCost | ||
variable::ProductionVariableCost | ||
no_load::Float64 | ||
fixed::Float64 | ||
start_up::NamedTuple{(:hot, :warm, :cold), NTuple{3, Float64}} | ||
shut_down::Float64 | ||
end | ||
|
||
Data Structure Operational Cost Data which includes fixed, variable cost, multiple start up cost and stop costs. | ||
|
||
# Arguments | ||
- `variable::ProductionVariableCost`: Production Variable Cost. Can take fuel curves or cost curve represenations | ||
- `fixed::Union{Nothing, Float64}`: Fixed cost of keeping the unit online. For some cost represenations this field can be duplicative. | ||
- `start_up::Union{NamedTuple{(:hot, :warm, :cold), NTuple{3, Float64}}, Float64}`: start-up cost can take linear of multi-stage costs | ||
- `shut_down::Float64`: cost of turning the unit offline. | ||
""" | ||
mutable struct ThermalGenerationCost <: OperationalCost | ||
"variable cost" | ||
variable::ProductionVariableCost | ||
"fixed cost" | ||
fixed::Float64 | ||
"start-up cost" | ||
start_up::Union{HEAT_STAGES, Float64} | ||
"shut-down cost" | ||
shut_down::Float64 | ||
end | ||
|
||
function ThermalGenerationCost(; variable, fixed, start_up, shut_down) | ||
jd-lara marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ThermalGenerationCost(variable, fixed, start_up, shut_down) | ||
end | ||
|
||
# Constructor for demo purposes; non-functional. | ||
function ThermalGenerationCost(::Nothing) | ||
ThermalGenerationCost(; | ||
variable = InputOutputCostCurve(LinearProductionVariableCost(0.0)), | ||
fixed = 0.0, | ||
start_up = 0.0, | ||
shut_down = 0.0, | ||
) | ||
end | ||
|
||
"""Get [`ThermalGenerationCost`](@ref) `variable`.""" | ||
get_variable(value::ThermalGenerationCost) = value.variable | ||
"""Get [`ThermalGenerationCost`](@ref) `fixed`.""" | ||
get_fixed(value::ThermalGenerationCost) = value.fixed | ||
"""Get [`ThermalGenerationCost`](@ref) `start_up`.""" | ||
get_start_up(value::ThermalGenerationCost) = value.start_up | ||
"""Get [`ThermalGenerationCost`](@ref) `shut_down`.""" | ||
get_shut_down(value::ThermalGenerationCost) = value.shut_down | ||
|
||
"""Set [`ThermalGenerationCost`](@ref) `variable`.""" | ||
set_variable!(value::ThermalGenerationCost, val) = value.variable = val | ||
"""Set [`ThermalGenerationCost`](@ref) `fixed`.""" | ||
set_fixed!(value::ThermalGenerationCost, val) = value.fixed = val | ||
"""Set [`ThermalGenerationCost`](@ref) `start_up`.""" | ||
set_start_up!(value::ThermalGenerationCost, val) = value.start_up = val | ||
"""Set [`ThermalGenerationCost`](@ref) `shut_down`.""" | ||
set_shut_down!(value::ThermalGenerationCost, val) = value.shut_down = val |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
abstract type ProductionVariableCost end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstrings don't match the types.