ModelingOfDynamicSystems PDF
ModelingOfDynamicSystems PDF
Bernt Lie
Preface xxix
Nomenclature xxxi
1 Introduction 1
1.1 Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1 System: object, property, interaction . . . . . . . . . . . . . . 1
1.1.2 System decomposition . . . . . . . . . . . . . . . . . . . . . . 2
1.1.3 Causality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.4 Dynamic system . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Models and model types . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3.1 What is a model? . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3.2 Empirical models . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3.3 Mechanistic models . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3.4 Material vs Spatial Description . . . . . . . . . . . . . . . . . 6
1.3.5 Model vs System . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4 Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.5 Structure of notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
iii
iv CONTENTS
4 Mass conservation 87
4.1 Learning goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
4.2 The total mass balance . . . . . . . . . . . . . . . . . . . . . . . . . . 87
4.3 Continuum vs particle description . . . . . . . . . . . . . . . . . . . . 88
4.4 Extensive vs. intensive variables . . . . . . . . . . . . . . . . . . . . . 89
4.5 Equations of State . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
4.5.1 Ideal gas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
4.5.2 Non-ideal gas+ . . . . . . . . . . . . . . . . . . . . . . . . . . 92
4.5.2.1 The van der Waals EoS . . . . . . . . . . . . . . . . 92
4.5.2.2 Two-parametric Cubic EoS . . . . . . . . . . . . . . 93
4.5.2.3 Examples of two-parametric Cubic EoS . . . . . . . . 95
4.5.2.4 Three-parametric Cubic EoS . . . . . . . . . . . . . 97
4.6 The homogeneous system assumption . . . . . . . . . . . . . . . . . . 98
4.7 Bernoulli’s law for valve flow . . . . . . . . . . . . . . . . . . . . . . . 99
4.8 Cases: Liquid level in tanks . . . . . . . . . . . . . . . . . . . . . . . 101
4.8.1 Tank with effluent flow . . . . . . . . . . . . . . . . . . . . . . 101
4.8.1.1 Model objective . . . . . . . . . . . . . . . . . . . . . 102
4.8.1.2 Model development . . . . . . . . . . . . . . . . . . . 103
4.8.1.3 Model summary . . . . . . . . . . . . . . . . . . . . 104
4.8.1.4 Model simulation . . . . . . . . . . . . . . . . . . . . 104
4.8.1.5 Refining the model implementation . . . . . . . . . . 106
4.8.1.6 Exact solution of model . . . . . . . . . . . . . . . . 107
4.8.2 Tank with influent and effluent flows . . . . . . . . . . . . . . 109
4.8.2.1 Model objective . . . . . . . . . . . . . . . . . . . . . 109
4.8.2.2 Model development . . . . . . . . . . . . . . . . . . . 110
4.8.2.3 Model summary . . . . . . . . . . . . . . . . . . . . 111
4.8.2.4 Model simulation . . . . . . . . . . . . . . . . . . . . 111
4.8.3 Tank with varying area . . . . . . . . . . . . . . . . . . . . . . 114
4.8.3.1 Model objective . . . . . . . . . . . . . . . . . . . . . 114
4.8.3.2 Model development . . . . . . . . . . . . . . . . . . . 114
4.8.3.3 Model summary . . . . . . . . . . . . . . . . . . . . 117
4.8.3.4 Model simulation . . . . . . . . . . . . . . . . . . . . 117
4.9 Case: Pressure in single gas tank . . . . . . . . . . . . . . . . . . . . 120
4.9.1 Model objective . . . . . . . . . . . . . . . . . . . . . . . . . . 120
4.9.2 Model development . . . . . . . . . . . . . . . . . . . . . . . . 121
4.9.3 Model summary . . . . . . . . . . . . . . . . . . . . . . . . . . 122
4.9.4 Model simulation . . . . . . . . . . . . . . . . . . . . . . . . . 122
4.10 Case: Pressure in gas pipe . . . . . . . . . . . . . . . . . . . . . . . . 126
4.10.1 Model objective . . . . . . . . . . . . . . . . . . . . . . . . . . 126
4.10.2 Model development . . . . . . . . . . . . . . . . . . . . . . . . 127
vi CONTENTS
Bibliography 626
xiv CONTENTS
List of Figures
3.1 Stability region for the Explicit Euler method: z , hλ must lie in the
shaded area in order for the discretized system to be stable. . . . . . 63
3.2 Description of continuous function ε′ (x) as a function of x (green
line), with various quantities in the discretization of the conserva-
tive PDE for ε′ (x). Cells of equal width ∆x shown with pale blue
backdrop (alternating lightness). Cell nodes are at the cell centers in
positions j −1, j, j +1, etc. (red circle/red dotted lines). Cells bound-
aries are at positions j − 12 , j + 12 , etc. Cell averages ε̄′j−2 , . . . , ε̄′j+2 are
indicated with olive green lines. . . . . . . . . . . . . . . . . . . . . . 75
xv
xvi LIST OF FIGURES
4.9 Level h in driven tank, i.e., with influent mass flow rate ṁe . The
plot shows the level h with operational conditions as given in Table
4.4 (red), but also the level h (blue) when starting in steady state
conditions with a step change in the input ṁi (green). . . . . . . . . . 112
4.10 Driven water tank: initial mass is emptied through bottom of funnel
shaped tank at effluent rate ṁe , while at the same time the influent
water rate ṁi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
4.11 Functional diagram of tank with varying area and with influent and
effluent flow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
4.12 Level h in funnel shaped driven tank, with influent mass flow rate
ṁi . The plot shows the level h with operational conditions as given
in Table 4.6 (red), but also the level h (blue) when starting in steady
state conditions with a step change in the input ṁi (green). . . . . . 118
4.13 Gas tank with constant temperature T , and variable pressure p and
density ρ. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
4.14 Functional diagram single gas tank with inlet pressure pi and ambient
pressure pa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
4.15 Pressure p in gas tank. The plot shows the pressure p with operational
conditions as given in Table 4.8 (red), but also the pressure p (blue)
when starting in steady state conditions with a step change in the
input pi (green). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
4.16 Gas pipe of length L with constant temperature T and velocity v
throughout, where the velocity also is homogeneous over the cross
sectional area A. Mass flow rate ṁ and pressure p varies along posi-
tion x. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
4.17 Functional diagram of gas pipe with influent mass flow rate ṁ0 and
inlet pressure p0 , and effluent mass flow rate ṁL and effluent pressure
pL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
4.18 Pressure distribution through the tank gp.p[i] with N = 10 slices,
as a function of time. pL is annotated as _pL which equals gp.p[10],
while the inlet pressure p0 is annotated as p_0. The initial pressure
distribution, p (t = 0, x) is annotated as gp.p0. . . . . . . . . . . . . . 131
4.19 Pressure distribution through the tank caused by a step in the inlet
pressure p0 given as gp.p_0; the outlet pressure pL is given as _pL. . 131
4.20 Outlet pressure pL given by _pLN with N (N) slices N ∈ {10, 30, 90, 300},
in response to a step in the inlet pressure p0 given as p_0. . . . . . . 132
5.1 Isomeric realizations of ethanol (left) and dimethyl ether (right). . . . 141
5.2 Barn dance with species M, F, and P. . . . . . . . . . . . . . . . . . . 141
5.3 Barn dance with species M, F, P1 , P2 , and T. . . . . . . . . . . . . . 142
5.4 Ring dance with 3 species: M, F, and R. . . . . . . . . . . . . . . . . 142
5.5 Vessel where two input flows are mixed. . . . . . . . . . . . . . . . . . 162
5.6 Functional diagram of tank where two liquids are mixed. . . . . . . . 163
5.7 Liquid level h for liquid mixing tank. . . . . . . . . . . . . . . . . . . 166
5.8 Specific concentrations ρA and ρB for liquid mixing tank. . . . . . . . 167
5.9 Reactor with varying volume V , and reaction aA → B. . . . . . . . . 172
LIST OF FIGURES xvii
6.1 Torque T is the vector cross product of radius r and force F according
to the right hand rule of vector cross product, and leads to a rotation
indicated by angular velocity ω. The indicated right angles are not
required for the cross product to work, but simplifies things in that
for right angles, |T | = |r| · |F |. . . . . . . . . . . . . . . . . . . . . . . 217
6.2 Mass m circulating around axis at angular velocity ω, with constant
radius r, and influenced by force F . . . . . . . . . . . . . . . . . . . . 217
6.3 Conservative forces Fg due to gravitation (left) and Fs due to spring
elongation (right). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
6.4 Decomposition of flow system and mechanical system. . . . . . . . . . 221
6.5 Sketch of pendulum. . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
6.6 Moody diagram for Fanning’s friction factor f for fluid flow in a pipe,
as a function of the Reynolds number NRe , Bird et al. (2002). . . . . 229
6.7 Measuring pressure drop ∆pf = p1 − p2 due to friction, using a
manometer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
6.8 x, W relation between x and the Lambert “function” W showing two
branches (functions) W−1 (x) and W0 (x). The [ so-called) principal
−
branch W0 can be split into W0 valid for x ∈ − exp(1) 1
, 0 and W0+
valid for x ≥ 0. From Brkić (2011a). . . . . . . . . . . . . . . . . . . 241
xviii LIST OF FIGURES
7.20 Temperature T [K] in heated gas tank (red), and influent temperature
Ti [K] (blue). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
7.21 Pressure p [Pa] in heated gas tank (red) and influent gas pressure pi
[Pa] (blue). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
7.22 Added heat flow Q̇ [W] to gas tank. . . . . . . . . . . . . . . . . . . . 427
7.23 Vertical metal rod with temperature distribution T (t, x) influenced
by end temperatures Tp and Ta . Heat transfer may be influenced by
blowing air passed the top of the rod. . . . . . . . . . . . . . . . . . . 430
7.24 Functional diagram of metal rod. . . . . . . . . . . . . . . . . . . . . 430
7.25 Temperature TL at end of metal rod (red), heated plate temperature
Tp (blue), and air temperature Ta (green), all given in K. . . . . . . . 438
7.26 Heat transfer coefficient h between solid (metal rod) and air in mW 2K ,
E.1 Result from simulating the model in Problem 5.1. The upper plot
shows level h, and the lower plot shows concentration cA . Notice the
(ordinate) scale of the upper plot — the syntax means 2.10999 and
then the ordinate values should be added after these numbers, i.e.,
there is virtually no variation. . . . . . . . . . . . . . . . . . . . . . . 593
E.2 Result from simulating the model in Problem 6.5. The upper plot
shows level h, and the lower plot shows the volumetric feed/input
flow V̇i . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
E.3 Time evolution of level and temperature. . . . . . . . . . . . . . . . . 616
E.4 Time evolution of concentration and temperature. . . . . . . . . . . . 619
E.5 Simulation of cA and T for the reactor, indicating how sensitive the
solution is with regards to V̇c . . . . . . . . . . . . . . . . . . . . . . . 620
E.6 Simulation result from Problem 5.2 p. 212 for the model from Prob-
lem 5.1 p. 211, with inserted indication of tangent dcdt
A (t)
at t = 0, and
steady state value limt→∞ cA (t) under the assumption of no change
in the input variables. The time constant is found (approximately)
as the time from the initial time to the time of intersection between
tangent and steady state value. . . . . . . . . . . . . . . . . . . . . . 624
E.7 Simulation result from Problem 6.6 p. 339 for the model from Prob-
lem 6.5 p. 338, with inserted indication of tangent dh(t)
dt
at “t = 0”
— actually at time t = 2 h, but it is common to refer to the time of
step change in the input as time zero. Also indicated is the steady
state value limt→∞ h (t) under the assumption of no change in the in-
put variable for t > 2 h. The time constant is found (approximately)
as the time from the initial time to the time of intersection between
tangent and steady state value. . . . . . . . . . . . . . . . . . . . . . 625
LIST OF FIGURES xxiii
E.8 Simulation result from Problem 7.8 p. 463 for the model from Prob-
lem 7.7 p. 462, with inserted indication of tangent dh(t)
dt
at t = 0, and
steady state value limt→∞ h (t) under the assumption of no change in
the input variables for t > 0. The time constant is found (approxi-
mately) as the time from the initial time to the time of intersection
between tangent and steady state value. For the temperature re-
sponse T , the time constants can not be observed so directly. . . . . . 627
xxiv LIST OF FIGURES
List of Tables
4.1 Parameters for autonomous tank with constant cross sectional area. 104
4.2 Operating condition for autonomous tank with constant cross sec-
tional area. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
4.3 Parameters for driven tank with constant cross sectional area. . . . . 111
4.4 Operating condition for driven tank with constant cross sectional
area. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
4.5 Parameters for driven funnel shaped tank with constant cross sec-
tional area. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
xxv
xxvi LIST OF TABLES
4.6 Operating condition for driven funnel shaped tank with constant cross
sectional area. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
4.7 Parameters for gas tank with fixed temperature. . . . . . . . . . . . 123
4.8 Operating conditions for gas tank with fixed temperature. . . . . . . 123
4.9 Parameters for gas tube with homogeneous temperature. . . . . . . . 130
4.10 Operating conditions for gas tube with homogeneous temperature. . 131
5.1 The Periodic Table of the Elements. Each cell contains the atomic
number of the respective element, together with the adopted sym-
bol. Groups of elements include Noble Gases, Halogens, Non-Metals,
Semi-Metals, Metals, Transition Metals, Alkali Metals, Alkaline Earth,
as well as Lanthanides and Actinides. Elements marked with * are
elements that have been discovered, but for which names have yet
to be adopted. Adapted from Resnick et al. (2002) and Aylward &
Findlay (2002). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
5.2 Dilute diffusion coefficients for some binary liquid mixtures, where a
small fraction of solute is dissolved in the solvent Poling et al. (2001). 162
5.3 Parameters for tank with liquid mixing. . . . . . . . . . . . . . . . . 165
5.4 Operating conditions for tank with liquid mixing. Hτ is the Heaviside
function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
5.5 Parameters for liquid reactor with varying level. . . . . . . . . . . . 176
5.6 Operating conditions for liquid reactor with varying level. . . . . . . 176
5.7 Parameters for liquid reactor with fixed volume. . . . . . . . . . . . 186
5.8 Operating conditions for liquid reactor with fixed volume. . . . . . . 186
5.9 Parameters for isothermal gas reactor. . . . . . . . . . . . . . . . . . 192
5.10 Operating conditions for isothermal gas reactor. . . . . . . . . . . . 193
5.11 Parameters for study of diffusion of gas in liquid pipe. . . . . . . . . 204
5.12 Operating conditions for study of diffusion of gas in liquid pipe. . . . 204
5.13 Numerical values for parameters and operating points for the model
of Problem 5.1/5.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
8.1 Numerical values for parameters and operating points for the model
of Problem 7.9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545
C.1 Data for selected species. The table shows molar mass M [g/mol],
critical temperature Tc [K], critical pressure pc [bar], molar volume
Ṽc , and Pitzer’s acentric factor ω [dimensionless] Poling et al. (2001). 570
C.2 Molar heat capacity for selected substances. The table shows valid
temperature range, and aj for dimensionless molar heat capacity ex-
∑
pansion in temperature, c̃Rp = 4j=0 aj T j where c̃Rp is dimensionless.
All temperatures (range and T ) are absolute temperatures in K Poling
et al. (2001). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571
xxviii LIST OF TABLES
C.3 Enthalpy data etc. for selected substances. The table shows molar
enthalpy of formation ∆H̃f◦ , molar enthalpy of vaporization ∆H̃v◦ , and
◦
molar enthalpy of melting ∆H̃m , all at the standard state of 298.15 K
and 1 atm. Furthermore, the table shows molar liquid volume Ṽℓ at
temperature Tℓ Poling et al. (2001). See also (†) www.airproducts.com/products/Gases/gas-
facts/physical-properties. . . . . . . . . . . . . . . . . . . . . . . . . 572
C.4 Data taken from Wagman et al. (1982). The units are [H̃] = kJ/mol,
[G̃] = kJ/mol, [S̃] = J/(mol K), [M ] = g/mol, and [c̃p ] = J/(mol K).
The data are given at a pressure of 1 bar, thus not in the standard
state. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
Preface
These lecture notes describe the course content of Course FM1015 Modelling of
Dynamic Systems at University of South-Eastern Norway (USN). The course traces
its roots to a course developed at the Norwegian Institute of Technology (NTH) in
1980–19811 by Prof. Steinar Sælid. I taught the course at NTH 1988-1991, and
then at Telemark University College (TUC) 1991–2015, at University Colleage of
Southeast Norway (HSN) 2016–2017, and since then at USN.2 Through the years,
the course has been developed in new directions, e.g., with more emphasis on formal
methods for describing reacting systems. At the same time the course has been
simplified, with less emphasis on calculus and model reduction.
From 2015 of, the course is offered both as a traditional classroom course, and
in an asynchronous distance learning program. This made it necessary to update
the lecture notes with a clearer definition of learning goals, as well as updating
illustrating examples/cases with a clearer definition of the goal of the modeling task,
and an even more systematic approach to model development. Modeling languages
have seen important developments since the 1990s, in particular with equation based
languages. Application of equation based languages allows for a reduced focus on
model manipulation, since equation based languages are fare less restrictive wrt.
the model form compared to traditional assignment based languages. However, it is
still useful to have knowledge of model manipulation techniques, but the emphasis
should be shifted. At the same time, there has been a development towards free
software. The examples will thus to a large degree be based on such free software
tools. A separate document with introduction to Modelica will be made available.
Most chapters see the addition of concluding sections on Exercises and Problems.
Exercises are meant as simple, repetitive tasks to learn basic skills, while Problems
are meant as more realistic/slightly more complex task designed to put the material
in perspective. As part of the course, a larger group project will be given. This
project will not be described in the lecture notes, but rather in a separate document.
The aim of the project is to give a semi-realistic experience in developing models
and solving the models.
In summary, the course material is still based on previous theory and previous
examples, but the material has been updated and focused. Parts of the lecture notes
are meant to be informational, and is marked with symbol †. Other sections are
marked with symbol +, which is meant to indicate that this is more advanced/com-
plex material. Finally, parts of the lecture notes is still under development; these
1
The Norwegian Institute of Technology (NTH) became part of the Norwegian University of
Science and Technology (NTNU) in 1996.
2
...except 1994, 2000 and 2011, when I was on research leave.
xxix
xxx PREFACE
chapters/sections will be marked with symbol ⋆ — and will obviously not be part of
the syllabus. Because the notes are under development, I am very much interested
in feedback from you, the reader, on (a) what information/material is missing, (b)
what parts are too complicated and needs to be expanded, (c) what parts are too
simple and can be shortened/removed, (d) other ways the notes can be improved.
Finally, the ability to develop models can only be learnt from practice. This
means that without the active involvement from you, the student, there will be no
learning. On the other hand, with active involvement in the course, you will learn
both skills and ways of thinking that will be beneficial for the rest of your career.
xxxi
xxxii PREFACE
Introduction
1.1 Systems
1.1.1 System: object, property, interaction
What is a system? A system may be defined as in Fritzson (2011):
We could alternatively say that a system S is a well defined subset of the world
W, where we know precisely what is part of the system and what is not part of
the system. Those parts of the world that is not part of the system, e.g., the
complement to the system, {S,1 is denoted the environment or the surroundings.
Taken as a whole, the system and the environment together contains the whole
world: S ∪ {S = W.
In thermodynamics, a system is denoted isolated if there is no interaction of mass
nor energy between the system and the environment. If energy can be exchanged
but not mass, the system is closed. If both energy and mass may be exchanged, the
system is open. More generally, there may be information exchange I between the
system and the environment. See Fig. 1.1 for an illustration.
This definition of the system as a well defined subset of the world is not precise,
because a system would have (close to) infinite complexity: we also need to state
which properties of this well defined subset we are interested in studying.
As an example, we may define a system to be a class room in a school, where
the definition includes the walls and everything in between. This definition is not
complete, though: there is an “infinity” of things going on in the room, e.g., a
large number of molecules with their position and velocities (or maybe an even
larger number of quarks, etc.), there are electromagnetic waves, temperature fields,
pressure fields, perhaps human beings with thoughts being developed, a learning
process, etc., etc. Some of these “things” may be related, e.g., the temperature
may be related to the movement of molecules (statistical mechanics). It is clearly
meaningless to let a system be this open-ended: we need to restrict the meaning to
the properties of interest, e.g., be the temperature observed in a certain thermometer
1
System S is a set, and {S is the complement of the set; S ∪ {S = W.
1
2 CHAPTER 1. INTRODUCTION
on the wall and transmitted to the environment, and the CO2 concentration in the
air, and the heating (power) added to the room and the ventilation of fresh air.
1.1.3 Causality
Although not perfectly well understood, the idea of time and causality is important
in physics.2 From experience, systems are causal, which implies that there is a cause
2
See discussions of “the arrow of time” in physics literature: with snapshots of the position and
velocity of individual particles at different times, it is impossible to tell in which direction time
moves. However, considering the cloud of particles as a whole, experience tells us that the system
1.2. EXPERIMENTS 3
Figure 1.3: System S with inputs u from the environment {S and outputs of interest
(properties) y.
that leads to an effect. In other words: the cause must come first, and then the
effect is a result of the cause. Thus: information exchange has a direction. Flow
of information from the environment into the system which affects the behavior
of the system, will be denoted inputs to the system; the common symbol used for
inputs in systems science is u. In a similar manner, flow of information from the
system into the environment which affects the behavior of the environment, will be
denoted outputs from the system; the symbol used for outputs is y. Outputs include
information about the properties that we seek in the system. See Fig. 1.3.
Whether the idea of causality is a system concept, or a model concept, can be
discussed. However, causality allows us to split the information exchange into inputs
and outputs.
1.2 Experiments
The purpose of defining a system is to find out something about the properties of
interest in a system through observations. Thus, we can observe the value of outputs
from a system. It is reasonable to think that we can find out more about a system by
entropy increases with time; this experience enables us to tell the direction of time.
4 CHAPTER 1. INTRODUCTION
manipulating (if possible) the inputs to the system. An experiment can be defined
as Fritzson (2011):
• An experiment is the process of manipulating inputs to a system, in such a way
as to be able to extract information about the system through the outputs.
More information can be extracted from a system if the planning of the experiment
utilizes some knowledge of the system. However, if the system is not well known or
understood, it may be difficult to even design good experiments. As a minimum,
one should have some idea of the time scale of interest in the system. As a general
rule, however: the more that is known about the system, the better experiments can
be designed. To some degree, experiment planning and information extraction is
thus an iterative process.
In systems science, both inputs u to the system and outputs y from the system
are variables of time. Thus, carrying out experiments imply varying inputs to the
system, and observing the response in the outputs. However, it is also of interest
to carry out experiments where the design of the system itself is changed, e.g., the
geometry, fluid properties, etc. These quantities are strictly speaking not inputs to
the system, but rather parameters 3 . We will extend the idea of doing experiments
to include changing parameter values.
In summary, this implies that in a model description, our sets of input and
output variables u, y will only be a subset of the information exchange I between
the system and the environment.
Many types of models/system representations are useful. However, here we will
consider quantitative mathematical models. Such mathematical models can be used
to quantify numerical values in forecasts.
Figure 1.4: Ceci n’est pas une pipe = This is not a pipe. René Magritte.
A common problem in model development is that the modeler may start to look
upon the model as reality (“falls in love with the model”), and believe in the model
behavior instead of the system behavior. It is important to realize that the model
is just a simplified “image” of the system, and that a model will never be able to
predict system behavior perfectly. Even with imperfect models, the model may still
be useful, though.
1.4 Simulation
Models are often discussed in tandem with simulation 8 . Simulation can be defined
as follows Fritzson (2011):
Simulation can thus include both varying input variables, and varying model pa-
rameters.
Varying input variables is relevant for studying operational aspects of the system:
how should a given system be operated to give the best possible result. Because sim-
ulation is based on a model, which is never perfect, it may be relevant to study how
sensitive a proposed operational strategy is wrt. to model uncertainty, e.g., model
parameters or unknown inputs. Operational strategies may be simulated off-line
prior to its use, where a detailed model of the system may be useful. However, oper-
ational strategies typically use models themselves in on-line optimization including
feedback and feed forward control, and such models must typically be solvable many
times faster than real time. Thus, models to be used for on-line optimization must
in general be “simple”.
Detailed models may be used for system design studies. In that case, it is relevant
to study the consequences of changing geometrical parameters (the “experiment”),
the use of different materials, various topologies, etc. However, in operational stud-
ies, it is necessary with a balance between model simplicity and model accuracy,
which may call for models with parameters that give an approximate description of
8
Simulation: from Latin simulare, meaning to pretend.
8 CHAPTER 1. INTRODUCTION
physical effects. It is thus relevant to consider experiment responses from the real
system with responses from a model, and allow for calibrating model parameters to
make the model responses as similar to the system responses as possible.
and are needed in order for the model to constitute a complete system description
where the number of independent equations equals the number of unknowns. The
additional relations/algebraic equations are therefore often referred to as constitutive
equations, or phenomenological 11 equations. Maintaining ε as symbol for extensive
quantities, and denoting algebraic variables (β̇j , σ̇, etc.) by ζ while inputs are
denoted u and constants/parameters are denoted θ, balance laws can typically be
written in the form
dε
= f (ε, ζ, u; θ)
dt
while the constitutive equations can be written as
0 = h (ε, ζ, u; θ) .
Together, Eqs. 1.5 and 1.6 form a set of Differential and Algebraic Equations, DAEs.
One comment on balance laws is due. In principle, it is possible to form a balance
equation for any variable x, not only for an extensive variable ε. Because of this,
DAEs are often more generally written as
dx
= f (x, z, u; θ) (1.5)
dt
0 = h (x, z, u; θ) . (1.6)
However, constitutive equations are not available for general x. In fact, constitutive
equations are by and large only available for conserved quantities or quantities that
are “almost” conserved. Because of this, model development should use conservation
laws as its starting point.
These notes are centered around conservation laws/balance laws. With each
balance law, various relevant phenomena are discussed together with the equations
needed to constitute a complete model. The concepts are illustrated through exam-
ples.
Modelica is a modern language for encoding models in DAE form. Through-
out the notes, the Modelica language is therefore used to encode example models,
mainly taken from the realm of process and energy systems. In order to study ex-
periments on these models, a Modelica based simulation tool is needed; here the
free OpenModelica tool is used. Because Modelica based tools in general are rather
limited wrt. analysis support, it may be useful to combine Modelica with other lan-
guages which have their strength in scripting and numeric methods. One possible
such language is Python. To this end, Python is used to some degree for analysis
purposes.
The notes are structured as follows. In Chapter 2, an introduction is given to
quantities and their use, including units and dimensionless numbers. In Chapter 3,
a brief overview is given on methods for solving models.
Chapters 4–8 form a core part of the course, with the discussion of conserva-
tion/balance laws for mass, species, momentum and energy in chapters 4–7. Equally
important is Chapter 8 on model analysis. Model calibration is discussed briefly in
11
Phenomenological equations in the sense that they describe the particular phenomena that
take place, while the balance/conservation laws are generic.
10 CHAPTER 1. INTRODUCTION
• Symbols: good practice for choice of symbols for quantities and operators,
standards symbols for some quantities.
2.2 Quantities
A quantity is in general a product of a numeric value and a unit. We refer to a
quantity by using a quantity symbol, e.g., m. We will use the operator || to extract
the numeric value and the operator {} to extract the unit, thus |m| is the numeric
value of the quantity referred to by symbol m, while {m} is the unit of the quantity
referred to by symbol m. This means that
m = |m| · {m} ,
e.g.,
m = 5 kg.
Some quantities are physical constants which are independent of time and space,
and which we have no control over; we will refer to such quantities as constants.
Other quantities can be chosen at will — e.g., by a design choice, but will be constant
for a given operation/experiment. Examples are physical dimensions (volume of a
tank, thickness of a wall, etc.), the density of a chosen liquid, the heat transfer
coefficient of a material, etc.; we will refer to such quantities as parameters. See Fig.
2.1.
11
12 CHAPTER 2. QUANTITIES AND THEIR USE
system is still ρ — it does not increase, while the mass is the sum of masses, m1 +m2 .
The point of this quotation is that the name (rose) is just a placeholder or symbol
for the object (the physical object which in English is denoted by the word “rose”),
and that if we use a name in another language for the same object, the object is still
the same and does not change.
Similarly, in models we have quantities (objects) and we introduce symbols as
“names” for these objects. Obviously, the quantities are independent of what sym-
bols we choose to refer to them. As an example, if the quantity is the temperature
in a room, this temperature is the same whether we choose to refer to it as “T ”,
“β”, “upsilon”, “Temperature”, or whatever symbol/name we choose.
Because our models may contain many objects (quantities), it is much easier to
communicate our model if we choose symbols/names that are easy to understand.
Certain general rules have been defined for notation/symbols, and it is a good idea
to learn these rules and try to follow them as well as possible.
The following rules are used extensively in the sciences.
1. Symbols for quantities should be typeset in an italic font (slanted), and with
special rules for distance between letters.
Table 2.1: The Greek alphabet, with (ancient) pronunciation/sound — symbol “:”
indicates a long vowel. For some letters, two alternative miniscules exist, e.g., ε and
ϵ for E.
Letter Name Sound Letter Name Sound
A α alpha [a], [a:] N ν nu [n]
B β beta [b] Ξ ξ xi [ks]
Γ γ gamma [g] O o omicron [o]
∆ δ delta [d] Π π, ϖ pi [p]
E ε, ϵ epsilon [e] P ρ, ϱ rho [r]
Z ζ zeta [zd], [dz] Σ σ, ς sigma [s]
H η eta [ε:] T τ tau [t]
h
Θ θ, ϑ theta [t ] Y υ upsilon [y], [y:]
I ι iota [i], [i:] Φ φ, ϕ phi [ph ]
K κ, κ kappa [k] X χ chi [kh ]
Λ λ lambda [l] Ψ ψ psi [ps]
M µ mu [m] Ω ω omega [o]
2.3.2 Operators
2.3.2.1 Differentiation vs flow
Leibniz and Newton developed differentiation and integration independently, and
more or less at the same time. Leibniz5 introduced the infinitesimals dx, dy, and
dy
( dx for
the symbol ) the slope of the tangent; higher order derivatives were denoted
dn y dy n−1
dxn
, d
dx dxn−1
. With time as independent variable, this leads to the notation
5
Gottfried Wilhelm von Leibniz (1646–1716) developed infinitesimal calculus in 1676.
16 CHAPTER 2. QUANTITIES AND THEIR USE
dx n
dt
and ddtnx . Newton’s6 work was mainly related to dynamics, and he placed a dot
...
on top of a symbol to indicate time derivative, e.g., ẋ, ẍ, x , etc., thus ẋ = dx dt
,
7
etc., according to Leibniz’ more general notation. Lagrange used primes to denote
differentiation, e.g., f ′ (x) or f ′ equals df
dx
according to Leibniz’ notation. Higher
order differentials are denoted f ′′ and f ′′′ . For derivatives higher than 3, either a
roman superscript is used, e.g., f iv , or an Arab number in parenthesis, f (4) . Finally,
Euler8 introduced the notation Df to denote df dx
according to Leibniz’ notation, and
n dn f
D f to denote dxn . If explicitness of independent variable is desired, the Euler
notation is, e.g., Dnx f or Dnx f (x).
To this end, the following symbols are often used for time derivatives
dx
, ẋ, Dt x, x′ , . . .
dt
Here, dtd
, ·, Dt , and ′ are operators which operate on/modify quantity x. In good
mathematical practice, operators should really be typeset using roman typesetting,
d
e.g., dt and Dt ; see also the previous section. Not all equation editors have good
support for differentiation as an operator, and in this document we will write differ-
entiation as dxdt
.
In control engineering, it is common to use Newton’s notation and let ẋ denote
the time derivative of x and thus be equivalent to dx dt
. However, in physics, it is also
quite common to let ẋ denote the flow rate of an extensive quantity x, e.g., if m is
mass (extensive quantity), ṁ denotes mass flow rate. x′ has a more generic meaning
of derivative, e.g., y ′ could denote dxdy
. However, in this document we will use the
′
to denote something else. The notation Dt x is mainly used in more theoretical
mathematics. Because time derivative is of key importance in this course while flow
rates are also important, we will avoid using ẋ and x′ to denote time derivative, and
instead write the time derivative as dx dt
. In summary, this means that we will use
the following notation:
∂y y (t + ∆t, x) − y (t, x)
, lim
∂t ∆t→0 ∆t
∂y y (t, x + ∆x) − y (t, x)
, lim .
∂x ∆t→0 ∆x
6
Sir Isaac Newton (1643–1727) published his work on infinitesimal calculus in 1693, but most
likely developed it earlier.
7
Joseph-Louis Lagrange (1736–1813).
8
Leonhard Euler (1707–1783).
2.3. SYMBOLS AND OPERATORS 17
∑
5
xi .
i=1
∑
• If the value of quantity fi depends on index i, i fi thus is the sum of fi for
indices i. We could be more specific and say that i ∈ I, and write
all relevant ∑
the sum as i∈I fi .
9
Prepend = put in front of. Prepend is the opposite of append = put after; cf. appendix.
18 CHAPTER 2. QUANTITIES AND THEIR USE
´
Symbol denotes integration.
´
• For function f (x), a common notation for the indefinite
´ integral is f (x) dx,
where the function to be integrated is bracketed by and the infinitesimal of
the variable, dx.
• ε̂: extensive quantity ε per mass, also called specific ε. Example: if ε is energy
E, Ê is specific energy = energy per mass.
• ε̃: extensive quantity ε per number of moles, also called molar ε. Example: if
ε is energy E, Ẽ is molar energy.
• ε′ , ε′′ , ε′′′ : extensive quantity ε per length, per area and per volume; thus each
index ′ indicates one length unit. With this use, index ′ must not be confused
with derivative. Example: if ε is mass m, m′ is mass per length, m′′ is mass
per area, while m′′′ is mass per volume = density.
2.3. SYMBOLS AND OPERATORS 19
Some operators are commonly written as two letter combinations, but alternatives
exist and we will use the alternatives in order to avoid two letter symbols.
• The real part of complex number z is sometimes written as Rez; here we will
use the alternative standard notation ℜz; symbol ℜ is a special font/typeset-
ting of character R.
To illustrate this, consider quantities of length, which to a large degree have been
based on the size of body limbs, etc. The old Norwegian system consisted of the
following units, Table 2.4.
In an old society with limited information exchange and local production, a knife
could be described based on the thumb size of the local black smith, and a boat
could be described using the cubit size of the local carpenter. Later on, it became
necessary to define the units more accurately. Typically, a (local) standardized cubit
measure was “published” by hanging it on the local church door. Instead of the word
alen (cubit) the word stikke was sometimes used, which perhaps indicates a piece of
wood which copied the length alen as defined on the local church door.
With extended communication/travel, the Norwegian alen was modified, e.g., in
1541 to be equal to the Danish Zealand cubit, and in 1683 as two Rhinish feet. This
gradual change in the definition of units is the reason why unit fjerding (and/or rast)
had a change in the definition (4800 cubits to 4000 cubits) — simply to preserve the
original length. The rast is more or less equal to 10 km.
These problems were sought resolved during the centuries, and a key progress was
made during the French Revolution when a committee consisting of, among others,
the scientists Lagrange and Laplace , proposed what eventually became Systeme
International, the SI units. The SI system consists in precisely defined units in a
decimal system. The first version of the SI units was adopted by law in the 1790s in
France, but the process was reversed in 1812 by emperor Napoleon Bonaparte, and
22 CHAPTER 2. QUANTITIES AND THEIR USE
then reintroduced in France in 1837. After this, the introduction of the metric system
gradually spread to other countries, and became legal in USA in 1866. The main
launching of the SI system was at a meeting in France in 1872, resulting in the signing
of the International Metric Convention in Paris in 1875 and the establishment of the
General Conference on Weights and Measures, CGPM11 . The first CGPM in 1899
organized the distribution of a standardized meter to the (then) 21 member states. In
1954, the 10th CGPM adopted a set of six base units for length, mass, time, electric
current, thermodynamic (absolute) temperature, and luminous intensity. The 11th
CGPM in 1960 adopted the name Système International d’Unités, SI units. The
14th CGPM in 1972 adopted the amount of substance, the mole, as a seventh base
unit.
The word dimension is used with several meanings in science. The most common
one is perhaps that of 3-dimensional space, a surface as 2-dimensional space, the 4
dimensions of time-space in relativity theory, etc. In this section, we will use the
word dimension in a slightly different meaning: as a generalization of unit. We have
seen that certain quantities such as the height of a building, the width of a wooden
beam in a house, the thickness of a window pane, etc., can use different units —
e.g., units of meter, inch, and millimeter. All of these quantities are lengths, and
this slight abstraction of unit where we don’t really care about whether the quantity
is measured in meter, millimeter, inch, foot, etc., is known as the dimension. In
other words, when we use the word dimension, we haven’t really decided whether
we use the SI system, or some other unit system, or whether we use a mixture of
unit systems. Similarly, temperature is a dimension, pressure is a dimension, etc.
Just as there are base units, we can also define base dimensions.
We have already introduced symbol {} to extract the unit of a quantity, e.g.,
{q} is the unit of quantity q. Let us introduce operator [] to extract the dimension
of a quantity, e.g [q] is the dimension of quantity q.
Here, it should be observed that these two supplementary units are non-dimensional.
However, for clarity, the units and dimensions are sometimes included.
The SI derived units are defined by simple equations12 relating two or more base
units. Table 2.7 give the 19 derived SI units.
A general rule of SI units is that the use of non-SI units should be discontinued.
However, this is sometimes impractical. The SI unit system thus recognizes some
out-of-system units which may be used in combination with SI units. Table 2.8 lists
twelve common non-SI units.
Some non-SI units are defined by experiment, Table 2.9.
Thirteen non-SI units are temporarily maintained, but may disappear in the
future, Table 2.10
Finally, seventeen non-SI units are listed as to be discontinued, Table 2.11.
The SI unit system is a decimal system of units, and it is common to use prefixes
prepending the SI symbols. It is important to note that these prefixes are part of
the (extended) symbol, thus it is incorrect to insert extra space as if the prefix and
the SI symbol are separate symbols.
The twenty SI prefixes are given in Table 2.12.
To repeat: it is essential to adhere to the precise symbol in the tables when
it comes to use of symbols. As an example, 1 MW ̸= 1 mW, and the unit AW
doesn’t exist (specifically, it does not mean attoWatt) — if anything, AW would
mean ampere-watt.
The prefixes kilo, mega, giga, and tera are often used in computer science —
but with a different meaning: instead of representing 103·n = (1000)n where n ∈
{1, 2, 3, 4}, in computer science these prefixes represent 210·n = (1024)n . For com-
puter science, the recommended unit symbols are as indicated in Table 2.13.
Notice that in computer science, it is common to typeset all prefixes as cap-
ital letters/majuscules; the reason is that the prefixes in computer science mean
something else than in other sciences.
12
The only allowed operations in the equations are multiplication, integer power, and division.
24 CHAPTER 2. QUANTITIES AND THEIR USE
Table 2.7: The nineteen derived SI units with special names and symbols.
SI unit SI symbol Physical Dimension Using base units
quantity
becquerel Bq radioactivity T−1 1 Bq = 1 s−1
coulomb C electric charge IT 1 C = 1 As
farad F electric capac- M−1 L−2 T4 I2 1 F = 1 kg−1 m−2 s4 A2
itance
gray Gy absorbed dose M2 T−2 1 Gy = 1 m2 s−1
of radiation
henry H electric induc- ML2 T−2 I−2 1 H = 1 kg m2 s−2 A−2
tance
hertz Hz frequency T−1 1 Hz = 1 s−1
2 −2
joule J energy, work, ML T 1 J = 1 kg m2 s−2
heat
lumen lm luminous flux JΩ 1 lm = 1 cd sr
lux lx illuminance JΩL−2 1 lx = 1 cd sr m−2
newton N force, weight MLT−2 1 N = 1 kg m s−2
ohm Ω electric resis- ML2 T−3 I−2 1 Ω = 1 kg m2 s−3 A−2
tance
pascal Pa pressure, ML−1 T−2 1 Pa = 1 kg m−1 s−2
stress
poiseuille Po absolute/ dy- ML−1 T−1 1 Po = 1 Pa s =1 kg m−1 s−1
namic viscos-
ity
siemens S electric con- M−1 L−2 T3 I2 1 S = 1 Ω−1 = 1 kg−1 m−2 s3 A2
ductance
sievert Sv dose equiva- L2 T−2 1 Sv = 1 m2 s−2
lent
tesla T magnetic flux MT−2 I−1 1 T = 1 kg s−2 A−1
density
volt V electric poten- ML2 T−3 I−1 1 V = 1 kg m2 s−3 A−1
tial
watt W power, radi- ML2 T−3 1 W = 1 kg m2 s−3
ant flux
weber Wb induction ML2 T−2 I−1 1 Wb = 1 kg m2 s−2 A−1
magnetic flux
2.4. UNITS AND DIMENSIONS 25
Table 2.8: Twelve commonly used non-SI units. In the case of liter, two SI unit
symbols are possible: upper case and lower case L. Because lower case L (“l”) easily
is misread as the numerical unity symbol “1”, it is advised for clarity to use upper
case L.
SI unit SI symbol Physical quantity Dimension Using base units
ampere-hour Ah electric charge IT 1 Ah = 3600 C
day d time, duration T 1 d = 86400 s
◦
degree plane angle α 1 ◦ = π/180 rad
dioptre d refractive power L−1 1 d = 1 m−1
hour h time, duration T 1 h = 3600 s
2 −2
kilowatt-hour kWh energy, work, heat ML T 1 kWh = 3.6 · 106 J
liter l, L capacity, volume L 3
1 L = 10−3 m3
minute min time, duration T 1 min = 60 s
′
minute of angle plane angle α 1 ′ = π/10800 rad
′′
second of angle plane angle α 1 ′′ = π/648000 rad
tex tex linear mass density ML−1 1 tex = 10−6 kg m−1
tonne (metric) t mass M 1 t = 103 kg
Table 2.13: Outdated (but still used) computer science units; 1 byte = 8 bit.
Unit Unit Conversion Unit Unit Conversion
sym- factor sym- factor
bol bol
kilobyte KB 210 byte kilobit Kb 210 bit
megabyte MB 220 byte megabit Mb 220 bit
30
gigabyte GB 2 byte gigabit Gb 230 bit
terabyte TB 240 byte terabit Tb 240 bit
10
kilobyte/second KB/s 2 byte/s kilobit/second Kb/s 210 bit/s
megabyte/second MB/s 220 byte/s megabit/second Mb/s 220 bit/s
gigabyte/second GB/s 230 byte/s gigabit/second Gb/s 230 bit/s
40
terabyte/second TB/s 2 byte/s terabit/second Tb/s 240 bit/s
28 CHAPTER 2. QUANTITIES AND THEIR USE
thus y and c should have the same units. Typically, xς is chosen such that x̄ = xxς ∈
[0, 1]. We have thus solved the problem. The use of such a non-dimensional group
of quantities, x̄ = xxς , also have other advantages: such groups
• facilitate the scale-up of models of small-scale systems to real scale systems,
conditions,
• reduces numeric round-off due to manipulations with large/small numbers,
• enables the assessment of the relative importance of terms in the model equa-
tions.
What about expressions involving, e.g., a square root, as in
√
y = k x?
Technically, this is an algebraic expression — we get
{k}2 = {y}2 {x}−1 .
However, also in this case is it recommended to use a non-dimensional argument x,
e.g., use an expression √
x
y=k
xς
where x and xς have identical dimensions and units and thus x̄ = xxς is non-
dimensional. Why? Partially because unit conversion is greatly simplified. But
also because of numeric reasons: with a well chosen scaling quantity xς , it is possi-
ble to improve on the numerics of the model.
where ∀j means “for all j”, ℓij is a positive or negative integer, and n∆ = 7.15
and let the columns of matrix B be the linearly independent basis vectors for the
nullspace N (L). With any invertible transformation matrix T such that matrix M
has integer elements,
M = BT ,
( )T
let m(j) be column j of matrix M ; m(j) = m(j) 1
(j)
· · · mnq . Model forms Eqs.
2.1 and 2.2 are then equivalent with nπ = rankL non-dimensional quantities (non-
(j) (j) (j)
mnq
( )T
m1 m2
dimensional groups) πj = q1 q2 · · · qnq , m = m1 · · · mnq
(j) (j) (j)
.
⇓
ℓ11 m1 +ℓ12 m2 +···ℓ1nq mnq ℓ21 m1 +ℓ22 m2 +···ℓ2nq mnq ℓn 1 m1 +ℓn∆ 2 m2 +···ℓn∆ nq mnq
[π] = ∆1 · ∆2 · · · ∆n∆∆ .
From the requirement that π is non-dimensional, i.e., that ⟨π⟩ = ∆01 · ∆02 · · · ∆0n∆ , it
follows that
or in matrix form:
ℓ11 ℓ12 ··· ℓ1nq m1 0
ℓ21 ℓ22 ··· ℓ2nq m2 0
.. .. ... .. .. = .. ,
. . . . .
ℓn∆ 1 ℓn∆ 2 · · · ℓn∆ nq mnq 0
or
Lm = 0
where
ℓ11 ℓ12 ··· ℓ1nq m1
ℓ21 ℓ22 ··· ℓ2nq m2
L= .. .. .. .. , m= .. .
. . . . .
ℓn∆ 1 ℓn∆ 2 · · · ℓn∆ nq mnq
Here, the elements of L are given by Eq. 2.3. The non-dimensional quantity π
is a transformation of qj as given by Eq. 2.4, where m lies in the nullspace of L,
m ∈ N (L).
Nullspace N (L) has dimension nπ = dim N (L) = nq −rankL ≥ nq −min (nq , n∆ ).
This means that we can create nπ linearly independent dimensional quantities πj
given as
(j) (j) (j)
m1 m2 mn
πj = q 1 q2 · · · qnq q .
With (j)
m1
(j)
m2
m(j) = ,
·
(j)
mnq
m(j) is column j in matrix M
M = BT
where T is any invertible matrix, and B is the matrix of basis vectors for N (L).
Normally, πj is restricted to using integer values for m(j) .
Remark 2.1. Note that the dimension of a quantity has nothing to do with the
dimension of a matrix. The dimension of a quantity is a generalization of the unit
of the quantity, while the dimension of the matrix is the size of the matrix, i.e., the
number of rows and the number of columns. N
A number of examples of using the Buckingham Π-theorem for reducing the order of
models are presented in Stichlmair (2002), but without using the efficient formalism
of linear algebra/null space analysis.
Example 2.1. Non-dimensional quantities
Consider the flow of fluid in a pipe of length L and diameter D. The fluid has
velocity v, density ρ, and viscosity µ. We assume that all of these quantities affect
the pressure drop ∆p in the pipe, thus there is a relationship
f (∆p, ρ, v, µ, D, L) = 0, (2.6)
2.5. DIMENSIONLESS MODELS 33
where the functional relationship (mapping) f (·) is unknown at the moment. One
could conceptually do experiments where all six quantities (∆p, ρ, v, µ, D, L) are al-
lowed to vary, and then fit a parameterized model of these quantities to experimental
data using the least squares method.
From Tables 2.5 and 2.7 we have
Basis vectors for the nullspace of L, N (L), can be found using scientific computation
languages such as Python (with package NumPy), MATLAB, or Computer Algebra
Systems (CAS) such as Maple, Mathematica, or symbolic packages/toolboxes of
Python and MATLAB.
Using the Spyder IDE for the free Anaconda Python distribution, the following
script file is created and stored in file buckinghamPI-PipeFlow.py:
1 """
2 The Buckingham PI - theorem for finding dimensionless groups
3 for flow of fluid in pipe
4
5 Basis vectors for the nullspace of matrix L
6 ----
7 Created on Wed Aug 05 11:08:53 2015
8
9 @author : berntl
10 """
11
12 from sympy import Matrix
13 #
14 # Define L matrix
15 L = [[1 ,1 ,0 ,1 ,0 ,0] ,[ -1 , -3 ,1 , -1 ,1 ,1] ,[ -2 ,0 , -1 , -1 ,0 ,0]]
16 L = Matrix ( L )
17 #
18 # Compute ( symbolically ) basis vectors for nullspace of L
19 # and print the result to the console
20 print L . nullspace ()
34 CHAPTER 2. QUANTITIES AND THEIR USE
Here, we take advantage of the symbolic package sympy for Python, and define a
2D array L which is subsequently converted to a symbolic matrix L before method
nullspace is used to extract the basis vectors for the nullspace. The result is to be
printed to the console window.
Next, when running this code (e.g., by clicking the big green arrow at the top of
the IDE), the following response is given in the IPython console window.
We observe that the answer is given as a list of 3 column matrices (vectors) where
the elements are rational numbers, implying that the matrix B of basis vectors is:
− 12 1
2
1
2
1 1 1
2 2 2
1 0 0
B=
0
.
−1 −1
0 1 0
0 0 1
2.6 Review
We have seen that quantities can be categorized into either constants or variables.
Constants are typically either natural constants — which do not change, and pa-
rameters which can be altered by design changes.16 Thus in a given experiment,
parameters are constant, but in another experiment, we may change the parame-
ter. Natural constants can, of course, not be changed, and are constant across all
experiments.
Some variables are independent; when the topic is dynamic systems, time is
the obvious independent variable; time just marches on independently of what we
do. If some properties varies in space, spatial position may also be an independent
variable. Other independent variables can be also be relevant. Finally, we have seen
that some variables (or more generally: quantities) has a numeric value that depends
on the extension/size of the system, e.g., mass, volume, etc. These are classified as
extensive variables, while variables (quantities) that are independent of the size are
known as intensive variables (quantities).
It is important to have a clear and well functioning system for naming variables.
Normally, symbols are typeset in italic to distinguish symbols from text. Because it
is common in mathematics to let multiplication be assumed between two subsequent
letters, e.g., ab is assumed to denote a·b, the notation is not very clear if we introduce
symbols consisting of two or more letters in sequence. Thus, e.g., temp is not a
good symbol for temperature. To this end, it is recommended to use single letter
symbols to denote quantities, and instead distinguish between various quantities by
“decorating” the symbols with indices, etc. In this document, an extensive variable
decorated with a dot, e.g., ṁ, denotes a flow rate of quantity m. Similarly, prime
decoration is used to imply per length unit, i.e., m′ is mass per length, m′′ is mass
per area, and m′′′ is mass per volume. Furthermore, the hat decoration implies per
mass, ĉ, while the tilde decoration implies per mole, e.g., c̃. Indices are typeset in
italic if they are variables, and in roman if they are descriptive. Thus, in xi the
index i is typeset in italic and is considered an index — e.g., i ∈ Z. However, in
xi the index i is typeset in roman and is thus descriptive — xi could denote the
value of x at the inlet of the system. Finally, it is recommended to use mnemonic
symbols, e.g., t for time, T for temperature, m for mass, etc. – this makes it easier
to read and understand the models. Although it is good to pay respect to symbol
16
In mathematically oriented sciences, parameters are constants. In other fields, the word pa-
rameter may be used differently.
2.7. EXERCISES 39
2.7 Exercises
Solutions to these exercises are given in Appendix D.1. It is recommended to defer
looking at the solution until a serious attempt to solve an exercise has been given.
Exercise 2.2. Consider constant µ which is the viscosity of a fluid. Should this
be considered a natural constant or a parameter? Could µ be considered either a
natural constant or a parameter, depending on the problem? N
Exercise 2.4. Let Q be heat. What is the meaning of Q̇ in this document? Does
dQ
dt
make sense? N
Exercise 2.5. Let E be total energy. What is the meaning of Ė in this document?
Does dE
dt
make sense? N
Exercise 2.6. Let E be total energy. What is the meaning of E ′′ in this document?
N
dm
= ṁi − ṁe ,
dt
what are the dimensions of the various terms? Suggest units for the terms, and
discuss in particular what it means that the units must be consistent. N
Exercise 2.11. Suppose that you want to study mass stored in a tank, and mass
flows flowing into the tank and leaving the tank. Suggest relevant symbols to be
used in the study. N
2.8 Problems
Solutions to these problems are given in Appendix E.1. It is recommended to defer
looking at the solution until a serious attempt to solve a problems has been given.
2. Set up the indicated list of base dimensions ∆ for the model. (Hint: the ∆ in
∆p does not refer to the base dimension, but instead ∆p indicates a pressure
difference.)
3. Relate the dimension of the quantities to the base dimensions, i.e., ∀j : [qj ] =
∏ ℓk,j
k ∆k ; set up matrix L with elements ℓk,j .
2.8. PROBLEMS 41
4. Find basis vectors for the nullspace N (L), e.g., using Python. (Hint: there
should be two basis vectors.)
Impellers are used to agitate the liquid content of tanks in attempt to achieve
perfect mixing. The power consumption Ẇ of the impeller depends on the diameter
Di of the impeller, the number of revolutions ṅi per time unit, density ρ of the liquid,
and viscosity µ of the liquid.
π1 = F (π2 )
where
Ẇ
π1 =
ρDi5 ṅ3i
ρṅi Di2
π2 = = NRe .
µ
N
Pumps, compressors, turbines and fans are machines designed to change the energy
level of fluids. A pump, compressor or fan increases the total pressure of the fluid
with the purpose of transporting the fluid to a location with higher pressure, while
a turbine extracts energy from a flowing fluid. In this problem, we consider rotating
turbo machines.
The head H of a turbo machine is the liquid column which gives the equivalent
pressure change ∆p over the machine, i.e., ∆p = ρgH. Let V̇ denote the volumetric
fluid flow through the machine — which changes through the machine. Let further-
more ρ be the density at the location where V̇ is given (ρ will also change through
the machine). Let n denote the rotational speed, typically given in the number of
complete rotations per time unit. Let D be a typical diameter, and µ the viscosity.
We postulate that there is a relation
( )
f H, V̇ , n, ρ, g, µ, D = 0
that describes the important operation of the machine. Let the base dimensions be
L (length), T (time), and M (mass).
1. Set up the list of quantities q for this model.
3. Relate the dimension of the quantities to the base dimensions, i.e., ∀j : [qj ] =
∏ ℓk,j
k ∆k ; set up matrix L with elements ℓk,j .
4. Find basis vectors for the nullspace N (L), e.g., using Python. (Hint: there
should be four basis vectors.)
5. Show that the following set of dimensionless groups satisfies the null space:
gH
π1 = = head coefficient
n2 D 2
V̇
π2 = = volumetric flow coefficient
nD3
ρnD2
π3 = = Reynold number NRe
µ
D
π4 = = ratio between diameter and “heat”.
H
F (π1 , π2 , π3 , π4 ) = 0 ⇔ π1 = G (π2 , π3 , π4 ) .
7. It turns out that the operation of turbo machines is relatively insensitive to the
Reynolds number. Furthermore, for a given machine with constant head, π4 is
constant and can be neglected. What is the resulting expression (in physical
quantities) for the operation of turbo machines? N
Problem 2.5. [Solution E.5 p. 589] Simplifying PDE to ODE.
2.8. PROBLEMS 43
f (T, t, z, k, ρ, cv , T0 ) = 0.
Possible dimensions for the model are Θ (temperature), T (time, but also symbol
for variable temperature), and L (length).
1. Set up the list of quantities q for this model.
2. Set up the list of base dimensions ∆ for the model.
3. Relate the dimension of the quantities to the base dimensions, i.e., ∀j : [qj ] =
∏ ℓk,j
k ∆k ; set up matrix L with elements ℓk,j .
4. Find basis vectors for the nullspace N (L), e.g., using Python. (Hint: there
should be two basis vectors.)
5. Propose a couple of alternative sets of dimensionless groups, (π1 , π2 ).
6. Buckingham’s Π-theorem implies that
f (T, t, z, k, ρ, cv , T0 ) = 0 ⇔ F (π1 , π2 ) = 0.
π2 = F̃ (π1 ) ?
T = T0 · F̃ (π1 ) .
Insert this result into the original PDE. Show that the result is an ordinary
differential equation (ODE) for function F̃ of form
d2 F̃ π1 dF̃
2
+ = 0.
dπ1 2 dπ1
N
44 CHAPTER 2. QUANTITIES AND THEIR USE
Remark 2.3. It can be shown that this ODE can be solved, leading to the solution
(π ) z
= T0 (z) erf √
1
T (t, z) = T0 (z) erf
2 2 k t ρcv
´s
where erf (·) is the error function defined as erf (s) = √2 exp (−σ 2 ) dσ where
π 0
π = 3.141592.... N
Chapter 3
• What are the basic properties and solution methods for algebraic equations?
• What are the basic ideas for solving ordinary differential equations?
y = ax + b
∑
N
y= cj x j .
j=0
45
46 CHAPTER 3. MODELS AND MODEL SOLUTION†
polynomials xα1 1 · xα2 2 · · · xαnn . In a footnote of Section 2.5.1, the mathematical notion
of an algebraic function in variable x is defined as a function y = f (x) that satisfies a
polynomial equation an (x) y n + an−1 (x) y n−1 + · · · + a0 (x) = 0 where the coefficients
ai (x) are polynomial functions of x. In this respect, all of the above models are
algebraic.
However, in modeling theory, it is common to extend the notion of algebraic
equations to include any relation that does not involve ordinary or partial derivatives
of unknown dependent variables. In this modeling concept of algebraic equation
(AE), any relation of form
f (x) = 0
are algebraic equations, where the domain and the co-domain can be of any di-
mension, e.g., Rn and Rm , respectively. Typically, we can also introduce known
variables u in algebraic equations, which then become f (x, u) = 0. This would still
be considered an algebraic equation if the model involves derivatives of the known
variables u.
Dynamic models all deal with systems with inertia, where the rate of change of
key variables is important. Typical models are of form
dx
= f (x, u) (3.1)
dt
where x is the unknown variable varying with time, and u is some externally known
variable. Models of this form are known as first order, ordinary differential equations
(ODE). In order to be complete, ODEs must be accompanied by a condition of the
x value at a given time:
x (t1 ) = x1 .
If t1 is the initial time in the experiment, we have an initial value problem.
If x ∈ Rn and consequently f : Rn → Rn , this is an nth-order system described
by n first order ODEs. Second order ODEs of form
( )
d2 x dx
=f , x, u
dt2 dt
are also possible, but these can trivially be rewritten as a set of first order ODEs by
introducing y = dxdt
, leading to
dx
=y
dt
dy
= f (y, x, u)
dt
— thus, two first order differential equations constitute a second order system.
Multivariate models of form as in Eq. 3.1 are in so-called state space form; they are
state space models; x is known as the state. For higher order models (whether they
are in state space form or not), we need to specify the state at a certain time. If
all states are specified at the initial time of the experiment, we have an initial value
problem. If all states are specified at the end of the experiment, we have a final time
3.2. MODEL TYPES 47
problem. If some states are known at the initial time and others at the final time,
we have a two point boundary value problem.
Quite often, models include both descriptions of rate of change and algebraic
relations for flow rates. Thus, models of form
dx
= f (x, y, u)
dt
g (x, y, u) = 0
are quite common. Such models are often denoted differential algebraic equations
(DAE). Sometimes, a slightly simpler version can be formulated with g (x, y, u) = 0
replaced by y = g̃ (x, u). A slightly more general formulation of DAEs is as in Eq.
3.2: ( )
dx
f , x, u = 0 (3.2)
dt
where we have included the “algebraic variable” y in x, and even allowed for implicit
formulations of the rates of change.
Steady state is the case when x is constant (“steady”), which implies that dx
dt
= 0.
The DAE then reduces to
f (0, x, u) = f˜ (x, u) = 0,
which implies that there is an algebraic relationship between the steady input u and
the steady state x.
The above ODEs and DAEs are only valid when x (t) is differentiable. Thus,
they are not valid if, e.g., x ∈ Q, the rational numbers. Also, if the input vari-
able u contains random variations, e.g., are considered to be random noise — the
descriptions above are not valid. However, if we change the ODE to
dx = f (x, u) dt
xt+1 = F (xt , ut )
which sometimes are denoted as O∆E models; replacing D with ∆ is meant to signify
the discrete time index. Similarly, one could consider ∆AEs of form
F (xt+1 , xt , ut ) = 0.
48 CHAPTER 3. MODELS AND MODEL SOLUTION†
In real life, quantities often vary simultaneously with time and space. Thus
partial differential equations (PDEs) are common; a relatively basic form is
∂x ∂x
+v = f (x) ,
∂t ∂z
but such models can also be more general, e.g., of PDAE form
( )
∂x ∂x ∂ 2 x
f , , , x = 0.
∂t ∂z ∂z 2
In steady state, ∂x
∂t
= 0 and the PDE/PDAE reduces to an ordinary differential
equation in the spatial variable.
For partial differential equations, it is also necessary to specify a temporal con-
dition of form
x (t = t1 , x) = g (x)
where this is known as an initial condition if t1 is initial time of the experiment.
But PDEs and PDAEs also require boundary conditions which are conditions at
the system boundaries: typically, the order of the corresponding steady state model
gives the number of needed boundary conditions. Boundary conditions could be of
form
x (t, z = z1 ) = h (t, u)
∂x
= h (t, u) ,
∂z z=z1
etc. — notice that input variables u typically are introduced via boundary condi-
tions.
In Section 2.5.1, we considered dimensionless groups and models which were re-
lations between dimensionless groups. The discussion based on the Buckingham Π-
theorem required little knowledge about the model structure; essentially knowledge
about which quantities were involved sufficed to draw some conclusions. However,
dimensionless models are also of interest if we have more quantitative models avail-
able. Suppose we have the following model which could describe the temperature
distribution in a fluid flowing in a pipe:
( ) ( )2
∂T ∂T k 1 ∂ ∂T µ ∂v
+v =− r +
∂t ∂z ρcv r ∂r ∂r cv ∂r
(Tm is the temperature on the metal wall). We could want to introduce dimensional
groups while preserving the quantitativeness of the model. The idea of writing such
models in dimensionless form is similar to the introductory discussion in Section
3.2. MODEL TYPES 49
2.5.1, where quantities were scaled and put in dimensionless form by dividing them
with a quantity of the same dimension. To this end, suppose we scale the temper-
ature with a nominal metal wall temperature Tmς , the position with the length L of
the pipe, the radial position with the radius R of the pipe, and the velocity with a
nominal velocity v ς . Thus we introduce
T
= T̄ ⇒ T = Tmς T̄
Tmς
Tm
= T̄m ⇒ Tm = Tmς T̄
Tmς
z
= z̄ ⇒ z = Lz̄
L
r
= r̄ ⇒ r = Rr̄
R
v
= v̄ ⇒ v = v ς v̄.
vς
All the starred variables are now dimensionless. If we furthermore choose the scaling
variables (geometric quantities and nominal values) such that the scaled, dimen-
sionless variables (starred variables) have typical values in the range [0, 1], this also
makes it easier to solve the model numerically.
Inserting these relations into the model leads to
( ) ( ς ) ( ( ς )) ( )2
∂ Tmς T̄ ∂ Tm T̄ k 1 ∂ ∂ Tm T̄ µ ∂ (v ς v̄)
ς
+ v v̄ =− Rr̄ + .
∂t ∂ (Lz̄) ρcv Rr̄ ∂ (Rr̄) ∂ (Rr̄) cv ∂ (Rr̄)
Taking advantage of the fact that the scaling factors are constants, this model can
be rearranged into
( ) ( )2
ς ∂ T̄ v ς Tmς ∂ T̄ kRTmς 1 ∂ ∂ T̄ µv ς ∂v̄
Tm + v̄ =− r̄ +
∂t L ∂ z̄ ρcv RRR r̄ ∂r̄ ∂r̄ cv R ∂r̄
⇓
kTm ς ( ) µv ς ( )2
Tmς ∂ T̄ ∂ T̄ ρcv RR 1 ∂ ∂ T̄ ∂v̄
ς
v ς Tm
+ v̄ = − vς Tmς r̄ cv R
+ vς Tmς
L
∂t ∂ z̄ L
r̄ ∂r̄ ∂r̄ L
∂r̄
⇓
( ) ( )2
L ∂ T̄ ∂ T̄ kL 1 ∂ ∂ T̄ µL ∂v̄
ς
+ v̄ =− r̄ + .
v ∂t ∂ z̄ ρcv R2 v ς r̄ ∂r̄ ∂r̄ cv Tmς R ∂r̄
Here, vLς is the nominal time it takes the fluid to pass through the pipe, so we could
introduce this as a scaling of the time,
t
t̄ = L
.
vς
Lz = b.
z1 = b1
ℓ2,1 z1 + z2 = b2
ℓ3,1 z1 + ℓ3,2 z2 + z3 = b3
..
.
∑
n−1
ℓn,j zj + zn = bn .
j=1
Thus, starting at the bottom, we have xn = zn /un,n , xn−1 = (zn−1 − un−1,n xn ) /un−1,n−1 ,
etc. until every element of x is found. Obviously, this procedure only works when
the system has full rank, i.e., when ∀j : uj,j ̸= 0. Sometimes, it is necessary to
permute the equations before taking the LU factorization, i.e., write A as A = P LU
where for the permutation matrix P , we have P −1 = P T .
As an example, consider matrix A given as
( )
1 2
A= .
3 4
With Python, script factorLU.py uses both the NumPy package (to create an
array) and the LinAlg part of the SciPy package (to do the factorization).
1 import numpy as np
2 import scipy . linalg as sla
3 #
4 A = np . array ([[1 ,2] ,[3 ,4]])
5 lu = sla . lu ( A )
6 P = lu [0]
7 L = lu [1]
8 U = lu [2]
9 print " P : "
52 CHAPTER 3. MODELS AND MODEL SOLUTION†
10 print P
11 print "L:"
12 print L
13 print "U:"
14 print U
leads to the result
dx
= f (x, y, u)
dt
Ax + By = b
dx
= f (x, y, u)
dt
By = b − Ax
3.3.2 Polynomials
Single variable polynomial equations can be written in form
xn + a1 xn−1 + · · · + an−1 x + an = 0.
3.3. ALGEBRAIC EQUATIONS 53
With a ∈ R, it is well known that this equation has n solutions x ∈ C, and that for
n ≤ 4 it is possible to find analytic expressions for the solutions; for n = 2 the two
solutions are √
−a 1 ± a21 − 4a2
x 2 + a1 x + a2 = 0 ⇒ x = .
2
For use of algebraic equations in models, we have to choose which of the n roots
is physically realistic. Usually, we only accept real solutions, commonly we also
need to require that the solution is non-negative. In many cases, this is sufficient to
determine which of the n solutions is acceptable.
Sometimes for low order polynomials (order ≤ 4), it is advantageous to use
formulas for explicit solution of the problem. Alternatively, we may use iterative
techniques, possibly in combination with polynomial division.
Models may also include multivariate polynomials. These are of form, e.g.,
— in the case of two variables (x, y). If we have m equations relating nth-order
polynomials in m variables (x1 , . . . , xm ), it is still possible to find all solutions. In
this case, it is necessary to use more advanced techniques based on the so-called
Gröbner basis, or numerically better methods.
f (x) = 0.
It is considered a good strategy to bracket the solution, e.g., finding (a, b) such that
f (a) and f (b) have opposite signs, e.g., such that f (a) · f (b) < 0. If function
f is continuous in x, this means that ∃x ∈ (a, b) : f (x) = 0. Note that if f (x)
is discontinuous, e.g., by including singularities, bracketing does not guarantee a
known range for the solution.
If we have bracketed the solution, a simple strategy is to use some method of
narrowing down the bracket and refine the possible range of the solution. In bi-
sectioning, we find
a+b
x1 = .
2
Next, x1 → a if signf (x1 ) = signf (a), else x1 → b. The result is an updated bracket
(a, b). Bi-sectioning is repeated either a prespecified number of times n, or until the
bracket is sufficiently small.
or
x = g (x) .
By starting with an initial guess x0 which satisfies a possible bracket, new guesses
are generated successively as
xn = g (xn−1 ) .
Thus, the succession of iterate xn is based on a single past iterate, xn−1 . The problem
with successive substitution is that there is no guarantee that each iteration brings
the iterate xn closer to the true solution. By making k smaller, and/or changing
the sign k, this may improve the chance of finding the solution. At the same time,
a smaller value of k will make the convergence slower.
A special variation of successive substitution is the relaxation method starting
with
g (x) − x = 0 ⇒ k · (g (x) − x) = 0 ⇒ x + k · (g (x) − x) = x.
The iteration procedure is then
xn = xn−1 + k · (g (xn−1 ) − xn−1 ) .
g (x0 ; α) = f (x0 )
g (x1 ; α) = f (x1 ) · exp (α · 2∆x)
g (x2 ; α) = f (x2 ) · exp (α · ∆x) .
Thus
x2 − x0
x3 = x 2 ± √ f (x2 ) .
f 2 (x2 ) − f (x0 ) f (x1 )
The final step in the algorithm is to choose which of the options for x3 should be
chosen. It turns out that if f (x0 ) − f (x1 ) > 0, the choice should be
x2 − x0
x3 = x 2 + √ f (x2 ) ,
f2 (x2 ) − f (x0 ) f (x1 )
while otherwise,
x2 − x0
x3 = x2 − √ f (x2 ) .
f (x2 ) − f (x0 ) f (x1 )
2
Ridder’s method has the property that once it is bracketed, it stays bracketed.
It is therefore both a fast and a reliable method.
f (x) = 0
3
using Taylor series expansion
3.3. ALGEBRAIC EQUATIONS 57
Generally,
f (xn−1 )
xn = xn−1 −
df
.
dx x=xn−1
Newton’s method has very good convergence properties, but may fail to converge,
and requires the computation of the gradient df
dx
.
By comparing Newton’s method to the secant method, we observe that if we
df
approximate dx x=xn−1 as
df f (xn−1 ) − f (xn−2 )
=
dx x=xn−1 xn−1 − xn−2
these are the same. Methods where the gradient is computed by numeric approx-
imation are known as Quasi-Newton methods, and there are a number of them.
Quasi-Newton methods have poorer convergence than the true Newton method, but
may still be chosen if finding an analytic expression for fx = df
dx
is difficult.
h (x, 2∆λ) = 0
dh ∂h ∂x ∂h
= + = 0.
dλ ∂x ∂λ ∂λ
58 CHAPTER 3. MODELS AND MODEL SOLUTION†
Here,
∂h ∂f ∂g
=λ + (1 − λ)
∂x ∂x ∂x
∂h
= f (x) − g (x) .
∂λ
We thus have the initial value problem
∂x f −g
=
∂λ λfx + (1 − λ) gx
with initial condition x (λ = 0) = x0 , and where we seek x (λ = 1).
Example 3.1. Continuation.
Suppose f (x) = x3 + 3x2 + 3x + 1, and g (x) = x − 1. It follows that x0 = 1.
Furthermore,
fx = 3x2 + 6x + 3
gx = 1,
and we have the differential equation
dx x3 + 3x2 + 3x + 1 − (x − 1) x3 + 3x2 + 2x + 2
= = .
dλ λ (3x2 + 6x + 3) + (1 − λ) 1 λ (3x2 + 6x + 3) − λ + 1
This ODE is to be solved with initial value x (λ = 0) = 1, and we seek the solution
x (λ = 1) which is the solution of f (x) = 0. N
It should be noted that homotopy continuation is not guaranteed to work, and if
the original problem f (x) = 0 has several solutions, it is difficult to know in advance
which solution is found by starting at the solution of g (x) = 0. Furthermore, it is
possible that looping through λ in the interval [0, 1] in combination with a standard
method for solving the equation h (x, λn ) = 0 is better than reformulating it into an
initial value ODE.
and choose xn such that g (xn ) = 0. This leads to the multivariable equation
xn = xn−1 + ∆xn
where
∆xn = ω · sN
and
−1
sN = −Jx=x n−1
f (xn−1 )
is the Newton step where ω is a scalar. The Newton step is computed in the
normal way.
This modified Newton method leads to a more reliable algorithm. However, the
modification makes the method more complex, and the unmodified Newton method
should be tested first.
possible to find an analytic solution for the original ODE. It is thus not possible, in
general, to compare the numeric solution to the true solution.
An important parameter in the discretization algorithm is the so-called step
length h of the discretization4 . A common strategy in discretization is thus to tune
the step length such that the computational burden is minimized (= use a large step
length), while simultaneously the error in the simulation is kept under control (=
use a small step length).
For continuous functions f (·), the mean value theorem is valid, hence ∃τ ∈ [t0 , t0 + h]
such that ˆ t0 +h
f (x, u; t) dt = h · f (x (τ ) , u (τ ) ; τ ) .
t0
4
In numerical mathematics, it is common to denote the step length in time by h. In other fields,
it is also common to denote it ∆t.
3.4. ORDINARY DIFFERENTIAL EQUATIONS 61
|1 + hλ| < 1,
3. Points (ℜz (θ) , ℑz (θ)) give the boundary of the stability region where |w| < 1,
but in the z variable; z = hλ.
The stability region for the Explicit Euler method is given in Fig. 3.1.
Figure 3.1 is generated with the Python code in script stabilityExplicitEuler.py
below.
1 """
2 Created on Wed Aug 12 14:18:41 2015
3 The following code is a minor modification of the code in
4 https :// commons . wikimedia . org / wiki / File :
S t a b i l i t y _ r e g i o n _ f o r _ E u l e r _ m e t h o d . svg
5
6 @author : berntl
7 """
8
9 from pylab import linspace , pi , exp , real , imag , axis
10
11 import matplotlib . path as mpath
12 import matplotlib . patches as mpatches
3.4. ORDINARY DIFFERENTIAL EQUATIONS 63
2.0
1.5
1.0
0.5
0.0
− 0.5
− 1.0
− 1.5
− 2.0
−3 −2 −1 0 1 2
Figure 3.1: Stability region for the Explicit Euler method: z , hλ must lie in the
shaded area in order for the discretized system to be stable.
strictly speaking not possible. The common choice is to compute eigenvalues from
the Jacobian of the linearization of the nonlinear system at the current operating
point/solution. However, because the Jacobian will change with time for nonlinear
systems, this is not without problems.
Then we have
x1 − x0 dx
≈ = f (x1 , u1 ; t0 + h)
h dt t=t0 +h
⇓
x1 = x0 + h · f (x1 , u1 ; t0 + h) ,
which generalizes to
xn = xn−1 + h · f (xn , un ; t0 + n · h) .
This is the Implicit Euler method. The reason for the name is that we have an
implicit equation for finding x1 , and need to use iterating numerical methods in
order to find x1 .
Let us analyze the requirements on h for convergence of the Implicit Euler
method. We find
1
xn = xn−1 + h · λxn ⇒ xn = xn−1 .
1−h·λ
Convergence is assured when
( ) ( )
1 1 −1
1 − h · λ < 1 ⇒ 1 − h · λ < 1 ∧ 1 − h · λ < 1 .
We see that the second condition already is fulfilled by the requirement h > 0. The
conclusion is that the Implicit Euler method converges for any positive step length
h, which is a good property. However, convergence does not guarantee similarity to
the analytic solution x (t) = exp (λt) x0 , so in practice h can not be too big. Still,
it is possible to use larger step lengths in the Implicit Euler method than in the
Explicit Euler method and still get acceptable similarity to the analytic solution.
An important disadvantage of the implicit method is that it is necessary to iterate
in order to find xn . It is relatively common to use xn from the Explicit Euler method
as an initial guess for the Implicit Euler method, and then prune this guess by a
number of successive substitutions of the implicit scheme.
In many applications of ODE solvers such as for on-line/real time use, it is
important to known in advance how long time it takes to find the solution. Methods
that involve iterations are problematic from this perspective, and because of this,
explicit methods are normally preferred in on-line applications.
en , xn − x (tn )
when it is assumed that x0 , x (t0 ), i.e., the global error is the accumulation of
propagation error since the start of the simulation.
The order of a discretization method equals its global error. It can be shown
that the global order is one lower than the local error, i.e., if the order of the local
error is 2, then the order of the global error — and of the method — is 1.
Euler methods are based on truncating a Taylor series at the linear term, i.e.,
the local error is of order 2, O (h2 ). Thus the global error and the error of the Euler
methods is of order 1, O (h). This means that if we reduce the step length h to
half the step-length, this error is halved. See, e.g., Ascher & Petzold (1998) for a
relatively simple introduction to these ideas.
One characterization of the Euler methods is that they are one-step methods, i.e.,
xn depends only on xn−1 . It is possible to construct higher order methods which
still are one-step methods. These are known as Runge Kutta methods, and the
Euler methods are then classified as first order Runge Kutta methods. Higher order
methods will converge faster to the correct solution than the Euler methods, and
are thus considered better. On the other hand, the higher order methods are more
complex and more computationally demanding.
66 CHAPTER 3. MODELS AND MODEL SOLUTION†
dx
= f (x, u; t) ,
dt
this implies, e.g., that
k1 = f (xn−1 ; tn−1 )
( )
h h
k2 = f xn−1 + k1 ; tn−1 +
2 2
( )
h h
k3 = f xn−1 + k2 ; tn−1 +
2 2
k4 = f (xn−1 + hk3 ; tn−1 + h) .
y = g̃ (x, u; t) ,
then the DAE can easily be solved using an ODE solver. Using the Explicit Euler
method as an example, the procedure is:
1. Assume that x0 is given, together with u (τ ) for τ ∈ [t0 , t1 ].
3. Compute x1 as
x1 = x0 + h · f (x0 , y0 , u0 ; t0 ) .
4. Compute y1 as g̃ (x1 , u1 ; t1 ).
the number of model evaluations (typically to one) and then compute xn by using
a number of past values, xn−1 , xn−2 , etc. See, e.g., Ascher & Petzold (1998).
It is common to use the difference between the solution from an (m + 1)-th order
method and a method of order m to construct an estimate of the local error. This
enables the choice of step length h such that the local error is kept under control.
Such methods automatically construct a suitable step length for the solution, and
this step length may vary during the simulation. Automatic step length selection
greatly simplifies simulation, in particular if the eigenvalues of the system are un-
known. However, automatic step length selection is a somewhat iterative process,
and reduces the chances of a deterministic computation time5 .
3.5 Interpolation
3.5.1 Overview
Consider dependent variable y which depends on independent variable x, where a
number of points y (x0 ) , y (x1 ) , . . . , y (xn−1 ) with x0 < x1 < · · · < xn−1 are given.
It is of interest to find a function f (x) which passes exactly through these points,
i.e., f (x) such that f (x0 ) = y (x0 ), f (x1 ) = y (x1 ), etc.
If f (x) is used to compute y (x) when x ∈ [x0 , xn−1 ], this is known as interpola-
tion. If f (x) is used to compute a y (x) where x < x0 or x > xn−1 , this is known as
extrapolation.
..
.
θ0 + θ1 xn−1 + θ2 xn−1 + · · · θn−1 xn−1 = yn−1 .
2 n−1
where ϕj (x; c) are known functions, possibly with additional unknown parameters.
Examples of functions ϕj could be
ϕj = xj
( )
(x − cj,1 )
2
ϕj = exp −
c2j,2
0, x < xj
ϕj = 1, x ∈ [xj , xj+1 ] .
0, x > xj+1
The first of these simply leads to a polynomial. The second leads to a linear combi-
nation of various Gaussian Type functions. The third leads to piece-wise constant
behavior.
This parametric function can be fitted to given data (x0 , y0 ) , (x1 , y1 ) , . . . , (xN −1 , yN −1 ).
If the number of equations equals the number of parameters, normally we will be
able to find unique parameter values. The result is an interpolation function. If we
have more equations than the number of parameters, it is necessary to use some
least squares approach in order to find parameters.
As long as ϕj is independent of parameters, we have n parameters θ, and fitting
the model to data is simply a linear problem which can be posed as a matrix equa-
tion. However, if ϕj also
( depends ) on additional parameters c such as in the example
(x−cj,1 )2
above with ϕj = exp − c2j,2
, then model fitting requires solving nonlinear alge-
6
braic equations — unless
( the choice
) is made to fix c and not allow tuning of c. The
2
(x−c )
example with ϕj = exp − c2j,1 is known as radial basis artificial neural net.
j,2
dε
= φ̇i − φ̇e + σ̇. (3.5)
dt
Here, in principle ε, φ̇, σ̇ ∈ Rn , and typically vector ε contains extensive quantities
such as mass, momentum, energy, etc. Furthermore, if the source term is zero,
σ̇ ≡ 0, the balance law is referred to as a conservation law.
Let now extensive quantity ε be distributed in the system volume. Suppose that
ε only varies in the x-direction, and that the value of ε per length unit is ε′ , where
6
Sometimes, reasonably good choices of c can be made based on visual inspection of the data.
3.6. PARTIAL DIFFERENTIAL EQUATIONS* 71
We also introduce
In summary:
d ′ ′
(ε̄ · ∆x) = φ̇x − φ̇x+∆x + σ̇ · ∆x
dt
⇓
′
dε̄ φ̇x − φ̇x+∆x ′
= + σ̇ . (3.11)
dt ∆x
If we relax on the assumption of a fixed position x, and instead consider any
position x, then ε̄′ becomes a function of time and space, ε̄′ (t, x), and then ε =
ε (t, x). We then need to change dε
dt
to ∂ε
∂t
and instead get
′
this PDE can alternatively be written as ∂ε ∂t
+ ∂∂xφ̇ = σ̇ ′ .
As noted, ε (and φ̇ and σ̇) can be vectors of balanced quantities, e.g., it is possible
to let ε be a vector of total mass, number of moles of certain species, momentum,
and energy — all these quantities are described by balance laws. If σ̇ ′ ≡ 0, we will
refer to Eq. 3.12 as a differential conservation law.
In Eqs. 3.5, 3.12, φ̇ is known as the flow function, and often depends on ε′ , φ̇ (ε′ ).
If we take advantage of this, we can write the PDE as
∂ε′ ∂ φ̇ ∂ε′
=− ′ + σ̇ ′ (3.13)
∂t ∂ε ∂x
∂ φ̇
where ∂ε ′ is the Jacobian matrix. This form is known as the quasi-linear form of the
balance law (conservation law when σ̇ ′ ≡ 0). See John (1991) for an introduction to
PDEs and the quasi-linear form.
The best numerical methods for solving the balance law/conservation law are
based on the so-called integral form in Eq. 3.11.
quasi-linear form is
∂ε′ ∂ε′
= −v . (3.14)
∂t ∂x
This equation is known as the advection equation, and Eq. 3.14 simply describes the
transport of some quantity carried with the fluid/material, Fig. XXX (figure w/
v > 0 and v < 0)
If ε′ is the spatial “density” of a species carried with fluid flowing in a pipe at
velocity v, the property of ε′ entering at x = 0 is simply shifted to position x = v · t
at time t. Thus, a property entering the pipe at time t = 0 will leave the pipe
at position x = L at time t = Lv . In other words, the advection equation simply
describes a time delay.
With v > 0, the advection equation describes a species or something flowing
from x = 0 towards increasing values of x. Define ε′0 (t) , ε′ (t, x = 0). It then
follows that ( x)
ε′ (t, x) = ε′0 t − ,
v
where τ = xv is the time delay. At the outlet, x = L, we have
( )
′ ′ L
ε (t, x = L) = ε0 t − .
v
This solution ε′ (t, x) shows that when ε′0 (t) is known at time t, we can compute
ε′ (t, x) for x > 0 at a later time, t + xv > t. In other words, a change in ε′0 (t) causes
an effect at a later time for ε′ (t, x). Thus, we have a causal relationship. However,
if the velocity is negative, v < 0, we see that a change in ε′0 (t) implies that ε′ (t, x)
is known at a prior time t + xv < t. This implies a non-causal relationship — which
is physically impossible. Of course, the solution to this apparent problem is that for
3.6. PARTIAL DIFFERENTIAL EQUATIONS* 73
v < 0, we need to specify ε′ at position x = L. Thus, let ε′L (t) , ε′ (t, x = L). It
then follows that ( x)
ε′ (t, x) = ε′L t + ,
v
and if ε′L (t) is known at time t, we can compute ε′ (t, x) for x > 0 at a later time,
t − xv > t. Thus, with v < 0 and by specifying ε′L (t), we get a causal — hence
physically possible — result.
where
ψ = R−1 ε′ .
We can then write the quasi-linear equation in component form as
∂ψj ∂ψj
= −λj ,
∂t ∂x
where λj ∈ C. If now every eigenvalue is real, ∀j : λj ∈ R, the original conservation
equation is said to be hyperbolic. For simplicity, assume that all eigenvalues differ
from zero, and that we have p positive eigenvalues, denoted λ+j , and (n − p) negative
−
eigenvalues λj . Then we can write the component form as
∂ψj ∂ψj
= −λ+
j
∂t ∂x
and
∂ψj ∂ψj
= + λ−j
.
∂t ∂x
The point here is that in the diagonalized form, the hyperbolic equation has be
decomposed into n advection equations where the eigenvalues (sometimes denoted
characteristic values) represent the speed of transport. Quantities ψj are denoted
characteristic properties. Thus, p characteristic properties are transported towards
increasing x values with velocities λ+j , and (n − p) characteristic
− properties are
transported towards decreasing x values with velocities λj .
The transport of characteristic properties in conservation laws is often inter-
preted as waves moving in either direction, with wave velocity given by the real
eigenvalues λj . For nonlinear models, it is important to realize that the Jacobian
matrix can change over time and space, which also implies that the eigenvalues can
change both in magnitude and direction.
i.e., the limit from below (low value of x), while φ̇+
j± 1
is the limit from above. In
2
physical reality, we must require that φ̇−
j± 21
= φ̇+
j± 12
= φ̇j± 1 — if φ̇−
j± 12
̸= φ̇+
j± 21
, this
2
implies an accumulation of property ε at the cell interface, which is not allowed.
However, numerical methods may use different expressions for φ̇− j± 1
and φ̇+ j± 1
, and
2 2
because of that, there may be transient periods where φ̇− j± 12
̸= φ̇+
j± 21
. Good numerical
methods must, however, minimize this nonphysical situation.
From the interpretation of hyperbolic equations as combinations of advection
equations, it follows that in the simplest case, we can decompose the model into
waves — at least locally and for a short time, moving with velocities given by
the eigenvalues of the Jacobian of the quasi-linear form. Let λmax be the maximal
velocity, λmax = max {|λ1 | , . . . , |λn |}. It follows that when we discretize the ODEs
in time, some care must be shown. Let ∆t be the discretization time, hence the
waves move at most a distance δ = λmax · ∆t. To preserve the physics of the system,
this distance must lie within the neighbor cell, i.e., we must restrict ∆t to satisfy
δ < ∆x, i.e., λmax · ∆t < ∆x. This can be rewritten into
λmax · ∆t
< 1.
∆x
·∆t
Here, NCo = λmax∆x
is known as the Courant number, while the condition NCo < 1
is known as the Courant-Friedrichs-Lewy condition (CFL condition).
The CFL condition is imposed to preserve the physics of the problem: we cannot
discretize the system in such a way that information leapfrogs one cell and thus
jumps from one cell, and “lands” in a cell beyond the neighbor cell. In other words,
if we allow for NCo > 1, the information jumps past the neighbor cell, and the
76 CHAPTER 3. MODELS AND MODEL SOLUTION†
neighbor cell simply doesn’t play a role in the solution — which must be incorrect.
Thus, the CFL condition must be imposed.
Observe that Eq. 3.15 in fact constitutes an approximation of the original PDE
with a large number of ODEs. Thus, in addition to satisfying the CFL condition,
when we discretize these ODEs wrt. time, the discretized problem should preserve
stability — similar to how we analyzed the requirement for stability of the Explicit
Euler method. It turns out that the stability requirement gives a very similar condi-
∆t
tion for ∆x as the CFL condition. One could therefore hope for that Explicit ODE
solvers with adaptive time step algorithms will ensure that the CFL condition is pre-
served. However, implicit solvers may break the CFL condition. Thus, if implicit
solvers are chosen, it is necessary to restrict the length of the time step.
The discretized model consists of a number of ODEs with the average density ε̄′
as the state. However, the model does at the outset not contain information about
the actual shape of ε′ (x) within each grid cell. Because values for φ̇j− 1 and φ̇j+ 1
2 2
depend on the actual value of ε′ at the interfaces, it is important to have a relatively
good estimate of ε′ (x) in the various grid cells. A key method for discretization is
the Godunov REA method. REA is an abbreviation for the three steps Reconstruct,
Evolve, and Average of Godunov’s method.
1. Reconstruct: Based on known average values ε̄′j for the various cells, propose
a variation ε̃′ (x) to approximate the true variation ε′ (x) within each cell, and
reconstruct ε′ (x) by estimating ε̃′ (x) based on average values in the cells.
One possibility is to propose that ε̃′ (x) is piece-wise constant, which makes
ε̃′ (x) = ε̄′j within cell j; this leads to first order accuracy in the solution.
Another possibility is to propose that ε̃′ (x) varies linearly with x; this leads
to second order accuracy in the solution.
3. Average: From the evolved function ε̃′ (t + ∆t, x), find the cell average
ˆ x 1
1 j+ 2
ε̃′ (t + ∆t, x) dx
∆x x 1
j− 2
Both the reconstruction and the evolution steps are key for finding a good quality
numeric solution. The reconstruction step finds good expressions for ε̃′j (x) in various
cells. In the evolution step, these functions ε̃′j (x) are used for computing φ̇+
j− 1
and
2
φ̇−
j+ 1
, which are key for updating ε̃′ (t, x) to ε̃′ (t + ∆t, x). Good expressions for
2
φ̇+
j− 12
and φ̇− j+ 12
must both utilize the physical information flow, i.e., use information
about flow direction for waves, as well as limit the maximal flow in case of numerical
singularities, etc. Many problems also require that some elements of ε′ stay positive,
e.g., if ε′ is a mass density, it is required that ε′ stays positive. Some numeric schemes
are specially designed to also ensure this positivity requirement. See, e.g., LeVeque
(2002) for details.
3.7. SIMULATION TOOLS 77
x = 1
implies to put the numeric value 1 into a memory cell which we choose to denote by
x. Similarly, the statement
x = x + 1
implies to pull out the content of memory cell x and add the value 1 to the value
pulled out from x, before the sum is re-inserted into memory cell x. A more precise
notation could be:
x <- x + 1
but the normal syntax is x = x + 1. Some languages use the alternative notation
x := x + 1 for assignment.
The idea of assignment has some consequences. In the examples above, the
assignment
x = x + 1
works because x already has been given a value before — by the statement x = 1.
Suppose next that we write
y = y + 2
This statement will not work. Why? Let us consider what it means: on the right
hand side, y + 2 means “pull out the value from memory cell y and add 2 to the
value that was previously stored in y. Then the result is to be re-inserted into
memory cell y. But this time, we have not defined any previous value stored in
memory cell y; because of this the command y = y + 2 will not work, and will
instead lead to an error message.
78 CHAPTER 3. MODELS AND MODEL SOLUTION†
x = y + 1
y = 2
we will get an error message: the right hand side of the first assignment is interpreted
as “take out the value stored in memory cell y, and add 1 to its value, then store
the result in memory cell x”. Again, this can not work, because there is no content
in memory cell y.
However, if we rewrite the order of the assignments into
y = 2
x = y + 1
then the assignments make sense, and give the expected result: y = 2, x = y +1 = 3.
We see that for equations, the order of equations is not important, but for
assignments, the order is extremely important.
Finally, consider the equations
x + 2y = 3
x − y = 4.
These are valid equations. However, for assignments, these won’t work:
x + 2* y = 3
x - y = 4
is meaningless because the left hand side is the name of the memory cells where we
store the result, and x + 2*y and x-y are illegal names for memory cells. What if
we write the assignments as
x = -2* y + 3
x = y + 4
Still, we have problems: the equations depend on each other, and the assignment
procedure is not able to “decouple” the equations. That is one reason why, e.g.,
matrix factorization is important. The above problem can be written in matrix
form as ( )( ) ( )
1 2 x 3
= .
1 −1 y 4
| {z }| {z } | {z }
A z b
Here, matrix A can be LU-factored into
( ) ( )( )
1 2 1 0 1 2
A= = ,
1 −1 1 1 0 −3
| {z }| {z }
L U
3.7. SIMULATION TOOLS 79
thus leading to
U z = b ⇒ Lζ = b.
L|{z}
ζ
u=3
u + v = 4,
leading to assignments:
u = 3
v = -u + 4
gives (u, v) = (3, 1). Next, U z = ζ can be written as
x + 2y = u
−3y = v,
with assignments:
y = v /( -3)
x = -2* y + u
Thus y = 1/ (−3) = − 31 , and x = 23 + 3 = 11
3
.
In general, we thus see that implementing models using assignment requires a
careful re-ordering of equations where we put single unknowns on the left side of
the equations for easy conversion to assignments. Furthermore, we see that some
pre-manipulation of equations (e.g., matrix factorization) may be required before
assignment can be done.
dcA V̇
= (cA,i − cA ) − r
dt V
dcB V̇
= − cB + r
dt V
r = kc2A
T 7
compute the unknowns cA (t) and cB (t) in N points with step length ∆t = N . This
also means that we need to know the input signal cA,i (t) in these N points. The
following pseudo code will enable us to find cA (t) and cB (t):
This freedom of implementing equations as they appear, greatly eases the model im-
plementation part, especially if we connect several models, introduce re-circulation,
etc.: we can do this without too much reorganization of the model. In assignment
implementations, however, introducing model connections, re-circulation, etc. often
requires a total rewrite of the equations.
Solving models in computers eventually requires a reformulation to assignment
form. In equation based modeling languages, this conversion to a form suitable for
assignment is done automatically by the tool. Thus, in a language such as Modelica,
running simulation starts a process where the model is analyzed, equation order is
reorganized, etc., and eventually the model is converted to assignments — typically
in the language C. Then the generated C file is compiled into executable code, the
model is simulated, and the results are produced. The key issue here is that the user
does not have to become involved in this reorganization of the model into a form
that can be stated as assignments. Of course, if the user chooses to do so, he/she can
help in the conversion to assignment form by writing parts of the model in a form
where there is a single unknown on the left side of the equation. However, chances
are that a systematic algorithm for such rewriting is more efficient and makes fewer
errors than a human being.
3.8 Review
We have seen how problems and techniques from scientific computing are needed in
solving dynamic models. In particular, what types of models/equations are relevant
in systems modeling? What are the basic properties and solution methods for alge-
braic equations and differential equations? How is interpolation useful in modeling
and simulation? The discussion leads naturally to a discussion of ideas behind two
classes of simulation tools, traditional tools (e.g., MATLAB) based on assignments,
and equation based languages, with a brief introduction to their relative advantages
and disadvantages.
The topics of this chapter are not directly part of the topic of how to develop
models, instead they are meant to motivate an interest in a deeper study within a
course in scientific computing.
3.9 Exercises
First some exercises to brush up abilities in differentiation, see Appendix B for a
reminder.
Exercise 3.1. Find the derivatives dy/dx, d2 y/dx2 , and d3 y/dx3 when y (x) is given
as follows:
• y = x3 .
• y = x−1 .
• y = x0.7 .
√
• y = x.
• y = exp (k/x).
• y = sin x. N
• z = (dy/dx).
• z = (dy/dx)2 .
3.9. EXERCISES 83
√
• z = 1 − (dy/dx)2 .
( )
• z = 1/ 1 − (dy/dx)2 .
• z = (y · dy/dx). N
Exercise 3.3. Find the partial derivatives ∂z/∂x, ∂z/∂y, ∂ 2 z/∂x2 , ∂ 2 z/∂y 2 and
∂ 2 z/∂x∂y when z (x, y) is given as follows:
• z = sin x cos y.
• z = (2x2 + y 2 ) sin x.
• z = ln (x + exp y). N
• z = y 2 , y = sin x.
• z = (x + y)2 , y = sin x.
Exercise 3.5. Let mass m = ρV where density ρ and volume V both vary with
time t.
r = kc2A ,
( E)
where k = k0 exp − RT and concentration cA and temperature T varies with time,
while k0 , E, and R are constants.
• Find dr/dt. N
84 CHAPTER 3. MODELS AND MODEL SOLUTION†
H̃ (T ) = H̃ ig (T ) + (z − 1) RT
where
pṼ
z, ,
RT
and where also
Ṽ a Ṽ
z= − .
Ṽ − b Ṽ 2 RT
(Here, H̃ ig is the molar enthalpy of ideal gas, but it is not necessary to know this to
solve the problem.)
• Find an expression for c̃p (specific heat capacity at constant pressure) given
as
∂ H̃
c̃p = .
∂T
p
• Find an expression for c̃v (specific heat capacity at constant volume) given as
∂ Ũ
c̃v = ,
∂T
Ṽ
• y = x3 .
• y = x−1 .
• y = x0.7 .
√
• y = x.
• y = exp (k/x).
• y = sin x. N
´1
Exercise 3.10. With y (x) given as below, what is 0
y (x) dx — if it exists?
• y = x3 .
• y = x−1 .
• y = x0.7 .
√
• y = x.
3.10. PROBLEMS* 85
• y = exp (k/x).
• y = sin x. N
Exercise 3.11. With force F , find the corresponding potential energy P (hint:
F = −dP/dx):
• F = −mg.
• F = −k (x − x0 ). N
• What are the integration boundaries for the left hand side integral? N
c̃ig 2 3
p (T ) = c0 + c1 T + c2 T + c3 T :
• Find H̃ ig (T ).
To be developed.
• integration w/ interpolation
3.10 Problems*
To be developed
86 CHAPTER 3. MODELS AND MODEL SOLUTION†
Chapter 4
Mass conservation
• What extensive and intensive quantities are relevant for mass conservation?
• What is the meaning of ideal gas? How can the case of non-ideal gases be
handled?
• How can mass conservation be used to find liquid level in tanks and gas pres-
sure in closed volumes?
87
88 CHAPTER 4. MASS CONSERVATION
from the system and into the environment. To simplify the notation, we often write
the flows as ṁi and ṁe .
In classical physics we neglect any possibility of conversion between mass and
energy, and mass is conserved:
ˆ t+∆t
m (t + ∆t) − m (t) = [ṁi (τ ) − ṁe (τ )] dτ . (4.1)
t
If we assume that the mass flows ṁ (t) vary continuously with time t, it follows from
the mean value theorem of integration that there exists a time θ ∈ [t, t + ∆t] such
that ˆ t+∆t
[ṁi (τ ) − ṁe (τ )] dτ = [ṁi (θ) − ṁe (θ)] ∆t.
t
m (t + ∆t) − m (t)
= ṁi (θ) − ṁe (θ)
∆t
and as ∆t → 0, we have
d
m (t) = ṁi (t) − ṁe (t)
dt
or simply
dm
= ṁi − ṁe . (4.2)
dt
Here, it is emphasized that ṁ has the meaning of (instantaneous) flow of mass
per time unit across a system boundary, while dm dt
has the meaning of change of
accumulated mass per time unit within the system boundary. Make no mistake: ṁ
is not the same as dm
dt
; they represent different physical phenomena.5
where Ṅj typically will have to be some discontinuous function in time to ensure
that N remains an integer. Observe that in the number balance, we in general need
Note: ṁ and dm
5
dt are different in these notes because of our choice of notation. Other literature
may choose to use ṁ interchangeably with dm dt (e.g., control engineering literature), but this can
not be done if symbol ṁ is used to denote mass flow rate.
4.4. EXTENSIVE VS. INTENSIVE VARIABLES 89
where ṅj strictly speaking will have to be some discontinuous function in time to
ensure that n remains a rational number. Since rational numbers are not differ-
entiable, it is strictly speaking not possible to formulate differential equations for
mole numbers. However, because NA is such a large number, the number of moles
n will thus often appear as a quasi real number. In practice, it is therefore a good
approximation to assume that a differential form of the mole balance exists:
dn
= ṅi − ṅe + ṅg . (4.5)
dt
If each particle has the same mass, we can define the molar mass (mass per mole)
M as
m
M, ⇔ m = nM .
n
In the case of each particle being identical, it is not possible to include a generation
term, and ṅg ≡ 0.7 Under this assumption, the (total) mass balance and the (total)
mole balance are equivalent. Similarly, we could have introduced a molecular mass
of each particle, but this will simply be NMA .
Relevant extensive quantities for the material balances (mass, particle, mole) are
the conserved quantities mass m, number of particles N , and number of moles n.
Extensive variables related to the extent of the system are volume V , surface area
S, and length L. We can talk about the flow of extensive variables across system
boundaries. Thus, for extensive variable x, we let ẋ denote the flow of that extensive
variable across the boundary, e.g., ṁ and V̇ .
An intensive variable or quantity has a value which is invariant wrt. the size
or extent of the system. Typical intensive quantities relevant for the material bal-
ances are conserved quantities per system extension, e.g., mass per volume (density),
number of moles per surface area, number of particles per length unit, etc.
In general, intensive quantities will vary with the position within the system
(volume, area, length). If the intensive quantity happens to have the same value
everywhere within the system volume, we say that the system is homogeneous 10 in
that quantity. It follows that for system homogeneous in the density,
m
ρ= ⇔ m = ρV .
V
We could alternatively have used the more generic symbol m′′′ for density. Similarly,
a system which is homogeneous in the surface density or length density, satisfy
m
m′′ = ⇔ m = m′′ A
A
′ m
m = ⇔ m = m′ L.
L
Considering the number of moles, for homogeneous intensive variables, we have
n
n′′′ = ⇔ n = n′′′ V
V
n
n′′ = ⇔ n = n′′ A
A
n
n = ⇔ n = n′ L.
′
L
It is relatively common to use symbol c to denote concentration, or number of moles
per volume: c = n′′′ = Vn . Because symbol c has many uses in physics, and due to
the similarity between m′′′ and n′′′ , we could alternatively consider using symbol ρ
in both cases, and use, e.g., decoration ˆ· to imply mass basis and decoration ˜· to
imply mole basis. Thus we will let ρ̂ = m′′′ and ρ̃ = n′′′ .
Inversely, we could also define the intensive quantities specific volume V̂ as vol-
ume per mass, and molar volume Ṽ as volume per mole. In a homogeneous system,
V 1
V̂ , = ,
m ρ̂
V 1
Ṽ = = .
n ρ̃
10
Homogeneous = composed of parts or elements that are all of the same kind, having a
common property throughout
4.5. EQUATIONS OF STATE 91
absolute temperature T as
pV = nRT (4.6)
where R is the ideal gas constant. This Equation of State (EoS) can alternatively
be written as
V
pV = nRT ⇔ p = RT ⇔ pṼ = RT
n
where Ṽ = 1/ρ̃. If we introduce m = nM , it follows that we alternatively can write
the ideal gas law as
m RT
pV = RT ⇔ pV̂ =
M M
where V̂ = 1/ρ̂. Because we, e.g., can write ṅ as
ṅ = ρ̃V̇ ,
pV pṼ
z, = , (4.7)
nRT RT
we see that the ideal gas law can be expressed as
z = 1.
van der Waals proposed that the pressure as observed on the boundary is reduced
inversely proportional to Ṽ 2 .
Van der Waals’ final gas model was thus
( )
RT a a ( )
p= − ⇔ p+ Ṽ − b = RT (4.8)
Ṽ − b Ṽ 2 Ṽ 2
where the attractive “force” a ≥ 0 has unit pressure divided by the square of molar
volume, and covolume b ≥ 0 has unit molar volume. The van der Waals EoS is
explicit in pressure p, but implicit in molar volume Ṽ . By multiplying with Ṽ 2 and
rearranging the van der Waals EoS, we find
( )
RT
Ṽ −
3
+ b Ṽ 2 + aṼ − ab = 0,
p
which is cubic in Ṽ .
By introducing z , ⇒ Ṽ = z RT
pṼ
RT p
, the van der Waals EOS can be rewritten as
( )
a RT
RT = p + ( )2 z −b
RT p
z p
⇓
( )
pb pa p2 ab
0=z −z 1+3 2
+ z 2 2 − 3 3,
RT R T R T
and we see that this is a cubic equation in z when p and T are known.
pṼ
or z = RT
leading to
Ṽ a (T ) Ṽ
z= −( )( ) , (4.9)
Ṽ − b Ṽ + εb Ṽ + σb RT
By applying the inflection conditions Eqs. 4.10–4.11 on the general cubic EOS in
Eq. 4.9, we find that a and b must be given as
Ωa R2 Tc2 Ωa pc Ṽc2
a (T ) = α (Tr ; ω) = α (Tr ; ω) (4.12)
pc zc2
Ωb RTc Ωb Ṽc
b= = ; (4.13)
pc zc
T
Tr , , (4.14)
Tc
1
psat
r
= .
Tr =0.7 10ω+1
4.5. EQUATIONS OF STATE 95
van der Waals: The van der Waals Equation of State (vdW, 1873) is given by
α (Tr ; ω) = 1
ε=0
σ=0
27
Ωa = ≈ 0.421 88
64
1
Ωb = ≈ 0.125 .
8
Thus,
Ṽ a Ṽ
z= − .
Ṽ − b Ṽ 2 RT
Redlich-Kwong: The Redlich-Kwong Equation of State (RK, 1949) is given by
1
α (Tr ; ω) = √
Tr
ε=0
σ=1
Ωa = 0.42748
Ωb = 0.08662.
Thus,
Ṽ a (T ) Ṽ
z= − ( ) ,
Ṽ − b Ṽ Ṽ + b RT
where the essential new contribution is the introduction of the α function and
a modification of the attractive force by letting σ ̸= 0.
Thus,
Ṽ a (T ) Ṽ
z= − ( ) .
Ṽ − b Ṽ Ṽ + b RT
Thus,
Ṽ a (T ) Ṽ
z= − ( ) ( ) .
Ṽ − b Ṽ Ṽ + b + b Ṽ − b RT
where κ0 and κ1 are as above, and additional parameters κ2 and κ3 are species
specific parameters. PRSV2 is sufficiently accurate for Vapor-Liquid Equilib-
rium calculations.
Examples of selected pure species data for use in cubic equations of state are given
in Table C.1 of Appendix C.1.
⇓
Ṽ a (T ) Ṽ
z= − ,
Ṽ − b Ṽ 2 + (b + c) Ṽ − bc RT
where requiring that the critical point is an inflection point leads to
Ωa pc Ṽc2
a (T ) = · α (Tr )
zc2
Ωb Ṽc
b=
zc
Ωc Ṽc
c= .
zc
In the Patel-Teja EoS, parameters Ωa , Ωb and Ωc are given by
Ωc = 1 − 3ẑc
0 = Ω3b + (2 − 3ẑc ) Ω2b + 3ẑc2 Ωb − ẑc3
Ωa = 3ẑc2 + 3 (1 − 2ẑc ) Ωb + Ω2b + 1 − 3ẑc
where Ωb is the smallest, positive (real) root of its cubic equation, while ẑc is some
estimate of the compressibility factor, i.e., it is possible that ẑc ̸= zc = pRT
c Ṽc
c
.
14
Still, the minimum point for Soave’s α function is well above the critical point, i.e., at Tr =
( )2
1 + κ1S , so for most applications, this is not a problem.
98 CHAPTER 4. MASS CONSERVATION
One possible α function for the Patel-Teja EoS is the Heyen function,
( ( ))
α (Tr ) = exp H1 1 − TrH2
ẑc = 0.2710
H1 = 0.9472
H2 = 0.7262.
In some works, the parameters of polar fluids have been correlated to the combi-
nation of acentric factor ω and the relative dipole moment µr , which can be expressed
as ( )2
µ
0 µ0
µr = µr
Tc
· Ṽc
Tc0 Ṽc0
where µ is the dipole moment, and superscript 0 indicates some reference substance.
If water is used as reference substance so that 0 is w, then µw r = 0.39025. See,
e.g., Poling et al. (2001) for a definition of µr , and for tabular values for µ for some
substances.
where
m = ρV
ṁe = ρV̇e .
For liquids or solids, we often have the additional assumption that ρ is fixed wrt.
time, and we get
d
(ρV ) = ṁi − ρV̇e
dt
⇓
dV ṁi
= − V̇e .
dt ρ
Here, ṁi = ρi V̇i , so we can also write this as
dV ρi
= V̇i − V̇e .
dt ρ
If we in addition assume that ρi = ρ, this simplifies to the “volume balance”:
dV
= V̇i − V̇e .
dt
Here we should observe that the fundamental law of mass conservation or mass
balance is expressed by dm
dt
= ṁi − ṁe , and that the “volume balance” follows from
the total mass balance by introducing two additional simplifying assumptions wrt.
the density. Thus “volume balance” is not a fundamental law of physics; volume is
not conserved, and it is recommended to always start with the total mass balance
which is a fundamental law.
For gas, we often have that the volume V is constant. It follows that the mass
balance gives
d
(ρV ) = ṁi − ρV̇e
dt
⇓
dρ ṁi V̇e
= − ρ.
dt V V
The homogeneous system assumption has wide-reaching consequences, and is a
key assumption in developing models and stable numerical schemes for solving such
models. Sometimes the homogeneity assumption is denoted the stirred volume (or:
stirred tank) assumption due to the fact that in industry it is common to introduce
impellers and/or baffles to force the operation of equipment to more closely satisfy
the homogeneous system assumption.
flow Ė as given by
Ė = K̇ + Ṗ + pV̇ (4.16)
is constant for a give streamline. Here, the kinetic energy flow K̇ is given by
1
K̇ = ṁv 2 , (4.17)
2
where ṁ is mass flow rate and v is linear velocity, the potential energy flow Ṗ is
given by
Ṗ = ṁgz, (4.18)
where g is acceleration by gravity and z is the vertical position, while pV̇ expresses
the pressure-volume energy flow where p is pressure and V̇ is volumetric flow rate.
With flow through a valve, the level difference is negligible, z1 ≈ z2 , hence
Bernoulli’s law leads to
Ėk,1 + p1 V̇1 ≈ Ėk,2 + p2 V̇2 . (4.19)
Because of constant density ρ, ṁ1 = ṁ2 = ṁ and V̇1 = V̇2 = V̇ . Furthermore,
velocity v = V̇A = ρA
ṁ
. It follows that
1 2 1
ṁv1 + p1 V̇ = ṁv22 + p2 V̇
2 2
⇓
( )2 ( )2
1 ṁ ṁ 1 ṁ ṁ
ṁ + p1 = ṁ + p2
2 ρA1 ρ 2 ρA2 ρ
This expression can be reorganized into
p1 − p2
ṁ2 = A21 A22 2ρ. (4.20)
A21 − A22
Assuming that A1 > A2 , it follows that ∆p , p1 − p2 > 0. We then have
√
2ρ · ∆p
ṁ = A1 A2 . (4.21)
A21 − A22
Consider the liquid tank in Fig. 4.2, with cross sectional area A, and effluent
mass flow rate ṁ through an exit valve pipe with cross sectional area Av .
The indicated streamlines cover area A1 ≤ A at the inlet to the valve opening;
the distance between A1 and the tank bottom is exaggerated in Fig. 4.2 — this
distance is negligible. Similarly, the indicated streamlines cover area A2 ≥ Av at
the outlet from the valve pipe. For this tank, pressure p1 = pς + ρgh, while pressure
p2 = pς . Thus
∆p = ρgh. (4.22)
Bernoulli’s law thus reduces to
√
hς 2ρ · ρgh
ṁ = A1 A2
hς A21 − A22
⇓
√ √
A1 A2 2ghς h
ṁ = ρ √ 2 (4.23)
A1 − A22 hς
4.8. CASES: LIQUID LEVEL IN TANKS 101
Streamlines:
Figure 4.2: Flow through effluent valve by gravity. Indicated streamlines suggest
that the streamline area A1 at inlet to contraction is smaller than the tank cross
sectional area A, A1 < A, while streamline area A2 at outlet from contraction is
slightly larger than the exit pipe cross sectional area Av . The distance between area
A1 and tank bottom is exaggerated; this distance is negligible.
Figure 4.3: Autonomous liquid tank, with externally available quantities framed
in red: initial mass is emptied through bottom at rate ṁe , leading to a gradual
reduction in level h.
Figure 4.4: Functional diagram of tank with effluent flow, but no influent flow.
steps. The reason is that the detailed steps in the model development often indi-
cate which assumptions are necessary. With more experience in model development,
some assumptions may be introduced prior to the model development.
Consider the tank in Fig. 4.3 filled with liquid. Liquid is emptied by gravity through
a hole in the bottom at rate ṁe .16 No liquid is entered from the surroundings, thus
ṁi = 0.
We are interested in finding how the level h varies with time. The model objective
is illustrated by the functional diagram in Fig. 4.4.
The functional diagram depicts the causality of the system (“Tank with effluent
mass flow”), where inputs (green arrow) cause a change in the system and is observed
at outputs (orange arrow). Here, there is no input variable17 , while the output
variable is the quantity we are interested in, h.
16
This is similar to pulling the plug in a water tub; Bernoulli’s law as in Eq. 4.24 commonly
used.
17
The effluent flow ṁe is defined by gravity, i.e., is a function of the system state. Input variables
are determined by the environment, hence ṁe is not an input variable.
4.8. CASES: LIQUID LEVEL IN TANKS 103
Step 2: We need to relate the mass m to the level h, as well as find expressions for
mass flows ṁ. We have
m = ρV
V = Ah
ṁi ≡ 0.
√ driving force for flow through valves is the pressure drop ∆p, here ṁe ∝
18
The
∆p In this particular case, ∆p = ρgh. Because ρ and g are constants, we
combine them into a new constant and write the expression as
√ √
√ √ h h
ṁe = K̄ h = K̄ hς ς
=K .
h hς
Step 4: Finally, we relate the sought output to the model. Thus, if the state is the
level h, the output is directly equal to the level. However, here (step 2), the
state is m, and the output h is given as
m
h= .
ρA
In this model, there is no flow of information from the surroundings and into V .
The model is self sufficient in the sense that the water flow ṁe is described by a
quantity of the volume itself: h.
18
We’ll get back to this in the discussion of the energy balance.
104 CHAPTER 4. MASS CONSERVATION
Table 4.1: Parameters for autonomous tank with constant cross sectional area.
Parameter Value Unit Comment
ρ 1 kg/L Density of liquid
A 5 dm2 Constant cross sectional area
K 5 kg/s Valve constant
hς 3 dm Level scaling
Table 4.2: Operating condition for autonomous tank with constant cross sectional
area.
Quantity Value Unit Comment
h (0) 1.5 dm Initial level
m (0) ρh (0) A kg Initial mass (alternative initial condition)
1 package AutoTank
2 // Package for simulating autonomous tank
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // May 11 , 2017
6 //
7 model SimAutoTank
8 // Main Auto Tank model
9 // author : Bernt Lie
10 // University of South - Eastern Norway
11 // May 11 , 2017
12 //
13 // Parameters
4.8. CASES: LIQUID LEVEL IN TANKS 105
0.6
0.4
0.2
0.0
0 1 2 3 4 5
time t [s]
Figure 4.5: Level h in autonomous tank; time in seconds along the abscissa.
44 // Differential equations
45 der ( m ) = - md_e ;
46 // Outputs
47 _h = h ;
48 end SimAutoTank ;
49 // End package
50 end AutoTank ;
0.6
0.4
0.2
0.0
0 1 2 3 4 5
time t [s]
Figure 4.6: Level h in autonomous tank; time in seconds along the abscissa.
dm
= −ṁe
dt
m = ρV
V = Ah
√
h
ṁe = K .
hς
m = ρV = ρAh.
108 CHAPTER 4. MASS CONSERVATION
Inserting this expression for m and the expression for ṁe into the mass balance leads
to
√
d h
(ρAh) = −K
dt hς
⇓
√
dh h
ρA = −K
dt hς
⇓
dh K √ √
=− √ h = −k h
dt ρA hς
where
K
k= √ .
ρA hς
This differential equation can be solved analytically by the method of separation
of variables:
dh √
= −k h
dt
⇓
dh
√ = −kdt
h
⇓
ˆ h(t) ˆ t
dh
√ =− kdt.
h(0) h 0
Since ˆ √
dh
√ = 2 h + constant,
h
we find that
ˆ h(t) ˆ t
dh
√ =− kdt
h(0) h 0
⇓
[ √ ]h(t)
2 h = −kt
h(0)
⇓
√ √
2 h (t) − 2 h (0) = −kt
⇓
(√ )2
h (t) = h (0) − kt .
This example is one of a few cases in these notes where it is possible to find an
analytic solution. In general, it is necessary to solve the models numerically, and
numerical solution using OpenModelica will be the norm in the examples.
4.8. CASES: LIQUID LEVEL IN TANKS 109
Figure 4.7: Driven water tank, with externally available quantities framed in red:
initial mass is emptied through bottom at rate ṁe , while at the same time water
enters the tank at rate ṁi .
Figure 4.8: Functional diagram of tank with influent and effluent flow.
Let us next consider an example with information exchange with the surroundings.
Consider the tank in Fig. 4.7 filled with water.
Water with initial mass is emptied by gravity through a hole in the bottom at
effluent mass flow rate ṁe , while at the same time water is filled into the tank at
influent mass flow rate ṁi .
Our modeling objective is to find the liquid level h. The model objective is
illustrated by the functional diagram in Fig. 4.8.
The functional diagram depicts the causality of the system (“Tank with influent
and effluent mass flow”), where inputs (green arrow) cause a change in the system
and is observed at outputs (orange arrow). Here, the input variable is the influent
mass flow rate ṁi , while the output variable is the quantity we are interested in, h.
110 CHAPTER 4. MASS CONSERVATION
We assume that the system is homogeneous in the liquid density ρ, and that the
tank has constant cross sectional area A. The four steps in the model development
are given below.
Step 1: To find liquid level in a volume, we start with the total mass balance
dm
= ṁi − ṁe .
dt
Step 2: We need to relate the mass m to the level h, as well as find expressions for
mass flows ṁ. Similar to the previous example, we have
m = ρV
V = Ah
√
h
ṁe = K
hς
Step 3: Because we will use an equation based simulation tool (Modelica), it is not
necessary to further manipulate the model. If we instead use an ODE solver
(e.g., MATLAB), we would normally introduce the sought quantity h as the
state, i.e.,
dm d
= (ρAh) = ṁi − ṁe
dt dt
⇓
dh ṁi − ṁe
= .
dt ρA
The reason for using the sought quantity h as state, is that ODE solver only
compute the state.
If we had used m as state in the ODE solver, we would thus find m (t) instead
of h (t) and would need to introduce a post processing in order to find the
sought level h.
In this example, information from the surroundings in the form of ṁi is part of the
model: this model is not self sufficient in the sense that ṁi can not be determined
by information inside of the system volume (= liquid tank).
4.8. CASES: LIQUID LEVEL IN TANKS 111
Table 4.3: Parameters for driven tank with constant cross sectional area.
Parameter Value Unit Comment
ρ 1 kg/L Density of liquid
A 5 dm2 Constant cross sectional area
K 5 kg/s Valve constant
hς 3 dm Level scaling
Table 4.4: Operating condition for driven tank with constant cross sectional area.
Quantity Value Unit Comment
h (0) 1.5 dm Initial level
m (0) ρh (0) A kg Initial mass (alternative initial condition)
ṁi 2 kg/s Nominal influent mass flow rate; may be varied
1 package DrivenTank
2 // Package for simulating driven tank
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // August 26 , 2015
6 // May 11 , 2017
112 CHAPTER 4. MASS CONSERVATION
Figure 4.9: Level h in driven tank, i.e., with influent mass flow rate ṁe . The plot
shows the level h with operational conditions as given in Table 4.4 (red), but also
the level h (blue) when starting in steady state conditions with a step change in the
input ṁi (green).
7 //
8 model SimDrivenTank
9 // Simulation of Driven Tank model
10 // author : Bernt Lie
11 // University of South - Eastern Norway
12 // August 26 , 2015
13 // May 11 , 2017
14 //
15 // Instantiate model of * driven tank * ( dt )
16 ModDrivenTank dt ;
17 // Declaring variables
18 // -- inputs
19 Real md_i " Mass flow into tank ";
20 // -- outputs
21 Real _h " Level in tank ";
22 // Equations
23 equation
24 // -- input
25 md_i = 2;
26 dt . md_i = md_i ;
27 // -- output
28 _h = dt . h ;
29 end SimDrivenTank ;
30 //
31 model SimStepDrivenT ank
32 // Simulation of Driven Tank model with step input
33 // author : Bernt Lie
4.8. CASES: LIQUID LEVEL IN TANKS 113
83 equation
84 // Algebraic equations
85 m = rho * V ;
86 V = A*h;
87 md_e = K * sqrt ( h / h_s ) ;
88 // Differential equations
89 der ( m ) = md_i - md_e ;
90 end ModDrivenTank ;
91 // End package
92 end DrivenTank ;
The Modelica code illustrates how the two simulations use a common, under-
lying model, given in model ModDrivenTank, with a defined input signal md_i.
The two simulations are then defined by two “main models”, SimDrivenTank and
SimStepDrivenTank. These two main models inherit 19 the common, underlying
driven tank model (dt), and add a definition of the input signal ṁi (md_i, which is
different in the two cases), define the output h (_h), and connect the defined input
signal (md_i) to the input signal in the underlying code (dt.md_i; the connection is
done by equating dt.md_i = md_i). The “main model” which starts in steady state,
has an added initial equation section, where dm dt
= 0 at time t = 0; der(dt.m)
= 0.
Observe that in the common, underlying model ModDrivenTank, we have used
the simplistic expression for the effluent flow, md_e = K*sqrt(h/h_o), instead of
the more robust expression discussed in Section 4.8.1. The reason is that in this
example, the level stays positive, and there is no chance of taking the square root
of a negative number.
Figure 4.10: Driven water tank: initial mass is emptied through bottom of funnel
shaped tank at effluent rate ṁe , while at the same time the influent water rate ṁi .
Figure 4.11: Functional diagram of tank with varying area and with influent and
effluent flow.
116 CHAPTER 4. MASS CONSERVATION
below.
m = ρV.
Next, we need to relate the level h to the mass. For a funnel, the cross sectional
area A varies with the level, A (h). Because of this, V ̸= Ah. Instead, we have
dV = A (h) dh where
A = πr2 .
We need to relate r to h. From simple geometry, we see that
r Rς Rς
= ς ⇒ r = ς h.
h h h
Step 3: In this case, we need to carry out a minor manipulation of the model. With
constant density and m = ρV , we find that dm = ρdV = ρAdh. We thus get
dh
ρA = ṁi − ṁe .
dt
We could also have used the mass m as state, but then we would need to find
V by solving the integral
ˆ h ˆ h ˆ h ( ς )2 ( )2
2 R π Rς
V = A (h) dh = πr dh = π ς
h dh = ς
h3 ,
0 0 0 h 3 h
Finally, we can insert this relationship between h and m into the expression
for ṁe . Overall, it is probably more convenient to use the level as state.
Table 4.5: Parameters for driven funnel shaped tank with constant cross sectional
area.
Parameter Value Unit Comment
ρ 1
√ kg/L Density of liquid
15
Rς π
dm Chosen to give the same maximal volume as other tanks
hς 3 dm Level scaling
K 5 kg/s Valve constant
Table 4.6: Operating condition for driven funnel shaped tank with constant cross
sectional area.
Quantity Value Unit Comment
h (0) 1.5 dm Initial level
ṁi 2 kg/s Nominal influent mass flow rate; may be varied
1 package DrivenFunnelTank
2 // Package for simulating driven tank
3 // author : Bernt Lie
4 // University of South - Eastern Norway
118 CHAPTER 4. MASS CONSERVATION
Figure 4.12: Level h in funnel shaped driven tank, with influent mass flow rate
ṁi . The plot shows the level h with operational conditions as given in Table 4.6
(red), but also the level h (blue) when starting in steady state conditions with a
step change in the input ṁi (green).
5 // August 26 , 2015
6 // May 11 , 2017
7 //
8 model SimDriven Fu n n el T a nk
9 // Simulation of Driven Funnel Tank model
10 // author : Bernt Lie
11 // University of South - Eastern Norway
12 // August 26 , 2015
13 // May 11 , 2017
14 //
15 // Instantiate model
16 ModDriv enFu nne l T an k dft ;
17 // Declaring variables
18 // -- inputs
19 Real md_i " Mass flow into tank ";
20 // -- outputs
21 Real _h " Level in tank ";
22 // Equations
23 equation
24 // -- input
25 md_i = 2;
26 dft . md_i = md_i ;
27 // -- output
28 _h = dft . h ;
29 end SimDrivenFu n ne l T an k ;
30 //
31 model Si m St ep D r i v e n F u n n e l T a n k
4.8. CASES: LIQUID LEVEL IN TANKS 119
Figure 4.13: Gas tank with constant temperature T , and variable pressure p and
density ρ.
Gas Tank
Figure 4.14: Functional diagram single gas tank with inlet pressure pi and ambient
pressure pa .
81 // -- input variables
82 input Real md_i " Influent mass flow rate to tank , kg / s ";
83 // Equations constituting the model
84 equation
85 // Algebraic equations
86 A = PI * r ^2;
87 r = R_s / h_s * h ;
88 md_e = K * sqrt ( h / h_s ) ;
89 // Differential equations
90 rho * A * der ( h ) = md_i - md_e ;
91 end ModDrivenFu n ne l T an k ;
92 // End package
93 end DrivenFunnelTank ;
mass flow”), where inputs (green arrow) cause a change in the system and is observed
at outputs (orange arrow). Here, the input variables influencing the behavior are
inlet pressure pi and ambient pressure pa , while the output variable is the quantity
we are interested in, p.
dm
= ṁi − ṁe .
dt
m = ρV.
pV = nRT
m
n= .
M
Furthermore
√
∆pi
ṁi = Ki
pς
∆pi = pi − p
√
∆pe
ṁe = Ke
pς
∆pe = p − pa
Table 4.8: Operating conditions for gas tank with fixed temperature.
Quantity Value Unit Comment
p (t = 0) 1.2pa Pa Initial pressure of tank
p(t=0)V
m (t = 0) RT
M g Initial mass (alternative)
pi (t) 10pa Pa Inlet tank pressure
1000000
800000
600000
400000
p
pstep
200000
mi
0 20 40 60 80 100 120 140
time t [s]
Figure 4.15: Pressure p in gas tank. The plot shows the pressure p with operational
conditions as given in Table 4.8 (red), but also the pressure p (blue) when starting
in steady state conditions with a step change in the input pi (green).
124 CHAPTER 4. MASS CONSERVATION
given in Table 4.8); Fig. 4.15 shows the corresponding step change in pi (green curve)
with resulting response in p (blue curve — starting in steady state for the given pi )
using main program simStepGasTank.
An important observation here is that if pi suddenly would drop to beyond the
current value of p, the gas should in fact flow out through both of the valves — in
that case, we would need to rewrite the code by, e.g., redefining ṁi
√
|∆pi |
ṁi = Ki sign (∆pi ) ;
pς
in this case, ṁi is not really an “influent” flow any more. Alternatively, we could
consider the case of a one-way valve whereupon we need to redefine ṁi into
{ √
Ki ∆p pς
i
, ∆pi ≥ 0
ṁi = .
0, ∆pi < 0
The following Modelica code (file GasTank.mo) describes the system with opera-
tions. Notice that we have “cheated” by making pa a parameter instead of an input,
since it doesn’t change in our case.
1 package GasTank
2 // Package for simulating gas tank
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // August 27 , 2015
6 // May 11 , 2017
7 //
8 model SimGasTank
9 // Simulation of Gas Tank model
10 // author : Bernt Lie
11 // University of South - Eastern Norway
12 // August 27 , 2015
13 // May 11 , 2017
14 //
15 // Instantiate model
16 ModGasTank gt ;
17 // Declaring variables
18 // -- inputs
19 Real p_i " Upstream ( inlet ) pressure , Pa ";
20 // -- outputs
21 Real _p " Pressure in tank , Pa ";
22 // Equations
23 equation
24 // -- input
25 p_i = 10* gt . p_a ;
26 gt . p_i = p_i ;
27 // -- output
28 _p = gt . p ;
4.9. CASE: PRESSURE IN SINGLE GAS TANK 125
29 end SimGasTank ;
30 //
31 model SimStepGasTank
32 // Simulation of Gas Tank model with step input
33 // author : Bernt Lie
34 // University of South - Eastern Norway
35 // August 27 , 2015
36 // May 11 , 2017
37 //
38 // Instantiate model
39 ModGasTank gt ;
40 // Declaring variables
41 // -- inputs
42 Real p_i " Upstream ( inlet ) pressure , Pa ";
43 // -- outputs
44 Real _p " Pressure in tank , Pa ";
45 // Initial equations
46 initial equation
47 der ( gt . m ) = 0;
48 // Equations
49 equation
50 // -- input
51 p_i = if time < 25 then 10* gt . p_a else 12* gt . p_a ;
52 gt . p_i = p_i ;
53 // -- output
54 _p = gt . p ;
55 end SimStepGasTank ;
56 //
57 //
58 model ModGasTank
59 // Main Gas Tank model
60 // author : Bernt Lie
61 // University of South - Eastern Norway
62 // August 27 , 2015
63 // May 11 , 2017
64 //
65 // Constants
66 constant Real R = 8.31 " Ideal gas constant , J /( K . mol ) ";
67 // Parameters
68 parameter Real M = 28 " Molar mass of gas , g / mol ";
69 parameter Real p_a = 1.03 e5 " Ambient pressure , Pa ";
70 parameter Real V = 50 e -3 " Tank volume , m3 ";
71 parameter Real K_i = 3 " Input valve constant , kg / s ";
72 parameter Real K_e = 3 " Output valve constant , kg / s ";
73 parameter Real T = 300 " Temperature , K ";
74 // Initial state parameters
75 parameter Real p0 = 1.2* p_a " Initial tank pressure , Pa ";
76 parameter Real m0 = p0 * V * M /( R * T ) " Initial tank mass , g ";
77 // Declaring variables
126 CHAPTER 4. MASS CONSERVATION
Figure 4.16: Gas pipe of length L with constant temperature T and velocity v
throughout, where the velocity also is homogeneous over the cross sectional area A.
Mass flow rate ṁ and pressure p varies along position x.
78 // -- states
79 Real m ( start = m0 ) " Mass in tank , g ";
80 // -- auxiliary variables
81 Real n " Mole in tank , mol ";
82 Real p " Pressure in tank , Pa ";
83 Real dp_i " Influent valve pressure drop , Pa ";
84 Real dp_e " Effluent valve pressure drop , Pa ";
85 Real md_i " Influent mass flow rate to tank , g / s ";
86 Real md_e " Effluent mass flow rate from tank , g / s ";
87 // -- input variables
88 input Real p_i " Inlet pressure to tank , Pa ";
89 // Equations constituting the model
90 equation
91 // Algebraic equations
92 m = n*M;
93 p*V = n*R*T;
94 dp_i = p_i - p ;
95 dp_e = p - p_a ;
96 md_i = K_i * sqrt ( dp_i / p_a ) ;
97 md_e = K_e * sqrt ( dp_e / p_a ) ;
98 // Differential equations
99 der ( m ) = md_i - md_e ;
100 end ModGasTank ;
101 // End package
102 end GasTank ;
Gas Pipe
Figure 4.17: Functional diagram of gas pipe with influent mass flow rate ṁ0 and
inlet pressure p0 , and effluent mass flow rate ṁL and effluent pressure pL .
rate and pressure varies along x, and we seek the pressure and mass flow rate at the
outlet, ṁL and pL . The model objective is illustrated by the functional diagram in
Fig. 4.17.
The functional diagram depicts the causality of the system (“Gas Pipe”), where
inputs (green arrow) cause a change in the system and is observed at outputs (orange
arrow). Here, the input variables influencing the behavior are influent mass flow rate
ṁ0 inlet pressure p0 , while the output variables are the quantities we are interested
in, ṁL and pL .
Step 2: The terms in the total mass balance are considered. Because the volume is
homogeneous and intensive properties have the values at position ξ + ∆x (at
to position x = 0, thus index 0.
128 CHAPTER 4. MASS CONSERVATION
the outlet, assuming the flow direction is as depicted), we denote the mass by
mξ+∆x . From the ideal gas law:
V̇ M
pV̇ = ṅRT ⇔ ṁ = ṅM = p
RT
V̇ = vA.
Thus
V̇ M
ṁi = ṁξ = pξ
RT
V̇ M
ṁe = ṁξ+∆x = pξ+∆x .
RT
Step 3.a: We now manipulate the model slightly to find:
d
(nξ+∆x M ) = ṁξ − ṁξ+∆x
dt
⇓
( )
d pξ+∆x Vξ+∆x V̇ M V̇ M
M = pξ − pξ+∆x
dt RT RT RT
⇓
Vξ+∆x M dpξ+∆x V̇ M V̇ M
= pξ − pξ+∆x
RT dt RT RT
⇓
dpξ+∆x pξ − pξ+∆x
= V̇
dt Vξ+∆x
⇓
dpξ+∆x pξ − pξ+∆x
=v .
dt ∆x
This model is valid for the volume in position x ∈ [ξ, ξ + ∆x], and the variables
only depend on time t.
Step 3.b: We do need a model for all x ∈ [0, L]. To find this, we observe that the
model above can be generalized: by replacing ξ with x, the model becomes
valid for any position x ∈ (0, L]; it is not valid at x = 0, but there we simply
have that p (x = 0) = p0 , the inlet pressure — this is because the pressure p
must be continuous wrt. position x.
However, by generalizing the above model to be valid for any x, this means
that pξ+∆x (t), which only varies with t, now becomes a function of both time
4.10. CASE: PRESSURE IN GAS PIPE 129
and position, px+∆x (t, x). Because of this, we need to change the ordinary
derivative into a partial derivative:
p (t, x = 0) = p0 (t) .
Step 3.c: Finally, we relax on the assumption of the volume being homogeneous
by letting ∆x → 0:
( )
∂px+∆x (t, x) px+∆x − px
lim = lim −v
∆x→0 ∂t ∆x→0 ∆x
⇓
∂p ∂p
= −v .
∂t ∂x
The boundary condition remains unchanged:
p (t, x = 0) = p0 (t) .
Step 4: To complete the system description, we need to relate the output variables
ṁL and pL to the model variables. The partial differential equation for p with
boundary condition, leads to solution p (t, x), and it follows that output pL =
p (t, x = L). Mass flow rate ṁL can then be found as ṁL = V̇RT M
pL = vAM p .
RT L
such a discretization. A numerically good way to do it, is to use the so-called Finite
Volume Method.
Here we use a basic implementation of the upwind Finite Volume Method; the
basic scheme works here because the flow direction does not change. To this end,
we use the model in step 3 above, and just repeat this model for a large number of
different values ξ (alternatively, we could consider this as the model in step 4, or we
could perhaps even consider a less manipulated model from stage 2). By using the
Finite Volume Method with only spatial discretization, we can use a standard ODE
solver such as those in Modelica to solve the model.
Our preferred model summary can thus be described as: choose N , and define
∆x , NL . Then for i ∈ {1, . . . , N }:
Vi·∆x = ∆xA
pi·∆x Vi·∆x = ni·∆x RT
mi·∆x = ni·∆x M
V̇i·∆x = vA
V̇i·∆x M
ṁi·∆x = pi·∆x .
RT
V̇0 M
In addition, we need the boundary conditions p0 and ṁ0 = RT 0
p where V̇0 = vA.
The differential equations are then for i ∈ {1, . . . , N }
d
mi·∆x = ṁ(i−1)∆x − ṁi·∆x .
dt
We choose the following parameters for the model, Table 4.9.
The operating conditions (initial state, input) are defined in Table 4.10.
Note that temperature T could just as well have been considered as an input.
Table 4.10: Operating conditions for gas tube with homogeneous temperature.
Quantity Value Unit Comment
pi·∆x (t = 0) 1.2pa Pa Initial pressure along tube, i ∈ {1, . . . , N }
mi·∆x (t = 0) pi·∆x (t=0)·∆xA
RT
M g Initial mass along tube (alternative), i ∈ {1, . . . , N }
p0 (t) 10pa Pa Normal inlet pressure
v (t) 0.2 dm/s Normal gas velocity
Figure 4.18: Pressure distribution through the tank gp.p[i] with N = 10 slices,
as a function of time. pL is annotated as _pL which equals gp.p[10], while the
inlet pressure p0 is annotated as p_0. The initial pressure distribution, p (t = 0, x)
is annotated as gp.p0.
1200000 p(x = 0, t)
pL
p1
1150000 p2
p3
p4
1100000 p5
p6
p7
1050000 p8
p9
0 20 40 60 80 100 120 140
time t [s]
Figure 4.19: Pressure distribution through the tank caused by a step in the inlet
pressure p0 given as gp.p_0; the outlet pressure pL is given as _pL.
132 CHAPTER 4. MASS CONSERVATION
1150000
1100000
1050000
Figure 4.20: Outlet pressure pL given by _pLN with N (N) slices N ∈ {10, 30, 90, 300},
in response to a step in the inlet pressure p0 given as p_0.
The result of comparing N ∈ {10, 30, 90, 300} starting in steady state, and with
a step in the inlet pressure p0 is generated using class SimStepCompareGasPipe is
shown in Fig. 4.20.
The figure illustrates that the response gradually approaches the true delayed
step response as N increases. At the same time, the computation time increases
substantially with increasing N .
The following Modelica code (file GasPipe.mo) describes the system with oper-
ations. In this code, v is used as input variable instead of ṁ0 .
1 package GasPipe
2 // Package for simulating gas pipe
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // August 27 , 2015
6 // May 11 , 2017
7 //
8 model Si mS te pCo m p a r e G a s P i p e
9 // Simulation and comparison of Gas Pipe model
10 // author : Bernt Lie
11 // University of South - Eastern Norway
12 // August 27 , 2015
13 // May 11 , 2017
14 //
15 // Instantiate model
16 ModGasPipe gp10 ( N =10) , gp30 ( N =30) , gp90 ( N =90) , gp300 ( N
=300) ;
17 // Declaring variables
18 // -- inputs
4.10. CASE: PRESSURE IN GAS PIPE 133
4.11 Review
We have seen that in classical physics, total mass is conserved, i.e., for an isolated
system, the total mass is constant. This is in contrast to, e.g., relativity theory,
where total mass can be converted to energy, and vice versa. The concept of con-
servation laws is extended to open systems where there is an exchange of matter or
energy with the surroundings: these are still denoted conservation laws. However,
if the quantity in question is not conserved and there is a source term within the
system boundaries, we may still formulate balance laws. In general, it is difficult
to find the correct source terms, so it is still recommended to base balance laws on
quantities that are related to conserved quantities.
The concept of mass with a real numbered value, is related to the idea that matter
is a continuum. Alternatively, mass can be considered a collection of particles, where
each particle has a specific mass. If each particle has the same mass, there is a simple
relationship between particle description and the continuum description of matter.
For normal systems, the number of particles is so large that it is common to refer
to scaled numbers; when the number of particles is scaled with Avogadro’s number,
the scaled quantity is known as the mole number. Because of the large number of
particles, it is common to pretend that the number of particles or the number of
moles is a real variable. However, for systems with few/large particles, it may be
necessary to consider them as integers/rational numbers.
Mass, number of particles and number of moles, as well as geometric measures
of extent such as volume, area and length are examples extensive quantities relevant
for mass conservation. Examples of intensive quantities are density (specific concen-
tration), molar concentration, specific volume, molar volume, as well as temperature
and pressure.
Ideal gas behaves according to the ideal gas Equation of State. Non-ideal gases
can be described by, e.g., cubic Equations of State, or other more complex Equations
of State.
Assuming homogeneous intensive properties within the system volume implies
that the intensive properties have the same value everywhere in the system. This
implies that (i) there is a simple relationship between the intensive quantities and
the extensive quantities, and (ii) for flow systems, the intensive quantities in effluent
flows are identical to the intensive quantities within the system. The homogeneous
system assumption is sometimes referred to as the well stirred tank assumption.
Note that assuming a homogeneous systems has now effect on the intensive quantities
in the influents. Distributed systems where the homogeneity assumption fails, can
be treated as a large number of connected, well stirred tanks.
Through examples, the use of the total mass balance for finding liquid levels in
tanks and pressures in closed gas volumes has been illustrated. The examples illus-
trate how models can be encoded in the Modelica modeling language, and Open-
Modelica has been used to simulate the systems.
In the next chapter, we will consider systems composed of different types of
particles/species. In that case, we may be interested in considering the mass of each
species instead of the total mass. Because one species may be converted to another
species through a chemical reaction, this implies that we may need to add a source
4.12. EXERCISES* 137
term when we consider species. The implication is that the mass of species is not
conserved; instead we formulate balance laws for species.
4.12 Exercises*
Solutions to these exercises are given in Appendix D.3. It is recommended to defer
looking at the solution until a serious attempt to solve an exercise has been given.
...under construction...
4.13 Problems*
Solutions to these problems are given in Appendix E.3. It is recommended to defer
looking at the solution until a serious attempt to solve an problems has been given.
In Example 4.10, it is found that the pressure varies along the pipe as
∂p ∂p
= −v , x ∈ (0, L]
∂t ∂x
p (t, x = 0) = p0 (t) .
Show that in the more general case where v varies with x, the total mass balance
leads to
∂ρ ∂
+ (ρv) = 0.
∂t ∂x
N
138 CHAPTER 4. MASS CONSERVATION
Chapter 5
Species balance
• What is the structure of species balance laws with mass and mole as basis?
• What extensive and intensive quantities are relevant for species balances?
139
140 CHAPTER 5. SPECIES BALANCE
H H O
H C C H
H OH
Figure 5.1: Isomeric realizations of ethanol (left) and dimethyl ether (right).
P1
P2
If the dance hall also has a section for playing pool, then we might distinguish
between species M(d) and M(p), where species M(d) circulates in the dance hall,
while species M(p) hangs around in the pool hall — here, the distinction between d
and p is comparable to the distinction between gas phase g and liquid phase l. N
In medieval time, various forms of ring dances where popular, e.g., as in Fig. 5.4.
Similar constellations to ring dances are formed in nature by chemical species.
Ring dances and square dances are still popular among traditionalists. N
Another useful term is substance. How does a substance differ from a species?
We say that H2 (g) and H2 (l) are of the same substance H2 . Similarly, M(d) and
M(p) are of the same substance M. N
5.3. MASS SPECIES BALANCE 143
Because the species balance contains a generation term ṁj,g , we choose to not
refer to species balance as a conservation law.
Table 5.1: The Periodic Table of the Elements. Each cell contains the atomic number of the respective element, together with the
adopted symbol. Groups of elements include Noble Gases, Halogens, Non-Metals, Semi-Metals, Metals, Transition Metals, Alkali
Metals, Alkaline Earth, as well as Lanthanides and Actinides. Elements marked with * are elements that have been discovered, but
for which names have yet to be adopted. Adapted from Resnick et al. (2002) and Aylward & Findlay (2002).
1 2
H He
3 4 5 6 7 8 9 10
Li Be B C N O F Ne
11 12 13 14 15 16 17 18
Na Mg Al Si P S Cl Ar
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
K Ca Sc Ti V Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
Rb Sr Y Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I Xe
55 56 57– 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
Cs Ba 71 Hf Ta W Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn
87 88 89– 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
Fr Ra 103 Rf Db Sg Bh Hs Mt Ds Rg Cn Uut* Uuq* Uup* Uuh* Uus* Uuo*
Lantha- 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
nides La Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu
Acti- 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
nides Ac Th Pa U Np Pu Am Cm Bk Cf Es Fm Md No Lr
144
5.5. MOLAR SPECIES BALANCE 145
The value of the molar mass for various substances is found in standard physi-
cal/chemical tables. The atomic number of the elements in Table 5.1 approximately
gives the mass per NA elements, in g/mol. As an example, H2 O is composed of two
hydrogen elements H (atomic number 1) and one oxygen element O (atomic number
8). It follows that MH2 O ≈ 2 · 1.008 + 16.00 ≈ 18 g/mol. Air is composed of ca. 79%
N2 gas and 21% O2 gas, neglecting Argon and other components. The molar mass
of air is thus Mair ≈ 0.79 × 2 × 14.01 + 0.21 × 2 × 16.0 ≈ 28.86 g/mol. More accurate
numbers are given in physical/chemical tables.
mj
Nj = .
muj
What does this mean? It simply means that if, e.g., mH2 is the mass of hydrogen
H2 in a system, and every hydrogen molecule has mass muH2 , then the number of
hydrogen molecules is
mH
NH2 = u 2 .
mH2
In many systems, the individual elements of species do not have identical mass, e.g.,
human beings considered as species.
In chemical engineering, the number of elements in a species is typically very
large (e.g., there is a huge number of hydrogen molecules in one liter of hydrogen
gas), and it is therefore common to scale the numbers Nj by Avogadro’s number
NA , 6.0221415 × 1023 . This scaled number is known as a mole nj , i.e.,
mj
Nj mu mj mj
nj = = j = u
=
NA NA NA mj Mj
where Mj is the molar mass of species j, i.e., the mass of one mole of species j. Here,
some care should be shown: in continuoum physics, mass mj is considered a real
number. However, the molar mass Mj must be so that nj is a rational number —
after all, the mole number nj is the fraction of the particle number Nj (non-negative
integer) and the positive integer NA .3
This means that for species where each element has a fixed mass, we can use
a molar species balance (or a number species balance) instead of the mass species
balance. Since
mj = Mj nj ,
3
Although NA is typeset as a floating point number, with the new, current definition of NA , it
actually is positive integer.
146 CHAPTER 5. SPECIES BALANCE
In general, ṅg ̸= 0.
From the discussion above, it is clear that mass species balance and molar species
balance are equivalent balances — they contain the same information. Thus, there
is no problem in formulating mass balances for some species and mole balances for
the remaining species.
height in the interval (150, 160] cm, the number of persons with a height in
the interval (160, 170] cm, etc. When we have counted the number of persons
within each height interval, we can present the number of persons as a function
of the height. In this case, the attribute has a countable number of possible
values (interval [0, 10] cm, (10, 20] cm, etc.).
• The species is a molecule with double bonds, and the attribute is how the
atoms are connected, e.g., a so-called cis or trans bond4 . We can then for-
mulate a species balance for the various values of the attribute, e.g., a species
balance for molecules with the cis bond, and a separate species balance for the
trans bond. In this case, the attribute has two possible values (cis or trans
bond).
• The species is an iron particle, and the attribute is the size of the particle. It
is common to assume that the value of the attribute can vary continuously,
and we can present, e.g., the number of particles with a certain size. In this
case, the value of the attribute can vary continuously; the size is considered a
real (positive) number.
• It should be noted that there are other possibilities than counting the number
of individuals of a species with a certain size: we could also measure the mass
of species with a certain size.
• The content of a perfectly mixed tank is molecules, and not all of these
molecules have stayed in the tank for the same length of time. It is possi-
ble to formulate, e.g., a mass balance for the molecules that have stayed in the
tank a certain length a of time, often called the age of the molecule within the
tank. Then a mass balance is formulated for each possible age, in principle in
the range [0, ∞). The resulting population balance leads to a mass distribu-
tion over age, similar to the age distribution of the population in a country.
Clearly, this age distribution can change with time. 5
We see that population balances are very similar to standard species balances; the
way of thinking when formulating the population balances is identical to the way of
thinking when formulating species balances.
4
To the Romans, the Cisalpine Gauls lived on the hither side of the Alps (i.e., in current Italy),
while the Transalpine Gauls lived on the other side of the Alps (e.g., in current France): cis means
on this side, while trans means on the other side.
5
As an example, the age distribution in Norway was different in 1348 from that in 1351, and
will also be different in 2020 from that in 2017.
148 CHAPTER 5. SPECIES BALANCE
In the more general case of a system being inhomogeneous in the intensive quan-
tities, we have the more general relations:
dmj
m′′′
j = ρ̂j = ⇔ dmj = ρ̂j dV = m′′′
j dV
dV
dmj
m′′j = ⇔ dmj = m′′j dA
dA
dmj
m′j = ⇔ dmj = m′j dL
dL
and
dnj
n′′′
j = ρ̃j = ⇔ dnj = ρ̃j dV = n′′′
j dV
dV
dnj
n′′j = ⇔ dnj = n′′j dA
dA
dnj
n′j = ⇔ dnj = n′j dL.
dL
If we know how ρj varies in space, we can, e.g., find the system mass by integrating
over the volume, ˆ
mj = ρ̂j V .
V
Similarly, we could introduce the mass fraction ωj as an intensive quantity,
defined by ˆ
mj = ωj dm
V
or
dmj
ωj , ,
dm
which in a homogeneous system simplifies to
mj = ωj m.
nj = xj n.
It does not make sense to talk about flow of intensive properties. Thus, if
y is an intensive property, we do not consider ẏ; we never talk about the flow
of concentration. However, matter that flows across boundaries can possess an
intensive property. Thus, a matter with flow ṁj can possess a density ρ̂j , and thus
we have
ṁj = ρ̂j V̇
where V̇ is the volumetric flow; V is the extensive property volume.
where ns is the number of substances in the gas volume, ajk (T ) is a binary function
defined as √
ajk (T ) = (1 − δjk ) aj (T ) ak (T ), (5.5)
where δjk is a binary interaction parameter; δjj = 0, otherwise δjk is a small value
often assumed to be independent of composition, temperature and pressure. If δjk is
not known, it is common to set δjk ≈ 0. Furthermore, aj (T ) is the pure substance
function for substance j, and bj is the pure substance value for substance j.
The above mixing rules are empirical in nature, and are relatively poor for light
gases such as hydrogen and helium. More modern, theoretically based mixing rules
give better prediction capabilities at the cost of being considerably more compli-
cated.
To this end, when the mixing values of a (T ) and b have been determined, the
molar volume, etc. can be computed just as in Section 4.5. Relevant data for
selected pure species are given in Table C.1 of Appendix C.1.
5.9. RATES OF GENERATION 151
r = kcA cB
A + B
C,
A+B→C
A + B ← C.
Consider now row k of stoichiometric matrix ν, i.e., νk,: . Assume that there
are n− −
s,k negative elements Sk in νk,: ; we denote the corresponding stoichiometric
coefficients by νk− . Likewise, assume there are n+ +
s,k positive elements Sk in νk,: ; let
us denote the corresponding stoichiometric coefficients by νk+ . Row k of ν, vk:: will
also contain n0s,k zero elements; ns = n− 0 +
s,k + ns,k + ns,k . For an elementary forward
reaction, we thus have
∏ |ν − |
r+ = k+ (T ) cj k,j (5.7)
j∈Sk−
∏
where j is the product operator and cj is the concentration of element j of species
with negative coefficient νj . Likewise, for an elementary backwards reaction, we
have
∏ ν+
r− = k− (T ) cj k,j . (5.8)
j∈Sk+
The total reaction rate is thus r = r+ − r− . Reactions for which the rates follow the
expressions Eq. 5.7 for r+ and Eq. 5.8 for r− , are known as elementary reactions.
0
ν1 S1 + ν2 S2 + ν3 S3 + ν4 S3
where (ν1 , ν2 ) < 0 while (ν3 , ν4 ) > 0. With S3 , S4 products and S1 , S2 reactants,
we find that n− s = 2 with S
−
= (S1 , S2 ), and n+
s = 2 with S
+
= (S3 , S4 ), while
− + 7
ν = (ν1 , ν2 ) and ν = (ν3 , ν4 ). The forward reaction r+ is thus
|ν | |ν |
r+ = k+ (T ) cS11 cS22 .
At the same time, the products disintegrate in the reverse reaction, thus
r− = k− (T ) cνS33 cνS44 .
The overall reaction rate for this simple stoichiometric, elementary reaction is thus
r = r+ − r− .
N
For many reactions, a postulated elementary reaction rate gives a poor represen-
tation of reality. Such reactions could be termed non-elementary reactions. There
are many reasons why a reaction may be non-elementary; see, e.g., Levenspiel (1972)
or Fogler (1992) for a discussion.
7
The absolute value operator is needed because (ν1 , ν2 ) < 0.
154 CHAPTER 5. SPECIES BALANCE
The law of mass action states that the equilibrium constant is related to fugacities
fj as
( )r ( )s
f f
f◦ f◦
K = ( )aR ( )bS
f f
f◦ f◦
A B
where f ◦ is some standard state fugacity. For ideal gas, the fugacity fjig equals the
partial pressure pj , fjig = pj . With standard state 1 atm of each pure gas component,
then
fj pj
◦
= ς = p̄,
fj p
(p̄R )r (p̄S )s
K= = Kp ;
(p̄A )a (p̄B )b
In equilibrium, r = 0 and
k+ (p̄R )r (p̄S )s
= = Kp ⇒ k+ = k− Kp .
k− (p̄A )a (p̄B )b
(one for each reaction) with the molar rates of generation ṅg defined as
ṅ1,g
ṅg , ... .
ṅns ,g
rg , ν T r,
hence ˆ
ṅg = rg dV .
V
2. The relationship between molar rate of generation and reaction rates simplifies
to
ṅg = ν T rV .
156 CHAPTER 5. SPECIES BALANCE
rg = ν T r
where
ṅg = rg V .
ṅj,e = cj V̇e
where V̇e is the (total) volumetric flow rate out of the tank, and the mass flow
rate out of the system can be written as
ṁj,e = ρj V̇e .
dnS
wT = wT ṅS,i − wT ṅS,e + wT ν T rS,g V
dt
⇓
d ( T )
w nS = wT ṅS,i − wT ṅS,e + (νw)T rS,g V
dt
⇓
dz
= żi − że + (νw)T rS,g V .
dt
Question: can we choose weight w such that the pseudo species z is reaction
invariant, i.e such that νw ≡ 0? We see that this is equivalent to the question: can
we find column vector w such that
ν · w = 0?
Again, remember that ν ∈ Rnr ×ns is a matrix. The linear algebra answer is that
this is possible as long as w ∈ N (ν), where N (v) denotes the so-called nullspace of
matrix ν. The nullspace is defined by dim N (ν) = ns − rankν basis vectors. This
essentially means that we can choose dim N (ν) linearly independent such reaction
invariant pseudo species. Let us define nz = dim N (ν); we can thus find a vector of
pseudo species z ∈ Rnz as a linear transformation
z = Wz nS
ζ = Wζ nS .
and we have decomposed the system into two groups of pseudo species which
are reaction invariant (z) and reaction variant (ζ), and where dim ζ = rankν =
rank (ν · Wζ ).
In Section 2.5.29 , we have seen how we can use sympy in Python to compute the
nullspace of a matrix. It should be noted that
( )
N (ν)⊥ = C ν T
( )
where C ν T is the so-called column space of matrix ν T . One further observation
is that our stoichiometric matrix ν usually is of full row rank, which means that all
rows are linearly independent. This simply means that all proposed stoichiometric
reactions are independent of each other; there is no reaction which is a linear com-
bination of the other reactions. When matrix ν has full row rank, this obviously
means that ν T has full column rank.
Mathematical software normally have a function for computing basis vectors for
the nullspace of matrix A ∈ Rm×n , N (A). In the sympy package of Python, the
command is as follows:
A = QR
so that
A = QR = Q̃m×n R̃n×n + Q̄m×(m−n) 0(m−n)×n = Q̃m×n R̃n×n .
9
...on the Buckingham Π-theorem
5.10. DIFFUSION 159
( ) ( ) ( )
It can be shown that C Q̃ = C (A), and that C Q̄ = N AT . Because the
columns of both Q̃ and Q̄ are orthogonal,( T )the columns of Q̃ and Q̄ constitute or-
thogonal basis vectors for C (A) and N A , respectively.
From this general discussion, it follows that the if matrix ν T ∈ Rns ×nr has full
column rank, we can take the QR decomposition of ν T :
ν T = QR,
( )
and find basis vectors for C ν T as the nr first columns of Q.
The following snippet indicates how to find the QR decomposition using Python’s
sympy package.
1 Q , R = A . QRdecomposition ()
2 Q = Matrix ( Q )
Finally, it should be observed that for reaction invariant “pseudo species”, the
generation term is zero, thus the species balances for these reaction invariants are
in fact conservation laws.
5.10 Diffusion
5.10.1 Average velocity in mixtures
The linear velocity v of matter links the total mass/total mole and species balances
to Newtons law and the momentum balance (next chapter). In addition, linear
velocity v is related to volumetric flow as
ˆ
V̇ = vdA
A
V̇ = vA.
1∑
n
s
v̂ = ρ̂j vj
ρ̂ j=1
where ∑ns
m j=1 mj ∑
ns
ρ̂ = = = ρ̂j .
V V j=1
160 CHAPTER 5. SPECIES BALANCE
where ∑ns
n j=1 nj ∑
ns
ρ̃ = = = ρ̃j .
V V j=1
⇓
Jˆ1 + Jˆ2 ≡ 0.
Similarly, for a binary mixture, we also find that
J˜1 + J˜2 ≡ 0.
5.10. DIFFUSION 161
For binary mixtures, it is common to use the notation D̃12 for the common diffusion
coefficient.
A similar result is valid if mass based diffusion is considered.
The value of the diffusion coefficient varies with temperature, and the following
expression is sometimes used:
Dj (T1 ) T1 µ (T1 )
=
Dj (T2 ) T2 µ (T2 )
where T is absolute temperature, and µ (T ) is the temperature dependent viscosity.
The diffusion coefficient also depends on the fraction of each species in the mixture.
Binary diffusion coefficients for a few dilute mixtures are given in Table 5.2.
10
See problem in Section 4.13.
162 CHAPTER 5. SPECIES BALANCE
Table 5.2: Dilute diffusion coefficients for some binary liquid mixtures, where a small
fraction of solute is dissolved in the solvent Poling et al. (2001).
Solute Solvent T [K] D12 × 105 [cm2 /s]
Methane Water 275 0.85
—"— —"— 333 3.55
Carbon dioxide — " — 298 2.00
Propylene —"— 298 1.44
Methanol —"— 288 1.26
Ethanol —"— 288 1.00
Water Ethanol 298 1.24
Oxygen —"— 303 2.64
Toluene Benzene 298 1.85
We consider the tank in Fig. 5.5, where two influent flows containing species A and
B of different pure substance densities, ρ•A and ρ•B , are mixed.
It is of interest to find how the liquid level h and the specific concentrations
ρA and ρB at the outlet depend on the influent volumetric flow rates V̇i1 and V̇i2 ,
the influent specific concentrations ρA,i1 , ρB,i1 , ρA,i2 , ρB,i2 , as well as the effluent
volumetric flow rate V̇e . The model objective is illustrated by the functional diagram
in Fig. 5.6.
The functional diagram depicts the causality of the system (“Two-liquid mix-
ture”) where inputs (green arrow) V̇i1 , V̇i2 , ρA,i1 , ρB,i1 , ρA,i2 , ρB,i2 , and V̇e cause a
change in the system which is observed in the outputs (orange arrow) h, ρA and ρB .
5.11. CASE: LIQUID LEVEL IN TANK WITH TWO SPECIES 163
Two-liquid
mixture
Figure 5.6: Functional diagram of tank where two liquids are mixed.
Step 1: To find the specific concentrations and the liquid level, we will use the mass
based species balance
dmj
= ṁj,i − ṁj,e + ṁj,g .
dt
Step 2: In the species balances, we neglect the reactions, which means that ṁj,g =
0. The influent mass flow rates are given by
where j ∈ {A, B} and k ∈ {1, 2}. With the perfect mixing assumption, we
have
mj
ρj =
V
while the effluent flow rates are
ṁj,e = ρj V̇ .
∑ •
The assumption of ideal solution implies that V = j Vj , where the pure
substance volume Vj• is given from the density of the pure substance, i.e.,
Vj• = ρ•j . Finally, with constant cross sectional area A, the volume and the
m
j
level are related by V = Ah.
11
Many liquids are miscible. However, some are not — e.g., water and gasoline are not miscible,
and will appear as two different liquid phases.
164 CHAPTER 5. SPECIES BALANCE
Step 3: We can now manipulate the model into a suitable form. Application of the
species balance for species A and B leads to
dmA
= ṁA,i1 + ṁA,i2 − ṁA,e + ṁA,g
dt
dmB
= ṁB,i1 + ṁB,i2 − ṁB,e + ṁB,g .
dt
Here,
ṁA,i1 = ρA,i1 V̇i1
ṁB,i1 = ρB,i1 V̇i1
ṁA,i2 = ρA,i2 V̇i2
ṁB,i2 = ρB,i2 V̇i2
and
ṁA,e = ρA V̇e
ṁB,e = ρB V̇e
where
mA
ρA =
V
mB
ρB = .
V
Finally,
V = VA• + VB•
mA
VA• = •
ρA
m
VB• = • ,
B
ρB
and
V = Ah.
Step 4: A DAE solver will be able to compute h, ρA and ρB from the relations in
Step 3. However, let us develop explicit expressions
∑ for ∑
these quantities based
m
on the states mA and mB . We have that V = j V̄j = j ρ̄jj , thus
mA mB
V = + • .
ρ•A ρB
It follows that mA
V ρ•A
+ mρ•B
B
h= = .
A A
mj
Furthermore, ρj = V
and thus
mA mA
ρA = = mA mB
V ρ•A
+ ρ•
B
mB mB
ρB = = mA mB .
V ρ•
+ ρ•
A B
5.11. CASE: LIQUID LEVEL IN TANK WITH TWO SPECIES 165
dmA
= ṁA,i1 + ṁA,i2 − ṁA,e + ṁA,g
dt
dmB
= ṁB,i1 + ṁB,i2 − ṁB,e + ṁB,g .
dt
Here,
Table 5.4: Operating conditions for tank with liquid mixing. Hτ is the Heaviside
function.
Quantity Value Unit Comment
mA (t = 0) 60 kg Initial mass of A in tank
mB (t = 0) 40 kg Initial mass of B in tank
V̇i1 (t) 1 L/s Influent volumetric flow 1
V̇i2 (t) 1 L/s Influent volumetric flow 2
V̇e (t) 2 + 0.1H100 s L/s Effluent volumetric flow
ρA,i1 (t) 1 kg/L Influent density of A in flow 1
ρB,i1 (t) 0 kg/L Influent density of B in flow 1
ρA,i2 (t) 0 kg/L Influent density of A in flow 2
ρB,i2 (t) 0.8 kg/L Influent density of B in flow 2
4.0
3.9
3.8
3.7
3.6
0 50 100 150 200 250 300
time t [s]
From Figure 5.7, we observe that after the step in the effluent volumetric flow
rate V̇e , there is a net decrease in the liquid volume. We also observe that the specific
concentrations ρA and ρB differ considerably from the pure substance densities ρ•A
and ρ•B . The latter observation is to be expected, since
mA
ρA =
V
while
mA
ρ•A =
VA•
where VA• ≈ 0.5V , thus ρA should approach 0.5ρ•A with the given volumetric inputs.
The following Modelica code (file LiquidMixing.mo) is used to produce the
figures.
1 package LiquidMixing
2 // Package for simulating liquid mixing
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // September 3 , 2015
6 // May 11 , 2017
7 //
8 model SimLiquidMixing
9 // Simulation of liquid mixing
10 // author : Bernt Lie
11 // University of South - Eastern Norway
12 // September 3 , 2015
13 // May 11 , 2017
14 //
15 // Instantiate model of * liquid mixing * ( lm )
168 CHAPTER 5. SPECIES BALANCE
16 ModLiquidMixing lm ;
17 // Declaring variables
18 // -- inputs
19 Real Vdi1 " Influent volumetric rate 1 , L / s ";
20 Real Vdi2 " Influent volumetric rate 2 , L / s ";
21 Real Vde " Effluent volumetric rate , L / s ";
22 Real rhoAi1 " Influent concentration of A in 1 , kg / L ";
23 Real rhoBi1 " Influent concentration of B in 1 , kg / L ";
24 Real rhoAi2 " Influent concentration of A in 2 , kg / L ";
25 Real rhoBi2 " Influent concentration of B in 2 , kg / L ";
26 // -- outputs
27 output Real _h " Level in tank , dm ";
28 output Real _rhoA " Specific concentration of A in tank ,
kg / L ";
29 output Real _rhoB " Specific concentration of B in tank ,
kg / L ";
30 // Equations
31 equation
32 // -- input values
33 Vdi1 = 1;
34 Vdi2 = 1;
35 Vde = if time < 100 then 2 else 2.1;
36 rhoAi1 = 1;
37 rhoBi1 = 0;
38 rhoAi2 = 0;
39 rhoBi2 = 0.8;
40 // -- injecting input functions to model inputs
41 lm . Vdi1 = Vdi1 ;
42 lm . Vdi2 = Vdi2 ;
43 lm . Vde = Vde ;
44 lm . rhoAi1 = rhoAi1 ;
45 lm . rhoBi1 = rhoBi1 ;
46 lm . rhoAi2 = rhoAi2 ;
47 lm . rhoBi2 = rhoBi2 ;
48 // -- outputs
49 _h = lm . h ;
50 _rhoA = lm . rhoA ;
51 _rhoB = lm . rhoB ;
52 end SimLiquidMixing ;
53 //
54 model ModLiquidMixing
55 // Model of liquid mixing
56 // author : Bernt Lie
57 // University of South - Eastern Norway
58 // September 3 , 2015
59 // May 11 , 2017
60 //
61 // Parameters
62 parameter Real A = 25 " Cross sectional area of tank , dm2
5.11. CASE: LIQUID LEVEL IN TANK WITH TWO SPECIES 169
";
63 parameter Real rhoA0 = 1 " Pure substance density of A , kg
/ L ";
64 parameter Real rhoB0 = 0.8 " Pure substance density of B ,
kg / L ";
65 // Initial state parameters
66 parameter Real mA0 = 60 " Initial mass of species A , kg ";
67 parameter Real mB0 = 40 " Initial mass of species B , kg ";
68 // Declaring variables
69 // -- states
70 Real mA ( start = mA0 , fixed = true ) " Mass of species A , kg ";
71 Real mB ( start = mB0 , fixed = true ) " Mass of species B , kg ";
72 // -- auxiliary variables
73 Real mdAi1 " Influent mass flow of A in flow 1 , kg / s ";
74 Real mdBi1 " Influent mass flow of B in flow 1 , kg / s ";
75 Real mdAi2 " Influent mass flow of A in flow 2 , kg / s ";
76 Real mdBi2 " Influent mass flow of B in flow 2 , kg / s ";
77 Real mdAe " Effluent mass flow of B , kg / s ";
78 Real mdBe " Effluent mass flow of B , kg / s ";
79 Real rhoA " Specific concentration of A , kg / L ";
80 Real rhoB " Specific concentration of B , kg / L ";
81 Real V " Tank liquid volume , L ";
82 Real VA0 " Partial volume of species A , L ";
83 Real VB0 " Partial volume of species B , L ";
84 Real h " Tank liquid level , dm ";
85 // -- input variables
86 input Real Vdi1 , Vdi2 , Vde , rhoAi1 , rhoBi1 , rhoAi2 ,
rhoBi2 ;
87 // Equations constituting the model
88 equation
89 // Algebraic equations
90 mdAi1 = rhoAi1 * Vdi1 ;
91 mdBi1 = rhoBi1 * Vdi1 ;
92 mdAi2 = rhoAi2 * Vdi2 ;
93 mdBi2 = rhoBi2 * Vdi2 ;
94 mdAe = rhoA * Vde ;
95 mdBe = rhoB * Vde ;
96 rhoA = mA / V ;
97 rhoB = mB / V ;
98 V = VA0 + VB0 ;
99 VA0 = mA / rhoA0 ;
100 VB0 = mB / rhoB0 ;
101 V = A*h;
102 // Differential equations
103 der ( mA ) = mdAi1 + mdAi2 - mdAe ;
104 der ( mB ) = mdBi1 + mdBi2 - mdBe ;
105 end ModLiquidMixing ;
106 // End package
107 end LiquidMixing ;
170 CHAPTER 5. SPECIES BALANCE
⇓
mA mB
V = + •
ρ•A ρB
⇓
ρA V ρB V
V = •
+ •
ρA ρB
⇓
ρA ρB
1= + . (5.9)
ρ•A ρ•B
From this it follows that ρA and ρB are related, and thus can not vary independently:
if ρA is known, we can compute ρB , and vice versa. This indicates that we can not
choose ρA and ρB as independent states, because at all times they have to satisfy
Eq. 5.9.
The next question is: can we compute the level h if we know ρA and ρB ? The
development of the constraint relating ρA and ρB in Eq. 5.9 indicates that this is
not possible, and it is logical: we can not compute an extensive variable such as h
from purely intensive variables such as ρA and ρB .
From the model simulation, we observe that the system in fact has two indepen-
dent states (e.g., mA and mB ). Both of our original choice of variables were extensive
variables, and we see that we can compute all information from these states. We
have now also concluded that we can not use two intensive variables as states and
compute the full information of the system from these intensive variables. However,
if we choose one intensive variable (e.g., ρA ) as state, and in addition one exten-
sive variable (e.g., h) as state, we can compute all information about the system
contained in the original model.
Let us find the model with alternative states ρA and h. For species A, we have
dmA d dρA dV
= (ρA V ) = V + ρA .
dt dt dt dt
Volume V can be expressed as
mA mB
V = VA• + VB• = + • (5.10)
ρ•A ρB
leading to
dV 1 dmA 1 dmB
= • + •
dt ρA dt ρB dt
5.11. CASE: LIQUID LEVEL IN TANK WITH TWO SPECIES 171
thus
( )
dmA d dρA 1 dmA 1 dmB
= (ρA V ) = V + ρA + •
dt dt dt ρ•A dt ρB dt
⇓
dmA dρA ρA dmA ρA dmB
=V + • + •
dt dt ρA dt ρB dt
⇓
( )
dρA ρA dmA ρA dmB
V = 1− • − • .
dt ρA dt ρB dt
Similarly, we have
dV 1 dmA 1 dmB
= • + •
dt ρA dt ρB dt
⇓
d 1 ( ) 1 ( )
(Ah) = • V̇i1 ρA,i1 + V̇i2 ρA,i2 − V̇e ρA + • V̇i1 ρB,i1 + V̇i2 ρB,i2 − V̇e ρB .
dt ρA ρB
Here, A is constant, while ρB can be eliminated by using the relation in Eq. 5.9.
We can thus summarize the model for ρA and h as
( )
dρA ρA ( ) ρ (
A
)
V = 1− • V̇i1 ρA,i1 + V̇i2 ρA,i2 − V̇e ρA − • V̇i1 ρB,i1 + V̇i2 ρB,i2 − V̇e ρB
dt ρA ρB
dh 1 ( ) 1 ( )
A = • V̇i1 ρA,i1 + V̇i2 ρA,i2 − V̇e ρA + • V̇i1 ρB,i1 + V̇i2 ρB,i2 − V̇e ρB
dt ρA ρB
V = Ah
ρA ρB
1= • + •.
ρA ρB
Liquid phase
varying volume
reactor
the system; thus, ρ is constant. We assume that the cross sectional area of the tank
is constant, A.
In the first step of the model development, we introduce the necessary balance
laws, in the second step we relate the terms in the balance law to the properties of
interest, in the third step we manipulate the model into the desired form, and in
the fourth step we relate the computed variables to the outputs of interest.
Step 1: To find the level, we need to use the total mass balance
dm
= ṁi − ṁe .
dt
To find the molar concentrations, we need the molar species balance,
dnj
= ṅj,i − ṅj,e + ṅj,g
dt
where j ∈ {A, B}.
m = ρV
ṁi = ρV̇i .
V = Ah.
n j = cj V
ṅj,e = cj V̇e
174 CHAPTER 5. SPECIES BALANCE
where
ṁe
V̇e = .
ρ
rg = ν T r,
and
rj,g = νj r
Step 3: Because Modelica supports DAE models and we use OpenModelica to solve
our model, there is little manipulation needed in formulating the complete
model. The model is
dm
= ṁi − ṁe
dt
m = ρV
V = Ah
ṁi = ρV̇i
√
h
ṁe = K
hς
and furthermore
dnA
= ṅA,i − ṅA,e + ṅA,g
dt
dnB
= ṅB,i − ṅB,e + ṅB,g
dt
5.12. CASE: LIQUID PHASE, VARYING VOLUME REACTION 175
where
n A = cA V
nB = cB V
ṅA,i = cA,i V̇i
ṅB,i = 0
ṅA,e = cA V̇e
ṅB,e = cB V̇e
ṁe
V̇e =
ρ
ṅA,g = rA,g V
ṅB,g = rB,g V
rA,g = ν1 r
rB,g = ν2 r
( )
ν = −a 1
r = kcaA .
Table 5.6: Operating conditions for liquid reactor with varying level.
Quantity Value Unit Comment
h (0) 1.5 dm Initial level
m (0) ρh (0) A kg Initial mass (alternative initial condition)
nA (0) 2 mol Initial number of moles of species A
nB (0) 0 mol Initial number of moles of species B
V̇i 2 L/s Influent volumetric flow rate; may be varied
cA,i 3 mol/L Influent concentration of species A; may be varied
1 package VaryingVReactor
2 // Package for simulating liquid reactor with varying
volume
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // September 9 , 2015
6 // May 11 , 2017
7 //
8 model SimVaryingV Re ac tor
9 // Simulation of liquid mixing with varying volume
10 // author : Bernt Lie
11 // University of South - Eastern Norway
12 // September 9 , 2015
13 // May 11 , 2017
14 //
15 // Instantiate model of * varying volume reactor * ( vvr )
16 ModVaryingVRe ac to r vvr ;
17 // Declaring variables
18 // -- inputs
19 Real Vdi " Influent volumetric rate , L / s ";
20 Real cAi " Influent concentration of A , mol / L ";
21 // -- outputs
5.12. CASE: LIQUID PHASE, VARYING VOLUME REACTION 177
2.6
2.4
2.2
2.0
0 2 4 6 8 10 12 14
time t [s]
Figure 5.12: Influent volumetric flow rate V̇i and influent concentration cA,i .
178 CHAPTER 5. SPECIES BALANCE
0.15
0.10
0.05
0.00
0 2 4 6 8 10 12 14
time t [s]
nA (t) + a · nB (t) = nA (t = 0) + a · nB (t = 0) .
In other words, for the batch reactor, we only need one state, e.g., nA , and then nB
can be computed from nA .
1 # -* - coding : utf -8 -* -
2 """
3 Reaction invariants and variants
4
5.12. CASE: LIQUID PHASE, VARYING VOLUME REACTION 181
5 ----
6 Created on Wed Sept 09 2015
7
8 @author : berntl
9 """
10
11 from sympy import Matrix
12 #
13 # Define L matrix
14 nu = [[ -2 ,1]]
15 nu = Matrix ( nu )
16 nut = Matrix ( nu . transpose () )
17 Wri = Matrix ( nu . nullspace () )
18 Q , R = nut . QRdecomposition ()
19 Q = Matrix ( Q )
20 nr = nut . rank ()
21 #
22 # Compute ( symbolically ) basis vectors for nullspace of L
23 print " Basis ␣ for ␣ reaction ␣ invariant "
24 print Wri
25 print " # ␣ reaction ␣ variants "
26 print nr
27 print " Basis ␣ for ␣ reaction ␣ variant ␣ -␣ first ␣ columns ␣ of : "
28 print Q
leading to:
Although the output could have been more elegant, this essentially implies that
matrices
( 1 )
Wz = 2
1
( √ ) ( )
−√2 5 5 −2
Wζ = 5
∝
1
5
1
z = nA + nB
2
182 CHAPTER 5. SPECIES BALANCE
ζ = −2nA + nB
should be reaction variant. Let us insert these weight matrices, and check:
( ( 1 ))T
dz ( )
= żi − że + −2 1 · 2 rV = żi − że
dt 1
( ( ))T
dζ ( ) −2
= ζ̇i − ζ̇e + −2 1 · rV = ζ̇i − ζ̇e + 5rV .
dt 1
Hence, we see that z is reaction invariant, while ζ is reaction variant. For a batch
reactor, it follows that
dz
= 0 ⇒ z (t) = z (0)
dt
or
1 1
nA (t) + nB (t) = nA (0) + nB (0) ,
2 2
alternatively
nA (t) + 2nB (t) = nA (0) + 2nB (0) .
Similarly, for a batch reactor, it follows that
dζ
= 5rV .
dt
Simplifying the notation by using nj for nj (t), and n0j for nj (0), we have
( n )2
A
r = kc2A = k
V
while
1 1
ζ = −2nA + nB = −2nA − nA + n0A + n0B
2 2
⇓
5 1
ζ = − nA + n0A + n0B .
2 2
The differential equation for ζ thus can be rewritten as
( ) ( n )2
d 5 1 0 A
− nA + nA + nB = 5k
0
V
dt 2 2 V
⇓
5 dnA 5k 2
− = n
2 dt V A
⇓
dnA 2k
= − n2A .
dt V
This differential equation can be solved analytically by separation of variables.
5.13. CASE: LIQUID PHASE, CONSTANT VOLUME REACTOR 183
Liquid phase
fixed volume
reactor
m = ρV
ṁi = ρV̇i
ṁe = ρV̇e
leading to
d
0= (ρV ) = ρV̇i − ρV̇e ⇒ V̇i = V̇e = V̇ .
dt
n j = cj V
ṅj,e = cj V̇e = cj V̇ .
rg = ν T r,
and
rj,g = νj r
Step 3: Because Modelica supports DAE models and we use OpenModelica to solve
our model, there is little manipulation needed in formulating the complete
model. The model is
dnA
= ṅA,i − ṅA,e + ṅA,g
dt
dnB
= ṅB,i − ṅB,e + ṅB,g
dt
5.13. CASE: LIQUID PHASE, CONSTANT VOLUME REACTOR 185
where
n A = cA V
nB = cB V
ṅA,i = cA,i V̇
ṅB,i = 0
ṅA,e = cA V̇
ṅB,e = cB V̇
ṅA,g = rA,g V
ṅB,g = rB,g V
rA,g = ν1 r
rB,g = ν2 r
( )
ν = −a 1
r = kcaA .
where
( )
u = V̇ , cA,i
x = (nA , nB )
z = (cA , cB , ṅA,i , ṅB,i , ṅA,e , ṅB,e , ṅA,g , ṅB,g , rA,g , rB,g , r) .
y = (cA , cB ) .
We see that all outputs y are among the algebraic variables z, and they are
computed from the model. The model thus gives a relation between the inputs
u and the outputs.
Table 5.8: Operating conditions for liquid reactor with fixed volume.
Quantity Value Unit Comment
nA (0) 2 mol Initial number of moles of species A
nB (0) 0 mol Initial number of moles of species B
V̇ 2 mol/s Influent volumetric flow rate; may be varied
cA,i 3 mol/L Influent concentration of species A; may be varied
0.8
0.6
0.4
0.2
0.0
0 2 4 6 8 10 12 14
time t [s]
2.6
2.4
2.2
2.0
0 2 4 6 8 10 12 14
time t [s]
Figure 5.17: Volumetric flow rate V̇ through reactor, and influent concentration cA,i .
1 package FixedVReactor
2 // Package for simulating liquid reactor with fixed volume
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // September 10 , 2015
6 // May 11 , 2017
7 //
8 model SimFixedVReactor
9 // Simulation of liquid mixing with fixed volume
10 // author : Bernt Lie
11 // University of South - Eastern Norway
12 // September 10 , 2015
13 // May 11 , 2017
14 //
15 // Instantiate model of * fixed volume reactor * ( fvr )
16 ModFixedVReactor fvr ;
17 // Declaring variables
18 // -- inputs
19 Real Vd " Volumetric rate , L / s ";
20 Real cAi " Influent concentration of A , mol / L ";
21 // -- outputs
22 output Real _cA " Molar concentration of A in tank , mol / L
";
23 output Real _cB " Molar concentration of B in tank , mol / L
188 CHAPTER 5. SPECIES BALANCE
";
24 // Equations
25 equation
26 // -- input values
27 Vd = if time < 5 then 2 else 2.5;
28 // Vde = if time < 100 then 2 else 2.1;
29 cAi = if time < 10 then 3 else 2;
30 // -- injecting input functions to model inputs
31 fvr . Vd = Vd ;
32 fvr . cAi = cAi ;
33 // -- outputs
34 _cA = fvr . cA ;
35 _cB = fvr . cB ;
36 end SimFixedVReactor ;
37 //
38 model ModFixedVReactor
39 // Model of liquid reactor
40 // author : Bernt Lie
41 // University of South - Eastern Norway
42 // September 10 , 2015
43 // May 11 , 2017
44 //
45 // Parameters
46 parameter Real V = 15 " Reactor volume , L ";
47 parameter Real a = 2 " Stoichiometric constant , -";
48 parameter Real k = 0.1 " Reaction constant , ( mol / L ) ^(1 - a ) /
s ";
49 parameter Real [2] nu = { -a , 1} " Stoichiometric matrix ";
50 // Initial state parameters
51 parameter Real nA0 = 2 " Initial number of moles , species
A ; mol ";
52 parameter Real nB0 = 0 " Initial number of moles , species
B ; mol ";
53 // Declaring variables
54 // -- states
55 Real nA ( start = nA0 , fixed = true ) " Number of moles of
species A , mol ";
56 Real nB ( start = nB0 , fixed = true ) " Number of moles of
species B , mol ";
57 // -- auxiliary variables
58 Real cA " Molar concentration of species A , mol / L ";
59 Real cB " Molar concentration of species B , mol / L ";
60 Real ndAi " Influent molar flow rate of species A , mol / s ";
61 Real ndBi " Influent molar flow rate of species B , mol / s ";
62 Real ndAe " Effluent molar flow rate of species A , mol / s ";
63 Real ndBe " Effluent molar flow rate of species B , mol / s ";
64 Real ndAg " Molar rate of generation of species A , mol / s ";
65 Real ndBg " Molar rate of generation of species B , mol / s ";
66 Real rAg " Generation rate of species A , mol /( L . s ) ";
5.14. CASE: GAS PHASE REACTOR 189
where pj is the partial pressure of species j ∈ {A, B}; the reactor temperature is
constant. Influent and effluent flow rates V̇i and V̇e are proportional to the square
root of the valve pressure drops ∆pk , k ∈ {i, e}. The gas is assumed to be ideal gas.
It is of interest to study how the partial pressures pA and pB , as well as the total
pressure p varies with the influent pressure pi .
The functional diagram in Fig. 5.19 gives a compact description of the model
objective, with input pi and outputs pA , pB and p.
190 CHAPTER 5. SPECIES BALANCE
Gas reactor
Step 2: From the ideal gas law, we have for j ∈ {A, B} that
pj V = nj RT
∑
p= pj
j
∆pi = pi − p
∆pe = p − pa .
5.14. CASE: GAS PHASE REACTOR 191
300000
200000
100000
0
0.0 2.5 5.0 7.5 10.0 12.5 15.0 17.5 20.0
time t [s]
Figure 5.20: Partial pressures pA and pB and total pressure p in gas phase reactor.
Input pressure
1000000
900000
p_{\mathrm{i}}$
800000
700000
600000
500000
0.0 2.5 5.0 7.5 10.0 12.5 15.0 17.5 20.0
time t [s]
1 package GasReactor
2 // Package for simulating gas reactor
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // September 11 , 2015
6 // May 11 , 2017
7 //
8 model SimGasReactor
9 // Simulation of gas reactor
10 // author : Bernt Lie
11 // University of South - Eastern Norway
12 // September 11 , 2015
13 // May 11 , 2017
14 //
15 // Instantiate model of * gas reactor * ( gr )
16 ModGasReactor gr ;
17 // Declaring variables
18 // -- inputs
19 Real _pi " Influent pressure ( pure A ) , Pa ";
20 // -- outputs
21 output Real _pA " Partial pressure of A in reactor , Pa ";
22 output Real _pB " Partial pressure of B in reactor , Pa ";
23 output Real _p " Total pressure in reactor , Pa ";
24 // Equations
25 equation
26 // -- input values
27 _pi = if time < 8 then 10* gr . pa else 5* gr . pa ;
28 // -- injecting input functions to model inputs
29 gr . pi = _pi ;
30 // -- outputs
31 _pA = gr . pA ;
32 _pB = gr . pB ;
33 _p = gr . p ;
34 end SimGasReactor ;
35 //
36 model ModGasReactor
37 // Model of gas reactor
38 // author : Bernt Lie
39 // University of South - Eastern Norway
40 // September 11 , 2015
41 // May 11 , 2017
42 //
43 // Parameters
44 parameter Real V = 15 e -3 " Reactor volume , L ";
45 parameter Real R = 8.31 " Gas constant , J /( kmol . K ) ";
46 parameter Real T = 300 " Temperature in classroom , K ";
47 parameter Real Ki = 5e -4 " Influent valve constant , mol / s
";
48 parameter Real pa = 1.01 e5 " Atmospheric pressure , Pa ";
5.14. CASE: GAS PHASE REACTOR 195
Gas diffusion in
Liquid Pipe
We consider a liquid pipe of length L and cross sectional area A, where dissolved
gas diffuses along the x-axis, Fig. 5.22.
The influent volumetric flow rate to the pipe is V̇i , and the influent concentration
of the gas species is ρi . We seek the effluent concentration of the gas, which we will
simply denote by ρL .
The model objective is described compactly by the functional diagram in Fig.
5.23.
5.15. CASE: DIFFUSION OF GAS IN LIQUID PIPE 197
ṁj = ρj V̇j
where because of uniform velocity field, we have
V̇j = vj A.
Because of diffusion, we have
ρj vj = ρj v + Jj
where the diffusion flux Jj is assumed to follow Fick’s law,
∂ρj
Jj = −Dj .
∂x
Since no reaction is mentioned, we assume that ṁj,g ≡ 0.
Step 3.a: Next, we apply these relations to volume [ξ, ξ + ∆x]. Thus
mj = mj,ξ+∆x = ρj,ξ+∆x Vξ+∆x
Vξ+∆x = A∆x.
Furthermore,
ṁj,i = ṁj,ξ
ṁj,ξ = ρj,ξ V̇j,ξ
V̇j,ξ = vj,ξ A
ṁj,e = ṁj,ξ+∆x
ṁj,ξ+∆x = ρj,ξ+∆x V̇j,ξ+∆x
V̇j,ξ+∆x = vj,ξ+∆x A.
198 CHAPTER 5. SPECIES BALANCE
Here,
∂ρj,ξ
Jj,ξ = −Dj,ξ
∂x
∂ρj,ξ+∆x
Jj,ξ+∆x = −Dj,ξ+∆x .
∂x
∂ρj,ξ
Jj,ξ = −D
∂x
∂ρj,ξ+∆x
Jj,ξ+∆x = −D .
∂x
Step 3.b: We do need a model for all x ∈ [0, L]. To find this, we observe that
the model above can be generalized: by replacing a fixed position ξ with an
arbitrary position x, the model becomes valid for any position x ∈ (0, L); it is
not valid at x = 0 and possibly not at x = L. To answer the question about
boundary conditions, i.e., a description at x = 0 and/or x = L, it is convenient
to delay this until we have discussed the case of ∆x → 0 in Step 5.
By generalizing the above model to be valid for any x, this means that
mj,ξ+∆x (t) which only varies with t, now becomes a function of both time
and position, mj,x+∆x (t, x). Because of this, we need to change the ordinary
derivative into a partial derivative:
Thus we get
∂mj,x+∆x (t, x)
= ṁj,x − ṁj,x+∆x (5.11)
∂t
5.15. CASE: DIFFUSION OF GAS IN LIQUID PIPE 199
where
∂
(ρj,x+∆x A∆x) = ρj,x vj,x A − ρj,x+∆x vj,x+∆x A
∂t
⇓
∂
(ρj,x+∆x A∆x) = (ρj,x vx + Jj,x ) A − (ρj,x+∆x vx+∆x + Jj,x+∆x ) A
∂t
⇓
∂ρj,x+∆x
A∆x = ρj,x vx A + Jj,x A − ρj,x+∆x vx+∆x A − Jj,x+∆x A.
∂t
Here, the cross sectional area A cancels, and we can divide by ∆x and re-
arrange the model into
Step 3.c: We can relax on the assumption of the volume being homogeneous by
letting ∆x → 0:
( )
∂ρj,x+∆x ρj,x+∆x − ρj,x Jj,x+∆x − Jj,x
lim = lim −v −
∆x→0 ∂t ∆x→0 ∆x ∆x
⇓
∂ρj ∂ρj ∂Jj
= −v −
∂t ∂x ∂x
where
∂ρj
Jj = −D .
∂x
The easiest way to find the order of boundary conditions, is to consider the
∂ρ
model in steady state, e.g., when ∂tj = 0. Then we have the two equations
dρj dJj
0 = −v −
dx dx
dρj
Jj = −D
dx
which in principle can be manipulated into
( )
Jj dJj
0 = −v − −
D dx
Jj dρj
− =
D dx
or
dJj v
= Jj
dx D
dρj 1
= − Jj .
dx D
We see that we have 2 ordinary differential equations in the spatial variable,
which means that we need 2 free boundary conditions to solve the model
uniquely (or 4 — since j ∈ {1, 2}).
In this case, the equations are decoupled and can be easily solved:
dJj v (v )
= Jj ⇒ Jj = exp x Jj |x=0 , (5.12)
dx D D
then
dρj 1 1 (v )
= − Jj = − exp x Jj |x=0
dx D D D
⇓
Jj |x=0 [ ( v )]
ρj (x) = ρj |x=0 + 1 − exp x . (5.13)
v D
This steady state analysis does not tell us where the boundary conditions
should be placed, though. However, since the mass enters the pipe at x = 0,
5.15. CASE: DIFFUSION OF GAS IN LIQUID PIPE 201
it seems logical that at least one boundary condition must be put there. We
therefore propose that one boundary condition is
ρj |x=0 = ρj,i (t) . (5.14)
Inserting this boundary condition in the steady expression for ρj (x) above,
leads to the steady expression
1[ ( v )]
ρj (x) = ρj,i + 1 − exp x Jj |x=0 . (5.15)
v D
Here, we could impose some value on Jj |x=0 . Alternatively, we could observed
that (v ) ( )
vL
Jj (x) = exp x Jj |x=0 ⇒ Jj |x=0 = exp − Jj |x=L
D D
and consider
( )
exp − vL D
Jj |x=L [ ( v )]
ρj (x) = ρj,i + 1 − exp x
v D
⇓
[ ( ) ( )]
1 vL v (L − x)
ρj (x) = ρj,i + exp − − exp − Jj |x=L , (5.16)
v D D
where we impose some value on Jj |x=L . So, which is best, imposing a boundary
condition on Jj at x = 0, or at x = L? A common argument in favor of speci-
fying the boundary condition for Jj at x = L, is that this gives a “well-posed”
problem. The point is that an error in the boundary condition or parameters
propagates to ρj (x) in a “stable” way; we see that Jj |x=L is mapped to ρj (x)
via an exponential function with a negative argument − v(L−x)D
in Eq. 5.16. If
we specify the boundary condition for Jj at x = 0 instead, we see from Eq.
5.15 that Jj |x=0 propagates to ρj (x) in an “unstable” way in that errors will
be enhanced due to the positive argument Dv x of the exponential function.
To this end, we propose to specify the boundary condition for Jj at x = L. But
which value should be choose? Suppose D is very big, e.g., D → 0. This would
imply a perfect mixing in the pipe; in that case, the effluent concentration
should equal the concentration within the pipe, implying that Jj |x=L = 0. We
choose to use this boundary condition also when D is finite. This boundary
condition clearly does not imply perfect mixing when D is finite, but it is
compatible with the natural behavior of the system when D is large. Thus,
the second boundary condition is
Jj |x=L = 0. (5.17)
Since we only care about the gas species in our model, we will simplify the
notation and drop the species index j. Furthermore, we introduce that v = V̇Ai .
To this end, the complete model would be
∂ρ V̇i ∂ρ ∂J
=− − (5.18)
∂t A ∂x ∂x
∂ρ
J = −D (5.19)
∂x
202 CHAPTER 5. SPECIES BALANCE
where
Step 4: To complete the system description, we need to relate the output variable
ρL to the model variables. In this case, this is simple:
ρL = ρ (t, x = L) . (5.22)
In the sequel, we will describe a suitable DAE model based on the discussion in
Steps 3.b–4.
First, we divide the length into N slices/volumes, each of length ∆x = NL and
volume V = ∆xA. We are only interested in the gas diffusion, and thus only
formulate the model for the gas; thus we simplify the notation to mj,x → mx , etc.,
i.e., we skip species index j. We also simplify the notation of the slices from, e.g.,
mi·∆x to mi , i.e., we given the quantities in the slice number instead of specifying the
entire length of the slice. Observe that the index i now refers to the slice counter, not
to the species! We start with the mass balance as in Eq. 5.11 where i ∈ {1, . . . , N }:
d
mi = ṁi−1 − ṁi .
dt
Here,
mi = ρi Vi .
For influent, i.e., i = 0, and with constant average velocity v,
ṁi = ρi V̇i
V̇i = vA.
ṁi = ρi vi A = ρi vA + Ji A
⇓
ṁi = ρi V̇i + Ji A
5.15. CASE: DIFFUSION OF GAS IN LIQUID PIPE 203
The input variables could be the volumetric flow rate V̇i as well as influent
concentration ρi . This model can then be written in standard DAE form with
x = (m1 , m1 , . . . , mN )
z = (ρ1 , . . . , ρN , J1 , . . . , JN )
( )
u = V̇i , ρi
θ = (L, A, D, N )
y = ρL = ρN .
To complete the model description, we need to specify model parameters and
operating conditions. We choose the following parameters for the model, Table 5.11.
The operating conditions (initial state, input) are defined in Table 5.12.
204 CHAPTER 5. SPECIES BALANCE
Table 5.12: Operating conditions for study of diffusion of gas in liquid pipe.
Quantity Value Unit Comment
−3
ρj (t = 0) 5 × 10 kg/L Initial concentration of gas in slice j
mj (t = 0) ρj ∆x · A kg Initial mass of gas in slice j
−2 −2
V̇i 1 × 10 → 0.3 × 10 L/s Volumetric flow rate of mixture, varying
−3 −3
ρi 10 × 10 → 7 × 10 kg/L Influent gas concentration, varying
1 package Diffusio nG as Li qu id
2 // Package for simulating diffusion of gas in liquid pipe
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // September 14 , 2015
6 // May 11 , 2017
7 //
8 model S i m C o m p a r e D i f f u s i o n G a s L i q u i d
9 // Simulation and comparison of Diffusion of Gas in
Liquid model
10 // author : Bernt Lie
11 // University of South - Eastern Norway
12 // September 14 , 2015
13 // May 11 , 2017
5.15. CASE: DIFFUSION OF GAS IN LIQUID PIPE 205
0.008
[kg/L]
0.007
0.006
0.005
0 2 4 6 8 10 12
time t [h]
Figure 5.24: Influent gas concentration ρi (red) and resulting effluent concentration
ρL (blue); initial concentration ρ (t = 0, x) (green). N = 10 in simulations.
0.006
0.005
0.004
0.003
0 2 4 6 8 10 12
time t [h]
0.009
0.008
[kg/L]
0.007
i L (t = 0, x)
0.006 L (t = 0, x) i
(t = 0, x) i L
0.005 i L (t = 0, x)
0 2 4 6 8 10 12
time t [h]
Figure 5.26: Internal gas concentration ρj , with influent (red) and initial (green)
concentrations. N = 10 in simulations.
0.5
1.0
1.5
2.0 J1 J3 J5 J7 J9
2.5 J2 J4 J6 J8 J10
0 2 4 6 8 10 12
time t [h]
Diffusion: L depending on N
0.010
0.009
0.008
[kg/L]
0.007
0.006 i L, N = 90
L, N = 10 L, N = 300
0.005 L, N = 30
0 2 4 6 8 10 12
time t [h]
Figure 5.28: Influent gas concentration ρi (red) and resulting effluent concentration
ρL (N ), with N ∈ {10, 30, 90, 300}.
Diffusion: L depending on
0.010
0.009
0.008
[kg/L]
0.007
0.006 i
L( )
0.005 L(3 × 103 )
0 2 4 6 8 10 12
time t [h]
Figure 5.29: Influent gas concentration ρi (red) and resulting effluent concentration
ρL (D), with D ∈ {10−7 , 3 × 103 · 10−7 }.
208 CHAPTER 5. SPECIES BALANCE
14 //
15 // Instantiate model
16 M odDi ff us ion G a s L i q u i d dgl10 ( N =10) , dgl30 ( N =30) , dgl90 ( N
=90) , dgl300 ( N =300) ;
17 M odDi ff us ion G a s L i q u i d dglD1 ( D =0.01 e -5) , dglD3e3 ( D =3 e3
*0.01 e -5) ;
18 // Declaring variables
19 // -- inputs
20 Real _Vdi " Influent volumetric flow rate of mixture , L / s
";
21 Real _rhoi " Influent gas concentration , kg / L ";
22 // -- outputs
23 output Real _rhoL10 , _rhoL30 , _rhoL90 , _rhoL300 ;
24 output Real _rhoLD1 , _rhoLD3e3 ;
25 // Equations
26 equation
27 // -- setting input values
28 _Vdi = if time < 10000 then 1e -2 else 0.3 e -2;
29 _rhoi = if time < 15000 then 10 e -3 else 7e -3;
30 // -- injecting inputs to underlying model
31 dgl10 . Vdi = _Vdi ;
32 dgl30 . Vdi = _Vdi ;
33 dgl90 . Vdi = _Vdi ;
34 dgl300 . Vdi = _Vdi ;
35 dgl10 . rhoi = _rhoi ;
36 dgl30 . rhoi = _rhoi ;
37 dgl90 . rhoi = _rhoi ;
38 dgl300 . rhoi = _rhoi ;
39 dglD1 . Vdi = _Vdi ;
40 dglD3e3 . Vdi = _Vdi ;
41 dglD1 . rhoi = _rhoi ;
42 dglD3e3 . rhoi = _rhoi ;
43 // -- outputs
44 _rhoL10 = dgl10 . rho [ dgl10 . N ];
45 _rhoL30 = dgl30 . rho [ dgl30 . N ];
46 _rhoL90 = dgl90 . rho [ dgl90 . N ];
47 _rhoL300 = dgl300 . rho [ dgl300 . N ];
48 _rhoLD1 = dglD1 . rho [ dglD1 . N ];
49 _rhoLD3e3 = dglD3e3 . rho [ dglD3e3 . N ];
50 end S i m C o m p a r e D i f f u s i o n G a s L i q u i d ;
51 //
52 model Si mD if fus i o n G a s L i q u i d
53 // Simulation of Diffusion of gas in liquid
54 // author : Bernt Lie
55 // University of South - Eastern Norway
56 // September 14 , 2015
57 // May 11 , 2017
58 //
59 // Instantiate model
5.15. CASE: DIFFUSION OF GAS IN LIQUID PIPE 209
105 input Real Vdi " Influent volumetric flow rate of mixture
, L / s ";
106 input Real rhoi " Influent concentration of gas , kg / L ";
107 // Equations constituting the model
108 equation
109 // Differential equations
110 der ( m [1]) = mdi - md [1];
111 der ( m [2: end ]) = md [1: end -1] - md [2: end ];
112 // Algebraic equations
113 m [:] = rho [:]* V ;
114 mdi = rhoi * Vdi ;
115 md [:] = rho [:]* Vdi + J [:]* A ;
116 J [1] = -D *( rhoi - rho [2]) /(2* dx ) ;
117 J [2: N -1] = -D *( rho [1: N -2] - rho [3: N ]) /(2* dx ) ;
118 J [ N ] = 0;
119 end Mod Diff u si o n G a s L i q ui d ;
120 // End package
121 end Diffu si on GasLi qu id ;
5.16 Review
In this chapter, we have extended the concept of species from how it is used in
biology to denote any matter with a particular attribute. In the simplest case, we
have used it to distinguish between chemical substances which differ in molecular
formula, molecular structure, and phase.
Next, we have seen that the basic form of conservation of total mass can be
extended to mass or mole balances for each species, provided that we allow for a
generation term in the balance law. We have furthermore looked at which intensive
quantities are relevant for the species balances.
The concept of ideal gas has been extended to the case of a mixture of gases, and
as a bonus, the ideas of a cubic Equation of State has been generalized to mixtures.
A central topic in species balances, is how to express generation of species. We
have seen that for stoichiometric reactions, the reaction rates for each reaction can
be conveniently related to the rate of generation (mole per volume and time) of each
species, and thereby to the molar rate of generation.
Finally, the topic of diffusion is introduced, and Fick’s law for diffusion flux is
put in context with the species balances.
Through examples, the use of the species balances for finding concentrations
and partial pressures is illustrated through a number of examples, both with and
without a chemical reaction. The examples illustrate how DAE models easily can
be described in Modelica, and simulated using OpenModelica.
5.17 Exercises*
Solutions to these exercises are given in Appendix D.4. It is recommended to defer
looking at the solution until a serious attempt to solve an exercise has been given.
5.18. PROBLEMS 211
...under construction...
5.18 Problems
Solutions to these problems are given in Appendix E.4. It is recommended to defer
looking at the solution until a serious attempt to solve a problem has been given.
Problem 5.1. [Solution E.7 p. 590] We consider the process in Fig. 5.30.
CC
LC
In Fig. 5.30, V̇ic is volumetric flow [m3 /h] of water and catalyst. V̇iA is volumetric
flow [m3 /h] of a solution containing chemical reactant A. The concentration of A is
cA,i [mol/m3 ] in the liquid flowing into the system, and cA in the vessel itself. CC
denotes a concentration controller, and the valve signal uc to the valve governing
the feed of solution containing A, is12
uc = uc,s + Kc (cA,r − cA ) ,
where uc,s > 0 and cA,r denotes the reference value (desired value) for the concentra-
tion of A. V̇e [m3 /h] is the volumetric flow out of the vessel. LC is a level controller,
and the valve signal to the valve governing V̇e , is computed from13
uℓ = uℓ,s + Kℓ (h − hr ) ,
where uℓ,s > 0 and hr is the reference value (desired value) for the level.
12
The expression for uc is a proportional controller.
13
The expression for uℓ is a proportional controller.
212 CHAPTER 5. SPECIES BALANCE
• Rearrange the equations such that they have dh/dt and dcA /dt on the left
hand sides, and no differentials on the right hand sides.
Letting x = [h, cA ]T and u = [V̇ic , cA,r , hr , pa , pA , cA,i ]T , the model that has been
developed, can be written as
dx
= f (x, u) .
dt
• What must be known to be able to solve the model you have posed?
• Give one example of a (freely chosen) model that is not in state space form.
(Explain why your example model is not in state space form.) N
Solve the following problem using OpenModelica and/or Python.
Problem 5.2. [Solution E.8 p. 592] The system that is considered in Problem 5.1
p. 211, can be modeled as follows:
dh 1( c )
= V̇i + V̇iA − V̇e
dt A
dcA 1 A 1 ( A )
= V̇i cA,i − V̇i + V̇ic cA − kcA
dt Ah Ah
with algebraic equations
√
A pA − pa
V̇i = Kv,A uc
ρ
√
V̇e = Kv,e uℓ gh
and:
uc = uc,s + Kc (cA,r − cA )
uℓ = uℓ,s + Kℓ (h − hr ) .
5.18. PROBLEMS 213
Table 5.13: Numerical values for parameters and operating points for the model of
Problem 5.1/5.2.
Numerical values Units Description
A = 10 m2 cross sectional area of vessel
−2
g = 9.8 ms √ gravitational acceleration
3 −1 3 −1
Kv,A = 1 m h √ bar m kg valve constant
3 −1 2 −2
Kv,e = 1 mh ms valve constant
Kc = 100 m3 /mol proportional gain
−1
Kℓ = 100 m —”—
uc,s = 0 – constant offset in controller
uℓ,s = 0 – constant offset in controller
ρ = 1000 kg/m3 density of liquid
k=1 h−1 reaction rate constant
h|t=0 = 2.11 m initial value, h
−2
cA |t=0 = 1.5 × 10 mol/m 3
initial value, cA
V̇ic = 50 m3 /h volumetric flow
−2 3
cA,r = 10 mol/m reference value for cA
hr = 2 m reference value for h
pa = 1 bar atmospheric pressure
pA = 3 bar feed pressure, solute
cA,i = 5 − 3H1 h mol/m3 time varying feed concentration
• Use the numerical values and operating conditions in Table 5.13, and simulate
the system over a period of 3 h. If you choose to use a fixed step-length routine,
you can perhaps use a step length of ∆t = 2 × 10−2 h.
• Notice that with the numerical values in Table 5.13, uc may be negative in
some periods of time. This doesn’t really make sense, since it means that
liquid is sucked out of the vessel. A simple solution is to insert a test in the
MATLAB function where the model is defined, and ensure that uc = 0 if the
P-controller states that uc < 0. This can be achieved by a simple if test in
MATLAB.
Regarding the time varying cA,i , e.g., let cA,i drop from 5 to 2 mol/m3 after
1 h. N
214 CHAPTER 5. SPECIES BALANCE
Chapter 6
Momentum balance
• What extensive and intensive quantities are relevant for the momentum bal-
ance?
ma = F
where m is a fixed mass, a is the acceleration and F is the net (linear) force working
in the same direction as the acceleration vector a. With fixed mass, we can instead
introduce the (linear) momentum m defined as
m , mv
Newton’s law can thus be considered a (linear) momentum balance for a closed
system, i.e., a system with fixed mass. The net force F can include conservative
forces Fc such as gravitation, spring force, etc., and non-conservative forces Fnc such
as friction, freely varying input forces, etc. A characteristic of a conservative force
is that it can be written as the negative gradient of a potential function P which
only depends on the position,
Fc = −∇P ,
or in the case of a one-dimensional variation where position x is related to the linear
velocity v as dx
dt
= v:
∂P
Fc = − .
∂x
It follows that in the one-dimensional case,
ˆ
P = − Fc dx
where P (x = 0) can be chosen arbitrarily. The potential function P has the di-
mension of energy. Non-conservative forces Fnc can not be derived from a potential
function.
It is commonly assumed that a friction force Ff depends on the velocity v = dx
dt
,
e.g., as
Ff = −kv 2
or perhaps rather
Ff = −k |v| v
for the case that the movement may change direction. It may be possible to define
a pseudo-potential Pp as a function of the velocity, and define
∂Pp
Ff = − .
∂v
However, a function of the velocity does not count as a true potential; a true potential
can only depend on the position x.
m = mv = mωr,
6.2. MATERIAL DESCRIPTION 217
Figure 6.1: Torque T is the vector cross product of radius r and force F according
to the right hand rule of vector cross product, and leads to a rotation indicated by
angular velocity ω. The indicated right angles are not required for the cross product
to work, but simplifies things in that for right angles, |T | = |r| · |F |.
Figure 6.2: Mass m circulating around axis at angular velocity ω, with constant
radius r, and influenced by force F .
218 CHAPTER 6. MOMENTUM BALANCE
which implicitly defines J. For a distributed mass in a rigid body, the summation
is replaced by an integral.
To this end, we thus consider a rigid system which rotates around an axis at
angular velocity ω. Parallel to Newton’s law/the linear momentum balance, we can
thus introduce an angular momentum a given as
a = Jω
where J is the angular moment of inertia. The angular momentum balance for a
fixed mass system is then
da
=T
dt
where T is the torque; typically, the torque is given as a force F multiplied with a
lever distance r, i.e., T = r · F where r ⊥ F ; in the notation of calculus, T = r × F
where × is the vector cross product.
Just like with forces, we can introduce conservative and non-conservative torques
where a conservative torque Tc can be derived as the negative gradient of a potential
P which only depends on the angle:
Tc = −∇P
or in the one-dimensional case where angle α is related to the angular velocity ω as
dα
dt
=ω
∂P
Tc = − .
∂α
It follows that in the one-dimensional case,
ˆ
P = − Tc dα
1
In some literature, the angular moment of inertia is denoted I.
6.2. MATERIAL DESCRIPTION 219
Figure 6.3: Conservative forces Fg due to gravitation (left) and Fs due to spring
elongation (right).
where P (α = 0) can be chosen arbitrarily. The potential function P has the dimen-
sion of energy. Non-conservative torques Tnc can not be derived from a potential
function.
However, similar to the case of linear momentum, it is common to introduce
a friction torque Tf which depends on the angular velocity ω, e.g., Tf = −kω 2 or
Tf = −k |ω| ω. In this case, it may also be possible to define a pseudo potential Pp
such that
∂Pp
Tf = − ;
∂ω
this pseudo-potential is not a true potential since it depends on the angular velocity
ω and not on the angle α.
dPg
Fg = −
dy
⇓
dPg
−mg = −
dy
⇓
dPg = mgdy
⇓
Pg (y) − Pg (y0 ) = mg (y − y0 ) .
220 CHAPTER 6. MOMENTUM BALANCE
Here, we are free to choose y0 to be any position, and we can choose Pg (y0 ) freely
— the simplest is often to set Pg (y0 ) = 0 and y0 = 0, thus
Pg (y) = mgy.
Fs = ks (y0 − y) ,
where ks is the spring constant, y is the length of the spring, and y0 is the length
of the spring at rest. If y < y0 , the spring will push outwards — in the indicated
direction of Fs . For the spring, the potential energy becomes
dPs 1
= −ks (y0 − y) ⇒ Ps (y) = ks (y − y0 )2 + P (y0 ) .
dy 2
Here, y0 , the spring elongation at rest, can not be chosen freely; y0 is a spring model
parameter. However, P (y0 ) can be chosen freely, and it is common to set it to zero
and let the potential energy of the spring be
1
Ps (y) = ks (y − y0 )2 .
2
Similarly, we can model the torque of a torsional spring as
Ts = κs (α0 − α) ,
dm1
= −F1 + F2
dt
dm2
= −F3 + F4 .
dt
Forces F2 and F3 are the forces of interaction between systems S1 and S2 . According
to Newton’s third law, these are identical in quantity, and oppose each other:
F2 = F3 .
dm
= −F1 + F4 ;
dt
again, we see that the internal contact forces F2 and F3 cancel and does not have
an effect on the total system.
The idea behind Newton’s third law is analogous to the idea for the flow system
that ṁ2 + ṁ3 = 0.
1
K = mv 2 ,
2
222 CHAPTER 6. MOMENTUM BALANCE
E = K + P,
Ẇ = F vy .
x = ℓ sin α
y = −ℓ cos α.
It follows that
dx dα
vx = = ℓ cos α
dt dt
dy dα
vy = = ℓ sin α,
dt dt
and ( )2
2 dα
v = vx2 + vy2 = ℓ2 .
dt
We then have the total energy expressed as
( )2
1 dα
E= m ℓ2 − mgℓ cos α
2 dt
while
dα
Ẇ = F vy = F ℓ sin α.
dt
dE
For the energy balance, = Ẇ , we find
dt
( ( )2 )
dE d 1 dα
= m ℓ2 − mgℓ cos α
dt dt 2 dt
dα 2 d2 α dα
=m ℓ 2
+ mgℓ sin α,
dt dt dt
and then
dE
= Ẇ
dt
⇓
dα d2 α dα dα
m ℓ2 2 + mgℓ sin α = F ℓ sin α
dt dt dt dt
⇓
( )
dα d2 α dα
mℓ2 2 + mgℓ sin α = F ℓ sin α.
dt dt dt
6.3. SPATIAL DESCRIPTION 225
The physical law governing the movement must be valid for any (angular) ve-
locity dα
dt
, thus we can divide by dα
dt
to get at:
d2 α
mℓ2 + mgℓ sin α = −F ℓ sin α
dt2
⇓
2
dα g F
2
= − sin α − sin α. (6.2)
dt ℓ mℓ
The pendulum model in Eq. 6.2 can be rewritten in state space form as
dα
=ω (6.3)
dt
dω g F
= − sin α + sin α (6.4)
dt ℓ mℓ
where g is a natural constant, m, ℓ are parameters, F is a variable input, while α, ω
are states. N
We are now interested in extending the momentum balance to the case of a spatial
description, where we allow for mass to flow into and out of the system. The
extension is straightforward, and the general momentum balance becomes
dm
= ṁi − ṁe + F . (6.5)
dt
As we have seen, the momentum is
m = mv, (6.6)
where m is the (possibly varying) mass and v is the linear velocity. The linear
velocity v is an intensive variable, while the mass is an extensive variable. It follows
that the momentum flowing with matter is given as
ṁ = ṁv, (6.7)
where ∂V is the surface of the system and n is the outwardly pointing normal vector
to the surface. However, in these notes, we will use the simple formulation where
ṁ = ṁv.
Some of the force terms F relate to forces operating on the boundary ∂V of the
system, e.g., pressure forces. Other force terms operate within the system volume
V , e.g., gravity, friction, etc. The forces operating within the system volume V
are considered as source terms in the balance law, hence the momentum balance is
strictly speaking not a conservation law as defined in these notes.
Similarly, we can introduce an angular momentum balance in a spatial descrip-
tion, which takes the form
da
= ȧi − ȧe + T (6.8)
dt
where the angular momentum is
a = Jω (6.9)
Here, if the material influent is given at a fixed radius and tangential to the radius,
we have
ȧ = r · ṁ. (6.10)
where energy E is the sum of kinetic and potential energy, E = K + P , and where
kinetic energy K can come from linear movement, K = 12 mv 2 , or angular movement,
K = 12 Jω 2 , while the work rate is related to generalized force multiplied by gener-
alized velocity: Ẇ = F v for linear movement and Ẇ = T ω for angular movement.
Potential energy P describes the potential of those conservative forces that are not
included in the work rate term Ẇ .
In a spatial description, we need to include the possibility of a change of mass
within the system boundaries as well flow of energy transported by mass flow. Thus,
the mechanical energy balance changes to
dE
= Ėi − Ėe + Ẇ (6.11)
dt
where Ė = K̇ + Ṗ . By comparing the expression for linear kinetic energy K = 12 mv 2 ,
we can express kinetic energy flow rate as
1 1 1
K̇ = ṁv 2 = ṁv · v = ṁv.
2 2 2
Similarly, we could have a potential energy, say P = mgz, with potential energy
flow rate Ṗ = ṁgz. In both cases, it is an underlying assumption that the mass
flow ṁ enters the system. If the mass flow rate ṁ instead hits the system boundary
and creates a force F working on the system, this effect should be included in the
work term as Ẇ = F v.
Similarly, for angular movement, the kinetic energy K = 12 Jω 2 = 12 aω should
give rise to a convective kinetic energy flow rate as
1
K̇ = ȧω. (6.12)
2
Here,
ȧ = rṁ = rṁv.
Similarly, we could envision a potential energy flow Ṗ . Again, it is an underlying
assumption that the mass flow ṁ enters the system.
The mechanical energy balance for angular movement is commonly used for
turbo machines. In that case, a fluid moving with mass flow rate ṁ hits blades of an
object rotating with angular velocity ω. However, the fluid mass does not become
part of the rotating mass, hence for turbo machines, K̇ ≡ 0, and normally the
level difference zi − ze is so small that we can neglect Ṗ . Furthermore, the moving
fluid hits (or leaves) the blades of the rotating mass at a radius r with a torque
T = ȧ = rṁt where ṁt is the projection of momentum flow rate of the moving fluid,
ṁ = ṁv, on the direction tangential to the rotation. Thus, ṁt = ṁv t — where it has
been assumed that the mass flow rate ṁ actually is tangential to the rotation and
parallel to v, but where subscript t has been added to v t for clarity. The resulting
work rate is Ẇ = T ω. Introducing the “reference” velocity of the rotating object at
the “point of attack”, vρ = rω, the work rate can be written as
Ẇ = T ω = ωr · ṁt = vρ · ṁv t . (6.13)
As stated above, vρ is the reference velocity of the rotating object (the turbine mass,
etc.), while ṁ and v t refer to the flow of the fluid hitting (or leaving) the rotating
object.
228 CHAPTER 6. MOMENTUM BALANCE
6.4 Friction
6.4.1 Friction and pressure drop in filled pipes
6.4.1.1 Overview of friction force
The friction force Ff is directed in the opposite direction of the velocity v of the
fluid. A common expression for friction force in filled pipes is the following:
Ff = K ′′′ Aw f. (6.14)
Figure 6.6: Moody diagram for Fanning’s friction factor f for fluid flow in a pipe,
as a function of the Reynolds number NRe , Bird et al. (2002).
Ff = τw Aw .
It follows that τw has the same direction as Ff . Shear stress τw is a function of the
local velocity gradient of the fluid at the wall. For a straight, cylindrical pipe, the
∂v
relevant
( ∂v ) gradient is the gradient in the radial direction, thus τw is a function of ∂r ;
τw ∂r . For rigid walls, it is common to assume that the velocity at the wall is zero
— this indicates that the velocity decreases when the radius approaches the wall,
hence the gradient is negative at the wall and hence has the same direction as τw .
From thermodynamics, it can be shown that friction leads to a mechanical power
“production” Ẇf given by
∂v
Ẇf = −τw · .
∂r
( )
For non-elastic fluids, the functional relationship τw ∂v ∂r
is static. Then, the second
law of thermodynamics (entropy production) dictates that Ẇf ≤ 0, in other words:
friction leads to a loss of mechanical power5 for non-elastic fluids. ( ∂v )
It is straight forward to see that in general, function
( )τ w ∂r
must lie in the
first and third quadrant of the coordinate system of ∂v , τ . The simplest possible
( ∂v ) ∂r w
choice of τw ∂r that guarantees a negative Ẇf , is
∂v
τw = µ (6.16)
∂r
leading to ( )2
∂v
Ẇf = −µ ;
∂r
here Ẇf is guaranteed to be negative (and thus produce entropy) provided that
the proportionality factor µ > 0. Quantity µ is known as (dynamic) viscosity, and
the expression in Eq. 6.16 is known as Newton’s shear stress law; fluids for which
Newton’s shear stress law is valid, are known as Newtonian fluids.
Some fluids show viscoelastic behavior, where there is a dynamic relationship for
the shear stress, e.g., as in the Maxwell model:
( )
dτw 1 ∂v
= −τw − µ ;
dt Tr ∂r
here, Tr is the relaxation time and µ is the viscosity. Realistic viscoelastic mod-
els may be considerably more complicated than the Maxwell model. Examples of
4
Ad hoc: Latin expression, literally meaning “to this” (ad = to, hoc = this). The expression is
used in the meaning “temporary”, “informal”, or “arranged for a particular purpose”, as opposed
to a “formal and general treatment”. So far, we have used a temporary and simplified description
of friction force (ad hoc); now it is time for a more general treatment.
5
The lost mechanical power does not disappear: it leads to a heating of the fluid/wall.
6.4. FRICTION 231
viscoelastic fluids include, e.g., molten polymers. For viscoelastic fluids, the in-
stantaneous friction power Ẇf may break the second law of thermodynamics during
transients and may even become positive, but in steady state all systems must satisfy
Ẇf ≤ 0.
Figure 6.7: Measuring pressure drop ∆pf = p1 − p2 due to friction, using a manome-
ter.
Ff Aw πDL L 1 L
∆pf = = τw = K ′′′ f D2 = 4K ′′′ f L = 4 ρv 2 f
A A π 4 D 2 D
⇓
∆pf ρ v2
= 4f . (6.20)
L 2D
Comparing Eqs. 6.19 and 6.20 gives
fD = 4f. (6.21)
Because two different friction factors are used in the literature, it is important
to know which friction factor is involved in the relevant friction factor model, and
make sure that the correct factor is used in the chosen friction force expression.
where vm is the maximal velocity found in the center, r is the distance from the
pipe center, and R is the pipe radius. Laminar flow can be expected for 0 < NRe <
2.1 × 103 , and it can be shown that with NRe = ρ⟨v⟩D
µ
,
64 16
fD = ⇔f = , (6.22)
NRe NRe
4 K ′′′ 1
ρ ⟨v⟩2 8 ρ ⟨v⟩2
= = 2
⇒ =
fD τw τw fD τw
or √
8 ⟨v⟩ ⟨v⟩
=√ = .
fD τw /ρ vτ
√
Here, vτ = τw /ρ is known as the shear velocity or friction velocity. By observing
that Reynolds’ number NRe = ρ⟨v⟩D µ
µ
is dimensionless, it follows that ρ⟨v⟩ has unit
µ
length and thus also ρvτ has unit length. We can then introduce some dimensionless
234 CHAPTER 6. MOMENTUM BALANCE
quantities:
v
v̄ ,
vτ
R D
ρ ⟨v⟩ D vτ NRe vτ
R̄ , = 2
= · =
µ
ρvτ
µ
ρvτ
µ 2 ⟨v⟩ 2 ⟨v⟩
y
ȳ , µ ;
ρvτ
here, R̄ is the von Kármán number (or rather: the von Kármán distance) and
y = R − r; we see that Ry = R̄ȳ and it is clear that τw , hence vτ , is independent of r
or y. It follows that10
´R ´0 ˆ 1 (
2π 0 v (r) rdr v (y) · (R − y) dy y) (y)
⟨v⟩ = = −2 R
=2 v (y) 1 − d
πR2 R2 0 R R
⇓
ˆ 1 ( ∗) ( ) ( ∗)
⟨v⟩ ∗ y y∗ y
=2 v · 1 − d . (6.23)
vτ 0 R∗ R∗ R∗
Power laws for v̄ have been popular. One possible model is the one-seventh
power law:
( ȳ )1/7
v̄ = k · ȳ = k · R̄
1/7 1/7
R̄
which leads to
8 1
fD = ( )7/4 1/4
;
98k N
120·21/7 Re
see Exercise 6.3. By curve fitting to data for a smooth pipe, Blasius11 found (ca.
1913) k = 8.56, leading to
0.316 0.079
fD = 1/4
⇔f = 1/4
, (6.24)
NRe NRe
which gives a good description for NRe ∈ (2.3 × 103 , 105 ).
For higher Reynolds numbers and a smooth pipe, Blasius’ expression is not that
good. An improved model for v̄ could then be the “law of the wall” proposed by
von Kármán12 in 1930:
1
v̄ = ln (ȳ + ā) + C̄ (6.25)
κ
where κ is the von Kármán constant, ā = aµ is an offset parameter, while C̄ is an
ρvτ
additive constant, McKeon et al. (2005). In von Kármán’s version, ā ≡ 0, leading
to (
√ √ ) ln(10)
√
1 2·2 2 4κ 2 3 −κC̄
= −2 · log10 · 10 4κ 2 ,
2 √
√ (6.26)
fD NRe fD
10
See Exercise 6.1.
11
Paul Richard Heinrich Blasius, 1883–1970.
12
Theodore von Kármán, 1881–1963 was a PhD student of Prandtl.
6.4. FRICTION 235
see Exercise 6.4. Assuming that C̄ is independent of NRe and fD , Prandtl13 found
from curve fitting with the data of Nikuradse (see below) that
ln (10) ln (10)
√ = 1 ⇒ κ = √ ≈ 0.4070
4κ 2 4 2
and
√ 3 −κC̄
2 √
4 2 · 10 4κ 2 ≈ 2.51
⇓
( )
3 √ 2.51
C̄ = − 4 2 · log10 √ ≈ 5.6814,
2κ 4 2
thus √ ( )
1 2.51 1
= −2 · log10 ·√ . (6.27)
fD NRe fD
A modification of Prandtl’s fitting has later been suggested as (Coelho & Pinho
2007) √ ( )
1 2.825 1
= −2 · log10 ·√ . (6.28)
fD NRe fD
McKeon et al. (2005) suggest that for NRe ∈ (3.1 × 105 , 1.8 × 107 ), a better expres-
sion is
√ ( ) ( )
1 1 1 1.8557
= −1.93 log10 √ − 0.537 = −2 log10 ( √ )0.965 . (6.29)
fD NRe fD NRe fD
To this end, Colebrook proposed the following merging of the von Kármán–Prandtl
model with Nikuradse’s model:
( )
1 2.51 1 ϵ/D
√ = −2 · log10 ·√ + , (6.31)
fD NRe fD 3.71
which can be trivially modified, e.g., by replacing factor 2.51 with 2.825 (Coelho
& Pinho 2007) or by using the expression of McKeon et al. (2005). Colebrook’s
relation is in general taken to be valid for 2.3 × 103 < NRe < 108 .
As an extension of the above idea, we observe that
k k
k log10 f (x) = p log10 f (x) = log10 f (x)p .
p p
It follows that we could more generally write
k
F (x) = log10 (f1 (x)p + f2 (x)p )
p
where p > 0, and where a large value for p (p > 1) gives a more abrupt transition
between f1 (x) and f2 (x). Thus, we could generalize Colebrook’s model to
(( )p ( )p )
1 2 2.51 1 ϵ/D
√ = − · log10 ·√ + (6.32)
fD p NRe fD 3.71
Here,
∂f 2a (aT )p−1
=1+ · .
∂T ln 10 (aT )p + bp
It follows that the Newton scheme for our generalized Colebrook relation is
(( )p ( ) )
p
√ 1
(i)
+ 2
p
· log 10
2.51
NRe
√ 1
(i)
+ ϵ/D
3.71
1 1 f fD
√ =√ − D ( )p−1 ,
(i+1) (i) 2.51 √1
fD fD 2· 2.51 NRe (i)
·(
f
1 + lnN10 Re ) D
p
2.51 √1 ϵ/D p
NRe
+( 3.71 )
(i)
f
D
Merging this expression with the von Karman expression similar as to Colebrook’s
approach, we get
(( )0.875·p ( )p )
1 2 5.5292 ϵ/D
√ ≈ − · log + . (6.36)
fD p NRe 3.71
Figure 6.8: x, W relation between x and the Lambert “function” W showing two
branches (functions) W−1 (x) and
[ W0 (x). ) The so-called principal branch W0 can
−
be split into W0 valid for x ∈ − exp(1)
1
, 0 and W0+ valid for x ≥ 0. From Brkić
(2011a).
In general, W and x can be complex numbers, but here, x is a real number, and
W is a real number. The pair (x, W ) constitute a relation,18 see Fig. 6.8.
[ )
W (x) is a relation since W (x) is two-valued in the region x ∈ − exp(1)
1
, 0 . The
principal branch W0 (x) (Fig. 6.8) is a strictly increasing function.
From Theorem 6.1, we see that both x and W must be positive numbers, hence
18
Relations are generalizations of functions to allow for multi-valued mappings.
242 CHAPTER 6. MOMENTUM BALANCE
we are interested in the function W0+ (x), where W0+ (0) = 0. Recursively, we have
W · exp (W ) = x
⇓
W = x · exp (−W )
⇓
W = x · exp (−x · exp (−W ))
⇓
W = x · exp (−x · exp (−x · exp (−x · (· · · )))) ;
it can be shown that when x → 0, this recursion can be truncated to give an
approximation of W (x) (Barry et al. 1995). If we instead are interested in large
values of x (x → ∞), we can instead rewrite the expression as
W · exp (W ) = x
⇓
exp (ln W ) · exp (W ) = x
⇓
exp (ln W + W ) = x
⇓
x
W = ln x − ln W = ln
W
⇓
x
W = ln x .
ln ln x
x
ln ···
2. Next, with x known, compute W (x), e.g., via the approximation W0+∗2 (x),
Eq. 6.38.
6.4. FRICTION 243
which gives rise to 4 linear equations in the four unknowns (a, b, c, d).
In some cases where a “global” expression for fD could be useful, the average
velocity will oscillate around zero, i.e., change direction.19 With ⟨v⟩ → 0 ⇒ fD →
∞, which is not really useful. Instead, it is better to consider the friction force
directly:
1 Aw
∆pf = Ff = τw .
A A
where we utilized that
1
τw = f · K ′′′ = fD K ′′′ .
4
Aw πDL 4L
With a cylindrical pipe, we have A
= 2 = D
, and it follows that
π D4
L ′′′
∆pf = fD K .
D
Inspired by this, we could write the friction pressure drop as
L
where dimensionless factor ϕ is ϕ = fD D for a long, straight pipe. We will refer to
ϕ as the generalized friction factor.20
What if we instead of a long, straight pipe have various contractions, enlarge-
ments, bends, etc.? It turns out that we for those cases also can write the pressure
drop as in Eq. 6.41. Tables 6.3–6.4 illustrate some cases.
Table 6.3: Generalized friction factor ϕ for various fittings, valves, etc. For Reynolds
number NRe and Darcy friction coefficient fD , this refers to the entrance velocity ⟨v⟩1
and diameter D1 . See also Table 6.4. Taken from https://neutrium.net/fluid_flow
/pressure-loss-from-fittings-expansion-and-reduction-in-pipe-size/.
Square reduction Square expansion
Table 6.4: Generalized friction factor ϕ for various fittings, valves, etc. For Reynolds
number NRe and Darcy friction coefficient fD , this refers to the entrance velocity ⟨v⟩1
and diameter D1 . See also Table 6.3. Taken from https://neutrium.net/fluid_flow
/pressure-loss-from-fittings-expansion-and-reduction-in-pipe-size/.
Rounded reduction Rounded expansion
( ) [( )4 ]
ϕrr = 0.1 + 50
NRe
D1
D2
−1 ϕre = ϕse
Sharp orifice Thick Orifice
D2
ϕso = 2.72 + D1 120
NRe
− 1 · ϕ0so ϕto = 0.584 + (
L
0.0936
)1.5 · ϕso
D2
+0.225
NRe ≥[2500: ]
L
> 5:
( )2 D2
Here, Ffs′ is the (steady) friction force per unit length of the channel, ρ is the density
of the liquid, g is gravity, and As is the cross sectional area of the liquid in the
channel; Fig. 6.9.
For open channel flow of Newtonian liquids, it is common to describe the friction
slope Sfs using the Gauckler–Manning–Strickler formula
1 1
Ffs = Ks′′′ As f = ρvs2 ℘s Lf ⇒ Ff′ = ρvs2 ℘s f ,
2 2
thus the friction slope from this expression is
Ffs′ 1
ρv 2 ℘s f f vs2 ℘s
Sfs = = 2 s = .
ρgAs ρgAs 2g As
f
2
kM ≈ .
2g
248 CHAPTER 6. MOMENTUM BALANCE
Some typical values for Manning’s friction factor are given in Table 6.5.21
When used for flow of water in rivers, Manning’s friction coefficient kM typically
varies from 0.03 in clean and straight river beds to 0.06 for poorly conditioned
channel beds. A typical value for Fanning’s friction factor under turbulent flow in
hydraulically
√ smooth pipes is f ∈ [0.002, 0.005], Bird et al. (2002), which would lead
to f
∈ [0.01, 0.016]. For turbulent flow in less smooth pipes, the Fanning friction
2g
√
f
factor f can have a value of up to 0.01, which would lead to 2g
= 0.02 Thus,
values for Manning’s friction coefficient appear to be compatible with Fanning’s
friction factor.
Ẇ
= f (NRe )
ρDi5 ṅ3i
where Ẇ is the power consumption used for agitating the liquid tank, ρ is the liquid
density, Di is the impeller diameter, and ṅi is the number of revolutions per time unit
of the impeller. f is a friction factor (“power number”) and the Reynolds number
for agitation is22
ρṅi Di2
NRe =
µ
Figure 6.10 shows the agitation friction factor (“power number”) for some im-
peller geometries.
1 # -* - coding : utf -8 -* -
2 """
3 Created on Thu Feb 09 23:57:41 2017
4
23
L is pipe diameter for friction of flow in a circular pipe, sphere diameter for drag on spheres
in a flow, etc.
252 CHAPTER 6. MOMENTUM BALANCE
102
(T) [cSt]
101
5 @author : Bernt_Lie
6 """
7 import numpy as np
8 import matplotlib . pyplot as plt
9 #
10 NU = np . array ([[2130 ,2300 ,2357] ,
11 [500 ,480 ,600] ,
12 [100 ,90 ,150] ,
13 [14.3 ,11.5 ,24.3] ,
14 [5.1 ,3.9 ,8.] ,
15 [1.9 , np . nan ,2.6]])
16 T = np . array ([ -65 , -40 ,0 ,100 ,210 ,400])
17 T = (T -32) *5/9;
18 #
19 plt . semilogy (T , NU [: ,0] , ’k - ’ , label = " Univis ␣J -43 " )
20 plt . semilogy (T , NU [: ,1] , ’b : ’ , label = " Skydrol ␣ 500 A " )
21 plt . semilogy (T , NU [: ,2] , ’r - - ’ , label = " Oronite ␣ 8315 " )
22 plt . xlabel ( r ’ $T$ ␣ [ $ {}^\ circ$C ] ’)
23 plt . ylabel ( r ’$ \ nu ( T ) $ ␣ [ cSt ] ’)
24 plt . title ( r ’ Kinematic ␣ viscosity ␣ $ \ nu$ ␣ as ␣ a ␣ function ␣ of ␣
temperature ␣ $T$ ’)
25 plt . grid ( True )
26 plt . legend ()
Typical kinematic viscosity values for operating hydraulic fluids thus appear to be
6.6. HYDRAULICS AND SERVO CONTROL+ 253
We then find
dρ = ρ (βT dp − αp dT ) .
1 ◦ −1
A typical value of thermal expansion coefficient αp is αp ≈ 1200 C , Merritt (1967).
This implies that the density varies less than 10% with a temperature variation of
100 ◦ C. In the sequel, thermal effects will be neglected, leading to
dρ = ρβT dp
and we will assume that βT is constant.25 This implies that under a change in
pressure from a nominal pressure p0 to pressure p, the density changes from ρ0 to
density ρ = ρ0 [1 + βT (p − p0 )].
A typical value of isothermal bulk modulus is β1T ≈ 3 × 105 psi ≈ 20 kbar. In
practice, however, a smaller bulk modulus/larger isothermal compressibility factor
is observed — both because air is trapped in the hydraulic fluid, but also because
high pressures may cause the system volume to change slightly. Air will be both
dissolved in the hydraulic fluid, i.e., be present in liquid form, but air bubbles will
also be present. Dissolved air will not have much effect, but entrapped air in gas
form does.
24
See Section 7.8 for a more detailed treatment of thermodynamics.
25
Observe that the (isothermal) bulk modulus β in Merritt (1967) is the inverse of the isothermal
compressibility βT used here.
254 CHAPTER 6. MOMENTUM BALANCE
In the case of ideal gas, it can be shown that βT,g = p1 , Ex. 7.2 p. 379. Let the
volume fraction of air in the fluid be ξ, thus we can express the efficient isothermal
compressibility factor as
ξ
βT,e = (1 − ξ) βT,ℓ + .
p
1 1
= = 2.98 kbar ≈ 3 kbar,
βT,e (1 − 0.01) · 1
20×103
+ 0.01 · 1
35
1 1
= = 1.10 kbar.
βT,e (1 − 0.03) · 1
20×103
+ 0.03 · 1
35
N
If we also take into account the effect of the pressure on the volume, the efficient
isothermal compressibility factor can be written as
ξ
βT,e = (1 − ξ) βT,ℓ + + βT,V
p
1 E (Do − Di ) (Do + Di )
= · ,
βT,V 2 (1 + νP ) Do2 + (1 − νP ) Di2
Merritt (1967), where E is the Young modulus26 of the material, νP is the Poisson
ratio27 of the material, while Do and Di are the outer and inner diameters of the
cylinder, respectively. For homogeneous, isotropic materials, it can be shown that
3
Ehi = (1 − 2νP ) .
βT
6.6. HYDRAULICS AND SERVO CONTROL+ 255
Table 6.6: Bulk modulus, Poisson ratio and Young modulus for selected materials.
Material Aluminum alloy Stainless steel Cast iron
Bulk modulus β1T [GPa] [68, 70] 163 [58, 107]
Poisson ratio νP [–] 0.32 [0.27, 0.30] [0.21, 0.26]
Young modulus E [GPa] 70 180 82
Homogeneous-isotropic [73, 76] [196, 225] [83, 154]
assumption Ehi [GPa]
Thus, for the thick-walled case, the result is very similar to the case of a rigid volume.
If we instead assume a thin-walled cylinder where the pipe diameter is six times
the wall thickness, ∆R
D
= 16 , we find
1 1
= = 2.96 kbar ≈ 3 kbar,
βT,e (1 − 0.01) · 1
20×103
+ 0.01 · 1
35
+ 6
200×104
and we still see that the volume flexibility plays a minor role compared to the role
of the entrapped air. N
(a)
Figure 6.12: Flow through an orifice: (a) laminar flow, and (b) turbulent flow.
We can formulate a steady energy balance with influent at position “1” and
effluent at position “2”. With horizontal flow, we have
K̇1 + p1 V̇1 = K̇2 + p2 V̇2
where flow of kinetic energy is
1
K̇j = ṁj vj2 ;
2
V̇j
in steady state, ṁ1 = ṁ2 = ṁ, while vj = Aj
, ṁj = ρV̇j and pj is the pressure. This
leads to
1 V̇ 2 1 V̇ 2
ρV̇ 2 + p1 V̇ = ρV̇ 2 + p2 V̇
2 A1 2 A2
⇓
( )
ρ 1 1
2
− 2 V̇ 2 = p1 − p2
2 A2 A1
or
√ √
A21 − A22 2
V̇ = (p1 − p2 )
A21 A22 ρ
⇓
√
A2 2
V̇ = √ ( )2 (p1 − p2 ).
ρ
1− A 2
A1
6.6. HYDRAULICS AND SERVO CONTROL+ 257
Because of viscous friction, the flow rate is usually slightly smaller by a factor
Cv = 0.98;
√
Cv A 2 2
V̇ = √ ( )2 ρ (p1 − p2 ).
1− A A2
1
It is inconvenient to operate with the stream line constricted area A2 , Fig. 6.12. A
common assumption is that A2 = Cc A0 , leading to
√
Cc Cv A0 2
V̇ = √ ( )2 (p1 − p2 )
ρ
1 − CAc A1 0
For sharp-edged orifices and turbulent flow where A0 ≪ A1 , it can be shown that
π
Cc = π+2 ≈ 0.611. Introducing the discharge coefficient Cd defined as
Cc Cv
Cd , √ ( )2 ,
1 − A1
Cc A 0
πb2 w
V̇ = (p1 − p2 ) .
32µ
258 CHAPTER 6. MOMENTUM BALANCE
spool
house
land head
side
Supply
Servo valve
rod
Return side
Figure 6.13: Servo valve and piston: (a) three-land-four-way spool valve, (b) piston.
Valve drawing based on Merritt (1967), with modified notation.
6.6. HYDRAULICS AND SERVO CONTROL+ 259
If we assume a perfectly symmetric valve around the middle land so that the
valve orifice areas As,1 (xs ) = Ar,2 (−xs ) = A (xs ), we find that for xs ≥ 0:
√
2
V̇s,1 = Cd A (xs ) (ps − p1 )
ρ
√
2
V̇r,2 = Cd A (xs ) (p2 − pr ).
ρ
We are mainly interested in how the flow V̇p to the piston varies with xs , where
V̇p = V̇s,1 − V̇s,ℓ1 or alternatively V̇p = V̇r,2 − V̇s,ℓ2 . Assuming that xs > 0 and p1 ≥ p2 ,
we find
√
2
V̇p = Cd A (xs ) (ps − p1 ) − Ks,ℓ xs (p1 − pr ) .
ρ
For the case that xs < 0 and p1 ≤ p2 , the piston flow rate V̇p flows in the opposite
direction, leading to
√
2
−V̇p = Cd A (|xs |) (ps − p2 ) − Ks,ℓ |xs | (p2 − pr ) .
ρ
Quite often, the leakage terms are neglected, i.e., we set Ks,ℓ ≈ 0. In that case,
the model can be simplified by observing the following:
V̇s,1 = V̇r,2
⇓
ps − p1 = p2 − p r .
pp , p1 − p2 ,
we find }
ps − p1 = p2 − pr p1 = ps +p2r +pp
⇒
pp = p1 − p2 p2 = ps +p2r −pp ,
and the important driving pressures are
ps − pr − p p pa − pp
ps − p1 = =
2 2
ps − pr + pp pa + pp
ps − p2 = =
2 2
where the net accumulator pressure pa is defined as pa , ps − pr .
The driving pressure is ps − p1 when xs ≥ 0 and ps − p2 when xs < 0. We can
generalize the driving pressure to pa −|p
2
p|
. If we also assume that xs ≥ 0 : A (xs ) =
wxs where w is the width of the valve area, and xs < 0 : A (−xs ) = −wxs , we find
that for a symmetric valve without leakage,
√
1
V̇p = Cd wxs (pa − |pp |).
ρ
6.6. HYDRAULICS AND SERVO CONTROL+ 261
Cc Cv
Cd , √ ( )2 ,
1 − A1
Cc wx
6.6.4.3 Piston
Next, we turn to the piston part of the servo system. In reality, there will be a
pressure difference between the valve pressure p1 to the pressure above the piston,
and likewise between the pressure p2 below the piston and the valve pressure p2 .
However, in a simplified description it is common to assume that this pressure
difference is negligible.
The volumetric flow rate to the piston, V̇p , will change the accumulated mass
on each side of the piston, and will thereby build a corresponding pressure with
resulting net piston force Fp that will act to move the load mass mℓ . To this end,
use of Newton’s law on the load mass mℓ leads to
dvp
mℓ =F
dt
where
dxp
vp =
dt
and F is the net force composed of the piston force Fp and the opposing external
force Fe ,
F = Fp − Fe .
Assuming (unrealistically?) that the head side and rod side cross sectional areas are
the same, Ap , the piston force Fp is
Fp = Ap (p1 − p2 ) = Ap pp ,
dm1
= ρV̇p − ρV̇p,ℓ
dt
dm2
= −ρV̇p + ρV̇p,ℓ .
dt
Here, the masses are related to volumes as mj = ρVj , where the volumes can be
expressed as
V1 = V10 + Ap xp
V2 = V20 + Ap (Lp − xp ) ;
262 CHAPTER 6. MOMENTUM BALANCE
clearly, Vj0 includes the volumes of the houses, and the volume of the piston itself is
neglected. In reality, the cross sectional area may be different on the head side and
the rod side, too.
Expressing density as ρ (p), i.e., neglecting the temperature dependence, the
mass differential becomes
dm d dV dρ
= (ρV ) = ρ +V
dt dt dt dt
where
dρ ∂ρ dp 1 ∂ρ dp dp
= =ρ = ρβT .
dt ∂p dt ρ ∂p dt dt
It follows that the mass balance for piston volume 1 may be re-written as
dm1
= ρV̇p − ρV̇p,ℓ
dt
⇓
d dp1
ρ (V10 + Ap xp ) + V1 ρβT = ρV̇p − ρV̇p,ℓ
dt dt
⇓
dp1 1 V̇p − V̇p,ℓ − Ap vp
= · .
dt βT V10 + Ap xp
dm2
= −ρV̇p + ρV̇p,ℓ
dt
⇓
dp2 1 −V̇p + V̇p,ℓ + Ap vp
= · .
dt βT V20 + Ap (Lp − xp )
Here, we can combine these two differential equations for p1 and p2 to get
( )
dpp d (p1 − p2 ) 1 V̇p − V̇p,ℓ − Ap vp −V̇p + V̇p,ℓ + Ap vp
= = −
dt dt βT V1 V2
⇓
dpp 1 V1 + V2 ( )
= · V̇p − V̇p,ℓ − Ap vp ,
dt βT V1 V2
where
Thus
dpp 1 V1 + V2 ( )
= · V̇p − V̇p,ℓ − Ap vp .
dt βT (V10 + Ap xp ) (V20 + Ap (Lp − xp ))
6.6. HYDRAULICS AND SERVO CONTROL+ 263
fixed fixed
Core Core
Field
Field
Spring
Coil Coil
moving moving
Plunger Plunger
External plunger Internal plunger
Assuming that the piston leakage flow rate is small and that we can assume
laminar flow, we will have
πb2 w πb2 w
V̇p,ℓ = (p1 − p2 ) = pp
32µ 32µ
where b = D−D 2
p
and w = πD.
Above, it has been assumed that βT is constant and the same on each side of
the piston. In the case of a pneumatic valve/servo system, we have instead that
for ideal gas, βT = 1/p, and we need to use different value for βT for each control
volume. Also, it may be necessary to include the energy balance, e.g., by assuming
adiabatic compression, in order to handle the temperature in a good way.
6.6.4.4 Solenoid
Introduction A possible actuator for moving the spool is a solenoid: by applying
a voltage to the solenoid electric circuit, this results in a force F operating on a
plunger. Normally, a solenoid also includes a spring, and the spool force Fs in
Fig. 6.13 would be the difference between the solenoid force and this spring force.
Two possible solenoid designs are depicted in Fig. 6.14.
A clear presentation of the modeling aspects of the external plunger type is given
in Taghizadeh et al. (2009).
Electric circuit The electric part of the solenoid consists of an external voltage v
applied to the solenoid, which then sets up a current i going through the N -turn coil
and thereby generating a voltage e across the coil: from Faraday’s law, this voltage
is
dψ
e=
dt
264 CHAPTER 6. MOMENTUM BALANCE
where ψ is the flux linkage. The flux linkage is normally proportional to the current
i:
ψ = L · i;
proportionality factor L is known as the inductance. There is also a loss in the coil
circuit due to an electric resistor with resistance R.
Because the plunger of the solenoid can change position x, inductance L depends
on x; L = L (x). A characteristic of the solenoid is that for i ̸= 0, a force F > 0
is generated which drives the plunger position to a maximum value so that either
(external plunger) the air gap tends to zero, or (internal plunger) the plunger com-
pletely fills the coil. To enable the plunger to move in the negative x direction when
i = 0, a spring is normally inserted to push the plunger back.
Applying Kirchhoff’s voltage law to the solenoid circuit, this leads to the model
dψ
v = Ri + e = Ri +
dt
where
dψ d di ∂L dx
= (Li) = L + .
dt dt dt ∂x dt
We see that we need an expression for L (x).
where we integrate along a closed magnetic field line — the magnetic field lines are
shaped approximately like the red, closed lines in Fig. 6.14. Consider the external
plunger solenoid. We thus find
˛
Hdℓ = Hc ℓc + Ha ℓa + Hp ℓp
C
where Hj and ℓj is the magnetic field and path length in respectively the core, the
air gap and the plunger. As we see, the magnetic field varies along the closed line,
depending on the material it goes through. However, the co-called flux density B
is independent of material, and is related to the magnetic field via the permeability
µ. Thus, Hj = µBj , and we find by utilizing Ampere’s law that
( )
ℓc ℓa ℓp
Ni = B + + ;
µc µ0 µp
here, µ0 is the standard symbol for the permeability of air. Furthermore, from
Fig. 6.14, we see that ℓa = 2 (ℓ − x), and thus
Ni
B= ℓc 2(ℓ−x) ℓp
.
µc
+ µ0
+ µp
6.6. HYDRAULICS AND SERVO CONTROL+ 265
A standard finding in electromagnetism is that the flux density B inside of´ a coil is
more or less uniform across the cross sectional area A, thus the flux is Φ = BdA ≈
BA, and then the flux linkage ψ = ΦN becomes
N 2A
ψ = BAN = ℓc 2(ℓ−x) ℓp
i.
µc
+ µ0
+ µp
N 2A
L= ℓc 2(ℓ−x) ℓp
.
µc
+ µ0
+ µp
N 2A
L0 = ℓc ℓp
µc
+ µp
In the simplified case where the plunger and core materials are the same, we can set
ℓc
µc
+ µℓpp → µℓcc and introduce the relative permeability for the core, µc = µ0 µr , thus
simplifying the expression to
ℓc /µc ℓc
L = L0 = L0 .
ℓc /µc + 2 (ℓ − x) /µ0 ℓc + 2µr (ℓ − x)
Finally, we find
∂L 2ℓc µr
= L0 .
∂x [ℓc + 2µr (ℓ − x)]2
If we instead assume the internal plunger type, we similarly find from Ampere’s
law that ( )
ℓc ℓa ℓp
Ni = B + + .
µc µ0 µp
Assuming that the length of the plunger, Lp , is so that the plunger completely fills
the center of the coil when completely immersed, we have ℓa = Lp − x and ℓp = x.
It follows that ψ = BAN is
N 2A
ψ= ℓc Lp −x x
i,
µc
+ µ0
+ µp
thus
N 2A
L= ℓc Lp −x x
.
µc
+ µ0
+ µp
266 CHAPTER 6. MOMENTUM BALANCE
Defining L0 = L (x = Lp ), we have
N 2A
L0 = ℓc Lp
µc
+ µp
and
ℓc
µc
+ Lµpp
L = L0 · .
ℓc
µc
+ Lpµ−x
0
+ µxp
Again, if we have the same material in the core and in the plunger, we can introduce
ℓc
µc
+ Lµpp → µℓcc and thus
ℓc
µc
L = L0 · ℓc Lp −x x−Lp
.
µc
+ µ0
+ µc
Finally, we have
∂L (µr − 1) ℓc
= L0 · .
∂x [ℓc + (µr − 1) (Lp − x)]2
and will have an angle θ as indicated by the volumetric flow rate. Neglecting leak-
ages, this gives
Fℓ = ṁs,1 vs,1 cos θ
where
ṁ = ρV̇
V̇
v= .
A2
With A2 = Cc A0 and Cc ≈ 0.6, we find for xs ≥ 0
ρ
Fℓ = V̇ 2 cos θ.
Cc A0 s,1
ρ 2 2Cd2 A0 cos θ
Fℓ = Cd2 A20 (ps − p1 ) cos θ = (ps − p1 ) .
Cc A0 ρ Cc
Here, we will typically have Cc ≈ Cd . Under certain common conditions, it can be
shown that θ ≈ 69◦ (Merritt 1967) or cos 69◦ ≈ 0.358. We then find
If we take into account the possibility of both positive and negative value for xs , we
get ( )
sgn (xs ) + 1 1 − sgn (xs )
Fℓ = 0.43wxs ps − p1 − p2
2 2
where the sign function sgn (·) is defined as
1, x>0
sgn (x) = 0, x=0
−1, x < 0.
Valve + Valve +
Controller Controller Solenoid
piston piston
Figure 6.15: Servo system with solenoid as basic actuator, and two levels of valve +
piston. Two controllers are indicated to achieve good position control of the main
piston.
As described above, the solenoid is used to give a linear position of the spool.
An alternative is to switch the solenoid voltage(s) on and off , using a pulse width
modulation (PWM) technique to move the spool. If the on-off switching is at a high
frequency, the spool itself does not have time to move, but the operation gives a
PWM of the force acting on the spool. If the on-off switching is at a lower frequency,
the spool may actually have time to open and close rapidly, leading to a pulsing in
the flow of the hydraulic fluid. Such a pulsing in the hydraulic fluid flow will lead
to pressure transients in the system, and it is necessary to use some accumulator to
smooth out these pulses.
With a one-stage system, the solenoid operates directly on the main valve which
is used to direct hydraulic fluid flow to the piston which moves the guide vanes.
This may require relatively high power to the solenoid and large movements of the
plunger. An alternative is to use the solenoid to position a “pilot valve” (either
hydraulic or pneumatic) where the spool of the pilot valve is used to move the spool
of the main valve via a piston system. A system including a solenoid, a pilot valve
and the main valve constitutes a two stage system (e.g., two valves). If even this
is too demanding wrt. power to the solenoid, the pilot valve may control the spool
on an intermediate valve, and the piston from this intermediate valve may then be
used to control the position of the spool of the main valve.
The solenoid system and possible initial stage valves are equipped with servo
control systems, and are normally considerably faster than the main valve/piston.
It is therefore a good assumption that this underlying control system is designed
such that position xs of the main valve very closely follows the setpoint/reference
value of this position, xs,ref . This implies that for most practical purposes, we can
consider the spool position of the main valve as a control input to the guide vane
positioning system.
See, e.g., Taghizadeh et al. (2009), Kurode et al. (2013) or Hosseini (2010) for
examples of servo valves using solenoid as actuator.
6.6. HYDRAULICS AND SERVO CONTROL+ 269
• Zero spool position, x∗s = 0, which implies zero flow to the piston, V̇p∗ = 0.
• Assuming zero leakage between the piston chambers, i.e., V̇p,ℓ ≡ 0 — if this
is not fulfilled, there will be a steady drift in the piston position. With this
assumption, vp∗ = 0.
• The steady pressure difference over the piston is given by Ap p∗p = Fe∗ .
• The servo system is designed so that the resulting piston position satisfies
V1∗ = V2∗ , or in other words
( ) V20 − V10 + Ap Lp
V10 + Ap x∗p = V20 + Ap Lp − x∗p ⇒ x∗p = .
2Ap
Based on these assumptions, the linearized model about the operating point becomes
√
1 ( ∗ ∗ ) δ Cd wx∗s ρ1
δ
V̇p = Cd w p − p p · xs − √ ( δ
) pp
ρ a 2 1
p∗a − p∗p
ρ
which with considering the control input to be u = V̇pδ and the disturbance to be
w = Feδ , can be written in matrix form as
4
pδp 0 − β4A p
0 p δ
0
d δ Ap V
T p
δ βT Vp
p
vp = m 0 0 vp + 0 u + − m1ℓ w;
dt ℓ
xδ 0 1 0 xδp 0 0
| {zp } | {z } | {z } | {z }
x A B G
δ
( ) p p
y = 0 0 1 vpδ .
| {z } xδ
C p
In this description, Feδ is a disturbance. Here, it is clear that the real volumetric
flow rate V̇p is constrained as follows:
√
1 ∗
V̇p ≤ Cd wxs
max
p = V̇pmax ,
ρ a
We can thus represent the linear model approximation as in the block diagram of
Fig. 6.17. In the figure, a backlash block has been introduced in order describe the
backlash due to wear and tear between the piston position xδp and the guide vane
angle α1 .
CHAPTER 6. MOMENTUM BALANCE
Figure 6.17: Linearized description of servo system, with linear blocks, one nonlinear saturation block, and one nonlinear backlash
block.
272
6.6. HYDRAULICS AND SERVO CONTROL+ 273
1
s 4
1/Ap A2
βT Vp p
vpδ = mℓ V̇pδ − mℓ Feδ .
s2 4
A2
+1 s2 4
A2
+1
βT Vp p βT Vp p
Introducing
4A2p 2Ap
ω02 = ⇒ ω0 = √
βT V p m ℓ βT Vp mℓ
1
KV̇p =
Ap
1
KFe = 2
ω0 mℓ
( )
we can write the system from V̇pδ , Feδ to xδp = 1s vpδ as
KV̇p KFe δ
xδp = ( ) V̇pδ − 2 Fe .
s 1+ s2 1 + ωs 2
ω02 0
Here, a key observation is that the transfer function from V̇pδ to xδp is minimum
phase, i.e., there are no zeros in the right half plane. Because of this, using “nonlinear
decoupling feedback” leads to a stable closed loop system since the hidden zero
dynamics 29 will be stable.30 Thus, we can choose the closed loop system dynamics
to be linear and with pre-specified dynamics.
dy dx
=C = C (Ax + Bu + Gw)
dt dt
where
4
( ) β T Vp
CB = 0 0 1 0 = 0,
0
29
The zero dynamics is the hidden dynamics when the control input is chosen so that the output
is identically zero.
30
In fact, since there are no zeros at all, there will be no zero dynamics — hence using nonlinear
decoupling will give no hidden dynamics.
274 CHAPTER 6. MOMENTUM BALANCE
dy
thus dt
does not depend on the input u. Here, we also find that CG = 0, and
0 − β4A p
0
( ) T Vp
( )
CA = 0 0 1 Ap
mℓ
0 0 = 0 1 0 .
0 1 0
dy d
( dy )
Thus, dt
= CAx. Next, we consider dt dt
, and have
d2 y d dx
2
= (CAx) = CA = CAAx + CABu + CAGw
dt dt dt
where
4
( ) βT Vp
CA · B = 0 1 0 · 0 =0
0
(0 )
1
CA · G = 0 1 0 · − m1ℓ = − ̸= 0
mℓ
0
0 − β4A p
0 ( )
( ) A T Vp
Ap
CA · A = 0 1 0 · mp
0 0 = mℓ
0 0 .
ℓ
0 1 0
2 d2 y
In summary, ddt2y = CA2 x + CAGw. Still, dt2
does not depend on the input u since
3
CAB ≡ 0, and we need to consider ddt3y :
( )
d3 y d d2 y dx dw dw
3
= = CA2 + CAG = CA2 (Ax + Bu + Gw) + CAG .
dt dt dt2 dt dt dt
We find that
4
( ) βT Vp 4Ap
CA2 B = Ap
0 0 0 = ̸= 0
mℓ
βT Vp mℓ
0
( )0
CA2 G = Ap
mℓ
0 0 − m1ℓ = 0
0
4Ap
( ) 0 − 0 ( )
Ap Ap βT Vp
4A2p
CA2 A = mℓ
0 0 · m 0 0 = 0 − βT Vp mℓ
0 .
ℓ
0 1 0
d3 y
Finally, we see that dt3
depends affinely on u, and we have
d3 y dw
3
= CA3 x + CA2 Bu + CAG .
dt dt
6.6. HYDRAULICS AND SERVO CONTROL+ 275
d3 y d2 y dy ( )
t
= −K 1 − K2 − K3 y − xδp,r ,
dt dt dt
i
which in a stable steady state (limt→∞ ddtyi = 0 when i ≥ 0) will reach y = xδp,r . The
closed loop transfer function from xδp,r to y is then
K3
y= xδ .
s3 + K1 s2 + K2 s + K3 p,r
In order to ensure a stable closed loop system, we need to consider the closed loop
characteristic polynomial
φ (s) = s3 + K1 s2 + K2 s + K3
and must require that all roots of φ (s) have negative real parts. Suppose we want
the roots to be negative real roots − T1i . Then we have
( )( )( )
1 1 1
φ (s) = s + s+ s+
T1 T2 T3
⇓
( ) ( )
3 1 1 1 2 1 1 1 1
φ (s) = s + + + s + + + s+ .
T1 T2 T3 T1 T2 T1 T3 T2 T3 T1 T2 T3
Suppose next that we want the system to be dominant first order, which can be
achieved by requiring T1 ≫ T2 , T3 , e.g., T1 = 10T2 = 10T3 , hence setting T1 = T
leads to T2 = T3 = T /10. We then find
1 1 1 1 10 10 21
K1 = + + = + + =
T1 T2 T3 T T T T
1 1 1 10 10 100 120
K2 = + + = 2+ 2+ 2 = 2
T1 T2 T1 T3 T2 T3 T T T T
1 100
K3 = = 3.
T1 T2 T3 T
With these choices of Ti , the closed loop transfer function from xδp,r to y = xδp
becomes
K3 K3
xδp = ( 1
)( )( ) xδp,r = ( )( ) xδp,r
s+ T
s + 10
T
s+ 10
T
(1 + T s) 1 + T
10
s 1+ T
10
s K3
⇓
1
xδp ≈ xδ .
1 + T s p,r
276 CHAPTER 6. MOMENTUM BALANCE
d3 y
Finally, we equate the expressions for dt3
, thus
dw d2 y dy ( )
CA3 x + CA2 Bu + CAG = −K1 − K2 − K3 xδp,r − y
dt dt dt
⇓
( ) 4Ap 1 dw d2 y dy ( )
4A2p
0 − β T Vp m ℓ 0 x + u − = −K 1 − K2 − K3 xδp,r − y
βT Vp mℓ mℓ dt dt dt
⇓
2
4Ap δ 4Ap 1 dw d2 y dy ( )
− vp + u− = −K1 − K2 − K3 xδp,r − y .
βT Vp mℓ βT Vp mℓ mℓ dt dt dt
We can now solve this equation wrt. u to yield
( )
βT Vp mℓ 1 dw d2 y dy ( δ )
δ
u = Ap vp + − K1 − K2 − K3 xp,r − y .
4Ap mℓ dt dt dt
Here, we can insert physical variables for u, w and y: u = V̇pδ , w = Feδ , y = xδp ,
dxδ 2 dv δ ( )
dy
dt
= dtp = vpδ and ddt2y = dtp = m1ℓ Ap pδp − Feδ and find the following explicit
expression for the control input:
( )
βT Vp mℓ 1 dFeδ 1 ( ) ( δ )
δ δ
V̇p = Ap vp + − K1 Ap pp − Fe − K2 vp − K3 xp,r − xp .
δ δ δ δ
4Ap mℓ dt mℓ
( )
We see that this controller contains feedback from all states xδp , vpδ , pδp as well as
feedforward from the reference value xδp and feedforward from the disturbance Feδ
δ
and its rate of change dF dt
e
. With the suggested closed loop time constant which
gives values for Ki , the closed loop dynamics should be essentially first order.
Some practicalities: in reality, not all states will be known through measure-
ments, and it is then necessary to estimate the states in order to have their values
available for feedback. In particular, the estimate of the piston position xδp must
be unbiased in order to achieve xδp = xδp,r in steady state. Furthermore, normally,
neither the disturbance nor the derivative of the disturbance will be known, and
δ
these must also be estimated. In particular, the estimate of the derivative dF dt
e
will
be uncertain.
Control structure
Valve + piston
Controller
the closed loop dynamics in Fig. 6.18, we have considered the transfer from xδp,r to
xδp . However, if we use feedback from the guide vane angle α1 instead of the piston
position, we will have to take into account the effect of the backlash in the controller
design. Typically, the backlash will lead to oscillations — which will increase the
wear-and-tear.
Turbine
6.7.1 Turbines
In turbines, the fluid flows at mass flow rate ṁ (mass/time) through the machine,
and experiences a pressure drop ∆p = p0 − p2 and a velocity change v0 → v2 ; we
assume zero elevation change in the flows. At the same time, the power of the
turbine fluid is reduced by Ẇt . If we assume a constant density fluid (liquid, and
gas at low pressure), the volumetric flow rate V̇ is the same at the influent and the
effluent. Part of the power Ẇt is used to generate a torque on the turbine shaft,
Ẇs , and thus set up a rotating speed Ṅ (revolutions/time). The other part of the
power Ẇt is dissipated as friction, and is converted to heat. An actuator signal
u may change the opening in the fluid passage and change the pressure drop and
mechanical power produced.
Figure 6.19 indicates the key quantities for a turbine.
If we thus neglect the level difference of the influent and the effluent and assume
steady state on the fluid side, conservation of energy leads to
1 2 1
ṁv0 + p0 V̇ = ṁv22 + p2 V̇ + Ẇt
2 2
or with ∆p , p0 − p2 ,
ṁ ( 2 )
Ẇt = ∆p · V̇ + v0 − v22 .
2
6.7. TURBO MACHINES+,∗ 279
This power Ẇt is the power that is removed from the turbine fluid side. A part of
this power is transferred to the turbine shaft, Ẇs . In the sequel, we develop some
expression for the shaft power Ẇs based on mechanistic hydro turbine models; in
essence, we use the angular momentum balance for the turbines; these are customary
denoted the Euler turbine equations. The resulting shaft power will depend on
volumetric flow rate V̇ , actuator signal u, etc.
An alternative approach is to develop an expression for the turbine efficiency η,
defined as
Ẇs
η, .
Ẇ t
To this end, with η a known function, typically a function of u, V̇ , etc., we can
compute Ẇs as
Ẇs = η Ẇt
where Ẇt is found from steady energy conservation.
As a simplistic example, for some turbines, the pressure drop term dominates
in Ẇt ; Ẇt ≈ ∆p · V̇ . A very simple model would then be to express the efficiency
as η = Ct f (u) and neglect the effect of the flow rate V̇ ; with an efficiency that is
linear in u, this would simply yield
Ẇs = Ct u · ∆p · V̇
where it obviously is required that Ct u ∈ [0, 1) for all u. However, more accurate
models are normally needed.
Figure 6.20: Turbine selection chart for selected turbine types. Due to Heinzmann
HydroTech, India, see http://www.heinzmann.co.in/technology.html.
6.7. TURBO MACHINES+,∗ 281
Fluid guide
Stator/rotor
apparatus
Figure 6.21: Split of turbine into fluid guide apparatus and stator/rotor.
The water enters the rotor through a ring of stationary guide vanes which direct
the water flow onto the rotor blades at some optimal angle. After the turbine,
the remaining kinetic energy is recovered in a draft tube of gradually increasing
diameter, thereby gradually reducing the linear velocity and thus the kinetic energy
towards zero. See the paragraph on the Francis turbine, p. 289, for details.
The Kaplan turbine is used for very large and varying flow rates V̇ and low
waterfalls in the range of [7, 70] m; a typical use is in run-of-river hydro power pro-
duction. In Kaplan turbines, water enters the runner radially through guide vanes,
and the flow then changes to axial (vertical) flow where the axial propeller/turbine
blades are rotated. The guide vanes are adjusted automatically for optimal opera-
tion, while the produced power is manipulated by changing the turbine blade pitch.
See the paragraph on the Kaplan turbine, p. 302, for details.
Bulb turbines are used for very low water height differences, such as in tidal
plants, etc.
We will need to consider the fluid guide apparatus with the influence of an
actuator signal u and the possibility of friction loss through the apparatus. However,
the main focus will be on the shaft work Ẇs which is generated from torques set up
by forces from the fluid,
Ẇs , Ẇi − Ẇe , (6.43)
but we will also consider possible friction loss, Ẇf2 .
From Eq. 6.13
where T = ȧ = Rṁt = Rṁv t and vρ = ωR. We neglect the leakage of mass in the
turbine, hence ṁi = ṁe = ṁ; we consider the case of constant density ρ, hence the
volumetric flow rate through the fluid side is given by ṁ = ρV̇ . Furthermore, the
velocity v t is the projection of the velocity tangential to the rotation (orthogonal to
the radius r).
We thus have
( )
Ẇs = ṁ vρ,i · vit − vρ,e · vet (6.44)
where the “reference” velocity is vρ,j , Rj ω; the expression for ∆ẆE in Eq. 6.44 is
known as Euler’s turbine equation.
It is useful to also consider how the shaft work term will be used in a model of
an aggregate, i.e., the rotating part of a combined turbine and electric generator.
Let the total rotational energy be E = Ka for the aggregate and Ė = K̇ + Ṗ ≡ 0;
this gives the aggregate energy balance (Eq. 6.11)
dKa
= Ẇs − Ẇa
dt
where Ẇs is the shaft work produced by the fluid (water) side, while Ẇa is the
equivalent work on the aggregate side; Ẇa will include windage friction loss Ẇfw ,
bearing friction loss Ẇfb , friction loss in the generator Ẇfg , etc., but also work on the
aggregate due to consumption of electrical power Ẇg taken out from the generator:
⃗v = ⃗vρ + ⃗v̌ .
v x = vρx + v̌ x
v y = vρy + v̌ y .
v t = vρ + v̌ t (6.45)
v r = v̌ r . (6.46)
Here,
vt = v · cos α (6.47)
v̌ t = v̌ · cos γ (6.48)
vr = v · sin α (6.49)
v̌ r = v̌ · sin γ, (6.50)
we can use Eq. 6.52 to express v̌, and the relative velocity can be eliminated from
Eq.6.53 to get
sin α
v · cos α = vρ + v · cos γ
sin γ
⇓
cos α · sin γ − sin α · cos γ
vρ = v. (6.54)
sin γ
This expression relates the reference velocity vρ the absolute velocity v and the
involved angles.
Here, we can alternatively use Eq. 6.49 and relate vρ to v r :
v2 . Then water from position “1” hits the buckets of the turbine wheel at position
“2” and transfers energy to the rotating engine. It is natural to divide the treatment
into one model for the nozzle, and another one for the bucket system/rotating engine.
In general, the mass flow rate ṁ is assumed to be constant through the impulse
turbine, i.e., in all positions. Furthermore, we neglect compressibility of water which
leads to a constant density ρ, hence the volumetric flow rate V̇ is constant through
the turbine.
Nozzle pressure drop The nozzle model is based on a steady state energy
balance. Thus the energy flow is the same at positions “0” and “1”. Assuming a
small nozzle, we can neglect potential energy and only include kinetic energy flow
K̇ and pressure-flow power Ẇ , as well as friction loss Ẇf . Hence
where
1
K̇ = ṁv 2
2
Ẇ = pV̇ .
and [ ( ) ]
1 1 1
∆pn = ρV̇ V̇ − + kf .
2 A21 (Y ) A02
286 CHAPTER 6. MOMENTUM BALANCE
Geometry The ideal transfer of power Ẇs to the rotor shaft of the turbo
machine is given by Euler’s turbine equation
Ẇs = (T1 − T2 ) ω
where T1 is the torque at position “1” (or rather: when the water hits the bucket)
and T2 is the torque at position “2” (or rather for the water reflected from the
bucket). In the Pelton turbine, the torques share the same radius R of the turbine
wheel in Fig. 6.23:
T1 = ṁv1t R
T2 = ṁv2t R;
vjt indicates the tangential coordinate of the velocity in position j — parallel to ṁ;
R is the radius of rotor where the mass hits the bucket, and we have utilized that
the mass flow ṁ is constant in size through the turbine. This also means that the
reference velocity is the same for both position “1” and position “2”: vρ,1 = vρ,2 =
vR = ωR.
For position “1”, we simply have that
V̇
v1t = v1 = .
A1
For position “2”, we observe from Fig. 6.23 that the relative velocity v̌2 is reflected
from the bucket at an angle β backwards. By relative velocity, we mean the velocity
that we would observe had we been sitting and moving around on the turbine wheel.
But the velocity we need in our expression for the torque, is the absolute velocity in
the earth-bound coordinate system. Thus we need to find an expression for v2t .
First, we assume that the reflected relative velocity v̌2 is proportional in size to
the inlet relative velocity v̌1 :
v̌2 = kv̌1 ;
here k ≤ 1 is some friction factor, typically k ∈ [0.8, 0.9]. Next, we need to relate
the relative velocities to the absolute tangential velocity. Then we have
v̌1 = v1t − vR = v1 − vR
and
v2t = vR − v̌2 cos (180 − β) = vR + v̌2 cos β.
Here, a typical value for the reflection angle is β = 165◦ . We find
Shaft power and friction loss From the above, the turbine shaft work thus
becomes
Ẇs = (T1 − T2 ) ω
⇓
( )
Ẇs = ṁ v1t − v2t Rω.
6.7. TURBO MACHINES+,∗ 287
We have
v1t − v2t = v1 − [vR + k (v1 − vR ) cos β]
⇓
v1 − v2 = (v1 − vR ) (1 − k cos β) .
t t
It is easily found that Ẇs − Ẇf2 attains it maximum for vR given by (vR )max =
1
v leading to
2(1+K) 1
( ) v2 1
Ẇs − Ẇf2 (vR )max = ṁ 1 (1 − k cos β) .
4 1+K
288 CHAPTER 6. MOMENTUM BALANCE
Figure 6.24: Comparison of how Ẇs fits with actual data. Taken from Jyn-Cherng
Shieh (2007), www.taiwan921.lib.ntu.edu.tw/mypdf/fluid12.pdf, but with modi-
fied notation and correction of a typo in the expression for Ts .
6.7. TURBO MACHINES+,∗ 289
Turbine
entrance
flow
Guide
vanes
Spiralling
cage
Rotor
Stator
guide vanes is d, each guide vane has the same angle α1 with the vane perimeter,
and the distance between each (almost) parallel guide vane is δ. It follows that d
and δ are related as
δ
sin α1 = .
d
With width w of the rotor and stator orthogonal to the paper plane, it follows that
the cross sectional area of the flow through each guide vane pair is av = δ · w, hence
the linear velocity v1 is related to V̇ and α1 as
V̇ /N V̇ /N V̇ /N V̇
v1 = = = = .
av δ·w sin α1 · d · w N d · w · sin α1
Let ℘v , N d be the perimeter of the guide vane hinge circle, hence N d · w = ℘v w =
2πRv w = Av is the maximal area opening through the guide vanes;
V̇
v1 = .
Av sin α1
The flow from the turbine entrance (volumetric flow rate V̇ , cross sectional area
A0 ) through the guide vanes and to the stator/rotor interface (volumetric flow rate
V̇ , cross sectional area Av sin α1 ) gives a certain pressure change. Simultaneously,
the guide vanes steer the water at a certain angle α1 towards the rotor blades,
thus driving the rotor and producing a rotational power with another pressure drop
through the rotor and to the exit from the rotor.
6.7. TURBO MACHINES+,∗ 291
In the sequel, we first discuss the pressure drop across the guide vanes. Next,
the rotational shaft power produced in the turbine is discussed. Finally, paragraph
Guide vane actuation on p. 299 discusses how the actuator signal u relates to guide
vane angle α1 .
Guide vane pressure drop We will assume that the flow from the turbine
entrance through the inlet guide vanes follows steady energy conservation. To this
end, we have the following steady energy balance along stream lines, where we
neglect any vertical difference in position:
here subscript 0 indicates entrance to the turbine and subscript 1 indicates after
guide vanes, while Ẇf1 is friction loss from turbine entrance and across guide vanes.
Here, we have used that mass is not accumulated and assumed constant density,
hence the volumetric flow rate is the same everywhere. From Fig. 6.26 and the
above discussion, we have
1 1 V̇ 2
K̇0 = ṁv02 = ṁ 2
2 2 A0
1 1 V̇ 2
K̇1 = ṁv12 = ṁ 2 2 .
2 2 Av sin α1
1 V̇ 2 ṁ 1 V̇ 2 ṁ
ṁ 2 + p0 = ṁ 2 2 + p1 + Ẇf1 .
2 A0 ρ 2 Av sin α1 ρ
Introducing
∆pv , p0 − p1 ,
we find ( )
ρ 1 1 Ẇf1
∆pv = 2 − V̇ 2 + .
2 A2v sin α1 A20 V̇
When the vanes are closing, α1 → 0 and thus sin α1 → 0, the velocity v1 ∝ sin1α1 will
go to infinity. However, ∆pv will go to infinity quadratically (hence, much faster),
and thus the counter pressure to the turbine entrance flow will block the flow of
water as the guide vanes close.
In general, the friction loss will depend on (i) the mass flow rate, and (ii) the
vane angle α1 . If we simplify the description and set Ẇf1 = k2fv ṁ, then
[ 2 ]
1 A0 − A2v sin2 α1
∆pv = ρV̇ V̇ + kfv .
2 A20 A2v sin2 α1
As indicated above, the angle will be a function of the actuator signal u.
From this discussion, we see that ∆pv may be either positive or negative, de-
pending on the angle α1 and the size of kfv . In standard presentations of the Francis
turbine, the pressure drop ∆pv is not discussed, and is thus implicitly neglected, or
292 CHAPTER 6. MOMENTUM BALANCE
Inlet
Stator
Rotor
Outlet
Figure 6.27: Key quantities in the Francis turbine model, with blade angles β1 and
β2 . The water effluent comes out from the paper plane.
Geometry** Insert??
Shaft power Figure 6.27 shows absolute velocities, rotor reference velocities,
and relative velocities in the Francis turbine.
We have seen that the shaft power Ẇs produced in a turbo machine can be
developed from the Euler turbine equations in Eq. 6.44 p. 282, and can be written
as follows for the Francis turbine:
( )
Ẇs = ṁ vρ,1 v1t − vρ,2 v2t ,
where the reference velocity is
vρ,j = ωRj .
Being a radial flow turbine, the water net flow is in the radial direction. With
no mass accumulated in the turbine, we have
V̇ = A1 v1r = A2 v2r .
Here, Aj is the area through which the water flows, typically equal to the perimeter
of the turbine, ℘j = 2πRj , multiplied by the width of the turbine/blades wj : Aj =
6.7. TURBO MACHINES+,∗ 293
℘j wj , possibly with the reduction of the area taken by guide vanes, etc., expressed
through some factor κj . Thus
Aj = 2πRj wj κj .
Next, it is desirable that there is no shock when the water hits the turbine blades,
which implies that the angles of the relative velocities γj must be aligned with the
blade angles βj ; γj ≡ βj . At the inlet, Eq. 6.55 gives
vρ,1 = (cot α1 − cot γ1 ) v1r (6.56)
where vρ,1 = ωR1 is given by state ω, blade inlet angle β1 given by design, v1r = AV̇1
is given by state V̇ , and the inlet guide vane angle α1 is given by control signal u.
It follows that γ1 is then constrained by the above equation, and we do not have
the freedom to align γ1 with the blade angle β1 : this alignment can only be done
in a design phase — changing either of α1 , ω (through vρ,1 ) or V̇ (through v1r ) will
change γ1 according to Eq. 6.56 and make it differ from β1 . When operating with
γ1 ̸= β1 , this leads to a friction-like hydraulic loss in the turbine.
For the outlet from the turbine, however, Eq. 6.55 can be achieved with γ2 = β2 ,
leading to
vρ,2 = (cot α2 − cot β2 ) v2r . (6.57)
Here, reference velocity vρ,2 = ωR2 , blade outlet angle β2 is given by design, and
radial outlet velocity is v2r = AV̇2 . Thus, this equation gives the angle α2 .
From Eq. 6.51, we finally have the friction free shaft power as
Ẇs = ṁ (vρ,1 v1r cot α1 − vρ,2 v2r cot α2 )
or with
v2r cot α2 = vρ,2 + v2r cot β2 ,
we find
Ẇs = ṁ (vρ,1 v1r cot α1 − vρ,2 (vρ,2 + v2r cot β2 ))
⇓
( ( ))
V̇ V̇
Ẇs = ṁ ωR1 cot α1 − ωR2 ωR2 + cot β2 .
A1 A2
Here, α1 ≤ 90◦ is a function of the guide vane servo position u, and β2 ≤ 90◦ is a
design variable.
In turbine design, the following considerations are important:
1. For the nominal operating condition with given ω , V̇ , and operating guide
vane angle α1 , a suitable turbine with R1 , A1 , β1 , is selected such that the
influent no-shock condition of Eq. 6.56 can be achieved with γ1 = β1 . This
will reduce the hydraulic friction loss.
If the turbine is operated at conditions different from the nominal ones, this
will incur a friction shock loss which, e.g., can be expressed as
( )
Ẇf2,1 = Ff2,1 cot γ1 − cot β1 , V̇ ≥ 0
294 CHAPTER 6. MOMENTUM BALANCE
where β1 is a design variable (inlet blade angle) and cot γ1 is found from
Eq. 6.56 as
vρ,1 ωR1
cot γ1 = cot α1 − r = cot α1 − .
v1 V̇ /A1
2. For the nominal operating condition with effluent no-shock condition Eq. 6.57
satisfied, the so-called no-whirl effluent condition α2 = π2 ⇒ cot α2 = 0 is en-
forced, which increases and simplifies the shaft power to Ẇs = ṁωR1 AV̇1 cot α1 .
Effluent whirl both reduces the shaft power directly, and gives some hydraulic
friction loss: ( )
Ẇf2,2 = Ff2,2 cot α2 , V̇ ≥0
where
ωR2
cot α2 = cot β2 + .
V̇ /A2
As an example, we could postulate
while, e.g.,
where kf2,3 gives some standard friction loss due to wall friction, etc. Here, ṁ, V̇
will be a state of the entrance system (ṁ = ρV̇ ), ω will be a state of the aggregate,
α1 will be given by the actuator position u. The total work rate removed through
the turbine will be
Ẇt = Ẇs + Ẇf1 + Ẇf2 .
Ẇs
η= .
Ẇt
6.7. TURBO MACHINES+,∗ 295
Hydro power
turbine design
algorithm
Figure 6.28: Block diagram of algorithm for design of Francis turbine. Nominal
algorithm inputs are volumetric flow rate V̇ n , net head H n , electric grid frequency fen ,
and total work rate Ẇtn . Turbine geometry and operating conditions are computed
in the order β2 , R2 , R1 , w1 , α1n , and β1 .
4. Parameter w1 . ? suggests that v2r should be 10% larger than v1r to avoid
vr
back-flow, leading to v1r = 1.12 .33 With V̇ n = A1 v1r and A1 = 2πR1 w1 κ1 , the
n
inlet width w1 of the turbine rotor is computed as w1 = 2πRV̇1 κ1 vr where the
1
area loss due to vanes often is neglected by setting κ1 = 1.
6. Parameter β1 . The inlet blade angle β1 is(chosen to ) give zero shock, i.e., such
−1 v1 −R1 ω
t n
vω,1
that cot β1 = cot α1 − vr or β1 = cot
n
v1r
. Function cot−1 (·) maps
1
the solution in range [−90◦ , 90◦ ], while in our case, the angle should be mapped
into the range [0◦ , 180◦ ]. In general, cot−1 (x) = α + i · 180◦ . Thus, if β1 is
found to be in range [0◦ , 90◦ ], then the solution is ok, but if β1 ∈ [−90◦ , 0◦ ),
then we need to add 180◦ to the computed value — this will be the case when
v1t − R1 ω n < 0.
If we are interested in the nominal rotational speed Ṅ n (RPM) of the aggregate/-
n
turbine, we have ω n = 2π Ṅ60 ⇒ Ṅ n = 30
π
ωn.
33
Other design rules recommend that v2r is smaller than v1r in order to reduce the loss of kinetic
power in the tail water.
6.7. TURBO MACHINES+,∗ 297
The Sundsbarm hydro power plant in Telemark, Norway, has the following nom-
inal conditions:
We can now compute turbine parameters and operating inlet guide vane angle:
R2 as R2 = 3 − πω V̇ n
n cot β2 =
3 − 24.3
π· 2π·50
cot 162.5 ≈ 0.7767 m. As a check,
6
n
vω,2 = ω n R2 = 2π·50
6
· 0.7767 = 40.67 m/s which is within the recommended
ω n R2
range; also, v2 = − cot β2 = − 2π·50·0.7767
r
cot 162.5
≈ 12.82 m/s.
√ √
3. Parameter R1 . With v̄ω,1 = 0.725 and v ς = 2gHtn = 2 · 9.81 · 460 ≈
95 m/s, vω,1 = v̄ω,1 v ς = 0.725 · 95 = 68.88 m/s. Finally, R1 = vωω,1
n = 2π·50 ≈
68.88
6
1.315 m.
v2r
4. Parameter w1 . We assume κ1 = 1. With v1r = 1.1
= 12.82
1.1
≈ 11.66 m/s,
n 24.3
w1 = 2πRV̇1 κ1 vr = 2π·1.315·1·11.66 ≈ 0.2522 m.
1
5. Operating point α1n . With v̄1t = ≈ 0.6621, v1t = (v̄1t ·)v ς = 0.6621 · 95 ≈
0.48
0.725
vt ( )
62.90 m/s. Finally, the angle is given as α1n = cot−1 v1r = cot−1 62.90 11.66
≈
1
◦
10.50 .
Vane
(a) (b)
(c) (d)
Figure 6.29: Guide vane geometry relating actuator position Y to guide vane angle
α1 .
6.7. TURBO MACHINES+,∗ 299
Guide vane actuation The guide vane geometry is depicted in Fig. 6.29.34
From Fig. 6.29 (a), assuming that the actuator cylinder is “vertical” in position
“0”, we find that
α1 = ϕ − ψ.
In the above development, it has been assumed that the guide vane is perpen-
dicular to the attached “arm” of length ℓ, and that in position “0”, a guide vane is
at position “9 o’clock”, Fig. 6.29 (a).
As a simple example, consider the guide vane parameters as in Table 6.7 — these
numbers are not necessarily realistic.
The mapping from actuator position Y to guide vane angle α1 can then be found
as in the Python code below (file guideVaneGeometry.py).
34
www.mekanizmalar.com/francis-turbine-wicket-gate-animation.html
35
Clearly, d ∈ [d0 , 2ℓ].
300 CHAPTER 6. MOMENTUM BALANCE
1 # -* - coding : utf -8 -* -
2 """
3 Created on Tue Jan 17 16:02:20 2017
4
5 @author : Bernt Lie
6 """
7 import numpy as np
8 import numpy . random as nr
9 import matplotlib . pyplot as plt
10 import pandas as pd
11 #
12 rv = 1.5
13 Rv = 2
14 rY = 1.6
15 RY = 3
16 #
17 Y0 = np . sqrt ( RY **2 - rY **2)
18 theta0 = np . arccos ( rY / RY )
19 d0 = Rv - rv
20 #
21 L = np . sqrt ( d0 **2/2) *1.8
22 alpha10 = np . arccos ( d0 /(2* L ) )
23 #
24 Y = np . linspace (2.25 ,3.22)
25 #
26 theta = np . arccos (( rY **2 + RY **2 - Y **2) /2/ rY / RY )
27 dtheta = theta - theta0
28 d = np . sqrt ( rv **2 + Rv **2 -2* rv * Rv * np . cos ( dtheta ) )
29 psi = np . arccos (( d **2 + Rv **2 - rv **2) /(2* d * Rv ) ) * np . sign (
dtheta )
30 phi = np . arccos ( d /2/ L )
31 #
32 alpha1 = phi - psi
33 #
34 plt . plot (Y , alpha1 *180/ np . pi , linewidth =2.5)
35 plt . xlabel ( r ’ $Y$ ␣ [ m ] ’)
36 plt . ylabel ( r ’$ \ alpha_1$ ␣ [ $ {}^\ circ$ ] ’)
37 plt . title ( r ’ Guide ␣ Vane ␣ angle ␣ $ \ alpha_1$ ␣ as ␣ a ␣ function ␣ of ␣
actuator ␣ position ␣ $Y$ ’)
38 plt . grid ( True )
39 plt . hold ( True )
40 plt . plot ( Y0 , alpha10 *180/ np . pi , ’ ko ’)
41 plt . hold ( False )
This case leads to the guide vane characteristic of Fig. 6.30.
The shape of the Guide Vane characteristic will depend on the chosen geometry,
but with sensible geometry, it is possible to make the mapping from Y to α1 fairly
linear.
In order to change angle α1 , it is necessary to use a servo motor. Depending on
how the control loop is constructed, it may be possible to specify the setpoint to
6.7. TURBO MACHINES+,∗ 301
80
70
60
50
α1 [ ◦ ]
40
30
20
10
0
2.2 2.4 2.6 2.8 3.0 3.2 3.4
Y [m]
Figure 6.30: Guide Vane characteristic with numbers from Table 6.7. The bullet
indicates actuator position Y = Y0 with corresponding Guide Vane angle α10 .
302 CHAPTER 6. MOMENTUM BALANCE
Shaft power Being an axial flow turbine, the work on the shaft is added
through flow in the axial direction, and the volumetric flow rate V̇ is related to the
axial absolute velocities v1a and v2a as
V̇ = Av1a = Av2a ,
where the area through which the water flows typically is equal to the area
( )
A = π Rb2 − Ra2 ,
possibly with the reduction of the area taken up by the blades in the propeller.
One special thing about the Kaplan turbine is that the rotational forces operate
on a range of radii r ∈ [Ra , Rb ]. We have that the relative axial velocity v̌1a is given
as
v̌1a = v1a .
6.7. TURBO MACHINES+,∗ 303
pitched
blades
Adjusting the pitch of the blades will change the inlet angle β1 of the relative velocity
v̌1 . From simple geometry, we find that
v2t = vr − v̌2t .
V̇
v1t = vr + cot β1
A
where cot β1 < 0. Obviously, for turbine operation, increasing V̇ must increase the
shaft power. It is thus obvious that for the Kaplan turbine, the shaft power is given
by ( )
Ẇs = ṁ vr v2t − vr v1t .
304 CHAPTER 6. MOMENTUM BALANCE
We also notice that we have a radius in the range r ∈ [Ra , Rb ]. To make the
model manageable, it is common to use some average velocity vR̄ given by
vR̄ = ω R̄,
where
Ra + Rb
R̄ = .
2
We thus find the shaft work as
( )
Ẇs = ṁ vR̄ v2t − vR̄ v1t .
By inserting the values for v1t and v2t , we find
Ẇs = −ṁvR̄ v1t = ṁvR̄ [v1a (− cot β1 ) − vR̄ ] ,
where β1 > 90◦ is given by the positioner for the blade pitch angle, hence β1 (Y )
where Y is the position of the blade pitch adjuster.
Inlet pressure drop We will assume that the flow through the inlet guiding
vanes follows Bernoulli’s law, similarly to for the nozzle in the Pelton turbine, and
produces a pressure drop given by
1 [ ]
∆pv = ρV̇ f (Y ) V̇ + kf .
2
Total pressure drop For reaction turbines, the exit pressure is given by a
model of the tail race. Thus, the total pressure drop over the turbine is
∆p = ∆ps + ∆pv
⇓
Ẇs
∆p = + ∆pv .
V̇
A generic turbine model It is of interest to compare the models for shaft work
for the various turbines. Inserting volumetric flow rates and rotational speeds, we
find that:
[ ]
V̇
ẆsPelton = ṁωR δ (uδ ) − (1 + K) ωR (1 − k cos β) , β ≥ 90◦ =⇒ 1 − k cos β ≥ 1
A1
[ ( ) ]
V̇ R
(α1 , β2 ) ≤ 90◦
1
ẆsFrancis = ṁωR2 cot α1 + cot β2 − ωR2 ,
A1 R2
[ ]
V̇
ẆsKaplan = ṁω R̄ (− cot β1 ) − ω R̄ , β1 ≥ 90◦ =⇒ cot β1 ≤ 0
A
6.8. CASES: MATERIAL DESCRIPTION⋆ 305
From this comparison, we observe that all three turbines can be written in the
generic form ( )
V̇ j
j
Ẇs = ṁωk0j
k − ωk2j
A 1
with corresponding generic shaft pressure drop
( )
V̇ j
j
∆ps = ρωk0 j
k − ωk2
j
A 1
( )
where j ∈ {Pelton, Francis, Kaplan} and where parameters k0j , k1j , k2j are given as
in Table 6.8.
In the parameters of Table 6.8, it should be noted that in all three cases, param-
eter k1j can be used to adjust the shaft work:
• Pelton turbine: the deflection δ can be used to control over-speed. Normally,
however, the Pelton turbine is controlled by adjusting the needle position in
the nozzle, thus changing the pressure drop over the nozzle.
• Francis turbine: the guide vanes are adjusted by changing angle α1 . Changing
angle α1 will, however, also change the pressure drop over the guide vanes.
• Kaplan turbine: the propeller blade pitch is adjusted by changing angle β1 .
However, it is also possible to change the angle α1 of the guide vanes, and
thereby changing the pressure drop over the guide vanes. As the Kaplan
turbine thus has two independently adjustable parameters, it is common to
coordinate their adjustment to maximize the power output; this is normally
done by letting the operator adjust angle α1 of the guide vanes, and then
automatically compute β1 from a pre-computed relationship.
Scaled turbine models It may be of interest to scale turbine models wrt. nom-
inal/design conditions.
Figure 6.33: Pipe transporting water from a dam through a pipe and a valve.
• Turbin, generator
• Elastisk aksling?
Liquid flow
through pipe
Figure 6.34: Functional diagram of flow of water from dam through pipe, and re-
leased to the atmosphere through a valve. u is the valve input signal, h is the dam
level, and V̇ is the volumetric flow through the pipe.
Ff , and liquid pressure Fp . The length of the filled pipe is L, and the height drop
over the pipe length is H.
The functional diagram in Fig. 6.34 depicts the causality of the system where
valve input u and dam level h cause a change in the observed volumetric flow rate
V̇ .
Step 1: To find the flow through the pipe, we need to use the total mass balance
dm
= ṁi − ṁe ,
dt
and the (linear) momentum balance
dm
= ṁi − ṁe + F .
dt
m = ρV
ṁ = ρV̇ ,
V̇ = vAp .
308 CHAPTER 6. MOMENTUM BALANCE
Step 3: Composing the model. Because pipe mass m is constant, we only have a
differential equation for the momentum m, where ṁi − ṁe = 0. Then,
dm
=F
dt
where
m = mv
m = ρAp L
V̇ = vAp
ṁ = ρV̇
√
∆pe
ṁ = Ke0 · u
pς
∆pe = pe − pa
6.9. CASE: INCOMPRESSIBLE LIQUID PIPE FLOW 309
Table 6.9: Parameters for liquid flow from dam through pipe and valve.
Parameter Value Unit Comment
Ap 1.5 m2 Cross sectional area, pipe
2
g 9.81 m/s Acceleration by gravity
H 100 m Height drop, pipe
k 4 × 104 N
(m/s)2
Friction coefficient
Ke0 2 × 103 kg/s Valve coefficient
L 200 m Pipe length
m ρAp L kg Mass of liquid in pipe
pa 1.01 × 105 Pa Atmospheric pressure
ς
p = pa Pa Scaling pressure
3 3
ρ 10 kg/m Liquid density
while
F = −Ff + Fg + Fp
Ff = kv 2
H
Fg = mg
L
Fp = (p − pe ) Ap
where
p = pa + ρgh.
where
x = (m)
( )
z = v, V̇ , ṁ, ∆pe , pe , F, Ff , Fg , Fp , p
u = (u, h)
( )
θ = ρ, Ap , L, m, Ke0 , pa , k, g, H .
Table 6.10: Operating conditions for liquid flow from dam through pipe and valve.
Quantity Value Unit Comment
v (0) 2 m/s Initial linear velocity of water in pipe
mp (0) mv (0) N s Initial momentum, pipe
u 0.5 — Input signal to valve
h 5 m Dam level above pipe inlet
2.9
2.8
V [m3/s]
2.7
2.6
2.5
0 1 2 3 4 5 6 7 8
time t [s]
1 package PipeDam
2 // Package for simulating flow in pipe from dam
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // September 23 , 2015
6 // May 12 , 2017
7 //
8 model SimPipeDam
9 // Simulation of flow in pipe from dam
10 // author : Bernt Lie
11 // University of South - Eastern Norway
12 // September 23 , 2015
13 // May 12 , 2017
14 //
6.9. CASE: INCOMPRESSIBLE LIQUID PIPE FLOW 311
0.48
0.46
u
0.44
0.42
0.40
0 1 2 3 4 5 6 7 8
time t [s]
800000
600000
400000
200000
0 1 2 3 4 5 6 7 8
time t [s]
Figure 6.37: Pressure just upstream from valve, pe (red), compared to atmospheric
pressure pa (blue).
312 CHAPTER 6. MOMENTUM BALANCE
500000
1000000
1500000
2000000
0 1 2 3 4 5 6 7 8
time t [s]
Figure 6.38: Forces acting on the system: net force F (red), friction force Ff (blue),
gravitational force Fg (green), and net pressure force Fp (pale blue).
580000
560000
[Nm]
540000
520000
500000
0 1 2 3 4 5 6 7 8
time t [s]
Upper tank
Lower tank
Basin
Figure 6.40: System with basin, from which liquid is pumped to an upper tank,
flows by gravity to a lower tank, and then finally flows by gravity back to the basin.
Figure 6.41: Functional diagram of system for pumping liquid from a basin to an
upper tank, via gravity to the lower tank and back to the basin. u is the pump
signal, and hℓ is the level in the lower tank.
316 CHAPTER 6. MOMENTUM BALANCE
Step 1: To find the level in the tanks, we need to use the total mass balance
dm
= ṁi − ṁe .
dt
In order to find the flow rate of the pipe, we need to use the (linear) momentum
balance
dm
= ṁi − ṁe + F .
dt
Step 2: Assuming homogeneous density, mass is related to volume as (j ∈ {u, ℓ, b})
mj = ρVj ,
Vj = hj Aj .
where hςj is a scaling level. Effluent mass flow from the basin can be described
by
ṁe,b = ρV̇p
where V̇p is the volumetric flow rate through the pump.
For the pipe, mp = ρLAp = constant, thus ṁi,p = ṁe,p = ρV̇p and V̇p is
constant throughout the pipe. Furthermore, V̇p = vp Ap , and vp is constant
throughout the pipe.
For the pipe, the momentum is
mp = mp vp
where
V̇p
vp = .
Ap
Because
ṁp = ṁp vp = constant,
it follows that ṁi,p = ṁe,p . The forces are
F = −Ff − Fg + Fp
6.10. CASE: TWO TANKS WITH BASIN AND PUMP 317
Fp = pp Ap − pa Ap .
where V̇pς is a scaling volumetric flow rate through the pump. For simplicity
we assume that
f (u) = u.
Here,
∆pp = pp − ps .
Step 3: Composing the model. We can now apply the mass balance, etc. to all
volumes, and expand the model into the following.
dmu
= ṁi,u − ṁe,u
dt
dmℓ
= ṁi,ℓ − ṁe,ℓ
dt
dmb
= ṁi,b − ṁe,b
dt
dmp
=F
dt
where
mu = ρVu
Vu = Au hu
mℓ = ρVℓ
Vℓ = Aℓ hℓ
mb = ρVb
Vb = Ab hb
mp = mp vp
mp = ρAp L
V̇p
vp =
Ap
ṁp = ρV̇p
318 CHAPTER 6. MOMENTUM BALANCE
and
ṁi,u = ṁp
√
hu
ṁe,u = Ku
hςu
ṁi,ℓ = ṁe,u
√
hℓ
ṁe,ℓ = Kℓ
hςℓ
ṁi,b = ṁe,ℓ
ṁe,b = ṁp ,
while
F = −Ff − Fg + Fp
Ff = kvp |vp |
H
Fg = mp g
L
Fp = (pp − pa ) Ap
where
pp − pb = ∆pp
pb = pa + ρghb
( )2
V̇p
∆pp = u · ∆p0p − δpV̇p .
V̇pς
Table 6.11: Parameters for two tanks with basin and pump/pipe.
Parameter Value Unit Comment
Ab 0.25 m2 Cross sectional area, basin
2
Aℓ 0.025 m Cross sectional area, lower tank
1 1 2
Ap 16 100
m Cross sectional area, pipe
Au 0.025 dm2 Cross sectional area, upper tank
∆pp 0
1.5 × 104
Pa Nominal pump pressure increase
δpV̇p 100 Pa Pump pressure drop per scaled flow rate
ς −4 3
V̇p 10 m /s Pump flow rate scaling
g 9.81 m/s2 Acceleration by gravity
ς
hℓ 0.25 m Level scaling, lower tank
hςu 0.25 m Level scaling, lower tank
H 1 m Pumping elevation
N
k 10 (m/s)2
Friction coefficient
Kℓ 0.1 kg/s Valve coefficient, lower tank
Ku 0.1 kg/s Valve coefficient, upper tank
L 2 m Pipe length
mp ρAp L kg Mass of liquid in pipe
pa 1.01 × 105 Pa Atmospheric pressure
3 3
ρ 10 kg/m Liquid density
Table 6.12: Operating conditions for two tanks with basin and pump/pipe.
Quantity Value Unit Comment
hb (0) 0.25 m Initial level, basin
hℓ (0) 0.2 m Initial level, lower tank
hu (0) 0.2 m Initial level, upper tank
ṁp (0) 0.1 kg/s Initial mass flow rate in pipe
ṁp (0)
V̇p (0) ρ
m3 /s Initial volumetric flow rate in pipe
V̇p (0)
vp (0) Ap
m/s Liquid velocity through pipe
mb (0) ρAb hb (0) kg Initial mass, basin
mℓ (0) ρAℓ hℓ (0) kg Initial mass, lower tank
mu (0) ρAu hu (0) kg Initial mass, upper tank
mp (0) mp vp (0) N s Initial momentum, pipe
u 0.5 — Input signal to pump
320 CHAPTER 6. MOMENTUM BALANCE
0.18
0.16 h
hu
0.14 hb
0.0 2.5 5.0 7.5 10.0 12.5 15.0 17.5 20.0
time t [min]
Figure 6.42: Level in lower tank hℓ (red; output), and levels in upper tank hu (blue)
and basin hb (green); all with unit m.
1 package PipeTwoTank
2 // Package for simulating two tank system with basin and
pump / pipe
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // September 23 , 2015
6 // May 12 , 2017
7 //
8 model SimPipeTwoTank
9 // Simulation of two tank system with basin and pump / pipe
10 // author : Bernt Lie
11 // University of South - Eastern Norway
12 // September 23 , 2015
13 // May 12 , 2017
14 //
15 // Instantiate model of pipe with two tanks ( p2t )
6.10. CASE: TWO TANKS WITH BASIN AND PUMP 321
0.09
[kg/s]
0.08
0.07
0.06
0.0 2.5 5.0 7.5 10.0 12.5 15.0 17.5 20.0
time t [min]
Figure 6.43: Influent flows to lower tank ṁi,ℓ (red), upper tank ṁi,u = ṁp (blue),
and basin ṁi,b (green); all with unit kg/s.
0.5075
0.5050
0.5025
0.5000
0.0 2.5 5.0 7.5 10.0 12.5 15.0 17.5 20.0
time t [min]
16 ModPipeTwoTank p2t ;
17 // Declaring variables
18 // -- inputs
19 Real _u " Pump input signal , -";
20 // -- outputs
21 output Real _hl " Level in lower tank , m ";
22 // Equations
23 equation
24 // -- input values
25 _u = if time < 400 then 0.5 else 0.52;
26 // -- injecting input functions to model inputs
27 p2t . u = _u ;
28 // -- outputs
29 _hl = p2t . hl ;
30 end SimPipeTwoTank ;
31 //
32 model ModPipeTwoTank
33 // Model of two tank system with basin and pump / pipe
34 // author : Bernt Lie
35 // University of South - Eastern Norway
36 // September 23 , 2015
37 // May 12 , 2017
38 //
39 // Constants
40 constant Real g = 9.81 " Acceleration of gravity , m / s2 ";
41 // Parameters
42 parameter Real Ab = 0.25 " Cross sectional area of basin ,
m2 ";
43 parameter Real Al = 0.025 " Cross sectional area of lower
tank , m2 ";
44 parameter Real Ap = 1/(16*100) " Cross sectional area of
pipe , m2 ";
45 parameter Real Au = 0.025 " Cross sectional area of upper
tank , m2 ";
46 parameter Real dpp0 = 1.5 e4 " Nominal pump pressure
increase , Pa ";
47 parameter Real delpVd = 100 " Pump pressure drop due to
flow , Pa ";
48 parameter Real Vdpo = 1e -4 " Nominal pump flow rate , m3 / s
";
49 parameter Real hsl = 0.25 " Level scaling lower tank , m ";
50 parameter Real hsu = 0.25 " Level scaling upper tank , m ";
51 parameter Real H = 1 " Pumping elevation , m ";
52 parameter Real k = 10 " Friction coefficient , N /( m / s ) 2";
53 parameter Real Kl = 0.1 " Valve coefficient lower tank , kg
/ s ";
54 parameter Real Ku = 0.1 " Valve coefficient upper tank , kg
/ s ";
55 parameter Real L = 2 " Pipe length , m ";
6.10. CASE: TWO TANKS WITH BASIN AND PUMP 323
Gas flow
through pipe
Figure 6.46: Functional diagram of gas flow through a pipe, with influent pressure
pi and influent mass flow rate ṁi , and effluent pressure pe and effluent mass flow
rate ṁe .
We consider the system in Fig. 6.45, where a gas with influent pressure pi and
influent mass flow rate ṁi flows through a pipe of length L, influenced by gravity,
friction, and pressure forces, ending at level H below the entrance point with effluent
pressure pi and effluent mass flow rate ṁe .
We are interested in finding the relation between (pi , ṁi ) and (pe , ṁe ). The gas
is considered an ideal gas at constant temperature T . The velocity field is uniform
across the cross sectional area Ap .
The functional diagram in Fig. 6.46 depicts the relationship between (pi , ṁi ) and
(pe , ṁe ).
Note that the resulting model will essentially be a set of hyperbolic PDEs, imply-
ing that it is not straightforward to decide the location of the boundary conditions.
It is thus not straightforward to say in advance what is the input and what is the
output of the system.
326 CHAPTER 6. MOMENTUM BALANCE
Step 1: To find the pressure (or density) and velocity, we need to use the total
mass balance
dm
= ṁi − ṁe
dt
as well as the (linear) momentum balance
dm
= ṁi − ṁe + F .
dt
m RT
pV = nRT = RT ⇒ p = ρ.
M M
Mass flow rates can be expressed via the ideal gas law as
pV̇ = ṅRT
where
V̇ = Ap v
and
ṁ
ṅ = .
M
Momentum is given as
m = mv,
while momentum flow is given as
ṁ = ṁv.
F = Fp + Fg − Ff ,
36
..., but varies with position x.
6.11. CASE: GAS PIPELINE⋆,+ 327
where
Fp = (pi − pe ) Ap
H
Fg = mg
L
1
Ff = K ′′′ Af = ρv 2 ℘ℓf
2
where ℘ is the perimeter. For a circular cross section, Ap = πr2 and ℘ = 2πr,
thus √
Ap
℘ = 2π .
π
If we assume turbulent flow, Fanning’s friction factor f is more or less constant.
Step 3.a: Composing model for volume where x ∈ [ξ, ξ + ∆x]. Assuming that the
gas flows in the positive x-direction (e.g., that v everywhere is positive), we
find
dmξ+∆x
= ṁξ − ṁξ+∆x
dt
dmξ+∆x
= ṁξ − ṁξ+∆x + F ,
dt
where
mξ+∆x = ρξ+∆x V
V = Ap ∆x
RT
pξ+∆x = ρξ+∆x
M
pξ V̇ξ = ṅξ RT
pξ+∆x V̇ξ+∆x = ṅξ+∆x RT
V̇ξ = Ap vξ
V̇ξ+∆x = Ap vξ+∆x
1
ṅξ = ṁξ
M
1
ṅξ+∆x = ṁξ+∆x ,
M
and
mξ+∆x = mξ+∆x vξ+∆x
ṁξ= ṁξ vξ
ṁξ+∆x = ṁξ+∆x vξ+∆x
F = Fp + Fg − Ff
Fp = (pξ − pξ+∆x ) Ap
H
Fg = mξ+∆x g
L
1 2
Ff = ρvξ+∆x ℘∆xf .
2
328 CHAPTER 6. MOMENTUM BALANCE
The reason for assuming positive velocity, is that then we can set m = mξ+∆x ,
etc. If the velocity changes direction, then we need to set m = mξ , etc. The
compressibility of the fluid, with resulting possibility of change of direction of
the velocity is a big problem when it comes to the numeric solution of these
types of models, but we will not discuss that further here.
Step 3.b: Next, we need a model for all x ∈ [0, L]. To find this, we observe that
the model in the previous step can be generalized: by replacing fixed position
ξ with an arbitrary position x, the model becomes valid for any position x ∈
(0, L), i.e., with the possible exception at the boundary.
By generalizing the above model to be valid for any x, this means that
mξ+∆x (t) etc. which only varies with t, now becomes a function of both time
and position, mx+∆x (t, x). Because of this, we need to change the ordinary
derivatives into a partial derivative:
We thus get
∂mx+∆x
= ṁx − ṁx+∆x
∂t
∂mx+∆x
= ṁx − ṁx+∆x + F ,
∂t
where
mx+∆x = ρx+∆x V
V = Ap ∆x
RT
px+∆x = ρx+∆x
M
px V̇x = ṅx RT
px+∆x V̇x+∆x = ṅx+∆x RT
V̇x = Ap vx
V̇x+∆x = Ap vx+∆x
1
ṅx = ṁx
M
1
ṅx+∆x = ṁx+∆x ,
M
6.11. CASE: GAS PIPELINE⋆,+ 329
and
mx+∆x = mx+∆x vx+∆x
ṁx= ṁx vx
ṁx+∆x = ṁx+∆x vx+∆x
F = Fp + Fg − Ff
Fp = (px − px+∆x ) Ap
H
Fg = mx+∆x g
L
1 2
Ff = ρvx+∆x ℘∆xf .
2
Step 3.c: We now want to see what happens with the model when ∆x → 0. In
that case, it is convenient to relax on the DAE formulation, and eliminate
some variables. With
mx+∆x = ρx+∆x V = ρx+∆x Ap ∆x
we find
∂mx+∆x
= ṁx − ṁx+∆x
∂t
⇓
∂
(ρx+∆x Ap ∆x) = ṁx − ṁx+∆x
∂t
⇓
∂ρx+∆x 1 ṁx+∆x − ṁx
=− .
∂t Ap ∆x
With ∆x → 0, we find
∂ρ 1 ∂ ṁ
=−
∂t Ap ∂x
where
M
ṁ = M ṅ = pV̇ .
RT
Similarly, for the momentum balance we have
mx+∆x = mx+∆x vx+∆x = ρx+∆x Ap ∆xvx+∆x
while
F = F ′ ∆x
where
F ′ = Fp′ + Fg′ − Ff′
Fp (px − px+∆x ) Ap px+∆x − px
Fp′ = = = −Ap
∆x ∆x ∆x
F m g H ρ A ∆xg H gH
Fg′ =
g x+∆x x+∆x p
= = = Ap ρx+x∆
∆x ∆x L ∆x L L
1 2
′ Ff 2
ρvx+∆x ℘∆xf 1 2
Ff = = = ρ℘f vx+x∆ .
∆x ∆x 2
330 CHAPTER 6. MOMENTUM BALANCE
Thus,
∂mx+∆x
= ṁx − ṁx+∆x + F
∂t
⇓
∂
(ρx+∆x Ap ∆xvx+∆x ) = ṁx − ṁx+∆x + F ′ ∆x
∂t
⇓
∂ 1 ṁx+∆x − ṁx 1 ′
(ρx+∆x vx+∆x ) = − + F
∂t Ap ∆x Ap
If we let ∆x → 0, we find
∂ 1 ∂ ṁ 1 ′
(ρv) = − + F
∂t Ap ∂x Ap
where
F ′ = Fp′ + Fg′ − Ff′
∂p
Fp′ = −Ap
∂x
gH
Fg′ = Ap ρ
L
1
Ff′ = ρ℘f v 2 .
2
To summarize, we thus have
∂ρ 1 ∂ ṁ
=−
∂t Ap ∂x
∂ 1 ∂ ṁ 1 ′
(ρv) = − + F
∂t Ap ∂x Ap
where
RT
p= ρ
M
M
ṁ = pV̇
RT
F ′ = Fp′ + Fg′ − Ff′
∂p
Fp′ = −Ap
∂x
gH
Fg′ = Ap ρ
L
1
Ff′ = ρ℘f v 2 .
2
If so desired, we can e.g choose to use pressure p and mass flow rate ṁ as state
functions in the PDEs. We observe that we can express ρ by p as
RT M
p= ρ⇒ρ= p.
M RT
6.11. CASE: GAS PIPELINE⋆,+ 331
Next, we express ρv as
ρV̇ ṁ
ρv = = ,
Ap Ap
velocity is
ṁ ṁ RT ṁ
v= = M
= ,
Ap ρ Ap RT p Ap M p
while we express ṁ as
RT ṁ RT ṁ2
ṁ = ṁv = ṁ = .
Ap M p Ap M p
Finally, inserting expressions for ρ and v into the forces per length unit, F ′ ,
we have
( )
∂ M 1 ∂ ṁ
p =−
∂t RT Ap ∂x
( ) ( )
∂ ṁ 1 ∂ RT ṁ2
=−
∂t Ap Ap ∂x Ap M p
( ( )2 )
1 ∂p gH M 1 M RT ṁ
+ −Ap + Ap p − ℘f p
Ap ∂x L RT 2 RT Ap M p
or
∂p RT ∂ ṁ
=−
∂t M Ap ∂x
( )
∂ ṁ RT ∂ ṁ2 ∂p gH Ap M 1 RT ℘ ṁ2
=− − Ap + p− f .
∂t Ap M ∂x p ∂x L RT 2 M A2p p
The most common state functions for this system is, however, (ρ, v).
Step 3.d: The above model is mainly valid for x = (0, L). To complete the descrip-
tion, we need two boundary conditions37 . The problem is where we are allowed
to place them. It turns out that this is somewhat problem-dependent. At high
velocities, both conditions need to be placed at x = 0, i.e., p (t, x = 0) = pi (t)
and ṁ (t, x = 0) = ṁi (t). This leads to the solution p (t, x) and ṁ (t, x) valid
for x > 0, including pe (t) = p (t, x = L) and ṁe (t) = ṁ (t, x = L).
However, at lower velocities, one boundary condition must be placed at x = 0
while the other one should be placed at x = L. Typically, these would be
specifying the pressure at x = 0, i.e., p (t, x = 0) = pi (t), and specifying
the mass flow rate at x = L, i.e., ṁ (t, x = L) = ṁe (t). This leads to the
solution p (t, x) and ṁ (t, x), where we can compute pe (t) = p (t, x = L) and
ṁi (t) = ṁ (t, x = 0).
Step 4: Finally, we need to compute the outputs y = (pe , ṁe ). As seen, this can in
principle be achieved by solving the DAEs with boundary conditions, where-
upon both outputs are computed. Alternatively, we can numerically solve the
PDEs with p and ṁ as state functions, where the sought outputs are found at
the boundary x = L.
37
Two boundary conditions, because in steady state, the result is two first order ODEs in p and
ṁ, and it is well known that this requires two boundary conditions.
332 CHAPTER 6. MOMENTUM BALANCE
⇓
[ ]pe ˆ L
RT 2 1 RT ℘
2
ṁ ln p − p2 = 2 ṁ2 f dx
Ap M 2 pi
Ap M 2Ap 0
⇓
RT 2 pe 1 ( 2 ) RT 2 ℘
ṁ ln − p e − p 2
i = ṁ fL
A2p M pi 2 A2p M 2Ap
⇓
pe A2p M 1( 2 ) ℘
ln − pe − p2i = f L.
pi RT ṁ2 2 2Ap
6.12. CASE: UNDER-BALANCED DRILLING⋆ 333
∆pf = pi − pe ⇒ pe = pi − ∆pf .
Assuming that the inlet pressure pi is known, we thus get the following implicit
equation for computing the pressure drop ∆pf :
( )
pi − ∆pf A2p M 1 ( ) ℘
ln − (p i − ∆p f )2
− p 2
i = fL
pi RT ṁ2 2 2Ap
⇓
( )
pi − ∆pf Ap M 1 (
2 ) ℘
ln − 2
−2p i ∆p f + ∆p 2
f = fL
pi RT ṁ 2 2Ap
or
A2p M 1 ℘
ln (pi − ∆pf ) + 2
(2pi − ∆pf ) ∆pf = f L + ln pi .
RT ṁ 2 2Ap
The case of momentum balance for compressible fluids is difficult to solve nu-
merically. The reason is essentially that compressibility leads to waves traveling
back and forth in the spatial dimension, leading to flow directions that may vary. A
section on good numerical methods to solve such problems is planned, but has not
been included yet. When such a section has been developed38 , more computational
examples will be included.
In these notes, we have not discussed the inclusion of bends, contraction in pipes,
etc.: such situations will give pressure losses which often are modeled as equivalent
friction losses. But it is also possible to equate friction loss with pressure loss over
valves. See Lydersen (1979) for a simple discussion.
6.16 Review*
In this chapter, we have considered Newton’s law and how it can be re-phrased as
a (linear) momentum balance for closed systems/the material description. We have
also considered the similar angular momentum balance for the material description.
Furthermore, we have seen how Newton’s law is related to a mechanical energy
balance.
Next, we have extended the ideas of Newton’s law to open system where the
mass may vary, with the general momentum balance. We have briefly considered
the extensive quality momentum and the intensive quantities pressure and linear
velocity (and angular velocity).
The key forces working in the momentum balance are pressure forces, conserva-
tive forces such as gravity, and non-conservative forces such as the friction force. A
relatively detailed discussion of models for friction in fluid flow is given, both for
flow in filled pipes and for flow in open channels.
Planned topics on compressibility and wall elasticity, turbo machines, and nu-
meric methods to solve hyperbolic models have been deferred to a later version.
Through examples, the use of the momentum balance for computing velocity/vol-
umetric flow rate/mass flow rate is given. Constant density cases are illustrated us-
ing Modelica with simulation in OpenModelica. Varying density systems are more
complex to solve, and their solution is deferred to a later version.
So far, we have assumed that the temperature of the matter has been known.
In the next chapter, we will see how the energy balance can be used to model the
temperature of matter.
6.17 Exercises*
Exercise 6.1. [Solution D.15 p. 584] Mean velocity in laminar flow.
For laminar flow in cylindrical pipes of radius R, and with distance r from the
center line, it can be shown that the velocity is zero at the wall, r = R, and has a
38
...probably in 2016.
6.17. EXERCISES* 335
= −2 · log10 · 10 4κ 2 .
2 √
√
fD NRe fD
N
336 CHAPTER 6. MOMENTUM BALANCE
6.18 Problems*
Problem 6.1. [Solution E.9 p. 595] Fanning friction factor across laminar-turbulence
gap.
In Section 6.4.1, expressions for Fanning’s friction factor f as a function of
Reynolds’ number are given. However, there is a gap in the validity of the friction
factor: in a transitional region between laminar (NRe < 2.1 × 103 ) and turbulent
flow (NRe > 2.3 × 103 ), Fanning’s friction factor is not defined. In some cases, the
system may have a Reynolds number that lies in this undefined region. The best way
to handle this problem is probably to interpolate between flaminar (NRe = 2.1 × 103 )
and fturbulent (NRe = 2.3 × 103 ).
• Describe how you can use linear interpolation to fill the gap and ensure that
f (NRe ) is defined for all relevant values NRe .
Sometimes, it is also desirable that a model is continuously differentiable.
• Describe how you can use interpolation which ensures that the gap is filled,
and that f (NRe ) is differentiable wrt. NRe for all relevant values NRe . N
Problem 6.2. [Solution E.10 p. 595] Shock damper.
Consider the system in Fig. 6.47.
Figure 6.47: Sketch of mass hanging in a spring, with damping. Mass m is affected
by the spring force, friction force, gravity force, and an external force F .
Potential energy is composed of two terms: one term due to gravity, mgx, and
one term due to the spring being stretched from its rest position x0 , (x − x0 )2 k/2.
Potential energy P thus becomes:
k
P = mgx + (x − x0 )2 .
2
The potential energy describes the effect of the force of gravity and the spring force.
The total energy of the system is E = K + P . We also need to include the effects
of the damping force Fd and the external force F .
From basic physics, we know that a change of energy dE of a system affected by
forces, is equal to force working on the system multiplied by distance dx. In other
words:
dE = Fd dx + F dx.
By dividing with the time dt it takes to move the distance dx, we find
dE dx dx
= Fd +F
dt dt dt
⇓
dE
= (Fd + F ) v.
dt
The damping force Fd (the friction force) is given as
Fd = −µv,
where µ ≥ 0.
dE
• Assume that the external force F = 0. Discuss the resulting equation =
dt
−µv 2 (where Fd = −µv).
• Show that when m is a constant mass, the time derivative of total energy E
is given as
dE dv
= mv + mgv + k (x − x0 ) v.
dt dt
• Develop a model in state space form of the position x of the mass when F
is allowed to differ from zero. (Hint: The approach is similar to the method
applied in Example 6.1 p. 223.)
• What must be known before we can solve the model of the mass-spring-damper
system? (I.e., what must we know before we can compute x (t)?) N
Problem 6.3. [Solution E.11 p. 597] Shock damper model from the Euler-Lagrange
equation.
Solve Problem 6.2 using the Euler-Lagrange formalism. Do you get the same result?
(What do you get if you use Newton’s laws?) N
Problem 6.4. [Solution E.12 p. 597] Consider the system in Fig. 6.47.
338 CHAPTER 6. MOMENTUM BALANCE
Solve Problem... N
1. Formulate a mass balance for the vessel, and find an expression for the level
h.
2. Formulate the momentum balance for the mass of liquid within the pipe, and
find an expression for the volumetric flow V̇i . Assume that the friction force
Ff is given as
Ff = cV̇i2 .
where u is given by the velocity of the pump. Put the model in state space
form.
4. To ensure that the level in the vessel is kept at a reasonable value39 , we intro-
duce a P controller (proportional controller) which governs the pump velocity
39
i.e., the vessel should rather not get empty or flow over.
Figure 6.48: Sketch of vessel which is filled with liquid from pumping liquid through
a pipe.
6.18. PROBLEMS* 339
u = us + Kp (hr − h)
where:
( )
∆p = u c1 − c2 V̇i2
Ff = cV̇i2
and
u = us + Kp (hr − h) .
• Use the numerical values and operating conditions in Table 6.13, and simulate
the system over a period of 5 h. If you choose to use a fixed step-length solver,
you can use a step length of ∆t = 1 × 10−2 h.
Problem 6.7. [Solution E.15 p. 602] Entrance level/flow from tank to flume.
Table 6.13: Numerical values for parameters and operating points for the model of
Problem 6.5.
Numerical values
2
A = 10 m cross-sectional area of vessel
Ap = 10−2 m2 cross-sectional area of pipe
mp = 10 tonne mass of liquid in pipe
(if ρ = 1 tonne/m3 , then L = 1 km)
−6 2 −4
c = 8 × 10 bar h m friction coefficient
−4
c1 = 3 × 10 bar constant in pump characteristic
−8 2 −6
c2 = 4 × 10 bar h m —”—
m−1 h−2
κp = 102 × 36002 tonnebar conversion factor from bar to tonne m−1 h−2
Kp = 100 m−1 proportional gain
us = 0 — constant offset in controller
hr = 2 m reference value, level
h|t=0 = 1.9 m initial value, h
V̇i = 2 3
m /h initial value, V̇i
t=0
V̇e : 2 − 0.5H2 h m3 /h volumetric flow out of vessel
Chapter 7
Energy balance*
• Pressure work rate, volume work rate, and friction work rate.
∆E = ∆W + ∆Q.
341
342 CHAPTER 7. ENERGY BALANCE*
Here, ∆E is the change of total energy within the system, ∆W is net supply of work
on the system from the surroundings, while ∆Q is the net supply of heat from the
surroundings to the system.1 This notation is somewhat imprecise, in that ∆E is
the change of total energy within the system, while ∆W and ∆Q represent supply
of energy by energy flow across the system boundary from the surroundings to the
system, respectively flow of work and heat. To make the notation more precise, we
write
dE = δW + δQ,
where dE now represents an infinitesimal change of total energy within the sys-
tem, while δW and δQ represent infinitesimal supply of energy across the system
boundary.
As before, we are mainly interested in the energy change per time dt, leading to
dE δW δQ
= + .
dt dt dt
Here, dE
dt
is the net change of total accumulated energy per time, δW
dt
is the net work
rate (energy per time) from the surroundings to the system, while δQ dt
is the net
heat flow (energy per time) from the surroundings to the system. It is convenient
to introduce the simplified notation
δW
Ẇ ,
dt
δQ
Q̇ , .
dt
Thus, the energy balance can be written as follows in the material description2 :
dE
= Ẇ + Q̇. (7.1)
dt
If the system is isolated, neither mass nor energy flows interact with the surround-
ings, and dE
dt
≡ 0 ⇒ E = constant, and energy is conserved. What if we include Ẇ
and Q̇? As we will see, part of the work rate relates to work done on the system
boundary ∂V (e.g., pressure power) while other parts relates to work done within
the system volume V (e.g., friction work). Similarly, part of the heat flow relates
to heat flowing across the system boundary ∂V (e.g., heat conduction), and part
of the heat flow relates to heat absorbed in the system volume V (e.g., radiation).
Because of this, the energy balance for an open system may have source terms, and
we will refer to Eq. 7.1 as energy balance.
1
In some presentations, this energy balance is written as ∆E = −∆W + ∆Q, where ∆W then
has the different meaning of work carried out by the system on the surroundings. The formulation
∆E = −∆W + ∆Q is common when the main topic is machines and how they produce work to
the surroundings (from the system) — when we define ∆W in this way, the work that is produced
is positive. In these notes, however, the more modern approach of putting the system in focus is
used. Then it is more natural to use ∆E = ∆W + ∆Q such that the added work to the system is
positive.
2
Note: in some fields such as control engineering, ẋ is often equivalent to dx
dt . This equivalence
is not valid in these notes: here, ẋ is equivalent to δx
dt , which is something totally different from
dx
dt !
7.3. ENERGY BALANCE FOR OPEN SYSTEMS 343
dE
= Ėi − Ėe + Ẇ + Q̇. (7.2)
dt
Here, Ėi is the total influent energy transported via mass flow into the system, while
Ėe is the total effluent energy transported via mass flow. Energy which flows via
mass transport into and out of the system (i.e., Ėi , Ėe ), is known as convective
3
Symbol ∝ denotes is proportional to.
344 CHAPTER 7. ENERGY BALANCE*
energy transport.4
Let us now look in more detail at the various terms in the energy balance.
As already mentioned, E is the total energy in the system, i.e., the accumulated5
total energy in the system. Thus, dE/dt is the change of accumulated energy in
the system6 . Next, as mentioned, Ėi − Ėe is the net supply of total energy by
convection (carried by the mass flows ṁi and ṁe ). The term Ẇ is the work rate
or power added to the system in the form of (mechanical) work, while Q̇ represents
addition of energy by a heat flow. Since total energy E has dimension [energy],
the change of total energy per time (dE/dt) must have dimension [energy/time].
Consequently, convective energy flow (Ėi , Ėe ), work rate Ẇ , and heat flow Q̇ must
all have dimensions [energy/time]. In the SI system, the standard unit for dimension
[energy/time] is Watt, with symbol W, where 1 W = 1 J s−1 . But there is nothing
wrong in using other units such as kJ min−1 , etc. The requirement is simply that
every term that are summed or equated must have the same unit.
∑
N
1 1
K − ⟨K⟩ = mj vj2 − mv 2 .
j=1
2 2
It should be quite clear that normally, K − ⟨K⟩ ̸= 0. It is only in the special case of
vj ≡ v that K − ⟨K⟩ ≡ 0. The case of vj ≡ v is identical to the case of absolute zero
temperature; at absolute zero temperature, the particles are moving in tandem with
their mass center velocity. However, with a temperature larger than absolute zero,
the particles start to fluctuate around their mass center velocity, and the higher the
temperature, the more violent this fluctuation is.
Next, we consider potential energy at the particle level, typically
∑
N
P = Pj
j=1
∑
N ∑
1
P = kjℓ (yjℓ − yj,0 )2 ̸= ⟨P ⟩
j=1 ℓ̸=j
2
where ⟨P ⟩ is some potential energy for the mass center. The deviation between the
actual (particle level) potential energy P and the potential energy of the mass center
⟨P ⟩ will increase if particles are relocated to new location where the “springs” are
further extended, e.g., due to new, stable chemical species.
The total energy E is given by the true kinetic and potential energies at the
particle level. Because K ̸= ⟨K⟩ and P ̸= ⟨P ⟩, we can write
E = K + P = ⟨K⟩ + ⟨P ⟩ + U
where U is known as the internal energy of the system. In order to simplify the
notation, we will write K instead of ⟨K⟩ and P instead of ⟨P ⟩, and thus write
E = K + P + U.
346 CHAPTER 7. ENERGY BALANCE*
It follows that the internal energy U contains information about the temperature
of the system, where the temperature is interpreted as representing the kinetic energy
of particle movement around the mass center. Furthermore, the internal energy
contains information about relocation of particles in the sense of particles colliding
and forming (stable) new species. Typically, the potential energy part of U is set
to zero for pure elements at their normal conditions (e.g., phase), and then some
internal energy of formation is introduced for chemical compounds and for elements
outside of their normal phase, etc.
In the same way as total energy E is composed of kinetic energy (for the mass
center), internal energy, and potential energy (for the mass center), the convective
total energy flows Ė are composed of the same energies:
dEm
= Ėm,i − Ėm,e + Ẇm . (7.3)
dt
Here, the mechanical power Ẇm consists of terms that influence the movement of
the system. Examples of such forces/power are pressure forces at the influent and
effluent system surfaces represented by pressure power Ẇp , friction power dissipation
by agitation or friction forces along system walls, both leading to friction power Ẇf ,
compression forces within the system volume leading to a compression power Ẇc ,
external power Ẇv used to change the system volume, and other types of boundary
work Ẇb . Thus
Ẇm = Ẇp + Ẇf + Ẇc + Ẇv + Ẇb .
Let us discuss these mechanical power terms in turn.
First, pressure power is caused by the external pressure forces working on the
system:
Ẇp = Fi vi − Fe ve = pi Ai vi − pe Ae ve = pi V̇i − pe V̇e .
Next, we consider friction power. A key idea with friction power is that it
represents conversion of energy from mechanical energy to internal energy, as the
following example indicates.
In Problem 6.2 p. 336, a shock damper is studied. The total mechanical energy
Em = K + P is exposed to a damping force (friction) Fd , and the energy balance
leads to
dEm
= Fd v
dt
where v is the velocity. The damping force Fd (the friction force) is given as
Fd = −µv,
1. The friction power Ẇf is negative, causing the mechanical energy to decrease
over time.
So where does the friction power go? In the case of the shock damper, friction will
heat up the damper oil. Thus, we can make a distinction between the mechanical
energy of mass m, Em,m , and the “thermal” energy of the damper, Ed . By this way
of expanding the system to consist of two subsystems, the mass and the damper, we
have to formulate two energy balances:
dEm,m
= −µv 2
dt
dEd
= +µv 2 .
dt
Here, we also observe that the total energy of the system, E = Em,m + Ed must
satisfy the differential equation
dE dEm,m dEd
= + = 0!
dt dt dt
N
To sum up, friction power Ẇf is strictly non-positive (Ẇf ≤ 0), except for possible
transient power in the special case of viscoelastic fluids. Furthermore, friction power
is not lost, instead −Ẇf is transferred to internal energy in such a way that if we sum
the mechanical and the damper (internal) energy, friction gives zero contribution to
the total energy. Friction power can, e.g., be due to friction loss along the system
walls, or due to power loss in agitation.
348 CHAPTER 7. ENERGY BALANCE*
Next, we consider the internal volume compression work Ẇc which is related to
how velocities within the system change because of changes in density, etc., due to
pressure. Bird et al. (2002) give this term as
ˆ
Ẇc = p (∇ · v) dV.
V
dV
Ẇv = p .
dt
Power Ẇv also gives an opposite sign contribution to the internal energy, and these
terms sum to zero for the sum of the mechanical and internal energy balances.
Finally, we can consider other types of boundary power Ẇb which influences the
movement of the system content, but not the internal energy.
In summary, we have that the total power Ẇ can be expressed as those terms
from the mechanical power Ẇm which are not converted to increase the internal
energy,
Ẇ = Ẇp + Ẇb ,
or alternatively
Ẇ = Ẇm − Ẇf − Ẇc − Ẇv .
Table 7.1: Thermal conductivity k [ mWK ] for some materials at pressure 1 atm. Data
taken from Geankoplis (1993), p. 218.
Substance Temp. (K) k Substance Temp. (K) k
Gases Solids
Air 273 0.0242 Ice 273 2.25
373 0.0316 Fire clay-brick 473 1.00
H2 273 0.167 Paper — 0.130
n–Butane 273 0.0135 Hard rubber 273 0.151
Liquids Cork board 303 0.043
Water 273 0.569 Asbestos 311 0.168
366 0.680 Rock wool 266 0.029
Benzene 303 0.159 Steel 291 45.3
333 0.151 273 45
Biological materials and foods Copper 273 388
Olive oil 293 0.168 373 377
373 0.164 Aluminum 273 202
Lean beef 263 1.35
Skim milk 275 0.538
Apple sauce 296 0.692
Salmon 277 0.502
248 1.30
where x is the spatial coordinate and k is the thermal conductivity. This rela-
tionship is known as Fourier’s law. Examples of thermal conductivities taken from
Geankoplis (1993), are shown in Table 7.1.
Assume that we have one-dimensional heat flow through a homogeneous material
of thickness δ, Fig. 7.1.
It can then be shown that the temperature T (t, x) in the material is given by
the model
∂T ∂ 2T
=α 2
∂t ∂x
where α is some parameter. The boundary conditions could be to specify T in
positions x = 0 and x = δ, as indicated in Fig. 7.1.
Suppose that the material in Fig. 7.1 is a subsystem of a larger system. Depend-
ing on the heat capacity of the material, the dynamics of the heat conduction may
or may not be important in the context of the overall system. If the dynamic is
of little importance, we can instead consider the steady state. In steady state, the
dynamic heat conduction model reduces to
d2 T dT
2
=0⇒ = c1 ⇒ T = c0 + c1 x.
dx dx
By assuming that Tx=0 = T0 ⇒ c0 = T0 and Tx=δ = T1 ⇒ T0 + c1 x = T1 ⇒ c1 =
T1 −T0
δ
, we find that the solution is
T1 − T0
T (x) = T0 + x.
δ
350 CHAPTER 7. ENERGY BALANCE*
Figure 7.1: Heat flow by conduction through homogeneous material, with tempera-
ture Tx=0 = T0 and Tx=δ = T1 .
Bulk volume
Boundary layer
Wall
Figure 7.2: The mechanism of heat convection. y is the distance from the wall, and
T is the fluid temperature. The boundary layer is thin.
∂T k
Q̇′′c = −k = (T0 − T1 ) ,
∂x δ
and is thus independent of position x through the slab.
Table 7.2: Approximate value of some heat transfer coefficients. Data taken from
Geankoplis (1993), p. 219. [ ]
Mechanism Range of values h mW 2K
The boundary layer is normally very thin, and is particularly difficult to model
for turbulent flow. It is thus common to neglect the boundary layer, and imagine that
the temperature varies abruptly from the wall temperature to the bulk temperature
with a temperature difference ∆T = Tw − Tb . The combined convective energy
flux and heat conduction flux from wall to bulk, Q̇′′w2b [energy/(time area)] is thus
modeled as
Q̇′′w2b = h (Tw − Tb ) (7.4)
where h [power/(area temperature)] is the heat transfer coefficient; Q̇′′w2b > 0 if
Tw > Tb .
Typically, we operate with heat transfer between a fluid to a solid. The heat
transfer coefficient is then independent of the substance of the solid material, and
only depends on the substance and velocity/movement of the fluid. Table 7.2 is
taken from Geankoplis (1993).
Similarly as to for the friction factors, relations between dimensionless numbers
have been developed for heat transfer. For the heat transfer coefficient, the Nus-
selt number acts as dimensionless heat transfer coefficient. The Nusselt number is
defined as
hD
NNu , (7.5)
k
where h is the heat transfer coefficient, D is a characteristic length, and k is the
thermal conductivity; Table 2.15 p. 36 gives an overview of dimensionless numbers.
For forced convection in tubes, the Nusselt number depends on
where subscript b refers to the bulk of the fluid and subscript w refers to the wall,
the dimensionless Prandtl number is
µb ĉp,b
NPr , , (7.7)
kb
L/D is the ratio of the length to the diameter of the pipe, and µ is the viscosity of
the fluid. The viscosities µb and µw are to be evaluated at the relevant temperatures.
For laminar flow through pipes and assuming constant fluid properties, it has
been found theoretically that for perfectly smooth pipes, the Nusselt number is
352 CHAPTER 7. ENERGY BALANCE*
given as
48
NNu = . (7.8)
11
For turbulent flow and constant fluid properties with constant heat flux along the
pipe, a simple expression is that of Dittus and Boelter:
{
0.8 0.4
0.024NRe NPr for heating
NNu = 0.8 0.3
, (7.9)
0.026NRe NPr for cooling
[ ] L
NPr ∈ [0.7, 120] , NRe ∈ 2500, 1.24 × 105 , > 60.
D
A more accurate expression is that of Sandall and co-workers,
√
NRe NPr f2
NNu = ( √ ) , (7.10)
2/3 1/3
12.48NPr − 7.853NPr + 3.613 ln NPr + 5.8 + 2.78 ln 45 1
NRe f8
[ ]
0.5 ≤ NPr < 2 × 103 , NRe ∈ 104 , 5 × 106 .
For systems with low Prandtl numbers, such as liquid metal, other expressions
must be used. All of the above expressions presume a smooth pipe. For rough pipes,
other expressions must be used (Rohsenow et al. 1998).
For systems where viscosity and other fluid properties vary through the pipe,
the above expressions are not accurate. When the fluid properties vary through the
pipe, the laminar case may be described by
( )1/3 ( )0.14
D µb
NNu = 1.86 NRe NPr
L µw
while the highly turbulent flow case for L/D > 10 and NRe > 20 × 103 may be
described by ( )0.14
0.8 1/3 µb
NNu = 0.026NRe NPr
µw
— the latter is seen to be a modification of the Dittus and Boelter expression. It
should be noted that the expressions for varying fluid properties such as µj may be
based on non-local temperatures, etc. (Bird et al. 2002).
See Bird et al. (2002) for an introduction to interphase transport in nonisother-
mal systems, and Rohsenow et al. (1998) for a more detailed treatment, with further
references.
Fluid
Solid
Fluid
Solid
Solid
Fluid
Figure 7.3: Example of layered structure with solid and fluid layers between fluids
with bulk temperatures Tb,1 and Tb,2 .
Due to steady state, and assuming no heat leakage in the system, it follows that the
heat flux between each layer is the same, Q̇′′s .
We can now describe the heat flux as follows:
( )
Q̇′′s = h1 Tb,1 − T1− (7.11)
k1 ( − )
Q̇′′s = T1 − T1+ (7.12)
δ1
k2 ( − )
Q̇′′s = T2 − T2+ (7.13)
δ2
k3 ( − )
Q̇′′s = T3 − T3+ (7.14)
δ3
k4 ( − )
Q̇′′s = T4 − T4+ (7.15)
δ4
( )
Q̇′′s = h2 T4+ − Tb,2 . (7.16)
In addition, temperature continuity between the layers dictates that T1+ = T2− ,
T2+ = T3− , T3+ = T4− . By eliminating 4 of these temperatures, we reduce the model
to
( )
Q̇′′s = h1 Tb,1 − T1−
k1 ( − )
Q̇′′s = T1 − T1+
δ1
k2 ( + )
Q̇′′s = T1 − T2+
δ2
k3 ( + )
Q̇′′s = T2 − T3+
δ3
k4 ( + )
Q̇′′s = T3 − T4+
δ4
′′
( )
Q̇s = h2 T4+ − Tb,2 .
354 CHAPTER 7. ENERGY BALANCE*
′′
Next, we can solve the last of these expressions wrt. T4+ , leading to T4+ = Tb,2 + Q̇h2s ,
which is then inserted into the next-to-last expression with result:
( ) ( )
′′
′′ k Q̇ δ4 1
Q̇′′s .
4
Q̇s = T3 − Tb,2 −
+ s
⇒ T3 = Tb,2 +
+
+
δ4 h2 k4 h2
Next, let us remove the assumption of a stagnant fluid layer and instead allow
for some movement of the fluid. We then have to replace the single expression in
Eq. 7.14 by the two expressions
( )
Q̇′′s = h3 T2+ − Tb,3
( )
Q̇′′s = h3 Tb,3 − T4+ ,
and replace the two unknowns T3− and T3+ by the single unknown Tb,3 . The elimi-
nation procedure will then lead to
1 1 δ1 δ2 2 δ4 1
= + + + + + .
U h1 k1 k2 h3 k4 h2
|{z}
1
h3
+ h1
3
8
The normal symbol for the overall heat transfer coefficient is U , and it is common to talk about
the “U -value” of, e.g., windows. On the other side, symbol U also has a long history of denoting
internal energy, and is used as such in most books on thermodynamics. The internal energy will
be used quite a bit in these notes, too. In an attempt to avoid confusion, the overall heat transfer
coefficient is therefore denoted U.
7.7. THERMAL ENERGY BALANCE 355
1 ∑ bn
1 ∑ s n
δj
= + ,
U h
j=1 j
k
j=1 j
where nb is the number of boundary layers involved with corresponding heat transfer
coefficient hj , while ns is the number of solid/stagnant fluid slabs with corresponding
thickness δj and heat conduction coefficient kj .
Finally, let us once more emphasize that the idea of overall heat transfer and
overall heat transfer coefficient U is useful for subsystems that can be considered
in steady state. If, for some reason, some of the layers have a considerable heat
capacity, it may be necessary to use a dynamic model for that layer.
7.6.5 Radiation*
In addition to heat conduction, a system may be exposed to radiation, which is heat
transport through “vacuum”. Radiation of heat is, contrary to conduction of heat,
not dependent on physical contact between the media to exchange heat. The energy
in the charged particles is absorbed within the system, and thus constitutes a source
term. Assuming that the radiating medium has temperature T , then the absorbed
heat flux in the receiving medium is given by the Stefan-Boltzmann law as
q = εσT 4 ,
where q is given as [energy/(time area)]. For so-called black materials which do
not reflect heat, ε = 1, while for materials that reflect heat, ε < 1. If we have a
medium that radiates heat at temperature T1 , and a medium that absorbs heat at
temperature T2 , the total heat flux absorbed will be
( )
q = σ ε1 T14 − ε2 T24 .
See Bird et al. (2002) and Geankoplis (1993) for more details.
balance is not very difficult to develop, but involves some technical details — see
next section.
In a DAE model formulation, it is recommended to use the thermal energy
balance in the above form, and then add the algebraic equation U = H − pV as well
as algebraic thermodynamic relations relating H and p to mass, temperature, etc.
where ṅi > 0 is the number of rotations per time unit, ρ is the fluid density, Di is
the characteristic length of the impeller — typically the impeller diameter, while f
is some friction factor.
In essence, we have three possible strategies for handling friction power. In all
cases, the friction power Ẇf ≤ 0 and will slow down the mechanical movement of the
system content. But for the thermal/internal energy part which is heated by −Ẇf ,
we can consider any of the three following possibilities. (i) We assume that all the
dissipated friction power is absorbed by the internal energy in the system volume.
Possible heating of the wall (environment) is then described by heat flow. (ii) We
assume that all the dissipated friction power is absorbed by the environment, and
heating of the system volume is then described by heat flow from the environment
to the system volume. (iii) We assume that the dissipated friction power is partially
absorbed by the system volume (by some fraction), and partially absorbed by the
wall/environment — with heat flow between the two volumes.
In reality, the friction “rubbing” of fluid against the system volume will heat up
both the fluid and the wall. Still, the most common strategy is to assume that all
the friction power is absorbed within the system volume.
The internal volume compression Ẇc can be shown to be10
ˆ
Ẇc = p (∇ · v) dV (7.19)
V
⇓
ˆ
Ẇc = pe V̇e − pi V̇i − v (∇p) dV. (7.20)
V
10
First, the product rule for differentiation gives
ˆ ˆ ˆ
∇ · (pv) dV = p (∇ · v) dV + (v · ∇p) dV
V V V
⇓
ˆ ˆ ˆ
p (∇ · v) dV = ∇ · (pv) dV − (v · ∇p) dV.
V V V
Next, the divergence theorem, which is a generalization of the fundamental theorem of calculus,
gives ˆ ˛
∇ · (pv) dV = pv · ndS;
V ∂V
here ∂V indicates the surface of volume V and n is the surface normal vector pointing outwards
from the volume. Here, ˛
pv · ndS = −pi V̇i + pe V˙e ;
S
for the influent, the velocity is directed opposite to the outwards pointing normal vector, hence the
negative sign, while for the effluent the velocity points in the same direction as n, hence a positive
sign. In summary, ˆ ˆ
p (∇ · v) dV = pe V̇e − pi V̇i − (v · ∇p) dV.
V V
358 CHAPTER 7. ENERGY BALANCE*
because the internal velocity field to achieve perfect mixing is not well defined.
However, for a well mixed tank, there is no pressure gradient, thus in Eq. 7.20,
∇p ≡ 0, and it follows that for a well mixed tank,
Ẇc = pe V̇e − pi V̇i . (7.21)
Finally, we have Ẇv = p dV
dt
.
Inserting the expression for the internal compression power Ẇc into the internal
energy balance leads to
dU ( )
= U̇i − U̇e + pi V̇i − pe V̇e − Ẇf − Ẇv + Q̇
dt
⇓
dU ( ) ( )
= U̇ + pV̇ − U̇ + pV̇ − Ẇf − Ẇv + Q̇.
dt i e
In thermodynamics, one of several energy expressions is enthalpy H, which simply
is defined as
H , U + pV ; (7.22)
enthalpy is internal energy plus the product of pressure and volume. The enthalpy
flow is found in the standard way11 as
Ḣ = U̇ + pV̇ ,
and we can thus rephrase the internal energy/thermal energy balance as
d
U = Ḣi − Ḣe − Ẇf − Ẇv + Q̇ (7.23)
dt
where
U = H − pV,
friction power satisfies Ẇf ≤ 0 ⇒ −Ẇf ≥ 0, and the volume work is
dV
Ẇv = p .
dt
For liquids, V (t) will typically be given by the mass balance. For gases, normally
V = constant — unless the volume is changed as in a piston. Alternatively, the
volume V (t) may be given by the momentum balance, e.g., if the volume is allowed
to expand against a spring.
We can also insert the expression for internal energy and the expression for
volume work Ẇv , and get
d dV
(H − pV ) = Ḣi − Ḣe + Ẇf − p + Q̇
dt dt
⇓
dH dV dp dV
−p −V = Ḣi − Ḣe + Ẇf − p + Q̇
dt dt dt dt
⇓
dH dp
−V = Ḣi − Ḣe + Ẇf + Q̇. (7.24)
dt dt
11
Extensive variables (H, U , V ) are converted to flow variables (Ḣ, U̇ , V̇ ), while intensive
variables are preserved as they are (p).
7.8. BASIC THERMODYNAMICS 359
pV = nRT
where R is the ideal gas constant. Similarly, we have seen that for an ideal mixture
of substances, the partial pressure of substance j, pj , is given as
pj V = nj RT
∑
pj and the total
with total pressure p being the sum of partial pressures, p = j ∑
number of moles n being the sum of moles of the substances, n = j nj .
Similarly, for flow systems, we get
pj V̇ = ṅj RT.
where Fj• is the thermodynamic quantity of pure substance j when we pretend that
substance j occupies the volume alone. Often, superscript • is dropped if it is
obvious that we refer to a fictitious pure
∑ substance in a mixture. In general, i.e.,
•
for non-ideal solutions, we have F ̸= F
j j . Examples of such thermodynamic
quantities F are internal energy U , enthalpy H, and volume V . Here U and H are
related as H , U + pV .
Because F is an extensive quantity, it is proportional to the amount of material,
F = mF̂ = nF̃ ,
12
Sometimes, the steady state enthalpy formulation is presented: 0 = Ḣi − Ḣe − Ẇf − Ẇv + Q̇.
In some literature, this steady state enthalpy formulation is then erroneously generalized to an
“enthalpy balance” dHdt = Ḣi − Ḣe − Ẇf − Ẇv + Q̇ — which clearly is incorrect.
360 CHAPTER 7. ENERGY BALANCE*
where F̂ is denoted specific quantity (i.e., per mass) and F̃ is denoted molar quantity
(i.e., per mole); as examples Ĥ is specific enthalpy and Ũ is molar internal energy.
In the same vein, for ideal solutions, we have Fj• = mj F̂j• = nj F̃j• . For flow systems,
Ḟ = ṁF̂ = ṅF̃
Here, βT has already been used in relation to compressibility of fluids in pipes, e.g.,
in hydraulics.
We are now finally able to describe the differential in specific and molar enthalpies
as
dĤ = ĉp dT + V̂ (1 − αp T ) dp
dH̃ = c̃p dT + Ṽ (1 − αp T ) dp.
It is easy to see that for ideal gas, αp = T1 , while for an ideal, constant density liquid
or solid, αp = 0. In consequence, for ideal gas:
ˆ T
◦
dH̃ = c̃p dT ⇒ H̃ = H̃ + c̃p dT
T◦
With the above quantities and expressions, we can now use the thermal energy
balance with added algebraic equations
U = H − pV
∑
H= Hj•
j
Hj• = nj H̃j•
∑
Ḣ = Ḣj•
j
and choose expression for H̃j• depending on whether we have ideal gas or ideal
liquid/solid. Similarly if we choose to use mass as basis.
dmxj
= Fjx ⇒ dmxj = Fjx dt.
dt
If we assume elastic collision at time t between the particle and the wall such that
the particle velocity at time t− is −vj,x and the velocity at time t+ is vj,x , the change
in momentum in direction x for the collision is
2L
∆tj = .
vj,x
362 CHAPTER 7. ENERGY BALANCE*
It follows that
=m
∑
N 2
m̆vj,x 2 1 z}|{ 1 ∑ 2
N
21 2
Fx = = m̆N vj,x = mv
j=1
L L2 N j=1 L2 x
| {z }
=vx2
where vx2 is the average squared velocity of the particles in the x-direction
( and m )=
1 1
N m̆. With total average kinetic energy equal to K = 2 mv 2 = 2 m vx2 + vy2 + vz2 ,
and assuming vx2 = vy2 = vz2 , we get
2 1 v2 12
Fx = m = K.
L2 3 L3
The pressure on the wall is
Fx Fx 1 2 12
p= = 2 = 3 K= K
A L L 3 V 3
⇓
2
pV = K.
3
If we consider a system with average velocity v ≡ 0, the kinetic energy K we
refer to, is the rapid movements about this average velocity, hence K is part of the
internal energy U . Furthermore, the development above neglects potential energy
forces between the particles, and there is no reaction taking place. Thus, with no
potential energy, it follows that U = K. Thus, for ideal gas,
3
U = pV . (7.25)
2
In the kinetic theory of gases, the concept of temperature is not defined at the
outset. To this end, we define absolute temperature T for this ideal gas as
m̆vx2 m̆v 2
T , =
kB 3kB
7.8. BASIC THERMODYNAMICS 363
2 12 N m̆v 2 2 K
T = = .
3 kB N 3 kB N
Introducing the mole number n = NNA ⇒ N = NA n where NA = 6.02214086 ×
1023 mol−1 is Avogadro’s number, we find
2 K
T = .
3 kB NA n
We next introduce the ideal gas constant R,
J
R , kB NA = 1.3806488(13) × 10−23 · 6.02214086 × 1023 = 8.314 5 .
mol K
Then
2 K 2 U 3
T = = ⇒ U = nRT . (7.26)
3 nR 3 nR 2
By combining the expressions for U in Eqs. 7.25 and 7.26, we find
3 3
pV = nRT ⇒ pV = nRT .
2 2
So far, the model pV = nRT is only valid for monatomic gases with certain
assumptions of non-interaction between the particles, ideal collisions, etc. In a
generalization, it turns out to be necessary to modify Eq. 7.26 into the following
more general form:
c̃ig
U = v nRT ⇒ Ũ = c̃ig
vT (7.27)
R
with Ũ = U/n, and
pV = nRT ⇒ pṼ = RT (7.28)
with Ṽ = V /n. In Eq. 7.27, c̃ig
v is the ideal gas molar heat capacity at constant
c̃ig
volume and Rv is a scaled, dimensionless molar heat capacity at constant volume.
ig
As we have seen, for monatomic ideal gases, c̃Rv = 32 . More generally for ideal gases,
3
2 , monatomic gases
c̃ig
v 5
= , diatomic gases (7.29)
R 2
3, more complex gases.
ig
Clearly, these values for c̃Rv are not valid for any molecule — for complex molecules,
the assumptions behind ideal gases may break down.
Relationships such as those in Eqs. 7.27 and 7.28 are known as Equations of
State (EoS). A gas which can be described by the model in Eqs. 7.27 and 7.28 is
ig
referred to as and ideal gas, even if we replace the expression for c̃Rv in Eq. 7.29 with
c̃ig
v (T )
a temperature function R
.
364 CHAPTER 7. ENERGY BALANCE*
Postulate II. There exists a function, called the entropy S, of extensive arguments
U , V , and n1 , . . . , nns of any composite system, defined for all equilibrium
states with the following properties: in the absence of internal constraints,
the values reached by the extensive arguments are those that maximize the
entropy S.
Amongst others, this implies that there is a function S = S (U, V, n1 , . . . , nns ) relat-
ing entropy S with the extensive arguments; for simplicity we use the same symbol
for quantity entropy S and the function S (·).
Furthermore, this postulate implies that at equilibrium, the entropy is maxi-
mized.
Postulate III. The entropy of a composite system is additive over the subsystems.
The entropy is continuous and differentiable, and is a monotonically increasing
function of internal energy U .
This last property implies that it is possible to invert the relationship and express
U as
U = U (S, V, n1 , . . . , nns )
which contains all thermodynamic information about the system. Note: we have
not yet said anything about what these functions look like, we have only postulated
that they exist.
Postulate IV. The entropy of any system vanishes in the state for which
( )
∂U
= 0.
∂S V,n1 ,...,nns
These postulates (or axioms) are all that is needed. The rest is calculus and defini-
tions. Note again: so far, we have only claimed that the indicated functions exist;
we have not said anything about what they look like.
A = A (T, V, . . . , nj , . . .)
will contain all thermodynamic information about the system. Similarly, we can
introduce
H , U + pV
G , U − T S + pV
H = H (S, p, . . . , nj , . . .)
G = G (T, p, . . . , nj , . . .)
It follows that
à = Ũ − T S̃
H̃ = Ũ + pṼ
G̃ = Ũ − T S̃ + pṼ = Ã + pṼ = H̃ − T S̃.
where c̃p is the molar heat capacity at constant pressure, βT is the isothermal com-
pressibility, and αp is the coefficient of thermal expansion.
Assuming that we have an Equation of State relating p, V, T , see Section 4.5, we
can clearly compute βT and αp from this p, V, T relation. Thus, essentially, these
expression are available as soon as we have an EoS for p, V, T and an expression for
molar heat capacity, c̃p .
Table 7.4: Second order derivatives of Gibb’s free energy, ( ) and their relationships.
∂2G
( ∂S ) ∂2G
∂T 2
= − ∂T p,nj ∂p2
= ∂p ∂V
( ) ( )
T,nj
∂2G
∂T ∂p
= − ∂p ∂S ∂V
= ∂T p,nj
( ∂S ) ( ) T,nj( ) ( )
− ∂T p,nj
= − 1
n ∂T
∂ S̃ ∂V
∂p
= 1
n
∂ Ṽ
∂p
( ) ( ) p,x j
( )
T,n j ( ) T,xj
− ∂S∂p
= − n1 ∂∂pS̃ ∂V
∂T p,nj
= n1 ∂∂TṼ
T,nj T,xj p,xj
Consider the fundamental relation for Gibb’s free energy for a fixed amount of
substance,
G = G (T, p) .
Here,
∂G
= −S
∂T
∂G
=V
∂p
Gibb’s free energy has 3 independent second-order partial derivatives when we con-
sider a fixed composition, upper part of Table 7.4.
Furthermore, due to Euler’s Theorem, Eq. 7.30, the expressions for the second
order derivatives can be expressed by molar quantities, lower part of Table 7.4.
Again, for a pure amount of mass, we have G = G (T, p) ⇒ G̃ = G̃ (T, p), and
thus:
( ) ( )
∂ G̃ ∂ G̃
dG̃ = dT + dp
∂T ∂p
p T
⇓
dG̃ = −S̃dT + Ṽ dp. (7.34)
( ) ( )
∂ S̃ ∂ S̃
dS̃ (T, p) = dT + dp,
∂T ∂p
p T
7.8. BASIC THERMODYNAMICS 369
( ) ( )
∂2G
where the equality for ∂T ∂p
leads to ∂ S̃
∂p
=− ∂ Ṽ
∂T
. We thus have
T p
( ) ( )
∂ S̃ ∂ Ṽ
dS̃ (T, p) = dT − dp
∂T ∂T
p p
⇓
c̃p
dS̃ (T, p) = dT − αp Ṽ dp (7.35)
T
⇓
ˆ ˆ
◦
T
c̃p (T, p◦ ) p
S̃ = S̃ + dT − αp Ṽ dp. (7.36)
T◦ T p◦
(In a )similar manner, we can express non-fundamental relations for H̃ (T, p) and
Ũ T, Ṽ as
αp2
c̃p − c̃v = Ṽ · T. (7.40)
βT
T (α) = T (β)
p(α) = p(β)
(α) (β)
µj = µj ,
thus the two subsystems (“phases”) must have the same temperature, the same
pressure, and the same electrochemical potentials for every substance. If the system
is composed of more than two subsystems, the temperature must be the same in
every subsystem, the pressure must be the same in every subsystem, and the elec-
trochemical potentials must be the same in every subsystem for every substance —
when assuming thermodynamic equilibrium.
370 CHAPTER 7. ENERGY BALANCE*
If the system is not in equilibrium, the system will be driven towards equilibrium
by a heat flux Q̇′′
1 1
Q̇′′α2β ∝ (β) − (α) ,
T T
by a force Fα2β
Fα2β ∝ p(α) − p(β)
and by a molar flow rate ṅj,α2β
(α) (β)
µj µj
ṅj,α2β ∝ (α) − (β) .
T T
Clearly, at the equilibrium conditions, Q̇′′α2β ≡ 0, Fα2β ≡ 0 and ṅj,α2β ≡ 0 — as they
should be.
The first of these expressions, the one for Q̇′′α2β , can be rewritten as Q̇′′α2β ∝
T (α) −T (β)
T (α) T (β)
which close to equilibrium is approximately Q̇′′α2β ∝ T (α) − T (β) and thus
has a structure which already has been used in convective heat transport. Similarly,
(α) (β)
close to thermal equilibrium, we have approximately that ṅj,α2β ∝ µj − µj .
In practice, electrochemical potential µj is often transformed into the dimension-
less quantity activity aj through
µj = G̃◦j + RT · ln aj (7.41)
bulk of the relevant phase while index i indicates the conditions at the interphase
— there is thus one bulk phase in each of the phases α and β.
See, e.g., Kondepudi & Prigogine (1998) for an introduction to equilibrium and
non-equilibrium thermodynamics
bB + cC
rR + sS (7.42)
⇓
B
( ) C
0
−b, −c, r, s . (7.43)
| {z } R
=ν S
Assuming a so-called elementary reaction, the reaction rate for this reaction is r
given as
r = k+ abB acC − k− arR asS (7.44)
16
It is convenient to replace A with C and a with c to avoid confusion with the activity aj .
7.8. BASIC THERMODYNAMICS 371
dnj = V νj rdt
leading to ( )
∑
G̃ = −S̃dT + Ṽ dp + νj µ j V rdt.
j
As an example, the standard state molar Gibb’s free energy of reaction, ∆r G̃◦ , is
∑
∆r G̃◦ , νj G̃◦j ,
j
dn
17
In general, dtj = ṅj,i − ṅj,e + ṅj,g , but with no influent nor effluent, dnj = ṅj,g dt. With a
single reaction, ṅj,g = V νj r.
372 CHAPTER 7. ENERGY BALANCE*
∆r G̃◦
ln K , − . (7.49)
RT
Observe that ∆r G̃◦ depends on temperature, and that the data for computing ∆r G̃◦
are given at a specific temperature. Thus, if we use data that are specified for a
certain temperature, ∆r G̃◦ is valid at that temperature.
With negative molar Gibb’s free energy of reaction such that ∆RT
r G̃
> 1, this implies
arR asS
that K = ab ac > 1 and the conversion shifts from bB + cC to rR + sS, in other
B C
words: the reaction runs spontaneously in the forward direction. With a positive
value for ∆r G̃, we see that the logarithm of the equilibrium constant is negative,
ar as
which implies that 0 < abRacS < 1 and the conversion shifts from rR + sS to bB + cC;
B C
the reaction runs spontaneously in the backwards direction.
If we need the equilibrium constant at another state/temperature than for which
∆r G̃◦ is given, a popular approach is to use the van’t Hoff expression
d ∆r H̃
ln K = , (7.50)
dT RT 2
where ∆r H̃ is the enthalpy of reaction, defined as
We now introduce specific (per mass) and molar (per mole) energy as intensive
variables. Let Û and Ĥ denote specific internal energy and enthalpy, respectively.
Generally, we have
ˆ
U= Û dm
ˆm
H= Ĥdm,
m
U = mÛ
H = mĤ.
Similarly, we find
U̇ = ṁÛ
Ḣ = ṁĤ.
∞
where = is taken to denote “equal when the system is perfectly well mixed”. Simi-
larly, we have
U̇ = ṅŨ
Ḣ = ṅH̃.
Ĥ = Ĥ (T, p)
H̃ = H̃ (T, p) .
Ĥ = Ĥ (T, p, ω1 , . . . , ωns )
H̃ = H̃ (T, p, x1 , . . . , xns )
Equivalent for
Ideal Solution
Figure 7.5: Concept of an ideal solution: properties of a mixed volume are equal to
the sum of properties over layered, pure volumes.
The ideal solution In these notes, we will simplify the description and assume
that the mixture forms an ideal solution. Figure 7.5 illustrates the concept of an
ideal solution.
For an ideal solution, properties of the mixed volume are equal to the sum of
properties over hypothetically layered, pure volumes. We have already used this
concept in a species balance example, Section 5.11, where we assumed that the
volume V of a mixture of species A and B was equal to the sum V = VA• + VB•
of hypothetically pure, “layered” volumes VA• and VB• . For real systems, this will
only be an approximation.19 Here, superscript • is used to indicate a hypothetically
pure substance in a hypothetically layered volume. Sometimes, for simplicity, this
assumption will be taken for granted, and the symbol will be dropped. But in some
cases, it is important to be precise. As an example, suppose we have a volume V
containing masses mA and mB . For this case, we can define the specific concentra-
tions as ρA = mVA and ρB = mVB . But these specific concentrations will be different
from the pure substance densities ρ•A = m A
VA•
and ρ•B = m B
VB•
; ρA ̸= ρ•A and ρB ̸= ρ•B .
As an example, for an ideal solution, we simply have
∑
ns
H= Hj• ,
j=1
where Hj• denotes the enthalpy of species j assumed to be present as a pure species.
In other words, suppose we have ns separate volumes of size Vj with pure species
in each volume, and enthalpy Hj• in volume Vj . Then we pour all of these separate
volumes into a single volume∑and mix the volume
∑ perfectly. If the mixture forms
an ideal solution, then V = j Vj and H = j Hj• . Note: there are many mixtures
that do not form an ideal solution, e.g., the mixture of water and ethanol. For a
more general discussion, see, e.g., Modell & Reid (1983).
19
Mass and
∑number of moles,
∑ are, however, additive — there is no approximation involved in
setting m = j mj or n = j nj !
376 CHAPTER 7. ENERGY BALANCE*
Ṽ p+B
= 1 − C · ln ,
Ṽ0 p0 + B
7.8. BASIC THERMODYNAMICS 377
4.5
4
Ar
c̃p/R [–]
O2
3.5
N2
CO
3 H2
CO2
NH3
2.5 mon
di
multi
2
200 250 300 350 400
Temperature T [K]
Figure 7.6: Dimensionless molar heat capacity at constant pressure, c̃pR(T ) for one
monatomic gas (Ar), four diatomic gases (O2 , N2 , CO and H2 ), and two triatomic
gases (CO2 and NH3 ) vs. the dimensionless ideal gas molar heat capacities for
monatoic (mon), diatomic (di) and multi-atomic gases (multi). Note that the heat
capacities for N2 and CO are almost indistinguishable in this temperature range.
With accurate values for Ṽ0 , p0 , and βT,0 , the Tait equation thus depends on a single
quantity B; the expression for B depends on the substance, and is only a function
of temperature.
In their corresponding state approach, Hoang et al. (2015) propose that for
weakly polar liquids, B can be expressed as
B [ ( √ )]2
Br = = −2 + 1 + κ 1 − Tr
pc
with
κ = −0.883ω 2 + 14.34ω + 10.17
T
Tr = ;
Tc
here, subscript “r” indicates “reduced” properties, while Tc , pc , and ω are critical
temperature, critical pressure, and ascentric factor, respectively. This expression
has been found to give average deviation from experimental values in the order of
0.1% in Ṽ and 2% in βT for Tr ≤ 0.99 and p ≤ 200 MPa. See Table C.1 p. 570 for
examples of numerical values for selected substances.
In case of mixtures of fluids, Hoang et al. (2015) propose the following mixing
rules:
∑
Tc = xj Tc,j (7.52)
j
∑
pc = xj pc,j (7.53)
j
∑
ω= xj ω j (7.54)
j
N
Example 7.3. Constant density liquid βT and αp
V̂ 1
With constant density ρ, it follows that Ṽ = M
= ρM
is constant. Thus,
βT = 0
αp = 0.
N
Example 7.4. Constant volume heat capacity for ideal gas
1
For ideal gas, we have already seen that αp = T
while βT = p1 . It follows
1
pṼ pṼ
c̃p − c̃v = Ṽ T2
1 ·T = = · R = R.
p
T RT
N
Example 7.5. Constant volume heat capacity for constant density liquid
For constant density liquid, we have αp = 0 and βT = 0. Thus, in the expression
α2p
βT
we have a 00 expression, which are sometimes indeterminate. However, as we
,
approach constant density liquid, the numerator approaches zero quadratically while
α2
the denominator approaches zero linearly. Thus, βTp → 0, and we find
c̃p − c̃v = 0.
For ideal gas, 1 − αp T = 0, and c̃p is a function of temperature only. Thus the
enthalpy is found as
ˆ T
◦ ◦
dH̃ = c̃p dT ⇒ H̃ (T, p) = H̃ (T , p ) + c̃p dT.
T◦
H̃ (T, p) = H̃ (T ◦ , p◦ ) + c̃p (T − T ◦ ) .
H̃ (T, p) = H̃ (T ◦ , p◦ ) + c̃p (T − T ◦ ) + Ṽ (p − p◦ ) .
N
It is instructive to also briefly consider more general fluid models, e.g., the van
der Waals Equation of State in Section 4.5. Van der Waals’ EoS is a cubic EoS in
that it is cubic in Ṽ , Eq. 4.8 p. 93:
( )( )
a
p+ Ṽ − b = RT
Ṽ 2
⇓
pṼ − Ṽ (RT + bp) + aṼ = ab.
3 2
(7.56)
⇓
( )
∂ Ṽ RṼ 2
=
∂T
p
3pṼ 2 − 2 (RT + bp) Ṽ + a
⇓
( )
1 ∂ Ṽ RṼ
αp = = . (7.58)
Ṽ ∂T
p
3pṼ − 2 (RT + bp) Ṽ + a
2
The problem with this expression for αp is that it is constrained by the EOS, i.e.,
by Eq. 7.56. Equation 7.56 has three roots Ṽ ; although analytic expressions for
Ṽ can be found, they are rather complex, and we also need to pick the one which
represents the gas phase. However, if we find the analytic gas phase expression for
the root Ṽ (T, p) of Eq. 7.56, this can in principle be inserted into the expression for
αp in Eq. 7.58 to eliminate Ṽ and express αp purely as a function of T and p.
( ∂p )
Alternatively, we consider dŨ , where we need ∂T Ṽ
. Thus, from Eq. 7.57 with
7.8. BASIC THERMODYNAMICS 383
⇓
( )
∂p RṼ 2 R
= ( )= .
∂T Ṽ Ṽ 2 Ṽ − b Ṽ − b
Thus, we find
( )
∂p
dŨ = c̃v dT + T − p dṼ
∂T Ṽ
⇓
RT
dŨ = c̃v dT + − p dṼ
Ṽ − b
| {z }
a
=p+
Ṽ 2
⇓
a
dŨ = c̃v dT + dṼ .
Ṽ 2
From here, we find directly that
( ) ˆ T ( )
◦ 1 1
Ũ T, Ṽ = Ũ + c̃v dT − a − .
T◦ Ṽ Ṽ ◦
α2
If we don’t know c̃v but would rather use c̃p , we have c̃v = c̃p − Ṽ βTp · T . In this
case, it can be shown that
αp2 T
Ṽ =R
βT T −Θ
where
2a 4ab 2ab2
Θ= − + .
RṼ RṼ 2 RṼ 3
We then finally find
ˆ T ˆ T ( )
◦ T 1 1
Ũ = Ũ + c̃p dT − R dT − a −
T◦ T◦ T −Θ Ṽ Ṽ ◦
⇓
ˆ T [ ]T ( )
◦ 1 1
Ũ = Ũ + c̃p dT − T + ln (T − Θ) Θ
−a −
T◦ T◦ Ṽ Ṽ ◦
⇓
ˆ T ( )
◦ ◦ (T − Θ)Θ 1 1
Ũ = Ũ + c̃p dT − (T − T ) − ln −a − .
T◦ (T ◦ − Θ)Θ Ṽ Ṽ ◦
384 CHAPTER 7. ENERGY BALANCE*
pressure unit.
For liquids with standard state being pure liquid at standard pressure p◦ , typi-
cally, atmospheric pressure, activity is often expressed as
aj = γj xj a•j (7.61)
where γj is the so-called activity coefficient, xj is the mole fraction, and a•j is the
hypothetically pure liquid activity at the given temperature and pressure. Here,
ˆ p
•
RT · ln aj = Ṽ dp (7.62)
p◦
If the liquid mixture constitutes an ideal solution, then the activity coefficient is
γj = 1, thus for reasonable pressures,
aj = xj a•j ≈ xj .
find the reaction equilibrium constant K ◦ , we need ∆r G̃, etc. In some cases, G̃◦298,j
◦ ◦
is available in physical tables. In other cases, H̃298,j is given together with S̃298,j .
◦
And sometimes, data are not even given in the standard state, e.g., p = 1 atm for
gases, but, e.g., at p = 1 bar. It is useful to be able to convert the available data so
that we can find the quantities we need in our models.
To this end, quantities G̃, H̃, and S̃ are related as:
G̃ = H̃ − T S̃. (7.63)
Next, with F̃j denoting the molar thermodynamic quantity for species j, it is
common to introduce the molar thermodynamic quantity of formation, ∆f F̃j , defined
to be the difference between molar thermodynamic quantity F̃j of species j, and
the molar thermodynamic quantities of the elements constituting species j. To
this end, let εj = (εj,1 , · · · , ε,j,nε ) denote the stable elements constituting species
22
Molality is the amount (in mole) of the solute (low concentration species) per mass of solvent
(high concentration species).
386 CHAPTER 7. ENERGY BALANCE*
j,23 and let ηj = (ηj,1 , . . . , ηj,nε ) denote the corresponding number of each (stable)
element composing the species. It follows that the molar thermodynamic quantity
of formation is
∑
nε
∆f F̃j , F̃j − ηi F̃εi . (7.64)
i=1
1( )
∆f F̃NO = F̃NO − F̃N2 + F̃O2 .
2
( )
Similarly, for j = NO2 , εNO2 = (N2 , O2 ), while ηNO2 = 21 , 1 . Thus
1
∆f F̃NO2 = F̃NO2 − F̃N2 − F̃O2 .
2
N
It follows immediately that if j is a stable element itself, then ∆f F̃j ≡ 0. Thus,
e.g., ∆f F̃N2 ≡ 0 and ∆f F̃O2 ≡ 0.
Remark 7.1. In particular, it should be noted that the molar enthalpy and molar
Gibb’s free energy in the standard state are defined to be zero for stable elements,
thus H̃j◦ , 0 and G̃◦j , 0 — for any stable species, including stable elements. It
follows that H̃j◦ ≡ ∆f H̃j◦ and that G̃◦j ≡ ∆f G̃◦j for stable elements. However, in
general S̃j◦ ̸= ∆f S̃j◦ . N
Relevant sources for formation data are, e.g., Aylward & Findlay (2002) and
Wagman et al. (1982). See also Tables C.3 and C.4 in Appendix C.3.
From thermodynamics, it can be found that ideal gas enthalpy is independent
of pressure, thus H̃j and ∆f H̃ are independent of pressure (but dependent of tem-
perature). Gibb’s free energy, on the other hand, depends on pressure even in the
ideal gas case: ( )
p
G̃ (T, p) − G̃ (T, p1 ) = RT ln
p1
23
By elements is meant the stable elements in the Periodic Table of chemical elements, 5.1 p.
144, or stable variations of them. Thus, the oxygen atom in the periodic table is not a stable
element, but the oxygen molecule represents a stable variation of oxygen.
7.8. BASIC THERMODYNAMICS 387
and similarly
( )
p
∆f G̃ (T, p) − ∆f G̃ (T, p1 ) = RT ln . (7.66)
p1
Thus, if Gibb’s free energy is not given in the standard state pressure, we need to
convert it to the standard state pressure using Eq. 7.66.
R1 : 2NO + O2
2NO2
R2 : 2NO2
N2 O4 .
Introducing the species vector s = (NO, O2 , NO2 , N2 O4 ), we can write these two
reactions as
( ) NO
−2 −1 2 0
O2 = ν · s
0.
0 0 −2 1 NO2
| {z } NO
2 4
ν
| {z }
s
We consider the data for the four species + Nitrogen as in Table C.4 p. 572.
Here, we could check the values for ∆f G̃1j bar from the theoretical expressions. First,
we find
1 1 bar 1 1 bar
∆f S̃NO1 bar 1 bar
= S̃298,NO − S̃298,N − S̃298,O
2 2
2 2
1 1 J
= 210.761 − · 191.61 − · 205.138 = 12.387
2 2 mol K
∆f S̃O2 = S̃298,O2 − 1 · S̃298,O2
1 bar 1 bar 1 bar
J
= 205.138 − 205.138 = 0
mol K
1
∆f S̃NO1 bar 1 bar
= S̃298,NO − S̃298,N
1 bar
− S̃298,O
1 bar
2 2
2 2 2
1 J
= 240.06 − · 191.61 − 205.138 = −60.883
2 mol K
∆f S̃N1 bar
2 O4
= S̃ 1 bar
298,N2 O4 − S̃ 1 bar
298,N2 − 2S̃ 1 bar
298,O2
J
= 304.29 − 191.61 − 2 · 205.138 = −297.60 .
mol K
Based on these computed values for ∆f S̃j1 bar and the fact that ∆f H̃j1 bar ≡ H̃298,j
1 bar
, we
388 CHAPTER 7. ENERGY BALANCE*
∆f G̃1NO
bar 1 bar
= ∆f H̃NO − T298 ∆f S̃NO
1 bar
kJ
= 90.25 − 298.15 · 12.387 × 10−3 = 86.557
mol
∆f G̃1Obar
2
= ∆f H̃O1 bar
2
− T298 ∆f S̃O1 bar
2
kJ
= 0 − 298.15 · 0 × 10−3 = 0
mol
∆f G̃1NO
bar
2
1 bar
= ∆f H̃NO 2
− T298 ∆f S̃NO
1 bar
2
kJ
= 33.18 − 298.15 · (−60.883) × 10−3 = 51.332
mol
∆f G̃1Nbar O4 − T298 ∆f S̃N2 O4
= ∆f H̃N1 2bar 1 bar
2 O4
kJ
= 9.16 − 298.15 · (−297.60) × 10−3 = 97.889
mol
Here, we see that the numbers found for ∆f G̃1j bar fit the tabular values very well.
Gibbs( free
) energy is pressure dependent, so that ∆f G̃j (p, T298 ) = ∆f G̃j (p1 , T298 )+
RT298 ln pp1 . Because the data in Table C.4 are given at 1 bar instead of the stan-
dard state pressure of 1 atm, we find that
( )
◦ 1.01325
∆f G̃j = ∆f G̃j + 8.3114 · 298.15 · ln
1 bar
= ∆f G̃1j bar + 32.618 J/mol
1
N
where k+ = k− ·K. With molar Gibb’s free energy of reaction at a given temperature
T ◦ , ∆r G̃◦T ◦ , the equilibrium constant K ◦ at this temperature is
( )
◦
∆ G̃
r T◦
K ◦ = exp − .
RT ◦
7.8. BASIC THERMODYNAMICS 389
To find the equilibrium constant at any temperature, we can use van’t Hoff’s ex-
pression, Eq. 7.50. The enthalpy of reaction is
∆r H̃ = ∆r H̃ ◦ + ∆r c̃p
where
∆r H̃ ◦ = r · H̃R◦ + s · H̃S◦ − b · H̃B◦ − c · H̃C◦
∆r c̃p = r · c̃p,R + s · c̃p,S − b · c̃p,B − c · c̃p,C .
Example 7.12. Equilibrium constant with ideal gas, constant heat capacity
With constant heat capacities, we get
d ∆r H̃ ∆r H̃ ◦ + ∆r c̃p
ln K = =
dT RT 2 RT 2
⇓
ˆ K ( )ˆ
∆r H̃ ◦ + ∆r c̃p T
dT
d ln K = 2
K◦ R T◦ T
⇓
( )
K ∆r H̃ ◦ + ∆r c̃p 1 1
ln ◦ = − − ◦ .
K R T T
N
Example 7.13. Equilibrium constant with ideal gas and heat capacity linear in
temperature
With heat capacities which are linear in temperature, c̃p,j = c̃◦p,j + αj T , we find
d ∆r H̃ ∆r H̃ ◦ + ∆r c̃◦p + T · ∆r α
ln K = =
dT RT 2 RT 2
⇓
ˆ K ( )ˆ ˆ
∆r H̃ ◦ + ∆r c̃p T
dT ∆r α T dT
d ln K = 2
+
K◦ R T◦ T R T◦ T
⇓
( )
K ∆r H̃ ◦ + ∆r c̃p 1 1 ∆r α T
ln ◦ = − − ◦ + ln ◦ .
K R T T R T
N
For liquids, we have seen that activities can be written as
aj = γj xj a•j
where for normal pressures, a•j ≈ 1. For ideal solutions, γj = 1. For non-ideal
ω
solutions, γj = 1 for species high in concentration, but γj = xjj for species low in
concentration. Assuming an ideal liquid solution, we find the reaction rate to be
r = k+ (xB )b (xC )c − k− (xR )r (xS )s
390 CHAPTER 7. ENERGY BALANCE*
where
nj nj
xj = =∑
n j nj
where k+ = k− ·K. With molar Gibb’s free energy of reaction at a given temperature
T ◦ , ∆r G̃◦T ◦ , the equilibrium constant K ◦ at this temperature is just as in the gas
case.
To find the equilibrium constant at any temperature, we again use van’t Hoff’s
expression. The enthalpy of reaction is
∆r H̃ = ∆r H̃ ◦ + ∆r c̃p + (p − p◦ ) ∆r Ṽ .
Continuing on Example 7.11 p. 387, with G̃◦298,j = ∆f G̃◦j , the standard state
Gibb’s free energy for the two reactions are then:
From this, we see that both reactions occur spontaneously, and their equilibrium
constants are
( ) ( )
∆r G̃◦1 −70.48 × 103
R1 :K1◦ = exp − = exp − = 2.229 7 × 1012
RT298 8.314 · 298.15
( ) ( )
◦ ∆r G̃◦2 −4.697 4 × 103
R2 : K2 = exp − = exp − = 6.652 6.
RT298 8.314 · 298.15
It is also of interest to see how the equilibrium constants vary with temperature.
◦
Molar enthalpy is independent of pressure, thus H̃298,j = ∆f H̃j◦ = ∆f H̃j1 bar , and we
find that
∆r H̃1◦ = 2 · H̃298,NO
◦
2
◦
− 2 · H̃298,NO ◦
− H̃298,O 2
= 2 · 33.18 − 2 · 90.25 = −114.14 kJ mol−1
∆r H̃2◦ = H̃298,N
◦
2 O4
◦
− 2 · H̃298,NO2
= 9.16 − 2 · 33.18 = −57.2 kJ mol−1
∆r c̃p,1 , 2 · c̃p,NO2 − 2 · c̃p,NO − c̃p,O2 = 2 · 37.20 − 2 · 29.844 − 29.355 = −14.643 J/ (mol K)
∆r c̃p,2 , c̃p,N2 O4 − 2 · c̃p,NO2 = 77.28 − 2 · 37.20 = 2.88 J/ (mol K)
7.9. DISTRIBUTED HEAT EXCHANGERS 391
We then have
( ) ∆rRc̃p,1 ( ( ))
T ∆r H̃1◦ − ∆r c̃p,1 T298 1 1
Kp,1 = K1◦ exp − −
T298 R T T298
⇓
) −14.643
(
T 8.314
Kp,1 = 2.229 7 × 10 · 12
298.15
( ( ))
−114.14 × 103 − (−14.643) · 298.15 1 1
× exp − −
8.314 T 298.15
⇓
( )−1.761 2 ( ( ))
T 1 1
Kp,1 = 2.229 7 × 10 ·
12
exp 13204 − ,
298.15 T 298.15
and
( ) ∆rRc̃p,2 ( ( ))
T ∆r H̃2◦ − ∆r c̃p,2 T298 1 1
Kp,2 = K2◦ exp − −
T298 R T T298
⇓
( ) 8.314
2.88 ( ( ))
T −57.2 × 103 − 2.88 · 298.15 1 1
Kp,2 = 6.652 6 · exp − −
298.15 8.314 T 298.15
⇓
( )0.346 4 ( ( ))
T 1 1
Kp,2 = 6.652 6 · exp 6983.2 − .
298.15 T 298.15
N
Figure 7.7: Generic tube and shell heat exchanger. The tube fluid (index t) flows
in a tube, and the shell fluid (index s) flows in a shell surrounding the tube.
7.9. DISTRIBUTED HEAT EXCHANGERS 393
Figure 7.8: Tube-and-shell heat exchangers, with cross-current (a), co-current (b),
and counter-current (c) configurations.
394 CHAPTER 7. ENERGY BALANCE*
For the energy balance, we neglect the friction term and assume that there is no
volume work. Thus, the thermal energy balance reduces to
dU
= Ḣi − Ḣe + Q̇.
dt
The concept of logarithmic mean temperature difference (LMTD) is used when
describing heat exchangers.
Definition 7.1. Let ∆T1 be a temperature difference at a certain point in a heat
exchanger, and ∆T2 be the temperature difference at another point in the heat
1,2
exchanger. Then the logarithmic mean temperature difference ∆Tlm between points
1 and 2 is defines as:
∆T1 − ∆T2 ∆T2 − ∆T1
1,2
∆Tlm , ∆T1
= ∆T2
2,1
= ∆Tlm .
ln ∆T2 ln ∆T1
N
Remark 7.2. Consider the dimensionless ratio of heat transfer to heat capacity flow,
U Ax
ṁĉp
. From Table 2.15 p. 36, observe that the Stanton number NSt is given as
hL
NNu hL hLD hA
NSt , = k
ρvD µĉp
= = 2
=
NRe NPr ρvDĉp ρvD ĉp ṁĉp
µ k
where heat transfer coefficient h is qualitatively similar to the overall heat transfer
coefficient U. It follows that the ratio UṁĉApx is the Stanton number NSt of the heat
exchanger. N
Assume now that the Stanton number is independent of the temperature and
position. It turns out that for all these three heat exchanger configurations, the heat
transfer can be expressed as:
1,2
where ∆Tlm is as in Definition 7.1. For a cross-current heat exchanger, we have
∆T1 = Ti − Tes and ∆T2 = Tet − Tes . For a co-current heat exchanger, we have
t
∆T1 = Tit − Tis and ∆T2 = Tet − Tes . For a counter-current heat exchanger, we have
∆T1 = Tet − Tis and ∆T2 = Tit − Tes .
Often, Tit and Tis are given, and we seek Tet and Tes . A common procedure for
finding the effluent temperatures is thus to combine the above expression for heat
transfer with energy balances for each fluid stream which typically leads to the added
equations
( )
Q̇t2s = ṁt ĉp,t Tit − Tet
Q̇t2s = ṁs ĉp,s (Tes − Tis ) ;
this gives three nonlinear algebraic equations for the unknowns Q̇t2s , Tet , and Tes ; it
is necessary to iterate to find the solutions.
Although the above formulation is “simple” in the way that it gives a common
presentation for all three configurations, it has three flaws
7.9. DISTRIBUTED HEAT EXCHANGERS 395
Shell
Tube
1. As the subsequent detailed developments show, the basis for the above loga-
rithmic mean temperature description gives direct, explicit expressions for the
effluent temperatures. From a simulation point of view, the logarithmic mean
temperature formulation thus is a complicating detour.
1,2
2. Historically, it has been argued that computing logarithms in ∆Tlm is too
slow for simulations, and approximate expressions have been devised. These
arguments are hardly relevant today, even though iterations are involved. And,
as mentioned above, iterations are really unnecessary, since explicit expressions
are readily available.
Although the direct expressions developed in the sequel give explicit solutions, the
development is somewhat technical. Still, the development gives a good exercise
for the mathematically interested reader — and good background for tackling more
advanced models.
For the tube side, the thermal energy balance for interval x ∈ [ξ, ξ + ∆x] leads
to t
dUξ+∆x
= Ḣξt − Ḣξ+∆x
t
− Q̇t2s
ξ+∆x
dt
where
t
Uξ+∆x = ρt ∆x · At Ûξ+∆x
t
Here, we have
U℘ U℘
= U ℘ = ṁt ĉp,t ,
αt ṁ ĉ t p,t
Here,
ˆ Ĥis ˆ Tis
Ĥis − Ĥes = dĤ ≈ ĉp,s dT.
Ĥes Tes
Assuming heat capacity to be independent of T , we find
Ĥis − Ĥes ≈ ĉp,s (Tis − Tes ) ,
and then
( ( )) ( t )
0 = ṁs ĉp,s (Tis − Tes ) + ṁt ĉp,t 1 − exp −NSt
t
Ti − Tes .
From this final expression, we can compute Tes to be
ṁs ĉp,s Tis + ṁt ĉp,t [1 − exp (−NSt
t
)] Tit
Tes = . (7.73)
ṁs ĉp,s + ṁt ĉp,t [1 − exp (−NSt
t
)]
If we are interested in Tet , Eq. 7.69 gives
Θ (x = Lx ) = exp (−αt Lx ) Θ (0)
⇓
( )( t )
Te = Tes + exp −NSt
t t
Ti − Tes . (7.74)
7.9. DISTRIBUTED HEAT EXCHANGERS 399
This is typically the situation we have if the shell side is the content of a stirred
tank.
Because ( ( ))
k
lim xa 1 − exp − = ak,
x→∞ x
the heat transfer Q̇t2s in Eq. 7.71 simplifies to
( )
lim Q̇t2s = UAx Tit − Tes
ṁt →∞
Q̇t2s ( )
= Tit − Tes − Tet − Tes
ṁt ĉp,t
⇓
[( ) ( )]
Q̇t2s = ṁt ĉp,t Tit − Tes − Tet − Tes .
Thus, we have
(Tit − Tes ) − (Tet − Tes )
Q̇t2s = UAx T t −T s
.
ln Tit −Tes
e e
By defining
we thus have
Q̇t2s = UAx ∆Tlm
i,e
(7.75)
i,e
where ∆Tlm is the logarithmic mean temperature difference as introduced in Defi-
nition 7.1.
Here, it is important to realize that the expression in Eq. 7.75 is equivalent to
that of Eq. 7.71. Although the expression in Eq. 7.75 is quite common in chemical
engineering texts, this logarithmic mean temperature difference expression has the
disadvantage that we must first compute Tet before Q̇t2s can be evaluated.
7.9. DISTRIBUTED HEAT EXCHANGERS 401
Shell
Tube
However, this equation has two unknowns, Tet and Tes , so in reality we need to add
Eq. 7.75. But then we add Q̇t2s as unknown. So in reality, we need to solve three
(nonlinear) equations at the same time:
( )
ĉp,t ṁt Tit − Tet = ĉp,s ṁs (Tes − Tis )
( )
Q̇t2s = ĉp,t ṁt Tit − Tet
(T t − Tes ) − (Tet − Tes )
Q̇t2s = UAx i T t −T s
.
ln Tit −Tes
e e
The expression in Eq. 7.71, on the other hand, does not depend on Tet , and gives
a single, explicit expression for Q̇t2s .
dU
= Ḣi − Ḣe + Q̇.
dt
With perfect mixing in the volume defined by x ∈ [ξ, ξ + ∆x], the tube flow volume
402 CHAPTER 7. ENERGY BALANCE*
has
Q̇ = −Q̇t2s
ξ
′
Q̇t2s
ξ+∆x = Q̇t2s,ξ+∆x ∆x,
leading to
d ( )
∆xρt At Ûξ+∆x = ṁt Ĥξt − ṁt Ĥξ+∆x
t t
− Q̇′t2s,ξ+∆x ∆x.
dt
Generalizing ξ to any position x and letting ∆x → 0, this leads to
∂ Ût ∂ Ĥt
ρt At = −ṁt − Q̇′t2s .
∂t ∂x
Here,
Q̇′t2s = U℘ (Tt − Ts ) .
With ∂ Û ≈ ĉv ∂T and ∂ Ĥ ≈ ĉp ∂T , this leads to
∂Tt ∂Tt
ρt At ĉv,t = −ṁt ĉp,t − U℘ (Tt − Ts ) .
∂t ∂x
Similarly for the shell volume, the result is
∂Ts ∂Ts
ρs As ĉv,s = −ṁs ĉp,s + U℘ (Tt − Ts ) ,
∂t ∂x
where we have utilized that ṁs flows in the same direction as ṁt and that the heat
flow Q̇′t2s enters the shell volume. The boundary conditions are Tt (x = 0) = Tit and
Ts (x = 0) = Tis .
dTt U℘
=− (Tt − Ts )
dx ĉp,t ṁt
dTs U℘
= (Tt − Ts ) .
dx ĉp,s ṁs
U℘
Assuming that ĉp ṁ
is constant wrt. x leads to the linear, space invariant boundary
value problem ( )(
( ) U℘ U℘ )
d Tt − ĉp,t ṁt ĉp,t ṁt Tt
= U℘ U℘ .
dx Ts ĉp,s ṁs ĉp,s ṁs
Ts
7.9. DISTRIBUTED HEAT EXCHANGERS 403
U℘
αt ,
ĉp,t ṁt
U℘
αs , ,
ĉp,s ṁs
we have ( ) ( )( )
d Tt −αt αt Tt
= ,
dx Ts αs −αs Ts
| {z }
A
Tt (x = 0) = Tit
Ts (x = 0) = Tis .
Problem 8.1 p. 544 discusses the solution of this model, which is found to be
1 [( −(αs +αt )x ) ( ) ]
Tt (x) = αt e + αs Tit + αt − αt e−(αs +αt )x Tis (7.76)
αt + αs
1 [( ) ( ) ]
Ts (x) = αs − αs e−(αs +αt )x Tit + αt + αs e−(αs +αt )x Tis . (7.77)
αt + αs
Re-inserting the expressions for αt and αs and with U℘Lx = UAx , and introduc-
ing the tube side and shell side Stanton numbers (see Eq. 7.72),
UAx
t
NSt , (7.80)
ĉp,t ṁt
UAx
s
NSt , (7.81)
ĉp,s ṁs
we then have
[ ] [ ]
t −(NSt St ) + N s
s +N t −(NSt St ) T s
s +N t
NSt e St Ti
t
+ N t
St 1 − e i
Tet = t s
(7.82)
NSt + NSt
[ ] [ ]
1 − e−(NSt +NSt ) Tit + NSt s −(NSt St ) T s
s t s +N t
s t
NSt + NSt e i
Tes = t s
. (7.83)
NSt + NSt
404 CHAPTER 7. ENERGY BALANCE*
Thus, with
∆Ti = Tit − Tis
∆Te = Tet − Tes ,
we have
Q̇t2s = UAx ∆Tlm
i,e
,
It is much simpler to use the explicit expression in Eq. 7.85 directly.
7.9. DISTRIBUTED HEAT EXCHANGERS 405
Shell
Tube
Q̇ = −Q̇t2s
ξ
′
Q̇t2s
ξ+∆x = Q̇t2s,ξ+∆x ∆x,
leading to
d ( )
∆xρt At Ûξ+∆x = ṁt Ĥξt − ṁt Ĥξ+∆x
t t
− Q̇′t2s,ξ+∆x ∆x.
dt
Generalizing ξ to any position x and letting ∆x → 0, this leads to
∂ Ût ∂ Ĥt
ρt At = −ṁt − Q̇′t2s .
∂t ∂x
Here,
Q̇′t2s = U℘ (Tt − Ts ) .
With ∂ Û ≈ ĉv ∂T and ∂ Ĥ ≈ ĉp ∂T , this leads to
∂Tt ∂Tt
ρt At ĉv,t = −ṁt ĉp,t − U℘ (Tt − Ts ) .
∂t ∂x
406 CHAPTER 7. ENERGY BALANCE*
With Tit and Tis known, this is an implicit formulation of the unknown quantities
Tetand Tes . But that may be OK, so let us insert the expressions for αt and αs :
U℘ U℘
αt = ĉp,t ṁt
and αs , ĉp,s ṁs
, and set ℘Lx = Ax . Introducing the Stanton numbers in
Eqs. 7.80–7.81:
( s −N t
) ( s −N t
)
1
e( NSt St ) − ĉp,s ṁs Ti + ĉp,t ṁt − ĉp,t ṁt e
1 t 1 1 ( NSt St ) Tes
t ĉp,t ṁt
Te = 1
ĉp,t ṁt
− ĉp,s1ṁs
( s −N t
) ( s −N t
)
1
e ( NSt St ) − ĉp,s ṁs Ti + ĉp,t ṁt − ĉp,s ṁs e
1 t 1 1 ( NSt St ) Tes
s ĉp,s ṁs
Ti = .
1
ĉp,t ṁt
− ĉp,s1ṁs
This implicit expression for Tet and Tes is linear in the unknowns, and can be posed
in matrix form as ( t )
Te
A =b
Tes
with
1
− ĉ 1ṁ e St ( t
N s −NSt )
1 −
ĉp,t ṁt p,t t
1
− ĉ 1ṁ
A=
)
ĉp,t ṁt p,s s
(N s −NSt
t
1
ĉp,t ṁt
− ĉ ṁ e St
1
p,s s
0 1
− ĉ 1ṁ
ĉp,t ṁt p,s s
and
1 ( N s −NSt
e St
t
) − ĉ 1ṁ
ĉp,t ṁt p,s s t
T
1
− 1 i
b= ĉp,t ṁt ĉp,s ṁs
.
1 (
e
NSts −N t
)
St − 1
Tis − ĉp,s ṁs
1
− ĉ ṁ1
ĉp,s ṁs
Tit
ĉp,t ṁt p,s s
Re-inserting the expressions for αt and αs and with U℘Lx = UAx and introducing
the Stanton numbers, we then have
( )
1 − e(NSt −NSt ) Tis + (NSt ) e(NSt −NSt ) Tit
s t s t
t
NSt t
− NSt s
Tet = s −N t
s (NSt St )
NStt
− NSt e
( )
1 − e(NSt −NSt ) Tit
s t
(NStt
− NSts
) Tis + NSt s
Tes = s −N t
.
s (NSt St )
t
NSt − NSt e
We can either use this expression by assuming that Tes is computed first, or
we can insert the expression for Tes in order to express Q̇t2s by Tit and Tis . For
completion, let us express Q̇t2s explicitly using the influent temperatures. We find
[ (α −α )L ]
e s t x − 1 (Tit − Tes )
Q̇t2s = UAx
(αs − αt ) Lx
⇓
( )
[ (α −α )L ] (αt −αs )Tis −αs (e(αs −αt )Lx −1)Tit
e s t x
− 1 Ti − t
[αt −αs e(αs −αt )Lx ]
Q̇t2s = UAx
(αs − αt ) Lx
⇓
( )
[ (α −α )L ] (αt −αs e(αs −αt )Lx )Tit −(αt −αs )Tis +αs (e(αs −αt )Lx −1)Tit
e s t x
−1
[αt −αs e(αs −αt )Lx ]
Q̇t2s = UAx .
(αs − αt ) Lx
7.9. DISTRIBUTED HEAT EXCHANGERS 409
e(NSt −NSt ) − 1 ( )
s t
We can thus rewrite the expression for Q̇t2s into the form
Thus, with
we have
Q̇t2s = UAx ∆Tlm
1,2
.
Again, it is much simpler to use the explicit expression in Eq. 7.92 directly.
System boundary
the result would simply be a set of partial differential equations in time and space,
or alternatively: discretizing the model into a large set of DAEs.
In reality, heat diffuses in the fluids. Including heat diffusion complicates the
model somewhat, but it is still possible to solve the steady model.
In reality, the heat capacity changes with varying temperature T . Furthermore,
if the heat capacity and/or the viscosity of the fluid changes with the temperature,
this also changes the heat transfer coefficients of the system via the Prandtl number,
Eq. 7.7. In summary, this implies that αt and αs in the model development become
temperature dependent, and it is not possible to find closed solutions of the steady
model. Instead of a closed form for the solution, we then need to resort to a numerical
solution of the boundary value ODEs of the steady model.
Heated liquid
tank
Step 2: In general,
m = ρV
V = Ah.
while
dV p dm −p
Ẇv = −p =− = (ṁi − ṁe ) .
dt ρ dt ρ
Finally,
Q̇ = Q̇′ · h.
Finally, we set
p = pa + ρgh.
where
x = (m, U )
( )
z = ṁe , Ḣi , Ḣe , Ẇv , Q̇, V, h, Ĥ, p, T, Ĥi ,
( )
′
u = ṁi , υ, Ti , Q̇
( )
θ = ρ, A, Ke , hς , Ĥ ◦ , ĉp , T ◦ , p◦ , pa , g
Step 4: To complete the system description, we need to relate the output variables
h and T to the model variables; y = (h, T ). In a DAE formulation, h and T
are automatically computed, so this is no problem.
7.10. CASE: HEATED LIQUID TANK 413
0.22
0.20
[m]
0.18
0.16
0.14
0.12
0 5 10 15 20 25 30
time t [s]
Figure 7.14: Level h [m] in heated tank, both from DAE formulation (solid red)
and from ODE formulation of Section 7.10.5 (dash-dot-dot blue). Observe that the
results for the two formulations are identical, and cover each other.
20
C
18
16
0 5 10 15 20 25 30
time t [s]
Figure 7.15: Temperature T [◦ C] in heated tank, both from DAE formulation (solid
red) and from ODE formulation of Section 7.10.5 (dot-dot blue). In addition, the
influent temperature Ti [◦ C] is shown (solid green). Observe that the results for the
two formulations are identical, and cover each other.
7.10. CASE: HEATED LIQUID TANK 415
Figure 7.16: Influent mass flow ṁi [kg/s] (solid red), valve signal υ [–] (solid blue)
and effluent mass flow ṁe [kg/s] (solid green).
80
60
Q0 [kW/m]
40
20
0
0 5 10 15 20 25 30
time t [s]
The following Modelica code (file HeatedTank.mo) is used to produce the fig-
ures, both for the DAE formulation (ModHeatedTank) and for the ODE formulation
(ModHeatedTankODE).26
1 package HeatedTank
2 // Package for simulating Heated liquid Tank
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // October 22 , 2015
6 // May 12 , 2017
7 //
8 model SimHeatedTank
9 // Simulation of Heated liquid Tank
10 // author : Bernt Lie
11 // University of South - Eastern Norway
12 // October 22 , 2015
13 // May 12 , 2017
14 //
15 // Instantiate model of Heated liquid Tank ( ht )
16 ModHeatedTank ht ;
17 ModHeatedTankODE htODE ;
18 // Declaring variables
19 // -- inputs
20 Real _mdi " Influent mass flow rate , kg / s ";
21 Real _u " Valve input signal , -";
22 Real _Ti " Influent temperature , K ";
23 Real _Qdp " Heat flow per length , W / m ";
24 // -- outputs
25 output Real _h " Tank level , m ";
26 output Real _T " Heated tank temperature , K ";
27 output Real _hsDE ;
28 output Real _TODE ;
29 // Equations
30 equation
31 // -- input values
32 _mdi = if time < 2 then 1 else 1.5;
33 _u = if time < 15 then 1 else 0.8;
34 _Ti = if time < 10 then 288.15 else 293.15;
35 _Qdp = if time < 5 then 0 else 1 e5 ;
36 // -- injecting input functions to model inputs
37 ht . mdi = _mdi ;
38 ht . u = _u ;
39 ht . Ti = _Ti ;
40 ht . Qdp = _Qdp ;
41 htODE . mdi = _mdi ;
42 htODE . u = _u ;
Ĥ ‡ etc. is transcribed into Hhdd — Hh implies H with a hat (Ĥ), and dd implies a double
26
dagger ‡.
7.10. CASE: HEATED LIQUID TANK 417
43 htODE . Ti = _Ti ;
44 htODE . Qdp = _Qdp ;
45 // -- outputs
46 _h = ht . h ;
47 _T = ht . T ;
48 _hsDE = htODE . h ;
49 _TODE = htODE . T ;
50 end SimHeatedTank ;
51 //
52 model ModHeatedTank
53 // Model of Heated liquid Tank
54 // author : Bernt Lie
55 // University of South - Eastern Norway
56 // October 22 , 2015
57 // May 12 , 2017
58 //
59 // Constants
60 constant Real g = 9.81 " Acceleration of gravity , m / s2 ";
61 // Parameters
62 parameter Real rhs = 1 e3 " Liquid density , kg / m3 ";
63 parameter Real A = 1.5 e -2 " Cross sectional area of tank ,
m2 ";
64 parameter Real Ke = 2 " Effluent valve constant , kg / s ";
65 parameter Real hs = 3e -1 " Level scaling , m ";
66 parameter Real Hhdd = 0 " Standard state specific enthalpy
, J / kg ";
67 parameter Real chp = 4.2 e3 " Specific heat capacity of
liquid , J / kg / K ";
68 parameter Real Tdd = 298.15 " Standard state temperature ,
K ";
69 parameter Real pdd = 1.01 e5 " Standard state pressure , Pa
";
70 parameter Real pa = 1.01 e5 " Ambient pressure , Pa ";
71 // Initial state parameters
72 parameter Real h0 = 1.5 e -1 " Initial liquid level , m ";
73 parameter Real m0 = rhs * h0 * A " Initial mass , kg ";
74 parameter Real T0 = 293.15 " Initial temperature , K ";
75 parameter Real p0 = pa " Initial pressure , Pa ";
76 parameter Real Hh0 = Hhdd + chp *( T0 - Tdd ) + ( p0 - pdd ) / rhs
77 " Initial specific enthalpy , J / kg ";
78 parameter Real U0 = m0 * Hh0 - p0 * m0 / rhs " Initial internal
energy , J ";
79 // Declaring variables
80 // -- states
81 Real m ( start = m0 , fixed = true ) " Mass in tank , kg ";
82 Real U ( start = U0 , fixed = true ) " Internal energy in tank
, J ";
83 // -- auxiliary variables
84 Real mde " Effluent mass flow rate , kg / s ";
418 CHAPTER 7. ENERGY BALANCE*
dm
= ṁi − ṁe
dt
⇓
√
d h
(ρAh) = ṁi − Ke υ
dt hς
⇓
√
dh ṁi − Ke υ h
hς
= .
dt ρA
420 CHAPTER 7. ENERGY BALANCE*
Furthermore,
dU
= Ḣi − Ḣe + Ẇv + Q̇
dt
⇓
d dV
(H − pV ) = Ḣi − Ḣe − p + Q̇
dt dt
⇓
dH dV dp dV
−p −V = Ḣi − Ḣe − p + Q̇
dt dt dt dt
⇓
d ( ) dp
mĤ − V = Ḣi − Ḣe + Q̇
dt dt
⇓
dĤ dm dp
m + Ĥ −V = ṁi Ĥi − ṁe Ĥ + Q̇
dt dt
|{z} dt
ṁi −ṁe
⇓
dĤ dp ( )
m −V = ṁi Ĥi − Ĥ + Q̇.
dt dt
Here,
1
dĤ = ĉp dT + dp,
ρ
thus
dĤ dp ( )
m −V = ṁi Ĥi − Ĥ + Q̇
dt dt
⇓
dT m dp dp ( )
mĉp + −V = ṁi Ĥi − Ĥ + Q̇.
dt ρ dt dt
Here,
m dp dp
−V ≡0
ρ dt dt
and
1
Ĥi − Ĥ = Ĥ ◦ (T ◦ , p◦ ) + ĉp (Ti − T ◦ ) + (pa − p◦ )
ρ
1
− Ĥ ◦ (T ◦ , p◦ ) + ĉp (T − T ◦ ) + (p − p◦ )
ρ
⇓
1
Ĥi − Ĥ = ĉp (Ti − T ) + (pa − p) .
ρ
With p = pa + ρgh, we finally find
Ĥi − Ĥ = ĉp (Ti − T ) − gh.
7.10. CASE: HEATED LIQUID TANK 421
Because the pressure of the system volume varies with h, it is perhaps question-
able to set the volume pressure equal to the bottom pressure p — we could just as
well have set the system pressure to p+p
2
a
or even to pa ; in the latter case, Ĥi − Ĥ
would reduce to ĉp (Ti − T ).
=
dt ρA
dT ṁi [ĉp (Ti − T ) − gh] + Q̇′ h
= .
dt ρAhĉp
x = (h, T )
( )
u = ṁi , υ, Ṫi , Q̇′
θ = (Ke , ρ, A, hς , ĉp , g) .
The advantages of the ODE model over the DAE model, are (1) that it is signifi-
cantly simpler, and (2) that ODE solvers are simpler to implement or more readily
available than DAE solvers. The disadvantages with the ODE model over the DAE
model are (1) the considerable amount of model manipulation which is required
with possibilities of introducing errors, and (2) that in order to find other variables
than the states x and the inputs u of the ODE, some post-processing of the model
is required.
To complete the model, model parameters are taken from Table 7.7 and operating
conditions are taken from Table 7.8.
Heated gas
tank
that in Fig. 7.16 the computed effluent mass flow ṁe is not shown for the ODE for-
mulation — the reason is simply that we need to re-compute ṁe in a post processing
stage when we use an ODE solver such as MATLAB or Python, while ṁe is readily
available along with all the other algebraic variables in when we use a DAE solver
such as in OpenModelica.
we assume that the flow across the valves can be described by a Bernoulli type
model.
dm
= ṁi − ṁe
dt
dU
= Ḣi − Ḣe + Ẇf + Ẇv + Q̇.
dt
pV = nRT
with
m = nM .
Furthermore, we have
√
∆pj
ṁj = Kj
pς
where the scaling pressure is pς = pa , and ∆pj is the pressure drop over the
relevant valve.
with
ˆ T
◦ ◦
Ĥ (T, p) = Ĥ (T , p ) + ĉp (T ) dT .
T◦
Step 4: To complete the system description, we need to relate the output variables
y = (p, T ) to the model variables. In a DAE formulation, the outputs are
automatically computed, so the outputs are trivial to find.
340
330
[K]
320
310
300
290
0 50 100 150 200 250 300 350 400
time t [s]
Figure 7.20: Temperature T [K] in heated gas tank (red), and influent temperature
Ti [K] (blue).
1 package HeatedGasTank
2 // Package for simulating Heated gas Tank
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // October 26 , 2015
6 // May 12 , 2017
7 //
8 model SimHeatedGasTank
9 // Simulation of Heated gas Tank
10 // author : Bernt Lie
11 // University of South - Eastern Norway
12 // October 26 , 2015
13 // May 12 , 2017
14 //
15 // Instantiate model of Heated gas Tank ( hgt )
16 ModHeatedGasTank hgt ;
17 // Declaring variables
18 // -- inputs
7.11. CASE: HEATED GAS TANK 427
600000
[Pa]
400000
200000
Figure 7.21: Pressure p [Pa] in heated gas tank (red) and influent gas pressure pi
[Pa] (blue).
100
75
50
25
0
0 50 100 150 200 250 300 350 400
time t [s]
Insulation
Figure 7.23: Vertical metal rod with temperature distribution T (t, x) influenced by
end temperatures Tp and Ta . Heat transfer may be influenced by blowing air passed
the top of the rod.
Heated metal
rod
We consider a metal rod of length L and cross sectional area A, standing vertically
on a heated plate of temperature Tp . On the sides, the metal rod is insulated, but
on the top the rod is exposed to air of varying velocity v at temperature Ta .
It is of interest to study how the temperature at the top of the metal rod, Tx=L ,
varies with temperatures Tp and Ta , and possibly how the velocity influences the
temperature through the heat transfer coefficient h.
The model objective is described compactly by the functional diagram in Fig.
7.24.
7.12. CASE: HEAT DIFFUSION IN METAL ROD 431
dU
= Ḣi − Ḣe + Ẇv + Ẇf + Q̇.
dt
Q̇′′ = h (Tx=L − Ta ) .
432 CHAPTER 7. ENERGY BALANCE*
Step 3.a: Next, we apply these relations to volume [ξ, ξ + ∆x]. Because there is
no flow of material/mass, it is not clear whether we should associate U with
Uξ or Uξ+∆x . However, let us keep up with tradition and write
dUξ+∆x
= Q̇ξ+∆x
dt
where
Uξ+∆x = Hξ+∆x
Hξ+∆x = mĤξ+∆x
and
m = ρV
V = A · ∆x.
H◦ = 0
pξ+∆x = p◦ ,
thus
Ĥξ+∆x = ĉp (Tξ+∆x − T ◦ ) .
The heat flow is given by
where
Q̇ξ = Q̇′′ξ · A
Q̇ξ+∆x = Q̇′′ξ+∆x · A
and
∂T
Q̇′′ξ = −k
∂x ξ
∂T
Q̇′′ξ+∆x = −k .
∂x ξ+∆x
Step 3.b: We do need a model for all x ∈ [0, L]. To find this, we observe that
the model above can be generalized: by replacing a fixed position ξ with an
arbitrary position x, the model becomes valid for any position x ∈ (0, L); it is
not valid at x = 0 and possibly not at x = L. To answer the question about
7.12. CASE: HEAT DIFFUSION IN METAL ROD 433
By generalizing the above model to be valid for any x, this means that
Uξ+∆x (t) which only varies with t, now becomes a function of both time and
position, Ux+∆x (t, x). Because of this, we need to change the ordinary deriva-
tive into a partial derivative:
Thus we get
∂Ux+∆x (t, x)
= Q̇x+∆x (7.93)
∂t
where
∂Ux+∆x (t, x)
= Q̇x+∆x
∂t
⇓
∂ ( ) ( )
mĤx+∆x = Q̇′′x − Q̇′′x+∆x A
∂t
⇓
∂ ( ) ( )
ρA · ∆x · Ĥx+∆x = Q̇′′x − Q̇′′x+∆x A
∂t
⇓
∂ Ĥx+∆x 1 Q̇′′x+∆x − Q̇′′x
=− .
∂t ρ ∆x
Here
Ĥx+∆x = ĉp (Tx+∆x − T ◦ ) ⇒ ∂ Ĥx+∆x = ĉp ∂Tx+∆x .
434 CHAPTER 7. ENERGY BALANCE*
Thus, we find
where
∂T
Q̇′′ = −k .
∂x
Step 3.c: We can relax on the assumption of the volume being homogeneous by
letting ∆x → 0:
( )
∂Tx+∆x 1 Q̇′′x+∆x − Q̇′′x
lim = lim −
∆x→0 ∂t ∆x→0 ρĉp ∆x
⇓
∂T 1 ∂ Q̇′′
=−
∂t ρĉp ∂x
where
∂T
Q̇′′ = −k
.
∂x
Here, it can be observed that after we have let ∆x → 0, it doesn’t matter
whether we have associated U with Uξ or Uξ+∆x — the result will be the
same.
The easiest way to find the order of boundary conditions, is to consider the
model in steady state, e.g., when ∂T
∂t
= 0. Then we have the two equations
1 dQ̇′′
0=−
ρĉp dx
dT
Q̇′′ = −k
dx
which in principle can be manipulated into
dQ̇′′
=0
dx
dT 1
= − Q̇′′ .
dx k
We see that we have 2 ordinary differential equations in the spatial variable,
which means that we need 2 free boundary conditions to solve the model
uniquely.
This steady state analysis does not tell us where the boundary conditions
should be placed, though. But it seems reasonable that we should choose
7.12. CASE: HEAT DIFFUSION IN METAL ROD 435
two conditions among the four possibilities Q̇′′x=0 , Q̇′′x=L , Tx=0 and Tx=L . Be-
cause the problem description specifies that the heated plate temperature Tp
is known and temperature is continuous in solid phase, it follows
Tx=0 = Tp
∂T 1 ∂ Q̇′′
=− (7.101)
∂t ρĉp ∂x
∂T
Q̇′′ = −k (7.102)
∂x
and
Tx=0 = Tp (7.103)
Q̇′′x=L = h (Tx=L − Ta ) . (7.104)
Step 4: To complete the system description, we need to relate the output variable
TL to the model variables. In this case, this is simple:
TL = T (t, x = L) . (7.105)
In the sequel, we will describe a suitable DAE model based on the discussion in Steps
3.b–4, in particular taking advantage of Eqs. 7.93–7.100 with additional boundary
conditions.
First, we divide the length into N slices/volumes, each of length ∆x = NL and
volume V = ∆xA. Next, with discretized slices of equal thickness ∆x, we denote
436 CHAPTER 7. ENERGY BALANCE*
dUi
= Q̇i
dt
Ui = mĤi
m = ρV , constant
V = A · ∆x, constant
Ĥi = ĉp (Ti − T ◦ )
( )
Q̇i = Q̇′′i−1 − Q̇′′i A.
The input variables are the plate temperature Tp and the air temperature Ta .
It is also of interest to see how the heat transfer coefficient h effects the solution.
Although h often is considered a parameter, we could imagine it to be an input
variable manipulated by blowing air across the rod at x = L. Thus, we will include
h as an input variable. This model can then be written in standard DAE form with
x = (U1 , U2 , . . . , UN )
( )
z = Ĥ1 , . . . , ĤN , T1 , . . . , TN , Q̇1 , . . . , Q̇N , Q̇′′0 , . . . , Q̇′′N
u = (Tp , Ta , h)
θ = (L, A, ρ, N, ∆x, V, m, ĉp , T ◦ , k)
y = TL = TN .
Table 7.12: Operating conditions for study of temperature diffusion in metal rod.
Quantity Value Unit Comment
Ti (0) 293.15 K Initial temperature of metal in slice i
◦
Ĥi (0) ĉp (Ti (0) − T ) J
kg
Initial specific enthalpy of slice i
Ui (0) mĤi (0) J Initial internal energy of slice i
Tp 293.15 + 30 · H100 s K Plate temperature
Ta 293.15 + 5 · H750 s K Air temperature
h 3 + 27 · H500 s W
m2 K
Heat transfer coefficient, solid–air
45
40
35
[ C]
30
25
20 TL Tp Ta
0 5 10 15 20 25 30
time t [min]
Figure 7.25: Temperature TL at end of metal rod (red), heated plate temperature
Tp (blue), and air temperature Ta (green), all given in K.
7.12. CASE: HEAT DIFFUSION IN METAL ROD 439
25
20
h [W/(m2.K)]
15
10
0 5 10 15 20 25 30
time t [min]
W
Figure 7.26: Heat transfer coefficient h between solid (metal rod) and air in m2 K
,
varying because of change in air velocity.
30
25 Tp T4 T8
20 T1 T5 T9
T2 T6 TL
15 T3 T7 Ta
0 5 10 15 20 25 30
time t [min]
Figure 7.27: Heated plate temperature Tp and air temperature Ta with temperature
Ti in the various slices, all in ◦ C.
440 CHAPTER 7. ENERGY BALANCE*
45
40
TL, 10 TL, 90 Tp
35
[ C]
25
20
0 5 10 15 20 25 30
time t [min]
1 package MetalRod
2 // Package for simulating temperature diffusion in metal
rod
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // October 29 , 2015
6 // May 12 , 2017
7 //
8 model SimCompareM et al Rod
9 // Simulation and comparison of Temperature diffusion in
metal rod
10 // author : Bernt Lie
11 // University of South - Eastern Norway
12 // October 29 , 2015
13 // May 12 , 2017
14 //
15 // Instantiate model
16 ModMetalRod mr10 ( N =10) , mr30 ( N =30) , mr90 ( N =90) , mr300 ( N
=300) ;
17 // Declaring variables
18 // -- inputs
19 Real _Tp " Temperature of heated plate , K ";
20 Real _Ta " Temperature of air , K ";
21 Real _h " Heat transfer coefficient , J .m -2. K -1";
22 // -- outputs
23 output Real _TL10 , _TL30 , _TL90 , _TL300 ;
24 // Equations
25 equation
7.12. CASE: HEAT DIFFUSION IN METAL ROD 441
75 mr . h = _h ;
76 // -- output
77 _TL = mr . T [ mr . N ];
78 end SimMetalRod ;
79 //
80 model ModMetalRod
81 // Underlying model for Temperature diffusion in metal
rod
82 // author : Bernt Lie
83 // University of South - Eastern Norway
84 // October 29 , 2015
85 // May 12 , 2017
86 //
87 // Parameters
88 parameter Real L = 4 " Pipe length , dm ";
89 parameter Real A = 2 " Pipe cross sectional area , dm2 ";
90 parameter Real rho = 7.8 " Metal density , kg / L ";
91 parameter Integer N = 10 " Number of slices in pipe , -";
92 parameter Real dx = L / N " Slice length , dm ";
93 parameter Real V = dx * A " Slice volume , L ";
94 parameter Real m = rho * V " Slice mass , kg ";
95 parameter Real chp = 450 " Metal specific heat capacity , J
. kg -1. K -1";
96 parameter Real Tdd = 293.15 " Standard state temperature
of metal , K ";
97 parameter Real k = 45 " Thermal conductivity of metal , W .m
-1. K -1";
98 // Initial state parameters
99 parameter Real T0 = 293.15 " Initial temperature in slices
, K ";
100 parameter Real Hh0 = chp *( T0 - Tdd ) " Initial specific
enthalpy in slices , J / kg ";
101 parameter Real U0 = m * Hh0 " Initial internal energy of
slices , J ";
102 parameter Real oneN [ N ] = ones ( N ) ;
103 // Declaring variables
104 // -- states
105 Real U [ N ]( each start = U0 , each fixed = true ) " Internal
energy in each slice , J ";
106 // -- auxiliary variables
107 Real Hh [ N ] " Specific enthalpy in slices , J / kg ";
108 Real T [ N ] " Temperature in slices , K ";
109 Real Qd [ N ] " Heat flow through slices , W ";
110 Real Qdpp [ N +1] " Heat flux through slices , W ";
111 // -- input variables
112 input Real Tp " Temperature of heated plate , K ";
113 input Real Ta " Temperature of air , K ";
114 input Real h " Heat transfer coefficient depending on air
velocity , W .m -2. K -1";
7.13. CASE: HOT WATER ACCUMULATOR⋆ 443
Cooled liquid
reactor
The operation of the reactor is influenced by inputs V̇ , cA,i , Ti and Q̇, and it is
of interest to study how these influence the outputs cA , cB and T . See Fig. 7.29.
The model objective is described by the functional diagram in Fig. 7.30.
and
Hj• = nj H̃j• = mj Ĥj• .
For an incompressible liquid,29
ˆ T
• ◦
H̃j = H̃j + c̃•p,j (T ) dT + Ṽj• (p − p◦ ) .
T◦
Here, we are not concerned about the pressure p of the liquid, and will simply
assume that
p = p◦ .
For simplicity, we will furthermore assume that the molar heat capacity is
constant, thus
H̃j• = H̃j◦ + c̃•p,j (T − T ◦ ) .
Furthermore, we have ∑
Ḣ = Ḣj•
j
where
Ḣj• = ṅj H̃j• = ṁj Ĥj• .
We will assume that the reaction medium is of low viscosity, thus Ẇf ≈ 0.
Furthermore, because the reactor volume is constant, Ẇv ≡ 0. Q̇ is an input.
Step 3: The model can be compiled into the following:
dnA
= ṅA,i − ṅA,e + ṅA,g
dt
dnB
= ṅB,i − ṅB,e + ṅB,g
dt
dU
= Ḣi − Ḣe + Q̇
dt
28
In the sequel, superscript • implies a hypothetical pure species.
29
In the sequel, superscript ◦ implies the standard state of the fluid.
446 CHAPTER 7. ENERGY BALANCE*
with
n A = cA V
n B = cB V
mS = ρV = constant
ṅA,i = cA,i V̇
ṅB,i = 0
ṁS,i = ρV̇
ṅA,e = cA V̇
ṅB,e = cB V̇
ṁS,e = ṁS,i
ṅA,g = −arV
ṅB,g = rV
r = kcaA
( )
E
k = k0 exp −
RT
as well as
U = H − p◦ V
H = HA• + HB• + HS•
HA• = nA H̃A•
HB• = nB H̃B•
HS• = mS ĤS
• • •
Ḣi = ḢA,i + ḢB,i + ḢS,i
• •
ḢA,i = ṅA,i H̃A,i
• •
ḢB,i = ṅB,i H̃B,i
• •
ḢS,i = ṁS,i ĤS,i
•
H̃A,i = H̃A◦ + c̃•p,A (Ti − T ◦ )
•
H̃B,i =0
•
ĤS,i = ĤS◦ + ĉ•p,S (Ti − T ◦ )
7.14. CASES: LIQUID PHASE REACTOR 447
• • •
Ḣe = ḢA,e + ḢB,e + ḢS,e
•
ḢA,e = ṅA,e H̃A•
•
ḢB,e = ṅB,e H̃B•
•
ḢS,e = ṁS,e ĤS• .
where
x = (nA , nB , U )
(
z = ṅA,i , ṅA,e , ṅA,g , ṅB,i , ṅB,e , ṅB,g , ṁS,i , ṁS,e , Ḣi , Ḣe , cA , cB , r, k, T, H,
)
HA• , HB• , HS• , H̃A• , H̃B• , ĤS• , ḢA,i
• •
, ḢB,i •
, ḢS,i •
, H̃A,i •
, H̃B,i •
, ĤS,i •
, ḢA,e •
, ḢB,e •
, ḢS,e
( )
u = V̇ , cA,i , Ti , Q̇
( )
E ◦ ◦ ◦ ◦ ◦
θ = V, ρ, a, k0 , , H̃A , H̃B , ĤS , c̃p,A , c̃p,B , ĉp,S , T , p , mS .
R
Step 4: To complete the system description, we need to relate the output variables
y = (cA , cB , T ) to the model variables. In a DAE formulation, the outputs are
automatically computed, so the outputs are trivial to find.
1 package C oo le dL iq u i dR e a c to r
2 // Package for simulating Cooled Liquid Reactor
3 // author : Bernt Lie
4 // University of South - Eastern Norway
448 CHAPTER 7. ENERGY BALANCE*
Table 7.14: Operating conditions for liquid reactor with varying temperature.
Quantity Value Unit Comment
nA (0) 2 mol Initial number of moles of species A
nB (0) 0 mol Initial number of moles of species B
mS ρV kg Mass of solvent S
T (0) 288.15 K Initial temperature
H̃A• (0) H̃A◦ + c̃•p,A (T (0) − T ◦ ) kJ
mol
Initial molar enthalpy of species A
H̃B• (0) H̃B◦ + c̃•p,B (T (0) − T ◦ ) kJ
mol
Initial molar enthalpy of species B
ĤS• (0) ĤS◦ + ĉ•p,S (T (0) − T ◦ ) kJ
kg
Initial specific enthalpy of solvent (S)
HA• (0) nA (0) H̃A• (0) kJ Initial enthalpy of species A
HB• (0) nB (0) H̃B• (0) kJ Initial enthalpy of species B
HS• (0) mS (0) ĤS• (0) kJ Initial enthalpy of solvent (S)
H (0) HA• (0) + HB• (0) + HS• (0) kJ Initial total enthalpy of ideal solution mixture
U (0) H (0) − p◦ V kJ Initial internal energy
V̇ 2 + H80 s L/s Influent volumetric flow rate
cA,i 3 + H60 s mol/L Influent concentration of species A
Ti 283.15 − 5H40 s K Influent temperature
Q̇ 0 − H10 s kW Added “heat” (cooling)
7.14. CASES: LIQUID PHASE REACTOR 449
2.0
1.5
1.0
0.5
0.0
0 20 40 60 80 100 120
time t [s]
12
10
8
6
0 20 40 60 80 100 120
time t [s]
Figure 7.32: Reactor temperature T (red) and influent temperature Ti (blue), both
in [K].
450 CHAPTER 7. ENERGY BALANCE*
10
20
Q [kW]
30
40
50
0 20 40 60 80 100 120
time t [s]
Figure 7.33: Added “heat” Q̇ [kW] — the negative value of Q̇ indicates cooling.
2.8
2.6
V [L/s]
2.4
2.2
2.0
0 20 40 60 80 100 120
time t [s]
5 // October 27 , 2015
6 // May 12 , 2017
7 //
8 model S i m Co ol ed L i q u i d R e a c t o r
9 // Simulation of Cooled Liquid Reactor
10 // author : Bernt Lie
11 // University of South - Eastern Norway
12 // October 27 , 2015
13 // May 12 , 2017
14 //
15 // Instantiate model of Cooled Liquid Reactor ( clr )
16 Mo d Co ol ed L iq u i d R e a c t o r clr ;
17 M o d C o o l e d L i q u i d R e a c t o r O D E clrODE ;
18 // Declaring variables
19 // -- inputs
20 Real _Vd " Volumetric flow rate through reactor , L / s ";
21 Real _cAi " Influent molar concentration of A , mol / s ";
22 Real _Ti " Influent temperature , K ";
23 Real _Qd " Added ’ heat ’ to reactor , kW ";
24 // -- outputs
25 output Real _cA " Molar concentration of A , mol / L ";
26 output Real _cB " Molar concentration of B , mol / L ";
27 output Real _T " Reactor temperature , K ";
28 output Real _cA_ODE " Molar concentration of A , mol / L ";
29 output Real _cB_ODE " Molar concentration of B , mol / L ";
30 output Real _T_ODE " Reactor temperature , K ";
31 // Equations
32 equation
33 // -- input values
34 _Vd = if time < 80 then 2 else 3;
35 _cAi = if time < 60 then 3 else 4;
36 _Ti = if time < 40 then 283.15 else 278.15;
37 _Qd = if time < 10 then 0 else -50;
38 // -- injecting input functions to model inputs
39 clr . Vd = _Vd ;
40 clr . cAi = _cAi ;
41 clr . Ti = _Ti ;
42 clr . Qd = _Qd ;
43 clrODE . Vd = _Vd ;
44 clrODE . cAi = _cAi ;
45 clrODE . Ti = _Ti ;
46 clrODE . Qd = _Qd ;
47 // -- outputs
48 _cA = clr . cA ;
49 _cB = clr . cB ;
50 _T = clr . T ;
51 _cA_ODE = clrODE . cA ;
52 _cB_ODE = clrODE . cB ;
53 _T_ODE = clrODE . T ;
452 CHAPTER 7. ENERGY BALANCE*
54 end S im C oo le d L i q u i d R e a c t o r ;
55 //
56 model M o d Co ol ed L i q u i d R e a c t o r
57 // Model of Cooled Liquid Reactor
58 // author : Bernt Lie
59 // University of South - Eastern Norway
60 // October 27 , 2015
61 // May 12 , 2017
62 //
63 // Parameters
64 parameter Real V = 15 " Reactor volume , L ";
65 parameter Real rho = 1 " Liquid density , kg / L ";
66 parameter Real a = 2 " Stoichiometric constant , -";
67 parameter Real k0 = 0.1 " Pre - exponential factor , ...";
68 parameter Real EdR = 1 e3 " Activation temperature , K ";
69 parameter Real HtAdd = 100 " Molar enthalpy of A at std
cond , kJ / mol ";
70 parameter Real HtBdd = -150 " Molar enthalpy of B at std
cond , kJ / mol ";
71 parameter Real HhSdd = 0 " Specific enthalpy of solvent at
std cond , kJ / kg ";
72 parameter Real cptA = 50 e -3 " Molar heat capacity of A , kJ
. mol -1. K -1";
73 parameter Real cptB = 100 e -3 " Molar heat capacity of B ,
kJ . mol -1. K -1";
74 parameter Real cphS = 4.2 " Specific heat capacity of
solvent , kJ . kg -1. K -1";
75 parameter Real Tdd = 293.15 " Temperature in std state , K
";
76 parameter Real pdd = 1.01 e5 " Pressure in std state , Pa ";
77
78 // Initial state parameters
79 parameter Real nA0 = 2 " Initial number of moles of A , mol
";
80 parameter Real nB0 = 0 " Initial number of moles of B , mol
";
81 parameter Real mS = rho * V " Mass of solvent , kg ";
82 parameter Real T0 = 288.15 " Initial temperature , K ";
83 parameter Real HtAp0 = HtAdd + cptA *( T0 - Tdd ) " Initial
molar enthalpy of A , kJ / mol ";
84 parameter Real HtBp0 = HtBdd + cptB *( T0 - Tdd ) " Initial
molar enthalpy of B , kJ / mol ";
85 parameter Real HhSp0 = HhSdd + cphS *( T0 - Tdd ) " Initial
specific enthalpy of solvent , kJ / kg ";
86 parameter Real HAp0 = nA0 * HtAp0 " Initial enthalpy of A ,
kJ ";
87 parameter Real HBp0 = nB0 * HtBp0 " Initial enthalpy of B ,
kJ ";
88 parameter Real HSp0 = mS * HhSp0 " Initial enthalpy of
7.14. CASES: LIQUID PHASE REACTOR 453
solvent , kJ ";
89 parameter Real H0 = HAp0 + HBp0 + HSp0 " Initial total
enthalpy of ideal solution , kJ ";
90 parameter Real U0 = H0 - pdd * V " Initial internal energy ,
kJ ";
91 // Declaring variables
92 // -- states
93 Real nA ( start = nA0 , fixed = true ) " Initializing amount
of A in reactor , mol ";
94 Real nB ( start = nB0 , fixed = true ) " Initializing amount
of B in reactor , mol ";
95 Real U ( start = U0 , fixed = true ) " Initializing internal
energy in reactor , kJ ";
96 // -- auxiliary variables
97 Real ndAi " Influent molar flow rate of A , mol / s ";
98 Real ndAe " Effluent molar flow rate of A , mol / s ";
99 Real ndAg " Molar rate of generation of A , mol / s ";
100 Real ndBi " Influent molar flow rate of B , mol / s ";
101 Real ndBe " Effluent molar flow rate of B , mol / s ";
102 Real ndBg " Molar rate of generation of B , mol / s ";
103 Real mdSi " Influent mass flow rate of solvent , kg / s ";
104 Real mdSe " Effluent mass flow rate of solvent , kg / s ";
105 Real Hdi " Influent enthalpy flow rate , kJ / s ";
106 Real Hde " Effluent enthalpy flow rate , kJ / s ";
107 Real cA " Molar concentration of A , mol / L ";
108 Real cB " Molar concentration of B , mol / L ";
109 Real r " Rate of reaction , mol /( L . s ) ";
110 Real k " Reaction ’ constant ’ , ...";
111 Real T " Reactor temperature , K ";
112 Real H " Reactor enthalpy , kJ ";
113 Real HAp " Enthalpy of pure A , kJ ";
114 Real HBp " Enthalpy of pure B , kJ ";
115 Real HSp " Enthalpy of pure solvent , kJ ";
116 Real HtAp " Molar enthalpy of pure A , kJ / mol ";
117 Real HtBp " Molar enthalpy of pure B , kJ / mol ";
118 Real HhSp " Specific enthalpy of pure solvent , kJ / kg ";
119 Real HdApi " Influent enthalpy flow of pure A , kJ / s ";
120 Real HdBpi " Influent enthalpy flow of pure B , kJ / s ";
121 Real HdSpi " Influent enthalpy flow of pure solvent , kJ / s
";
122 Real HtApi " Influent molar enthalpy of pure A , kJ / mol ";
123 Real HtBpi " Influent molar enthalpy of pure B , kJ / mol ";
124 Real HhSpi " Influent specific enthalpy of solvent , kJ / kg
";
125 Real HdApe " Effluent enthalpy flow of pure A , kJ / s ";
126 Real HdBpe " Effluent enthalpy flow of pure B , kJ / s ";
127 Real HdSpe " Effluent enthalpy flow of pure solvent , kJ / s
";
128 // -- input variables
454 CHAPTER 7. ENERGY BALANCE*
";
211 input Real cAi " Influent molar concentration of A , mol / L
";
212 input Real Ti " Influent temperature , K ";
213 input Real Qd " Added ’ heat ’ , kW ";
214 // Equations constituting the model
215 equation
216 // Differential equations
217 V * der ( cA ) = cAi * Vd - cA * Vd - a * r * V ;
218 V * der ( cB ) = - cB * Vd + r * V ;
219 ( cA * V * cptA + cB * V * cptB + rho * V * cphS ) * der ( T ) = ( cAi * Vd *
cptA + rho * Vd * cphS ) *( Ti - T ) - dHtr * r * V + Qd ;
220 // Algebraic equations
221 r = k * cA ^ a ;
222 k = k0 * exp ( - EdR / T ) ;
223 dHtr = HtBdd - a * HtAdd + ( cptB - a * cptA ) *( T - Tdd ) ;
224 end M o d C o o l ed L i q u i d R e a c t o r O D E ;
225 // End package
226 end Co o ledLiquidRe a c to r ;
and
dU
= Ḣi − Ḣe + Q̇
dt
⇓
d
(H − p◦ V ) = Ḣi − Ḣe + Q̇
dt
⇓
dH
= Ḣi − Ḣe + Q̇.
dt
Here,
∑
H= Hj•
j
⇓
( )
dH d ∑ • d ∑ ∑ d H̃ •
dn
nj H̃j• = + H̃j•
j j
= Hj = nj ,
dt dt j dt j j
dt dt
while
∑
•
Ḣi = Ḣj,i
j
∑
•
Ḣe = Ḣj,e .
j
Here,
dH̃j• d ( ◦ ) dT
= H̃j + c̃•p,j (T − T ◦ ) = c̃•p,j
dt dt dt
dnj
= ṅj,i − ṅj,e + ṅj,g .
dt
Thus
dH
= Ḣi − Ḣe + Q̇
dt
⇓
∑( dT
) ∑ ∑
nj c̃•p,j + H̃j• (ṅj,i − ṅj,e + ṅj,g ) = •
ṅj,i H̃j,i − ṅj,i H̃j• + Q̇.
j
dt j j
∑ •
Here, both sides contain the term j H̃j ṅj,e ; these terms cancel. Moving the re-
maining two terms of H̃j• dtj to the RHS30 , we get
dn
∑( ) ∑ ∑
• dT • •
nj c̃p,j + H̃j (ṅj,i − ṅj,e + ṅj,g ) = ṅj,i H̃j,i − ṅj,i H̃j• + Q̇
j
dt j j
⇓
∑( dT
) ∑ ( ) ∑
nj c̃•p,j = •
ṅj,i H̃j,i − H̃j• − H̃j• ṅj,g + Q̇.
j
dt j j
30
RHS = right hand side (of equality sign).
458 CHAPTER 7. ENERGY BALANCE*
Here,
∑( )
( ) dT
• dT
nj c̃p,j = nA c̃•p,A + nB c̃•p,B + mS ĉ•p,S
j
dt dt
•
H̃j,i − H̃j• = H̃j◦ + c̃•p,j (Ti − T ◦ ) − H̃j◦ − c̃•p,j (T − T ◦ ) = c̃•p,j (Ti − T )
∑ ( )
•
ṅj,i H̃j,i − H̃j• = ṅA,i c̃•p,A + ṁS,i ĉ•p,S (Ti − T )
|{z} |{z}
j
cA,i V̇ ρV̇
∑ ( )
H̃j• ṅj,g = H̃A• (−arV ) + H̃B• rV = H̃B• − aH̃A• rV
j | {z }
∆r H̃
where
where
) (
E
r = k0 exp − caA
RT
( ) ( )
∆r H̃ = H̃B − aH̃A + c̃•p,B − ac̃•p,A (T − T ◦ ) .
◦ ◦
7.15. CASE: GAS PHASE REACTOR⋆ 459
we have
x = (cA , cB , T )
( )
u = V̇ , cA,i , Ti , Q̇
( )
• • • E ◦ ◦ ◦
θ = a, V, c̃p,A , c̃p,B , ĉp,S , k0 , , H̃B , H̃A , T
R
y = (cA , cB , T ) .
The advantages of the ODE model over the DAE model, are (1) that it is signifi-
cantly simpler, and (2) that ODE solvers are simpler to implement or more readily
available than DAE solvers. The disadvantages with the ODE model over the DAE
model are (1) the considerable amount of model manipulation which is required
with possibilities of introducing errors, and (2) that in order to find other variables
than the states x and the inputs u of the ODE, some post-processing of the model
is required.
To complete the model, model parameters are taken from Table 7.13 and oper-
ating conditions are taken from Table 7.14.
7.16 Review
In this chapter, we have extended the mechanical energy balance from the chapter
on Momentum balance to an energy balance for particles. By splitting out the
kinetic and potential energy for the mass center of the system from the total energy,
it is necessary to add the internal energy to cater for particle movements about the
460 CHAPTER 7. ENERGY BALANCE*
averaged mass center position. Molecular level work terms are separated out as heat
flow, with heat conduction and heat radiation. To simplify the model, convective
energy transport by mass movement in some boundary layer is re-interpreted as
heat flow by convection. Concepts such as heat transfer and overall heat transfer
has been introduced.
In order to relate internal energy for pure substances to intensive variables such
as temperature and pressure, specific internal energy and specific enthalpy has been
introduced. Basic thermodynamics has been discussed to enable the computation
of specific (or molar) enthalpy, which is then used to compute enthalpy flows and
internal energy. The cases of ideal gas and fixed density liquids are considered in
more detail. For mixtures, the ideal solution assumption is introduced, which enables
easy computation of molar enthalpy, enthalpy flows and internal energy. The added
difficulty of computing specific (or molar) enthalpy for more complex Equations of
State than the ideal gas law is discussed, and the structure of specific enthalpy for
non-ideal solutions is briefly addressed.
This is not a course about thermodynamics, and only a working knowledge of
the ideal gas law, Eq. 7.28, the differential of pure substance enthalpy, Eqs. 7.39,
with the coefficient of thermal expansion, Eq. 7.33, and an understanding of ideal
solutions is required to develop simple models.
Through examples, the use of the energy balance for computing the temperature
is given. In most examples, a DAE formulation is preferred: the DAE formulation is
simpler to pose, and can be solved using OpenModelica. However, selected examples
are also reduced to an ODE formulation through manipulation of equations, and it
is shown that the result of solving the DAE and the ODE formulation is identical.
The ODE formulations give added insight wrt. inertia, heat of reaction, etc.
So far, we have analyzed models through simulation. In the next chapter, a more
analytic approach to analysis is introduced.
7.17 Exercises*
Simple, repetitive to stress procedures
7.18 Problems*
Things to think about to give a deeper understanding
• Joule-Thompson
Find expressions for molar entropy S̃ for ideal gas (ref: Section 7.8):
gives a good approximation, and that this is a more efficient way to compute the
heat transfer. Some literature also propose that the above approximation removes
possible computational problems with the logarithm due to changing signs in the
temperature differences.
462 CHAPTER 7. ENERGY BALANCE*
• Find a simplified expression for Q̇t2s under the assumption that |αt − αs | is
small and a first order Padé approximation is used.
• How do these simplified expressions relate to the correct expressions for the
singular case of αs → αt , as found in Problem 7.5?
N
Problem 7.7. [Solution E.22 p. 608] Heated water tank with varying level.
We consider the system sketched in Fig. 7.35.
Figure 7.35: Sketch of system. Heat capacity that appears as cp , should be ĉp .
The vessel in Fig. 7.35 has a cross-sectional area A. Liquid flows into the system
at temperature Ti and volumetric flow rate V̇i [volume/time]. The vessel is ideally
stirred, and the temperature of the liquid in the vessel is T . We assume that the
bottom pressure is pb given by :
pb = pa + ρgh,
7.18. PROBLEMS* 463
where pa is the atmospheric pressure. The volumetric flow of liquid out of the vessel
is V̇e , given by the valve characteristic
√
pb − pa
V̇e = Kv u ,
pa
where u is some valve signal which can be controlled, e.g., through a computer.
A cylindrical heat element at temperature Th and diameter D has been put into
the vessel. The overall heat transfer coefficient from the heat element to the liquid
is Uh [ K mJ 2 h ].
The density of the liquid is ρ = constant throughout the system. The specific
heat capacity at constant pressure of the liquid is ĉp . We neglect the workflow from
the environment.
• Find a dynamic model of the liquid level h and the liquid temperature T .
The answer should show the development of the model, and any additional
assumptions that you introduce.
To avoid that the vessel is emptied of liquid, or that liquid overflows the vessel,
a so-called P-controller is introduced:
u = us − Kp (hr − h) .
• How is the model changed when you introduce the controller into the model?
N
Problem 7.8. [Solution E.24 p. 614] The system that is considered in Problem 7.7,
can be modeled as follows:
dh 1 ( )
= V̇i − V̇e
dt A1
dT V̇i Uh πD
≈ (Ti − T ) + (Th − T )
dt A1 h ρĉp A1
where
D2
A1 = A − π
√4
ρgh
V̇e = Kv u .
pa
u = us − Kp (hr − h) .
• Use the numerical values and operating conditions in Table 7.15, and simulate
the system using ODE solvers in MATLAB. Find an interesting time length
to simulate.
464 CHAPTER 7. ENERGY BALANCE*
Table 7.15: Numerical values for parameters and operating points for the model of
Problem 7.7.
Numerical values
2
A = 10 m cross-sectional area of vessel
D = 0.5 m diameter of heat element
3
Kv = 1 m /h valve constant
ρ = 1000 kg/m3 liquid density
g = 9.81 m/s2 gravitational acceleration
pa = 1 bar atmospheric pressure
κp = 1.01 × 105 Pa/bar conversion factor, bar → Pa
Uh = 3 × 103 J
K m2 h
overall heat transfer coefficient, heat element-liquid
J
ĉp = 4200 kg K
specific heat capacity at constant pressure
hr = 2 m reference value, level controller
−1
Kp = 1 m proportional gain, controller
us = 0 — constant offset in controller
h|t=0 = 2 m initial value, h
T |t=0 = 350 K initial value, T
2
V̇i = 50 m /h volumetric flow into vessel
Ti = 300 K feed temperature
Th = 450 K temperature of heat element
Problem 7.9. [Solution E.23 p. 611] Modification of reactor in Seborg et al. (2011).
r = kcm
A,
where ρc is the density of the cooling water, ĉp,c is the heat capacity of the cooling
water, Tc,i is the feed temperature of the cooling water, while L is the length of the
cooling coil, Ω is the circumference of the cooling coil, and h is the heat transfer
coefficient from the cooling liquid to the reactor content.
Assume initially that the temperature of the reactor is constant.
Assume now that the temperature T of the reactor can vary with time, and that
the reaction rate factor k is given by the Arrhenius expression
( )
E
k = k0 exp −
RT
H = HS + HA + HB ,
Problem 7.10. [Solution E.25 p. 617] Reaction equilibrium constant for Haber
Bosch synthesis.
c A, c B
Model analysis*
467
468 CHAPTER 8. MODEL ANALYSIS*
where we will denote the unknowns x by “state variables” — those which are dif-
ferentiated wrt. time, the unknowns z by “algebraic variables”, while u are input
variables with values decided externally of the system, and θ are parameters/con-
stants. In general, we should have the same number of equations and unknowns,
thus the number of (nonlinear) equations in f (·) should equal dim x + dim z. These
most general DAEs can be complex to analyze and solve ?.
In the model structure of Eq. 8.1, the inputs u are typically a function of time
t. In addition, we have allowed for explicit time dependence by indicating that t is
one of the arguments of f (·). What is the difference between the time dependence
via u and the direct time dependence? The following simple example illustrates the
idea.
Example 8.1. Model reduction to time variance by partial solution.
Consider a system
dx1
= −2x1
dt
dx2
= −x1 x2 + u.
dt
In this system, there is no direct time dependence; the only time dependence is
via u. However, in this case, we can solve explicitly the equation for x1 to yield
x1 (t) = exp (−2t) x0 . Thus, we can re-phrase the model as
dx2
= − exp (−2t) x0 · x2 + u,
dt
which has explicitly time dependence through the term exp (−2t). Thus, we have
introduced explicit time dependence while simultaneously reducing the model order
from a second order ODE to a first order ODE. N
DAE models with explicit time dependence are denoted time variant DAEs.
Normally, such explicit dependence of time makes it more difficult to analyze the
model. Also, such time dependence often is the result of solving part of the model
analytically and thus reducing the order of the model. One of the key axioms of
physics is that the underlying mechanisms of nature are time invariant, i.e., does
not depend explicitly of time. Thus, for mechanistic models, it is perhaps better
to use an underlying time invariant model, even at the expense of a slightly higher
model order. To this end, the time invariant version of the model in Eq. 8.1 is the
slightly different model in Eq. 8.2,
( )
dx
f , x, z, u; θ = 0. (8.2)
dt
Both in Eq. 8.1 and in Eq. 8.2, the function name f (·) is a generic function, and
there is no implication that the function actually is the same mapping in the two
cases.
The model in Eq. 8.1 is non-autonomous or driven because of the external input
variable u. If the input variable is missing, the general DAE reduces to the form of
Eq. 8.3, ( )
dx
f , x, z; θ, t = 0. (8.3)
dt
8.2. MODEL TYPES, SOLVABILITY AND STABILITY 469
Eqs. 8.5–8.6 give the time invariant version of this structured DAE.
How do we find the equations in Eq. 8.5? The answer is simple: the differen-
tial equations are found by setting up the balance equations of the system, i.e.,
by formulating mass, species, momentum, and energy balances. In this case, func-
tion f (·) simply reflects the balance laws. Alternatively, the state could be some
transformation of the extensive variables in balance laws, e.g., level, concentration,
velocity, temperature, etc., whereupon the function f (·) becomes more complicated.
A warning is still due: if we have ns species and pose ns species balances as differ-
ential equations, we can not simultaneously use the total mass balance — because
the total mass balance is simply the sum (= a linear combination) of the ns mass
based species balances. Thus, if we choose to use the total mass balance, we can
only pose ns − 1 species balances.
What about the algebraic equations in Eq. 8.6? These are simply the additional
equations, relating algebraic quantities with states and input variables. Typically,
these algebraic equations contain thermodynamic Equations of State (EoS), ther-
modynamic relationships, valve models, reaction rates, etc. These equations that
come in addition to the balance laws, and which are necessary to fully specify the
model, are known as constitutive 1 equations or material 2 equations.
A linear, time invariant version of the structured DAE is of form
dx
= Ax + Bu + Cz
dt
0 = Dx + Eu + F z
where the matrices are constant valued. If we allow for the matrices to vary with
time, the model is a linear, time invariant DAE.
Clearly, the above structured DAEs are driven (non-autonomous). If there is no
dependence on input u, the models are autonomous.
1
Constitutive in the sense of being necessary to constitute a complete model.
2
Material in the sense of depending on the chosen material and geometric dimensions, as opposed
to the balance laws which are generic.
470 CHAPTER 8. MODEL ANALYSIS*
dx
= f (x, u; t, θ) (8.7)
dt
Again, x is the state variable, which is usually the unknown that we seek to find. u
is the input variable. θ is a (list of) parameters (constants) in the model. Finally,
t is the time variable. The state can be the level in a tank, the concentration of
a species, the temperature, etc. In more general models, the state can also be an
ordered list of variables (a vector) that we have ODEs for. Likewise, u can be an
ordered list of known functions of time — input variables (vector of inputs). Finally,
θ can be an ordered list (vector) of known parameters.
Just as for DAEs, we can introduce specialized versions of ODEs such as time
invariant, driven (non-autonomous) models
dx
= f (x, u; θ) , (8.8)
dt
time invariant, autonomous models
dx
= f (x; θ) , (8.9)
dt
and linear, time invariant (LTI) models
dx
= Ax + Bu, (8.10)
dt
where matrices A and B are constant valued matrices, and where allowing A and B
makes the model linear, time variant (LTV).
A further classification for ODEs is the following: if the function f (x, u; t, θ) has
the structure
f (x, u; t, θ) = x · f1 (u (t) ; t, θ) ,
then the ODE/model is linear provided that u is a pure function of time. In par-
ticular, this implies that u is not computed from the value of x (which is the case
in feedback control). In the simpler case
f (x, u; t, θ) = x · f1 (t, θ) ,
For this case, the model is affine in u. With f1 (·) ≡ 0, the model is linear in u.
8.2. MODEL TYPES, SOLVABILITY AND STABILITY 471
So now we have time derivatives of both x and z. Does this mean that both x and
z are states now, see Eqs. 8.5 and 8.11? Is the concept of “state” so vague that we
don’t even known how many states we have?
To get at a more precise definition of “state”, we remember that for ordinary
differential equations
dx
= f (x, u; θ) ,
dt
we need to have as many boundary values as there are states in order for the equation
to be well defined.
• functions f (x, u, z; θ) and g (x, z, u; θ) with some mild restrictions on f (·) and
g (·) in order for a unique solution to exist, see Section 8.2.2.3 below,
• the input variable u (t) for all times of interest. If we seek the solution of x (t)
in the interval t = [t0 , t1 ], then we need to know u (t) for t ∈ [t0 , t1 ],
dx
= f˜ (x, u; θ) (8.12)
dt
where
f˜ (x, u; θ) = f (x, g̃ (x, u; θ) , u; θ)
The DAE is thus equivalent to an ODE wrt. to the solution of variable x. By solving
this ODE, we find x. Then we can recreate z from g̃ (x, u; θ).
When can a model as in Eq. 8.12 be solved? We will assume that u is a known
function of time t so that we can reduce the ODE to
dx
= F (x, t; θ) (8.13)
dt
where
F (x, t; θ) = f˜ (x, u (t) ; θ) .
It can be shown that an ODE as in Eq. 8.13 has at least one solution (existence)
if F (x, t) is continuous in x and t. Most models we face will be continuous in the
state (and time). But we also want the solution to be unique. It can be shown that
3
Alternatively, a final time could be specified, or a mixed initial-final time for the states.
8.2. MODEL TYPES, SOLVABILITY AND STABILITY 473
The condition for being Lipschitz continuous is weaker than being differentiable,
thus if ∂F
∂x
exists at some point, then it certainly is Lipschitz continuous and the
solution is unique. One example of a function which is not differentiable and still is
Lipschitz continuous = a solution exists, is F (x, t; θ) = |x|.
Extensions of these conditions exist, e.g., to systems where F (x, t; θ) is contin-
uous in x at almost all times t, systems where we preserve the input u as in Eq.
8.12 in the analysis, and so-called variable structure control systems (VSC systems)
DeCarlo et al. (1996).
The conditions for existence and uniqueness of the model are usually satisfied
for the types of models we consider in these lecture notes. Clearly, the balance
equations pose no problems wrt. solvability. If some unfortunate choice of mapping
in the constitutive equations (Eq. 8.6) should render the model unsolvable, then
this equation should be reformulated: our models are supposed to represent physical
systems, and physical reality has a solution.
Under the validity of the mean value theorem, this integral formulation can be
rephrased in the differential formulation as
dm
= ṁi − ṁe .
dt
N
Although not stated explicitly, the same assumption of validity of the mean
value theorem has been used in all balance equations. The problem with the DAE
formulation is thus that we assume that the mean value theorem is valid for the
time integral of the flow variables. What, then, is the underlying assumption in the
mean value theorem? It is simply that the flow terms and generation terms vary
4
Named after German mathematician Rudolf Lipschitz (1832–1903).
474 CHAPTER 8. MODEL ANALYSIS*
continuously with time. What if there are step changes/jumps in these terms? Then
the differential formulation is, strictly speaking, not valid.
If there are few such jumps in the flow/generation terms, we can handle the
situation by detecting when the jumps take place5 , stop the simulation at a jump,
introduce the jump, and then continue the simulation. We can theoretically handle
the situation if we can count the number of changes, i.e., if the changes take place
at point t ∈ {t1 , t2 , . . . , ti , . . .}.6 However, if there are many jumps, the situation
becomes hard to handle in practice. An alternative is to simply neglect that the
jumps break the assumption of the model development. But this will produce an
inaccuracy in the solution.
If the input varies randomly, we basically assume that it is generated by a hypo-
thetical random number generator. Still, if we have a countable number of changes,
a random input can be handled. However, a common and extreme case is that the
input is considered as white noise. White noise implies that the input varies ran-
domly at each time instance, and that there is no correlation between the random
outcomes at time t and t + dt where dt is infinitesimal. For continuous time systems
where the independent time variable t ∈ R, this means that number of changes
can not even be counted; it is uncountable. For white noise input, the differential
formulation is invalid. In that case, we can not write a structured DAE model as
dx
= f (x, z, u; θ)
dt
0 = g (x, z, u; θ) ,
dx = f (x, z, u; θ) dt
0 = g (x, z, u; θ) .
Another way to phrase this is that with a white noise input u, the value of f (x, z, u; θ)
will jump randomly, and dx dt
is discontinuous and hence does not really exist. How-
ever, dx = f (x, z, u; θ) dt will exist.
The second problem indicated above, is that the system is stochastic in that we
do not really know x (t0 ), θ and u (t), but instead that we know the statistics of these
quantities. This means that we do not x (t0 ), but instead know that x (t0 ) belongs to
some population defined by a probability distribution. Likewise, we do not know θ,
but we know that θ belong to some population defined by a probability distribution.
Finally, we do not know u (t), but we know that u (t) at each non-countable instance
t ∈ R belongs to some population defined by a probability distribution.
are relatively easy to handle simply because these cases do not invalidate the DAE
formulation. Let us illustrate the idea by θ belonging to some population described
by a probability distribution. Suppose we have a random generator valid for the
particular population and that we can draw NMC outcomes θ(i) of the parameter.
We can then solve the DAE model NMC times, one time for each θ(i) , and leading
to NMC solutions x(i) (t). We then say that the NMC trajectories/solutions x(i) (t)
constitute an ensemble of solutions. Note that the number of solutions is countable.
If we let NMC → ∞, we get an ensemble of infinitely many solutions, and the
number of solutions is still countable. In each time instance t, the ensemble gives
a population for x (t), and we can compute the statistics of x (t). As examples, the
expected value µx (t) can be found as
1 ∑
NMC
µx (t) = E {x (t)} = lim x(i) (t) (8.14)
NMC →∞ NMC
i=1
while for x (t) being a column vector, co-variance matrix Σx (t) can be found as
{ }
Σx (t) = E [x (t) − µx (t)] [x (t) − µx (t)]T
1 ∑
N MC
Here, the main diagonal elements of Σx (t) give the individual squared standard
deviations for the individual states, σx2i = Σx,(i,i) .
In practice, Monte Carlo simulation is carried out a finite number of times, i.e.,
NMC is finite. Experience shows that good estimates of x̄ (t) and σx are found with
NMC ≈ 102 . Higher order statistics such as quantiles, etc. may require NMC ≈ 103 .
The same strategy is valid for the case of x (t0 ) belonging to some population
with a given probability distribution.
The case when u (t) is not deterministic, but instead that u (t) at each non-
countable instance t ∈ R belongs to some population with a given probability dis-
tribution, is much more complicated. The reason is, of course, that then the DAE
formulation is not valid. And even if the integral formulation of the DAE is valid,
it is not possible to solve it exactly on a computer because it requires an infinite
and even uncountable number of starts and stops of the simulation. This is the case
when the theory of Stochastic Differential Equations really come into use Øksendal
(1995).
However, if we reduce the number of changes in u (t) to a countable number tj
where j ∈ N, then we can in principle use the ideas of Monte Carlo simulation where
for each u (tj ) we draw N outcomes u(i) (tj ), and inject u(i) (tj ) into the model while
solving the DAE, again leading to N solution trajectories x(i) (t). Still, a countable
number is still a large number.
A practical solution is to allow u (t) to change only at certain time instances, e.g.,
t ∈ {0, ∆t, 2∆t, . . . , (N − 1) ∆t}, while keeping u (t) constant between these time in-
stances. Thus, we need to draw outcomes u(i) (t) with t ∈ {0, ∆t, 2∆t, . . . , (N − 1) ∆t},
and can solve the DAE to yield x(i) (t), where the statistics of the ensemble of solu-
tions is relatively easy to compute.
476 CHAPTER 8. MODEL ANALYSIS*
Figure 8.1: Concepts in stability definition. For simplicity, absolute value has been
used instead of norm.
dx
= f (x, t) ,
dt
∗
with x ∈ Rnx , i.e., dx
dt
= f (x∗ , t0 ) = 0.7 Then the system is stable at point x∗ if, for
every ϵ > 0, there exists δ (ϵ) ≤ ϵ such that for all t > t0
Consider a pendulum hanging straight down, where x∗ = (α∗ , ω ∗ ) and the angle
is α∗ = 0 (hanging straight down) while the angular velocity is ω ∗ = 0. If we perturb
the initial position slightly to x (0), where ∥x (0) − x∗ ∥ < δ, the pendulum will start
to oscillate with a deviation around x∗ contained in ∥x (t) − x∗ ∥ < ϵ. If we shrink ϵ
even to an arbitrarily small positive number so that the oscillations are required to
be arbitrarily small, this can still be achieved by shrinking δ. Thus, the system is
stable at point x∗ . N
dx
= f (x, t)
dt
with x ∈ Rnx is asymptotically stable at a point x∗ , where x∗ is a constant vector, if
it is stable and if for some δ > 0, ∥x (t0 ) − x∗ ∥ < δ ⇒ limt→∞ x (t) = x∗ . N
A system
dx
= f (x, t)
dt
with x ∈ Rnx is exponentially stable at a point x∗ , where x∗ is a constant vector, if it
is asymptotically stable and if there are positive numbers (α, β) such that for some
δ > 0, ∥x (t0 ) − x∗ ∥ < δ ⇒ ∥x (t) − x∗ ∥ < α ∥x (t0 ) − x∗ ∥ exp (−βt). N
Instead of talking about stability at a fixed operating point x∗ , we could talk
about stability around an operating solution x∗ (t).9 The definitions are more or
less the same as long as we replace x∗ with x∗ (t).
9
Stability around a solution is known as Lyapu’nov stability Jordan & Smith (1987), after
Russian mathematician Alexandr Lyapu’nov (1857–1918). A slightly less strict requirement is the
Poincaré stability (French mathematician Henri Poincaré, 1954–1912), which is stability around a
path; essentially measured as a deviation in phase space where differences in phase are lost.
478 CHAPTER 8. MODEL ANALYSIS*
dx
= f1 (x; θ) · f2 (t; θ)
dt
where x ∈ R. We can then use the method of separation of variables, and write the
model as
dx
= f1 (x; θ) · f2 (t; θ)
dt
⇓
dx
= f2 (t; θ) dt
f1 (x; θ)
⇓
ˆ x(t) ˆ t
dx
= f2 (t; θ) dt
x(t=t0 ) f1 (x; θ) t=t0
⇓
F1 (x (t) ; x (t0 ) , θ) = F2 (t; t0 , θ) .
Here, it may or may not be possible to solve the equation wrt. x (t).
Consider the case in Example 5.12.5, which can be combined and simplified into
the ODE
dnA ak
= − a−1 naA .
dt V
This is a separable ODE, and we find
dnA ak
= − a−1 naA
dt V
⇓
dnA ak
a
= − a−1 dt
nA V
⇓
ˆ nA (t) ˆ t
dnA ak
a
=− a−1
dt.
nA (0) nA 0 V
We have {
ˆ
dnA ln nA + c1 , a=1
= ̸ 0 .
− na−1 a−1 + c2 , a =
1 1
naA A
8.3. ANALYTIC SOLUTION OF NONLINEAR MODELS 479
Thus, for a = 1 (first order reaction) we have a linear, time invariant, autonomous
model:
n (t)
[ln nA ]nAA (0) = −kt
⇓
ln nA (t) − ln nA (0) = −kt
⇓
nA (t)
ln = −kt.
nA (0)
nA (t)
= exp (−kt)
nA (0)
⇓
nA (t) = exp (−kt) nA (0) .
Consider the case in Example 4.8.1 p. 101, which can be combined and simplified
into
dh K √
=− √ h
dt ρA hς
⇓
ˆ h(t) ˆ t
dh K
√ =− √ dt
h(t=0) h 0 ρA hς
⇓
[ √ ]h(t) K
2 h =− √ t.
h(0) ρA hς
480 CHAPTER 8. MODEL ANALYSIS*
It follows that
√ √ K
h (t) = h (0) − √ t
2ρA hς
⇓
( )2
√ K
h (t) = h (0) − √ t . (8.16)
2ρA hς
where x ∈ Rnx , u ∈ Rnu , and y ∈ Rny . The idea is simple to extend to DAEs.
Non-analytic function
25
20
15
f (x)
10
−4 −2 0 2 4
x
Figure 8.2: Example of non-analytic function: this function can not be expressed as
∑ 1 di f (x)
f (x) = ∞ i=0 i! dxi (x − x∗ )i .
x=x∗
where we in the final expression assume that f (x) is infinitely differentiable. The
Taylor series expansion theorem actually requires slightly more: it is necessary that
the function is analytic.10 As an example of why infinite differentiability does not
suffice, consider function
{
0 x<0
f (x) = , (8.17)
x2 x ≥ 0
depicted in Fig. 8.2: this function can not be expressed as a Taylor series, even
∗
though it is infinitely differentiable. Why? If we choose, e.g., x = −1, for every i,
i
d f (x)
dxi
≡ 0, leading to the incorrect result f (x) ≡ 0. Function f (x) in Eq. 8.17
x=x∗
is not analytic.
In practice, we will truncate the series at a finite value of i. In linearization, we
will truncate the series after the linear term, i.e., we will write
∗ df (x) ∗
( ∗ 2
)
f (x) = f (x ) + (x − x ) + O (x − x )
dx x=x∗
| {z }
fℓ (x)
( )
where O (x − x∗ )2 indicates a remaining term which is “of order 2 in x − x∗ ”.
1.5
1.0
0.5
0.0
−0.5
0,1 order
−1.0 2,3 order
4,5 order
sin(x)
−1.5
0 π/4 2π/4 3π/4 4π/4 5π/4 6π/4 7π/4 8π/4
x
Figure 8.3: The Taylor series expansion of y = sin x. The various graphs show
y (solid, black), and series expansions around x = π2 : y0,1 (dash-dot, blue), y2,3
(dash-dot,
( ) green), and y4,5 (dash-dot, red). Note that y0 and y1 are identical, since
cos π2 = 0. Similarly for y2 , y3 and y4 , y5 .
To clarify the idea, let us consider y = sin x, and use the operating point x∗ =
π/2. We find the Taylor expansion as
1 1
y = sin x = sin x∗ + (x − x∗ ) cos x∗ − (x − x∗ )2 sin x∗ − (x − x∗ )3 cos x∗
2 6
1
+ (x − x∗ )4 sin x∗ + · · ·
24
⇕
π ( π) π 1( π )2 π 1( π )3 π
y = sin + x− cos − x− sin − x− cos
2 2 2 2 2 2 6 2 2
y1
1 ( π )4 π
+ x− sin + · · · .
24 2 2
Now, let
(
∑ 1 di sin x π )i
n
yn = x− .
i=0
i! dxi x= π 2
2
As displayed in Fig. 8.3, the approximation gets better and better the larger n is,
i.e., yn (x) is closer to y (x) when n is large.
N
Example 8.4.2 shows that even a linear approximation y ≈ fℓ (x) of y = f (x)
may be useful with small deviations of x from x∗ .
8.4. LINEARIZATION BY TAYLOR SERIES EXPANSION 483
To simplify the notation, we will write ·|x=x∗∗ as ·|∗ . The linear approximation is
u=u
∗ ∗ ∂f (x, u) ∗ ∂f (x, u)
f (x, u) ≈ f (x , u ) + (x − x ) + (u − u∗ ) .
∂x ∗ ∂u ∗
In order to streamline our notation, we write this linear approximation using the
matrix product
∗
( ) z − z
∑ nz
∂f (z) ∂f (z) ∂f (z)
1
..
1
∗
(zi − zi ) = ∂z1 · · · ∂znz . ,
∂z i ∗ | ∗
{z ∗
}
i=1 znz − zn∗ z
∂f (z)
∂z |∗
| {z }
z−z ∗
or
∑nz
∂f (z) ∂f (z)
∗
(zi − zi ) = (z − z ∗ )
i=1
∂zi ∗ ∂z ∗
where we have used the definition of the matrix product between the row vector
∂f (z)
∂z
and the column vector z − z ∗ .
∗
We see that we can write the linear approximation of a scalar function with
multivariable argument as
∗ ∂f (z)
f (z) ≈ f (z ) + (z − z ∗ ) .
∂z ∗
484 CHAPTER 8. MODEL ANALYSIS*
where fi (x, u) is a scalar function where dim x = nx and dim u = nu ? We then have
that
∗ ∗ ∂fi (x, u) ∗ ∂fi (x, u)
fi (x, u) ≈ fi (x , u ) + (x − x ) + (u − u∗ ) .
∂x ∗ ∂u ∗
Similarly, we define
∂f1 (x,u)
∂f (x, u) ∂u ∗
..
, . .
∂u
∗ ∂fn (x,u)
∂u
∗
(x,u)
Here, ∂f ∂x is the Jacobian matrix of vector of functions f (·) wrt. vector x, while
∗
∂f (x,u)
∂u
is the Jacobian matrix of f (·) wrt. u. We can thus for a general vector
∗
function f (x, u) write the linear approximation as
∗ ∗ ∂f (x, u) ∗ ∂f (x, u)
f (x, u) ≈ f (x , u ) + (x − x ) + (u − u∗ ) ;
∂x ∗ ∂u ∗
∂f (x,u) ∂f (x,u)
this expression presupposes that ∂x
and ∂u
are defined as above, and that
we use the matrix product.
and have
dx
= f (x∗ , u∗ ; θ) + A (x − x∗ ) + B (u − u∗ ) .
dt
If we assume that x∗ is constant wrt. time, we have dx∗ /dt = 0, such that
dx dx dx∗
= − = f (x∗ , u∗ ; θ) + A (x − x∗ ) + B (u − u∗ )
dt dt dt
⇕
d
(x − x∗ ) = A (x − x∗ ) + B (u − u∗ ) + f (x∗ , u∗ ; θ) .
dt
Next, introducing
xδ , x − x∗
uδ , u − u∗ ,
we find
dxδ
= Axδ + Buδ + f (x∗ , u∗ ) . (8.18)
dt
If we have chosen an operating point (x∗ , u∗ ) that satisfies the model, i.e., such that
dx∗
= f (x∗ , u∗ ) = 0,
dt
we find from the linearization that
dxδ
= Axδ + Buδ (8.19)
dt
which describes the deviation between x and x∗ . Since we have assumed that (x∗ , u∗ )
is a fixed/constant operating point, this deviation model will constitute a linear, time
invariant (LTI) model. As we will see, it is then possible to find an analytic solution
to the model suitable for analysis.
If we instead assume that (x∗ , u∗ ) is allowed to vary with time, we will get
dxδ dx∗
= Axδ + Bux + f (x∗ , u∗ ) − ,
dt dt
where A and B will vary with time. If (x∗ , u∗ ) is chosen such that the model is
fulfilled, i.e., such that
dx∗
= f (x∗ , u∗ ) ,
dt
we can still simplify the deviation model at the time varying operating point (x∗ , u∗ )
into
dxδ
= Axδ + Bux .
dt
Note, however, that with an operating point which varies with time, A and B will
vary with time and the system is linear time variant (LTV). LTV systems are much
more complicated to solve and analyze than LTI models.
8.5. SOLUTION OF LINEAR SYSTEMS 487
y = g (x, u) .
We find that
∂g ∂g
y = g (x) ≈ g (x∗ ) + (x − x∗ ) + (u − u∗ ) .
∂x ∗ ∂u ∗
we get
y δ = Cxδ + Duδ ,
where y δ , y − y ∗ .
dx
= Ax + Bu
dt
where x ∈ Rnx is a column vector with nx states of real value, and u ∈ Rnu is
a column vector of nu input variables of real value. State matrix A ∈ Rnx ×nx is
a matrix of dimension nx × nx where the elements have real value, and the time
invariance is expressed in that the elements of A have a constant, time invariant
value. Similarly, input matrix B ∈ Rnx ×nu is a matrix of dimension nx × nu with
real elements.
The reason why we demand that x and u are column vectors, is that we want
to let, e.g., Ax denote the standard matrix product between matrix A and matrix
x — where we consider a column vector as a matrix of dimension nx × 1; similarly
for Bu.
The crucial point in the development is that state matrix A is constant, so for
the development, we can just as well simplify the model to
dx
= Ax + v
dt
where we later re-introduce
v = Bu.
488 CHAPTER 8. MODEL ANALYSIS*
Thus,
x (t)
= exp (at)
x (0)
⇕
x (t) = exp (at) x (0) .
Because our guess solution must fit into the original differential equation, we also
have that
dx
= ax + v = a exp (at) k (t) + v. (8.21)
dt
By equating the RHS12 of Eqs. 8.20 and 8.21, we find that
dk dk
exp (at) + ak (t) exp (at) = a exp (at) k (t) + v ⇔ exp (at) = v.
dt dt
dk
= exp (−at) v (t) ⇔ dk = exp (−at) v (t) dt.
dt
By integrating on both sides of the equality symbol and using that k (0) = x (0), we
find that
ˆ t ˆ t
k (t) − k (0) = exp (−at) v (t) dt ⇔ k (t) = x (0) + exp (−at) v (t) dt.
0 0
To reduce the possibility of confusing the integral boundary t with the arbitrarily
named integrand variable t, it is perhaps clearer to write k (t) as
ˆ t
k (t) = x (0) + exp (−aτ ) v (τ ) dτ
0
dx
= ax + v
dt
d dx d exp (−at) dx
(exp (−at) x) = exp (−at) + x = exp (−at) − exp (−at) ax.
dt dt dt dt
(8.23)
Combining Eqs. 8.22 and 8.23 leads to
d
(exp (−at) x) = exp (−at) v
dt
⇓
ˆ t
t
[exp (−at) x]t0 = exp (−aτ ) v (τ ) dτ
t0
⇓
ˆ t
exp (−at) x (t) − exp (−at0 ) x (t0 ) = exp (−aτ ) v (τ ) dτ .
t0
13
A MacLaurin series is a Taylor series of f (x) expanded at x∗ = 0.
8.5. SOLUTION OF LINEAR SYSTEMS 491
It follows that
ˆ t
x (t) = exp (a (t − t0 )) x (t0 ) + exp (at) exp (−aτ ) v (τ ) dτ .
t0
For the case of t0 = 0, we get the same result as in the previous section.
It could be argued that in the MacLaurin series of exp (at), we had to use knowl-
edge of the derivative of exp (at), so what is really new? And furthermore, we had to
“guess” that it was smart to multiply the original differential equation by exp (−at).
Again, what is new? Well, nothing is really new, but it turns out that the MacLaurin
series idea readily leads to the general solution for the multivariable case.
where coefficients ci are the same as in the scalar case Chen (1999).
For the exponential function, we thus have
1 1
exp (at) = 1 + at + (at)2 + · · · + (at)n + . . . .
2 n!
Then for the matrix argument, we have
1 1
exp (At) , I + At + (At)2 + · · · + (At)n + . . . . (8.24)
2 n!
It follows that
( )
d d 1 1
exp (At) = I + At + (At) + · · · + (At) + . . .
2 n
dt dt 2 n!
⇓
d 1·2 2 n
exp (At) = A + A t + · · · + An tn−1 + . . .
dt 2 n!
⇓
( )
d 1
exp (At) = A I + At + · · · + (At)n−1
+ . . . = A exp (At) .
dt (n − 1)!
492 CHAPTER 8. MODEL ANALYSIS*
In order to evaluate this expression, we need to compute exp (At), which is defined
as in Eq. 8.24.
14
If multiplication commutes, we can change the order of the multiplication, i.e., ab = ba. This
is valid for scalar multiplication. However, matrix multiplication does normally not commute, and
in general AB ̸= BA. It is even possible that AB exists but BA does not.
8.5. SOLUTION OF LINEAR SYSTEMS 493
dx
= Ax + v
dt
where v = Bu. Let (λ, r) be an eigenvalue λ and (right) eigenvector r pair of matrix
A. Then
Ar = λr,
where λ ∈ C is a complex valued scalar, while r ∈ Cnx is a complex valued column
vector of the same dimension as that of the state vector x. It is well known from
mathematics that a real valued matrix A ∈ Rnx ×nx has nx complex eigenvalues λ
with related complex eigenvectors r, and where complex eigenvalues must occur in
so-called complex conjugate pairs.15
We can then write an equation Ari = λi ri for each of the eigenvalues:
By introducing
( )
R, r1 · · · rnx
.
λ1 . . 0
Λ , . . . . . . ... = diag (λ1 , . . . , λnx ) ,
0 · · · λnx
we find that
AR = RΛ.
If matrix R, which has the eigenvectors of A as columns, is invertible/has full
rank, we find that
R−1 AR = Λ,
where Λ is diagonal with the eigenvalues as diagonal elements, ordered in the same
sequence as the columns of R. Under this assumption (invertible R), we say that
15
Complex conjugate eigenvalue pairs means that if λ is an eigenvalue, then λ̄ is also an eigen-
value, where λ̄ is the complex conjugate of λ.
494 CHAPTER 8. MODEL ANALYSIS*
A = RΛR−1 .
z = R−1 x
w = R−1 v,
where x can be expressed as x = Rz. Our differential equation can then be written
as
dz
= Λz + w.
dt
Because Λ is diagonal, we can decompose this vector equation into nx scalar equa-
tions
dz1
= λ1 z1 + w1
dt
..
.
dznx
= λnx znx + wnx .
dt
As found for the scalar, driven system, these scalar equations have the solution
[ ˆ t ]
zi (t) = exp (λi t) zi (0) + exp (−λi τ ) wi (τ ) dτ , (8.26)
0
or in matrix form:
.
exp (λ1 t) . . 0
. . ..
z (t) = .. .. . z (0)
0 · · · exp (λnx t)
. ˆ ...
exp (λ1 t) . . 0 t − exp (λ 1 τ ) 0
. . .. ... ... ..
+ .. .. . . w (τ ) dτ .
0
0 · · · exp (λnx t) 0 · · · − exp (λnx τ )
8.5. SOLUTION OF LINEAR SYSTEMS 495
Next, we define
.
exp (λ1 t) . . 0
..
exp (Λt) , ..
.
..
. . = diag (exp (λ1 t) , . . . , exp (λnx t)) ,
0 · · · exp (λnx t)
(8.27)
such that
( ˆ t )
z (t) = exp (Λt) z (0) + exp (−Λτ ) w (τ ) dt
0
⇕
( ˆ t )
−1 −1 −1
R x (t) = exp (Λt) R x (0) + exp (−Λτ ) R v (τ ) dτ .
0
Finally, by comparing Eq. 8.28 with Eq. 8.25, we see that with invertible (right)
eigenvector matrix R, exp (At) can alternatively be be found as
or with v = Bu:
( ˆ t )
x (t) = exp (At) x (0) + exp (−Aτ ) Bu (τ ) dt . (8.30)
0
Clearly, the power series definition of exp (At) in Eq. 8.24 is still valid, but for
diagonalizable A matrices (i.e., invertible right eigenvector matrix R), we can find
a closed form solution of exp (At) as in Eq. 8.29 where exp (Λt) is as defined in Eq.
8.27.
496 CHAPTER 8. MODEL ANALYSIS*
With R an invertible (right) eigenvector and x = Rz, we have the decoupled system
[ ˆ t ]
zi (t) = exp (λi t) zi (0) + exp (−λi τ ) wi (τ ) dτ , i ∈ {1, . . . , nx } .
0
of the eigenvector
( r)i of λi . Assume for simplicity that we have only two states x,
thus Λ = diag λ, λ̄ and
( )
( ) r1 r̄1
R= r r̄ = .
r2 r̄2
Because eigenvectors are indeterminate in the sense that we have to choose one of
the elements,16 assume for simplicity that we have chosen r1 = r̄1 = 1 and that we
for simplicity denote r2 by r.17 With Bu ≡ 0, we have
where
exp (At) = R exp (Λt) R−1 .
Here
( ( ))
exp (Λt) = diag exp (λt) , exp λ̄t
( )−1 ( )
−1 1 1 1 r̄ −1
R = = .
r r̄ r̄ − r −r 1
Thus,
( )( )( )
1 1 1 exp (λt) 0( ) r̄ −1
exp (At) =
r̄ − r r r̄ 0 exp λ̄t −r 1
⇓
( ( ) )( )
1 exp (λt) exp (λ̄t ) r̄ −1
exp (At) =
r̄ − r r exp (λt) r̄ exp λ̄t −r 1
⇓
( ( ) [ ( )] )
r̄ exp
[ (λt) − r exp λ̄t
( )] − exp (λt)
( ) − exp λ̄t
rr̄ exp (λt) − exp λ̄t r̄ exp λ̄t − r exp (λt)
exp (At) = .
r̄ − r
With complex eigenvalue
λ = α + jβ,
we find
and
( )
exp (λt) − exp λ̄t = exp (αt) [exp (jβt) − exp (−jβt)] .
16
Ar = rλ ⇒ (A − λI) r = 0. Because eigenvalues λ are defined by det (A − λI) = 0, matrix
(A − λI) is singular/not invertible, and we can not find (all elements of) r uniquely.
17
In principle, it is possible that we have to choose r2 due to the structure of matrix A.
498 CHAPTER 8. MODEL ANALYSIS*
In general,
This gives
( )
exp (λt) − exp λ̄t = 2j exp (αt) sin (βt) .
r = γ + jδ,
we have
r̄ = γ − jδ
rr̄ = (γ + jδ) (γ − jδ) = γ 2 + δ 2
r̄ − r = −2jδ.
It follows that
( ( ) [ ( )] )
r̄ exp
[ (λt) − r exp λ̄t
( )] − exp (λt) − exp λ̄t
( )
rr̄ exp (λt) − exp λ̄t −r exp (λt) + r̄ exp λ̄t
exp (At) = (8.31)
r̄ − r
⇓
( )
exp (αt) −γ sin (βt) + δ cos (βt) sin (βt)
exp (At) = . (8.32)
δ − (γ 2 + δ 2 ) sin (βt) γ sin (βt) + δ cos (βt)
It follows that
Here, the terms sin (βt) and cos (βt) are bounded in size, and we see that a
perturbation in xj (0) will stay bounded provided that α ≤ 0.
The conclusion is that this system is stable if α ≤ 0, or in other words that
ℜ (λ) ≤ 0.
8.6. LINEAR SYSTEM ANALYSIS 499
dx
= Ax + Bu
dt
⇓
∗
dx dx dx∗
− = Ax + Bu −
dt dt dt
⇓
dx dx∗
− = Ax + Bu − (Ax∗ + Bu∗ )
dt dt
⇓
dxδ
= Axδ + Buδ .
dt
If we start in the operating point and perturb the initial state x (0) with uδ ≡ 0, we
are back at the autonomous model
dxδ
= Axδ
dt
and the stability condition for the autonomous case with perturbation in the initial
state is identical to that of the non-autonomous case.
If we have a steady input t < 0 : u (t) = u∗ with steady state x∗ , and then change
the input from u∗ to t ≥ 0 : u (t) = u∗ , for a stable system limt→∞ x (t) → x∗ . We can
500 CHAPTER 8. MODEL ANALYSIS*
c = λi zi (0) ,
ziℓ (T ) = 0
⇓
(1 + λi T ) zi (0) = 0
⇓
1 1
T =− = .
λi −λi
8.6. LINEAR SYSTEM ANALYSIS 501
( ) ( )
Figure 8.4: zi (t) = exp − 12 t zi (0) (black, solid) and ziℓ (t) = 1 − 12 t zi (0) (red,
dashed) for zi (0) = 1.
Because we have assumed that λi < 0, it follows that T > 0 and we can also write
1
T = .
|λi |
Since we have nx eigenvalues, we can also conceptually talk about nx time constants
Ti , and thus write
1
Ti = . (8.33)
|λi |
Consider now the situation where we have experimental data of the transient
of “mode” zi (t) approaching zero. We hypothesize that the system is linear, and
that we observe one of the modes (i.e., decoupled quantity zi (t)). How can we
experimentally find the time constant T ?
The two possibilities are:
1. We attempt to draw the tangent of zi (t) at t = 0, and then notice at which
time this tangent crosses zi = 0. The time taken from initial time t = 0
until zi (t) = 0 is the time constant. The difficulty with this method is that
quite often, experimental data are “polluted” by measurement noise, and it
may be difficult to accurately draw the tangent line. Thus there may be some
uncertainty in this estimate of the time constant T .
2. Instead, we can find the steady initial value zi (0). Then we draw a line parallel
to the abscissa axis (time axis), in ordinate position 0.36788 · zi (0). This line
crosses the experimental curve at t = T . Again, there may be some uncertainty
in our estimate of T . However, the uncertainty is probably less than for the
initial tangent method since the uncertainty in the initial value zi (0) will be
dzi (t)
less than the uncertainty in the initial slope dt .
t=0
The two possible experimental methods of finding T indicated above, are really
based on the assumption that the observed experimental data stem from a first
order system. In other words that we observe the single “mode” given by zi (t). In
practice, this is rarely so. In the general, multivariable case the observed output
y = Cx + Du will contain a linear combination of all the modes in the system, hence
every time constant Ti may influence the behavior of the system.
In general, it is very difficult to extract the time constants Ti by visually inspect-
ing experimental data: the transient may even not look like an exponential decay
to zero. In industry, it is quite common to still define the time constant according
to the crossing point between the observed zi (t) and 0.36788 · zi (0). If this is done,
the resulting (single) time constant for the system will be some sort of overall time
constant, and is not necessarily compatible with the definition in Eq. 8.33.
see Section 8.6.1.4. Thus, we are back to the autonomous case, and can find the time
constant. This time, we must remember to consider the tangent ziδ = (1 + λi t) ziδ (0),
and the time constant is given by the time T such that ziδ (T ) = 0. Observe that
this implies the location where the tangent line ziℓ (T ) = zi∗ .
In the illustration and discussion above, it has been assumed that zi (0) and ziδ (0)
are positive. However, it is equally possible that the initial values are negative, and
in that case the time evolution of zi (t) and ziδ (t) approach the new steady state
from below.
where we are interested in the case y (0) = y0 , thus x (0) = C T y0 , and u (t) =
ua H0 (t).18 The characteristic equation of the A matrix is given by det (λI − A) = 0.
Thus,
( ( ) ( ))
1 0 0 1
det (λI − A) = det λ −
0 1 −ω02 −2ζω0
⇓
( )
λ −1
det (λI − A) = det 2 = λ2 + 2ζω0 λ + ω02 .
ω0 λ + 2ζω0
⇓
( 2 2
)
r1 λ + 2ζω0 λ + ω0 = 0.
Because the term λ2 + 2ζω0 λ + ω02 ≡ 0, we can not find r1 , and have to choose it.
For simplicity, let r1 = 1. It follows from the first equation that r2 = r1 λ = λ. Thus,
the eigenvector matrix R is ( )
1 1
R= ,
λ λ̄
and in the “standard form” of Section 8.6.1.3, γ = α and δ = β.
In Eq. 8.32 for exp (At), inserting γ = α and δ = β leads to
( )
exp (αt) −α sin (βt) + β cos (βt) sin (βt)
exp (At) = .
β − (α2 + β 2 ) sin (βt) α sin (βt) + β cos (βt)
The solution x (t) is given by
ˆ t
x (t) = exp (At) x (0) + exp (At) exp (−Aτ ) Bu (τ ) dτ .
0
and
√
ζ sin (βt) + 1 − ζ 2 cos (βt)
y (t) = exp (−ζω0 t) √ y0
1 − ζ2
( √ )
1 − exp (−ζω0 t) √ 1
ζ sin (βt) + 1 − ζ cos (βt)
2
1−ζ 2
+ ua .
ω02
We now utilize the trigonometric angular addition rule
cos ψ = ζ
√
sin ψ = 1 − ζ 2 ?
In conclusion, we have
where
ψ = arccos ζ.
Figure 8.5 compares the solution of the differential equation in Eqs. 8.34–8.35
with the analytic solution for y (t) in Eq. 8.36.
Modelica code for the case study is given below in package LinearOscillator.
The analytic solution is given in a Modelica function. N
0.2
0.0
0.2
0.4
0 20 40 60 80 100
time t [s]
Here,
exp (α (t − τ ))
C exp (A (t − τ )) Bua sin (ωτ ) = sin (β (t − τ )) ua sin (ωτ ) ,
β
and we find
ˆ t
(α2 + β 2 − ω 2 ) sin (ωt) + 2αω cos (ωt)
[C exp (A (t − τ )) Bua sin (ωτ )] dτ = ua
0 (α2 + β 2 + ω 2 )2 − 4β 2 ω 2
ω (α2 − β 2 + ω 2 ) sin (βt) − 2αβ cos (βt)
+ exp (αt) ua
β (α2 + β 2 + ω 2 )2 − 4β 2 ω 2
With
( ) ( )
α2 − β 2 = ζ 2 ω02 − 1 − ζ 2 ω02 = −ω02 1 − 2ζ 2
√
αβ = −ζ 1 − ζ 2 ω02 ,
8.6. LINEAR SYSTEM ANALYSIS 507
we find
(√ )
sin 1 − ζ 2 ω0 t + ψ
y (t) = exp (−ζω0 t) √ y0
1 − ζ2
(ω 2 − ω 2 ) sin (ωt) − 2ζω0 ω cos (ωt)
+ 0 2 2 ua
(ω0 + ω 2 ) − 4 (1 − ζ 2 ) ω02 ω 2
(√ ) √ (√ )
ω exp (−ζω0 t) (ω 2
− ω 2
0 (1 − 2ζ 2
)) sin 1 − ζ 2 ω t + 2ζ
0 1 − ζ 2 ω 2 cos
0 1 − ζ 2ω t
0
+ √ 2 ua .
1 − ζ 2 ω0 (ω02 + ω 2 ) − 4 (1 − ζ 2 ) ω02 ω 2
(8.37)
It is of interest to consider the case of ω → ω0 . This leads to
(√ )
sin 1 − ζ 2 ω0 t + ψ cos (ω0 t)
y (t) = exp (−ζω0 t) √ y0 − ua
1 − ζ2 2ζω02
(√ ) √ (√ )
exp (−ζω0 t) ζ sin 1 − ζ 2ω t +
0 1 − ζ 2 cos 1 − ζ 2ω t
0
+ √ 2
ua . (8.38)
1 − ζ2 2ζω0
With
(√ ) (√ ) (√ )
sin 1 − ζ 2 ω0 t + ψ = sin 1 − ζ 2 ω0 t cos ψ + cos 1 − ζ 2 ω0 t sin ψ
we postulate that
cos ψ = ζ
√
sin ψ = 1 − ζ 2 .
Because ( )
sin2 ψ + cos2 ψ = ζ 2 + 1 − ζ 2 = 1,
we see that this works out, and we choose ψ = arccos ζ. Thus, we have
(√ )
sin 1 − ζ ω0 t + ψ
2
cos (ω0 t)
y (t) = exp (−ζω0 t) √ y0 − ua
1 − ζ2 2ζω02
(√ )
exp (−ζω0 t) sin 1 − ζ ω0 t + ψ
2
+ √ ua .
1 − ζ2 2ζω02
The expression on the second line of the RHS, can be reformulated into
(√ )
cos 1 − ζ 2 ω0 t − exp (ζω0 t) cos (ω0 t)
exp (−ζω0 t) .
2ζω02
For small ζ
(√ ) 1 ( )
cos 1 − ζ ω0 t ≈ cos (ω0 t) + tω0 ζ 2 sin (ω0 t) + O ζ 3
2
2 ( )
exp (ζω0 t) cos (ω0 t) ≈ cos (ω0 t) + tωo ζ cos (ω0 t) + O ζ 2 .
Thus
(√ ) ( )
cos 1 − ζ 2 ω0 t − exp (ζω0 t) cos (ω0 t) ≈ −tω0 ζ cos (ω0 t) + O ζ 2 ,
and we have
√ (√ )
exp (−ζω0 t) 1 − ζ 2 cos 1 − ζ 2ω t
0 cos (ω0 t) t cos (ω0 t) + O (ζ 2 )
√ − = − exp (−ζω 0 t)
1 − ζ2 2ζω02 2ζω02 2ω0
or
√ (√ )
exp (−ζω0 t) 1 − ζ 2 cos 1 − ζ 2 ω0 t cos (ω0 t) t
lim √ 2
− 2
=− cos (ω0 t) .
ζ→0 1−ζ 2 2ζω0 2ζω0 2ω0
0
y
50
100
150
0 100 200 300 400 500 600
time t [s]
Modelica code for the case study is given below in package LinearOscillator.
The analytic solution is given in a Modelica function. N
The Modelica code for the studies of the Linear oscillator are given in package
LinearOscillator in file LinearOscillator.mo:
1 package LinearOscillator
2 // Package for simulating linear oscillator
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // November 10 , 2015
6 / May 15 , 2017
7 //
8 model SimLinear Os c i ll a t or
9 // Simulation of linear oscillator
10 // author : Bernt Lie
11 // University of South - Eastern Norway
12 // November 10 , 2015
13 / May 15 , 2017
14 //
15 // Instantiate model of linear oscillator ( mlo )
16 Mo d LinearOscil l a to r mlo0 , mlo1 ( Zeta =0) , mlo2 ( Zeta =0) ,
mlo3 ( Zeta =0) ;
17 // Declaring variables
18 // -- inputs
19 Real _u0 , _u1 , _u2 , _u3 " Input signal ";
20 parameter Real w [3] = {0.9* mlo0 . w0 , mlo0 . w0 ,1.1* mlo0 . w0 };
510 CHAPTER 8. MODEL ANALYSIS*
21 // -- outputs
22 output Real _y0 , _y1 , _y2 , _y3 " Output ";
23 output Real _y0a , _y1a , _y2a , _y3a " Analytically computed
output ";
24 // Equations
25 equation
26 // -- input values
27 _u0 = 0;
28 _u1 = 0.1* sin ( w [1]* time ) ;
29 _u2 = 0.1* sin ( w [2]* time ) ;
30 _u3 = 0.1* sin ( w [3]* time ) ;
31 // -- injecting input functions to model inputs
32 mlo0 . u = _u0 ;
33 mlo1 . u = _u1 ;
34 mlo2 . u = _u2 ;
35 mlo3 . u = _u3 ;
36 // -- outputs
37 _y0 = mlo0 . x [1];
38 _y1 = mlo1 . x [1];
39 _y2 = mlo2 . x [1];
40 _y3 = mlo3 . x [1];
41 _y0a = A Mo dL in e a r O s c i l l a t o r ( t = time , w0 = mlo0 . w0 , Zeta = mlo0 .
Zeta , y0 =1 , ua =0 , w =0) ;
42 _y1a = AModLi n e a r O s c i l l a t o r ( t = time , w0 = mlo0 . w0 , Zeta = mlo1 .
Zeta , y0 =1 , ua =0.1 , w =0.9* mlo0 . w0 ) ;
43 _y2a = AModLi n e a r O s c i l l a t o r ( t = time , w0 = mlo0 . w0 , Zeta = mlo2 .
Zeta , y0 =1 , ua =0.1 , w = mlo0 . w0 ) ;
44 _y3a = AM od Li n e a r O s c i l l a t o r ( t = time , w0 = mlo0 . w0 , Zeta = mlo3 .
Zeta , y0 =1 , ua =0.1 , w =1.1* mlo0 . w0 ) ;
45 end SimLinearOs c il l a to r ;
46 //
47 model ModLinear Os c i ll a t or
48 // Model of linear oscillator
49 // author : Bernt Lie
50 // University of South - Eastern Norway
51 // November 6 , 2015
52 / May 15 , 2017
53 //
54 // Parameters
55 parameter Real Zeta = 0.3 " Damping factor , -";
56 parameter Real w0 = 0.2 " Natural frequency ";
57 // Initial state parameters
58 parameter Real x0 [2] = {1 ,0};
59 // Declaring variables
60 // -- states
61 Real x [2] " Initial state ";
62 // -- input variables
63 input Real u " Input signal ";
64 // Equations constituting the model
8.6. LINEAR SYSTEM ANALYSIS 511
65 initial equation
66 x = x0 ;
67 equation
68 // Differential equations
69 der ( x ) = { x [2] , - w0 ^2* x [1] - 2* Zeta * w0 * x [2] + u };
70 end Mod Line arOs c il l a to r ;
71 //
72 function AM od Li n e a r O s c i l l a t o r " Analytic solution of linear
oscillator "
73 // Function for computing analytic solution of linear
oscillator
74 // author : Bernt Lie
75 // University of South - Eastern Norway
76 // November 10 , 2015
77 //
78 // Function input arguments
79 input Real t " time , s ";
80 input Real w0 " resonance frequency ";
81 input Real Zeta " damping ";
82 input Real y0 " initial output ";
83 input Real ua " amplitude of input ";
84 input Real w = 0 " excitation frequency ";
85 // Function output response value
86 output Real y ;
87 // Hidden , internal variables
88 protected
89 parameter Real a = - Zeta * w0 ;
90 parameter Real b = sqrt (1 - Zeta ^2) * w0 ;
91 Real y_y0 ;
92 Real y_u ;
93 // Algorithm for computing function value
94 algorithm
95 y_y0 := - exp ( a * t ) *( a * sin ( b * t ) -b * cos ( b * t ) ) * y0 / b ;
96 if w == 0 then
97 y_u := (1 - exp ( a * t ) *( b * cos ( b * t ) -a * sin ( b * t ) ) / b ) /( a ^2+ b ^2)
* ua ;
98 else
99 if ( Zeta == 0) and ( w == w0 ) then
100 y_u := ( sin ( w0 * t ) - w0 * t * cos ( w0 * t ) ) * ua /2/ w0 ^2;
101 else
102 y_u := (( w0 ^2 - w ^2) * sin ( w * t ) + 2* a * w * cos ( w * t ) ) * ua /(( w0
^2+ w ^2) ^2 -4* b ^2* w ^2)
103 + w * exp ( a * t ) / b *(( a ^2 - b ^2+ w ^2) * sin ( b * t ) -2* a * b * cos (
b * t ) ) * ua /(( w0 ^2+ w ^2) ^2 -4* b ^2* w ^2) ;
104 end if ;
105 end if ;
106 y := y_y0 + y_u ;
107 end AM od Li ne ar Os c i l l a t or ;
108 // End package
512 CHAPTER 8. MODEL ANALYSIS*
2. In general, this implies that systems with ∀j : ℜλj < 0, are guaranteed to be
stable for small deviation from the operating point.
dx
= f (x, u)
dt
y = g (x) ,
and that we have a fixed operating point (x∗ , u∗ ) which satisfies the model, i.e., such
that
dx∗
= f (x∗ , u∗ ) = 0.
dt
We can then analyze the stability of the system around the operating point (x∗ , u∗ )
by considering the eigenvalues of the linearized system
dxδ
= Axδ + Bux
dt
y δ = Cxδ .
In other words: if every eigenvalue of the resulting A matrix has a negative real
part, the operating point (x∗ , u∗ ) will be stable. However, if there exist at least
one eigenvalue with a positive real part, then the system will be unstable. If the A
matrix has non negative real part for the eigenvalues (including some with zero real
part), the stability must be analyzed further.
In the same way, we can find transfer functions/matrices for the linearized sys-
tem, and then finding poles, zeros, etc.
Definition 8.4. Zero dynamics. The zero dynamics of the system in Eq. 8.39 is
defined as the internal dynamics when u is chosen such that y ≡ 0, i.e., when
dx
= f (x, z, u; θ)
dt
0 = g (x, z, u; θ)
0 = h (x, z, u; θ) .
We see that this is simply another DAE, where now u plays the role of an algebraic
variable just like z. If nu < ny , it may not be possible to achieve y ≡ 0. Likewise,
if nu > ny , there may inputs u that can not be determined. N
dx
= f (x, u; θ)
dt
y = g (x, u; θ)
dx
= f (x, u; θ)
dt
0 = g (x, u; θ) .
dx
= Ax + Bu
dt
y = Cx + Du
514 CHAPTER 8. MODEL ANALYSIS*
We will here just list seven important results for the Laplace transform.
Theorem 8.1. Laplace transform
1. The Laplace transform is a linear operator, thus with a, b constants and x, u
functions of t:
2. The Laplace transform of dx/dt satisfies
( )
dx ( )
Lt = sX (s) − x t = 0+ ,
dt
where x (t = 0+ ) = limt→0+ x (t), i.e., the limit from the positive side of zero.
If x (t) is discontinuous at t = 0, then x (t = 0+ ) may differ from x (t = 0− ).
3. The Final Value Theorem states that
lim x (t) = lim sX (s) .
t→∞ s→0
( ∂x )
2. For functions of two variables, x (t, z), we have Lt (x (t, z)) = X (s, z), Lt =
( ) dX(s,z) ∂t
sX (s, z) − x (t = 0+ , z) and Lt ∂x∂z
= dz .
The Laplace transform is a linear transformation, see Theorem 8.1 point 1, and is
useful for linear systems.
Example 8.11. Scalar system
We consider the system
dx 1
= −10x − u.
dt 4
Taking the Laplace transform gives
( ) ( )
dx 1
Lt = Lt −10x − u
dt 4
⇕
( ) 1
sX (s) − x t = 0+ = −10X (s) − U (s) .
4
Here, we can find an expression for X (s) as
( ) 1
X (s) (s + 10) = x t = 0+ − U (s)
4
⇕
1 ( ) 1
X (s) = x t = 0+ − U (s) .
s + 10 4 (s + 10)
N
To simplify the notation, we will from now on write Lt (x (t)) = x (s), instead of
Lt (x (t)) = X (s).
Definition 8.6. Zeros, poles. Given a scalar transfer function g (s) = n (s) /d (s),
where n (s) and d (s) are polynomials in s, and n (s) and d (s) do not have any
common factors. The roots of n (s) are denoted the zeros of the transfer function,
while the roots of d (s) are denoted the poles of the transfer function. N
Example 8.13. Poles and zeros of transfer function
For the transfer function Hu (s) in Example 8.10.2, we have Hu (s) = n(s)
d(s)
where
n (s) = −1 and d (s) = 4 (s + 10). We see that the numerator has no roots, @s :
n (s) = 0. Thus, the system doesn’t have any zeros. The poles are found as those s
for which d (s) = 0, i.e.,
d (s) = 0 ⇒ 4 (s + 10) = 0 ⇒ s = −10.
Thus, this transfer function model has pole s = −10. N
It is possible to also introduce the concepts of poles and zeros for transfer matri-
ces, but these definitions are more complex. From Examples 8.10.1 and 8.10.2, we
see that the pole coincides with the eigenvalue of the system. This is no coincidence:
the poles stem from inverting matrix (sI − A):
adj (sI − A)
(sI − A)−1 =
det (sI − A)
where adj (·) denotes the adjugate matrix. Thus, the poles must be roots of det (sI − A),
and det (sI − A) also gives the characteristic polynomial from which the eigenvalues
are computed.
In transfer functions/transfer matrices, numerators and denominators are not
supposed to have any common factors — possible common factors are to be canceled.
This implies that if they do have common factors, these will be canceled. Thus the
poles constitute a subset of the eigenvalues.
It is possible to find transfer functions which are not a fraction of polynomials
in numerator and denominator, see Example 8.16. In that case, the concept of poles
and zeros is more complicated.
d (s)
= s2 + 2ζω0 s + ω02 ,
K
where ω0 is denoted the resonance frequency (rad/time) and ζ is denoted damping
(dimensionless). We see that the relationship between the pair of real part and
imaginary part (α, β), and the pair of resonance frequency and damping (ω0 , ζ) is:
( ) ( ) ( )
ω02=α +β 2 2 ω02 = α2 + β 2 α =√−ζω0
⇔ ζ = √ −α ⇔ .
ζω0 = −α 2
α +β2 β = ω0 1 − ζ 2
It follows that we can write the denominator polynomial in the following standard
form
( ) ( )
1 1 ( )
d (s) = K s + × ··· × s + × s2 + 2ζ1 ω0,1 s + ω0,1
2
× ···
T1 Tnr
( )
· · · × s2 + 2ζnc ω0,nc s + ω0,n
2
c
,
where nr is the number of real poles, and nc is the number of complex conjugate
pole pairs. We see that a real pole/eigenvalue λr,i is given as
1
λr,i = − ,
Ti
Thus, we see that in order for λc,i to have an imaginary part, it is required that
1 − ζi2 > 0, i.e., ζi2 < 1. Further, it follows that the system is stable if ∀i : Ti > 0
and ∀i : ζi > 0.
It can be shown that quantity Ti has dimension time, while quantity ω0,i has
quantity frequency. It is common to denote Ti a time constant when Ti > 0, and
ω0,i a resonance frequency when ζi ∈ [0, 1).
√ √
20
In Mathematics, the notation i , −1. Electrical engineers tend to use j = −1 since i
denotes currency in electrical engineering.
520 CHAPTER 8. MODEL ANALYSIS*
The ideas of time constant, resonance frequency and damping for transfer func-
tions are the same as for the time domain models: the pole polynomial in the transfer
function/“frequency domain” is equal to the characteristic polynomial21 which gives
the eigenvalues in the time domain.
where x ∈ Rnx , u ∈ Rnu , and y ∈ Rny , then Ti and ω0,i in the standard factorization
of the numerator polynomial n (s) are the time constants and resonance frequencies
of the internal dynamics of the DAE system
dx
= Ax + Bu
dt
0 = Cx + Du.
We find the eigenvalues and the eigenvectors of A using, e.g., Python, or analytically:
( ) ( )
−1 3
λ1 = −10, r1 = ; λ2 = 1, r2 = .
1 1
21
Possibly divided by a common factor with the zero polynomial.
8.11. CASES: SOLUTION OF LINEAR MODELS 521
Then ( )
exp (−10t) 0
exp (Λt) = ,
0 exp (t)
and exp (At) is given as
Similarly
To find an explicit time function for x (t), we need to know the function u (t). N
Example 8.15. Diagonalizable system with known input
522 CHAPTER 8. MODEL ANALYSIS*
−5
−10
Figure 8.7: x1 (t) (solid, blue) and x2 (t) (dashed, red) when u (t) = 1 and x (0) =
( )T
1 −1 .
Starting with Example 8.11, let us illustrate the problem further. Assume that
( )T
x (0) = 1 −1 , and let us consider two cases:
1 −10t
e + 43 et − 34 e−10t + 34 et ( ) ˆ t
1 10t
e + 34 e−t
4 1 4
x (t) = + · 1dt
−1
− 41 e−10t + 1 t
4
e 3 −10t
4
e + 1 t
4
e 0 − 14 e10t + 1 −t
4
e
⇕
( −10t
) 1
(1 − 30e−11t + 29e−10t ) e10t
e 40
x (t) = +
−e−10t −11t −10t
1
40
(−1 − 10e + 11e )e 10t
⇕
e−10t + 1
40
(1 − 30e−11t + 29e−10t ) e10t
x (t) = .
−10t −11t −10t
−e + 1
40
(−1 − 10e + 11e )e 10t
1.00 x1
x2
0.75
0.50
0.25
0.00
−0.25
−0.50
−0.75
−1.00
(t)
Figure 8.8: x1 (t) (solid, blue) and x2 (t) (dashed, red) when u (t) = sin and
( )T 10
x (0) = 1 −1 .
( )
Let u (t) = sin 10t . This gives:
1 −10t 3 t
e + 4e − 34 e−10t + 34 et ( ) ˆ t ( 1 10t 3 −t ) ( )
4 1 e + e t
x (t) = + 4 4
1 −t · sin dt
−1 − 1 10t
e + e 10
− 14 e−10t + 41 et 3 −10t
4
e + 1 t
4
e 0 4 4
⇕
( ) ( )
5 t 250 t
x1 (t) = exp (−10t) − exp (10t) cos + exp (10t) sin
20 002 10 10 001 10
( ) ( )
15 t 75 t 75 260
− exp (−10t) cos − exp (−10t) sin +
202 10 101 10 1010 101
( ) ( )
5 t 250 t
x2 (t) = − exp (−10t) + exp (10t) cos − exp (10t) sin
20 002 10 10 001 10
( ) ( )
5 t 25 t 24 750
− exp (−10t) cos − exp (−10t) sin +
202 10 101 10 1010 101
The temporal evolution of x (t) is shown in Fig. 8.8.
The results in 8.8 should be compared to the results in Fig. 8.7 — note the
difference in the ordinate axis scale. N
Example 8.16. Non-diagonalizable system
In the more general case where matrix A can not be diagonalized, we can still
write the solution as
( ˆ t )
x (t) = exp (At) x (0) + exp (−At) Bu (t) dt
0
524 CHAPTER 8. MODEL ANALYSIS*
∑
∞
exp (At) , (At)i . (8.40)
i=0
This is a very general definition. The disadvantage with this definition is that we
in general must let i → ∞. For diagonalizable systems, we can find a closed form
solution where exp (At) is described as in Eq. 8.29. For non-diagonalizable systems,
it is more difficult to find closed forms of the solution.
We consider a model which is developed using Newton’s law:
d2 x F
2
= = u.
dt m
By introducing v = dx/dt, we find the following system in state space form
( ) ( )( ) ( )
d x 0 1 x 0
= + u.
dt v 0 0 v 1
| {z } | {z } | {z }
y A B
Thus ( ) ( )
0 0 1 1
Λ= , R= .
0 0 0 0
Here it is clear that R can not be inverted: rankR = 1 < dim y. We can therefore
not use the expression in Eq. 8.29, and must instead use Eq. 8.40. Thus, we have
that
∑∞
exp (At) = (At)i .
i=0
∑
∞ ∑
1 ( ) ( ) ( )
i i 1 0 0 t 1 t
exp (At) = (At) = (At) = + = .
0 1 0 0 0 1
i=0 i=0
8.11. CASES: SOLUTION OF LINEAR MODELS 525
To find an explicit expression for y (t), we need to know more about the time function
u (t). N
Example 8.17. Non-diagonalizable system with known input
Starting from the system in Example 8.11, let us illustrate the problem further.
( )T
Assume that x (0) = 1 −1 , and let us look at two cases.
Let first u (t) = 1. This gives:
( )( ) ˆ t( )
1 t 1 −t
y (t) = + · 1dt
0 1 −1 0 1
⇕
1−t − 21 t2 1 − t − 12 t2
y (t) = + = .
−1 t −1 + t
(1 ) (1 )
1 − t − 100 sin 10
t + 10t cos 10
t
= (1 )
.
9 − 10 cos 10 t
The temporal evolution of x (t) and v (t) are shown in Fig. 8.10.
The results of Fig. 8.10 should be compared to the results of Fig. 8.9 — note the
difference in scale in the ordinate axis.
Notice that in the general case, exp (At) can not be expressed as simply as in
Examples 8.11. N
526 CHAPTER 8. MODEL ANALYSIS*
−5
−10
−15
0 1 2 3 4 5
t
Figure 8.9: x (t) (solid, blue) and v (t) (dashed, red) when u (t) = 1 and y (0) =
( )T
1 −1 .
−2
−4
−6
x
−8 v
0 1 2 3 4 5
t
(1 )
Figure 8.10: x (t) (solid, blue) and v (t) (dashed, red) when u (t) = sin t and
( )T 10
y (0) = 1 −1 .
8.12. CASES: STABILITY OF LINEAR SYSTEMS 527
d δ
z = −10z1δ ⇔ z1δ (t) = exp (−10t) z1δ (0) .
dt 1
Since limt→∞ exp (−10t) = 0, and since exp (−10t) has a finite numerical value for
all t ≥ 0, we see that we can make z1δ (t) arbitrarily small, t ≥ 0, by choosing z1δ (0)
sufficiently small.
Then, the system is stable according to our definition. N
d δ 1
z2 = z2δ + uδ .
dt 4
By choosing uδ = 0, we have the equation
d δ
z = z2δ ⇔ z2δ (t) = exp (1 · t) z2δ (0) .
dt 2
Because limt→∞ exp (1 · t) → ∞, z2δ (t) will become infinitely large when t increases,
no matter how small a value we pick for z2δ (0).
Then, the system is unstable according to our definition. N
So far, we may suspect from our examples that linear, time invariant systems
are stable around a point if the eigenvalue is negative, and unstable if the eigenvalue
is positive.
Let us study the system in Example 8.11 one more time. The system is given by
7
−4 33 ( )
dx 4
x + 1 u,
=
dt 0
11
− 29 | {z }
| 4
{z 4
} B
A
and the eigenvalues of the system were found to be λ1 = −10 and λ2 = 1, while the
eigenvector matrix R was found to be
( )
−1 3
.
1 1
x = Rx
⇕
( ) ( )( ) ( )
x1 (t) −1 3 z1 (t) −z1 (t) + 3z2 (t)
= = ,
x2 (t) 1 1 z2 (t) z1 (t) + z2 (t)
we see that each of the states (x1 , x2 ) is a combination of a stable state (z1 ) and an
unstable state (z2 ). In total, both of the original states (x1 , x2 ) are thus unstable. N
8.12. CASES: STABILITY OF LINEAR SYSTEMS 529
and this system has two eigenvalues at zero (in the origin). If we choose y ∗ = (0, 0)T
and u∗ = (0) as our operating point, we see that this operating point satisfies the
model. The deviation from the operating point is thus:
( ) ( )
d δ 0 1 δ 0
y = y + uδ ,
dt 0 0 1
with the solution
( ) ˆ t( )( )
δ 1 t δ 1 −t 0
y (t) = y (0) + uδ (t) dt.
0 1 0 0 1 1
By choosing uδ = 0, we see that the solution is
( )
δ 1 t
y (t) = y δ (0)
0 1
⇕
xδ (t) = xδ (0) + t · v δ (0)
v δ (t) = v δ (0) .
530 CHAPTER 8. MODEL ANALYSIS*
dh∗ 1 ( ∗ ′
√ ) √ ṁ∗
=0= ṁi − K h∗ ⇔ h∗ = i′ .
dt ρA K
We then find that the model can be written as
dhδ
= Ahδ + B ṁδi ,
dt
where
∂f (h, ṁi ) ∂f (h, ṁi )
A= = ,
∂h h=h∗ ∂h ∗
ṁi =ṁ∗i
and where ( )
∂f (h, ṁi ) ∂ 1 ( ′
√ ) 1 K′
= ṁi − K h =− √ .
∂h ∂h ρA 2ρA h
Then, we find
1 K′ 1 (K ′ )2
A=− √ =− .
2ρA h∗ 2ρA ṁ∗i
8.13. CASES: ANALYSIS OF NONLINEAR SYSTEMS 531
Thus
0 1 ( )
∂f
0 1
A= = = .
∂x ∗
− gℓ 0
− gm−F
mℓ
cos α 0 ∗
Similarly, we can find an expression for B.
The eigenvalues of A are found as follows
( ( ) ( ))
1 0 0 1
det (sI − A) = 0 ⇔ det s − = 0.
0 1 − gℓ 0
This gives √
s2 ℓ + g g
=0⇔s=± .
ℓ ℓ
Then, the characteristic polynomial is proportional to
g
s2 + = s2 + 2ζω0 s + ω02 .
ℓ
We thus have an oscillating system with (resonance) frequency
√
g
ω0 =
ℓ
and damping
ζ = 0,
which means that we have an undamped oscillating system.
Assume that we instead choose the operating point (α∗ , ω ∗ ) = (π, 0), i.e., the
operating point is that the pendulum hangs with the pendulum pointing downward.
We then find that
0 1 ( )
= 0 1
A= g .
0
− mℓ cos α
gm−F
0 ∗
ℓ
= = fh (x, u)
dt ρA
dT ṁi [ĉp (Ti − T ) − gh] + Q̇′ h
= = fT (x, u) .
dt ρAhĉp
8.13. CASES: ANALYSIS OF NONLINEAR SYSTEMS 533
Here,( we have two ) states: x = (h, T ), and the possibility of 4 input variables:
′
u = ṁi , υ, Ti , Q̇ . We find that
√
∂fh Ke υ ∂fh 1 ∂fh Ke h
=− √ , = , =−
∂h 2ρA hς h ∂ ṁi ρA ∂υ ρA hς
and all the other partial derivatives for fh = 0, while
∂fT Ti − T ∂fT ṁi ∂fT ĉp (Ti − T ) − gh
= −ṁi , = − , = ,
∂h ρAh2 ∂T ρAh ∂ ṁi ρAhĉp
∂fT ṁi ∂fT 1
= , = .
∂Ti ρAh ∂ Q̇′ ρAĉp
If we have a fixed level h∗ as the operating point, the model requires that22
√
∗ ∗ h∗ √
dh ∗ ṁ i − K e υ hς h∗
∗ ∗
0= = ⇒ ṁi = Ke υ .
dt ρA hς
Thus
∂fh Ke υ ∗ ṁ∗i
=− √ =−
∂h ∗ 2ρA hς h∗ 2ρAh∗
√
∂fh Ke h∗ ṁ∗i
= − = − .
∂υ ∗ ρA hς ρAυ ∗
Assume that Ti∗ and Q̇′∗ are given. In order to have constant temperature T ∗ in the
operating point, we must require that T ∗ satisfies
dT ∗ ṁ∗i [ĉp (Ti∗ − T ∗ ) − gh∗ ] + Q̇′∗ h∗ ∗ ∗ ∗ Q̇′∗ h∗
0= = ⇒ ĉp (Ti − T ) − gh = − ∗ .
dt ρAh∗ ĉp ṁi
Thus
∂fT ĉp (Ti∗ − T ∗ ) − gh∗ Q̇′∗
= = − .
∂ ṁi ∗ ρAh∗ ĉp ρAĉp ṁ∗i
We thus find that the model can be written in state space form as the time invariant,
linear system
dxδ
= Axδ + Buδ .
dt
Here A and B are given as
ṁ∗i
− 2ρAh ∗ 0
A=
∗ ∗ ∗
∗ Ti −T ṁi
−ṁi ρAh∗ − ρAh∗
ṁ∗
1
ρA
− ρAυi ∗ 0 0
B= .
′∗ ṁ∗i
− ρAĉQ̇p ṁ∗ 0 ρAh∗
1
ρAĉp
i
22
Of course, assuming that we want to force the operating point to fulfill the model!
534 CHAPTER 8. MODEL ANALYSIS*
Because matrix A is triangular, the eigenvalues are found along the main diagonal
of A: { }
ṁ∗i ṁ∗i ṁ∗i
λ (A) = − , − = {−1, −2} × .
2ρAh∗ ρAh∗ 2ρAh∗
It can be shown that this system is stable according to our definition. N
Example 8.26. Stability of reactor⋆
In Section 7.14.5, a model of a constant volume liquid reactor was reduced to
ODE form as
dcA cA,i V̇ − cA V̇ − arV
=
dt V
dcB −cB V̇ + rV
=
dt ( V ) ( )
• •
dT c A,i V̇ c̃ p,A + ρ V̇ ĉ p,S (Ti − T ) + −∆ r H̃ rV + Q̇
=
dt cA V c̃•p,A + cB V c̃•p,B + ρV ĉ•p,S
where
( )
E
r = k0 exp − caA
RT
( ) ( )
∆r H̃ = H̃B◦ − aH̃A◦ + c̃•p,B − ac̃•p,A (T − T ◦ ) .
| {z }
∆r H̃ ◦
What remains is to insert the values for the operating point. As we see, it begins
to be difficult to analyze the stability when we stick with symbolic expressions. If we
insert numerical values into A, we have a much simpler numeric problem of finding
eigenvalues; the disadvantage is that we then must analyze the stability for each
operating point and for each set of model parameters. N
We find
( )
dx
Lt = Lt (Ax + Bu)
dt
⇕
( )
sx (s) − x t = 0 +
= Ax (s) + Bu (s) .
such that
1 4s+29
4 (s+10)(s−1)
33
4(s+10)(s−1)
( +
) 1 4s+29
4 (s+10)(s−1)
x1 (t = 0 )
x (s) = + u (s) .
11 1 4s+7 x2 (t = 0+ ) 11
4(s+10)(s−1) 4 (s+10)(s−1) 4(s+10)(s−1)
For the system in Example 8.16, we find the transfer function G (s) from input
to state as 1 4s+29
4 (s+10)(s−1)
G (s) = ,
11
4(s+10)(s−1)
while the transfer function from the initial state to the state is
1 4s+29 33
4 (s+10)(s−1) 4(s+10)(s−1)
H (s) = .
11 1 4s+7
4(s+10)(s−1) 4 (s+10)(s−1)
N
538 CHAPTER 8. MODEL ANALYSIS*
where we assume that the initial value is zero. From the Final Value Theorem, we
find
lim y (t) = lim sy (s) .
t→∞ s→0
It can be shown that if u (s) is a unit step function at t = 0, then u (s) = 1s . Then
1 1 1
lim y (t) = lim s K = lim K = K.
t→∞ s→0 1 + T s s s→0 1 + T s
From the Initial Value Theorem, we have
1 1 1
lim+ y (t) = lim sy (s) = lim s K = lim K = 0.
t→0 s→∞ s→∞ 1 + T s s s→∞ 1 + T s
Furthermore, we find the initial slope to be
( )
dy 1 1 s K
lim+ = lim s2 y (s) = lim s2 K = lim K= .
t→0 dt s→∞ s→∞ 1 + T s s s→∞ 1 + T s T
The time domain representation is
1
y (s) = Ku (s)
1 + Ts
⇕
(1 + T s) y (s) = Ku (s)
⇓
dy
T = −y + Ku
dt
⇕
dy 1 K
= − y + u.
dt T T
The solution to this system is
( )( ˆ t ( ) )
t t K
y (t) = exp − y (0) + exp u (t) dt .
T 0 T T
540 CHAPTER 8. MODEL ANALYSIS*
We have already stated that we neglect the initial value, i.e., y (0+ ) = 0. Thus we
find that ( ( ))
t
y (t) = K 1 − exp − .
T
Again, we see that
lim y (t) = 0
t→0
lim y (t) = K
t→∞
( ( )) ( )
dy d t K t K
lim = lim K 1 − exp − = lim exp − = ,
t→0 dt t→0 dt T t→0 T T T
which corresponds with what we deduced directly from the transfer function using
the Final Value and the Initial Value Theorems.
We see that the complete solution is an exponential decay from y (0) = 0 to
y (∞) = K, where the initial slope is K/T . Assuming a linear expansion in time
valid for small t, we have
dy
y (t) ≈ y (0) + t , yℓ (t) .
dt t=0
yℓ (t∞ ) = y (∞)
⇕
dy
y (0) + t∞ = y (∞)
dt t=0
⇕
y (∞) − y (0) K −0
t∞ =
dy
= K = T.
dt t=0 T
Hence
1 4s+29
( ) 4 (s+10)(s−1)
y (s) = Cx (s) = 1 0 u (s) = 1 4s + 29
u (s) .
11 4 (s + 10) (s − 1)
4(s+10)(s−1)
We see that this system has a pole at s = −10, another pole at s = +1, and a zero
at s = − 29
4
.
Let us consider the zero dynamics of the system:
7
−4 33 ( )
dx 4
1
= x+ u
dt 0
11
− 29
( 4 ) 4
y = 1 0 x = 0.
x1 = 0,
dx2 29
= − x2
dt 4
−33
u= x2 .
4
8.17 Review
We have seen how quite general models can be classified as differential algebraic
equations (DAEs), and that mechanistic model development founded on balance
laws typically leads to structured DAEs of form
dx
= f (x, z, u; θ)
dt
0 = g (x, z, u; θ)
dx
= F (x, t; θ) .
dt
In the ODE, the state x may differ from that of the DAE. If F (·) is continuous in t
and Lipschitz continuous in x, then a unique solution exists. A solution may exist
and be unique for more relaxed conditions, too.
We have seen that a system is point stable at an operating point (x∗ , u∗ ) if it is
possible to slightly perturb x (t = 0) away from x∗ in such a way that ∥x (t) − x∗ ∥
is arbitrarily small for all future times t > 0. If ∥x (t) − x∗ ∥ → 0 when t → ∞,
then the system is asymptotically (point) stable, while if the deviation goes to zero
exponentially, it is exponentially point stable. The point stability concepts can be
8.17. REVIEW 543
extended to time varying trajectories (x∗ (t) , u∗ (t)) to the more general Lyapu’nov
stability. For linear, time invariant systems (LTI) systems of form
dx
= Ax + Bu
dt
where the elements of matrix A are constant, these systems are exponentially stable
(and thus automatically asymptotically stable) when ∀i : ℜ (λi ) < 0 where λi is an
eigenvalue of matrix A. The LTI system may also be stable when ∀i : ℜ (λi ) ≤ 0.
For real negative eigenvalues λi , we can define time constants Ti as
1
Ti = .
|λi |
Although general nonlinear DAE models can be solved by numeric simulation,
in general it is not possible to find an analytic solution. However, for LTI systems,
the general solution can be written as
ˆ t
x (t) = exp (At) x (0) + exp (At) exp (−Aτ ) Bu (τ ) dτ
0
where
1 1
exp (At) , I + At + (At)2 + · · · + (At)n + · · · .
2 n!
If A has a non-singular right eigenvector matrix R, then a closed form expression
for exp (At) can be found.
Because nonlinear models can not be solved analytically, one possible approach
is to find a linear approximation for the nonlinear model by truncated Taylor series
expansion, and then analyze the approximation using linear theory.
The zero dynamics of the input-output system
dx
= f (x, z, u; θ)
dt
0 = g (x, z, u; θ)
y = h (x, z, u; θ)
is the internal dynamics of the system when y ≡ 0. The reason why this is referred
to as the internal dynamics, is that because y ≡ 0, the dynamics of the resulting
DAE
dx
= f (x, z, u; θ)
dt
0 = g (x, z, u; θ)
0 = h (x, z, u; θ)
8.18 Exercises*
Simple, repetitive to stress procedures
8.19 Problems
Problem 8.1. [Solution E.26 p. 617] Solution of steady, counter-current heat ex-
changer model.
Consider the linear steady counter-current heat exchanger model in Section 7.9.3,
where ( ) ( )( )
d Tt −αt αt Tt
= .
dx Ts αs −αs Ts
| {z }
A
Find the solutions Tt (x) and Ts (x) with known inputs Tit and Tis . N
Problem 8.2. [Solution E.27 p. 618] Solution of steady, counter-current heat ex-
changer model.
Consider the linear steady counter-current heat exchanger model in Section 7.9.4,
where ( ) ( )( )
d Tt −αt αt Tt
= .
dx Ts −αs αs Ts
| {z }
A
Find the solutions Tt (x) and Ts (x) with known inputs Tit and Tis . N
Problem 8.3. [Solution E.28 p. 619] Analysis of reactor with distributed cooling.
The system that is considered in Problem 7.9 p. 464, can be modeled as follows:
dcA V̇
= (cA,i − cA ) − m · r
dt V ( )
dT V̇ −∆H̃r 1
= (Ti − T ) + r+ Q̇,
dt V ρĉpS ρV ĉpS
8.19. PROBLEMS 545
where
( )
E/R m
r = k0 exp − cA
T
( ( ))
UΩL
Q̇ = V̇c ρc ĉp,c 1 − exp − (Tc,i − T ) .
ρc ĉp,c V̇c
• Use the numerical values and nominal conditions in Table 8.1, and simulate the
system over a period of 8 min using MATLAB. If you choose to use routine
odexeu, you can use a step length of ∆t = 0.01 min.
Table 8.1: Numerical values for parameters and operating points for the model of
Problem 7.9.
Variable Symbol Nominal value
Vessel volume V 100 ℓ
Volumetric feed flow V̇ 100 ℓ/min
Feed concentration cAi 1 mol/ℓ
Feed temperature Ti 350 K
Volumetric coolant flow V̇c 100 ℓ/min
Coolant feed temperature Tc,i 350 K
Densities ρ, ρc 1000 g/ℓ
Specific heat capacities ĉp , ĉp,c 1 cal g−1 K−1
Pre-exponential factor k0 7.2 × 1010 min−1
Activation “temperature” E/R 9.98 × 103 K
Reaction order m 1
Reaction enthalpy −∆H̃r 2.0 × 105 cal mol−1
Heat transfer coefficient UΩL 7 × 105 cal min−1 K−1
Initial value, cA cA (t = 0) 8.235 × 10−2 mol/ℓ
Initial value, T T (t = 0) 441.81 K
Nominal value, V̇c V̇c (t) 100 ℓ/min
• Repeat the simulation, as you decrease V̇c by 10% from the nominal value.
Let the change in V̇c take place at t = 1 min.
• Repeat the simulation, as you increase V̇c by 10% from the nominal value. Let
the change in V̇c take place at t = 1 min.
The system that is considered in Problem 5.1 p. 211, and simulated in Problem 5.2
p. 212, was modeled as follows:
dh 1( c )
= V̇ + V̇i − V̇e
A
dt A i
dcA 1 A 1 ( A )
= V̇ cA,i − V̇ + V̇i cA − kcA
c
dt Ah i Ah i
with algebraic equations
√
A pA − pa
V̇i = Kv,A uc
ρ
√
V̇e = Kv,e uℓ gh
and:
uc = uc,s + Kc (cA,r − cA )
uℓ = uℓ,s + Kℓ (h − hr ) ,
where we chose to put uc,s = 0 and uℓ,s = 0. ( )
With a given operating point specified by states (h∗ , c∗A ) and inputs V̇ic∗ , c∗A,i , p∗A , h∗r , c∗A,r ,
a linear approximation can be written as:
( δ ) ( )( δ )
d h −47.767 −0.44721 h
=
dt cA δ
−0.0043228 −3.7952 δ
cA
c,δ
V̇i
( ) cδA,i
0.1 0 0.00055508 45.496 0.44721 pδ .
+
−0.0002343 0.0010717 0.00052484 0 0.42285 hδ
A
r
cδA,r
• Analyze the stability of the system. (Hint: use the eig function in MAT-
LAB.)
• Find the time constants of the system. What is the time unit of the time
constants?
• Sketch( how the system will ) approach a new steady state after a change in
δ c,δ δ δ δ δ
u = V̇i , cA,i , pA , hr , cA,r . Compare your sketch to the relevant figure in
the solution of Problem 5.2 (Solution E.8 p. 592). N
where:
( )
∆p = u c1 − c2 V̇i2
Ff = cV̇i2
and
u = us + Kp (hr − h) ,
where us was chosen as us = 0. ( ) ( )
With a given operating point specified by states h∗ , V̇i∗ and inputs V̇e∗ , h∗r ,
a linear approximation can be written as:
( δ ) ( )( δ )
d h 0 0.1 h
=
dt V̇i δ −388.59 −42.531 V̇iδ
( )( δ )
−0.1 0 V̇e
+ .
0 388.59 hδr
• Find the time constants of the system. What is the time unit of the time
constants?
• Sketch( how the) system will approach a new steady state after a change in
uδ = V̇eδ , hδr . Compare your sketch to the relevant figure in the solution of
Problem 6.6. N
Problem 8.6. [Solution E.31 p. 624] Stability of heated tank with varying water
level.
The system that is considered in Problem 7.7 p. 462, and simulated in Problem 7.8
p. 463, was modeled as follows:
dh 1 ( )
= V̇i − V̇e
dt A1
dT V̇i Uh πD
≈ (Ti − T ) + (Th − T )
dt A1 h ρĉp A1
where
D2
A1 = A − π
√4
ρgh
V̇e = Kv u .
pa
u = us − Kp (hr − h) ,
dxδ
= Axδ + Buδ ,
dt
where
xδ = (h − h∗ , cA − c∗A ) ∈ R2×1
( )
∗ ∗ ∗ ∗
u = V̇i − V̇i , cA,i − cA,i , pA − pA , hr − hr , cA,r − cA,r ∈ R5×1 ,
δ c c∗
and find the steady state value of the states, i.e., find (h∗ , c∗A ).
• With these numerical values for the operating point, find matrices A and B.
(I.e., insert the numbers into the symbolic expressions found above.)
• Compare your result with the numerical answer given in Problem 8.4. N
The system that is considered in Problem 6.5 p. 338, and simulated in Problem 6.6
p. 339, was modeled as follows:
dh 1( )
= V̇i − V̇e
dt A
dV̇i Ap [ ]
= ∆p · V̇i − Ff
dt mp
where:
( )
∆p = u c1 − c2 V̇i 2
Ff = cV̇i2
and
u = Kp (hr − h) .
( )
• Assume that an operating point with fixed (time invariant) values h∗ , V̇i∗
( )
∗ ∗
and V̇e , hr is given, and find a linear approximation
dxδ
= Axδ + Buδ ,
dt
where
( )
xδ = h − h∗ , V̇i − V̇i∗ ∈ R2×1
( )
uδ = V̇e − V̇e∗ , hr − h∗r ∈ R2×1 ,
• With these numerical values for the operating point, find matrices A and B.
(I.e., insert the numbers into the symbolic expressions found above.)
• Compare your result with the numerical answer given in Problem 8.5. N
Problem 8.9. [Solution E.34 p. 626] Linearization of heated tank with varying
level.
The system that is considered in Problem 7.7 p. 462, and simulated in Problem 7.8
p. 463, was modeled as follows:
dh 1 ( )
= V̇i − V̇e
dt A1
dT V̇i Uh πD
≈ (Ti − T ) + (Th − T )
dt A1 h ρĉp A1
where
D2
A1 = A − π
√4
ρgh
V̇e = Kv u .
pa
u = −Kp (hr − h) .
• Assume
( that an) operating point with fixed (time invariant) values (h∗ , T ∗ ) and
V̇i∗ , h∗r , Ti∗ , Th∗ is given, and find a linear approximation
dxδ
= Axδ + Buδ ,
dt
where
xδ = (h − h∗ , T − T ∗ ) ∈ R2×1
( )
uδ = V̇i − V̇i∗ , h − h∗r , Ti − Ti∗ , Th − Th∗ ∈ R4×1 ,
and find the steady state value of the states, i.e., find (h∗ , T ∗ ).
• With these numerical values for the operating point, find matrices A and B.
(I.e., insert the numbers into the symbolic expressions found above.)
• Compare your result with the numerical answer given in Problem 8.6. N
Chapter 9
Model calibration†*
9.2 Calibration*
• Information/data, DAQ, outlier detection, smoothing, filtering, prediction,
prefiltering.
• Experiment design.
9.3 Review*
...
9.4 Exercises*
Simple, repetitive to stress procedures
9.5 Problems*
Things to think about to give a deeper understanding
551
552 CHAPTER 9. MODEL CALIBRATION† *
Chapter 10
553
554 CHAPTER 10. MODELS IN A WIDER PERSPECTIVE†
mismatch between a theory and empirical data, then the theory is said to be false.
Falsification is, however, not a trivial process: empirical data is marred with
uncertainties and noise. And even if a theory/model is proven false, it may still
be useful: Newton’s laws have been replaced by Einstein’s theory of relativity, but
Newton’s laws are much more used in practice.
why not fit some mathematical function to the data? The same idea applies to
feathers, but obviously, we have to refit the mathematical function to these new
data.
In mathematics, a common procedure is to approximate a mathematical function
f (x) by a so-called linear combination of other functions ϕi (x), as
∑
n
f (x) ≈ ci ϕi (x)
i=1
f (x) ≈ c0 + c1 x + c2 x2 + c3 x3 + · · ·
If we now go back to the idea of fitting a mathematical function to data, our idea
is that f (x) represents reality (e.g., the rock data or the feather data), while we try
to attempt to fit these data to the approximate function. If we choose to fit such
models to experimental data (xj , yj ), a normal way to do this is using Least Squares
model fit, which in the simplest case leads to minimizing the deviation function
V (c) given as
( )2
∑ N ∑
N ∑n
V (c) = (yi − f (xi ))2 = yi − ci ϕi (xi ) .
j=1 j=1 i=1
By minimizing V wrt. c1 ,c2 , etc., this leads to the well known, linear Normal
Equation:
y = Φc
where
y1 c1
y = ... , c = ...
yN cn
while
ϕ1 (x1 ) ϕ2 (x1 ) · · · ϕn (x1 )
ϕ1 (x2 ) ϕ2 (x2 ) · · · ϕn (x2 )
Φ= .. .. ... .. .
. . .
ϕ1 (xN ) ϕ2 (xN ) · · · ϕn (xN )
This Normal equation is trivial to solve using, e.g., Python or MATLAB, and the
result is the coefficients c1 , c2 , ..., cN in the model approximation.
556 CHAPTER 10. MODELS IN A WIDER PERSPECTIVE†
1. Design [off-line]: traditionally, steady state models have been used for de-
sign. However, if a system is operated periodically or experiences large dis-
turbances/upsets, it may be necessary to use a dynamic model for design.
(a) The design itself may be based on some heuristic rules, or on advanced
optimization. In optimization, typically one tunes geometric parameters
(real variables) to achieve the sought after conversion, temperature range,
etc.
(b) In more advanced studies of flow sheet design, pinch methods based on
exergy, etc. may be used to design the sequence of unit operations, the
tree of unit operations in the flow sheet, and maybe also the number
of units: do we need three or five distillation columns? Similarly, it is
possible to do flow sheet design based on optimization. Because in flow
sheet design, some decision parameters will be real numbers (geometry,
etc.) while others will be integers (number of units, number of trays,
etc.), mixed integer (non-) linear programming is used (MI(N)LP).
(c) Because models are not perfect, design studies are often followed by pilot
plant studies, etc.
(d) Typically, only mechanistic models are used for design.
(a) Suppose we have a dynamic model that relates influent flow rate, tem-
perature, and concentration to effluent temperature and concentration of
substances, and that we need to “measure” the concentration of species
A — but we can only measure the temperature T and the concentration
of species B. By using so-called state estimation (Kalman filter, optimal
estimator) or state observer, we can “estimate”/compute the sought con-
centration of species A by combining the sensor signals with the model.
(b) Suppose we have a water-oil-gas separator and want to know the water
level, the oil level, and the thickness of foam between the layers. This
is not trivial to measure. However, suppose we position a number of
pressure sensors along the vertical axis which can easily be measured on-
line. Next, we carry out controlled experiments where we in each case
measure the water level, the oil level and the foam levels — e.g., by a
ruler, etc. Finally, we fit an empirical model that correlates the pressure
measurements to the carefully measured levels. When we have fitted
this empirical model, we can thereafter infer the levels by combining the
pressure levels with the fitted empirical model. We are able to “measure”
the un-measurable levels via a smart sensor.9
(a) Manual feedback control: suppose that the operator goes out into a plant
and inspects the color of the flames in a combustion process. Based on
the observations, the operator returns to the control room and adjusts
the fuel feed. Is this feedback control? Certainly! The color of the flames
9
This is essentially an extension of the idea of the mercury thermometer: obviously, the mercury
thermometer doesn’t show the temperature — it shows the length of a mercury string, and then
someone has already by experiment figured out how the length of the string correlates with the
temperature, and has put temperature marks on the meter.
560 CHAPTER 10. MODELS IN A WIDER PERSPECTIVE†
What will the process of modeling be like in the future? There are several trends
in education that indicate an improved emphasis on computer science in all fields,
and perhaps less emphasize on traditional physics/mathematics. This could indicate
that future modelers will have less background for developing mechanistic models,
unless they specialize on this in a graduate study. Does this imply that the future
of mechanistic models is grim?
Not necessarily: there are many on-going activities on developing advanced com-
puter tools to aid a modeler in modeling of dynamic systems. One example is the
classical process flow sheeting tools such as Aspen Plus and Aspen HYSYS: essen-
tially, the user draws pre-made unit operations from a palette into a canvas, and
connects the various unit operations. Then, the user may choose which substances
flow in a stream, what flow rates, temperatures and pressures, etc. are available.
Finally, the various unit operations may be modified by changing geometrical dimen-
sions, number of trays, filling material, reaction rates, etc. Thermodynamic models
may be selected, etc. In essence, a user may develop advanced/complex models with
relatively little knowledge in physics and mathematics.
Other examples are so-called “equation based” systems such as gPROMS and
tools based on the Modelica language (e.g., OpenModelica). These systems also
contain a large palette of subsystems which can be moved into a canvas, and con-
nected by drawing connections between two units. Just like for traditional systems,
the user can define content of streams, geometry, etc. Again, tools based on the
Modelica language makes it possible to reuse pre-made models, and can be used
without a deep knowledge of physics.
However, equation based systems also makes it relatively easy for specialists to
add their own unit models, and this way to build additional libraries for the system
— in general, equation based systems makes it considerably easier to extend the
system than traditional flow sheeting systems.
There is also a development in equation based systems to develop additional tools
of analysis, e.g., automatic/analytic linearization, automatic generation of sensitiv-
ity equations, support for optimal control, model calibration, etc. The development
of these additional tools makes it realistic to do really advanced analysis and syn-
thesis without having a Ph.D.-degree in advanced control.
Modeling in the future is expected to expand in the direction of supporting ever
larger system models, offering computer science tools for developing unit models,
better support for using “big data” both to assume model complexity and for assess-
ing the statistical quality of a model. More tools for analysis and synthesis will be
developed, in particular tools for large systems. Also, the on-going development in
computers with multi kernels and multiple processors (CPUs), together with more
powerful graphical processors (GPUs) will necessitate development in parallel pro-
cessing.
In summary, although the availability of “big data” and improvements in ma-
chine learning are developing quickly, there is every reason to believe that mecha-
nistic models also will be important in the future, and that computer tools will be
needed and will be developed to support such models. A good background in the
development of mechanistic models is therefore essential also for future engineers:
without this background, you don’t really understand how flow sheeting tools work.
562 CHAPTER 10. MODELS IN A WIDER PERSPECTIVE†
Also, knowledge of modeling of dynamic systems gives a platform for extending flow
sheet tools with your own models. And — perhaps a provocative final maxim: you
don’t really understand a system unless you can model it. Or — a less bombastic
statement could be: if you have formulated a mechanistic model of a system, you
have gained a very good understanding of the system.
Appendix A
Computer simulation∗
563
564 APPENDIX A. COMPUTER SIMULATION∗
Appendix B
Basic differentiation
565
566 APPENDIX B. BASIC DIFFERENTIATION
Proposition B.2. According to the chain rule for differentiation: for scalars x and
v, we find that:
dy (v (x)) dy (v) dv
= .
dx dv dx
More generally, when x belongs to a subset of Rn and v belongs to a subset of Rp ,
we find that
∂y (v (x)) ∑ ∂y (v) ∂vj
p
= .
∂xi j=1
∂vj ∂xi
, ∂x1 · · · ∂x
∂y
= . . .
∂x n
∂ym
∂x1
··· ∂ym
∂xn
∂y (v) ∂y ∂v
= · ,
∂x ∂v ∂x
where · denotes ordinary matrix multiplication.
Often, we write ∂y ∂v
∂v ∂x
instead of ∂y
∂v
· ∂x
∂v
for simplicity, i.e., we drop the matrix
multiplication symbol. But still, matrix multiplication is implied.
If we think of ∂x, ∂y, etc. as column vectors, then we can define:
∂y
∂y = ∂x.
∂x
2
The definition of ∂y/∂x varies in the literature.
B.1. DEFINITIONS AND BASIC RULES 567
∂y
Here, it is implied that matrix multiplication is assumed between ∂x and ∂x; this
is actually the reason why we require ∂x to be a column vector.3 If we have that
y = y (v (x)), it follows from the chain rule that
∂y ∂v
∂y = ∂x.
∂v ∂x
The total differential for the multivariate/multivariable function is given as
∑n
∂y ∑n
∂f (x)
dy = dxi = dxi .
i=1
∂xi i=1
∂xi
If we assume that dx and dy are column vectors, we can write the total differential
as
∂y
dy = dx.
∂x
In the same way as for derivation of mono-variate functions, we can consider
higher order derivatives for multivariate functions.
Proposition B.4. Partial differentiation is a linear operation. Hence, when k1 , k2
are constants (scalars or matrices), we have:
∂ ∂y1 ∂y2
(K1 y1 + K2 y2 ) = K1 + K2 .
∂x ∂x ∂x
Proposition B.5. For a multivariate function y = f (x) where y is a scalar, we
find that ( ) ( )
∂ ∂y ∂ 2y ∂ 2y ∂ ∂y
= = = .
∂xj ∂xi ∂xj ∂xi ∂xi ∂xj ∂xi ∂xj
More generally:
( ) ( )
∂k ∂ ℓy ∂ (k+ℓ) y ∂ (k+ℓ) y ∂ℓ ∂ky
= = = ,
∂xkj ∂xℓi ∂xkj ∂xℓi ∂xℓi ∂xkj ∂xℓi ∂xkj
..
∂xn
, · · · ∂iy
= .. . . .
∂xi ∂x i
1 ∂xi
n . . .
i i
∂ ym
∂xi
· · · ∂∂xyim
1 n
dy ∂y du ∂y dv ∂ (uv) du ∂ (uv) dv du dv
= + = + =v +u .
dx ∂u dx ∂v dx ∂u dx ∂v dx dx dx
Proposition B.8. Consider the case: y (x) = u (x) /v (x) = u (x) · v −1 (x). We then
have:
dy du dv −1
= v −1 +u .
dx dx dx
Here:
dv −1 dv −1 dv dv
= = −v −2 ,
dx dv dx dx
and the result becomes:
dy du dv
= v −1 − uv −2 .
dx dx dx
This expression can be transformed to the standard form:
dy v −1 du − uv −2 dx
dv
v du − u dx
dv
= v2 dx
= dx
.
dx v2 v2
Thermophysical data
569
570 APPENDIX C. THERMOPHYSICAL DATA
Table C.1: Data for selected species. The table shows molar mass M [g/mol], critical
temperature Tc [K], critical pressure pc [bar], molar volume Ṽc , and Pitzer’s acentric
factor ω [dimensionless] Poling et al. (2001).
Substance M Tc pc Ṽc ω
Oxygen, O2 31.999 154.58 50.43 73.37 0.021⋆
Nitrogen, N2 28.014 126.20 33.98 90.10 0.037
Argon, Ar 39.948 150.86 48.98 74.57 −0.002
Carbon monoxide, CO 28.010 132.85 34.94 93.10 0.045
Carbon dioxide, CO2 44.010 304.12 73.74 94.07 0.225
Hydrogen, H2 2.016 33.98 12.93 64.20 −0.217
Water, H2 O 18.015 647.14 220.64 55.95 0.344
Ammonia, NH3 (H3 N) 17.031 405.40 113.53 72.47 0.257
Benzene, C6 H6 78.114 562.05 48.95 256.0 0.210
Toluene, C7 H8 92.141 591.75 41.08 316.0 0.264
Methane, CH4 16.043 190.56 45.99 98.60 0.011
Ethyne (acetylene), C2 H2 26.038 308.30 61.14 112.20 0.189
Ethene, C2 H4 28.054 282.34 50.41 131.10 0.087
Ethane, C2 H6 30.070 305.32 48.72 145.50 0.099
Ethanol, C2 H6 O 46.069 513.92 61.48 167.00 0.649
Propene, C3 H6 42.081 364.90 46.00 184.60 0.142
Propane, C3 H8 44.097 369.83 42.48 200.00 0.152
Butane, C4 H10 58.123 425.12 37.96 255.00 0.200
Iso butane, C4 H10 58.123 407.85 36.40 262.70 0.186
Pentane, C5 H12 72.150 469.70 33.70 311.00 0.252
Iso pentane, C5 H12 72.150 460.39 33.81 308.30 0.229
Heptane, C7 H16 100.204 540.20 27.4 428.00 0.350
Octane, C8 H18 114.231 568.70 24.90 492.00 0.399
C.3. STANDARD STATE MOLAR THERMODYNAMIC QUANTITIES 571
Table C.2: Molar heat capacity for selected substances. The table shows valid
temperature range, and aj for dimensionless molar heat capacity expansion in tem-
∑
perature, c̃Rp = 4j=0 aj T j where c̃Rp is dimensionless. All temperatures (range and
T ) are absolute temperatures in K Poling et al. (2001).
Substance [Tmin , Tmax ] a0 a1 × 103 a2 × 105 a3 × 108 a4 × 1011
Oxygen, O2 [50, 1000] 3.630 −1.794 0.658 −0.601 0.179
Nitrogen, N2 [50, 1000] 3.539 −0.261 0.007 0.157 −0.099
Argon, Ar — 2.5 0.000 0.000 0.000 0.000
Carbon monoxide, CO [50, 1000] 3.912 −3.913 1.182 −1.302 0.515
Carbon dioxide, CO2 [50, 1000] 3.259 1.356 1.502 −2.374 1.056
Hydrogen, H2 [50, 1000] 2.883 3.681 −0.772 0.692 −0.213
Water, H2 O [50, 1000] 4.395 −4.186 1.405 −1.564 0.632
Ammonia, NH3 (H3 N) [50, 1000] 4.238 −4.215 2.041 −2.126 0.761
Benzene, C6 H6 [50, 1000] 3.551 −6.184 14.365 −19.807 8.234
Toluene, C7 H8 [50, 1000] 3.866 3.558 13.356 −18.659 7.690
Methane, CH4 [50, 1000] 4.568 −8.975 3.631 −3.407 1.091
Ethyne (acetylene), C2 H2 [50, 1000] 2.410 10.926 −0.255 −0.790 0.524
Ethene, C2 H4 [50, 1000] 4.221 −8.782 5.795 −6.729 2.511
Ethane, C2 H6 [50, 1000] 4.178 −4.427 5.660 −6.651 2.487
Ethanol, C2 H6 O [50, 1000] 4.396 0.628 5.546 −7.024 2.685
Propene, C3 H6 [50, 1000] 3.834 3.893 4.688 −6.013 2.283
Propane, C3 H8 [50, 1000] 3.847 5.131 6.011 −7.893 3.079
Butane, C4 H10 [200, 1000] 5.547 5.536 8.057 −10.571 4.134
Iso butane, C4 H10 [50, 1000] 3.351 17.883 5.477 −8.099 3.243
Pentane, C5 H12 [200, 1000] 7.554 −0.368 11.846 −14.939 5.753
Iso pentane, C5 H12 [200, 1000] 1.959 38.191 2.434 −5.175 2.165
Heptane, C7 H16 [200, 1000] 9.634 4.156 15.494 −20.066 7.770
Octane, C8 H18 [200, 1000] 10.824 4.983 17.751 −23.137 8.980
572 APPENDIX C. THERMOPHYSICAL DATA
Table C.3: Enthalpy data etc. for selected substances. The table shows molar en-
thalpy of formation ∆H̃f◦ , molar enthalpy of vaporization ∆H̃v◦ , and molar enthalpy
◦
of melting ∆H̃m , all at the standard state of 298.15 K and 1 atm. Furthermore, the
table shows molar liquid volume Ṽℓ at temperature Tℓ Poling et al. (2001). See also
(†) www.airproducts.com/products/Gases/gas-facts/physical-properties. [ 3]
[ kJ ] [ kJ ] [ kJ ]
Substance ∆H̃f◦ mol ∆H̃v◦ mol ◦
∆H̃m mol
Ṽℓ
cm
mol
Tℓ [K]
Oxygen, O2 0.0 6.82 0.44 27.85 90
Nitrogen, N2 0.0 5.58 0.72 34.84 78
Argon, Ar 0.0 6.43 — 29.10 90
Carbon monoxide, CO −110.53 6.04 0.84 34.88 81
Carbon dioxide, CO2 −393.51 — 9.02 57.67† 294.26†
Hydrogen, H2 0.0 0.90 0.12 — —
Water, H2 O −241.81 40.66 6.01 18.07 298.15
Ammonia, NH3 (H3 N) −45.94 23.35 5.66 24.96 239.15
Benzene, C6 H6 82.88 30.72 9.95 89.41 298.15
Toluene, C7 H8 50.17 33.18 6.85 106.87 298.15
Methane, CH4 −74.52 8.17 0.94 35.54 90.68
Ethyne (acetylene), C2 H2 190.92 − 21.28 43.47 203.15
Ethene, C2 H4 52.50 13.53 3.35 51.07 183.15
Ethane, C2 H6 −83.82 14.70 2.86 46.15 90.36
Ethanol, C2 H6 O −234.95 38.56 5.01 58.68 298.15
Propene, C3 H6 20.00 18.42 3 82.30† 294.26†
Propane, C3 H8 −104.68 19.04 3.53 74.87 233.15
Butane, C4 H10 −125.79 22.44 4.66 100.48 298.15
Iso butane, C4 H10 −134.99 21.30 4.61 104.36 298.15
Pentane, C5 H12 −146.76 25.79 8.40 115.22 298.15
Iso pentane, C5 H12 −153.70 24.69 5.16 116.46 298.15
Heptane, C7 H16 −187.80 31.77 14.03 147.47 298.15
Octane, C8 H18 −208.75 34.41 20.65 163.53 298.15
Table C.4: Data taken from Wagman et al. (1982). The units are [H̃] = kJ/mol,
[G̃] = kJ/mol, [S̃] = J/(mol K), [M ] = g/mol, and [c̃p ] = J/(mol K). The data are
given at a pressure of 1 bar, thus not in the standard state.
Species Name Mj ∆f H̃j1 bar ∆f G̃1j bar 1 bar
S̃298,j c̃1p,jbar
(N2 Nitrogen 28.0134 0.0 0.0 191.61 29.125)
NO Nitric oxide 30.0061 90.25 86.55 210.761 29.844
O2 Oxygen 31.9988 0.0 0.0 205.138 29.355
NO2 Nitrogen dioxide 46.0055 33.18 51.31 240.06 37.20
N2 O4 Dinitrogen tetroxide 92.0110 9.16 97.89 304.29 77.28
Appendix D
Solution to Exercises*
• y = x3 :
dy
y = x3 ⇒ = 3 · x3−1 = 3x2 .
dx
• y = x−1 :
dy 1
= −1x−1−1 = −x−2 = − 2 .
dx x
• y = x0.7 :
dy 0.7
= 0.7x0.7−1 = 0.7x−0.3 = 0.3 .
dx x
√
• y= x:
√ dy 1 1 1 1
y= x = x1/2 ⇒ = x1/2−1 = x−1/2 = 1/2 = √ .
dx 2 2 2x 2 x
573
574 APPENDIX D. SOLUTION TO EXERCISES*
• z = (dy/dx): ( )
dz d dy d2 y
= = .
dx dx dx dx2
Solution D.3. Find the partial derivatives ∂z/∂x, ∂z/∂y, ∂ 2 z/∂x2 , ∂ 2 z/∂y 2 and
∂z 2 /∂x∂y when z (x, y) is given as follows:
• z = sin x cos y:
∂z ∂ ∂ (sin x)
= (sin x cos y) = cos y = cos x cos y.
∂x ∂x ∂x
∂z ∂
= (sin x cos y) = − sin x sin y.
∂y ∂y
( )
∂ 2z ∂ ∂z ∂
= = (cos x cos y) = − sin x cos y.
∂x2 ∂x ∂x ∂x
( )
∂ 2z ∂ ∂z ∂
= = (− sin x sin y) = − sin x cos y.
∂y 2 ∂y ∂y ∂y
( )
∂ 2z ∂ ∂z ∂
= = (− sin x sin y) = − cos x sin y.
∂x∂y ∂x ∂y ∂x
( )
∂ 2z ∂ ∂z ∂
= = (cos x cos y) = − cos x sin y.
∂y∂x ∂y ∂x ∂y
Note that ∂ 2 z/∂x∂y ≡ ∂ 2 z/∂y∂x!!
D.2. CHAPTER: MODELS AND MODEL SOLUTION 575
• z = (2x2 + y 2 ) sin x:
∂z ∂ (( 2 ) ) ∂ ( 2 ) ∂ ( 2 ) ∂x2
= 2x + y 2 sin x = 2x sin x + y sin x = 2 sin x +.
∂x ∂x ∂x ∂x ∂x
∂z ∂
= (sin x cos y) = − sin x sin y.
∂y ∂y
( )
∂ 2z ∂ ∂z ∂
= = (cos x cos y) = − sin x cos y.
∂x2 ∂x ∂x ∂x
( )
∂ 2z ∂ ∂z ∂
= = (− sin x sin y) = − sin x cos y.
∂y 2 ∂y ∂y ∂y
( )
∂ 2z ∂ ∂z ∂
= = (− sin x sin y) = − cos x sin y.
∂x∂y ∂x ∂y ∂x
( )
∂ 2z ∂ ∂z ∂
= = (cos x cos y) = − cos x sin y.
∂y∂x ∂y ∂x ∂y
Note that ∂ 2 z/∂x∂y ≡ ∂ 2 z/∂y∂x!!
• z = ln (x + exp y). Let u = x + exp y:
∂z d ln u ∂u 1 ∂u 1
= = = .
∂x du ∂x u ∂x x + exp y
∂z d ln u ∂u 1 ∂u 1
= = = exp y.
∂y du ∂y u ∂y x + exp y
( ) ( )
∂ 2z ∂ 1 d 1 ∂u 1 ∂u 1
= = =− 2 =− .
∂x2 ∂x x + exp y du u ∂x u ∂x (x + exp y)2
( ) ( ) ( )
∂ 2z ∂ 1 ∂ 1 1 ∂ exp y ∂ 1
= exp y = exp y = + exp y
∂y 2 ∂y x + exp y ∂y u u ∂y ∂y u
( ) ( )
1 d 1 ∂u 1 exp y ∂u exp y exp y
= exp y + exp y = exp y − 2 = 1− .
u du u ∂y u u ∂y x + exp y x + exp y
( ) ( ) ( )
∂ 2z ∂ ∂z ∂ 1 ∂ 1 exp y
= = exp y = exp y =− .
∂x∂y ∂x ∂y ∂x x + exp y ∂x x + exp y (x + exp y)2
( ) ( )
∂ 2z ∂ ∂z ∂ 1 1 ∂ exp y
= = =− 2 (x + exp y) = − .
∂y∂x ∂y ∂x ∂y x + exp y (x + exp y) ∂y (x + exp y)2
Note that ∂ 2 z/∂x∂y ≡ ∂ 2 z/∂y∂x!! N
Solution D.4. Consider functions z (x, y) where y is a function of x. Find ∂z/∂x
when:
• z = y 2 , y = sin x:
∂z ∂y 2 ∂y 2 ∂y ∂y
= = = 2y = sin x cos x.
∂x ∂x ∂y ∂x ∂x
∂z ∂y 2 ∂y 2 ∂y ∂y dy
= = = 2y = 2y .
∂x ∂x ∂y ∂x ∂x dx
Here, we have used that since y is a function of the single variable x, then
∂y/∂x = dy/dx.
Solution D.5. Let mass m = ρV where density ρ and volume V both vary with
time t.
dm d dρ dV
= (ρV ) = V +ρ .
dt dt dt dt
N
∂ρ ∂
= − (ρv) ,
∂t ∂x
both density ρ and velocity v are functions of (t, x):
∂ ∂ρ ∂v
(ρv) = v +ρ .
∂x ∂x ∂x
Thus:
∂ρ ∂ ∂ρ ∂v
= − (ρv) = −v −ρ .
∂t ∂x ∂x ∂x
N
r = kc2A ,
( E)
where k = k0 exp − RT and concentration cA and temperature T varies with time,
while k0 , E, and R are constants.
D.2. CHAPTER: MODELS AND MODEL SOLUTION 577
• Find dr/dt:
where
pṼ
z, ,
RT
which defines z, and where also
Ṽ a Ṽ
z= − ,
Ṽ − b Ṽ 2 RT
which is van der Waals equation of state from thermodynamics (the ideal gas law
can be written: z = 1, which means that z = pṼ / (RT ) = 1 ⇔ pṼ = RT ⇔ pV /n =
RT ⇔ pV = nRT ).
• Find an expression for c̃p (specific heat capacity at constant pressure) given
as
∂ H̃
c̃p = .
∂T
p
We start by considering
∂ H̃ ∂ ( ig ) ∂ H̃ ig (T ) ∂
= H̃ (T ) + (z − 1) RT = + ((z − 1) RT )
∂T ∂T ∂T ∂T
∂ H̃ ig (T ) ∂ ∂ (RT ) ∂ H̃ ig (T ) ∂z
= + RT (z − 1) + (z − 1) = + RT + R (z − 1) .
∂T ∂T ∂T ∂T ∂T
so that
∂ H̃ ∂z
= c̃ig
p + RT + R (z − 1) .
∂T ∂T
The difficulty here is that we have two expression for z which are valid simul-
taneously (the definition of z and the van der Waals equation), hence
pṼ Ṽ a Ṽ
= − .
RT Ṽ − b Ṽ 2 RT
( )
Because of this relationship, it follows that p, T, Ṽ are not independent of
each other, and we need to exercise cause when computing ∂z/∂T ! From the
expression above, we find that
RT a
p= − ,
Ṽ − b Ṽ 2
which is in a useful form since we know that we want to keep p constant (that’s
what the subscript in ∂ H̃/∂T means!), i.e., that dp = 0. We find that
p
( ) ( )
∂p ∂p ∂ RT a ∂ RT a
0 = dp = dT + dṼ = − dT + − dṼ
∂T ∂ Ṽ ∂T Ṽ − b Ṽ 2 ∂ Ṽ Ṽ − b Ṽ 2
⇓
R −RT Ṽ 3 + 2aṼ 2 − 4aṼ b + 2ab2
0= dT + ( )2 dṼ
Ṽ − b Ṽ 3 Ṽ − b
⇓
R −RT Ṽ 3 + 2aṼ 2 − 4aṼ b + 2ab2
dT = − ( )2 dṼ .
Ṽ − b Ṽ 3 Ṽ − b
Notice that we should have found the same expression if we instead had written
( )
∂z ∂ Ṽ a Ṽ
= −
∂T p ∂T Ṽ − b Ṽ 2 RT
p
⇓
( )
pṼ Ṽ − b Ṽ 2
c̃p = c̃ig
p +R − R,
RT Ṽ 3 − 2aṼ 2 + 4aṼ b − 2ab2
• Find an expression for c̃v (specific heat capacity at constant volume) given as
∂ Ũ
c̃v = ,
∂T
Ṽ
where
Ũ = H̃ − pṼ .
We thus have that
Ũ = H̃ ig + (z − 1) RT − pṼ .
580 APPENDIX D. SOLUTION TO EXERCISES*
Introducing
( )ig
ig ig
H̃ = Ũ + pṼ = Ũ ig + RT ,
we have
Ũ = Ũ ig + zRT − pṼ ,
where Ũ ig = H̃ ig (T ) − RT = Ũ ig (T ) only depends on T . Next, consider
( )
∂ Ũ ∂ ( ) ig
∂ Ũ (T ) ∂ (zRT ) ∂ pṼ
= Ũ ig (T ) + zRT − pṼ = + −
∂T ∂T ( ) ∂T ∂T ∂T ( )
ig ∂ p Ṽ ig
( ) ∂ pṼ
∂ Ũ (T ) ∂ (zT ) dŨ (T ) ∂z
= +R − = +R z+T − .
∂T ∂T ∂T dT ∂T ∂T
Introducing
ig
∂ Ũ dŨ ig (T )
c̃ig , = .
v
∂T dT
Ṽ
we have
( )
( ) ∂ pṼ
∂ Ũ ∂z
= c̃ig
v +R z +T −
∂T ∂T ∂T
⇓
∂z ∂p
c̃v = c̃ig
v + Rz + RT
− Ṽ .
∂T Ṽ ∂T Ṽ
∂z
Notice that in the expression for ∂T Ṽ
above, we can not choose p, T and, Ṽ
freely! We have to require that for a specifically given constant Ṽ , we have
to relate p and T by p = ṼRT−b
− Ṽa2 ; this is trivial, and we can just as well
eliminate p and write
( )
∂z 1 Ṽ Ṽ a Ṽ a 1
= − + = .
∂T Ṽ T Ṽ − b Ṽ − b Ṽ 2 RT Ṽ RT 2
This result may seem surprising; however it is correct, see, e.g., Kondepudi &
Prigogine (1998) p. 160. N
• y = x3 : ˆ ˆ
1 1
ydx = x3 dx = x3+1 + c = x4 + c.
3+1 4
• y = x−1 : ˆ ˆ
ydx = x−1 dx = ln x + c.
• y = x0.7 :
ˆ ˆ
1 1 1.7
ydx = x0.7 dx = x0.7+1 + c = x + c.
0.7 + 1 1.7
√
• y= x: ˆ ˆ
√ 1 1 2 3
ydx = xdx = 1 x 2 +1 + c = x 2 + c.
2
+1 3
• y = exp (k/x): ( )
ˆ ˆ
k
ydx = exp dx.
x
This is a non-trivial problem to solve. If we define the function Ei (n, x) as:
Ei (n, x) = xn−1 Γ (1 − n, x) ,
582 APPENDIX D. SOLUTION TO EXERCISES*
´ (k)
Figure D.1: Symbolic computation of exp x
dx using the WolframAlpha app.
then using the WolframAlpha1 app gives the solution in Fig. D.2, which is
valid for x > 0.
• y = x3 : [ ]1
ˆ 1
1 1
x dx = x4 + c
3
= .
0 4 x=0 4
• y = x−1 : ˆ 1
dx
0 x
doesn’t exist.
1
The WolframAlpha app is available on various platforms, e.g., Windows 10, iOS for iPad,
Android.
2
Note:
´ introducing a function such as Ei (n, x) is similar to introducing the well known function
ln x = dx x .
D.2. CHAPTER: MODELS AND MODEL SOLUTION 583
• y = x0.7 :
ˆ 1 [ ]1
1 1.7 1
0.7
x dx = x +c = ≈ 0.588 .
0 1.7 x=0 1.7
√
• y= x:
ˆ 1 √ 2
xdx = .
0 3
• y = exp (k/x): too complicated... [the computer algebra system is not able to
find a solution]
• y = sin x: ˆ 1
sin xdx = 1 − cos 1 ≈ 0.459 7.
0
N
Solution D.11. With force F , find the corresponding potential energy P (hint:
F = −dP/dx):
• F = −mg:
ˆ P ˆ x
dP
= −F = mg ⇔ dP = mgdx ⇔ dP = mgdx ⇔ P −P0 = mgx ⇔ P = P0 +mgx.
dx P0 0
• F = −k (x − x0 ):
ˆ P ˆ x
dP = −F dx = k (x − x0 ) dx ⇔ dP = k (x − x0 ) dx
P0 0
⇕
1 1 1 1 1 1
P − P0 = kx2 − kxx0 = kx2 − kxx0 + kx20 − kx20 = k (x0 − x)2 − kx20
2 2 2 2 2 2
⇕
1 1
P = k (x0 − x)2 + P0 − kx20
2 | {z2 }
P̃0
⇕
1
P = k (x0 − x)2 + P̃0 .
2
c̃ig 2 3
p (T ) = c0 + c1 T + c2 T + c3 T :
• Find H̃ ig (T ):
ˆ ˆ ˆ
H̃ ig T T ( )
ig
dH̃ = c̃ig
p (T ) dT ⇔ H̃ − ig
H̃0ig = c0 + c1 T + c2 T 2 + c3 T 3 dT ,
H̃0ig 0 0
where H̃0ig , H̃ ig (T ) . We can compute the integral of c̃ig
p and find:
T =0
ˆ T ( ) 1 1 1
H̃ = ig
H̃0ig + c0 + c1 T + c2 T 2 + c3 T 3 dT = H̃0ig +T c0 + T 2 c1 + T 3 c2 + T 4 c3 .
0 2 3 4
N
Solution D.16. [Exercise 6.2 p. 335] Darcy friction factor for laminar flow.
4τw
fD = .
K ′′′
With Newtonian fluid,
∂v
τw = µ
∂r
where the contact between fluid and wall is at r = R, thus shear stress τw is to be
evaluated at r = R.
With laminar flow velocity profile
( ( r )2 ) ( ( r )2 )
v (r) = vm 1 − = 2 ⟨v⟩ 1 −
R R
it follows that
∂v 2r 8 ⟨v⟩ r
= −2 ⟨v⟩ 2 = −
∂r R D R
which at the wall evaluates to
∂v 8 ⟨v⟩
=− .
∂r r=R D
4τw µ 8⟨v⟩
D 64 64
fD = = 4 = = .
K ′′′ 1
2
ρ ⟨v⟩ 2 ρ⟨v⟩D NRe
µ
Solution D.17. [Exercise 6.3 p. 335] Blasius’ Darcy friction factor for turbulent
flow.
With
( ȳ )1/7
v̄ = k · R̄1/7 ,
R̄
586 APPENDIX D. SOLUTION TO EXERCISES*
ȳ
and setting x = R̄
, we have
ˆ
⟨v⟩ 1
49
= 2 · k · R̄1/7 x1/7 (1 − x) dx = 2 · k · R̄1/7 ,
vτ 0 120
Finally,
√ ( )7/8
8 ⟨v⟩ 98k 1/8 8 1
= = · NRe ⇒ fD = ( )7/4 .
fD vτ 120 · 21/7 98k 1/4
NRe
120·21/7
Solution D.18. [Exercise 6.4 p. 335] Prandtl’s Darcy friction factor for turbulent
flow.
With
1
v̄ = ln (ȳ) + C̄
κ
3 ∂v
Remember: the absolute value of τw = µ ∂r r=R is to be used...
D.6. CHAPTER: ENERGY BALANCE 587
ȳ
and setting x = ,
we have
R̄
ˆ 1[ ] ( )
⟨v⟩ 1 ( ) 2 · ln R̄ + 2κC̄ − 3
=2 ln R̄x + C̄ (1 − x) dx = ,
vτ 0 κ 4κ
see Fig. D.3. √
NRe vτ 8 ⟨v⟩
With R̄ = 2 ⟨v⟩
and fD
= vτ
,we then have
( )
⟨v⟩ 2 · ln N2Re ⟨v⟩
vτ
+ 2κC̄ − 3
=2·
vτ 4κ
⇓
( )
√ 2 · ln NRe √1
2 8
+ 2κC̄ − 3
8 fD
= .
fD 2κ
Finally,
( √ )
√ 2 · ln (10) · log10 NRe √fD
+ 2κC̄ − 3
√ 1 2·2 2
2 2· =
fD 2κ
⇓
( √ )
√ 2 · ln (10) · log NRe √fD
+ 2κC̄ − 3
1 10 2·2 2
= √
fD 2 2 · 2κ
⇓
(
√ √ ) 2ln(10)
√
1 2·2 2 2·2κ 3 −κC̄
= −2 · log10 · 10 2 2·2κ .
2√
√
fD NRe fD
N
Solution to Problems*
... N
... N
... N
...under construction... N
589
590 APPENDIX E. SOLUTION TO PROBLEMS*
and:
uc = uc,s + Kc (cA,r − cA )
uℓ = uℓ,s + Kℓ (h − hr ) .
592 APPENDIX E. SOLUTION TO PROBLEMS*
• With x = [h, cA ]T and u = [V̇ic , cA,r , hr , pa , pA , cA,i ]T , the model can be written
as
dx
= f (x, u) .
dt
This model is in state space form because it consists of two first order ordinary
differential equations.
• For the state space model of the reactor, we need to know the initial value of
the states, i.e., x (0) if the initial time is zero. The concrete meaning of x (0)
is that we have to know
h (t = 0) , cA (t = 0) .
• The following can be a model of a mass hanging in a spring, with shock damper
(see Problem 6.2 p. 336)
dx
=v
dt
dv µ k F
= − v − (x − x0 ) − g + .
dt m m m
d2 x µ dx k F
2
=− − (x − x0 ) − g + .
dt m dt m m
This is a second order ODE (ordinary differential equation), and is hence not
in state space form. N
0.000009
h [m]
0.000008
0.010
0.005
Figure E.1: Result from simulating the model in Problem 5.1. The upper plot shows
level h, and the lower plot shows concentration cA . Notice the (ordinate) scale of
the upper plot — the syntax means 2.10999 and then the ordinate values should be
added after these numbers, i.e., there is virtually no variation.
and:
uc = uc,s + Kc (cA,r − cA )
uℓ = uℓ,s + Kℓ (h − hr )
where it is specified that uc,s = 0 and uℓ,s = 0. The model is solved by running the
Modelica model ModControlledReactor in package SpeciesControlledReactor.
The results are shown in Fig. E.1.
The Modelica code is given in package SpeciesControlledReactor.
1 package S p e c ie s C o n t r o l l e d R e a c t o r
2 // Package for simulating controlled reactor
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // May 15 , 2017
6 //
7 model ModContro l l e d R e a c t o r
8 // Model of controlled reactor , problems for species
balance
9 // author : Bernt Lie
10 // University of South - Eastern Norway
11 // May 15 , 2017
12 //
13 // Constants
14 constant Real g = 9.81 " Acceleration of gravity , m / s2 ";
15 // Parameters
594 APPENDIX E. SOLUTION TO PROBLEMS*
N
E.5. CHAPTER: MOMENTUM BALANCE 595
To be developed. N
• We find:
dE d
= (K + P ) .
dt dt
With constant mass m, we have
( )
dK d 1 2 m dv 2 dv m dv dv
= mv = = 2v = mv
dt dt 2 2 dv dt 2 dt dt
( )
dP d k dx k d (x − x0 )2 d (x − x0 )
= mgx + (x − x0 ) = mg
2
+
dt dt 2 dt 2 d (x − x0 ) dt
dx dx
= mg + k (x − x0 ) = mgv + k (x − x0 ) v.
dt dt
Thus,
dE dv
= mv + mgv + k (x − x0 ) v.
dt dt
Note: this expression for dE/dt results from a mathematical manipulation of
the expression for E; we have not used any physical laws yet (apart from the
expression for E). In particular, we have not taken advantage of the energy
balance yet!
Because the physical law must be valid for any velocity, we can divide by v
and find:
dv
Fd + F = m + mg + k (x − x0 ) .
dt
By rearranging this expression and dividing by m, we find:
dv µ k F
= − v − (x − x0 ) − g + .
dt m m m
So far, the model is not complete — we need to explicitly include the relation-
ship between position x and velocity v:
dx
= v.
dt
The total model is thus:
dx
=v
dt
dv µ k F
= − v − (x − x0 ) − g + .
dt m m m
This model is, in fact, in state space form: a state space model is a set or list
of first order models. The state is the set of quantities that are differentiated
wrt.1 time, i.e the state is (x, v).2 Normally, we denote the state by x, but
that is unfortunate here, because x already denotes position. Thus, let us
denote the state by y: y = (x, v). Similarly, we denote the inputs by u. In the
current case, there is only one input, F . Thus: u = F .3 Finally, we define the
parameters θ as θ = (m, µ, k, x0 , g). Thus, we can write the model as
dy
= f (y, u; θ) ,
dt
where f (·) is a vector of functions: the first element is
f1 (y, u; θ) = y2 = v.
• Suppose we want to find x (t) and/or v (t) for t ∈ [t0 , t1 ]. Before we can
attempt to solve the model, we must know:
1
wrt. = with respect to
2
The definition of state is somewhat more complicated: the state is the minimal current in-
formation needed to find the future. Thus, there is a possibility that the quantities that are
differentiated wrt. time are constrained in some way, and thus do not constitute the minimal set
of information.
3
If gravity g also changes, g can be written as a function of x, g (x).
E.5. CHAPTER: MOMENTUM BALANCE 597
m = ρAh
ṁi = ρV̇i
ṁe = ρV̇e .
Inserting this information into the mass balance and assuming that ρ and A
are constants, leads to
dh 1( )
= V̇i − V̇e .
dt A
2. The mass balance for the pipe is:
dm
= ṁi − ṁe ,
dt
where
m = ρAp L = constant,
thus
ṁi = ṁe .
Furthermore:
ṁi = ρV̇i = ρvi Ap = ρve Ap .
It follows that
The momentum balance for the pipe is:
d
(mv) = ṁi vi − ṁe ve + F .
dt
598 APPENDIX E. SOLUTION TO PROBLEMS*
Here, we have already found that ṁi vi = ṁe ve , and m = constant. Thus, the
momentum balance reduces to Newtons law:
dv
m = F,
dt
where
V̇i
v=
Ap
F = pAp − p0 Ap − Ff
Ff = cV̇i2 .
dV̇i Ap ( ) Ap
= Ap u c1 − c2 V̇i − c V̇i2 .
2
dt m m
Here:
m = ρAp L,
and we can rewrite the model as:
dV̇i 1 ( ) c 2
= Ap u c1 − c2 V̇i2 − V̇ .
dt ρL ρL i
4. Introducing a P controller:
u = us + Kp (hr − h) ,
where
u = us + Kp (hr − h) ,
or we can insert the P controller to get:
dh 1( )
= V̇i − V̇e
dt A
dV̇i 1 ( ) c 2
= Ap (us + Kp (hr − h)) c1 − c2 V̇i −
2
V̇
dt ρL ρL i
The reason why we must require that Kp > 0, is as follows: if the level of
the tank is too low such that hr − h > 0, then making Kp > 0 ensures that
u increases and thus that the pump velocity increases, leading to a higher
pressure difference ∆p across the pump, and thus that V̇i increases. If hr − h
increases, then u and V̇i will increase. This makes sense: if the level in the
tank sinks (i.e., hr − h increases), then we must pump more water from the
dam. N
Solution E.14. [Problem 6.6 p. 339] Simulation of water pump system.
The model from Problem 6.5 can be written as:
dh 1( )
= V̇i − V̇e
dt A
dV̇i Ap
= (Ap ∆p − Ff )
dt mp
where:
( )
∆p = u c1 − c2 V̇i 2
Ff = cV̇i2
and
u = us + Kp (hr − h)
where us = 0. { }
Here, the unit of dV̇i /dt is dV̇i /dt = m3 /h2 . Thus, every term on the right
hand side must have the same unit in order to have consistency.
• The unit of Ap /mp is {Ap /mp } = m2 /tonne. Thus, the force Ff must have
unit { }
dV̇i /dt m3 /h2
{Ff } = = 2 = tonne m h−2 .
{Ap /mp } m /tonne
Although this is a relatively uncommon unit for force, it is a perfectly legal
unit.
Alternatively, we can state that the required unit of c is:
{Ff } tonne m h−2
{c} = { } = 2 = tonne m−5 .
2 3
(m /h)
V̇i
600 APPENDIX E. SOLUTION TO PROBLEMS*
m 10−3 tonne m
2
5 N 5 kg s2 tonne
1
( h)
1 bar = 10 2 = 10 2
= 105 3600
= 100 · 36002 .
m m m2 m h2
We thus need a conversion factor κp from pressure given in bar to pressure
given in tonne m−1 h−2 :
tonne m−1 h−2
κp = 100 · 36002 .
bar
As an example, if we convert c from bar to tonne m−1 h−2 , we have:
h [m] 1.92
1.90
0 1 2 3 4 5
2.0
Vi [m3/h]
1.8
1.6
0 1 2 3 4 5
time t [h]
Figure E.2: Result from simulating the model in Problem 6.5. The upper plot shows
level h, and the lower plot shows the volumetric feed/input flow V̇i .
32 // -- disturbance flow
33 Real Vde " Effluent flow rate , m3 / h ";
34 // -- algebraic variables
35 Real dp " Pump differential presure , bar ";
36 Real Ff " Pipe friction force , N ";
37 // -- control signal
38 Real u " Level control input ";
39 // Equations constituting the model
40 equation
41 // Effluent flow disturbance
42 Vde = if time < 2 then 2 else 2 -0.5;
43 // Controller
44 u = max (0 , us + Kp *( hr - h ) ) ;
45 // Pump differential pressure
46 dp = u *( c1 - c2 * Vdi ^2) ;
47 // Friction force
48 Ff = c * Vdi ^2;
49 // Differential equations
50 der ( h ) = ( Vdi - Vde ) / A ;
51 der ( Vdi ) = Ap *( Ap * dp - Ff ) / mp ;
52 end ModWaterPump ;
53 // End package
54 end MomentumWaterPu mp ;
N
Solution E.15. [Problem 6.7 p. 339] Entrance level/flow from tank to flume.
Solution E.17. [Problem 7.2 p. 461] Constant density liquid molar entropy
With αp Ṽ = 0 and molar heat capacity only depending on temperature, we find
ˆ T
◦ c̃p (T )
S̃ = S̃ + dT.
T◦ T
Again, with constant heat capacity, then
( )
◦ T
S̃ = S̃ + c̃p ln .
T◦
N
Solution E.18. [Problem 7.3 p. 461] Ideal gas molar Gibb’s free energy
To find molar Gibb’s free energy, we use
ˆ T ˆ p
◦
G̃ = G̃ − S̃dT + Ṽ dp.
T◦ p◦
Here, some care must be used. When we integrate over T , we need to keep p fixed.
It follows that
ˆ T ˆ T[ ˆ T ( )]
◦ c̃p (θ) p
S̃dT = S̃ + dθ − R ln ◦ dT
T◦ T◦ T◦ θ p
⇓
ˆ T [ ( )] ˆ T (ˆ T )
◦ p ◦ c̃p (θ)
S̃dT = S̃ − R ln ◦ (T − T ) + dθ dT.
T◦ p T◦ T◦ θ
Likewise, when we integrate of p, we need to keep T fixed. The integral involves
Ṽ = RT , thus
p ˆ p ˆ p ( )
RT p
Ṽ dp = dp = RT ln ◦ .
p◦ p◦ p p
In summary
[ ( ) ]
p
G̃ = G̃ + R ln ◦ − S̃ (T − T ◦ )
◦ ◦
p
ˆ T (ˆ T ) ( )
c̃p (θ) p
− dθ dT + RT ln ◦ .
T◦ T◦ θ p
If the heat capacity is constant, we have
ˆ T ( )
c̃p T
dθ = c̃p ln ,
T◦ θ T◦
and furthermore
ˆ T ( ) [ ( ( ) )]T ( )
T T T
c̃p ln ◦
dT = c̃p T ln ◦
−1 = c̃p T · ln ◦
− c̃p (T − T ◦ ) .
T ◦ T T T◦ T
604 APPENDIX E. SOLUTION TO PROBLEMS*
where S̃ is given as ˆ T
◦ c̃p (T )
S̃ = S̃ + dT
T◦ T
and Ṽ is constant. Thus,
ˆ T[ ˆ T ] ˆ p
◦ ◦ c̃p (θ)
G̃ = G̃ − S̃ + dθ dT + Ṽ dp
T◦ T◦ θ p◦
⇓
ˆ T (ˆ T )
◦ ◦ ◦ c̃p (θ)
G̃ = G̃ − S̃ (T − T ) − dθ dT + Ṽ (p − p◦ ) .
T◦ T◦ θ
With constant heat capacity, we find
ˆ T( ( ))
◦ ◦ ◦ T
G̃ = G̃ − S̃ (T − T ) − c̃p ln ◦
dT + Ṽ (p − p◦ ) ,
T ◦ T
or ( ) ( )
◦ ◦ ◦ T
G̃ = G̃ + c̃p − S̃ (T − T ) − c̃p T · ln + Ṽ (p − p◦ ) .
T◦
N
Solution E.20. [Problem 7.5 p. 461] Singular counter-current heat exchanger.
where
U℘
αt ,
ĉp,t ṁt
U℘
αs , .
ĉp,s ṁs
E.6. CHAPTER: ENERGY BALANCE 605
• What if we start with the expressions valid for αt ̸= αs , and then consider
αs → αt ? For αt ̸= αs , we, e.g., have
( )
t αt 1 − e(αs −αt )Lx Tis + (αt − αs ) e(αs −αt )Lx Tit
Te = .
αt − αs e(αs −αt )Lx
Then we consider the limit as αs → αt . We have:
( )
αt 1 − e(αs −αt )Lx αt L x
lim =
αs →αt αt − αs e(αs −αt )Lx αt Lx + 1
and
(αt − αs ) e(αs −αt )Lx 1
= .
αt − αs e s t x
(α −α )L αt L x + 1
It follows that for αs → αt ,we find
αt Lx Tis + Tit
Tet = .
αt L x + 1
But this expression is exactly the same as what we found when considering
the singular case from the outset!
Similarly, we find
Tis + αt Lx Tit
Tes = ,
αt Lx + 1
and
UAx ( t )
Q̇t2s = Ti − Tis .
1 + αt Lx
It follows that if we assume that αt ̸= αs , the resulting expression “gracefully”
approaches the correct values when αs → αt . In other words, we can use the
expressions valid for αt ̸= αs without experiencing numerical problems if we
happen to have αs → αt ! N
E.6. CHAPTER: ENERGY BALANCE 607
Solution E.21. [Problem 7.6 p. 461] Approximations of the LMTD heat exchanger
approach.
1−
Tes = 2
(αe −αt )Lx
.
1+
αt − αs 2
(αe −αt )Lx
1− 2
• Using the first order Padé approximation, we find for Q̇t2s the result
[ (α −α )L ]
1+ s 2 t x
(α −α )L − 1 (Tit − Tis )
1− s 2 t x
Q̇t2s = UAx [ (α −α )L
] ,
1+ s 2 t x
αs (αs −αt )Lx − αt Lx
1− 2
• When αs → αt , we find
Tit + αt Lx Tis
Tet →
αt L x + 1
T + αt Lx Tit
s
Tes → i
αt L x + 1
UAx ( t )
Q̇t2s → Ti − Tis
1 + αt L x
which are identical to the expressions for the singular case. N
where it is assumed that A and D are independent of h, and that the level h
is well defined (no waves, etc.).
Inserting the expression for ṁe , ṁi , and m into the mass balance leads to
( ( ) ) √
2
d D ρgh
ρ A−π h = ρV̇i − ρKv u .
dt 4 pa
To find a model for the temperature, we need to use the energy balance:
dE
= Ėi − Ėe + Q̇ + Ẇ .
dt
E.6. CHAPTER: ENERGY BALANCE 609
where Ẇf is friction work (“shaft work”) and other work apart from the pressure
work (pa V̇i − pb V̇e ). Introducing enthalpy H = U + pV and Ḣ = U̇ + pV̇ , we can
write the energy balance as
d
(H − pV ) = Ḣi − Ḣo + Q̇ + Ẇf .
dt
Liquids are relatively inelastic, such that for the time scale of interest to the tem-
perature:
d dH
(H − pV ) ≈ .
dt dt
For liquids with a viscosity similar to that of water, Ẇf is negligible (this may not
be the case for syrup, etc.).
We assume
that this is valid for the liquid in question,
i.e., that we can let Ẇf ≪ Q̇. The added heat is assumed to be proportional
to the contact area between the liquid and the heating element, as well as to the
temperature difference between the heating element and the liquid:
Q̇ = Uh πDh (Th − T ) .
H = mĤ
Ḣ = ṁĤ.
Inserting some of these approximations and expressions into the energy balance leads
to:
d ( )
mĤ ≈ ṁi Ĥi − ṁe Ĥ + Q̇
dt
⇓
dĤ dm
m + Ĥ ≈ ṁi Ĥi − ṁe Ĥ + Q̇.
dt dt
Here we have used the ideally stirred tank assumption, which leads to Ĥo = Ĥ. By
inserting the mass balance, we get:
dĤ
m + Ĥ (ṁi − ṁe ) ≈ ṁi Ĥi − ṁe Ĥ + Q̇.
dt
Here, the terms related to mass flow out of the vessel will cancel, and the resulting
balance equation is:
dĤ ( )
m ≈ ṁi Ĥi − Ĥ + Q̇.
dt
610 APPENDIX E. SOLUTION TO PROBLEMS*
Assuming that the liquid is a pure component, we have that Ĥ = Ĥ (T, p) such
that
∂ Ĥ ∂ Ĥ
dĤ = dT + dp.
∂T
|{z} ∂p
ĉp
∂ Ĥ
Normally, |ĉp dT | ≫ ∂p dp, such that
dĤ ≈ ĉp dT .
Furthermore, this gives:
ˆ Ĥi ˆ Ti
Ĥi − Ĥ , dĤ ≈ ĉp dT .
Ĥ T
For relatively small temperature differences (e.g., |Ti − T | ≤ 30 ◦ C), we can assume
that ĉp is approximately constant such that
ˆ Ti
Ĥi − Ĥ ≈ ĉp dT ≈ ĉp (Ti − T ) .
T
Inserting the expressions for dĤ and Ĥi − Ĥ into the balance equations, we get:
dT
mĉp ≈ ṁi ĉp (Ti − T ) + Q̇
dt
⇓
dT ṁi Uh πDh
≈ (Ti − T ) + (Th − T )
dt m mĉp
⇓
dT V̇i Uh πD
≈( 2) (Ti − T ) + ( 2 ) (Th − T ) .
dt A−π 4 h
D
ρĉp A − π D4
The total model is thus:
( √ )
dh 1 ρgh
= V̇i − Kv u
A − π D4
2
dt pa
dT V̇i Uh πD
≈( 2) (Ti − T ) + ( 2 ) (Th − T ) .
dt A−π 4 h
D
ρĉp A − π D4
• The proportional controller (P-controller) has the following form:
u = us − Kp (hr − h) .
When we insert this controller into the model, the model changes to the fol-
lowing expression:
( √ √ )
dh 1 ρgh ρgh
= V̇i − Kv us + Kv Kp (hr − h)
A − π D4
2
dt pa pa
dT V̇i Uh πD
≈( 2) (Ti − T ) + ( 2 ) (Th − T ) .
dt A−π 4 h
D
ρĉp A − π D4
N
E.6. CHAPTER: ENERGY BALANCE 611
nA = cA V
ṅA,i = cA,i V̇
ṅA,e = cA V̇
ṅA,g = rA V ,
where
rA = −mr = −mkcm
A.
Inserting these relationships into the mole balance, and using that V = con-
stant, we find:
d
(cA V ) = cA,i V̇ − cA V̇ − mkcm
AV
dt
⇓
dcA V̇
= (cA,i − cA ) − mkcm
A.
dt V
Here, m is specified, and k is fixed.
• Similarly, we find:
dmS
= ṁS,i − ṁS,e
dt
dnB
= ṅB,i − ṅB,e + ṅB,g .
dt
Here,
ṁS,i ≈ ṁS,e
(but we do not need this information), and
ṅB,g = rB V ,
where
1
rB = −rA = r.
m
We do not need to go into further details about components B and S.
When we allow the temperature T to vary, the reaction constant k is not constant
any more. We then need to find a model of temperature T , and how T interacts
with concentration cA .
612 APPENDIX E. SOLUTION TO PROBLEMS*
• For the energy balance, we assume that E ≈ U and Ė ≈ U̇ , such that we can
write the energy balance as
d
(H − pV ) = Ḣi − Ḣe + Q̇ + Ẇf .
dt
Ẇf ≈ 0.
dH
≈ Ḣi − Ḣe + Q̇
dt
⇓
( )
d ∑ ∑ ∑
nj H̃j ≈ ṅj,i H̃j,i − ṅj,e H̃j + Q̇
dt j j j
⇓
( )
∑ dH̃j dnj ∑ ∑
nj + H̃j ≈ ṅj,i H̃j,i − ṅj,e H̃j + Q̇.
j
dt dt j j
dnj
= ṅj,i − ṅj,e + ṅj,g ,
dt
E.6. CHAPTER: ENERGY BALANCE 613
which gives:
( )
∑ dH̃j ∑ ∑
nj + H̃j (ṅj,i − ṅj,e + ṅj,g ) ≈ ṅj,i H̃j,i − ṅj,e H̃j + Q̇
j
dt j j
⇓
∑ dH̃j ∑
nj ≈− H̃j (ṅj,i − ṅj,e + ṅj,g )
j
dt j
∑ ∑
+ ṅj,i H̃j,i − ṅj,e H̃j + Q̇.
j j
We thus find:
( )
dT V̇ 1 ∑ 1
= (Ti − T ) + − H̃j ṅj,g + Q̇.
dt V ρV ĉp,S j
ρV ĉp,S
∆r H̃ , H̃B − mH̃A .
Thus, we find: ∑
H̃j ṅj,g = V ∆r H̃r,
j
u = us − Kp (hr − h) .
The valve model contains the square root of ρgh/pa . Since the unit of ρgh is
Pa, we have to convert pa from bar to Pa — then the argument of the square root
function is without unit. Since the dimension of Kp is m3 h−1 , u is dimensionless.
Clearly, the unit of V̇i / (A1 h) is h−1 . Likewise, the unit of Uh πD/ (ρĉp A1 ) is:
{ }
Uh πD J K−1 m−2 h−1 · m
= = h−1 ,
ρĉp A1 kg m · J kg K · m
−3 −1 −1 2
so we see that the only unit conversion that is necessary in this case, is changing
the pressure dimension from bar to Pa.
The model is encoded in Modelica modelModHeatedTank, which is wrapped in
package EnergyHeatedTank.
The results are shown in Fig. E.6. Modelica EnergyHeatedTank package is
included below.
1 package EnergyHeatedTank
2 // Package for simulating heated tank with varying liquid
level
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // May 15 , 2017
6 //
7 model ModHeatedTank
8 // Model of heated tank with varying liquid level
9 // author : Bernt Lie
10 // University of South - Eastern Norway
11 // May 15 , 2017
12 //
13 // Constants
14 constant Real g = 9.81 " Acceleration of gravity , m / s2 ";
15 constant Real PI = 3.141592654 " Math constant PI ";
616 APPENDIX E. SOLUTION TO PROBLEMS*
0 2 4 6 8 10 12 14
60
T [ C]
40
0 2 4 6 8 10 12 14
time t [h]
16 // Parameters
17 parameter Real A = 10 " Cross sectional area of vessel , m2
";
18 parameter Real D = 0.5 " Diameter of heat element , m ";
19 parameter Real A1 = A - PI * D ^2/4 " Effective cross sectional
area , m2 ";
20 parameter Real Kv = 1 " Valve constant , m3 / h ";
21 parameter Real rho = 1 e3 " Density of liquid , kg / m3 ";
22 parameter Real kappa_p = 1.01 e5 " Conversion factor , bar
to Pa ";
23 parameter Real pa = 1* kappa_p " Atmospheric pressure , bar
";
24 parameter Real Uh = 3 e3 " Overall heat transfer
coefficient , J /( K . m2 . h ) ";
25 parameter Real cp = 4200 " Specific heat capacity of
liquid , J / kg / K ";
26 parameter Real us = 0 " Fixed controller offset ";
27 parameter Real Kp = 1 " Controller proportional gain , 1/ m
";
28 // Initial state parameters
29 parameter Real h0 = 2 " Initial level , m ";
30 parameter Real T0 = 350 " Initial temperature , K ";
31 // Variables
32 // -- states
33 Real h ( start = h0 , fixed = true ) " Level in tank , m ";
34 Real T ( start = T0 , fixed = true ) " Temperature in tank , K ";
35 // -- reference value
36 Real hr = 2 " Reference value for level , m ";
37 // -- inputs
38 Real Vdi = 50 " Influent volumetric flow , m3 / h ";
E.7. CHAPTER: MODEL ANALYSIS 617
We seek the solutions Tt (x) and Ts (x) with known inputs Tit and Tis .
Provided that αt ̸= αs , the Eigenspace decomposition of matrix A is
( ) ( )( )( )−1
−αt αt 1 − ααst 0 0 1 − ααst
= .
αs −αs 1 1 0 -(αs + αt ) 1 1
It follows that
( ) ( ) ( )
Tt (x) Tt (x = 0) Tt
= exp (Ax) = exp (Ax)
Ts (x) Ts (x = 0) Ts
where
( )( )( )−1
1 − ααst 1 0 1− αt
αs
exp (Ax) =
1 1 0 exp (− (αs + αt )) 1 1
⇓
( )
1 αt e−(αs +αt )x + αs αt − αt e−(αs +αt )x
exp (Ax) = .
αt + αs αs − αs e−(αs +αt )x αt + αs e−(αs +αt )x
618 APPENDIX E. SOLUTION TO PROBLEMS*
We seek the solutions Tt (x) and Ts (x) with known inputs Tit and Tis .
Provided that αt ̸= αs , the Eigenspace decomposition of matrix A is
( ) ( )( )( )−1
−αt αt 1 ααst 0 0 1 ααst
= .
−αs αs 1 1 0 αs − αt 1 1
It follows that
( ) ( ) ( )
Tt (x) Tt (x = 0) Tt
= exp (Ax) = exp (Ax)
Ts (x) Ts (x = 0) Ts
where
( αt
)( )( αt
)−1
1 αs 1 0 1 αs
exp (Ax) =
1 1 0 exp (αs − αt ) 1 1
⇓
( )
1 αt e(αs −αt )x − αs αt − αt e(αs −αt )x
exp (Ax) = .
αt − αs αs e(αs −αt )x − αs αt − αs e(αs −αt )x
From here, it follows that
1 [( (αs −αt )x ) ( ) ]
Tt (x) = αt e − αs Tit + αt − αt e(αs −αt )x Tes
αt − αs
1 [( (αs −αt )x ) ( ) ]
Ts (x) = αs e − αs Tit + αt − αs e(αs −αt )x Tes .
αt − αs
What if αt = αs ? Will the above equations break down? Because exp (αs − αt )
approaches zero faster than αs − αt does, we find that
1 [( (αs −αt )x ) ( ) ]
lim Tt (x) = lim αt e − αs Tit + αt − αt e(αs −αt )x Tes
αt →αs αt →αs αt − αs
1 [ ]
≈ lim (αt − αs ) Tit + (αt − αt ) Tes =
αt →αs αt − αs
N
E.7. CHAPTER: MODEL ANALYSIS 619
165
160
0 1 2 3 4 5 6 7 8
time t [min]
Solution E.28. [Problem 8.3 p. 544] Analysis of reactor with distributed cooling.
dcA V̇
= (cA,i − cA ) − m · r
dt V ( )
dT V̇ −∆ r H̃ 1
= (Ti − T ) + r+ Q̇,
dt V ρĉpS ρV ĉpS
where
( )
E
r = k0 exp − cm
A
RT
( ( ))
UΩL
Q̇ = V̇c ρc ĉp,c 1 − exp − (Tc,i − T )
ρc ĉp,c V̇c
• The results of the nominal simulation are shown in Fig. E.7 with dotted lines.
• The repeated the simulation, when V̇c is decreased by 10% from the nominal
value (V̇c → 0.9V̇c ) after t = 1 min is indicated in Fig. E.7.
• The repeated the simulation, when V̇c is increased by 10% from the nominal
value (V̇c → 1.1V̇c ) after t = 1 min is indicated in Fig. E.7.
620 APPENDIX E. SOLUTION TO PROBLEMS*
0 1 2 3 4 5 6 7 8
150
T [ C]
125 1.13 Vc
1.14 Vc
100
1.15 Vc
0 1 2 3 4 5 6 7 8
time t [min]
Figure E.5: Simulation of cA and T for the reactor, indicating how sensitive the
solution is with regards to V̇c .
The simulations of Fig. E.7 are a clear indication of a nonlinear behavior. If the
reactor had a linear behavior, the simulations found by decreasing and increasing
V̇c by 10% should have been symmetric around the nominal steady state (dotted)
operation. In Fig. E.7, the two cases of increasing/decreasing the operation by 10%,
are clearly non-symmetric.
• It may also be of interest to see how sensitive the solution is with regards to
the change of V̇c . This is also carried out using the simulation experiments
in Modelica model SimReactorHeatExchanger. The results are shown in Fig.
E.5.
The model is defined in the function modex6 in file modex6.m:
1 package A n a l y s i s R e a c t o r H e a t E x c h a n g e r
2 // Package for analysis of reactor with heat exchanger
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // May 15 , 2017
6 //
7 model S i m R e ac t o r H e a t E x c h a n g e r
8 // Simulation of A n a l y s i s R e a c t o r H e a t E x c h a n g e r
9 // author : Bernt Lie
10 // University of South - Eastern Norway
11 // May 15 , 2017
12 //
13 Mo dR e ac t or He a tE x c h a n g e r mcn , mcu , mcd , mcu3 , mcu4 , mcu5 ;
14 Real Vdc_n , Vdc_u , Vdc_d , Vdc_u3 , Vdc_u4 , Vdc_u5 ;
15 Real cA_n , cA_u , cA_d , cA_u3 , cA_u4 , cA_u5 ;
16 Real T_n , T_u , T_d , T_u3 , T_u4 , T_u5 ;
E.7. CHAPTER: MODEL ANALYSIS 621
17 equation
18 Vdc_n = 100;
19 Vdc_u = if time < 1 then Vdc_n else Vdc_n *1.1;
20 Vdc_d = if time < 1 then Vdc_n else Vdc_n *0.9;
21 Vdc_u3 = if time < 1 then Vdc_n else Vdc_n *1.13;
22 Vdc_u4 = if time < 1 then Vdc_n else Vdc_n *1.14;
23 Vdc_u5 = if time < 1 then Vdc_n else Vdc_n *1.15;
24 //
25 mcn . Vdc = Vdc_n ;
26 mcu . Vdc = Vdc_u ;
27 mcd . Vdc = Vdc_d ;
28 mcu3 . Vdc = Vdc_u3 ;
29 mcu4 . Vdc = Vdc_u4 ;
30 mcu5 . Vdc = Vdc_u5 ;
31 //
32 cA_n = mcn . cA ;
33 cA_u = mcu . cA ;
34 cA_d = mcd . cA ;
35 T_n = mcn . T ;
36 T_u = mcu . T ;
37 T_d = mcd . T ;
38 //
39 cA_u3 = mcu3 . cA ;
40 cA_u4 = mcu4 . cA ;
41 cA_u5 = mcu5 . cA ;
42 T_u3 = mcu3 . T ;
43 T_u4 = mcu4 . T ;
44 T_u5 = mcu5 . T ;
45 end S i mR e ac to r H e a t E x c h a n g e r ;
46 //
47 model Mo d Re ac t or H e a t E x c h a n g e r
48 // Model of A n a l y s i s R e a c t o r H e a t E x c h a n g e r
49 // author : Bernt Lie
50 // University of South - Eastern Norway
51 // May 15 , 2017
52 //
53 // Parameters
54 parameter Real V = 100. " Vessel volume , L ";
55 parameter Real rho = 1. e3 " Liquid density , g / L ";
56 parameter Real rhoc = rho " Coolant liquid density , g / L ";
57 parameter Real cp = 1. " Liquid specific heat capacity ,
cal /( g . K ) ";
58 parameter Real cpc = cp " Coolant liquid specific heat
capacity , cal /( g . K ) ";
59 parameter Real k0 = 7.2 e10 " Reaction pre - exponential
factor , 1/ min ";
60 parameter Real EdR = 9.98 e3 " Reaction activation ’
temperature ’ , K ";
61 parameter Real m = 1 " Reaction order , -";
622 APPENDIX E. SOLUTION TO PROBLEMS*
62 parameter Real dHr = -2. e5 " Reaction enthalpy , cal / mol ";
63 parameter Real UOmL = 7. e5 " Heat transfer coefficient ,
cal /( min . K ) ";
64 // Initial state parameters
65 parameter Real cA0 = 8.235 e -2 " Initial concentration , mol
/ L ";
66 parameter Real T0 = 441.81 " Initial temperature , K ";
67 // Variables
68 // -- differential variables
69 Real cA ( start = cA0 , fixed = true ) " Concentration , mol / L ";
70 Real T ( start = T0 , fixed = true ) " Temperature , K ";
71 // -- auxiliary variables
72 Real r " Reaction rate ";
73 Real Qd " Heat rate ";
74 // -- fixed input
75 Real Vd = 100. " Volumetric through - flow , L / min ";
76 Real cAi = 1. " Influent concentration of A , mol / L ";
77 Real Ti = 350. " Influent temperature , K ";
78 Real Tci = 350. " Influent temperature , K ";
79 // External input
80 input Real Vdc " Coolant flow rate , L / min ";
81 // Equations constituting the model
82 equation
83 // Algebraic equations
84 r = k0 * exp ( - EdR / T ) * cA ^ m ;
85 Qd = Vdc * rhoc * cpc *(1 - exp ( - UOmL /( rhoc * cpc * Vdc ) ) ) *( Tci - T ) ;
86 // Differential equations
87 der ( cA ) = Vd *( cAi - cA ) /V - m * r ;
88 der ( T ) = Vd *( Ti - T ) / V + ( - dHr ) * r /( rho * cp ) + Qd /( rho * V * cp ) ;
89 end M o d R e a c to r H e a t E x c h a n g e r ;
90 // End package
91 end A n a l y s i s R e a c t o r H e a t E x c h a n g e r ;
We see that the solution is extremely sensitive of the increase in V̇c for these
values. This further indicates a strongly nonlinear behavior. N
For the model developed in Problem 5.1 p. 211 and simulated in Problem 5.2
p. 212, the following linearized
( model gives an approximation
) of the behavior around
∗ ∗ c∗ ∗ ∗ ∗ ∗
states (h , cA ) and inputs V̇i , cA,i , pA , hr , cA,r :
( ) ( )( )
d hδ −47.767 −0.44721 hδ
=
dt cδA −0.0043228 −3.7952 δ
cA
V̇ic,δ
( ) cδA,i
0.1 0 0.00055508 45.496 0.44721
+ pδA .
−0.0002343 0.0010717 0.00052484 0 0.42285
hδr
cδA,r
E.7. CHAPTER: MODEL ANALYSIS 623
Figure E.6: Simulation result from Problem 5.2 p. 212 for the model from Prob-
lem 5.1 p. 211, with inserted indication of tangent dcdt
A (t)
at t = 0, and steady state
value limt→∞ cA (t) under the assumption of no change in the input variables. The
time constant is found (approximately) as the time from the initial time to the time
of intersection between tangent and steady state value.
From the analysis in Problem 6.6 p. 339, it is clear that the time unit is h.
We see that one time constant has the size of T2 = 0.024 04 h ≈ 1.44 min,
while the other time constant has the value of T1 = 1.070 5 h ≈ 64 min. Here,
the longest time constant is the one of interest, and the time constant of the
system is T ≈ 1.07 h ≈ 64 min.
• Figure E.7 indicates how the exponential decay time evolution of h (t) can
be sketched based on knowing h (0) (actually: h (2)), the steady state value
limt→∞ h (t), and the time constant T . N
Solution E.31. [Problem 8.6 p. 547] Stability of heated tank with varying level.
For the model developed in Problem 7.7 p. 462 and simulated in Problem 7.8 p. 463,
the following linearized
( model gives)an approximation of the behavior around states
∗ ∗
(h , T ) and inputs V̇i∗ , h∗r , Ti∗ , Th∗ :
( ) ( )( )
d hδ −0.26242 0 hδ
=
dt Tδ 0.00071377 −0.16535 Tδ
( ) V̇iδ
0.102 0.17652 0 0 hδ
+ r .
−0.00046266 0 0.16523 0.00011445 Tiδ
Thδ
E.7. CHAPTER: MODEL ANALYSIS 625
Tangent
Figure E.7: Simulation result from Problem 6.6 p. 339 for the model from Prob-
lem 6.5 p. 338, with inserted indication of tangent dh(t)
dt
at “t = 0” — actually at time
t = 2 h, but it is common to refer to the time of step change in the input as time
zero. Also indicated is the steady state value limt→∞ h (t) under the assumption of
no change in the input variable for t > 2 h. The time constant is found (approxi-
mately) as the time from the initial time to the time of intersection between tangent
and steady state value.
626 APPENDIX E. SOLUTION TO PROBLEMS*
• Since the A-matrix is triangular, the eigenvalues are found along the diagonal:
Both eigenvalues are real and negative. The system is then stable wrt. small
perturbations around the chosen operating point.
From the analysis in Problem 7.8 p. 463, it is clear that the time unit is h.
We see that one time constant has the size of T2 ≈ 6 h, while the other time
constant has the value of T1 ≈ 3.8 h. In this case, the time constants are so
close in value, that we can not neglect any of them. One relevant question is
then: can we distinguish both time constants from a model response, or can
we only observe a “mixed”/“averaged” time constant?
• Figure E.8 indicates how the exponential decay time evolution of h (t) can be
sketched based on knowing h (0), the steady state value limt→∞ h (t), and the
time constant T2 ≈ 6 h. Thus, time constant T2 appears to be connected with
the level. At the same time, we see that time constant T1 is not observed
directly in the time evolution of temperature T . Instead, the evolution of
temperature T appears to be composed of more complex time evolutions (a
mixture of terms containing T1 and T2 ).
Figure E.8: Simulation result from Problem 7.8 p. 463 for the model from Prob-
lem 7.7 p. 462, with inserted indication of tangent dh(t)
dt
at t = 0, and steady state
value limt→∞ h (t) under the assumption of no change in the input variables for t > 0.
The time constant is found (approximately) as the time from the initial time to the
time of intersection between tangent and steady state value. For the temperature
response T , the time constants can not be observed so directly.
628 APPENDIX E. SOLUTION TO PROBLEMS*
Bibliography
Ascher, U. & Petzold, L. (1998), Computer Methods for Ordinary Differential Equa-
tions and Differential-Algebraic Equations, SIAM, Philadelphia.
Aylward, G. & Findlay, T. (2002), SI Chemical Data, 5th edn, John Wiley & Sons,
Australia.
Barry, D., Culligan-Hensley, P. & Barry, S. (1995), ‘Real Value of the W -Function’,
ACM Transactions on Mathematical Software 21(2), 161–171.
Barry, D., Parlange, J.-Y., Li, L., Prommer, H., Cunningham, C. & Stagnitti, F.
(2000), ‘Analytical approximations for real values of the Lambert W -function’,
Mathematics and Computers in Simulation 53, 95–103.
Chen, C.-T. (1999), Linear System Theory and Design, third edn, Oxford University
Press, New York.
Coelho, P. M. & Pinho, C. (2007), ‘Consideration about equations for steady state
flow in natural gas pipelines’, Journal of the Brazilian Society of Mechanical Sci-
ences and Engineering 29(3), 262–273. DOI: 10.1590/S1678-58782007000300005.
629
630 BIBLIOGRAPHY
DeCarlo, R., Zak, S. & Drakunov, S. (1996), The Control Handbook (ed: William S.
Levine), CRC Press and IEEE Press, Boca Raton, Florida, chapter 57, pp. 941–
951.
Forero G., L. A. & Velásquez J., J. A. (2013), ‘A modified Patel-Teja cubic equation
of state: Part I — Generalized model for gases and hydrocarbons’, Fluid Phase
Equilibria 342, 8–22.
Forero G., L. A. & Velásquez J., J. A. (2014), ‘A modified Patel-Teja cubic equation
of state. Part II: Parameters for polar substances and its mixtures’, Fluid Phase
Equilibria 364, 75–87.
Geankoplis, C. J. (1993), Transport Processes and Unit Operations, third edn, Pren-
tice Hall, Englewood Cliffs, NJ.
Golub, G. H. & Van Loan, C. F. (2013), Matrix Computations, 4th edn, The Johns
Hopkins University Press, Baltimore. www.press.jhu.edu, ISBN 13: 978-1-4214-
0794-4, ISBN 10: 1-4214-0794-9.
Hoang, H., Galliero, G., Montel, F. & Bickert, J. (2015), ‘Tait equation in the
extended corresponding states framework: Application to liquids and liquid mix-
tures’, Fluid Phase Equilibria 387, 5–11.
Kaggerud, E. & Tosterud, B., eds (1998), Latinsk-Norsk ordbok, fjerde reviderte edn,
J.W. Cappelens Forlag a.s., Oslo, Norway.
Levenspiel, O. (1972), Chemical Reaction Engineering, second edn, John Wiley &
Sons, New York.
Lydersen, A. (1979), Fluid Flow and Heat Transfer, John Wiley & Sons, Chichester.
McKeon, B., Zagarola, M. & Smits, A. (2005), ‘A new friction factor relationship
for fully developed pipe flow’, Journal of Fluid Mechanics 538, 429–443.
Merritt, H. (1967), Hydraulic Control Systems, John Wiley & Sons, New York.
Modell, M. & Reid, R. (1983), Thermodynamics and its Applications, second edn,
Prentice-Hall, Inc., Englewood Cliffs, NJ.
Resnick, R., Halliday, D. & Krane, K. S. (2002), Physics, Vol. One, Fifth edn, John
Wiley & Sons, New York.
632 BIBLIOGRAPHY
Seborg, D. E., Edgar, T. F., Mellichamp, D. A. & Doyle, Frank J., I. (2011), Process
Dynamics and Control, third edition edn, John Wiley & Sons, Hoboken, NJ. ISBN
978-0-470-12867-1.
Smith, J., Van Ness, H. & Abbott, M. (1996), Introduction to Chemical Engineering
Thermodynamics, fifth edn, McGraw-Hill, New York.
Stichlmair, J. G. (2002), Scale-up Engineering, Begell House, Inc., New York. ISBN
1-56700-160-2.
Wagman, D., Evans, W., Parker, V., Schumm, R., Halow, I., Bailey, S., Churney,
K. & Nuttall, R. (1982), ‘The NBS tables of chemical thermodynamic prop-
erties. Selected values for inorganic and C1 and C2 organic substances in si
units’, Journal of Physical and Chemical Reference Data 11. Supplement No.
2. www.nist.gov/data/PDFfiles/jpcrdS2Vol11.pdf.