Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
aedf419
added coupling files
JayHuLBL Sep 27, 2022
f056e4c
corrected comments
JayHuLBL Sep 27, 2022
c086363
creating the dummy code
JayHuLBL Sep 28, 2022
8ac10d6
adding user guide
JayHuLBL Sep 30, 2022
ee88d9f
merged master
JayHuLBL Jan 4, 2023
722f65c
updated python code comments
JayHuLBL Jan 4, 2023
1a7f512
updated SI units
JayHuLBL Jan 4, 2023
7c8c720
created tough avatot
JayHuLBL Jan 4, 2023
1b92a77
updated modelica-tough user guide
JayHuLBL Jan 7, 2023
2f80ca5
Merge branch 'master' into issue1495_clean_Mo2To_Interface
JayHuLBL Feb 2, 2023
2bf3b3a
added toughTemp folder
JayHuLBL Feb 23, 2023
3b82fa8
dummy commit
JayHuLBL Mar 1, 2023
8f71638
converting Fortran script to python
JayHuLBL Apr 19, 2023
4f5090f
converting fortran code
JayHuLBL Apr 19, 2023
a295afc
converting script
JayHuLBL Apr 20, 2023
ec2a088
converted Fortran functinality to python
JayHuLBL Apr 21, 2023
55b65a9
dummy commit
JayHuLBL Apr 24, 2023
3322640
changed the data format to fortran style
JayHuLBL May 1, 2023
a65d87c
corrected data format, so have the right results
JayHuLBL May 1, 2023
3d793e1
Updated user guide for TOUGH coupling
EttoreZ Feb 27, 2024
e8fa41b
Merge branch 'master' into issue1495_clean_Mo2To_Interface
JayHuLBL Mar 8, 2024
f700977
cleaned the documentation
JayHuLBL Mar 9, 2024
c9da375
added the toughTemp
JayHuLBL Mar 9, 2024
3bd73f8
used the tough avatar code, updated reference
JayHuLBL Mar 11, 2024
52b7601
updated revision note
JayHuLBL Mar 11, 2024
cb09d53
Merge branch 'master' into issue1495_clean_Mo2To_Interface
JayHuLBL Mar 11, 2024
f50d995
added release note
JayHuLBL Mar 11, 2024
041bec9
updated flow chart figure
JayHuLBL Mar 11, 2024
17a54f1
added to the exclusion list
JayHuLBL Mar 12, 2024
d8e7e38
added toughTemp folder
JayHuLBL Mar 12, 2024
0015cf2
avoided delete the Dummy file
JayHuLBL Mar 12, 2024
70db3f3
deleted not used files
JayHuLBL Mar 15, 2024
048b8ed
sorted configuration file conf.yml
JayHuLBL Mar 15, 2024
5b578e7
Merge branch 'master' into issue1495_clean_Mo2To_Interface
JayHuLBL Mar 15, 2024
7e66505
increased the time out time
JayHuLBL Mar 27, 2024
626cb06
merged master
JayHuLBL May 2, 2024
fe42068
temporary disabled other tests
JayHuLBL May 3, 2024
dcb2bb6
merged master
JayHuLBL Jun 11, 2024
4b6f924
merged master
JayHuLBL Jun 11, 2024
41c873a
removed obsolete text [ci skip]
JayHuLBL Jun 11, 2024
20de026
Update TOUGH co-simulation script
EttoreZ Jun 22, 2024
f962393
merged master
JayHuLBL Nov 13, 2024
b3da830
updated reference
JayHuLBL Nov 14, 2024
3cfaace
added model to exclude optimica CI test
JayHuLBL Nov 14, 2024
b2d89b2
enabled all ci tests
JayHuLBL Nov 15, 2024
b959c9a
improved documentation
JayHuLBL Nov 15, 2024
9d3aacb
corrected typo, added reference
JayHuLBL Nov 19, 2024
06948ef
Merge branch 'master' into issue1495_clean_Mo2To_Interface
JayHuLBL Mar 13, 2025
92d2caa
merged master
JayHuLBL May 14, 2025
4de65cf
improving tutorial
JayHuLBL May 15, 2025
9e2beb7
merged master
JayHuLBL Sep 9, 2025
f15c2fd
Merge branch 'master' into issue1495_clean_Mo2To_Interface
JayHuLBL Sep 15, 2025
cfb271a
refining guide [ci skip]
JayHuLBL Sep 16, 2025
c1a5464
Merge branch 'master' into issue1495_clean_Mo2To_Interface
JayHuLBL Sep 18, 2025
375d688
fixed typo
JayHuLBL Sep 18, 2025
17485ad
improved documentation
JayHuLBL Sep 19, 2025
60826d3
Started revising the user guide. Renamed files [ci skip]
mwetter Sep 25, 2025
b233e0f
Merge branch 'master' into issue1495_clean_Mo2To_Interface
JayHuLBL Sep 26, 2025
fd061c0
Merge branch 'issue1495_clean_Mo2To_Interface' of https://github.com/…
JayHuLBL Sep 26, 2025
99b0521
debuging the example models
JayHuLBL Sep 26, 2025
c6364a7
merged master [ci skip]
JayHuLBL Jan 11, 2026
3337a9e
Merge branch 'master' into issue1495_clean_Mo2To_Interface
JayHuLBL Jan 13, 2026
9de5ff7
debugging python
JayHuLBL Jan 13, 2026
cddc362
updated reference [ci skip]
JayHuLBL Jan 14, 2026
a89688d
improved the python code so the TOUGH working folder in system temp f…
JayHuLBL Jan 14, 2026
8d5dd51
updated python code comments
JayHuLBL Jan 15, 2026
b6d5f48
added number of modelica segment and the interested observation points
JayHuLBL Jan 15, 2026
bda3509
added number of TOUGH grids, bore length as python input
JayHuLBL Jan 15, 2026
63afc77
addressing comments
JayHuLBL Jan 21, 2026
b042f80
renamed the package
JayHuLBL Jan 21, 2026
474e87b
corrected wrong syntax
JayHuLBL Jan 21, 2026
0bf0c5a
corrected OME error
JayHuLBL Jan 21, 2026
1807ae7
deleted binary
JayHuLBL Jan 22, 2026
e2593df
renamed the image folder
JayHuLBL Jan 23, 2026
d2f22b0
cleaned up the user guide and documentation
JayHuLBL Jan 26, 2026
a901146
Merge branch 'master' into issue1495_clean_Mo2To_Interface
JayHuLBL Feb 5, 2026
bc3a5b5
renamed class
JayHuLBL Feb 5, 2026
9040e80
updated guide and improved dummy code
JayHuLBL Feb 6, 2026
763b9c1
Merge branch 'master' into issue1495_clean_Mo2To_Interface
JayHuLBL Feb 6, 2026
50f6598
fixed text color annotation
JayHuLBL Feb 6, 2026
8c85d40
changed display variables
JayHuLBL Feb 20, 2026
dcd7748
fixed typo
JayHuLBL Feb 23, 2026
5a5373b
increased the timeout
JayHuLBL Feb 27, 2026
66d5911
Merge branch 'master' into issue1495_clean_Mo2To_Interface
JayHuLBL Mar 10, 2026
6718860
changed working folder permission
JayHuLBL Mar 10, 2026
b5726d0
updated BESTEST references
JayHuLBL Mar 10, 2026
fa04c74
reverted the accidently changed references
JayHuLBL Mar 10, 2026
ea075b4
Merge branch 'master' into issue1495_clean_Mo2To_Interface
JayHuLBL Mar 13, 2026
cf28559
merged master and updated to use Python3.12
JayHuLBL Mar 13, 2026
fc02408
merged master and updated to use Python3.12
JayHuLBL Mar 13, 2026
5d1c541
Merge branch 'master' into issue1495_clean_Mo2To_Interface
JayHuLBL Mar 16, 2026
c495dd7
test commit, to check if creating temp folder causing CI test error
JayHuLBL Mar 17, 2026
33ffdd5
testing add folder removing in the mos
JayHuLBL Mar 17, 2026
fa1c193
updated comment
JayHuLBL Mar 17, 2026
e3485d1
reverted changes
JayHuLBL Mar 17, 2026
ed4ea29
improved comments
JayHuLBL Mar 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
within Buildings.Fluid.Geothermal.Borefields.TOUGH.BaseClasses;
model GroundResponse "Ground response calculated by the TOUGH simulator"

