Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue1785 modelica conf tutorial #1788

Merged
merged 51 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
53f86ac
First version of the intermediate results of the SimpleHouse exercise…
jelgerjansen Sep 6, 2023
0cc1328
Include diagram and experiment annotations in all models since this i…
jelgerjansen Sep 6, 2023
6de6c0d
Slightly replace a connection line
jelgerjansen Sep 6, 2023
926f5f6
Update documentation of KU Leuven Modelica crash course to be used in…
jelgerjansen Sep 6, 2023
7c39a70
Merge pull request #1783 from jelgerjansen/modelicaConferenceWorkshop
mwetter Sep 6, 2023
3962270
Move the SimpleHouse Modelica models to 'Fluid.Examples.Tutorial.Simp…
jelgerjansen Sep 7, 2023
34061c2
Move LaTeX files to IBPSA/Resources/Documentation/Fluid/Examples/Tuto…
jelgerjansen Sep 7, 2023
8250965
Add a short description in the info section of the examples and move …
jelgerjansen Sep 7, 2023
8264fef
Add regression tests for each model.
jelgerjansen Sep 7, 2023
b55edbd
Add Tolerance to experiment annotation
jelgerjansen Sep 7, 2023
5766402
Made editorial revision
mwetter Sep 8, 2023
7665717
Add exercise to the info section of the Modelica models.
jelgerjansen Sep 8, 2023
d2a82e0
Corrected typo
mwetter Sep 8, 2023
5c82475
Added full name (so that renaming works robustly)
mwetter Sep 8, 2023
7f93094
Increased tolerances to 1E-6, added test case and results
mwetter Sep 8, 2023
98c56b0
Moved tutorial
mwetter Sep 11, 2023
625b981
Corrected hyperlinks
mwetter Sep 11, 2023
e000767
Deleted old files
mwetter Sep 11, 2023
5747b73
Added IBPSA.Examples to CI tests
mwetter Sep 11, 2023
b63b01d
Corrected html syntax
mwetter Sep 11, 2023
b8951a9
Corrected annotation
mwetter Sep 11, 2023
fa40230
Rename SimpleHouseTemplate to SimpleHouse0
jelgerjansen Sep 15, 2023
beb647c
Remove the thermal resistor of the wall from SimpleHouse0 and include…
jelgerjansen Sep 15, 2023
586d689
Rename parameters to comply with the naming convention, fix appearanc…
jelgerjansen Sep 15, 2023
32ba036
Move window to 'wall' block
jelgerjansen Sep 15, 2023
61d4828
Update documentation of SimpleHouse0
jelgerjansen Sep 15, 2023
59b6d11
Extend information section of SimpleHouse0
jelgerjansen Sep 15, 2023
9ddbbde
Rename useConstantHeater to use_constantHeater to comply with the IBP…
jelgerjansen Sep 15, 2023
8e4eb45
Fix small typo in information section of the SimpleHouse package
jelgerjansen Sep 15, 2023
b5fef2f
Update information section of the package itself.
jelgerjansen Sep 15, 2023
f003250
Run dos2unix
mwetter Sep 15, 2023
4e2f13f
Corrected wrong model name
mwetter Sep 15, 2023
6ced3f0
Corrected old use of variable name in scripts
mwetter Sep 15, 2023
4315a72
Corrected name of mos script
mwetter Sep 15, 2023
3efa230
Merge branch 'master' into issue1785_modelicaConfTutorial
mwetter Sep 15, 2023
5d2a6d7
Deleted old mos file
mwetter Sep 15, 2023
4a6ab6a
Added missing reference results
mwetter Sep 15, 2023
bee48ed
Corrected variable names
mwetter Sep 16, 2023
bee86ba
fix poorly displayed connection in OM [ci-skip]
Sep 18, 2023
6e96fd5
Restructure diagram and components and move all building envelope com…
jelgerjansen Sep 18, 2023
11cb524
Make the connector between the constant and heater conditional again
jelgerjansen Sep 18, 2023
dbd1850
Removed BOM and run dos2unix
mwetter Sep 20, 2023
10ff8bb
Use preconfigured movers for circulation pump and fan and added contr…
jelgerjansen Sep 21, 2023
e5c257d
Update documentation section and put required models in alphabetical …
jelgerjansen Sep 21, 2023
6f6c838
Remove BOM
jelgerjansen Sep 21, 2023
0e318be
Revised documentation
mwetter Sep 22, 2023
1b5a7cc
Conditionally removed components, rather than connectors
mwetter Sep 22, 2023
0c21758
Removed BOM
mwetter Sep 22, 2023
2efca98
Merge branch 'master' into issue1785_modelicaConfTutorial
mwetter Sep 22, 2023
ada3549
Added comments, updated reference results, changed parameter to constant
mwetter Sep 22, 2023
a50b2b5
Removed BOM
mwetter Sep 22, 2023
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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ env:
# Test matrix for regression tests.
# The documentation is tested using github actions.
- TEST_ARG="make test-bestest"
- TEST_ARG="make test-dymola PACKAGE=\"IBPSA.Experimental\""
- TEST_ARG="make test-openmodelica PACKAGE=\"IBPSA.Experimental\""
- TEST_ARG="make test-dymola PACKAGE=\"IBPSA.{Examples,Experimental}\""
- TEST_ARG="make test-openmodelica PACKAGE=\"IBPSA.{Examples,Experimental}\""
- TEST_ARG="make test-dymola PACKAGE=\"IBPSA.Fluid.{Actuators,BaseClasses,Chillers,Delays,Geothermal,Examples,FMI,FixedResistances}\""
- TEST_ARG="make test-openmodelica PACKAGE=\"IBPSA.Fluid.{Actuators,BaseClasses,Chillers,Delays,Geothermal,Examples,FMI,FixedResistances}\""
- TEST_ARG="make test-dymola PACKAGE=\"IBPSA.Fluid.{HeatExchangers,HeatPumps,Humidifiers,Interfaces,MassExchangers,MixingVolumes,Movers,Sensors,Sources,Storage}\""
Expand Down
99 changes: 99 additions & 0 deletions IBPSA/Examples/Tutorial/SimpleHouse/SimpleHouse0.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
within IBPSA.Examples.Tutorial.SimpleHouse;
model SimpleHouse0
"Start file for simple house example"
extends Modelica.Icons.Example;
package MediumAir = IBPSA.Media.Air "Medium model for air";
package MediumWater = IBPSA.Media.Water "Medium model for water";
parameter Modelica.Units.SI.Area AWall = 100 "Wall area";
parameter Modelica.Units.SI.Length dWall = 0.25 "Wall thickness";
parameter Modelica.Units.SI.ThermalConductivity kWall = 0.04 "Wall thermal conductivity";
parameter Modelica.Units.SI.Density rhoWall = 2000 "Wall density";
parameter Modelica.Units.SI.SpecificHeatCapacity cpWall = 1000 "Wall specific heat capacity";
IBPSA.BoundaryConditions.WeatherData.ReaderTMY3 weaDat(filNam=
ModelicaServices.ExternalReferences.loadResource(
"modelica://IBPSA/Resources/weatherdata/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.mos"))
"Weather data reader"
annotation (Placement(transformation(extent={{-200,-20},{-180,0}})));
IBPSA.BoundaryConditions.WeatherData.Bus weaBus "Weather data bus"
annotation (Placement(transformation(extent={{-160,-20},{-140,0}})));
Modelica.Thermal.HeatTransfer.Sources.PrescribedTemperature TOut
"Exterior temperature boundary condition"
annotation (Placement(transformation(extent={{-80,-10},{-60,10}})));
equation
connect(weaDat.weaBus, weaBus) annotation (Line(
points={{-180,-10},{-150,-10}},
color={255,204,51},
thickness=0.5));
connect(TOut.T, weaBus.TDryBul)
annotation (Line(points={{-82,0},{-150,0},{-150,-10}},color={0,0,127}));
annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-240,
-220},{200,200}}), graphics={
Rectangle(
extent={{-220,40},{-38,-40}},
fillColor={238,238,238},
fillPattern=FillPattern.Solid,
pattern=LinePattern.None),
Rectangle(
extent={{-220,-60},{180,-200}},
fillColor={238,238,238},
fillPattern=FillPattern.Solid,
pattern=LinePattern.None),
Rectangle(
extent={{-220,180},{180,60}},
fillColor={238,238,238},
fillPattern=FillPattern.Solid,
pattern=LinePattern.None),
Rectangle(
extent={{-20,40},{180,-40}},
fillColor={238,238,238},
fillPattern=FillPattern.Solid,
pattern=LinePattern.None),
Text(
extent={{22,22},{-23,39}},
textColor={0,0,127},
fillColor={255,213,170},
fillPattern=FillPattern.Solid,
textString="Wall"),
Text(
extent={{-157,-79},{-223,-61}},
textColor={0,0,127},
fillColor={255,213,170},
fillPattern=FillPattern.Solid,
textString="Heating"),
Text(
extent={{-118,18},{-214,40}},
textColor={0,0,127},
fillColor={255,213,170},
fillPattern=FillPattern.Solid,
textString="Weather inputs"),
Text(
extent={{-76,158},{-214,180}},
textColor={0,0,127},
fillColor={255,213,170},
fillPattern=FillPattern.Solid,
textString="Cooling and ventilation")}),
experiment(Tolerance=1E-6, StopTime=1e+06),
__Dymola_Commands(file=
"modelica://IBPSA/Resources/Scripts/Dymola/Examples/Tutorial/SimpleHouse/SimpleHouse0.mos"
"Simulate and plot"),
Documentation(revisions="<html>
<ul>
<li>
September 4, 2023, by Jelger Jansen:<br/>
Replace IDEAS by IBPSA models.
</li>
<li>
October 11, 2016, by Filip Jorissen:<br/>
First implementation.
</li>
</ul>
</html>", info="<html>
<p>
This model is used as the starting point for the <code>SimpleHouse</code> tutorial.
It contains a weather data reader and a <code>PrescribedTemperature</code> component
that allows the user to connect thermal components to the dry bulb temperature.
It was based on from the Modelica crash course organised by KU Leuven
(<a href=\"https://github.com/open-ideas/__CrashCourse__\">https://github.com/open-ideas/__CrashCourse__</a>).
</p>
</html>"));
end SimpleHouse0;
89 changes: 89 additions & 0 deletions IBPSA/Examples/Tutorial/SimpleHouse/SimpleHouse1.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
within IBPSA.Examples.Tutorial.SimpleHouse;
model SimpleHouse1 "Building wall model"
extends SimpleHouse0;

Modelica.Thermal.HeatTransfer.Components.HeatCapacitor walCap(
C=AWall*dWall*cpWall*rhoWall, T(fixed=true))
"Thermal mass of wall"
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
rotation=270,
origin={150,0})));
Modelica.Thermal.HeatTransfer.Components.ThermalResistor walRes(R=dWall/AWall
/kWall) "Thermal resistor for wall: 25 cm of rockwool"
annotation (Placement(transformation(extent={{80,-10},{100,10}})));
equation
connect(walRes.port_b, walCap.port) annotation (Line(points={{100,0},{112,0},
{112,1.77636e-15},{140,1.77636e-15}}, color={191,0,0}));
connect(TOut.port, walRes.port_a)
annotation (Line(points={{0,0},{80,0}}, color={191,0,0}));
annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-240,
-220},{200,200}})),
experiment(Tolerance=1e-6, StopTime=1e+06),
Documentation(revisions="<html>
<ul>
<li>
September 4, 2023, by Jelger Jansen:<br/>
First implementation.
</li>
</ul>
</html>", info="<html>
<p>
A very simple building envelope model will be constructed manually using thermal resistors and heat capacitors.
The house consists of a wall represented by a single heat capacitor and a thermal resistor.
The boundary temperature are already included in
<a href=\"modelica://IBPSA.Examples.Tutorial.SimpleHouse.SimpleHouse0\">
IBPSA.Examples.Tutorial.SimpleHouse.SimpleHouse0</a>.
The wall has a surface area of <i>A<sub>wall</sub>=100 m<sup>2</sup></i>,
a thickness of <i>d<sub>wall</sub>=25 cm</i>,
a thermal conductivity of <i>k<sub>wall</sub>=0.04 W/(m K)</i>,
a density of <i>&rho;<sub>wall</sub>=2000 kg/m<sup>3</sup></i>,
and a specific heat capacity of <i>c<sub>p,wall</sub>= 1000 J/(kg K)</i>
</p>
<p>
These parameters are already declared in the equation section of
<a href=\"modelica://IBPSA.Examples.Tutorial.SimpleHouse.SimpleHouse0\">
IBPSA.Examples.Tutorial.SimpleHouse.SimpleHouse0</a>.
You can use this way of declaring parameters in the remainder of this exercise, but this is not required.
</p>
<p>
The conductive thermal resistance value of a wall may be computed as <i>R=d/(A*k)</i>.
The heat capacity value of a wall may be computed as <i>C=A*d*c<sub>p</sub>*&rho;</i>
</p>
<h4>Required models</h4>
<ul>
<li>
<a href=\"modelica://Modelica.Thermal.HeatTransfer.Components.ThermalResistor\">
Modelica.Thermal.HeatTransfer.Components.ThermalResistor</a>
</li>
<li>
<a href=\"modelica://Modelica.Thermal.HeatTransfer.Components.HeatCapacitor\">
Modelica.Thermal.HeatTransfer.Components.HeatCapacitor</a>
</li>
</ul>
<h4>Connection instructions</h4>
<p>
Connect one side of the thermal resistor to the output of <code>PrescribedTemperature</code>
and the other side of the thermal resistor to the heat capacitor.
</p>
<h4>Reference result</h4>
<p>
If you correctly added the model of the heat capacitor,
connected it to the resistor and added the parameter values for <i>C</i>,
then you should be able to simulate the model.
To do this, press the <i>Simulation Setup</i> and set the model <i>Stop time</i> to 1e6 seconds.
You can now simulate the model by pressing the <i>Simulate</i> button.
</p>
<p>
You can plot individual variables values by clicking on their name in the variable browser on the left.
Now plot the wall capacitor temperature value <i>T</i>.
It should look like the figure below (1 Ms is around 12 days).
</p>
<p align=\"center\">
<img alt=\"Wall temperature as function of time.\"
src=\"modelica://IBPSA/Resources/Images/Examples/Tutorial/SimpleHouse/result1.png\" width=\"1000\"/>
</p>
</html>"),
__Dymola_Commands(file=
"modelica://IBPSA/Resources/Scripts/Dymola/Examples/Tutorial/SimpleHouse/SimpleHouse1.mos"
"Simulate and plot"));
end SimpleHouse1;
80 changes: 80 additions & 0 deletions IBPSA/Examples/Tutorial/SimpleHouse/SimpleHouse2.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
within IBPSA.Examples.Tutorial.SimpleHouse;
model SimpleHouse2 "Building window model"
extends SimpleHouse1;

