246
6 Hierarchical Component Models
Tank Program Code:
parameter SI.Volume volumeTank = 1 "Tank volume";
SI.Volume volL "Fluid volume";
parameter SI.Mass epsMass = 1;
equation
// tank operating modes
liq.mode = heat.mode;
liq.mode = if not sum(mass) > epsMass then MODE_Empty
else if not volL < volumeTank then MODE_Full
else MODE_Normal;
// equations for fluid mass:
der(mass) = liq.Fm;
liq.mass = mass;
volL = sum( mass[i]/density[i] for i in 1:nComp);
// For energy:
for i in 1:nComp loop
Cp[i] = CpCoefs[i,1] + CpCoefs[i,2]*temp;
end for;
der(enthalpy) = liq.Fh + heat.Q;
enthalpy = liq.mass*Cp*temp;
liq.temp = temp;
end Tank;
model Tank
parameter Integer nComp = 1;
Interfaces.Liquid liq(nComp=nComp)
Interfaces.Heat heat;
// Specific heat of substances in the mixture
parameter Real CpCoefs[nComp,2];
// The density of substances in the mixture
parameter SI.Density density[nComp];
SI.Mass mass[nComp] (start=epsMass*ones(nComp)/nComp, fixed=true);
SI.Temperature temp(start=300, fixed=true);
SI.Enthalpy enthalpy;
SI.SpecificHeatCapacity Cp[nComp];
Next, you need to combine the prepared components into one module. Let us
draw a block diagram of our hierarchical model (Fig. 6.50):
In each created component, it is necessary to enter the parameters in accordance
with Table 6.1.
Let us assemble the component model from the created components (Fig. 6.51):
We give the main results of a numerical experiment (Figs. 6.52, 6.53, 6.54, 6.55,
6.56, 6.57, and 6.58).
6.3 Inverted Pendulum Problem
Formulation of the problem
This problem is adopted from [5]. A dynamic mechanical system consists of an
inverted (reverse) pendulum mounted on a motorized trolley through a hinge, without
Précédent

- 257/274

Suivant