parameter Modelica.Units.SI.Height hBor "Total height of the borehole";
parameter Integer nSeg "Total number of segments";
parameter Integer nInt "Number of points in the ground to be investigated";
parameter Integer nTouSeg "Total number of grids along the entire borehole in the TOUGH mesh";
parameter Modelica.Units.SI.Time samplePeriod "Sample period of component"
annotation(Dialog(group="Sampling"));

Modelica.Blocks.Interfaces.RealInput QBor_flow[nSeg](
final unit=fill("W", nSeg))
"Heat flow from boreholes (positive if heat from fluid into soil)"
annotation (Placement(transformation(extent={{-140,20},{-100,60}}),
iconTransformation(extent={{-120,50},{-100,70}})));
Modelica.Blocks.Interfaces.RealInput TBorWal_start[nSeg](
final unit=fill("K", nSeg),
displayUnit=fill("degC", nSeg),
quantity=fill("ThermodynamicTemperature", nSeg))
"Initial borehole outer wall temperature at the begining of the simulation"
annotation (Placement(transformation(extent={{-140,-20},{-100,20}}),
iconTransformation(extent={{-120,-10},{-100,10}})));
Modelica.Blocks.Interfaces.RealInput TOut(
final unit="K",
displayUnit="degC",
quantity="ThermodynamicTemperature")
"Outdoor air temperature"
annotation (Placement(transformation(extent={{-140,-60},{-100,-20}}),
iconTransformation(extent={{-120,-70},{-100,-50}})));
Modelica.Blocks.Interfaces.RealOutput TBorWal[nSeg](
final unit=fill("K", nSeg),
displayUnit=fill("degC", nSeg),
quantity=fill("ThermodynamicTemperature", nSeg))
"Temperature of current borehole wall temperature"
annotation (Placement(transformation(extent={{100,40},{140,80}}),
iconTransformation(extent={{100,50},{120,70}})));
Modelica.Blocks.Interfaces.RealOutput pInt[nInt]
"Pressure of the interested points in the ground"
annotation (Placement(transformation(extent={{100,0},{140,40}}),
iconTransformation(extent={{100,10},{120,30}})));
Modelica.Blocks.Interfaces.RealOutput xInt[nInt]
"Satuation of the interested points in the ground"
annotation (Placement(transformation(extent={{100,-40},{140,0}}),
iconTransformation(extent={{100,-30},{120,-10}})));
Modelica.Blocks.Interfaces.RealOutput TInt[nInt](
final unit=fill("K", nInt),
displayUnit=fill("degC", nInt),
quantity=fill("ThermodynamicTemperature", nInt))
"Temperature at the interested points in the ground"
annotation (Placement(transformation(extent={{100,-80},{140,-40}}),
iconTransformation(extent={{100,-70},{120,-50}})));

