Skip to content

Commit

Permalink
Merge pull request #1180 from NREL-Sienna/rh/new_fuelcost_ts
Browse files Browse the repository at this point in the history
New PR for Fuel Cost
  • Loading branch information
jd-lara authored Dec 11, 2024
2 parents 4960e1f + 63548e1 commit 8a5d25b
Show file tree
Hide file tree
Showing 19 changed files with 788 additions and 80 deletions.
1 change: 1 addition & 0 deletions src/PowerSimulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ export EmergencyUp
export EmergencyDown
export RawACE
export ProductionCostExpression
export FuelConsumptionExpression
export ActivePowerRangeExpressionLB
export ActivePowerRangeExpressionUB

Expand Down
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{<:ParameterType}, String}
attributes::Dict{String, Any}
subsystem::Union{Nothing, String}

Expand Down
2 changes: 2 additions & 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 All @@ -16,6 +17,7 @@ struct InterfaceTotalFlow <: ExpressionType end
struct PTDFBranchFlow <: ExpressionType end

should_write_resulting_value(::Type{<:CostExpressions}) = true
should_write_resulting_value(::Type{FuelConsumptionExpression}) = true
should_write_resulting_value(::Type{InterfaceTotalFlow}) = true
should_write_resulting_value(::Type{RawACE}) = true
should_write_resulting_value(::Type{ActivePowerBalance}) = true
Expand Down
15 changes: 13 additions & 2 deletions src/core/optimization_container.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ function get_objective_expression(v::ObjectiveFunction)
else
# JuMP doesn't support expression conversion from Affn to QuadExpressions
if isa(v.invariant_terms, JuMP.GenericQuadExpr)
return JuMP.add_to_expression!(v.invariant_terms, v.variant_terms)
# Avoid mutation of invariant term
temp_expr = JuMP.QuadExpr()
JuMP.add_to_expression!(temp_expr, v.invariant_terms)
return JuMP.add_to_expression!(temp_expr, v.variant_terms)
else
# This will mutate the variant terms, but these are reseted at each step.
return JuMP.add_to_expression!(v.variant_terms, v.invariant_terms)
end
end
Expand Down Expand Up @@ -1438,11 +1442,18 @@ function add_expression_container!(
::T,
::Type{U},
axs...;
expr_type = GAE,
sparse = false,
meta = IS.Optimization.CONTAINER_KEY_EMPTY_META,
) where {T <: ExpressionType, U <: Union{PSY.Component, PSY.System}}
expr_key = ExpressionKey(T, U, meta)
return _add_expression_container!(container, expr_key, GAE, axs...; sparse = sparse)
return _add_expression_container!(
container,
expr_key,
expr_type,
axs...;
sparse = sparse,
)
end

function add_expression_container!(
Expand Down
9 changes: 8 additions & 1 deletion src/core/parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ function add_component_name!(attr::TimeSeriesAttributes, name::String, uuid::Str
return
end

_get_ts_uuid(attr::TimeSeriesAttributes, name) = attr.component_name_to_ts_uuid[name]
function _get_ts_uuid(attr::TimeSeriesAttributes, name)
return attr.component_name_to_ts_uuid[name]
end

struct VariableValueAttributes{T <: OptimizationContainerKey} <: ParameterAttributes
attribute_key::T
Expand Down Expand Up @@ -303,6 +305,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
Loading

2 comments on commit 8a5d25b

@jd-lara
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/119365

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.29.0 -m "<description of version>" 8a5d25b4c3aa41d5723cb93a726aa0a226abca6a
git push origin v0.29.0

Please sign in to comment.