Skip to content

Commit 44cd70e

Browse files
author
Giovanni Mangola
committed
Merge branch 'master' of https://github.com/casella/ThermoPower
2 parents 2840795 + a654e28 commit 44cd70e

File tree

5 files changed

+108
-17
lines changed

5 files changed

+108
-17
lines changed

ThermoPower/Gas.mo

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,9 @@ package Gas "Models of components with ideal gases as working fluid"
11841184
p = pstart;
11851185
end if;
11861186
Ttilde = Tstart[2:N];
1187-
Xtilde = ones(size(Xtilde, 1), size(Xtilde, 2))*diagonal(Xstart[1:nX]);
1187+
if (not Medium.fixedX) then
1188+
Xtilde = ones(size(Xtilde, 1), size(Xtilde, 2))*diagonal(Xstart[1:nX]);
1189+
end if;
11881190
elseif initOpt == Choices.Init.Options.steadyState then
11891191
if (not Medium.singleState) and not noInitialPressure then
11901192
der(p) = 0;
@@ -1259,7 +1261,7 @@ package Gas "Models of components with ideal gases as working fluid"
12591261
replaceable model HeatTransfer2 = Thermal.HeatTransferFV.IdealHeatTransfer
12601262
constrainedby ThermoPower.Thermal.BaseClasses.DistributedHeatTransferFV
12611263
annotation (choicesAllMatching=true);
1262-
HeatTransfer heatTransfer2(
1264+
HeatTransfer2 heatTransfer2(
12631265
redeclare package Medium = Medium,
12641266
final Nf=N,
12651267
final Nw=Nw,
@@ -2741,6 +2743,85 @@ The packages Medium are redeclared and a mass balance determines the composition
27412743
</html>"));
27422744
end FanMech;
27432745

2746+
package Utility "Utility models"
2747+
2748+
model ClosedSystemInit
2749+
"Component for the steady-state initialization of closed systems"
2750+
replaceable package Medium = Modelica.Media.Interfaces.PartialMedium
2751+
"Medium model"
2752+
annotation(choicesAllMatching = true);
2753+
parameter Medium.AbsolutePressure pstart "Start value of pressure";
2754+
parameter Boolean initEquationFromInput = false
2755+
"Get initial condition residual from input connector"
2756+
annotation(Dialog(group="External inputs"), choices(checkBox=true));
2757+
parameter Boolean useHomotopy
2758+
"Use homotopy for residual-based initialization";
2759+
final parameter Medium.MassFlowRate w_b(fixed = false, start = 0)
2760+
"Initial balance flow rate eventually equal to zero";
2761+
outer ThermoPower.System system "System wide properties";
2762+
2763+
FlangeB flange(redeclare package Medium = Medium, m_flow(min = 0))
2764+
annotation (Placement(transformation(extent={{-20,-100},{20,-60}},
2765+
rotation=0),
2766+
iconTransformation(extent={{-20,-100},{20,-60}})));
2767+
Modelica.Blocks.Interfaces.RealInput initEquationResidual if initEquationFromInput
2768+
"Residual of initial equation" annotation (Placement(transformation(extent={
2769+
{-60,0},{-20,40}}), iconTransformation(extent={{-60,-10},{-40,10}})));
2770+
protected
2771+
Modelica.Blocks.Interfaces.RealInput initEquationResidual_int
2772+
"Hidden internal connector for conditional connection";
2773+
equation
2774+
0 = flange.m_flow + w_b "Mass balance";
2775+
flange.h_outflow = Medium.h_default
2776+
"Unused value as there is no flow out of the flange";
2777+
flange.Xi_outflow = Medium.X_default[1:Medium.nXi]
2778+
"Unused value as there is no flow out of the flange";
2779+
2780+
connect(initEquationResidual, initEquationResidual_int)
2781+
"Connects conditional input to hidden connector";
2782+
2783+
if not initEquationFromInput then
2784+
initEquationResidual_int = 0 "Not used";
2785+
end if;
2786+
2787+
initial equation
2788+
if initEquationFromInput then
2789+
if useHomotopy then
2790+
homotopy(initEquationResidual_int, (flange.p - pstart)/pstart) = 0
2791+
"Set initial value of residual to zero, simplified equation sets start value of pressure";
2792+
else
2793+
initEquationResidual_int = 0 "Set initial value of residual to zero";
2794+
end if;
2795+
else
2796+
flange.p = pstart "Set initial value of pressure";
2797+
end if;
2798+
2799+
annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={
2800+
Line(
2801+
points={{0,0},{0,-60}},
2802+
color={159,159,223},
2803+
thickness=0.5),
2804+
Ellipse(
2805+
extent={{-40,40},{40,-40}},
2806+
lineColor={159,159,223},
2807+
fillColor={159,159,223},
2808+
fillPattern=FillPattern.Solid),
2809+
Text(
2810+
extent={{-32,24},{30,-24}},
2811+
lineColor={255,255,255},
2812+
lineThickness=0.5,
2813+
fillColor={0,0,255},
2814+
fillPattern=FillPattern.Solid,
2815+
textString="Init")}), Diagram(
2816+
coordinateSystem(preserveAspectRatio=false)),
2817+
Documentation(info="<html>
2818+
<p>This component can be used for the steady-state initialization of closed-system where all components have steady-state initial conditions. Without this component such systems would give rise to undetermined initial conditions, i.e., the amount of fluid and the initial pressures in the system would be unspecified.</p>
2819+
<p>Connect the component to one point of the system. If <code>initEquationFromInput = false</code>, the system is initialized with pressure equal to <code>pstart</code> at the connection point.</p>
2820+
<p>It is possible to use a generic initial equation instead of <code>p = pstart</code>, e.g., to set the initial charge of a refrigeration circuit, by setting <code>initEquationFromInput = true</code> and connecting to the input the output of a <a href=\"Modelica://Modelica.Blocks.Sources.RealExpression\">Modelica.Blocks.Sources.RealExpression</a> component, containing the residual of the initial equation. In this case, if <code>useHomotopy = true</code>, the simplified initial equation is <code>(p - pstart)/pstart = 0</code>. To ensure a smooth homotopy transformation, it is recommended to write the residual in normalized form, i.e., with values have the order of magnitude of one, as for the simplified equation.</p>
2821+
</html>"));
2822+
end ClosedSystemInit;
2823+
end Utility;
2824+
27442825
package BaseClasses
27452826
extends Modelica.Icons.BasesPackage;
27462827
partial model Flow1DBase

ThermoPower/Thermal.mo

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,17 @@ package Thermal "Thermal models of heat transfer"
783783
end for;
784784
annotation (
785785
Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}),
786-
graphics));
786+
graphics={Polygon(
787+
points={{-72,0},{-72,-16},{-50,-8},{-72,0}},
788+
lineColor={0,0,0},
789+
lineThickness=0.5,
790+
fillColor={0,0,0},
791+
fillPattern=FillPattern.Solid), Polygon(
792+
points={{72,0},{52,8},{72,16},{72,0}},
793+
lineColor={0,0,0},
794+
lineThickness=0.5,
795+
fillColor={0,0,0},
796+
fillPattern=FillPattern.Solid)}));
787797
end HeatExchangerTopologyFV;
788798

