Skip to content

Commit

Permalink
Merge pull request #1132 from NREL-Sienna/gks/add_conversions
Browse files Browse the repository at this point in the history
Add some more PSY 3 -> PSY 4 system conversions
  • Loading branch information
jd-lara authored Jun 24, 2024
2 parents 15d63de + 29dda4b commit fb5c37a
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion src/data_format_conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@ _convert_op_cost(::Val{:ThermalStandard}, ::Val{:ThreePartCost}, op_cost::Dict)
op_cost["shut_down"],
)

function _convert_op_cost(::Val{:RenewableDispatch}, ::Val{:TwoPartCost}, op_cost::Dict)
(op_cost["fixed"] != 0) && throw(
ArgumentError("Not implemented for nonzero fixed cost, got $(op_cost["fixed"])"),
)
return RenewableGenerationCost(CostCurve(InputOutputCurve(op_cost["variable"])))
end

_convert_op_cost(::Val{:GenericBattery}, ::Val{:StorageManagementCost}, op_cost::Dict) =
StorageCost(;
charge_variable_cost = CostCurve(InputOutputCurve(op_cost["variable"])),
discharge_variable_cost = CostCurve(InputOutputCurve(op_cost["variable"])),
fixed = op_cost["fixed"],
start_up = float(op_cost["start_up"]),
shut_down = float(op_cost["shut_down"]),
energy_shortage_cost = op_cost["energy_shortage_cost"],
energy_surplus_cost = op_cost["energy_surplus_cost"],
)

# TODO implement remaining _convert_op_cost methods

function _convert_data!(
Expand All @@ -106,8 +124,33 @@ function _convert_data!(
component["operation_cost"] = new_op_cost
end
if component["__metadata__"]["type"] ["BatteryEMS", "GenericBattery"]
old_type = component["__metadata__"]["type"]
component["__metadata__"]["type"] = "EnergyReservoirStorage"
component["storage_technology_type"] = "StorageTech.OTHER_CHEM"
component["storage_technology_type"] = IS.serialize(StorageTech.OTHER_CHEM)
soc_min = component["state_of_charge_limits"]["min"]
soc_max = component["state_of_charge_limits"]["max"]
if soc_max == 0.0
component["storage_capacity"] = 0.0
component["storage_level_limits"] = Dict("min" => 0.0, "max" => 1.0)
(component["initial_energy"] != 0.0) && throw(
ArgumentError(
"Maximum state of charge is zero but initial energy is not; cannot parse",
),
)
component["initial_storage_capacity_level"] = 0.0
else
# Derive storage_capacity from old state of charge limits and normalize new
# state of charge limits, initial capacity accordingly
@warn "Parsing $PowerSystems 3.0.0 $old_type as $PowerSystems 4.0.0 $(component["__metadata__"]["type"]), accuracy of conversion not guaranteed"
component["storage_capacity"] = soc_max
component["storage_level_limits"] =
Dict("min" => soc_min / soc_max, "max" => 1.0)
component["initial_storage_capacity_level"] =
component["initial_energy"] / soc_max
end
end
if haskey(component, "rate") # Line, TapTransformer, etc.
component["rating"] = component["rate"]
end
end
return
Expand Down

0 comments on commit fb5c37a

Please sign in to comment.