Skip to content

Commit 1a3e4fd

Browse files
committed
Update ElectricTariffInputs urdb_metadata from Julia in process_results
1 parent b2a3b6b commit 1a3e4fd

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

julia_src/Manifest.toml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

julia_src/http.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ function reopt(req::HTTP.Request)
237237
high_temp_storage_dict = Dict(key=>getfield(model_inputs.s.storage.attr["HighTempThermalStorage"], key) for key in inputs_with_defaults_from_julia_high_temp_storage)
238238
else
239239
high_temp_storage_dict = Dict()
240+
end
241+
if haskey(d, "ElectricTariff") && !isempty(get(d["ElectricTariff"], "urdb_metadata", Dict()))
242+
inputs_from_julia_electric_tariff = [
243+
:urdb_metadata
244+
]
245+
electric_tariff_dict = Dict(key=>getfield(model_inputs.s.electric_tariff, key) for key in inputs_from_julia_electric_tariff)
246+
else
247+
electric_tariff_dict = Dict()
240248
end
241249
inputs_with_defaults_set_in_julia = Dict(
242250
"Financial" => Dict(key=>getfield(model_inputs.s.financial, key) for key in inputs_with_defaults_from_julia_financial),
@@ -253,7 +261,8 @@ function reopt(req::HTTP.Request)
253261
"ElectricStorage" => electric_storage_dict,
254262
"ColdThermalStorage" => cold_storage_dict,
255263
"HotThermalStorage" => hot_storage_dict,
256-
"HighTempThermalStorage" => high_temp_storage_dict
264+
"HighTempThermalStorage" => high_temp_storage_dict,
265+
"ElectricTariff" => electric_tariff_dict
257266
)
258267
catch e
259268
@error "Something went wrong in REopt optimization!" exception=(e, catch_backtrace())

reoptjl/src/process_results.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
SteamTurbineOutputs, GHPInputs, GHPOutputs, ExistingChillerInputs, \
1010
ElectricHeaterOutputs, ASHPSpaceHeaterOutputs, ASHPWaterHeaterOutputs, \
1111
SiteInputs, ASHPSpaceHeaterInputs, ASHPWaterHeaterInputs, CSTInputs, CSTOutputs, PVInputs, \
12-
HighTempThermalStorageInputs, HighTempThermalStorageOutputs
12+
HighTempThermalStorageInputs, HighTempThermalStorageOutputs, ElectricTariffInputs
1313
import numpy as np
1414
import sys
1515
import traceback as tb
@@ -179,6 +179,9 @@ def update_inputs_in_database(inputs_to_update: dict, run_uuid: str) -> None:
179179
if inputs_to_update.get("HighTempThermalStorage") is not None:
180180
prune_update_fields(HighTempThermalStorageInputs, inputs_to_update["HighTempThermalStorage"])
181181
HighTempThermalStorageInputs.objects.filter(meta__run_uuid=run_uuid).update(**inputs_to_update["HighTempThermalStorage"])
182+
if inputs_to_update.get("ElectricTariff"):
183+
prune_update_fields(ElectricTariffInputs, inputs_to_update["ElectricTariff"])
184+
ElectricTariffInputs.objects.filter(meta__run_uuid=run_uuid).update(**inputs_to_update["ElectricTariff"])
182185
except Exception as e:
183186
exc_type, exc_value, exc_traceback = sys.exc_info()
184187
debug_msg = "exc_type: {}; exc_value: {}; exc_traceback: {}".format(

0 commit comments

Comments
 (0)