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 some more PSY 3 -> PSY 4 system conversions #1132

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Changes from all commits
Commits
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
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
Copy link
Member

Choose a reason for hiding this comment

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

This is going to be dependent on the data that the user had and we have no way of knowing the prior assumptions. We should just throw a warning that we are doing the conversion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a warning.

@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
Loading