Cooling Revisited - NewtonCoolingSteadyThenDynamic

Gallery
Tutorial
Click on the image to view it full size
The Modelica By Example target code (using 'initial equation') is:

model NewtonCoolingSteadyThenDynamic
  "Dynamic cooling example with steady state conditions"
  type Temperature=Real(unit="K", min=0);
  type ConvectionCoefficient=Real(unit="W/(m2.K)", min=0);
  type Area=Real(unit="m2", min=0);
  type Mass=Real(unit="kg", min=0);
  type SpecificHeat=Real(unit="J/(K.kg)", min=0);

  parameter ConvectionCoefficient h=0.7 "Convective cooling coefficient";
  parameter Area A=1.0 "Surface area";
  parameter Mass m=0.1 "Mass of thermal capacitance";
  parameter SpecificHeat c_p=1.2 "Specific heat";

  Temperature T_inf "Ambient temperature";
  Temperature T "Temperature";
initial equation
  der(T) = 0 "Steady state initial conditions";
equation
  if time<=0.5 then
    T_inf = 298.15 "Constant temperature when time<=0.5";
  else
    T_inf = 298.15-20*(time-0.5) "Otherwise, decreasing";
  end if;
  m*c_p*der(T) = h*A*(T_inf-T) "Newton's law of cooling";
end NewtonCoolingSteadyThenDynamic;

The exported Modelica code is:


model NewtonCoolingSteadyThenDynamic
  NewtonCoolingSteadyThenDynamic _NewtonCoolingSteadyThenDynamic;
  model NewtonCoolingSteadyThenDynamic
    parameter ConvectionCoefficient h(start=0.7,fixed=true);
    parameter Area a(start=1.0,fixed=true);
    parameter Mass m(start=0.1,fixed=true);
    parameter SpecificHeat c_p(start=1.2,fixed=true);
    Temperature t_inf;
    Temperature t;
    TemperatureRate dt(start=0.0,fixed=true);
  equation
    m*c_p*der(t)=h*a*(t_inf-t);
    if time<=0.5 then
t_inf=298.15;
else
t_inf=298.15-20*(time-0.5);
end if;
    dt=der(t);
  end NewtonCoolingSteadyThenDynamic;
  type ConvectionCoefficient=Real(unit="W/(m2.K)");
  type Area=Real(unit="m2");
  type Mass=Real(unit="kg");
  type SpecificHeat=Real(unit="J/(K.kg)");
  type Temperature=Real(unit="K");
  type TemperatureRate=Real(unit="K/s");
end NewtonCoolingSteadyThenDynamic;

As always with these SysPhS-1.1 based trail example we note:

So an additional initialised variable dt is used:


    TemperatureRate dt(start=0.0,fixed=true);
Where dt = der(t).
Up next
Notes
Snippets (quotes/extracts)
Visit also
Visit also (backlinks)
Related slides (includes other tutorials)
Related slides (backlinks, includes other tutorials)
External links