Skip to content

Commit

Permalink
Closed-loop changes to existing test_single_ghe test (#597)
Browse files Browse the repository at this point in the history
* Add Q_flow output

* Add function for saving the used gfunction to tmp

* Change length to length_of_boreholes

* Add temp sensors and pump controller

* Modify connections for closed loop

* Change expansion vessel port number

* Take out hard code

* Enlarge number of boreholes

* Enlarge default borehole length

* Disable use_m_flow_in for GHE test

* Pre-commit changes

* pre-commit to run modelica-formatter

---------

Co-authored-by: Nathan Moore <nathan.moore@nrel.gov>
  • Loading branch information
JingWang-CUB and vtnate committed Nov 29, 2023
1 parent e90cb3e commit e32ce97
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 19 deletions.
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 @@ -3,11 +3,12 @@
{% for building in range( sys_params.num_buildings ) %}
Buildings.Fluid.Sources.MassFlowSource_T supHeaWat_{{ building + 1 }}(
redeclare package Medium={{ globals.medium_w }},
use_m_flow_in=true,
use_T_in=false,
{% if 'ghe_parameters' in sys_params.district_system['fifth_generation'] %}
use_m_flow_in=false,
T={{ sys_params.district_system.fifth_generation.ghe_parameters.soil.undisturbed_temp }}+273.15,
{% else %}
use_m_flow_in=true,
T={{ sys_params.district_system.fifth_generation.central_heating_plant_parameters.temp_setpoint_hhw }}+273.15,
{% endif %}
nPorts=1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,29 @@
m_flow_nominal=datDes.mPumDis_flow_nominal)
"Distribution pump"
{% raw %}annotation (Placement(transformation(extent={{10,-10},{-10,10}},rotation=270,origin={-44,-60})));
{% endraw %}Modelica.Blocks.Sources.Constant masFloMaiPum(k=datDes.mPumDis_flow_nominal)
"Distribution pump mass flow rate"
{% raw %}annotation (Placement(transformation(extent={{0,-70},{-20,-50}})));
{% endraw %}// pump controller
Buildings.Experimental.DHC.Networks.Controls.MainPump conPum(
nMix=datDes.nBui,
nSou=1,
use_temperatureShift=false)
{% raw %}annotation (Placement(transformation(extent={{-120,-100},{-100,-80}})));
{% endraw %}Buildings.Controls.OBC.CDL.Continuous.MultiplyByParameter gai(k=datDes.mPumDis_flow_nominal)
"Scale with nominal mass flow rate"
{% raw %}annotation (Placement(transformation(extent={{-80,-100},{-60,-80}})));
{% endraw %}// expansion vessel
Buildings.Fluid.Sources.Boundary_pT expVes(
redeclare final package Medium = {{ globals.medium_w }},
T={{ sys_params.district_system.fifth_generation.ghe_parameters.soil.undisturbed_temp}}+273.15,
nPorts=2)
nPorts=1)
"Expansion vessel"
{% raw %}annotation (Placement(transformation(extent={{140,-76},{120,-56}})));
{% endraw %}// temperature sensors
Buildings.Fluid.Sensors.TemperatureTwoPort TIn(
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={110,-30})));
{% endraw %}Buildings.Fluid.Sensors.TemperatureTwoPort TOut(
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 %}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ within {{ project_name }}.Plants.{{ model_name }};
start=TExt0_start)
"Average borehole wall temperature in the borefield"
annotation (Placement(transformation(extent={{100,34},{120,54}})));
Buildings.Controls.OBC.CDL.Interfaces.RealOutput Q_flow(
final unit="W")
"Rate at which heat is extracted from soil"
annotation (Placement(transformation(extent={{100,-50},{120,-30}}),iconTransformation(extent={{100,-64},{140,-24}})));
{% endraw %}{{ project_name }}.Plants.GroundTemperatureResponse groTemRes(
{% raw %}final tLoaAgg=tLoaAgg,
final nCel=nCel,
Expand Down Expand Up @@ -211,6 +215,8 @@ equation
annotation (Line(points={{31,30},{36,30},{36,44},{48,44}},color={0,0,127}));
connect(AveTBor.y,TBorAve)
annotation (Line(points={{71,44},{110,44}},color={0,0,127}));
connect(gaiQ_flow.y,Q_flow)
annotation (Line(points={{1,80},{12,80},{12,60},{94,60},{94,-40},{110,-40}},color={0,0,127}));
annotation (
Icon(
coordinateSystem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ within {{ project_name }}.Plants.{{ model_name }};
start=TExt0_start)
"Average borehole wall temperature in the borefield"
annotation (Placement(transformation(extent={{100,34},{120,54}})));
Buildings.Controls.OBC.CDL.Interfaces.RealOutput Q_flow(
final unit="W")
"Rate at which heat is extracted from soil"
annotation (Placement(transformation(extent={{100,-50},{120,-30}}),iconTransformation(extent={{100,-64},{140,-24}})));
{% endraw %}{{ project_name }}.Plants.GroundTemperatureResponse groTemRes(
{% raw %}final tLoaAgg=tLoaAgg,
final nCel=nCel,
Expand Down Expand Up @@ -211,6 +215,8 @@ equation
annotation (Line(points={{31,30},{36,30},{36,44},{48,44}},color={0,0,127}));
connect(AveTBor.y,TBorAve)
annotation (Line(points={{71,44},{110,44}},color={0,0,127}));
connect(gaiQ_flow.y,Q_flow)
annotation (Line(points={{1,80},{12,80},{12,60},{94,60},{94,-40},{110,-40}},color={0,0,127}));
annotation (
Icon(
coordinateSystem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ model GroundTemperatureResponse
"File name of g-function data file in MAT format";
parameter Integer nTimTot=76
"Total length of g-function vector";
Boolean writegFun
"True if g-function was succesfully written to file";
Modelica.Blocks.Interfaces.RealOutput delTBor(
unit="K")
"Temperature difference current borehole wall temperature minus initial borehole wall temperature"
Expand Down Expand Up @@ -144,7 +146,17 @@ initial equation
ttsMax=ttsMax,
sha=SHAgfun,
forceGFunCalc=forceGFunCalc);
*/equation
*/algorithm
Modelica.Utilities.Files.createDirectory(
"tmp");
Modelica.Utilities.Files.createDirectory(
"tmp/temperatureResponseMatrix");
writegFun := Modelica.Utilities.Streams.writeRealMatrix(
fileName="tmp/temperatureResponseMatrix/TStep.mat",
matrixName="TStep",
matrix=timSer,
append=false);
equation
der(
delTBor)=dTStepdt*QBor_flow+derDelTBor0;
der(
Expand Down
4 changes: 2 additions & 2 deletions tests/model_connectors/data/system_params_ghe.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"borehole": {
"buried_depth": 2.0,
"diameter": 0.15,
"length_of_boreholes": 1.0,
"length_of_boreholes": 100,
"number_of_boreholes": 5
}
},
Expand All @@ -106,7 +106,7 @@
"borehole": {
"buried_depth": 2.0,
"diameter": 0.15,
"length_of_boreholes": 1.0,
"length_of_boreholes": 100,
"number_of_boreholes": 5
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/model_connectors/data/system_params_ghe_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"buried_depth": 2.0,
"diameter": 0.15,
"length_of_boreholes": 150,
"number_of_boreholes": 4
"number_of_boreholes": 40
}
}
]
Expand Down

0 comments on commit e32ce97

Please sign in to comment.