789799
model CounterCurrentFV
@@ -880,7 +890,7 @@ The swapping is performed if the counterCurrent parameter is true (default value
880890
DHTVolumes side2(final N=Nv) annotation (Placement(transformation(extent={{-40,-42},{40,-20}},
881891
rotation=0)));
882892
equation
883-
side1.Q = G*(side1.T - side2.T) "Convective heat transfer";
893+
side1.Q = G*(side1.T - side2.T)/Nv "Convective heat transfer";
884894
side1.Q + side2.Q = zeros(Nv) "Static energy balance";
885895
annotation (Icon(graphics={Text(
886896
extent={{-100,-44},{100,-68}},

ThermoPower/Water.mo

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ outlet is ignored; use <t>Pump</t> models if this has to be taken into account c
13731373
end if;
13741374
annotation (
13751375
Diagram(graphics),
1376-
Icon(graphics={Text(extent={{-100,-40},{100,-80}}, textString="%name")}),
1376+
Icon(graphics={Text(extent={{-100,-60},{100,-100}},textString="%name")}),
13771377
Documentation(info="<HTML>
13781378
<p>This model describes the flow of water or steam in a rigid tube. The basic modelling assumptions are:
13791379
<ul><li>The fluid state is always one-phase (i.e. subcooled liquid or superheated steam).
@@ -1462,7 +1462,7 @@ outlet is ignored; use <t>Pump</t> models if this has to be taken into account c
14621462
connect(wall2,heatTransfer2.wall);
14631463
annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,
14641464
-100},{100,100}}), graphics), Icon(coordinateSystem(
1465-
preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics));
1465+
preserveAspectRatio=false, extent={{-100,-100},{100,100}})));
14661466
end Flow1DFV2w;
14671467

14681468
model Flow1DFV2ph
@@ -1785,7 +1785,7 @@ outlet is ignored; use <t>Pump</t> models if this has to be taken into account c
17851785