parameter Modelica.Units.SI.Area AWin=2 "Window area";

Modelica.Blocks.Math.Gain gaiWin(k=AWin)
"Gain for solar irradiance through the window"
annotation (Placement(transformation(extent={{0,-30},{20,-10}})));
Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow win
"Very simple window model"
annotation (Placement(transformation(extent={{40,-30},{60,-10}})));
equation
connect(gaiWin.y, win.Q_flow)
annotation (Line(points={{21,-20},{40,-20}}, color={0,0,127}));
connect(win.port, walCap.port) annotation (Line(points={{60,-20},{130,-20},{
130,1.77636e-15},{140,1.77636e-15}},
color={191,0,0}));
connect(gaiWin.u, weaBus.HDirNor) annotation (Line(points={{-2,-20},{-150,-20},
{-150,-10}}, color={0,0,127}), Text(
string="%second",
index=1,
extent={{-6,3},{-6,3}},
horizontalAlignment=TextAlignment.Right));
annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-240,
-220},{200,200}})),
experiment(Tolerance=1e-6, StopTime=1e+06),
Documentation(revisions="<html>
<ul>
<li>
September 4, 2023, by Jelger Jansen:<br/>
First implementation.
</li>
</ul>
</html>", info="<html>
<p>
The window has a surface area of <i>2 m<sup>2</sup></i>.
In this simple model we will therefore assume that
two times the outdoor solar irradiance is injected as heat onto the inside of the wall.
</p>
<h4>Required models</h4>
<ul>
<li>
<a href=\"modelica://Modelica.Blocks.Math.Gain\">
Modelica.Blocks.Math.Gain</a>
</li>
<li>
<a href=\"modelica://Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow\">
Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow</a>
</li>
</ul>
<h4>Connection instructions</h4>
<p>
To be able to use the value of the outdoor solar irradiance
you will need to access the weather data reader.
To do this, make a connection to the <code>weaBus</code>.
In the dialog box select <i>&lt;New Variable&gt;</i> and here type <i>HDirNor</i>,
which is the direct solar irradiance on a surface of <i>1 m<sup>2</sup></i>,
perpendicular to the sun rays.
Set the gain factor <i>k</i> to 2,
in order to get the solar irradiance through the window of <i>2 m<sup>2</sup></i>.
</p>
<p>
Make a connection with the <code>PrescribedHeatFlow</code> as well.
This block makes the connection between the heat flow from the gain, represented as a real value,
and a heat port that is compatible with the connectors of the thermal capacitance and resistance.
</p>
<h4>Reference result</h4>
<p>
The result with and without the window model is plotted in the figure below.
</p>
<p align=\"center\">
<img alt=\"Wall temperature as function of time, with (blue) and without (red) window.\"
src=\"modelica://IBPSA/Resources/Images/Examples/Tutorial/SimpleHouse/result2.png\" width=\"1000\"/>
</p>
</html>"),
__Dymola_Commands(file=
"modelica://IBPSA/Resources/Scripts/Dymola/Examples/Tutorial/SimpleHouse/SimpleHouse2.mos"
"Simulate and plot"));
end SimpleHouse2;
87 changes: 87 additions & 0 deletions IBPSA/Examples/Tutorial/SimpleHouse/SimpleHouse3.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
within IBPSA.Examples.Tutorial.SimpleHouse;
model SimpleHouse3 "Air model"
extends SimpleHouse2;

