diff --git a/geojson_modelica_translator/model_connectors/couplings/5G_templates/NetworkAmbientWaterStub_Borefield/ComponentDefinitions.mopt b/geojson_modelica_translator/model_connectors/couplings/5G_templates/NetworkAmbientWaterStub_Borefield/ComponentDefinitions.mopt deleted file mode 100644 index fd8f493b3..000000000 --- a/geojson_modelica_translator/model_connectors/couplings/5G_templates/NetworkAmbientWaterStub_Borefield/ComponentDefinitions.mopt +++ /dev/null @@ -1 +0,0 @@ - // No components for borefield and ambient water stub coupling diff --git a/geojson_modelica_translator/model_connectors/couplings/5G_templates/NetworkAmbientWaterStub_Borefield/ConnectStatements.mopt b/geojson_modelica_translator/model_connectors/couplings/5G_templates/NetworkAmbientWaterStub_Borefield/ConnectStatements.mopt deleted file mode 100644 index c73ee9ea6..000000000 --- a/geojson_modelica_translator/model_connectors/couplings/5G_templates/NetworkAmbientWaterStub_Borefield/ConnectStatements.mopt +++ /dev/null @@ -1,10 +0,0 @@ -// Borefield ambient coupling connections -{% for group_num in range(sys_params.district_system.fifth_generation.ghe_parameters.ghe_specific_params|length) %} - {% if graph.get_ghe_id(coupling.id) == sys_params.district_system.fifth_generation.ghe_parameters.ghe_specific_params[group_num].ghe_id %} - connect(supHeaWat_1.ports[{{ group_num+1 }}], {{ coupling.plant.id }}.port_a) - {% raw %}annotation (Line(points={{-70,10},{-10,10}}, color={0,127,255})); - {% endraw %}connect({{ coupling.plant.id }}.port_b, sinHeaWat.ports[{{ group_num+1 }}]) - {% raw %}annotation (Line(points={{10,10},{60,10}}, color={0,127,255})); - {% endraw %} - {% endif %} -{% endfor %} diff --git a/geojson_modelica_translator/model_connectors/couplings/5G_templates/TimeSeries_UnidirectionalSeries/ConnectStatements.mopt b/geojson_modelica_translator/model_connectors/couplings/5G_templates/TimeSeries_UnidirectionalSeries/ConnectStatements.mopt index 76acfb1f8..f2af52c6c 100644 --- a/geojson_modelica_translator/model_connectors/couplings/5G_templates/TimeSeries_UnidirectionalSeries/ConnectStatements.mopt +++ b/geojson_modelica_translator/model_connectors/couplings/5G_templates/TimeSeries_UnidirectionalSeries/ConnectStatements.mopt @@ -13,7 +13,8 @@ {% endraw %} connect({{ coupling.load.id }}.port_bSerAmb, {{ coupling.network.id }}.ports_aCon[{{ bldg_num+1 }}]) {% raw %}annotation (Line(points={{80,30},{92,30},{92,6},{82,6},{82,0}}, color={0,127,255})); - {% endraw %}connect({{ coupling.load.id }}.QCoo_flow, conPum.QCoo_flow[{{ bldg_num+1 }}]) + {% endraw %}{% set sum_bldg = loop_order.data[:group_num]|map(attribute='list_bldg_ids_in_group')|map('length')|sum %} + connect({{ coupling.load.id }}.QCoo_flow, conPum.QCoo_flow[{{ sum_bldg+bldg_num+1 }}]) {% raw %}annotation (Line(points={{67,-12},{128,-12},{128,-112},{-124,-112},{-124,-96},{-121.692,-96}}, color={0,0,127})); {% endraw %} {% endif %} diff --git a/geojson_modelica_translator/model_connectors/couplings/5G_templates/UnidirectionalSeries_Borefield/ComponentDefinitions.mopt b/geojson_modelica_translator/model_connectors/couplings/5G_templates/UnidirectionalSeries_Borefield/ComponentDefinitions.mopt index 073427a3e..3a4105f1e 100644 --- a/geojson_modelica_translator/model_connectors/couplings/5G_templates/UnidirectionalSeries_Borefield/ComponentDefinitions.mopt +++ b/geojson_modelica_translator/model_connectors/couplings/5G_templates/UnidirectionalSeries_Borefield/ComponentDefinitions.mopt @@ -8,3 +8,12 @@ redeclare final package Medium = {{ globals.medium_w }}, m_flow_nominal=datDes.mPumDis_flow_nominal) {% raw %}annotation (Placement(transformation(extent={{-10,10},{10,-10}},rotation=0,origin={16,10}))); {% endraw %} +Buildings.Fluid.Sensors.TemperatureTwoPort TDisSup_{{ coupling.id }}( +redeclare final package Medium = {{ globals.medium_w }}, +m_flow_nominal=datDes.mPumDis_flow_nominal) +{% raw %}annotation (Placement(transformation(extent={{-10,10},{10,-10}},rotation=0,origin={34,10}))); +{% endraw %}Buildings.Fluid.Sensors.TemperatureTwoPort TDisRet_{{ coupling.id }}( +redeclare final package Medium = {{ globals.medium_w }}, +m_flow_nominal=datDes.mPumDis_flow_nominal) +{% raw %}annotation (Placement(transformation(extent={{-10,10},{10,-10}},rotation=-90,origin={100,-30}))); +{% endraw %} diff --git a/geojson_modelica_translator/model_connectors/couplings/5G_templates/UnidirectionalSeries_Borefield/ConnectStatements.mopt b/geojson_modelica_translator/model_connectors/couplings/5G_templates/UnidirectionalSeries_Borefield/ConnectStatements.mopt index b0f9972c3..70a11caf2 100644 --- a/geojson_modelica_translator/model_connectors/couplings/5G_templates/UnidirectionalSeries_Borefield/ConnectStatements.mopt +++ b/geojson_modelica_translator/model_connectors/couplings/5G_templates/UnidirectionalSeries_Borefield/ConnectStatements.mopt @@ -4,30 +4,55 @@ {% raw %}annotation (Line(points={{-44,-50},{-44,10},{-40,10}}, color={0,127,255})); {% endraw %} {% endif %} -connect(TIn_{{ coupling.id }}.port_b, {{ coupling.plant.id }}.port_a) +connect(TIn_{{ coupling.id }}.port_b, conSto_{{ coupling.plant.id }}.port_aDis) {% raw %}annotation (Line(points={{-20,10},{-10,10}}, color={0,127,255})); -{% endraw %}connect({{ coupling.plant.id }}.port_b, TOut_{{ coupling.id }}.port_a) +{% endraw %}connect(conSto_{{ coupling.plant.id }}.port_bDis, TOut_{{ coupling.id }}.port_a) {% raw %}annotation (Line(points={{10,10},{6,10}}, color={0,127,255})); -{% endraw %}connect(TOut_{{ coupling.id }}.port_b, {{ coupling.network.id }}.port_aDisSup) -{% raw %}annotation (Line(points={{26,10},{38,10},{38,-10},{50,-10}}, color={0,127,255})); +{% endraw %}connect(conSto_{{ coupling.plant.id }}.port_bCon, pumSto_{{ coupling.plant.id }}.port_a) +{% raw %}annotation (Line(points={{-18,20},{-18,32},{-50,32},{-50,50},{-40,50}}, color={0,127,255})); +{% endraw %}connect(pumSto_{{ coupling.plant.id }}.port_b, {{ coupling.plant.id }}.port_a) +{% raw %}annotation (Line(points={{-20,50},{-10,50}}, color={0,127,255})); +{% endraw %}connect({{ coupling.plant.id }}.port_b, conSto_{{ coupling.plant.id }}.port_aCon) +{% raw %}annotation (Line(points={{10,50},{20,50},{20,32},{-12,32},{-12,20}}, color={0,127,255})); +{% endraw %}connect(TOut_{{ coupling.id }}.port_b, TDisSup_{{ coupling.id }}.port_a) +{% raw %}annotation (Line(points={{20,10},{24,10}}, color={0,127,255})); +{% endraw %}connect(TDisSup_{{ coupling.id }}.port_b, {{ coupling.network.id }}.port_aDisSup) +{% raw %}annotation (Line(points={{44,10},{50,10}}, color={0,127,255})); +{% endraw %}connect({{ coupling.network.id }}.port_bDisSup, TDisRet_{{ coupling.id }}.port_a) +{% raw %}annotation (Line(points={{90,10},{100,10},{100,-20}}, color={0,127,255})); {% endraw %} {% for group_num in range(loop_order.number_of_loops) %} {% if graph.get_ghe_id(coupling.id) == loop_order.data[group_num].list_ghe_ids_in_group[0] %} {% if group_num == loop_order.number_of_loops-1 %} - connect({{ coupling.network.id }}.port_bDisSup, pumDis.port_a) - {% raw %}annotation (Line(points={{90,-10},{110,-10},{110,-20}}, color={0,127,255})); + connect(TDisRet_{{ coupling.id }}.port_b, pumDis.port_a) + {% raw %}annotation (Line(points={{100,-40},{100,-74},{-72,-74},{-72,-70}}, color={0,127,255})); {% endraw %} {% else %} {% set ground_id = graph.couplings_by_type(coupling.network.id).network_couplings[0].network.id %} {% set next_borefield_id = graph.couplings_by_type(ground_id).plant_couplings[group_num+1].plant.id %} {% set next_dis_id = graph.couplings_by_type(next_borefield_id).network_couplings[0].network.id %} - connect({{ coupling.network.id }}.port_bDisSup, TIn_{{ graph.couplings_by_type(next_dis_id).plant_couplings[0].id }}.port_a) + connect(TDisRet_{{ coupling.id }}.port_b, TIn_{{ graph.couplings_by_type(next_dis_id).plant_couplings[0].id }}.port_a) {% raw %}annotation (Line(points={{-44,-50},{-44,10},{-40,10}}, color={0,127,255})); {% endraw %} {% endif %} {% endif %} {% endfor %} // control related connections +connect(conBor_{{ coupling.plant.id }}.y, gai1_{{ coupling.plant.id }}.u) +{% raw %}annotation (Line(points={{-38.4615,90},{-32,90}}, color={0,0,127})); +{% endraw %}connect(gai1_{{ coupling.plant.id }}.y, pumSto_{{ coupling.plant.id }}.m_flow_in) +{% raw %}annotation (Line(points={{-8,90},{0,90},{0,70},{-30,70},{-30,62}}, color={0,0,127})); +{% endraw %}connect({{ coupling.plant.id }}.TBorAve, conBor_{{ coupling.plant.id }}.TSou) +{% raw %}annotation (Line(points={{11,54.4},{22,54.4},{22,70},{-78,70},{-78,93},{-61.5385,93}}, color={0,0,127})); +{% endraw %}connect(TIn_{{ coupling.id }}.T, conBor_{{ coupling.plant.id }}.TSouIn) +{% raw %}annotation (Line(points={{-58,-1},{-58,-4},{-78,-4},{-78,97},{-61.5385,97}}, color={0,0,127})); +{% endraw %}connect(TOut_{{ coupling.id }}.T, conBor_{{ coupling.plant.id }}.TSouOut) +{% raw %}annotation (Line(points={{10,-1},{10,-4},{-78,-4},{-78,89},{-61.5385,89}}, color={0,0,127})); +{% endraw %}connect(TDisSup_{{ coupling.id }}.T, conBor_{{ coupling.plant.id }}.TSupDis) +{% raw %}annotation (Line(points={{34,-1},{34,-30},{-78,-30},{-78,82},{-61.5385,82}}, color={0,0,127})); +{% endraw %}connect(TDisRet_{{ coupling.id }}.T, conBor_{{ coupling.plant.id }}.TRetDis) +{% raw %}annotation (Line(points={{89,-30},{-78,-30},{-78,85},{-61.5385,85}}, color={0,0,127})); +{% endraw %} {% for group_num in range(loop_order.number_of_loops) %} {% if graph.get_ghe_id(coupling.id) == loop_order.data[group_num].list_ghe_ids_in_group[0] %} {% if group_num == 0 %} diff --git a/geojson_modelica_translator/model_connectors/networks/templates/DesignDataSeries_Instance.mopt b/geojson_modelica_translator/model_connectors/networks/templates/DesignDataSeries_Instance.mopt index 1cffde25d..5bdf3b572 100644 --- a/geojson_modelica_translator/model_connectors/networks/templates/DesignDataSeries_Instance.mopt +++ b/geojson_modelica_translator/model_connectors/networks/templates/DesignDataSeries_Instance.mopt @@ -1,13 +1,14 @@ inner parameter {{ model.modelica_type }} {{ model.id }}( nBui={{ sys_params.num_buildings }}, +mPumDis_flow_nominal=max(datDes.mCon_flow_nominal) + datDes.mSto_flow_nominal, +mPipDis_flow_nominal=datDes.mPumDis_flow_nominal, {% if sys_params.district_system.fifth_generation.ghe_parameters.design.flow_type == 'borehole' %} - mPumDis_flow_nominal={{ sys_params.district_system.fifth_generation.ghe_parameters.design.flow_rate* + mSto_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={{ sys_params.district_system.fifth_generation.ghe_parameters.design.flow_rate }}, + mSto_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, final mCon_flow_nominal={ {% for building in range( sys_params.num_buildings - 1 ) %} diff --git a/geojson_modelica_translator/model_connectors/networks/templates/NetworkDistributionPump_Instance.mopt b/geojson_modelica_translator/model_connectors/networks/templates/NetworkDistributionPump_Instance.mopt index 9c31cdebe..e70586f95 100644 --- a/geojson_modelica_translator/model_connectors/networks/templates/NetworkDistributionPump_Instance.mopt +++ b/geojson_modelica_translator/model_connectors/networks/templates/NetworkDistributionPump_Instance.mopt @@ -1,11 +1,7 @@ // ambient loop pump - Buildings.Fluid.Movers.FlowControlled_m_flow pumDis( + Buildings.DHC.ETS.BaseClasses.Pump_m_flow pumDis( redeclare final package Medium = {{ globals.medium_w }}, allowFlowReversal=true, - redeclare Buildings.Fluid.Movers.Data.Generic per, - inputType=Buildings.Fluid.Types.InputType.Continuous, - use_inputFilter=true, - riseTime=20, m_flow_nominal=datDes.mPumDis_flow_nominal, dp_nominal={{ sys_params.district_system.fifth_generation.central_pump_parameters.pump_design_head }}) "Distribution pump" diff --git a/geojson_modelica_translator/model_connectors/plants/templates/Borefield_Instance.mopt b/geojson_modelica_translator/model_connectors/plants/templates/Borefield_Instance.mopt index 063b4a1e3..fc8c73c20 100644 --- a/geojson_modelica_translator/model_connectors/plants/templates/Borefield_Instance.mopt +++ b/geojson_modelica_translator/model_connectors/plants/templates/Borefield_Instance.mopt @@ -1,3 +1,37 @@ + parameter Modelica.Units.SI.Length dhSto_{{ model.id }}(fixed=false,start=0.05,min=0.01) + "Hydraulic diameter of the distribution pipe before each connection"; + Buildings.DHC.ETS.BaseClasses.Pump_m_flow pumSto_{{ model.id }}( + dp_nominal=30000, + redeclare final package Medium = {{ globals.medium_w }}, + m_flow_nominal=datDes.mSto_flow_nominal) + "Bore field pump" + {% raw %}annotation (Placement(transformation(extent={{10,10},{-10,-10}},rotation=180,origin={-30,50}))); +{% endraw %} + Buildings.DHC.Networks.Connections.Connection1Pipe_R conSto_{{ model.id }}( + redeclare final package Medium = {{ globals.medium_w }}, + final mDis_flow_nominal=datDes.mPipDis_flow_nominal, + final mCon_flow_nominal=datDes.mSto_flow_nominal, + lDis=0, + final allowFlowReversal=allowFlowReversalSer, + dhDis=dhSto_{{ model.id }}) + "Connection to the bore field (pressure drop lumped in plant and network model)" + {% raw %}annotation (Placement(transformation(extent={{-10,-10},{10,10}},rotation=0,origin={-18,10}))); +{% endraw %} + Buildings.DHC.Networks.Controls.AgentPump1Pipe conBor_{{ model.id }}( + yPumMin=0, + dToff=0.45, + k=1.1, + Ti=600, + uLowHea=0.25, + uHighHea=0.5, + uLowCoo=0.15, + uHighCoo=0.4) "Borefield GHE pump controller" + {% raw %}annotation (Placement(transformation(extent={{-60,80},{-40,100}}))); +{% endraw %} + Buildings.Controls.OBC.CDL.Reals.MultiplyByParameter gai1_{{ model.id }}(k=datDes.mSto_flow_nominal) + "Scale with nominal mass flow rate" + {% raw %}annotation (Placement(transformation(extent={{-30,80},{-10,100}}))); +{% endraw %} {{ model.modelica_type }} {{ model.id }} {% raw %}annotation (Placement(transformation(extent={{-10,0},{10,20}}))); {% endraw %} diff --git a/tests/model_connectors/data/_loop_order_2.json b/tests/model_connectors/data/_loop_order_2.json deleted file mode 100644 index b07fecef3..000000000 --- a/tests/model_connectors/data/_loop_order_2.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "list_bldg_ids_in_group": [ - "0" - ], - "list_ghe_ids_in_group": [ - "0b575a8f-97d1-47e6-b329-7ef7566d26f2", - "47fd01d3-3d72-46c0-85f2-a12854783764" - ] - } -] diff --git a/tests/model_connectors/data/sdk_output_skeleton_13_buildings/run/baseline_scenario/ghe_dir/sys_params_proportional.json b/tests/model_connectors/data/sdk_output_skeleton_13_buildings/run/baseline_scenario/ghe_dir/sys_params_proportional.json index a8a170c3b..6e52afb96 100644 --- a/tests/model_connectors/data/sdk_output_skeleton_13_buildings/run/baseline_scenario/ghe_dir/sys_params_proportional.json +++ b/tests/model_connectors/data/sdk_output_skeleton_13_buildings/run/baseline_scenario/ghe_dir/sys_params_proportional.json @@ -581,7 +581,7 @@ }, "central_pump_parameters": { "pump_flow_rate": 0.01, - "pump_design_head": 10000000 + "pump_design_head": 600000000 } } }, diff --git a/tests/model_connectors/data/system_params_ghe_3.json b/tests/model_connectors/data/system_params_ghe_2.json similarity index 99% rename from tests/model_connectors/data/system_params_ghe_3.json rename to tests/model_connectors/data/system_params_ghe_2.json index 167e20676..9744ce6c9 100644 --- a/tests/model_connectors/data/system_params_ghe_3.json +++ b/tests/model_connectors/data/system_params_ghe_2.json @@ -73,7 +73,7 @@ "district_system": { "fifth_generation": { "central_pump_parameters": { - "pump_design_head": 60000, + "pump_design_head": 300000, "pump_flow_rate": 0.01 }, "horizontal_piping_parameters": { diff --git a/tests/model_connectors/test_borefield.py b/tests/model_connectors/test_borefield.py deleted file mode 100644 index 9c3a0d23a..000000000 --- a/tests/model_connectors/test_borefield.py +++ /dev/null @@ -1,58 +0,0 @@ -# :copyright (c) URBANopt, Alliance for Sustainable Energy, LLC, and other contributors. -# See also https://github.com/urbanopt/geojson-modelica-translator/blob/develop/LICENSE.md - -from pathlib import Path - -import pytest - -from geojson_modelica_translator.model_connectors.couplings.coupling import Coupling -from geojson_modelica_translator.model_connectors.couplings.graph import CouplingGraph -from geojson_modelica_translator.model_connectors.districts.district import District -from geojson_modelica_translator.model_connectors.networks.network_ambient_water_stub import NetworkAmbientWaterStub -from geojson_modelica_translator.model_connectors.plants.borefield import Borefield -from geojson_modelica_translator.system_parameters.system_parameters import SystemParameters -from tests.base_test_case import TestCaseBase - - -class DistrictSystemTest(TestCaseBase): - def setUp(self): - super().setUp() - - project_name = "borefield_stub" - self.data_dir, self.output_dir = self.set_up(Path(__file__).parent, project_name) - - # load system parameter data - filename = Path(self.data_dir) / "system_params_ghe.json" - sys_params = SystemParameters(filename) - - # create ambient water stub - ambient_water_stub = NetworkAmbientWaterStub(sys_params) - - all_couplings = [] - for ghe in sys_params.get_param("$.district_system.fifth_generation.ghe_parameters.ghe_specific_params"): - # create borefields - borefield = Borefield(sys_params, ghe) - # couple each borefield to the thermal loop - all_couplings.append(Coupling(borefield, ambient_water_stub, district_type="fifth_generation")) - - graph = CouplingGraph(all_couplings) - - self.district = District( - root_dir=self.output_dir, project_name=project_name, system_parameters=sys_params, coupling_graph=graph - ) - self.district.to_modelica() - - def test_build_district_system(self): - root_path = Path(self.district._scaffold.districts_path.files_dir).resolve() - assert (root_path / "DistrictEnergySystem.mo").exists() - - @pytest.mark.simulation - def test_simulate_district_system(self): - self.run_and_assert_in_docker( - f"{self.district._scaffold.project_name}.Districts.DistrictEnergySystem", - file_to_load=self.district._scaffold.package_path, - run_path=self.district._scaffold.project_path, - start_time=17280000, # Day 200 (in seconds) (Run in summer to keep chiller happy) - stop_time=17366400, # For 1 day duration (in seconds) - step_size=3600, # (in seconds) - ) diff --git a/tests/model_connectors/test_district_single_ghe.py b/tests/model_connectors/test_district_single_ghe.py index d64ad2090..21999e1b3 100644 --- a/tests/model_connectors/test_district_single_ghe.py +++ b/tests/model_connectors/test_district_single_ghe.py @@ -32,7 +32,7 @@ def setUp(self): self.gj = UrbanOptGeoJson(geojson_filename) # load system parameter data - sys_param_filename = Path(self.data_dir) / "system_params_ghe_3.json" + sys_param_filename = Path(self.data_dir) / "system_params_ghe_2.json" sys_params = SystemParameters(sys_param_filename) # read the loop order and create building groups