17861786
annotation (
17871787
Diagram(graphics),
1788-
Icon(graphics={Text(extent={{-100,-40},{100,-80}}, textString="%name")}),
1788+
Icon(graphics={Text(extent={{-100,-60},{100,-100}},textString="%name")}),
17891789
Documentation(info="<HTML>
17901790
<p>This model describes the flow of water or steam in a rigid tube. The basic modelling assumptions are:
17911791
<ul><li>The fluid state is either one-phase, or a two-phase mixture.
@@ -2288,7 +2288,7 @@ enthalpy between the nodes; this requires the availability of the time derivativ
22882288
end if;
22892289
annotation (
22902290
Diagram(graphics),
2291-
Icon(graphics={Text(extent={{-100,-40},{100,-80}}, textString="%name")}),
2291+
Icon(graphics={Text(extent={{-100,-60},{100,-100}},textString="%name")}),
22922292
Documentation(info="<HTML>
22932293
<p>This model describes the flow of water or steam in a rigid tube. The basic modelling assumptions are:
22942294
<ul><li>The fluid state is always one-phase (i.e. subcooled liquid or superheated steam).

ThermoPower/package.mo

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,7 @@ annotation (
20262026
<p><ul>
20272027
<li>F. Casella, F. Schiavo, &QUOT;Modelling and Simulation of Heat Exchangers in Modelica with Finite Element Methods&QUOT;, <i>Proceedings of the 2003 Modelica Conference</i>, Link&ouml;ping, Sweden, 2003, pp. 343-352. (<a href=\"http://www.modelica.org/Conference2003/papers/h22_Schiavo.pdf\">Available online</a>) </li>
20282028
<li>A. Cammi, M.E. Ricotti, F. Casella, F. Schiavo, &QUOT;New modelling strategy for IRIS dynamic response simulation&QUOT;, <i>Proc. 5th International Conference on Nuclear Option in Countries with Small and Medium Electricity Grids</i>, Dubrovnik, Croatia, May 2004.</li>
2029-
<li>A. Cammi, F. Casella, M.E. Ricotti, F. Schiavo, &QUOT;Object-oriented Modelling for Integral Nuclear Reactors Dynamic Dimulation&QUOT;, <i>Proceedings of the International Conference on Integrated Modeling &AMP; Analysis in Applied Control &AMP; Automation</i>, Genova, Italy, October 2004. </li>
2029+
<li>A. Cammi, F. Casella, M.E. Ricotti, F. Schiavo, &QUOT;Object-oriented Modelling for Integral Nuclear Reactors Dynamic Simulation&QUOT;, <i>Proceedings of the International Conference on Integrated Modeling &AMP; Analysis in Applied Control &AMP; Automation</i>, Genova, Italy, October 2004. </li>
20302030
<li>Antonio Cammi, Francesco Casella, Marco Ricotti and Francesco Schiavo, &ldquo;Object-Oriented Modeling, Simulation and Control of the IRIS Nuclear Power Plant with Modelica&rdquo;. In <i>Proceedings 4th International Modelica Conference</i>, Hamburg, Germany,Mar. 7-8, 2005, pp. 423-432. <a href=\"http://www.modelica.org/events/Conference2005/online_proceedings/Session5/Session5b3.pdf\">Online</a>. </li>
20312031
<li>A. Cammi, F. Casella, M. E. Ricotti, F. Schiavo, G. D. Storrick, &QUOT;Object-oriented Simulation for the Control of the IRIS Nuclear Power Plant&QUOT;, <i>Proceedings of the IFAC World Congress, </i>Prague, Czech Republic, July 2005 </li>
20322032
<li>Francesco Casella and Francesco Pretolani, &ldquo;Fast Start-up of a Combined-Cycle Power Plant: a Simulation Study with Modelica&rdquo;. In <i>Proceedings 5th International Modelica Conference</i>, Vienna, Austria, Sep. 6-8, 2006, pp. 3-10. <a href=\"http://www.modelica.org/events/modelica2006/Proceedings/sessions/Session1a1.pdf\">Online</a>. </li>
@@ -2049,9 +2049,9 @@ annotation (
20492049
This is a major new release, that has been in the making for 5 years. The new release is not compatible with 2.1. However, models built using the development version of the library after 2011 should compile with little or no adjustments. It has many new features:
20502050
<ul>
20512051
<li>Use of Modelica 3.2 revision 2 and Modelica Standard Library 3.2.1, ensuring full compatibility with all compliant Modelica tools</li>
2052-
<li>Tested with Dymola and OpenModelica./li>
2052+
<li>Tested with Dymola and OpenModelica.</li>
20532053
<li>Use of stream connectors, compatible with the Modelica.Fluid library, allowing multiple-way connections (see <a href=\"http://dx.doi.org/10.3384/ecp09430078\">paper</a>).</li>
2054-
<li>Use of the homotopy operator for improved convegence of steady-state initialization problems(see <a href=\"https://www.modelica.org/events/modelica2011/Proceedings/pages/papers/04_2_ID_131_a_fv.pdf\">paper</a>).</li>
2054+
<li>Use of the homotopy operator for improved convergence of steady-state initialization problems(see <a href=\"https://www.modelica.org/events/modelica2011/Proceedings/pages/papers/04_2_ID_131_a_fv.pdf\">paper</a>).</li>
20552055
<li>Improved Flow1D models with embedded replaceable heat transfer models, allowing a much easier customization of heat transfer correlations</li>
20562056
<li>Many bug fixes</li>
20572057
</ul></p>
@@ -2105,6 +2105,6 @@ This is a major new release, that has been in the making for 5 years. The new re
21052105
<p>The ThermoPower package is licensed by Politecnico di Milano under the <b><a href=\"http://www.modelica.org/licenses/ModelicaLicense2\">Modelica License 2</a></b>. </p>
21062106
<p><h4>Copyright &copy; 2002-2014, Politecnico di Milano.</h4></p>
21072107
</html>"),
2108-
uses(Modelica(version="3.2.2")),
2108+
uses(Modelica(version="3.2.3")),
21092109
version="3.1");
21102110
end ThermoPower;

docs/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ <h2>References</h2>
9393
<p></p><ul>
9494
<li>F. Casella, F. Schiavo, "Modelling and Simulation of Heat Exchangers in Modelica with Finite Element Methods", <i>Proceedings of the 2003 Modelica Conference</i>, Linköping, Sweden, 2003, pp. 343-352. (<a href="http://www.modelica.org/Conference2003/papers/h22_Schiavo.pdf">Available online</a>) </li>
9595
<li>A. Cammi, M.E. Ricotti, F. Casella, F. Schiavo, "New modelling strategy for IRIS dynamic response simulation", <i>Proc. 5th International Conference on Nuclear Option in Countries with Small and Medium Electricity Grids</i>, Dubrovnik, Croatia, May 2004.</li>
96-
<li>A. Cammi, F. Casella, M.E. Ricotti, F. Schiavo, "Object-oriented Modelling for Integral Nuclear Reactors Dynamic Dimulation", <i>Proceedings of the International Conference on Integrated Modeling &amp; Analysis in Applied Control &amp; Automation</i>, Genova, Italy, October 2004. </li>
96+
<li>A. Cammi, F. Casella, M.E. Ricotti, F. Schiavo, "Object-oriented Modelling for Integral Nuclear Reactors Dynamic Simulation", <i>Proceedings of the International Conference on Integrated Modeling &amp; Analysis in Applied Control &amp; Automation</i>, Genova, Italy, October 2004. </li>
9797
<li>Antonio Cammi, Francesco Casella, Marco Ricotti and Francesco
9898
Schiavo, “Object-Oriented Modeling, Simulation and Control of the IRIS
9999
Nuclear Power Plant with Modelica”. In <i>Proceedings 4th International Modelica Conference</i>, Hamburg, Germany,Mar. 7-8, 2005, pp. 423-432. <a href="http://www.modelica.org/events/Conference2005/online_proceedings/Session5/Session5b3.pdf">Online</a>. </li>
@@ -138,11 +138,11 @@ <h2>Release notes:</h2>
138138
the development version of the library after 2011 should compile with
139139
little or no adjustments. It has many new features:
140140
</p><ul>
141-
<li>Use of Modelica 3.2.1 revision 2 and Modelica Standard Libary
141+
<li>Use of Modelica 3.2.1 revision 2 and Modelica Standard Library
142142
3.2.1, ensuring full compatibility with all compliant Modelica tools</li>
143-
<li>Tested with Dymola and OpenModelica./li&gt;
144-
</li><li>Use of stream connectors, compatible with the Modelica.Fluid library, allowing multiple-way connections (see <a href="http://dx.doi.org/10.3384/ecp09430078">paper</a>).</li>
145-
<li>Use of the homotopy operator for improved convegence of steady-state initialization problems(see <a href="https://www.modelica.org/events/modelica2011/Proceedings/pages/papers/04_2_ID_131_a_fv.pdf">paper</a>).</li>
143+
<li>Tested with Dymola and OpenModelica.</li>
144+
<li>Use of stream connectors, compatible with the Modelica.Fluid library, allowing multiple-way connections (see <a href="http://dx.doi.org/10.3384/ecp09430078">paper</a>).</li>
145+
<li>Use of the homotopy operator for improved convergence of steady-state initialization problems(see <a href="https://www.modelica.org/events/modelica2011/Proceedings/pages/papers/04_2_ID_131_a_fv.pdf">paper</a>).</li>
146146
<li>Improved Flow1D models with embedded replaceable heat transfer
147147
models, allowing a much easier customization of heat transfer
148148
correlations</li>

0 commit comments

Comments
 (0)