parameter Modelica.Units.SI.Volume VZone=8*8*3 "Zone volume";
parameter Modelica.Units.SI.MassFlowRate mAir_flow_nominal=1
"Nominal mass flow rate for air loop";
parameter Modelica.Units.SI.CoefficientOfHeatTransfer hWall=2
"Convective heat transfer coefficient at the wall";

Modelica.Thermal.HeatTransfer.Components.ThermalResistor conRes(R=1/hWall/
AWall) "Thermal resistance for convective heat transfer" annotation (
Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={130,20})));
IBPSA.Fluid.MixingVolumes.MixingVolume zon(
redeclare package Medium = MediumAir,
V=VZone,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
m_flow_nominal=mAir_flow_nominal) "Very simple zone air model"
annotation (Placement(transformation(extent={{110,130},{90,150}})));
equation
connect(conRes.port_b, walCap.port) annotation (Line(points={{130,10},{130,
1.77636e-15},{140,1.77636e-15}}, color={191,0,0}));
connect(zon.heatPort, conRes.port_a)
annotation (Line(points={{110,140},{130,140},{130,30}}, color={191,0,0}));
annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-240,
-220},{200,200}})),
experiment(Tolerance=1e-6, StopTime=1e+06),
Documentation(revisions="<html>
<ul>
<li>
September 4, 2023, by Jelger Jansen:<br/>
First implementation.
</li>
</ul>
</html>", info="<html>
<p>
To increase the model detail we now add an air model assuming the zone is <i>8m</i> x <i>8m</i> x <i>3m</i> in size.
The air will exchange heat with the wall.
This may be modelled using a thermal resistance representing
the convective heat resistance which is equal to <i>R<sub>conv</sub>=1/(h*A)</i>,
where <i>A</i> is the heat exchange surface area and <i>h=2 W/(m<sup>2</sup>*K)</i> is the convective heat transfer coefficient.
</p>
<h4>Required models</h4>
<ul>
<li>
<a href=\"modelica://IBPSA.Fluid.MixingVolumes.MixingVolume\">
IBPSA.Fluid.MixingVolumes.MixingVolume</a>
</li>
<li>
<a href=\"modelica://Modelica.Thermal.HeatTransfer.Components.ThermalResistor\">
Modelica.Thermal.HeatTransfer.Components.ThermalResistor</a>
</li>
</ul>
<h4>Connection instructions</h4>
<p>
The <code>MixingVolume</code> <i>Medium</i> parameter contains information about
the type of fluid and its properties that should be modelled by the <code>MixingVolume</code>.
Set its value to <i>MediumAir</i>, which is declared in the template,
by typing <i>redeclare package Medium = MediumAir</i>.
For the nominal mass flow rate you may assume a value of <i>1 kg/m<sup>3</sup></i> for now.
You will have to change this value once you add a ventilation system to the model (see
<a href=\"modelica://IBPSA.Examples.Tutorial.SimpleHouse.SimpleHouse6\">
IBPSA.Examples.Tutorial.SimpleHouse.SimpleHouse6</a>).
Finally, set the <i>energyDynamics</i> of the <code>MixingVolume</code>,
which can be found in the <i>Dynamics</i> tab of the model parameter window, to <i>FixedInitial</i>.
</p>
<p>
Make a connection with the <code>PrescribedHeatFlow</code> as well.
This block makes the connection between the heat flow from the gain, represented as a real value,
and a heat port that is compatible with the connectors of the thermal capacitance and resistance.
</p>
<h4>Reference result</h4>
<p>
The result with and without the air model is plotted in the figure below.
</p>
<p align=\"center\">
<img alt=\"Wall temperature as function of time, with (green) and without (blue) air model.\"
src=\"modelica://IBPSA/Resources/Images/Examples/Tutorial/SimpleHouse/result3.png\" width=\"1000\"/>
</p>
</html>"),
__Dymola_Commands(file=
"modelica://IBPSA/Resources/Scripts/Dymola/Examples/Tutorial/SimpleHouse/SimpleHouse3.mos"
"Simulate and plot"));
end SimpleHouse3;
Loading