Buildings.Utilities.IO.Python_3_12.Real_Real pyt(
final moduleName="GroundResponse",
final functionName="doStep",
final nDblRea=nSeg+3*nInt,
final nDblWri=2*nSeg + 6,
final samplePeriod=samplePeriod,
final flag=0,
final passPythonObject=true)
"Python interface model to call TOUGH simulator"
annotation (Placement(transformation(extent={{40,-10},{60,10}})));
Modelica.Blocks.Routing.Multiplex mul(
final n=2*nSeg + 6)
"Multiplex"
annotation (Placement(transformation(extent={{0,-10},{20,10}})));
Modelica.Blocks.Sources.ContinuousClock clock
"Current time"
annotation (Placement(transformation(extent={{-80,-70},{-60,-50}})));
Buildings.Controls.OBC.CDL.Reals.Sources.Constant griNum[3](
final k={nSeg,nTouSeg,nInt}) "Total number of grids"
annotation (Placement(transformation(extent={{-80,60},{-60,80}})));
Buildings.Controls.OBC.CDL.Reals.Sources.Constant borHei(final k=hBor)
"Total height of the borehole"
annotation (Placement(transformation(extent={{-40,-90},{-20,-70}})));

equation
// Delete the TOUGH temporary working folder
// Note that the working folder path is specified in the Python function.
when {terminal()} then
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The terminal() function is not supported by Optimica 1.66.

