Skip to content

Commit

Permalink
Fix serialization, typos
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielKS committed Mar 22, 2024
1 parent 2d434dd commit 3032e2d
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/models/cost_functions/CostCurves.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ struct InputOutputCostCurve <: CostCurve
function_data::FunctionData
end

InputOutputCostCurve(; function_data) = InputOutputCostCurve(function_data)

"""
First derivative of the Input/Output cost curve.
Expand All @@ -23,3 +25,6 @@ struct IncrementalCostCurve <: CostCurve
function_data::FunctionData
no_load_cost::Float64
end

IncrementalCostCurve(; function_data, no_load_cost) =
InputOutputCostCurve(function_data, no_load_cost)
2 changes: 1 addition & 1 deletion src/models/cost_functions/HydroPowerCost.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ end
# Constructor for demo purposes; non-functional.
function HydroGenerationCost(::Nothing)
HydroGenerationCost(;
variable = InputOutputCostCurve(LinearProductionVariableCost(0.0)),
variable = InputOutputCostCurve(LinearFunctionData(0.0)),
fixed = 0.0,
)
end
Expand Down
2 changes: 1 addition & 1 deletion src/models/cost_functions/LoadCost.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ end
# Constructor for demo purposes; non-functional.
function LoadCost(::Nothing)
LoadCost(;
variable = InputOutputCostCurve(LinearProductionVariableCost(0.0)),
variable = InputOutputCostCurve(LinearFunctionData(0.0)),
fixed = 0.0,
)
end
Expand Down
15 changes: 11 additions & 4 deletions src/models/cost_functions/RenewablePowerCost.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,28 @@ curtailment Costs can be used to represent the loss of tax incentives.
# Arguments
- `variable::InputOutputCostCurve`: Production Variable Cost represented as input/output.
- `curtailment_cost::InputOutputCostCurve`: Input/output cost of curtailing power.
"""
mutable struct RenewablePowerCost <: OperationalCost
"variable cost"
variable::InputOutputCostCurve
"curtailment cost"
curtailment_cost::InputOutputCostCurve
variable_cost::InputOutputCostCurve
end

function RenewablePowerCost(; variable)
RenewablePowerCost(variable)
RenewablePowerCost(variable) =
RenewablePowerCost(variable, InputOutputCostCurve(LinearFunctionData(0.0)))

function RenewablePowerCost(; variable, curtailment_cost)
println(variable)
println(curtailment_cost)
RenewablePowerCost(variable, curtailment_cost)
end

# Constructor for demo purposes; non-functional.
function RenewablePowerCost(::Nothing)
RenewablePowerCost(;
variable = InputOutputCostCurve(LinearProductionVariableCost(0.0)),
variable = InputOutputCostCurve(LinearFunctionData(0.0)),
)
end

Expand Down
2 changes: 1 addition & 1 deletion src/models/cost_functions/StorageCost.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const STORAGE_OPERATION_MODES = NamedTuple{(:charge, :discharge), NTuple{2, Floa
end
Data Structure for Operational Cost Data like variable cost and start - stop costs and energy storage cost.
This data structure is not intented to represent market storage systems market operations like the submission of
This data structure is not intended to represent market storage systems market operations like the submission of
buy/sell bids.
# Arguments
Expand Down
2 changes: 1 addition & 1 deletion src/models/cost_functions/ThermalGenerationCost.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ end
# Constructor for demo purposes; non-functional.
function ThermalGenerationCost(::Nothing)
ThermalGenerationCost(;
variable = InputOutputCostCurve(LinearProductionVariableCost(0.0)),
variable = InputOutputCostCurve(LinearFunctionData(0.0)),
fixed = 0.0,
start_up = 0.0,
shut_down = 0.0,
Expand Down
3 changes: 3 additions & 0 deletions src/models/cost_functions/variable_cost.jl
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
abstract type ProductionVariableCost end

IS.serialize(val::ProductionVariableCost) = IS.serialize_struct(val)
IS.deserialize(T::Type{<:ProductionVariableCost}, val::Dict) = IS.deserialize_struct(T, val)
3 changes: 3 additions & 0 deletions src/models/operational_cost.jl
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
""" Super type for operational cost representation in the model"""
abstract type OperationalCost <: DeviceParameter end

IS.serialize(val::OperationalCost) = IS.serialize_struct(val)
IS.deserialize(T::Type{<:OperationalCost}, val::Dict) = IS.deserialize_struct(T, val)
3 changes: 2 additions & 1 deletion src/parsers/power_models_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ function make_hydro_gen(gen_name, d, bus, sys_mbase)
end

function make_renewable_dispatch(gen_name, d, bus, sys_mbase)
cost = TwoPartCost(LinearFunctionData(0.0), 0.0)
cost = RenewablePowerCost(InputOutputCostCurve(LinearFunctionData(0.0)))
base_conversion = sys_mbase / d["mbase"]

rating = calculate_rating(d["pmax"], d["qmax"])
Expand Down Expand Up @@ -449,6 +449,7 @@ function make_thermal_gen(gen_name::AbstractString, d::Dict, bus::ACBus, sys_mba
cost = PolynomialFunctionData(Dict((i, c / sys_mbase^i) for (i, c) in coeffs))
fixed = (d["ncost"] >= 1) ? last(d["cost"]) : 0.0
end
cost = InputOutputCostCurve(cost)
startup = d["startup"]
shutdn = d["shutdown"]
else
Expand Down

0 comments on commit 3032e2d

Please sign in to comment.