Skip to content

Commit

Permalink
Merge branch 'openmodelica' into openmodelica-weather
Browse files Browse the repository at this point in the history
  • Loading branch information
mwetter committed Oct 18, 2014
2 parents 3405217 + 58aae13 commit 965b6dc
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 25 deletions.
Expand Up @@ -64,11 +64,19 @@ initial equation
// Calculate derivatives at support points (non-monotone)
(ud, Td, dT_du) =
Buildings.HeatTransfer.Conduction.BaseClasses.der_temperature_u(
materialNonMonotone);
c= materialNonMonotone.c,
TSol=materialNonMonotone.TSol,
TLiq=materialNonMonotone.TLiq,
LHea=materialNonMonotone.LHea,
ensureMonotonicity=materialNonMonotone.ensureMonotonicity);
// Calculate derivatives at support points (monotone);
(udMonotone, TdMonotone, dT_duMonotone) =
Buildings.HeatTransfer.Conduction.BaseClasses.der_temperature_u(
materialMonotone);
c= materialMonotone.c,
TSol=materialMonotone.TSol,
TLiq=materialMonotone.TLiq,
LHea=materialMonotone.LHea,
ensureMonotonicity=materialMonotone.ensureMonotonicity);
equation
u = 2.5e5+time*(1.5*materialMonotone.c*(materialMonotone.TLiq-273.15)+materialMonotone.LHea)*conFac;

Expand Down Expand Up @@ -148,6 +156,15 @@ obtained for different specific internal energy values (right hand side figure).
</html>", revisions="<html>
<ul>
<li>
October 17, 2014, by Michael Wetter:<br/>
Changed the input argument for the function
<code>Buildings.HeatTransfer.Conduction.BaseClasses.der_temperature_u</code>
from type
<code>Buildings.HeatTransfer.Data.BaseClasses.Material</code>
to the elements of this type as OpenModelica fails to translate the
model if the input to this function is a record.
</li>
<li>
October 11, 2013, by Michael Wetter:<br/>
Added missing <code>each</code> keywords.
</li>
Expand Down
50 changes: 33 additions & 17 deletions Buildings/HeatTransfer/Conduction/BaseClasses/der_temperature_u.mo
@@ -1,8 +1,16 @@
within Buildings.HeatTransfer.Conduction.BaseClasses;
function der_temperature_u
"Computes the derivative of the temperature of a phase change material with respect to specific internal energy"
input Buildings.HeatTransfer.Data.BaseClasses.Material material
"Material properties";
input Modelica.SIunits.SpecificHeatCapacity c "Specific heat capacity";
input Modelica.SIunits.Temperature TSol
"Solidus temperature, used only for PCM.";
input Modelica.SIunits.Temperature TLiq
"Liquidus temperature, used only for PCM";
input Modelica.SIunits.SpecificInternalEnergy LHea
"Latent heat of phase change";
input Boolean ensureMonotonicity = false
"Set to true to force derivatives dT/du to be monotone";

