Skip to content

Commit

Permalink
handle ElectricStorage being a list of dicts
Browse files Browse the repository at this point in the history
  • Loading branch information
hdunham committed Aug 29, 2024
1 parent 5f2ceb6 commit 710f2f5
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/core/scenario.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ A Scenario struct can contain the following keys:
- [SteamTurbine](@ref) (optional)
- [ElectricHeater](@ref) (optional)
All values of `d` are expected to be `Dicts` except for `PV` and `GHP`, which can be either a `Dict` or `Dict[]` (for multiple PV arrays or GHP options).
All values of `d` are expected to be `Dicts` except for `PV`, `ElectricStorage`, and `GHP`, which can be either a `Dict` or `Dict[]` (for multiple PV arrays or GHP options).
!!! note
Set `flex_hvac_from_json=true` if `FlexibleHVAC` values were loaded in from JSON (necessary to
Expand Down Expand Up @@ -157,15 +157,29 @@ function Scenario(d::Dict; flex_hvac_from_json=false)
emissions_factor_series_lb_PM25_per_kwh = 0
)
end

storage_structs = Dict{String, AbstractStorage}()
if haskey(d, "ElectricStorage")
storage_dict = dictkeys_tosymbols(d["ElectricStorage"])
storage_dict[:off_grid_flag] = settings.off_grid_flag
if typeof(d["ElectricStorage"]) <: AbstractArray
for (i, elecstor) in enumerate(d["ElectricStorage"])
if !(haskey(elecstor, "name"))
elecstor["name"] = string("ElectricStorage", i)
end
storage_dict = dictkeys_tosymbols(elecstor)
storage_dict[:off_grid_flag] = settings.off_grid_flag
storage_structs[storage_dict[:name]] = ElectricStorage(storage_dict, financial)
end
elseif typeof(d["ElectricStorage"]) <: AbstractDict
storage_dict = dictkeys_tosymbols(d["ElectricStorage"])
storage_dict[:off_grid_flag] = settings.off_grid_flag
storage_structs[storage_dict[:name]] = ElectricStorage(storage_dict, financial)
else
throw(@error("PV input must be Dict or Dict[]."))
end
else
storage_dict = Dict(:max_kw => 0.0)
storage_structs["ElectricStorage"] = ElectricStorage(storage_dict, financial)
end
storage_structs["ElectricStorage"] = ElectricStorage(storage_dict, financial)
# TODO stop building ElectricStorage when it is not modeled by user
# (requires significant changes to constraints, variables)
if haskey(d, "HotThermalStorage")
Expand Down

0 comments on commit 710f2f5

Please sign in to comment.