The function is also being used in Buildings.DHC.Loads.HotWater.ThermostaticMixingValve. Running the model Buildings.DHC.Loads.HotWater.Examples.StorageTankWithExternalHeatExchanger with Optimica 1.66, we can see

In component theMixVal:
    The terminal() operator is not supported, and is currently evaluated to false

Modelica.Utilities.Files.remove("Resources/Python-Sources/tmp-tou-work");
end when;

connect(pyt.yR[1:nSeg], TBorWal)
annotation (Line(points={{61,0},{80,0},{80,60},{120,60}}, color={0,0,127}));
connect(mul.y, pyt.uR)
annotation (Line(points={{21,0},{38,0}},color={0,0,127}));
connect(pyt.yR[nSeg + 1:nSeg + nInt], pInt) annotation (Line(points={{61,0},{80,
0},{80,20},{120,20}}, color={0,0,127}));
connect(pyt.yR[nSeg+nInt+1:nSeg+2*nInt], xInt)
annotation (Line(points={{61,0},{80,0},{80,-20},{120,-20}}, color={0,0,127}));
connect(pyt.yR[nSeg+2*nInt+1:nSeg+3*nInt], TInt)
annotation (Line(points={{61,0},{80,0},{80,-60},{120,-60}}, color={0,0,127}));
connect(griNum.y, mul.u[1:3]) annotation (Line(points={{-58,70},{-30,70},{-30,
0},{0,0}}, color={0,0,127}));
connect(QBor_flow, mul.u[4:nSeg+3]) annotation (Line(points={{-120,40},{-40,40},
{-40,0},{0,0}}, color={0,0,127}));
connect(TBorWal_start, mul.u[nSeg+4:2*nSeg+3]) annotation (Line(points={{-120,0},
{0,0}}, color={0,0,127}));
connect(TOut, mul.u[2*nSeg+4]) annotation (Line(points={{-120,-40},{-40,-40},{
-40,0},{0,0}}, color={0,0,127}));
connect(clock.y, mul.u[2*nSeg+5]) annotation (Line(points={{-59,-60},{-30,-60},
{-30,0},{0,0}}, color={0,0,127}));
connect(borHei.y, mul.u[2*nSeg+6]) annotation (Line(points={{-18,-80},{-10,-80},
{-10,0},{0,0}}, color={0,0,127}));

annotation (defaultComponentName="toughRes",
Icon(coordinateSystem(preserveAspectRatio=false), graphics={
Rectangle(
extent={{-100,100},{100,-100}},
lineColor={0,0,0},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{-100,30},{100,-100}},
lineColor={0,0,0},
fillColor={127,127,0},
fillPattern=FillPattern.Solid),
Rectangle(
extent={{-52,30},{-94,-100}},
lineColor={0,0,0},
fillColor={135,135,135},
fillPattern=FillPattern.Solid),
Line(
points={{-66,-4},{72,-4}},
color={255,0,0},
arrow={Arrow.None,Arrow.Filled}),
Rectangle(
extent={{-100,30},{-94,-100}},
lineColor={0,0,0},
fillColor={0,128,255},
fillPattern=FillPattern.Solid),
Text(
extent={{-150,150},{150,110}},
textString="%name",
textColor={0,0,255})}), Diagram(coordinateSystem(preserveAspectRatio=
false)),
Documentation(info="<html>
<p>
This model calculates the ground temperature response to obtain the temperature
at the borehole wall in a geothermal system where heat is being injected into or
extracted from the ground.
</p>
<p>
The instance <code>pyt</code> finds the ground response with the
<a href=\"https://tough.lbl.gov/software/tough3\">TOUGH</a> simulator
through the Python interface
<a href=\"modelica://Buildings.Utilities.IO.Python_3_12.Real_Real\">
Buildings.Utilities.IO.Python_3_12.Real_Real</a>. See
<a href=\"modelica://Buildings.Fluid.Geothermal.Borefields.TOUGH.UsersGuide\">
Buildings.Fluid.Geothermal.Borefields.TOUGH.UsersGuide</a>
for instructions.
</p>
</html>", revisions="<html>
<ul>
<li>
March 8, 2024, by Jianjun Hu:<br/>
First implementation.
</li>
</ul>
</html>"));
end GroundResponse;
Loading
Loading