output Modelica.SIunits.SpecificInternalEnergy ud[Buildings.HeatTransfer.Conduction.nSupPCM]
"Support points for derivatives";
output Modelica.SIunits.Temperature Td[Buildings.HeatTransfer.Conduction.nSupPCM]
Expand All @@ -11,30 +19,31 @@ function der_temperature_u
"Derivatives dT/du at the support points";
protected
parameter Real scale=0.999 "Used to place points on the phase transition";
parameter Modelica.SIunits.Temperature Tm1=material.TSol+(1-scale)*(material.TLiq-material.TSol);
parameter Modelica.SIunits.Temperature Tm2=material.TSol+scale*(material.TLiq-material.TSol);
parameter Modelica.SIunits.Temperature Tm1=TSol+(1-scale)*(TLiq-TSol)
"Support point";
parameter Modelica.SIunits.Temperature Tm2=TSol+scale*(TLiq-TSol)
"Support point";
algorithm
assert(Buildings.HeatTransfer.Conduction.nSupPCM == 6,
"The material must have exactly 6 support points for the u(T) relation.");
assert(material.TLiq > material.TSol,
"TLiq has to be larger than TSol.");
assert(TLiq > TSol, "TLiq has to be larger than TSol.");
// Get the derivative values at the support points
ud:={material.c*scale*material.TSol,
material.c*material.TSol,
material.c*Tm1 + material.LHea*(Tm1 - material.TSol)/(material.TLiq - material.TSol),
material.c*Tm2 + material.LHea*(Tm2 - material.TSol)/(material.TLiq - material.TSol),
material.c*material.TLiq + material.LHea,
material.c*(material.TLiq + material.TSol*(1 - scale)) + material.LHea};
Td:={scale*material.TSol,
material.TSol,
ud:={c*scale*TSol,
c*TSol,
c*Tm1 + LHea*(Tm1 - TSol)/(TLiq - TSol),
c*Tm2 + LHea*(Tm2 - TSol)/(TLiq - TSol),
c*TLiq + LHea,
c*(TLiq + TSol*(1 - scale)) + LHea};
Td:={scale*TSol,
TSol,
Tm1,
Tm2,
material.TLiq,
material.TLiq + material.TSol*(1 - scale)};
TLiq,
TLiq + TSol*(1 - scale)};
dT_du := Buildings.Utilities.Math.Functions.splineDerivatives(
x=ud,
y=Td,
ensureMonotonicity=material.ensureMonotonicity);
ensureMonotonicity=ensureMonotonicity);
annotation(smoothOrder=1,
Documentation(info="<html>
<p>
Expand All @@ -50,6 +59,13 @@ to compute for a given specific internal energy the temperature.
revisions="<html>
<ul>
<li>
October 17, 2014, by Michael Wetter:<br/>
Changed the input argument from type
<code>Buildings.HeatTransfer.Data.BaseClasses.Material</code>
to the elements of this type as OpenModelica fails to translate the
model if the input to this function is a record.
</li>
<li>
October 13, 2014, by Michael Wetter:<br/>
Corrected the input argument to be an instance of
<code>Buildings.HeatTransfer.Data.BaseClasses.Material</code> rather than
Expand Down
15 changes: 14 additions & 1 deletion Buildings/HeatTransfer/Conduction/SingleLayer.mo
Expand Up @@ -71,7 +71,11 @@ initial equation

if material.phasechange then
(ud, Td, dT_du) = Buildings.HeatTransfer.Conduction.BaseClasses.der_temperature_u(
material=material);
c= material.c,
TSol=material.TSol,
TLiq=material.TLiq,
LHea=material.LHea,
ensureMonotonicity=material.ensureMonotonicity);
else
ud = zeros(Buildings.HeatTransfer.Conduction.nSupPCM);
Td = zeros(Buildings.HeatTransfer.Conduction.nSupPCM);
Expand Down Expand Up @@ -264,6 +268,15 @@ Buildings.HeatTransfer.Conduction.MultiLayer</a> instead of this model.
revisions="<html>
<ul>
<li>
October 17, 2014, by Michael Wetter:<br/>
Changed the input argument for the function
<code>Buildings.HeatTransfer.Conduction.BaseClasses.der_temperature_u</code>
from type
<code>Buildings.HeatTransfer.Data.BaseClasses.Material</code>
to the elements of this type as OpenModelica fails to translate the
model if the input to this function is a record.
</li>
<li>
May 30, 2014, by Michael Wetter:<br/>
Removed undesirable annotation <code>Evaluate=true</code>.
</li>
Expand Down
12 changes: 7 additions & 5 deletions Buildings/HeatTransfer/Examples/ConductorSingleLayerPCM.mo
Expand Up @@ -46,8 +46,7 @@ model ConductorSingleLayerPCM "Test model for heat conductor"
Buildings.HeatTransfer.Conduction.SingleLayer con2(
A=1, material=concrete100) "Construction without PCM"
annotation (Placement(transformation(extent={{50,-40},{70,-20}})));
parameter Buildings.HeatTransfer.Data.SolidsPCM.Generic
matPCM(
parameter Buildings.HeatTransfer.Data.SolidsPCM.Generic matPCM(
x=0.2,
k=1.4,
c=840,
Expand All @@ -70,8 +69,7 @@ model ConductorSingleLayerPCM "Test model for heat conductor"
Buildings.HeatTransfer.Sources.FixedTemperature TB2(T=293.15)
"Temperature boundary condition"
annotation (Placement(transformation(extent={{100,34},{80,54}})));
parameter Buildings.HeatTransfer.Data.SolidsPCM.Generic
matPCM2(
parameter Buildings.HeatTransfer.Data.SolidsPCM.Generic matPCM2(
x=0.2,
k=1.4,
c=840,
Expand Down Expand Up @@ -180,10 +178,14 @@ if there is a difference in heat fluxes.
</html>", revisions="<html>
<ul>
<li>
October 17, 2014, by Michael Wetter:<br/>
Increased tolerance for OpenModelica.
</li>
<li>
March 6 2010, by Michael Wetter:<br/>
First implementation.
</li>
</ul>
</html>"),
experiment(StopTime=7200));
experiment(StopTime=7200, Tolerance=1E-8));
end ConductorSingleLayerPCM;
13 changes: 13 additions & 0 deletions Buildings/package.mo
Expand Up @@ -311,6 +311,19 @@ have been <b style=\"color:blue\">improved</b> in a
<td valign=\"top\">Removed block as it is not used in any model.
</td>
</tr>

<tr><td colspan=\"2\"><b>Buildings.HeatTransfer</b>
</td>
</tr>
<tr><td valign=\"top\">Buildings.HeatTransfer.Conduction.BaseClasses.der_temperature_u
</td>
<td valign=\"top\">Changed the input argument for this function from type
<code>Buildings.HeatTransfer.Data.BaseClasses.Material</code>
to the elements of this type as OpenModelica fails to translate the
model if the input to this function is a record.
</td>
</tr>

<tr><td colspan=\"2\"><b>Buildings.Fluid</b>
</td>
</tr>
Expand Down

0 comments on commit 965b6dc

Please sign in to comment.