Skip to content

Commit

Permalink
Merge branch 'develop' into support-312
Browse files Browse the repository at this point in the history
  • Loading branch information
vtnate committed Dec 14, 2023
2 parents 4019494 + 05e2f13 commit 4b2fe59
Show file tree
Hide file tree
Showing 56 changed files with 394 additions and 243 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,4 @@ tests/modelica/data/packages/*/*.c
tests/modelica/data/packages/*/dymosim
tests/management/data/sdk_project_scraps/run/baseline_scenario/system_parameter.json
geojson_modelica_translator/modelica/buildingslibrary/
not/a/real/**
# TODO: this file shoud not be writtent out, but it is... fix this eventually
geojson_modelica_translator/modelica/ets_cooling_indirect_templated.mo
not/
2 changes: 1 addition & 1 deletion geojson_modelica_translator/geojson_modelica_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _parse_couplings(geojson, sys_params, district_type=None):

# create the loads and their ETSes
for building in geojson.buildings:
load_model_type = sys_params.get_param_by_building_id(building.id, "load_model")
load_model_type = sys_params.get_param_by_id(building.id, "load_model")
load_class = LOAD_MODEL_TO_CLASS[load_model_type]
load = load_class(sys_params, building)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Borefield ambient coupling connections
connect(pumDis.port_b, {{ coupling.plant.id }}.port_a)
{% raw %}annotation (Line(points={{-44,-50},{-44,-10},{-20,-10}},color={0,127,255}));
{% endraw %}connect({{ coupling.plant.id }}.port_b, dis.port_aDisSup)
{% raw %}annotation (Line(points={{0,-10},{50,-10}},color={0,127,255}));
{% endraw %}connect({{ coupling.plant.id }}.port_b, TOut.port_a)
{% raw %}annotation (Line(points={{-10,10},{6,10}}, color={0,127,255}));
{% endraw %}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
datDes(
nBui={{ sys_params.num_buildings }},
{% if sys_params.district_system.fifth_generation.ghe_parameters.design.flow_type == 'borehole' %}
mPumDis_flow_nominal={{ 10*sys_params.district_system.fifth_generation.ghe_parameters.design.flow_rate*
mPumDis_flow_nominal={{ sys_params.district_system.fifth_generation.ghe_parameters.design.flow_rate*
sys_params.district_system.fifth_generation.ghe_parameters.ghe_specific_params[0].borehole.number_of_boreholes }},
{% else %}
mPumDis_flow_nominal={{ 10*sys_params.district_system.fifth_generation.ghe_parameters.design.flow_rate }},
mPumDis_flow_nominal={{ sys_params.district_system.fifth_generation.ghe_parameters.design.flow_rate }},
{% endif %}
mPipDis_flow_nominal=datDes.mPumDis_flow_nominal,
dp_length_nominal=250,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
// Connections for sub-components
{% raw %}connect(masFloMaiPum.y,pumDis.m_flow_in)
annotation (Line(points={{-21,-60},{-32,-60}}, color={0,0,127}));
connect(pumDis.port_a, expVes.ports[1])
annotation (Line(points={{-44,-70},{-44,-80},{100,-80},{100,-64},{120,-64}}, color={0,127,255}));
connect(expVes.ports[2], dis.port_bDisSup)
annotation (Line(points={{120,-68},{100,-68},{100,-10},{90,-10}}, color={0,127,255}));
{% raw %}connect(dis.port_bDisSup, TIn.port_a)
annotation (Line(points={{90,10},{110,10},{110,-20}}, color={0,127,255}));
connect(TIn.port_b, pumDis.port_a)
annotation (Line(points={{110,-40},{110,-80},{-44,-80},{-44,-70}}, color={0,127,255}));
connect(expVes.ports[1], pumDis.port_a)
annotation (Line(points={{-20,-100},{-20,-80},{-44,-80},{-44,-70}}, color={0,127,255}));
connect(conPum.y, gai.u)
annotation (Line(points={{-98,-90},{-82,-90}}, color={0,0,127}));
connect(gai.y, pumDis.m_flow_in)
annotation (Line(points={{-58,-90},{-26,-90},{-26,-60},{-32,-60}}, color={0,0,127}));
connect(dis.TOut, conPum.TMix)
annotation (Line(points={{92,4},{128,4},{128,-112},{-134,-112},{-134,-84},{-122,-84}}, color={0,0,127}));
connect(TIn.T, conPum.TSouIn[1])
annotation (Line(points={{121,-30},{128,-30},{128,-112},{-130,-112},{-130,-90},{-122,-90}}, color={0,0,127}));
connect(TOut.port_b, dis.port_aDisSup)
annotation (Line(points={{26,10},{50,10}}, color={0,127,255}));
connect(TOut.T, conPum.TSouOut[1])
annotation (Line(points={{16,-1},{16,-112},{-126,-112},{-126,-96},{-122,-96}},color={0,0,127}));
{% endraw %}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def to_modelica(self):
coupling_load = coupling.get_load()
if coupling_load is not None:
# read sys params file for the load
building_sys_params = self.system_parameters.get_param_by_building_id(coupling_load.building_id, '$')
building_sys_params = self.system_parameters.get_param_by_id(coupling_load.building_id, '$')
template_context['sys_params']['building'] = building_sys_params
# Note which load is being used, so ports connect properly in couplings/5G_templates/ConnectStatements
template_context['sys_params']['load_num'] = load_num
Expand All @@ -128,7 +128,7 @@ def to_modelica(self):
template_params.update(**common_template_params)

if issubclass(type(model), LoadBase):
building_sys_params = self.system_parameters.get_param_by_building_id(model.building_id, '$')
building_sys_params = self.system_parameters.get_param_by_id(model.building_id, '$')
template_params['sys_params']['building'] = building_sys_params

templated_instance, instance_template_path = model.render_instance(template_params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def to_modelica(self, scaffold):
"""
cooling_indirect_template = self.template_env.get_template("CoolingIndirect.mot")

ets_data = self.system_parameters.get_param_by_building_id(
ets_data = self.system_parameters.get_param_by_id(
self._geojson_load_id,
'ets_indirect_parameters'
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def to_modelica(self, scaffold):
"""
heating_indirect_template = self.template_env.get_template("HeatingIndirect.mot")

ets_data = self.system_parameters.get_param_by_building_id(
ets_data = self.system_parameters.get_param_by_id(
self._geojson_load_id,
"ets_indirect_parameters"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,58 +40,58 @@ def __init__(self, system_parameters, geojson_load):
# TODO: Decide if we're requiring sys-param file, and if all loads have an ets.
# test_base.py and test_time_series.py test these cases
if system_parameters is not None:
if self.system_parameters.get_param_by_building_id(
if self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters") is not None:
self.ets_template_data = {
"heat_flow_nominal": self.system_parameters.get_param_by_building_id(
"heat_flow_nominal": self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters.heat_flow_nominal"
),
"heat_exchanger_efficiency": self.system_parameters.get_param_by_building_id(
"heat_exchanger_efficiency": self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters.heat_exchanger_efficiency"
),
"nominal_mass_flow_district": self.system_parameters.get_param_by_building_id(
"nominal_mass_flow_district": self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters.nominal_mass_flow_district"
),
"nominal_mass_flow_building": self.system_parameters.get_param_by_building_id(
"nominal_mass_flow_building": self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters.nominal_mass_flow_building"
),
"valve_pressure_drop": self.system_parameters.get_param_by_building_id(
"valve_pressure_drop": self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters.valve_pressure_drop"
),
"heat_exchanger_secondary_pressure_drop": self.system_parameters.get_param_by_building_id(
"heat_exchanger_secondary_pressure_drop": self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters.heat_exchanger_secondary_pressure_drop"
),
"heat_exchanger_primary_pressure_drop": self.system_parameters.get_param_by_building_id(
"heat_exchanger_primary_pressure_drop": self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters.heat_exchanger_primary_pressure_drop"
),
"cooling_supply_water_temperature_building": convert_c_to_k(self.system_parameters.get_param_by_building_id(
"cooling_supply_water_temperature_building": convert_c_to_k(self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters.cooling_supply_water_temperature_building"
)),
"heating_supply_water_temperature_building": convert_c_to_k(self.system_parameters.get_param_by_building_id(
"heating_supply_water_temperature_building": convert_c_to_k(self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters.heating_supply_water_temperature_building"
)),
"delta_temp_chw_building": self.system_parameters.get_param_by_building_id(
"delta_temp_chw_building": self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters.delta_temp_chw_building"
),
"delta_temp_chw_district": self.system_parameters.get_param_by_building_id(
"delta_temp_chw_district": self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters.delta_temp_chw_district"
),
"delta_temp_hw_building": self.system_parameters.get_param_by_building_id(
"delta_temp_hw_building": self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters.delta_temp_hw_building"
),
"delta_temp_hw_district": self.system_parameters.get_param_by_building_id(
"delta_temp_hw_district": self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters.delta_temp_hw_district"
),
"cooling_controller_y_max": self.system_parameters.get_param_by_building_id(
"cooling_controller_y_max": self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters.cooling_controller_y_max"
),
"cooling_controller_y_min": self.system_parameters.get_param_by_building_id(
"cooling_controller_y_min": self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters.cooling_controller_y_min"
),
"heating_controller_y_max": self.system_parameters.get_param_by_building_id(
"heating_controller_y_max": self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters.heating_controller_y_max"
),
"heating_controller_y_min": self.system_parameters.get_param_by_building_id(
"heating_controller_y_min": self.system_parameters.get_param_by_id(
self.building_id, "ets_indirect_parameters.heating_controller_y_min"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,48 +49,48 @@ def to_modelica(self, scaffold, keep_original_models=False):
# grab the data from the system_parameter file for this building id
# TODO: create method in system_parameter class to make this easier

idf_filename = self.system_parameters.get_param_by_building_id(
idf_filename = self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.spawn.idf_filename"
)
thermal_zones = self.system_parameters.get_param_by_building_id(
thermal_zones = self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.spawn.thermal_zone_names",
)
zone_nom_htg_loads = self.system_parameters.get_param_by_building_id(
zone_nom_htg_loads = self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.spawn.zone_nom_htg_loads",
)
zone_nom_clg_loads = self.system_parameters.get_param_by_building_id(
zone_nom_clg_loads = self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.spawn.zone_nom_clg_loads",
)
# TODO: pick up default value from schema if not specified in system_parameters,
# to avoid the inline if/then statement in nominal_values below
has_liquid_heating = self.system_parameters.get_param_by_building_id(
has_liquid_heating = self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.spawn.has_liquid_heating",
)
has_liquid_cooling = self.system_parameters.get_param_by_building_id(
has_liquid_cooling = self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.spawn.has_liquid_cooling",
)
has_electric_heating = self.system_parameters.get_param_by_building_id(
has_electric_heating = self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.spawn.has_electric_heating",
)
has_electric_cooling = self.system_parameters.get_param_by_building_id(
has_electric_cooling = self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.spawn.has_electric_cooling",
)
hhw_supply_temp = convert_c_to_k(self.system_parameters.get_param_by_building_id(
hhw_supply_temp = convert_c_to_k(self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.spawn.temp_hw_supply",
))
hhw_return_temp = convert_c_to_k(self.system_parameters.get_param_by_building_id(
hhw_return_temp = convert_c_to_k(self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.spawn.temp_hw_return",
))
chw_supply_temp = convert_c_to_k(self.system_parameters.get_param_by_building_id(
chw_supply_temp = convert_c_to_k(self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.spawn.temp_chw_supply",
))
chw_return_temp = convert_c_to_k(self.system_parameters.get_param_by_building_id(
chw_return_temp = convert_c_to_k(self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.spawn.temp_chw_return",
))
temp_setpoint_cooling = convert_c_to_k(self.system_parameters.get_param_by_building_id(
temp_setpoint_cooling = convert_c_to_k(self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.spawn.temp_setpoint_cooling",
))
temp_setpoint_heating = convert_c_to_k(self.system_parameters.get_param_by_building_id(
temp_setpoint_heating = convert_c_to_k(self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.spawn.temp_setpoint_heating",
))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def to_modelica(self, scaffold, keep_original_models=False):
)

prj.used_library_calc = "IBPSA"
prj.number_of_elements_calc = self.system_parameters.get_param_by_building_id(
prj.number_of_elements_calc = self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.rc.order"
)
prj.merge_windows_calc = False
Expand Down Expand Up @@ -330,7 +330,7 @@ def post_process(self, scaffold, keep_original_models=False):
mofile.remove_connect('weaDat.weaBus', 'weaBus')

# add new port connections
rc_order = self.system_parameters.get_param_by_building_id(
rc_order = self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.rc.order"
)
thermal_zone_name = None
Expand Down Expand Up @@ -509,36 +509,36 @@ def post_process(self, scaffold, keep_original_models=False):
"path": os.path.dirname(mos_weather_filename),
},
"nominal_values": {
"chw_supply_temp": convert_c_to_k(self.system_parameters.get_param_by_building_id(
"chw_supply_temp": convert_c_to_k(self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.rc.temp_chw_supply"
)),
"chw_return_temp": convert_c_to_k(self.system_parameters.get_param_by_building_id(
"chw_return_temp": convert_c_to_k(self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.rc.temp_chw_return"
)),
"hhw_supply_temp": convert_c_to_k(self.system_parameters.get_param_by_building_id(
"hhw_supply_temp": convert_c_to_k(self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.rc.temp_hw_supply"
)),
"hhw_return_temp": convert_c_to_k(self.system_parameters.get_param_by_building_id(
"hhw_return_temp": convert_c_to_k(self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.rc.temp_hw_return"
)),
"temp_setpoint_heating": convert_c_to_k(self.system_parameters.get_param_by_building_id(
"temp_setpoint_heating": convert_c_to_k(self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.rc.temp_setpoint_heating"
)),
"temp_setpoint_cooling": convert_c_to_k(self.system_parameters.get_param_by_building_id(
"temp_setpoint_cooling": convert_c_to_k(self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.rc.temp_setpoint_cooling"
)),
# FIXME: pick up default value from schema if not specified in system_parameters,
# FYI: Modelica insists on booleans being lowercase, so we need to explicitly set "true" and "false"
"has_liquid_heating": "true" if self.system_parameters.get_param_by_building_id(
"has_liquid_heating": "true" if self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.rc.has_liquid_heating",
) else "false",
"has_liquid_cooling": "true" if self.system_parameters.get_param_by_building_id(
"has_liquid_cooling": "true" if self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.rc.has_liquid_cooling",
) else "false",
"has_electric_heating": "true" if self.system_parameters.get_param_by_building_id(
"has_electric_heating": "true" if self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.rc.has_electric_heating",
) else "false",
"has_electric_cooling": "true" if self.system_parameters.get_param_by_building_id(
"has_electric_cooling": "true" if self.system_parameters.get_param_by_id(
self.building_id, "load_model_parameters.rc.has_electric_cooling",
) else "false",
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
old_hidden_avoid_double_computation=Hidden.AvoidDoubleComputation;
Hidden.AvoidDoubleComputation=true;
simulateModel("{{full_model_name}}",
method="cvode",
tolerance=1e-6,
numberOfIntervals=500,
stopTime=604800.0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
simulateModel("{{full_model_name}}",
method="cvode",
tolerance=1e-6,
numberOfIntervals=500,
stopTime=604800.0,
Expand Down
Loading

0 comments on commit 4b2fe59

Please sign in to comment.