100% found this document useful (1 vote)
407 views

ModelingOfDynamicSystems PDF

This document provides an introduction to modeling dynamic systems. It discusses key concepts like systems, experiments, models and simulations. It also covers important modeling topics such as quantities and their representation, dimensional analysis, solving different types of models like algebraic equations, ordinary differential equations, and partial differential equations. The document aims to equip readers with the fundamental skills needed for dynamic system modeling.

Uploaded by

Zahid Ronty
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
407 views

ModelingOfDynamicSystems PDF

This document provides an introduction to modeling dynamic systems. It discusses key concepts like systems, experiments, models and simulations. It also covers important modeling topics such as quantities and their representation, dimensional analysis, solving different types of models like algebraic equations, ordinary differential equations, and partial differential equations. The document aims to equip readers with the fundamental skills needed for dynamic system modeling.

Uploaded by

Zahid Ronty
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 666

Modeling of Dynamic Systems

Bernt Lie

Version of August 16, 2019


ii
Contents

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

2 Quantities and their Use 11


2.1 Learning goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2 Quantities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3 Symbols and Operators . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3.1 Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3.2 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.2.1 Differentiation vs flow . . . . . . . . . . . . . . . . . 15
2.3.2.2 Partial derivatives . . . . . . . . . . . . . . . . . . . 16
2.3.2.3 Summation and integration . . . . . . . . . . . . . . 17
2.3.2.4 Mass vs mole basis . . . . . . . . . . . . . . . . . . . 18
2.3.2.5 Complex number operators . . . . . . . . . . . . . . 19
2.3.3 Some standard symbols . . . . . . . . . . . . . . . . . . . . . . 19
2.3.4 Symbols and computer notation . . . . . . . . . . . . . . . . . 20
2.4 Units and Dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.4.1 Units. Dimensions . . . . . . . . . . . . . . . . . . . . . . . . 20
2.4.2 Dimensions and SI Units . . . . . . . . . . . . . . . . . . . . . 22
2.5 Dimensionless Models . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

iii
iv CONTENTS

2.5.1 Why non-dimensional models? . . . . . . . . . . . . . . . . . . 28


2.5.2 Buckingham’s Π-theorem+ . . . . . . . . . . . . . . . . . . . . 30
2.6 Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.8 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

3 Models and Model Solution† 45


3.1 Learning goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.2 Model Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.3 Algebraic Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.3.1 Linear equations . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.3.2 Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.3.3 Nonlinear scalar equations . . . . . . . . . . . . . . . . . . . . 53
3.3.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . 53
3.3.3.2 Successive Substitution . . . . . . . . . . . . . . . . . 53
3.3.3.3 Linear approximation methods . . . . . . . . . . . . 54
3.3.3.4 Other approximation methods . . . . . . . . . . . . . 55
3.3.3.5 Newton’s method . . . . . . . . . . . . . . . . . . . . 56
3.3.3.6 Homotopy Continuation . . . . . . . . . . . . . . . . 57
3.3.4 Systems of nonlinear equations . . . . . . . . . . . . . . . . . 58
3.4 Ordinary Differential Equations . . . . . . . . . . . . . . . . . . . . . 59
3.4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.4.2 The Explicit Euler method . . . . . . . . . . . . . . . . . . . . 60
3.4.3 The Implicit Euler method . . . . . . . . . . . . . . . . . . . . 64
3.4.4 Runge Kutta methods . . . . . . . . . . . . . . . . . . . . . . 65
3.4.4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . 65
3.4.4.2 Second order explicit Runge Kutta method . . . . . 66
3.4.4.3 Fourth order explicit Runge Kutta method . . . . . . 66
3.4.4.4 Solving DAEs . . . . . . . . . . . . . . . . . . . . . . 67
3.4.4.5 Closing comments . . . . . . . . . . . . . . . . . . . 67
3.4.5 Other methods . . . . . . . . . . . . . . . . . . . . . . . . . . 67
3.5 Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
3.5.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
3.5.2 Use of interpolation in solving models . . . . . . . . . . . . . . 68
3.5.3 Basic construction of interpolation functions . . . . . . . . . . 68
3.5.4 General model fitting . . . . . . . . . . . . . . . . . . . . . . . 69
3.6 Partial Differential Equations* . . . . . . . . . . . . . . . . . . . . . . 70
3.6.1 Balance laws and conservation laws . . . . . . . . . . . . . . . 70
3.6.2 Case: scalar advection . . . . . . . . . . . . . . . . . . . . . . 72
3.6.3 Hyperbolic equations and advection+ . . . . . . . . . . . . . . 73
3.6.4 Discretization of balance laws+ . . . . . . . . . . . . . . . . . 74
3.7 Simulation Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
3.7.1 Assignment vs. equation . . . . . . . . . . . . . . . . . . . . . 77
3.7.2 Assignment by example . . . . . . . . . . . . . . . . . . . . . 77
3.7.3 Assignment based model implementation . . . . . . . . . . . . 79
3.7.4 Equation based model implementation . . . . . . . . . . . . . 80
CONTENTS v

3.7.5 Debugging models . . . . . . . . . . . . . . . . . . . . . . . . 81


3.7.6 Scripting of equation based models . . . . . . . . . . . . . . . 81
3.8 Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.10 Problems* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

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

4.10.3 Model summary . . . . . . . . . . . . . . . . . . . . . . . . . . 129


4.10.4 Model simulation . . . . . . . . . . . . . . . . . . . . . . . . . 130
4.11 Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
4.12 Exercises* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
4.13 Problems* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

5 Species balance 139


5.1 Learning goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
5.2 The concept of “species” . . . . . . . . . . . . . . . . . . . . . . . . . 139
5.2.1 Matter with attributes . . . . . . . . . . . . . . . . . . . . . . 139
5.2.2 Species and balance laws . . . . . . . . . . . . . . . . . . . . . 140
5.2.3 Species and substance . . . . . . . . . . . . . . . . . . . . . . 140
5.3 Mass species balance . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
5.4 Elements and Molar mass . . . . . . . . . . . . . . . . . . . . . . . . 143
5.5 Molar species balance . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
5.6 Population balance† . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
5.7 Extensive vs. intensive variables . . . . . . . . . . . . . . . . . . . . . 148
5.8 Equations of State . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
5.9 Rates of generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
5.9.1 Chemical reactions . . . . . . . . . . . . . . . . . . . . . . . . 151
5.9.2 Reaction rates . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
5.9.3 Reaction equilibrium and rate constants . . . . . . . . . . . . 154
5.9.4 Reaction rate vs. generation rate . . . . . . . . . . . . . . . . 155
5.9.5 Homogeneous system . . . . . . . . . . . . . . . . . . . . . . . 155
5.9.6 Reaction invariants and variants+ . . . . . . . . . . . . . . . . 156
5.10 Diffusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
5.10.1 Average velocity in mixtures . . . . . . . . . . . . . . . . . . . 159
5.10.2 Diffusion flux . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
5.10.3 Binary mixtures . . . . . . . . . . . . . . . . . . . . . . . . . . 160
5.10.4 Model of diffusion flux . . . . . . . . . . . . . . . . . . . . . . 161
5.11 Case: Liquid level in tank with two species . . . . . . . . . . . . . . . 162
5.11.1 Model objective . . . . . . . . . . . . . . . . . . . . . . . . . . 162
5.11.2 Model development . . . . . . . . . . . . . . . . . . . . . . . . 163
5.11.3 Model summary . . . . . . . . . . . . . . . . . . . . . . . . . . 165
5.11.4 Model simulation . . . . . . . . . . . . . . . . . . . . . . . . . 165
5.11.5 Alternative states . . . . . . . . . . . . . . . . . . . . . . . . . 170
5.12 Case: Liquid phase, varying volume reaction . . . . . . . . . . . . . . 172
5.12.1 Model objective . . . . . . . . . . . . . . . . . . . . . . . . . . 172
5.12.2 Model development . . . . . . . . . . . . . . . . . . . . . . . . 172
5.12.3 Model summary . . . . . . . . . . . . . . . . . . . . . . . . . . 175
5.12.4 Model simulation . . . . . . . . . . . . . . . . . . . . . . . . . 176
5.12.5 Batch reactor . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
5.12.6 Reaction invariants and reaction variants+ . . . . . . . . . . . 180
5.13 Case: Liquid phase, constant volume reactor . . . . . . . . . . . . . . 183
5.13.1 Model objective . . . . . . . . . . . . . . . . . . . . . . . . . . 183
5.13.2 Model development . . . . . . . . . . . . . . . . . . . . . . . . 183
CONTENTS vii

5.13.3 Model summary . . . . . . . . . . . . . . . . . . . . . . . . . . 185


5.13.4 Model simulation . . . . . . . . . . . . . . . . . . . . . . . . . 187
5.14 Case: Gas phase reactor . . . . . . . . . . . . . . . . . . . . . . . . . 189
5.14.1 Model objective . . . . . . . . . . . . . . . . . . . . . . . . . . 189
5.14.2 Model development . . . . . . . . . . . . . . . . . . . . . . . . 190
5.14.3 Model summary . . . . . . . . . . . . . . . . . . . . . . . . . . 192
5.14.4 Model simulation . . . . . . . . . . . . . . . . . . . . . . . . . 192
5.15 Case: Diffusion of gas in liquid pipe . . . . . . . . . . . . . . . . . . . 196
5.15.1 Model objective . . . . . . . . . . . . . . . . . . . . . . . . . . 196
5.15.2 Model development . . . . . . . . . . . . . . . . . . . . . . . . 197
5.15.3 Model summary . . . . . . . . . . . . . . . . . . . . . . . . . . 202
5.15.4 Model simulation . . . . . . . . . . . . . . . . . . . . . . . . . 204
5.16 Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
5.17 Exercises* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
5.18 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211

6 Momentum balance 215


6.1 Learning goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
6.2 Material description . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
6.2.1 Newton’s law and linear momentum . . . . . . . . . . . . . . . 215
6.2.2 Angular momentum . . . . . . . . . . . . . . . . . . . . . . . 216
6.2.3 Some conservative forces/torques . . . . . . . . . . . . . . . . 219
6.2.4 System decomposition . . . . . . . . . . . . . . . . . . . . . . 220
6.2.5 Mechanical energy balance . . . . . . . . . . . . . . . . . . . . 221
6.2.5.1 Energy and work. Mechanical energy balance . . . . 221
6.2.5.2 Multi-body, one degree of freedom⋆ . . . . . . . . . . 225
6.2.5.3 n degrees of freedom⋆ . . . . . . . . . . . . . . . . . 225
6.2.5.4 Energy balance vs momentum balance⋆ . . . . . . . . 225
6.2.6 Lagrangian mechanics⋆,+ . . . . . . . . . . . . . . . . . . . . . 225
6.2.7 Beams, torsion⋆,+ . . . . . . . . . . . . . . . . . . . . . . . . . 225
6.3 Spatial description . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
6.3.1 Momentum balance . . . . . . . . . . . . . . . . . . . . . . . . 225
6.3.2 Mechanical energy balance . . . . . . . . . . . . . . . . . . . . 226
6.4 Friction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
6.4.1 Friction and pressure drop in filled pipes . . . . . . . . . . . . 228
6.4.1.1 Overview of friction force . . . . . . . . . . . . . . . 228
6.4.1.2 Friction force and friction loss+ . . . . . . . . . . . . 230
6.4.1.3 Fanning friction+ . . . . . . . . . . . . . . . . . . . . 231
6.4.1.4 Friction force and pressure drop+ . . . . . . . . . . . 232
6.4.1.5 Darcy friction+ . . . . . . . . . . . . . . . . . . . . . 232
6.4.1.6 Smooth pipe friction factors+ . . . . . . . . . . . . . 233
6.4.1.7 Rough pipes and the Colebrook relation+ . . . . . . 235
6.4.1.8 Solution of Colebrook’s relation by iteration+ . . . . 236
6.4.1.9 Approximations to Colebrook’s relation+ . . . . . . . 237
6.4.1.10 Colebrook’s relation and the Lambert W function+ . 238
6.4.1.11 Global friction factor models+ . . . . . . . . . . . . . 243
viii CONTENTS

6.4.2 Pressure drop due to constrictions, etc. . . . . . . . . . . . . . 244


6.4.3 Liquid friction in open channel+ . . . . . . . . . . . . . . . . . 244
6.4.4 Power consumption in agitated liquid tanks . . . . . . . . . . 249
6.5 Compressible fluid. Elasticity of walls⋆ . . . . . . . . . . . . . . . . . 249
6.6 Hydraulics and Servo Control+ . . . . . . . . . . . . . . . . . . . . . 251
6.6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
6.6.2 Fluid properties . . . . . . . . . . . . . . . . . . . . . . . . . . 251
6.6.3 Flow through orifices . . . . . . . . . . . . . . . . . . . . . . . 255
6.6.4 Valve and Servo system . . . . . . . . . . . . . . . . . . . . . 259
6.6.4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . 259
6.6.4.2 Servo valve . . . . . . . . . . . . . . . . . . . . . . . 259
6.6.4.3 Piston . . . . . . . . . . . . . . . . . . . . . . . . . . 261
6.6.4.4 Solenoid . . . . . . . . . . . . . . . . . . . . . . . . . 263
6.6.4.5 Complete servo system . . . . . . . . . . . . . . . . . 267
6.6.5 Servo control design . . . . . . . . . . . . . . . . . . . . . . . 269
6.6.5.1 Overview of model . . . . . . . . . . . . . . . . . . . 269
6.6.5.2 Linearized model . . . . . . . . . . . . . . . . . . . . 269
6.6.5.3 Basic system analysis . . . . . . . . . . . . . . . . . 273
6.6.5.4 Decoupling control design . . . . . . . . . . . . . . . 273
6.6.5.5 Closed loop approximation . . . . . . . . . . . . . . . 276
6.6.6 Servo system nonlinearities . . . . . . . . . . . . . . . . . . . . 276
6.7 Turbo machines+,∗ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
6.7.1 Turbines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
6.7.2 Mechanistic hydro turbine models* . . . . . . . . . . . . . . . 279
6.8 Cases: Material description⋆ . . . . . . . . . . . . . . . . . . . . . . . 305
6.8.1 “Car” with mass and shock-dampers⋆ . . . . . . . . . . . . . . 305
6.8.2 Two rotational masses w/ turbine⋆ . . . . . . . . . . . . . . . 306
6.8.3 Particle feeder⋆ . . . . . . . . . . . . . . . . . . . . . . . . . . 306
6.8.4 Elastic beam⋆,+ . . . . . . . . . . . . . . . . . . . . . . . . . . 306
6.9 Case: Incompressible liquid pipe flow . . . . . . . . . . . . . . . . . . 306
6.9.1 Model objective . . . . . . . . . . . . . . . . . . . . . . . . . . 306
6.9.2 Model development . . . . . . . . . . . . . . . . . . . . . . . . 307
6.9.3 Model summary . . . . . . . . . . . . . . . . . . . . . . . . . . 309
6.9.4 Model simulation . . . . . . . . . . . . . . . . . . . . . . . . . 310
6.10 Case: Two tanks with basin and pump . . . . . . . . . . . . . . . . . 314
6.10.1 Model objective . . . . . . . . . . . . . . . . . . . . . . . . . . 314
6.10.2 Model development . . . . . . . . . . . . . . . . . . . . . . . . 316
6.10.3 Model summary . . . . . . . . . . . . . . . . . . . . . . . . . . 318
6.10.4 Model simulation . . . . . . . . . . . . . . . . . . . . . . . . . 320
6.11 Case: Gas pipeline⋆,+ . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
6.11.1 Model objective . . . . . . . . . . . . . . . . . . . . . . . . . . 325
6.11.2 Model development . . . . . . . . . . . . . . . . . . . . . . . . 326
6.11.3 Model summary . . . . . . . . . . . . . . . . . . . . . . . . . . 332
6.11.4 Model analysis . . . . . . . . . . . . . . . . . . . . . . . . . . 332
6.12 Case: Under-balanced drilling⋆ . . . . . . . . . . . . . . . . . . . . . . 333
6.13 Case: Penstock with compressible water/elastic wall⋆,+ . . . . . . . . 333
CONTENTS ix

6.14 Case: Open channel flow⋆,+ . . . . . . . . . . . . . . . . . . . . . . . 333


6.15 Concluding comments . . . . . . . . . . . . . . . . . . . . . . . . . . 333
6.16 Review* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
6.17 Exercises* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
6.18 Problems* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336

7 Energy balance* 341


7.1 Learning goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
7.2 Energy balance for closed and isolated systems . . . . . . . . . . . . . 341
7.3 Energy balance for open systems . . . . . . . . . . . . . . . . . . . . 343
7.4 Internal energy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
7.5 Work rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
7.6 Heat flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
7.6.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
7.6.2 Continuous phase . . . . . . . . . . . . . . . . . . . . . . . . . 348
7.6.3 Phase boundary . . . . . . . . . . . . . . . . . . . . . . . . . . 350
7.6.4 Overall heat transfer . . . . . . . . . . . . . . . . . . . . . . . 352
7.6.5 Radiation* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
7.7 Thermal energy balance . . . . . . . . . . . . . . . . . . . . . . . . . 355
7.7.1 Overview of Thermal energy balance . . . . . . . . . . . . . . 355
7.7.2 Development of Thermal energy balance+ . . . . . . . . . . . 356
7.8 Basic thermodynamics . . . . . . . . . . . . . . . . . . . . . . . . . . 359
7.8.1 Overview of thermodynamics . . . . . . . . . . . . . . . . . . 359
7.8.2 Kinetic theory of ideal gas+ . . . . . . . . . . . . . . . . . . . 361
7.8.3 Fundamental thermodynamic relations+ . . . . . . . . . . . . 364
7.8.3.1 Postulates . . . . . . . . . . . . . . . . . . . . . . . . 364
7.8.3.2 Alternative fundamental relations . . . . . . . . . . . 365
7.8.3.3 Molar relations . . . . . . . . . . . . . . . . . . . . . 366
7.8.3.4 Physically measurable thermodynamic relations . . . 367
7.8.3.5 Expressions for G̃, S̃, H̃ and Ũ . . . . . . . . . . . . 367
7.8.3.6 Subsystem equilibrium. Non equilibrium . . . . . . . 369
7.8.3.7 Reaction equilibrium . . . . . . . . . . . . . . . . . . 370
7.8.4 Practical thermodynamics+ . . . . . . . . . . . . . . . . . . . 372
7.8.4.1 Core quantities in general Equations of State . . . . 372
7.8.4.2 Enthalpy and internal energy in mixtures . . . . . . 374
7.8.4.3 Expressions for c̃p , βT , αp and c̃v . . . . . . . . . . . 376
7.8.4.4 Expressions for H̃ and Ũ . . . . . . . . . . . . . . . . 380
7.8.4.5 Expressions for activity . . . . . . . . . . . . . . . . 384
7.8.4.6 Quantities of formation . . . . . . . . . . . . . . . . 385
7.8.4.7 Reaction equilibrium . . . . . . . . . . . . . . . . . . 388
7.9 Distributed heat exchangers . . . . . . . . . . . . . . . . . . . . . . . 391
7.9.1 Overview with heat exchanger configurations . . . . . . . . . . 391
7.9.2 Cross-current heat exchanger+ . . . . . . . . . . . . . . . . . . 395
7.9.2.1 Dynamic model . . . . . . . . . . . . . . . . . . . . . 395
7.9.2.2 Steady model . . . . . . . . . . . . . . . . . . . . . . 397
7.9.2.3 Solution of steady model . . . . . . . . . . . . . . . . 397
x CONTENTS

7.9.2.4 Heat transfer . . . . . . . . . . . . . . . . . . . . . . 397


7.9.2.5 Effluent temperatures . . . . . . . . . . . . . . . . . 398
7.9.2.6 Computational procedures . . . . . . . . . . . . . . . 399
7.9.2.7 Logarithmic mean temperature difference approach . 400
7.9.3 Co-current heat exchanger+ . . . . . . . . . . . . . . . . . . . 401
7.9.3.1 Dynamic model . . . . . . . . . . . . . . . . . . . . . 401
7.9.3.2 Steady model . . . . . . . . . . . . . . . . . . . . . . 402
7.9.3.3 Solution of steady model . . . . . . . . . . . . . . . . 403
7.9.3.4 Heat transfer . . . . . . . . . . . . . . . . . . . . . . 404
7.9.3.5 Logarithmic mean temperature approach . . . . . . . 404
7.9.4 Counter-current heat exchanger+ . . . . . . . . . . . . . . . . 405
7.9.4.1 Dynamic model . . . . . . . . . . . . . . . . . . . . . 405
7.9.4.2 Steady model . . . . . . . . . . . . . . . . . . . . . . 406
7.9.4.3 Solution of steady model . . . . . . . . . . . . . . . . 406
7.9.4.4 Heat transfer . . . . . . . . . . . . . . . . . . . . . . 408
7.9.4.5 Logarithmic mean temperature difference approach . 409
7.9.5 Final comments . . . . . . . . . . . . . . . . . . . . . . . . . . 409
7.10 Case: Heated liquid tank . . . . . . . . . . . . . . . . . . . . . . . . . 410
7.10.1 Model objective . . . . . . . . . . . . . . . . . . . . . . . . . . 410
7.10.2 Model development . . . . . . . . . . . . . . . . . . . . . . . . 410
7.10.3 Model summary . . . . . . . . . . . . . . . . . . . . . . . . . . 413
7.10.4 Model simulation . . . . . . . . . . . . . . . . . . . . . . . . . 413
7.10.5 ODE formulation . . . . . . . . . . . . . . . . . . . . . . . . . 419
7.10.5.1 Model reduction to ODE . . . . . . . . . . . . . . . . 419
7.10.5.2 Model summary . . . . . . . . . . . . . . . . . . . . 421
7.10.6 ODE model simulation . . . . . . . . . . . . . . . . . . . . . . 421
7.11 Case: Heated gas tank . . . . . . . . . . . . . . . . . . . . . . . . . . 422
7.11.1 Model objective . . . . . . . . . . . . . . . . . . . . . . . . . . 422
7.11.2 Model development . . . . . . . . . . . . . . . . . . . . . . . . 422
7.11.3 Model summary . . . . . . . . . . . . . . . . . . . . . . . . . . 424
7.11.4 Model simulation . . . . . . . . . . . . . . . . . . . . . . . . . 426
7.12 Case: Heat diffusion in metal rod . . . . . . . . . . . . . . . . . . . . 430
7.12.1 Model objective . . . . . . . . . . . . . . . . . . . . . . . . . . 430
7.12.2 Model development . . . . . . . . . . . . . . . . . . . . . . . . 431
7.12.3 Model summary . . . . . . . . . . . . . . . . . . . . . . . . . . 435
7.12.4 Model simulation . . . . . . . . . . . . . . . . . . . . . . . . . 437
7.13 Case: Hot water accumulator⋆ . . . . . . . . . . . . . . . . . . . . . . 443
7.13.1 Model objective . . . . . . . . . . . . . . . . . . . . . . . . . . 443
7.13.2 Model development . . . . . . . . . . . . . . . . . . . . . . . . 443
7.13.3 Model summary . . . . . . . . . . . . . . . . . . . . . . . . . . 443
7.13.4 Model simulation . . . . . . . . . . . . . . . . . . . . . . . . . 443
7.14 Cases: Liquid phase reactor . . . . . . . . . . . . . . . . . . . . . . . 443
7.14.1 Model objective . . . . . . . . . . . . . . . . . . . . . . . . . . 443
7.14.2 Model development . . . . . . . . . . . . . . . . . . . . . . . . 444
7.14.3 Model summary . . . . . . . . . . . . . . . . . . . . . . . . . . 447
7.14.4 Model simulation . . . . . . . . . . . . . . . . . . . . . . . . . 447
CONTENTS xi

7.14.5 ODE formulation . . . . . . . . . . . . . . . . . . . . . . . . . 456


7.14.5.1 Model reduction to ODE . . . . . . . . . . . . . . . . 456
7.14.5.2 Model summary . . . . . . . . . . . . . . . . . . . . 458
7.14.6 ODE model simulation . . . . . . . . . . . . . . . . . . . . . . 459
7.15 Case: Gas phase reactor⋆ . . . . . . . . . . . . . . . . . . . . . . . . . 459
7.15.1 Model objective . . . . . . . . . . . . . . . . . . . . . . . . . . 459
7.15.2 Model development . . . . . . . . . . . . . . . . . . . . . . . . 459
7.15.3 Model summary . . . . . . . . . . . . . . . . . . . . . . . . . . 459
7.15.4 Model simulation . . . . . . . . . . . . . . . . . . . . . . . . . 459
7.16 Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
7.17 Exercises* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
7.18 Problems* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460

8 Model analysis* 467


8.1 Learning goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
8.2 Model types, solvability and stability . . . . . . . . . . . . . . . . . . 467
8.2.1 Classification of models . . . . . . . . . . . . . . . . . . . . . . 467
8.2.1.1 General Differential Algebraic Equations . . . . . . . 467
8.2.1.2 Structured Differential Algebraic Equations . . . . . 469
8.2.1.3 Ordinary Differential Equations . . . . . . . . . . . . 470
8.2.2 Solvability of models . . . . . . . . . . . . . . . . . . . . . . . 471
8.2.2.1 The concept of state . . . . . . . . . . . . . . . . . . 471
8.2.2.2 Required information . . . . . . . . . . . . . . . . . . 472
8.2.2.3 Required model properties . . . . . . . . . . . . . . . 472
8.2.2.4 Random systems/Stochastic Differential Equations+ 473
8.2.2.5 Random systems in practice . . . . . . . . . . . . . . 474
8.2.3 Stability concepts . . . . . . . . . . . . . . . . . . . . . . . . . 476
8.3 Analytic solution of nonlinear models . . . . . . . . . . . . . . . . . . 478
8.4 Linearization by Taylor series expansion . . . . . . . . . . . . . . . . 480
8.4.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
8.4.2 Scalar Taylor series expansion . . . . . . . . . . . . . . . . . . 480
8.4.3 Scalar function with multivariable argument . . . . . . . . . . 483
8.4.4 Vector of functions with multivariate argument . . . . . . . . 484
8.4.5 Linearization of model . . . . . . . . . . . . . . . . . . . . . . 485
8.5 Solution of linear systems . . . . . . . . . . . . . . . . . . . . . . . . 487
8.5.1 Linear, time invariant systems . . . . . . . . . . . . . . . . . . 487
8.5.2 Scalar, autonomous system . . . . . . . . . . . . . . . . . . . . 488
8.5.3 Scalar, driven system . . . . . . . . . . . . . . . . . . . . . . . 488
8.5.3.1 Guessing the solution structure . . . . . . . . . . . . 488
8.5.3.2 Series expansion of exponential . . . . . . . . . . . . 490
8.5.4 Multivariable systems . . . . . . . . . . . . . . . . . . . . . . . 491
8.5.5 Diagonalizable multivariable system . . . . . . . . . . . . . . . 493
8.6 Linear system analysis . . . . . . . . . . . . . . . . . . . . . . . . . . 496
8.6.1 Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496
8.6.1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . 496
8.6.1.2 Real eigenvalues, autonomous case . . . . . . . . . . 496
xii CONTENTS

8.6.1.3 Complex eigenvalues, autonomous case . . . . . . . . 496


8.6.1.4 General LTI systems . . . . . . . . . . . . . . . . . . 499
8.6.2 Time constant and oscillations . . . . . . . . . . . . . . . . . . 500
8.6.2.1 Time constant defined . . . . . . . . . . . . . . . . . 500
8.6.2.2 Experimental determination of time constant . . . . 501
8.6.2.3 Time constant in non-autonomous systems . . . . . . 502
8.6.2.4 Oscillatory systems . . . . . . . . . . . . . . . . . . . 503
8.6.3 Linearized nonlinear system . . . . . . . . . . . . . . . . . . . 512
8.6.4 Stability analysis based on steady-state model . . . . . . . . . 512
8.7 Nonlinear analysis by simulation* . . . . . . . . . . . . . . . . . . . . 513
8.7.1 Steady state vs. stationary solution⋆ . . . . . . . . . . . . . . 513
8.7.2 Sensitivity analysis⋆ . . . . . . . . . . . . . . . . . . . . . . . . 513
8.7.3 Stochastic systems and discretization⋆ . . . . . . . . . . . . . 513
8.8 Zero dynamics+ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
8.8.1 What is zero dynamics? . . . . . . . . . . . . . . . . . . . . . 513
8.8.2 Interpretation of zero dynamics . . . . . . . . . . . . . . . . . 514
8.8.3 Nonlinear feedback control . . . . . . . . . . . . . . . . . . . . 515
8.9 Singular perturbation+,⋆ . . . . . . . . . . . . . . . . . . . . . . . . . 515
8.10 Transfer function models . . . . . . . . . . . . . . . . . . . . . . . . . 515
8.10.1 Laplace transform . . . . . . . . . . . . . . . . . . . . . . . . . 515
8.10.2 Transfer function. Poles and zeros . . . . . . . . . . . . . . . . 516
8.10.3 Standard forms of the poles and zeros . . . . . . . . . . . . . . 518
8.10.3.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . 518
8.10.3.2 Poles: time constants and resonance frequencies . . . 518
8.10.3.3 Zeros and zero dynamics . . . . . . . . . . . . . . . . 520
8.11 Cases: Solution of linear models . . . . . . . . . . . . . . . . . . . . . 520
8.12 Cases: Stability of linear systems . . . . . . . . . . . . . . . . . . . . 527
8.13 Cases: Analysis of nonlinear systems . . . . . . . . . . . . . . . . . . 530
8.14 Cases: Analysis by simulation⋆ . . . . . . . . . . . . . . . . . . . . . . 536
8.15 Cases: Zero dynamics⋆ . . . . . . . . . . . . . . . . . . . . . . . . . . 536
8.16 Cases: Transfer function models . . . . . . . . . . . . . . . . . . . . . 536
8.17 Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
8.18 Exercises* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
8.19 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544

9 Model calibration† * 551


9.1 Learning goals* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551
9.2 Calibration* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551
9.3 Review* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551
9.4 Exercises* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551
9.5 Problems* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551

10 Models in a Wider Perspective† 553


10.1 Data and models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
10.2 Mechanistic models . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
10.3 Empirical models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
10.4 “Big data” and models . . . . . . . . . . . . . . . . . . . . . . . . . . 557
CONTENTS xiii

10.5 Use of models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558


10.6 Modeling in the future . . . . . . . . . . . . . . . . . . . . . . . . . . 560

A Computer simulation∗ 563


A.1 Running case studies . . . . . . . . . . . . . . . . . . . . . . . . . . . 563
A.2 Coding models on your own . . . . . . . . . . . . . . . . . . . . . . . 563

B Basic differentiation 565


B.1 Definitions and basic rules . . . . . . . . . . . . . . . . . . . . . . . . 565
B.2 Some useful rules for differentiation . . . . . . . . . . . . . . . . . . . 568
B.3 The derivative of some common functions . . . . . . . . . . . . . . . . 568

C Thermophysical data 569


C.1 Critical point properties of pure species . . . . . . . . . . . . . . . . . 569
C.2 Pure species heat capacity data . . . . . . . . . . . . . . . . . . . . . 569
C.3 Standard State Molar Thermodynamic Quantities . . . . . . . . . . . 569

D Solution to Exercises* 573


D.1 Chapter: Quantities and their Use . . . . . . . . . . . . . . . . . . . . 573
D.2 Chapter: Models and Model Solution . . . . . . . . . . . . . . . . . . 573
D.3 Chapter: Mass conservation . . . . . . . . . . . . . . . . . . . . . . . 584
D.4 Chapter: Species balance . . . . . . . . . . . . . . . . . . . . . . . . . 584
D.5 Chapter: Momentum balance . . . . . . . . . . . . . . . . . . . . . . 584
D.6 Chapter: Energy balance . . . . . . . . . . . . . . . . . . . . . . . . . 587
D.7 Chapter: Model analysis . . . . . . . . . . . . . . . . . . . . . . . . . 587
D.8 Chapter: Model calibration . . . . . . . . . . . . . . . . . . . . . . . 588

E Solution to Problems* 589


E.1 Chapter: Quantities and their Use . . . . . . . . . . . . . . . . . . . . 589
E.2 Chapter: Models and Model Solution . . . . . . . . . . . . . . . . . . 589
E.3 Chapter: Mass conservation . . . . . . . . . . . . . . . . . . . . . . . 589
E.4 Chapter: Species balance . . . . . . . . . . . . . . . . . . . . . . . . . 590
E.5 Chapter: Momentum balance . . . . . . . . . . . . . . . . . . . . . . 595
E.6 Chapter: Energy balance . . . . . . . . . . . . . . . . . . . . . . . . . 602
E.7 Chapter: Model analysis . . . . . . . . . . . . . . . . . . . . . . . . . 617
E.8 Chapter: Model calibration . . . . . . . . . . . . . . . . . . . . . . . 626

Bibliography 626
xiv CONTENTS
List of Figures

1.1 System S, environment {S, the world W, and interaction I. . . . . . 2


1.2 System S decomposed into 5 subsystems Sj , with interactions be-
tween neighboring subsystems Ijk and the environment E, Ij . . . . . 2
1.3 System S with inputs u from the environment {S and outputs of
interest (properties) y. . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 Ceci n’est pas une pipe = This is not a pipe. René Magritte. . . . . . 7

2.1 Quantities, constants and variables. . . . . . . . . . . . . . . . . . . . 12

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

4.1 Forces on particles in a gas. . . . . . . . . . . . . . . . . . . . . . . . 93


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. . . . . . . . . . . . . . . . . . 101
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. . . . . . . . . . . . . . . . . . . . . . . 102
4.4 Functional diagram of tank with effluent flow, but no influent flow. . 102
4.5 Level h in autonomous tank; time in seconds along the abscissa. . . . 105
4.6 Level h in autonomous tank; time in seconds along the abscissa. . . . 107
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 . . . . . . . . . . . . . . . . . . . 109
4.8 Functional diagram of tank with influent and effluent flow. . . . . . . 109

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

5.10 Functional diagram of varying volume liquid phase reactor. . . . . . . 173


5.11 Varying liquid level h, and molar concentrations cA and cB . . . . . . . 177
5.12 Influent volumetric flow rate V̇i and influent concentration cA,i . . . . . 177
5.13 Molar concentrations cA and cB in the case of a batch reactor. . . . . 180
5.14 Fixed volume reactor with reaction aA → B. . . . . . . . . . . . . . . 183
5.15 Functional diagram of fixed volume liquid phase reactor. . . . . . . . 183
5.16 Molar concentrations cA and cB in fixed volume reactor. . . . . . . . . 186
5.17 Volumetric flow rate V̇ through reactor, and influent concentration cA,i .187
5.18 Gas reactor with reaction aA → B. . . . . . . . . . . . . . . . . . . . 190
5.19 Functional diagram of gas phase reactor. . . . . . . . . . . . . . . . . 190
5.20 Partial pressures pA and pB and total pressure p in gas phase reactor. 193
5.21 Influent pressure pi (pure species A) to gas phase reactor. . . . . . . . 193
5.22 Pipe with diffusion of dissolved gas in liquid. . . . . . . . . . . . . . . 196
5.23 Functional diagram of diffusion of gas in liquid pipe. . . . . . . . . . . 196
5.24 Influent gas concentration ρi (red) and resulting effluent concentra-
tion ρL (blue); initial concentration ρ (t = 0, x) (green). N = 10 in
simulations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
5.25 Influent volumetric flow rate V̇i . . . . . . . . . . . . . . . . . . . . . . 205
5.26 Internal gas concentration ρj , with influent (red) and initial (green)
concentrations. N = 10 in simulations. . . . . . . . . . . . . . . . . . 206
5.27 Internal gas diffusion fluxes Ji . N = 10 in simulations. . . . . . . . . 206
5.28 Influent gas concentration ρi (red) and resulting effluent concentration
ρL (N ), with N ∈ {10, 30, 90, 300}. . . . . . . . . . . . . . . . . . . . . 207
5.29 Influent gas concentration ρi (red) and resulting effluent concentration
ρL (D), with D ∈ {10−7 , 3 × 103 · 10−7 }. . . . . . . . . . . . . . . . . 207
5.30 Sketch of process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211

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

6.9 Nomenclature for open channel flow. . . . . . . . . . . . . . . . . . . 245


6.10 Agitation friction factor f (“power number”) as a function of Reynolds
number NRe for some impeller geometries (Lydersen 1979). In the up-
per figure, Di is the impeller diameter, Dt is the tank diameter, h is
the propeller pitch (No. 4), zi is the height of impeller above bottom,
ze is the liquid level in the tank, and B is the width of baffles. In
the curves of the lower figure, the curve numbers (1–4) refer to the
configuration row in the upper figure. . . . . . . . . . . . . . . . . . . 250
6.11 Kinematic viscosity as a function of temperature, ν (T ), for various
hydraulic fluids. Data taken from Merritt (1967) with temperature
converted to ◦ C. In a log-log diagram, the curves are relatively linear. 252
6.12 Flow through an orifice: (a) laminar flow, and (b) turbulent flow. . . 256
6.13 Servo valve and piston: (a) three-land-four-way spool valve, (b) pis-
ton. Valve drawing based on Merritt (1967), with modified notation. . 258
6.14 Possible layouts for solenoids. . . . . . . . . . . . . . . . . . . . . . . 263
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. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
6.16 Nonlinear block diagram of servo system, with linear blocks, nonlinear
blocks and control inputs as well as disturbances. . . . . . . . . . . . 270
6.17 Linearized description of servo system, with linear blocks, one non-
linear saturation block, and one nonlinear backlash block. . . . . . . . 272
6.18 Approximate servo system description. . . . . . . . . . . . . . . . . . 277
6.19 Key quantities in a turbine. . . . . . . . . . . . . . . . . . . . . . . . 278
6.20 Turbine selection chart for selected turbine types. Due to Heinzmann
HydroTech, India, see http://www.heinzmann.co.in/technology.
html. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
6.21 Split of turbine into fluid guide apparatus and stator/rotor. . . . . . . 281
6.22 The absolute (earth bound) velocity v of a horse/rider is observed as
a relative velocity v̌ by passengers in a train moving with a reference
velocity vρ . More generally, an absolute velocity vector ⃗v is observed
as relative velocity ⃗v̌ for an observer moving with reference velocity
⃗vρ ; ⃗v = ⃗vρ + ⃗v̌ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
6.23 Some key concepts of the impulse turbine. . . . . . . . . . . . . . . . 284
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 modified notation and correction of a typo in the expression for
Ts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
6.25 Principle drawing and illustration of Francis turbine. From Harinaldi,
http://staff.ui.ac.id/system/files/users/harinaldi.d/material/
fluidsystem09-reactionturbine-francisandkaplan.pdf. . . . . . . . 289
6.26 Effect of guide vane angle α1 on stator inlet velocity v1 . . . . . . . . . 290
6.27 Key quantities in the Francis turbine model, with blade angles β1 and
β2 . The water effluent comes out from the paper plane. . . . . . . . . 292
LIST OF FIGURES xix

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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
6.29 Guide vane geometry relating actuator position Y to guide vane angle
α1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
6.30 Guide Vane characteristic with numbers from Table 6.7. The bullet
indicates actuator position Y = Y0 with corresponding Guide Vane
angle α10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
6.31 Principle drawing and illustration of Kaplan turbine. From Harinaldi,
http://staff.ui.ac.id/internal/132048279/material/FluidSystem09
-ReactionTurbine-FrancisandKaplan.pdf. . . . . . . . . . . . . . . . 302
6.32 Key quantities in the Kaplan turbine model. . . . . . . . . . . . . . . 303
6.33 Pipe transporting water from a dam through a pipe and a valve. . . . 306
6.34 Functional diagram of flow of water from dam through pipe, and
released 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. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
6.35 Volumetric flow rate V̇ through pipe/valve. . . . . . . . . . . . . . . . 310
6.36 Valve input signal u. . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
6.37 Pressure just upstream from valve, pe (red), compared to atmospheric
pressure pa (blue). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
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). . 312
6.39 Momentum m (our chosen state). . . . . . . . . . . . . . . . . . . . . 312
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. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
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. . . . . . . . . . 315
6.42 Level in lower tank hℓ (red; output), and levels in upper tank hu
(blue) and basin hb (green); all with unit m. . . . . . . . . . . . . . . 320
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. . . . . . . . . . . . . . . . 321
6.44 Input signal u to pump. . . . . . . . . . . . . . . . . . . . . . . . . . 321
6.45 Pipe for transporting gas. . . . . . . . . . . . . . . . . . . . . . . . . 325
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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
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. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
6.48 Sketch of vessel which is filled with liquid from pumping liquid through
a pipe. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
xx LIST OF FIGURES

7.1 Heat flow by conduction through homogeneous material, with tem-


perature Tx=0 = T0 and Tx=δ = T1 . . . . . . . . . . . . . . . . . . . . 350
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. . . . . . . 350
7.3 Example of layered structure with solid and fluid layers between fluids
with bulk temperatures Tb,1 and Tb,2 . . . . . . . . . . . . . . . . . . . 353
7.4 Variation of molar enthalpy H̃ (T, p◦ ) with temperature T ; pressure
p◦ is assumed fixed at a standard pressure. If the substance normally
is in the liquid phase, the molar enthalpy at some reference point
(T ◦ , p◦ ) is H̃ (T ◦ , p◦ ) which equals the molar enthalpy of formation
∆H̃f◦ for the liquid phase. If there is a phase change at some temper-
ature (e.g., T ◦ or T1 ), the molar enthalpy increases with the molar
enthalpy of vaporization, ∆H̃v — which depends on the temperature. 374
7.5 Concept of an ideal solution: properties of a mixed volume are equal
to the sum of properties over layered, pure volumes. . . . . . . . . . . 375
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. . . . . . . . . 377
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. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
7.8 Tube-and-shell heat exchangers, with cross-current (a), co-current
(b), and counter-current (c) configurations. . . . . . . . . . . . . . . . 393
7.9 Detailed depiction of cross-current heat exchanger. . . . . . . . . . . 395
7.10 Detailed depiction of co-current heat exchanger. . . . . . . . . . . . . 401
7.11 Detailed depiction of counter-current heat exchanger. . . . . . . . . . 405
7.12 Sketch of ideally stirred tank with heating. . . . . . . . . . . . . . . . 410
7.13 Functional diagram of heated liquid tank. . . . . . . . . . . . . . . . . 411
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). Ob-
serve that the results for the two formulations are identical, and cover
each other. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
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). Ob-
serve that the results for the two formulations are identical, and cover
each other. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
7.16 Influent mass flow ṁi [kg/s] (solid red), valve signal υ [–] (solid blue)
and effluent mass flow ṁe [kg/s] (solid green). . . . . . . . . . . . . . 415
7.17 Heat flow per length, Q̇′ [kW/m]. . . . . . . . . . . . . . . . . . . . . 415
7.18 Sketch of gas tank with heating. . . . . . . . . . . . . . . . . . . . . . 422
7.19 Functional diagram of heated gas tank. . . . . . . . . . . . . . . . . . 422
LIST OF FIGURES xxi

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 ,

varying because of change in air velocity. . . . . . . . . . . . . . . . . 439


7.27 Heated plate temperature Tp and air temperature Ta with tempera-
ture Ti in the various slices, all in ◦ C. . . . . . . . . . . . . . . . . . . 439
7.28 Temperature TL at end of metal rod as a function of the number of
slices N , and with heated plate temperature Tp and air temperature
Ta , all given in K. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
7.29 Cooled liquid reactor with reaction aA → B. . . . . . . . . . . . . . . 444
7.30 Functional diagram of cooled liquid reactor. . . . . . . . . . . . . . . 444
7.31 Molar concentrations cA (red), cB (blue), and influent concentration
cA,i (green), all given in [mol/L]. . . . . . . . . . . . . . . . . . . . . . 449
7.32 Reactor temperature T (red) and influent temperature Ti (blue), both
in [K]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
7.33 Added “heat” Q̇ [kW] — the negative value of Q̇ indicates cooling. . . 450
7.34 Volumetric flow rate V̇ [L/s] through the reactor. . . . . . . . . . . . 450
7.35 Sketch of system. Heat capacity that appears as cp , should be ĉp . . . 462
7.36 Sketch of reactor (CSTR) with distributed heat transfer. . . . . . . . 466

8.1 Concepts in stability definition. For simplicity, absolute value has


been used instead of norm. . . . . . . . . . . . . . . . . . . . . . . . . 476
8.2 Example of non-analytic function: this function can not be expressed
∑ 1 di f (x)
as f (x) = ∞ i=0 i! dxi (x − x∗ )i . . . . . . . . . . . . . . . . . . 481
x=x∗
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 . 482
( ) ( )
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. . . . . . . . . . . . . . . . . . . . . . . . . . . 501
8.5 Comparison of solution of differential equation (solid, red y) with
analytic solution (dotted, blue ya ) with step change in input, with
ζ = 0.3 and u (t) = 0.1H0 (t). The ODE solution and the analytic
solution are identical. . . . . . . . . . . . . . . . . . . . . . . . . . . . 506
xxii LIST OF FIGURES

8.6 Comparison of solution of differential equation with sinusoidal input


and ζ = 0. Cases u = 0.1 sin (0.9ω0 t) (red, y1 ), u = 0.1 sin (ω0 t) (blue,
y2 ), and u = 0.1 sin (1.1ω0 t) (green, y3 ). In all cases, the expressions
for the analytic solution give identical results. . . . . . . . . . . . . . 509
8.7 x1 (t) (solid, blue) and x2 (t) (dashed, red) when u (t) = 1 and x (0) =
( )T
1 −1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
( )
8.8 x1 (t) (solid, blue) and x2 (t) (dashed, red) when u (t) = sin 10t and
( )T
x (0) = 1 −1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
8.9 x (t) (solid, blue) and v (t) (dashed, red) when u (t) = 1 and y (0) =
( )T
1 −1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526
(1 )
8.10 x (t) (solid, blue) and v (t) (dashed, red) when u (t) = sin 10 t and
( )T
y (0) = 1 −1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526
´ (k)
D.1 Symbolic computation of exp x
dx using the WolframAlpha app. 582
D.2 Evaluation of “Blasius” integral using WolframAlpha. . . . . . . . . . 586
D.3 Evaluation of “Prandtl” integral using Maple 2016. . . . . . . . . . . 587

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

1 Essentials of general nomenclature used in these notes. . . . . . . . . xxxii


2 Essentials of specialized nomenclature used in these notes. . . . . . . xxxiii

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. . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2 Some standard symbols as used in mechanics. . . . . . . . . . . . . . 19
2.3 Some standard symbols as used in thermodynamics. Subscript j
refers to species j. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.4 Some old Norwegian units of length. . . . . . . . . . . . . . . . . . . 21
2.5 The seven base SI units. . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.6 The two supplementary SI units. . . . . . . . . . . . . . . . . . . . . 23
2.7 The nineteen derived SI units with special names and symbols. . . . 24
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. . . . . . . . . . . . . . . . . . 25
2.9 Three non-SI units defined through experiments. . . . . . . . . . . . 25
2.10 Thirteen temporary non-SI units. . . . . . . . . . . . . . . . . . . . . 25
2.11 Seventeen non-SI units to be discontinued/recommended to not use. 26
2.12 Twenty SI prefixes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.13 Outdated (but still used) computer science units; 1 byte = 8 bit. . . 27
2.14 Modern computer science units as defined by International Electrotech-
nical Commission; 1 byte = 8 bit. . . . . . . . . . . . . . . . . . . . 28
2.15 Some dimensionless numbers commonly used in science and engineer-
ing. In Eq. 2.7, symbol D is used to denote characteristic length/-
diameter. Below, D denotes (binary) diffusion coefficient, while L
denotes characteristic length. . . . . . . . . . . . . . . . . . . . . . . 36

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

6.1 Roughness height ϵ for various materials. . . . . . . . . . . . . . . . 229


6.2 Simple, explicit approximations of Colebrook’s relation, with maximal
deviation (Max dev) from Colebrook’s relation over the region NRe ∈
[104 , 108 ] and Dϵ ∈ [10−1 , 10−6 ]. See Brkić (2011b). . . . . . . . . . . . 239
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/. . . . . . . . . . 245
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/. . . . . . . . . . 246
6.5 Examples of values for Manning’s friction factor kM . . . . . . . . . . 248
6.6 Bulk modulus, Poisson ratio and Young modulus for selected materials.255
LIST OF TABLES xxvii

6.7 Example parameters for Guide Vane system. . . . . . . . . . . . . . . 299


6.8 Parameters in the generic turbine model. . . . . . . . . . . . . . . . 305
6.9 Parameters for liquid flow from dam through pipe and valve. . . . . 309
6.10 Operating conditions for liquid flow from dam through pipe and valve. 310
6.11 Parameters for two tanks with basin and pump/pipe. . . . . . . . . 319
6.12 Operating conditions for two tanks with basin and pump/pipe. . . . 319
6.13 Numerical values for parameters and operating points for the model
of Problem 6.5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340

7.1 Thermal conductivity k [ mWK ] for some materials at pressure 1 atm.


Data taken from Geankoplis (1993), p. 218. . . . . . . . . . . . . . . 349
7.2 Approximate value of some heat transfer coefficients. Data taken
from Geankoplis (1993), p. 219. . . . . . . . . . . . . . . . . . . . . 351
7.3 Interpretation of partial derivatives of thermodynamic quantities. . . 366
7.4 Second order derivatives of Gibb’s free energy, and their relationships. 368
7.5 Isothermal compressibility βT , coefficient of thermal expansion αp ,
and difference c̃p − c̃v for ideal gas and for constant density liquid
(“ideal liquid”). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
7.6 Molar enthalpy and internal energy with arguments (T, p) for ideal

gas and for constant density liquid (“ideal liquid). F̃ − F̃ ◦ implies
c
constant heat capacity. . . . . . . . . . . . . . . . . . . . . . . . . . . 380
7.7 Parameters for heated liquid tank. . . . . . . . . . . . . . . . . . . . 413
7.8 Operating conditions for heated liquid tank. . . . . . . . . . . . . . . 413
7.9 Parameters for heated gas tank. . . . . . . . . . . . . . . . . . . . . 425
7.10 Operating conditions for heated gas tank. . . . . . . . . . . . . . . . 425
7.11 Parameters for study of temperature diffusion in metal rod. . . . . . 438
7.12 Operating conditions for study of temperature diffusion in metal rod. 438
7.13 Parameters for liquid reactor with varying temperature. . . . . . . . 448
7.14 Operating conditions for liquid reactor with varying temperature. . . 448
7.15 Numerical values for parameters and operating points for the model
of Problem 7.7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464

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.

Bernt Lie, Porsgrunn, August 16, 2019


Nomenclature

A summary of essential general nomenclature used in these lecture notes is given in


Table 1.
Table 2 gives some specialized nomenclature for the topics of these notes.

xxxi
xxxii PREFACE

Table 1: Essentials of general nomenclature used in these notes.


Symbol Description
V System volume
∂V System boundary
=, ≡, , Equal to, identically equal (i.e., always equal), and equal by definition,
respectively
∀i : Ci ; ∃i : Ci For all i, condition Ci is satisfied; there exists i such that condition Ci is
satisfied
q General quantity
[q] Dimension of q, e.g., time, mass, temperature, power, energy, etc.
{q} Unit of q, e.g., s, min, g, kg, ◦ C, K, W, kW, J, Btu, etc.
|q| Numeric value of q. Thus q = |q| {q}; if q = 1 m, then |q| = 1 and {q} = m.
ς
q Scaling quantity for q, where [q ς ] = [q] [ ]
q̄ Dimensionless quantity for q, e.g., q̄ = qqς where qqς = 1 is dimensionless
q∗ Operating value of quantity q
qδ q δ = q − q ∗ , deviation between quantity q and the operating
{ q ∗ value of q
0, t < τ
Hτ (t) Heaviside function, often abbreviated Hτ ; Hτ (t) ,
1, t ≥ τ
ℜ (z) , ℑ (z) Real part and imaginary part of complex number z, respectively
ε Extensive variable within V , i.e., variable that increases linearly with system
extent (mass, volume, energy, etc.)
ι Intensive variable within V , i.e., variable that is independent of system
extent (concentration, temperature, pressure, etc.)
β Non-extensive quantity of same dimension as ε, [β] = [ε], but crossing
boundary ∂V (heat, work, etc.)
σ Source quantity of same dimension as ε, [σ] = [ε], created within V (chemical
reaction, etc.)
dq
dt
Time derivative of variable q (t)
δε Amount of ε crossing ∂V in a given time interval dt as a result of moving
mass
δβ Amount of ε and β crossing ∂V in a given time interval dt without moving
mass
δσ Amount of σ created within V in a given time interval dt
δε [ε]
ε̇ dt
, convective transport of ε (by moving mass) across ∂V . [ε̇] = time .
ε1 = ιε2 ⇒ ε̇1 = ιε̇2 [ ]
δβ
β̇ dt
, flow of β (without moving mass) across ∂V . β̇ = [ε̇]
φ̇ φ̇ , ε̇ + β̇ across boundary ∂V .
δσ
σ̇ dt
, generation rate within V . [σ̇] = [ε̇]
ε′ , ε′′ , ε′′′ Amount of ε per length, per area, per volume
∂q(t,x) ∂q(t,x)
, ∂x Partial derivatives of quantity q wrt. free variables t (time) and x (position)
∑∂tJ ∑
j=1 qj = Jk=1 qk = q1 + q2 + · · · + qJ . (Note: we are free to change the summand
index (j → k), but not the sum boundaries.)
´X ´X
x=0
q (x) dx = ξ=0 q (ξ) dξ. (Note: we are free to change the integrand variable, but not
the boundaries.)
PREFACE xxxiii

Table 2: Essentials of specialized nomenclature used in these notes.


Symbol Description
m; mj Mass; mass of species j
n; nj Amount in mole; amount of species j
ρ, m′′′ ; ρj , m′′′
j (Mass) density; mass concentration of species j
cj , n′′′
j Molar concentration of species j
q̂ Quantity q per total mass m
q̃ Quantity q per total amount n in mole
v Linear velocity
ω Angular velocity
J Rotational moment of inertia
m Linear momentum, typically m = mv
a Angular momentum, typically a = Jω
F Force
T Torque
p, F ′′ Pressure
E Total energy
K Kinetic energy, typically K = 21 mv 2 , K = 12 Jω 2
P Potential energy, Fc = − ∂P ∂x
where Fc is a conservative force
U Internal energy
H Enthalpy, H , U + pV
W, Ẇ Work, work rate/(mechanical) power
Q, Q̇ Heat, heat flow
T Temperature
q• (Thermodynamic) quantity qj for species j in a mixture when pretending it is
a pure species
q◦ (Thermodynamic) quantity q in the standard state at p = 1 atm; the
temperature depends on species
r Rate of reaction
ν Stoichiometric matrix
ĉp , c̃p Specific and molar heat capacity at constant pressure, respectively.
∂ Ĥ ∂ H̃
ĉp = ∂T , c̃p = ∂T
p p

ĉv , c̃v Specific and molar heat capacity at constant volume, respectively. ĉv = ∂∂TÛ ,
p
∂ Û
c̃v = ∂T
p
( ) ( ) ( )
αp Thermal expansion coefficient, αp , V1 ∂V ∂T p
= 1 ∂ V̂
∂T
= 1 ∂ Ṽ
∂T
( ) V̂
( ) p Ṽ
(p )
βT Isothermal compressibility, βT , − V ∂p1 ∂V
= − V̂ ∂p
1 ∂ V̂
= − Ṽ ∂∂pṼ
1
T T T
k Heat conduction, Q̇′′ = −k ∂T
∂x
h Heat transfer coefficient, Q̇′′ = h · ∆T where ∆T is a temperature difference
U Overall heat transfer coefficient
xxxiv PREFACE
Chapter 1

Introduction

1.1 Systems
1.1.1 System: object, property, interaction
What is a system? A system may be defined as in Fritzson (2011):

• A system is an object or collection of objects whose properties we want to


study.

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

Figure 1.1: System S, environment {S, the world W, and interaction I.

Figure 1.2: System S decomposed into 5 subsystems Sj , with interactions between


neighboring subsystems Ijk and the environment E, Ij .

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.2 System decomposition


An important concept is that of system decomposition: we can decompose the system
into subsystems with information exchange between the neighboring subsystems and
with the environment E, Fig. 1.2

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.1.4 Dynamic system


All systems are dynamic, in the sense that they exhibit some inertia against change:
change takes time. Our observation of this inertia does, however, depend on the
time scale of interest. If we switch on the electric light in a room, this change may
appear as instantaneous in the time scale of interest. In reality, turning on the light
takes some time: there is inertia, e.g., in the build-up of voltage in the resistor of
a light bulb. But if, in the time scale of interest, this appears as instantaneous,
we may not realize the dynamics of it. Thus, some systems may appear to have
instantaneous response. In other systems, the time scale may make it obvious that
there is an inertia against change. It is important to realize that the time scale of
interest for a system may change over time, or by a change in the use of the system.

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.

1.3 Models and model types


1.3.1 What is a model?
A model is a representation of a system, including the inputs that influences the
behavior of the system and the outputs that influences the environment. A model
can thus be defined as Fritzson (2011):
• A model of a system is anything an “experiment” can be applied to in order
to answer questions about the system at hand.
A real problem in modeling is that rarely are all the inputs u to a system known.
We may not be aware of all inputs that influence the behavior. And even if we do
know of inputs that influence a system, we may not know their values, or we may
deem them unimportant. Some inputs to a system may be manipulated at will: in
heating a room, we may determine the electric power provided as heating. Other
inputs can not be manipulated; they just are what they are: in heating a room, we
can hardly manipulate the irradiation from the sun or the cloud coverage, humidity,
etc.
Inputs to a system that can be manipulated at will and in fact are manipulated,
are known as control inputs or manipulated variables. Inputs to a system that are
known but can not be manipulated at will or which we choose to not manipulate,
or inputs that we do not even know of, are known as disturbances.
Realistically, there is an infinite number of outputs (influences) from a system
to the environment. We will, however, only include those outputs that we measure
and/or are properties of interest in the system in our output variable y.
3
See the next chapter.
1.3. MODELS AND MODEL TYPES 5

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.

1.3.2 Empirical models


Predating Newton4 , models were typically empirical in form: the behavior of systems
were observed, and cause and effect and correlations were represented in tables. As
an example, one could have tabular representations of observations of the position of
an apple falling from a tree wrt. time, depending on the size of the apple, or of the
position of a pebble falling, or a feather falling. Such models can be denoted empiri-
cal models. Later, such tabular descriptions were fitted to parametric mathematical
structures, where the parameters were tuned to, e.g., give good prediction proper-
ties in a least squares sense. Examples of modern versions of such empirical models
include regression models, subspace models, neural network models, etc. The key
characteristic is that these models are based on observations from specific systems.
This also has the consequence that until the system is built and observations can
be made from the system, it is not possible to develop an empirical model. The
advantage of such empirical models is that it is relatively straightforward to make
computer systems for automating the development of the models — as soon as the
observations are representative.

1.3.3 Mechanistic models


One of Newton’s most important achievements was the discovery that the behavior
of systems such as an apple seemed to be governed by an underlying mechanism,
which became known as Newton’s law. With Newton’s law, it became possible to
in principle predict the behavior of the apple or pebble or feather without actually
having available the system. Later extensions and discoveries such as conservation
of mass, momentum, energy, transport equations, etc. postulate that there are
underlying mechanisms that explain the behavior of systems. Models based on
the understanding of these mechanisms, can be denoted mechanistic models. Their
advantage is that such models can be developed even if the system in question does
not exist. The idea of mechanistic models is very important and useful. They
still have some problems, though. It is possible and even probable that not all
mechanisms driving a system are known. Furthermore: a detailed mechanistic model
may become so complex that their usefulness decreases — it is necessary to find a
balance between model complexity and model usefulness. Finally, it is not easy to
develop computer systems for automating the development of mechanistic models
with a good balance between complexity and usefulness.
4
Sir Isaac Newton (1643 – 1727), English physicist and mathematician (described in his own
day as a “natural philosopher”); one of the most influential scientists of all time.
6 CHAPTER 1. INTRODUCTION

Mechanistic models typically depend on natural constants and mathematical


constants which are (thought to be) universally valid. In addition, such models de-
pend on parameters (constants) defining geometry, physical properties, etc. Finally,
mechanistic models include variables such as input variables, output variables, and
usually additional variables describing hidden quantities. A key concept in mech-
anistic models is that of causality, where a response comes as a result of an input
change, i.e., after in time. This gives rise to the idea that certain variables hold
information about the history/past of a system, known as state variables. The im-
plication of this idea of state variables is that if a state is known at a given time,
then the future behavior of the system can be predicted by knowing the state at this
time and future inputs influencing the system. In other words: it is not necessary to
know past inputs. It should be observed that the states are not unique: states can
be transformed into other quantities that hold the same information.

1.3.4 Material vs Spatial Description


When developing models of systems, we can make a choice as to whether the system
always contains the same matter, whether the system geometry is fixed in space, or
whether the system geometry moves/changes with time.
If the system geometry moves in space in such a way as to always contain the
same matter, the model description is denoted a material description:5 the idea is
that we always consider the same matter. For material description, there is obviously
no exchange of matter with the environment. Material description is commonly used
for mechanical systems where the main interest is how a fixed object moves in space.
If we instead consider a fixed geometry where matter flows through the geometry
and changes the content of the system, this model description is known as a spatial
description:6 the idea is that we always consider the same system volume, where
matter flows through the system. Spatial description is commonly used for flow
systems where the main interest is how the properties in a given volume/system
change with time. In these notes, the main focus is on the spatial description.

1.3.5 Model vs System


A model represents those parts of a system that are needed in order to describe the
properties of interest; in particular, the model must represent how input variables
affect these parts of the system. The model must also represent how the chosen
parts of a system are manifested in the output variables. Figure 1.47 illustrates the
relationship between system and model: the pipe represents the system, while the
painting represents a model of the pipe. The painting is an image of the pipe, and
is in itself not equal to the pipe. The painting shows what the pipe may look like,
but has no information about other aspects of the pipe, such as what it smells like,
how it feels to hold the pipe in the hand, etc.
5
Also known as Lagrangian description.
6
Also known as Eulerian description.
7
By René Magritte (1898–1967), Belgian surrealist artist. His work is known for challenging
observers’ preconditioned perceptions of reality.
1.4. SIMULATION 7

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):

• A simulation is an experiment performed on a model.

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.

1.5 Structure of notes


These lecture notes deal with modeling principles for describing dynamics of flow
systems, based on classical physics. When developing mechanistic models of systems,
i.e., models that attempt to describe the mechanisms that drive the evolution of a
system, setting up balances of extensive quantities is the starting point. A fairly
general balance law for extensive quantities can be written as

= ε̇i − ε̇e + β̇i − β̇e + σ̇ (1.1)
dt
where ε is some extensive quantity (e.g., mass, momentum, energy), ε̇ is advective9
flow of this quantity, β̇i and β̇e are transport terms across the system boundary
without the movement of matter, and σ̇ is some source term within the volume;
indices i and e on ε̇ and β̇ refer to influx and efflux, respectively. Here, ε̇ and β̇ can
be combined into the flux φ̇ , ε̇ + β̇. Thus, we can recast the balance law into the
form

= φ̇i − φ̇e + σ̇. (1.2)
dt
The idea of classifying systems into open systems, closed systems, and isolates
systems is useful. Equation 1.1 describes an open system where free flow of the
extensive quantity is allowed across the system boundaries. The system is closed if
there is no material flow across the system boundaries, in other words if ε̇i ≡ ε̇e ≡ 0.
In that case, the balance law simplifies to

= β̇i − β̇e + σ̇. (1.3)
dt
Finally, for isolated systems, there is no transport of the quantity across the system
boundaries, φ̇i ≡ φ̇e ≡ 0, and the balance law reduces to

= σ̇. (1.4)
dt
If the source term is zero in Eq. 1.1, σ̇ ≡ 0,10 we will refer to the balance law
as a conservation law. The reason is that for an isolated system, Eq. 1.4, where
σ̇ ≡ 0, dε
dt
= 0 ⇒ ε = const and ε is conserved. Balance laws, and in particularly the
refinement into conservation laws, are of key importance in mechanistic modeling of
dynamic systems.
To have a complete model, additional relations need to be added to the balance
laws. These additional relations typically are in the form of algebraic equations,
9
Advective = with flow. Thus, advective flow is some quantity that is carried/transported by
the general fluid flow.
10
In other words: when σ̇ ≡ 0, quantity ε is neither produced nor consumed within the system.
1.5. STRUCTURE OF NOTES 9

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

= 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

Chapter 9. Finally, in Chapter 10, modeling is put into a wider perspective in a


concluding discussion.
A few appendices are provided. Appendix A discusses how to install the com-
puter tools used in the course, Appendix B gives examples of thermophysical data,
Appendix C and D give solutions to exercises and problems, while Appendix E holds
Python code used in analysis parts. When it comes to Modelica code, such code is
included directly in the examples of the main body of the text.
Chapter 2

Quantities and their Use

2.1 Learning goals


After working through this chapter, the following concepts should be mastered.

• Quantities: natural constants vs. parameters vs. variables, independent and


dependent variables, extensive and intensive variables.

• Symbols: good practice for choice of symbols for quantities and operators,
standards symbols for some quantities.

• Units vs. dimensions, consistency of units and dimensions in equations. Di-


mensions and SI units.

• Dimensionless models. The Buckingham Π-theorem and dimensionless groups.

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

Natural constants; constant


Constants:
Design constants; parameter
Quantities:
Independent variables; time, position
Variables:
Dependent variables

Extensive variables Intensive variables

Figure 2.1: Quantities, constants and variables.

In addition to quantities which are constant (constants and parameters), quan-


tities can have a value that varies; we call such quantities variables. The most basic
variables are the independent variables; these have a value that varies independently
of other quantities. Examples are time which varies in a given temporal interval dur-
ing an experiment, or position which varies linearly in a given spatial interval during
an experiment.
Dependent variables are variables which depend on other variables. Typically,
dependent variables depend either directly on independent variables, or indirectly
by depending on other dependent variables.
So-called boundary variables are variables that are given by an autonomous envi-
ronment of a system, and are transferred from this environment through the system
boundary and into the system. Such variables are often also called input variables.
These boundary variables or input variables are dependent variables which depend
solely on independent variables, i.e., on time and/or position.
Since we are mainly concerned with dynamic system, variability will normally
refer to temporal variation, in other words that the dependent variables mainly
varies with time as independent variable.
Some (dependent) variables have a numeric value which depends on the extent
of the system. Consider the decomposed system in Fig. 1.2. If we take the system
masses mj , the volumes Vj or the energies Ej of the 5 subsystems ∑ Sj in that∑figure,
the total mass, volume, and energy of the system S is m = 5j=1 mj , V = 5j=1 Vj

and E = 5j=1 Ej . Such quantities (variables) which depend on the extent of the
system in an additive way, are called extensive variables. Examples of extensive vari-
ables are mass, electric charge, volume, length, area, momentum, energy, enthalpy,
and entropy.
Other (dependent) variables have a numeric value which is independent of the
extent of the system; these are called intensive variables. Examples of intensive
variables are temperature, pressure, density, concentration, specific energy, molar
enthalpy, elasticity, viscosity, specific heat capacity. If, e.g., two systems with masses
m1 and m2 have the same densities, ρ1 = ρ2 = ρ, then the density of the combined
2.3. SYMBOLS AND OPERATORS 13

system is still ρ — it does not increase, while the mass is the sum of masses, m1 +m2 .

2.3 Symbols and Operators


2.3.1 Symbols
“What’s in a name? that which we call a rose
By any other name would smell as sweet”
— Juliet in Romeo and Juliet by William Shakespeare

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.

• Always use an equation editor to express symbols for quantities, mathe-


matics, etc. This will ensure that the typesetting is correct.
• An equation editor should be used for typesetting both displayed math-
ematics, such as
dx
= ax + bu
dt
and in-line mathematics such as T = 300 K. Do not cheat and typeset
in-line mathematics as text, e.g., T=300K; this looks ugly.

2. Symbols for quantities should consist of a single letter 1 .

• Two-letter expressions such as ax and bu will be considered as implicitly


expressing multiplication, thus ax = a · x and bu = b · u. Because of this,
multi-letter symbols will be confusing, and should be avoided.
• In some fields, two letter symbols are still used. If so, they are typeset
using a roman font, e.g., Re — Re is sometimes used as a symbol for the
Reynolds number.2
1
...and typeset in an italic font.
2
Osborne Reynolds (1842–1912).
14 CHAPTER 2. QUANTITIES AND THEIR USE

• In mathematics, operators are typeset in a roman font (straight) and


often consist of multiple letters. Some examples are the functions sin,
cos, ln, log, exp, etc. and the operators min, max, etc. Similarly, ℜ and
ℑ sometimes appear as the operators for taking the real part and the
imaginary part of a complex number.
• Both because of the possibility of confusion because of assumed multi-
plication, and of an interpretation as an operator, multi-letter symbols
should be avoided.

3. To ease communication, symbols should follow a tradition or be made “mnemonic” 3 .

• Examples of mnemonic symbol choices are m for mass, T for temper-


ature, and p for pressure. Examples of symbols by tradition are λ for
eigenvalue, and s for the variable in the Laplace transform — these are
hardly mnemonic.4
• In a multi-physics course, symbol tradition may lead to conflicting or
overlapping symbols. As an example, p signifies pressure in thermody-
namics, but sometimes momentum (impulse) in mechanics.
• Traditionally, letters i, j, . . . , n and I, J, . . . , N are used to denote inte-
gers, but not always.
√ As an example, M is often used for molar mass, i
√ to denote −1 in mathematics, while i is used for current and j
is used
for −1 in electric engineering.
• It is common to extend the symbol set by using letters from different font
sets and different alphabets. As an example S, S, Σ are representations
of the same letter in two different Latin font sets (standard Latin and
calligraphic), and the Greek alphabet. With the Unicode representation
of characters, it is easy to include symbols from many different alpha-
bets in a document. However, it is recommended to restrict the use of
symbols/alphabets — at some stage, symbols that are unknown to the
reader will become confusing, simply because a reader is not well trained
to distinguish between symbols in a different alphabet than her/his own.
• Use of decoration can extend the available...symbol set, e.g., decorations of
letter q such as q̇, q̂, q̃, q̄, q̌, q́, q̀, q̆, q̊, q̈, q , −

q , q ′ , q ′′ can be used to give
special meaning to the symbol. Some of these decorations are commonly
used as operators, and thus often have a special meaning. Others are
perhaps so similar that it may be difficult to distinguish between them.

4. Use of indices to distinguish between symbols for similar quantities.

• Single letter symbols may be distinguished from another by adding an


index (subscript, superscript).
• If the index is a symbol for a quantity, e.g., counter i, position x, pressure
p, etc., the index should be typeset as a symbol, i.e., using an italic font.
3
mnemonic = Greek mnēmonikos, from mnēmōn mindful, from mimnēskesthai to remember.
4
Symbols that appear as not being mnemonic in English, may in fact have been mnemonic in
the language where the concept appeared.
2.3. SYMBOLS AND OPERATORS 15

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]

As an example, Ti may denote the temperature in system volume i, ρx


may denote the density in position x, cp may denote specific heat capacity
at constant pressure.
• If the index is a descriptive sequence of letters, the index should be
typeset as text, using a roman font. As an example, Ti may denote
temperature at the inlet of the system, ρx may denote the density at the
exit from the system, cp may denote a constant for a pump.
• When using a superscript index, some care should be used to make sure
whether xi denotes x raised to the ith power, x for system volume i, etc.
• A symbol may have a list of indices, e.g., a12 , a1,2 or several levels of
indices, e.g., Tij . In general, it is recommended to avoid having too
complex indices.

5. In handwriting, care should be used to avoid confusing symbols that may


appear similar, e.g., Latin p and Greek ρ, Latin v and Greek ν, Latin u and
Greek υ, Latin e and Greek ε, etc.
The Greek alphabet is used extensively in symbols, see Table 2.1.

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:

• For time derivative, we write this as dx


dt
(e.g., dm dT
dt
, dt , etc.), i.e., dx
dt
, lim∆t→0 x(t+∆t)−x(t)
∆t
.

• When x is an extensive variable, we let ẋ denote the flow rate of x; ẋ is never


used in the meaning of time derivative in these notes.

2.3.2.2 Partial derivatives


In the case that a dependent variable y depends on two independent variables t, x,
i.e., y = y (t, x), we will write the partial derivative as

∂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

• Note in particularly that δy


δt
does not symbolize partial differentiation! Symbol
δ is different from symbol ∂! In mathematics, δ is sometimes used to symbolize
so-called variation, but not partial derivative.

• Sometimes in mathematics, partial derivative is indicated by inserting a sub-


script with the variable that the derivative is taken with respect to; occasion-
ally the index is prepended 9 by a comma:
∂y ∂y
yt = , y,t =
∂t ∂t
∂y ∂y
yx = , y,x = .
∂x ∂x

• In a more mathematical/precise notation, we should really write ∂y(t,x)


∂t
and
∂y(t,x)
∂x
to indicate which are the independent variables. Because space is saved
by instead writing ∂y ∂t
∂y
and ∂x , it is relatively common to add the constant
independent variable as a subscript, e.g.,

∂y ∂y (t, x)
=
∂t x ∂t

∂y ∂y (t, x)
= ,
∂x t ∂x

where notation ·|t means evaluated at the fixed value t, etc.

2.3.2.3 Summation and integration



Symbol denotes summation, and is a different symbol than the capital Greek
letter Σ. For summation over a range of values, the indices are typically∑specified on
the right side of the summation symbol in in-line mathematics, e.g., 5i=1 xi , and
below/above the symbol in displayed mathematics, e.g.,


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 .

• If the index set I is a subset∑of integers,∑i.e., I = {i1 , i1 + 1, . . . , i2 }, it is


common to write the sum as ii=i 2
f or ii21 fi , with the obvious meaning
1 i
∑i 2
i=i1 fi = fi1 + fi1 +1 + fi1 +2 + · · · fi2 .

• If the quantity happens to depend on two indices, e.g.,


∑i2fi,j , it is necessary to
be specific about which index one sums over. Thus, i1 fi,j is not sufficiently
∑2
precise, and it is necessary to write ii=i f .
1 i,j

9
Prepend = put in front of. Prepend is the opposite of append = put after; cf. appendix.
18 CHAPTER 2. QUANTITIES AND THEIR USE

• Because the symbol for the ∑ 2summation∑i2index is arbitrary,


∑i 2 it follows that fi1 +
fi1 +1 + fi1 +2 + · · · fi2 = ii=i f
1 i
= f
j=i1 j = k=i1 k We thus note that
f .
the summation index is arbitrary, but the summation boundaries i1 and i2 are
not arbitrary.
∑ ∑
• An interesting question is: how should we interpret the sum ii1 fi or ii=i1 fi ?
The problem here is that we have used the same symbol for the upper summa-
tion
∑i boundary ∑i and the ∑iindex. The only interpretation that makes sense is that
f i = f
1 i
= j=i1 fj = fi1 + fi1 +1 + fi1 +2 + · · · + fi . Because writing
∑ii1 ∑i=i
i
i1 fi or i=i1 fi may seem somewhat confusing (although the notation is
∑ ∑
correct!), communication is improved if we instead write ii1 fj or ij=i1 fj .

´
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.

• In some fields, e.g.,


´ theoretical physics,
´ the indefinite integral is sometimes
instead written as dxf (x), i.e., ´dx prepends the function. One could con-
ceptually also write the integral as x f (x), and let the lower bound x indicate
the integration variable. However, in these notes, we will use ´the standard
description where the function to be integrated is bracketed by and dx.
´ x2 ´ x2
• Similar to the case of summation, we have x=x f (x) dx = f (z) dz.
´x 1 ´z=x
x
1
Thus the integral x=x1 f (x) dx makes sense, and equals, e.g., ξ=x1 f (ξ) dξ.
Because the latter notation perhaps is clearer and communicates better, this
is the recommended form.

2.3.2.4 Mass vs mole basis


It is common to sometimes refer extensive variables to the total mass, the total
number of moles, or the total volume or some other length based quantity such as
extensive variable length, or surface area. To this end, we will use the following
operator notation for extensive quantity ε:

• ε̂: 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

Table 2.2: Some standard symbols as used in mechanics.


Symbol Quantity Symbol Quantity
t time W work
ℓ, w length, width F, G force, gravitational force
h, d, δ height, thickness p momentum
D, d, r diameter, radius µ friction number
x, y, z position E, K, P energy, kinetic energy, po-
tential energy
A, (S) area, (surface) Q heat
V volume η efficiency
α, β, γ,etc angle T torque
Ω solid angle I, J moment of inertia
m mass qm , ṁ mass flow
ρ density q, qV , V̇ volumetric flow
u, v, w, c velocity µ, (η) viscosity
ω angular velocity ν kinematic viscosity, µρ
a, g acceleration, a. due to gravity p pressure

2.3.2.5 Complex number operators

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.

• The imaginary part of complex number z is sometimes written as Imz; here


we will use the alternative standard notation ℑz; symbol ℑ is a special font/-
typesetting of character I.

2.3.3 Some standard symbols


It is useful to be aware of some of the standard symbols used for quantities in
physical based sciences. Table 2.2 lists some symbols for quantities in mechanics.
Table 2.3 lists some symbols for quantities in thermodynamics.
In these notes, we will give priority to mnemonic and systematic notation over
tradition. This will also allow us to avoid double meanings, e.g., U meaning both
internal energy and overall heat-transfer coefficient. Such a systematic notation
may, e.g., imply that we use the symbol n′′′ j to signify molar concentration instead
of the more common symbol cj . However, it is important to not take this systematic
approach too far. Also, in some cases, tradition will win in that we will use Q for
heat, although there is nothing in the word heat that is related to letter Q. Some of
the non-mnemonic symbols may originate from other languages than English, and
thus be mnemonic in the language of origin.
20 CHAPTER 2. QUANTITIES AND THEIR USE

Table 2.3: Some standard symbols as used in thermodynamics. Subscript j refers


to species j.
Symbol Quantity Symbol Quantity
T, Θ absolute temperature N number of particles
t, θ temperature NA Avogadro’s number
∆T, ∆Θ, ∆t temperature difference n number of moles, NNA
Q heat cj molar concentration of j
Q̇, Φ heat flow ρj specific concentration of j
U internal energy xj molar fraction of j
H enthalpy wj mass fraction of j
S entropy νj stoichiometric number of j
C total heat capacity µj chemical potential of j
h heat-transfer coefficient z charge number of ion
k thermal conductivity Dj diffusion coefficient for j
U overall heat-transfer coefficient

2.3.4 Symbols and computer notation


Although it is straightforward to use a systematic notation with single letter sym-
bols and indices in mathematical typesetting of documents, most programming lan-
guages require quantities to be described as a sequence of “flat” characters.10 Thus,
typically, a sequence of Latin letters from the English alphabet + Arab numbers
+ underscore “_” are normally allowed for, where a distinction is made between
minuscules (lower case letters) and majuscules (capital letters, upper case letters).
Furthermore, the first character normally has to be a letter, although some languages
allow for a sequence of underscores (e.g., Modelica).
Some languages have separate “operators” for differentiation, e.g., in Modelica
der(x) implies dx dt
; notice that operator der means time derivative, and is not a
general differentiation operator — the reason is the importance of time derivatives
in dynamic models.
In general, it is recommended to use a short and systematic translation of symbols
for variables in a mathematical typesetting, to the related computer notation. As
an example, dx dt
could be translated into dxdt, ẋ could be translated into xd, xi
could be translated into x_i, etc. Because there is no general agreed upon standard
for such a translation, each programmer should develop her/his own style, but it is
important to be systematic in order to make the computer code readable.

2.4 Units and Dimensions


2.4.1 Units. Dimensions
Old unit systems suffered from two weaknesses:
• units with the same name varied from one region to the next, and
10
Two exceptions: the modern scientific computer language Julia allows for Greek letters and
indices in variable names; the same is true for Python 3.
2.4. UNITS AND DIMENSIONS 21

Table 2.4: Some old Norwegian units of length.


English Norwegian Meaning
line linje possibly the width cut by a sharp weapon such as
sword or javelin = 1/12 inch
inch tomme “thumb”, the width of the thumb of a grown-up man
at the outermost finger joint
foot fot the length of a foot blade of a grown-up man from
heel to toe tip = 10/12 inches
cubit alen the length from the bowed elbow joint to the tip of
the middle finger of a grown-up man = 2 feet
yard skritt the normal step length = 3 feet
fathom favn the length from finger tip to finger tip of a grown-up
man standing with spread arms; equal to the height
of a grown-up man = 3 alen
“stone’s throw” steinkast as far as a grown-up man could throw a stone large
as a hand = 120 alen
“arrow’s shot” pilskudd as far as a grown-up man could shoot an arrow using
a standard bow = 4 steinkast
“quarter” fjerding a quarter of a rast = 4800 alen/4000 alen
“rest” rast the length that a person could walk before a rest was
called for = 4 fjerding

• subdivisions were not decimal, and it was difficult to do computations with


units.

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.

2.4.2 Dimensions and SI Units


The SI units consists of three classes of units: seven base units, two supplementary
units, and a number of derived units. In total, they form a coherent system of units.
In addition to the SI units, there are a number of out-of-system units which are still
used and thus are difficult to avoid.
The base SI units are given in Table 2.5: the physical quantity is given, together
with the dimension symbol, the unit name, and the unit symbol.
Here, it should in particular be observed that in the SI system, the use of letters
in the SI symbols is fixed, and that it is incorrect to change minuscules to majuscules,
and vice versa. In other words, it is incorrect to write, e.g., mole as Mol — even in
the start of a sentence. It is incorrect to write kelvin as k. And so on. For dimension
symbols, there is perhaps more variation.
A key observation is that all other SI units can be expressed from these 7 base
units. Likewise, all other dimensions can be expressed using these 7 base dimensions.
However, it is common to use more units, partially for readability. Table 2.6 gives
two supplementary SI units.
11
CGPM = Conférence Générale des Poids et Mesures.
2.4. UNITS AND DIMENSIONS 23

Table 2.5: The seven base SI units.


Physical quantity Dimension symbol SI unit SI symbol
Mass M kilogram kg
Length L meter m
Time T second s
Temperature Θ kelvin K
Amount of substance N mole mol
Electric current intensity I ampere A
Luminous intensity J candela cd

Table 2.6: The two supplementary SI units.


Physical quantity Dimension symbol SI unit SI symbol
Plane angle α radian rad
Solid angle Ω steradian sr

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.9: Three non-SI units defined through experiments.


SI unit SI symbol Physical quantity Dimension
electron volt eV energy, work ML2 T−2
faraday F molar electric charge ITN−1
unified atomic mass unit u, u.m.a. mass M

Table 2.10: Thirteen temporary non-SI units.


SI unit SI symbol Physical quantity Dimension Using base units
ångström Å length L 1 Å = 10−10 m
are a surface, area L2 1 a = 102 m2
bar bar pressure ML−1 T−2 1 bar = 105 Pa
barn b surface area L2 1 barn = 10−28 m2
curie Ci radioactivity T−1 1 Ci = 3.7 · 1010 Bq
gal Gal acceleration LT−2 1 Gal = 10−2 m s−2
hectare ha surface, area L2 1 ha = 104 m2
tonneau de – capacity, vol- L3 1 tonneau = 2.83 m3
jauge ume
nautical mile naut.mi length L 1 naut.mi = 1852 m
knot kn linear velocity LT−1 1852
1 kn = 3600 m s−1
rad rad absorbed dose L2 T−2 1 rad = 10−2 Gy
of radiation
rem rem dose equiva- L2 T−2 1 rem = 10−1 Sv
lent
röntgen R exposure M−1 IT 1 R = 2.58 · 10−4 C kg−1
26 CHAPTER 2. QUANTITIES AND THEIR USE

Table 2.11: Seventeen non-SI units to be discontinued/recommended to not use.


SI unit SI symbol Physical quantity Dimension Using base units

calorie (15 C) cal15 ◦ C energy, heat ML2 T−2 1 cal15 ◦ C = 4.1855 J
calorie (IT) calIT energy, heat ML2 T−2 1 calIT = 4.1868 J
2 −2
calorie calth energy, heat ML T 1 calth = 4.1840 J
(therm.)
carat (metric) ct mass M 1 ct = 2 · 10−4 kg
fermi F length L 1 F = 10−15 m
gamma (in- γ magnetic in- MT−2 I−1 1 γ = 10−9 T
duction) duction
gamma γ mass M 1 γ = 10−9 kg
(mass)
grade (gon) gr, g plane angle α 1 gr = 1 g = π/200 rad
kilogram- kgf force MLT−2 1 kgf = 9.80665 N
force
lambda λ capacity, vol- L3 1 λ = 10−9 m3
ume
micron µ length L 1 µ = 10−6 m
revolution rev plane angle α 1 rev = 2π rad
revolution per rpm angular veloc- αT−1 1 rpm = π/30 rad s−1
minute ity
standard atm pressure ML−1 T−2 1 atm = 101325 Pa
atmosphere
stère st capacity, vol- L3 1 st = 1 m3
ume
torr torr pressure ML−1 T−2 1 torr = 101325/760 Pa
X-unit XU length L 1 XU = 1.0023 · 10−13 m
2.4. UNITS AND DIMENSIONS 27

Table 2.12: Twenty SI prefixes.


Multiple Sub multiple
Prefix (ety- Symbol Multiply Prefix (ety- Symbol Multiply
mology) by mology) by
yotta Y 1024 deci (Latin dec- d 10−1
imus, tenth)
zetta Z 1021 centi (Latin c 10−2
centum, hun-
dredth)
exa E 1018 milli (Latin m 10−3
milli, thou-
sandth)
peta P 1015 micro (Greek µ 10−6
µικρoς, small)
tera (Greek T 1012 nano (Greek n 10−9
τ εραζ, mon- νανoζ, dwarf)
ster)
giga (Greek G 109 pico (Italian p 10−12
γιγαζ, giant) piccolo, small)
mega (Greek M 106 femto (Danish f 10−15
µεγαζ, big) femten, fifteen)
kilo (Greek k 103 atto (Danish at- a 10−18
κιλιoι, thou- ten, eighteen)
sand)
hecto (Greek h 102 zepto z 10−21
εκατ oν, hun-
dred)
deca (Greek da 10 yocto y 10−24
δεκa, ten)

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

Table 2.14: Modern computer science units as defined by International Electrotech-


nical Commission; 1 byte = 8 bit.
Unit Unit symbol Conversion Unit Unit symbol Conversion
factor factor
10
kibibyte KiB 2 byte kibibit Kib 210 bit
20
mebibyte MiB 2 byte mebibit Mib 220 bit
gibibyte GiB 230 byte gibibit Gib 230 bit
40
tebibyte TiB 2 byte tebibit Tib 240 bit
pebibyte PiB 250 byte pebibit Pib 250 bit
exbibyte EiB 260 byte exbibit Eib 260 bit
70
zebibyte ZiB 2 byte zebibit Zib 270 bit
yobibyte YiB 280 byte yobibit Yib 280 bit

This non-standard use of prefixes in computer science is unfortunate, and a new


standard has been introduced. The new standard is presented in Table 2.14, and it
is recommended to use this new standard instead of the one in Table 2.13.
Observe the system for naming prefixes: the two first letters from the SI prefixes in
Table 2.12 are used, followed by the string “bi” — indicating binary. The unit symbol
uses the single letter from the SI prefixes, but in capital letter, and followed by letter
“i”. Byte is indicated by capital “B”, while bit is indicated by lower case/minuscule
“b”.
Finally, it is useful to briefly discuss how to write (SI) units in computer code
— this is important when documenting the code. A standard recommended, e.g., in
the modeling language Modelica, is to include period “.” as a multiplication symbol,
and to use a positive or negative integer to indicate power. Thus, as an example:
2
10 kW is written as 10 kW, 1 H = 1 kgm s2 A2
is written 1 H = 1 kg.m2.s-2.A-2, etc.

2.5 Dimensionless Models


2.5.1 Why non-dimensional models?
As mentioned in the previous subsection, the SI system is a coherent system of
units. What does this mean? A coherent system of units implies that formulating
expressions among quantities leads to identical expressions among the units, when
the numeric value is eliminated. Consider kinetic energy
1
K = mv 2 ,
2
which is an expression among quantities energy, mass and linear velocity. In a
coherent system of units, dropping the numeric values should lead to an identical
expression among units, i.e.,
{K} = {m} {v}2 .
Furthermore, it is clear that in models involving equalities of expressions, e.g.,
y = f (x) + g (x) ,
2.5. DIMENSIONLESS MODELS 29

such an equation is only valid if


{f (x)} = {g (x)} :
we can only add and subtract expressions which have an identical overall dimension
and unit; furthermore
{y} = {f (x)} = {g (x)} :
we can only equate expressions which have identical overall units.
Because quantities in general should have units that are expressed by multi-
plication between base units, and base units raised to an integer power, this has
important consequences. If the expression involves an algebraic function13 , there is
no problem. However, if the expression instead involves a transcendental function14
such as trigonometric functions, logarithmic functions, etc., this creates problems.
Assume that we have the following relationship between x, k and y:
y = k sin x.
With a coherent unit system,
{y} = {k} sin {x} .
From this, it follows that unless the argument of the transcendental function is non-
dimensional (unit free), it is impossible to ensure that the unit of y and/or k can
be expressed as the multiplication of base units and base units raised to an integer
power. This is easily illustrated by a case where, e.g., {x} is m; then {y} and {k}
are related as
{y} = {k} sin m
— which breaks a standard rule for units.
In summary: good models involving transcendental functions should ensure that
the arguments of all transcendental functions in the expression are non-dimensional
— and thus unit free. How can this be achieved? Suppose again that we start with
the basic hypothesis of a model
y = k sin x.
What if we scale the argument of the transcendental function, and instead write the
expression as (x)
y = c sin ς
x
where x and xς have identical dimensions — and for practical purposes even identical
units? In that case, x̄ = xxς is non-dimensional, and the units are related as
{x}
{y} = {c} sin ς = {k} ,
x
13
In mathematics, an algebraic function is a function that can be expressed using a finite number
of terms, involving only the algebraic operations addition, subtraction, multiplication, division, and
raising to a fractional power. An algebraic function in one variable x is 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.
14
A function that is not algebraic is called a transcendental function.
30 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

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.

2.5.2 Buckingham’s Π-theorem+


Suppose that we have a model/relationship between quantities qj , j ∈ {1, . . . , nq },
( )
f q1 , q 2 , . . . , q n q = 0 (2.1)
where quantity qj has unit {qj }. Instead of restricting the discussion to units, let us
consider the slight abstraction of dimension, where quantity qj has dimension [qj ].
If q1 is mass, then [q1 ] = M, see Table 2.5. Why is the idea of dimension useful?
Because we know that [q1 ] = M (in our example of q1 being mass), whereas the unit
{q1 } is non-unique: it can be kg, g, mg, etc. And if we go outside of the SI system,
the dimension is still unique, whereas we have even more units to choose among.
According to Buckingham’s Π-theorem, we can introduce non-dimensional vari-
ables πj and find an equivalent relationship to Eq. as
F (π1 , π2 , . . . , πnπ ) = 0 (2.2)
where nπ ≤ nq .
We have seen that within the SI system, we have 7 base units with their corre-
sponding 7 base dimensions. Let us denote these base dimensions by ∆j ; thus the
number of base dimensions is n∆ = 7.
The basic idea of a coherent unit system can be described as follows:
2.5. DIMENSIONLESS MODELS 31

1. Any quantity qj has a dimension described as a product of dimensions raised


to (positive or negative) integers, in other words:
ℓ ℓ ℓn
∀j : [qj ] = ∆11j ∆22j · · · ∆n∆∆
j
(2.3)

where ∀j means “for all j”, ℓij is a positive or negative integer, and n∆ = 7.15

2. We can create a non-dimensional quantity π as


mnq
π = q1m1 q2m2 · · · qnq (2.4)

where mj are integers, and for a coherent unit system,


[ ]mnq
[π] = [q1 ]m1 [q2 ]m2 · · · qnq . (2.5)

Theorem 2.1. Let matrix L be defined as (Eq. 2.3)


 
ℓ11 ℓ12 ··· ℓ1nq
 ℓ21 ℓ22 ··· ℓ2nq 
 
L =  .. .. .. .. ,
 . . . . 
ℓn∆ 1 ℓn∆ 2 · · · ℓn∆ nq

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)
.

Proof. By inserting Eq. 2.3 into Eq. 2.5, we get


( ) ( ) ( ℓ )
ℓn∆ 1 m1 ℓn∆ 2 m2 ℓ2nq ℓn∆ nq mnq
[π] = ∆1 ∆2 · · · ∆n∆
ℓ11 ℓ21
∆1 ∆2 · · · ∆n∆
ℓ12 ℓ22
· · · ∆1 ∆2 · · · ∆n∆
1nq


ℓ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

ℓ11 m1 + ℓ12 m2 + · · · ℓ1nq mnq = 0


ℓ21 m1 + ℓ22 m2 + · · · ℓ2nq mnq = 0
..
.
ℓn∆ 1 m1 + ℓn∆ 2 m2 + · · · ℓn∆ nq mnq = 0,
15
It is useful to write n∆ in case more base dimensions are introduced.
32 CHAPTER 2. QUANTITIES AND THEIR USE

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

[∆p] = ML−1 T−2 = M1 L−1 T−2


[ρ] = ML−3 = M1 L−3 T0
[v] = LT−1 = M0 L1 T−1
[µ] = ML−1 T−1 = M1 L−1 T−1
[D] = L = M0 L1 T0
[L] = L = M0 L1 T0 .

It follows that matrix L is given as


 
1 1 0 1 0 0
L =  −1 −3 1 −1 1 1  .
−2 0 −1 −1 0 0

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.

1 In [1]: runfile ( ’ C :/ Users /.../ PyModelica / buckinghamPI -


PipeFlow . py ’ , wdir = ’ C :/ Users /.../ PyModelica ’)
2 [ Matrix ([
3 [ -1/2] ,
4 [ 1/2] ,
5 [ 1] ,
6 [ 0] ,
7 [ 0] ,
8 [ 0]]) , Matrix ([
9 [1/2] ,
10 [1/2] ,
11 [ 0] ,
12 [ -1] ,
13 [ 1] ,
14 [ 0]]) , Matrix ([
15 [1/2] ,
16 [1/2] ,
17 [ 0] ,
18 [ -1] ,
19 [ 0] ,
20 [ 1]]) ]

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

If we choose the transformation matrix T = 2 · I, we get


   
− 12 1
2
1
2
−1 1 1
 1 1 1  1 1 1 
 2 2 2  
 1 0 0   2 0 0 
M = BT = 

·2=
 
.
 0 −1 −1   0 −2 −2 

 0 1 0   0 2 0 
0 0 1 0 0 2
2.5. DIMENSIONLESS MODELS 35

We see that we have 3 non-dimensional quantities π:


ρv 2
π1 = ∆p−1 · ρ1 · v 2 · µ0 · D0 · L0 =
∆p
∆pρ
π2 = ∆p1 · ρ1 · v 0 · µ−2 · D2 · L0 = 2 D2
µ
∆pρ
π3 = ∆p1 · ρ1 · v 0 · µ−2 · D0 · L2 = 2 L2 ;
µ
these quantities are non-dimensional:
( )2
[ρ] [v]2 ML−3 LT−1
[π1 ] = = =1
[∆p] ML−1 T−2
[∆p] [ρ] 2 ML−1 T−2 ML−3 2
[π2 ] = [D] = ( )2 L = 1
[µ]2 ML−1 T−1
[∆p] [ρ] 2 ML−1 T−2 ML−3 2
[π3 ] = [L] = ( )2 L = 1.
[µ]2 ML−1 T−1
We have thus found that a model
f (∆p, ρ, v, µ, D, L) = 0
has an equivalent description
F (π1 , π2 , π3 ) = 0

( 2 )
ρv ∆pρ 2 ∆pρ 2
F , D , 2 L = 0.
∆p µ2 µ
Thus, instead of varying all 6 original variables ∆p, ρ, v, µ, D, L to find the mapping
f (·) = 0, we can instead vary the 3 non-dimensional groups π1 , π2 , π3 and find the
mapping F (·) = 0.
Because we can choose T freely (as long as it is invertible...), this answer is not
unique. Suppose we choose T as follows:
 1 1   
−2 2 1
2
1 0 0
 1 1 1    −1 1 0 
 2 2 2  −2 1 0  
 1 0 0   −2 1 0 
M = BT =   0 1 −1  =  .
0 −1 −1  0 −1 0 
  0 0 1  
 0 1 0   0 1 −1 
0 0 1 0 0 1
Now the non-dimensional quantities (non-dimensional groups) become
∆p
π1′ = ∆p1 · ρ−1 · v −2 · µ0 · D0 · L0 =
ρv 2
ρvD
π2′ = ∆p0 · ρ1 · v 1 · µ−1 · D1 · L0 =
µ
L
π3′ = ∆p0 · ρ0 · v 0 · µ0 · D−1 · L1 = .
D
36 CHAPTER 2. QUANTITIES AND THEIR USE

We see that we have an alternative description for F (π1′ , π2′ , π3′ ) = 0:


( )
∆p ρvD L
F , , = 0.
ρv 2 µ D

This latter one is the one that is normally used. N


We see that we have infinitely many choices for non-dimensional quantities, and
it may be difficult to decide which choice is best. One strategy could be to choose
T such that M has only integers, while the norm of each column of M is as small as
possible. Alternatively, choose T such that M has only integers while each column
of M has as many zeros as possible.
A final comment: some common non-dimensional groups occur in many different
models, e.g., the group
ρvD
π2′ = (2.7)
µ
in the last suggestion of T . This particular non-dimensional group is known as the
Reynolds number. In much of the literature, the symbol for the Reynolds number
is Re. However, this symbol breaks with the idea that quantities should have single
letter symbols. In addition, it can be confused with the operator for taking the real
part of complex numbers. Here, we will use the symbol NRe for Reynolds’ number.
Many dimensionless numbers with a physical interpretation have been introduced
in science and engineering, see Table 2.15for a partial list (Rohsenow et al. 1998).

Table 2.15: Some dimensionless numbers commonly used


in science and engineering. In Eq. 2.7, symbol D is
used to denote characteristic length/diameter. Below,
D denotes (binary) diffusion coefficient, while L denotes
characteristic length.

Number Symbol Definition Interpretation — Use


hL
Biot number NBi ks
Ratio of internal solid thermal
resistance to fluid thermal
resistance — Fluid-solid heat
transfer
hD L
Biot number NBiD D
Ratio of internal to boundary
(mass transfer) layer species transfer resistance
— Fluid-solid mass transfer
2
v∞
Eckert number NEc ĉp (Tw −T∞ )
Ratio of flow kinetic energy to
boundary layer enthalpy
difference — Forced convection
(compressible flow)
∆p
Euler number NEu ρv 2
Ratio of friction to velocity head
— Fluid friction
τw
Fanning’s f K ′′′
Ratio of surface shear stress to
friction factor volumetric kinetic energy —
Flow resistance
2.5. DIMENSIONLESS MODELS 37

Dimensionless numbers commonly used in science and


engineering (continued).

Number Symbol Definition Interpretation — Use


v2
Froude number NFr gL
Ratio of inertial to gravitational
force — Wave phenomena
Graetz number NGz NRe NPr D
L
Ratio of fluid stream thermal
capacity to convective heat —
Forced convection transfer
ρ2 gL3 αp ∆T
Grashof number NGr µ2
Ratio of buoyancy to viscous
forces — Natural convection
2/3
Coulburn j NjH NSt NPr Dimensionless heat transfer
factor (heat coefficient — Forced convection
transfer)
2/3
Coulburn j NjD NStD NSc Dimensionless mass transfer
factor (mass coefficient — Forced convection
transfer)
hL
Nusselt number NNu k
Dimensionless convective heat
transfer coefficient — Convective
heat transfer
Péclet number NPe NRe NPr Dimensionless independent heat
transfer parameter — Forced
convection
Péclet number NPeD NRe NSc Dimensionless independent mass
(mass transfer) transfer coefficient — Mass
transfer
µĉp
Prandtl number NPr k
Ratio of molecular momentum to
thermal diffusivities — Forced
and natural convection
Rayleigh NRa NGr NPr Modified Grashof number —
number Natural convection
ρvL
Reynolds NRe µ
Ratio of inertia to viscous forces
number — Dynamic similarity
µ
Schmidt number NSc ρD
Ratio of molecular momentum
and mass diffusivities — Mass
transfer
hD L
Sherwood NSh D
Ratio of convection mass transfer
number to diffusion in slab of thickness L
— Convective mass transfer
NNu
Stanton number NSt NRe NPr
Dimensionless heat transfer
coefficient — Forced convection
NSh
Stanton number NStD NRe NSc
Dimensionless mass transfer
(mass transfer) coefficient — Convective mass
transfer
38 CHAPTER 2. QUANTITIES AND THEIR USE

Dimensionless numbers commonly used in science and


engineering (continued).

Number Symbol Definition Interpretation — Use


ρv 2 L
Weber number NWe σ
Ratio of inertia force to surface
tension force — Droplet breakup

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

tradition, in a multidisciplinary course it is also necessary to take some liberty wrt.


choice of symbols for variables.
The SI units are consistent, and a systematic/good choice for units in a system.
However, the rate of change of dependent variables is also important: if it takes 2
months to fill a hydro power magazine with water, it is somewhat inconvenient to
use the SI unit seconds for the time. Thus, some liberty to use convenient units
must be used. The dimension of a quantity constitutes an abstraction of units, and
is independent of the actual choice of unit system. Models/equations need to be
consistent both wrt. dimensions, and more specifically wrt. units.
The requirement for dimensional consistency has far reaching consequences, and
can, e.g., be used via the Buckingham Π-theorem to reduce the structure of models
to be relations between dimensionless groups — with very little detailed knowledge
about the system/model.

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.1. Consider constants π, g (acceleration of gravity), L (length of a


beam), A (cross sectional area of a tank). Explain which of these are “natural
constants” and which are “parameters”. For simulation purposes, what is the reason
for making this distinction. N

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.3. Consider µ which is the viscosity of a fluid. Could µ be considered


a variable? If so, is it an independent variable or a dependent variable? 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

Exercise 2.7. Let V be volume of a fluid. What is the meaning of V̇ ′′ in this


document? N

Exercise 2.8. Let V be volume. What is the dimension of V , [V ]? Is the dimension


unique? N

Exercise 2.9. Let V be volume. Give a unit of V , {V }. Is the unit unique? N


40 CHAPTER 2. QUANTITIES AND THEIR USE

Exercise 2.10. If you have a model

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.

Problem 2.1. [Solution E.1 p. 589] Units

Find examples of old units of length from your own culture/background.


Hint: Cardarelli (1999) discusses the following systems from antiquity: the
Chinese system, the Indian system, the Egyptian system, the Assyrio-Chaldean-
Persian system, the Hebrew system, the Greek (Attic) system, the Roman system,
the Arab system. In addition, Cardarelli discusses the Old French system (ancien
régime), the Old French system (1812–1840), the Old Italian system, the Old Spanish
system (Castillian), the Old Portuguese system, the Old Dutch system, the Old
German system (Prussian), the Old Russian system, the Old Swedish system, and
the Old Japanese system. N

Problem 2.2. [Solution E.2 p. 589] Pressure loss in pipe

Consider a pressure loss ∆p in a pipe of length L and diameter D. The material


flowing in the pipe has velocity v, density ρ, and viscosity µ. Assume that all these
quantities affect the pressure loss such that we have a function
( )
L
∆p = f ρ, v, µ, D, .
D
L
Use base dimensions M , L and T . Notice that here, D
is already a dimensionless
group.

1. Set up a list of (dimensional) quantities q for this model.

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.)

5. Propose a couple of alternative sets of dimensionless groups, (π1 , π2 ). (Hint:


L
π3 = D is a third dimensionless group.)
2
6. Show that π1 = ∆p·ρ
µ2
D2 and π2 = ρv ∆p
are two possible dimensionless groups
for the system, implying that the model can be simplified to
( )
∆p · ρ 2 ρv 2 L
F (π1 , π2 , π3 ) = F D , , = 0.
µ2 ∆p D

7. Show that π̄1 = ρvDµ


is an alternative dimensionless group to π1 , leading to the
alternative relation ( )
ρvD ρv 2 L
F̄ , , = 0.
µ ∆p D

Assume that F̄ (π̄1 , π2 , π3 ) = 0 can be inverted wrt. π2 , leading to π2 = F̃ (π̄1 , π3 ).


What is the resulting expression for ∆p? N
Remark 2.2. The dimensionless group π̄1 = ρvD
µ
occurs frequently in physics, and
is known as the Reynolds number. In this document, we use symbol NRe for this
dimensionless group. N

Problem 2.3. [Solution E.3 p. 589] Agitation of liquid tanks.

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. Introduce the necessary dimensions for the problem.

2. Using Buckingham’s Π-theorem, show that the power consumption can be


described by the relationship

π1 = F (π2 )

where


π1 =
ρDi5 ṅ3i
ρṅi Di2
π2 = = NRe .
µ
N

Problem 2.4. [Solution E.4 p. 589] Turbo machines.


42 CHAPTER 2. QUANTITIES AND THEIR USE

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.

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 four basis vectors.)

5. Show that the following set of dimensionless groups satisfies the null space:
gH
π1 = = head coefficient
n2 D 2

π2 = = volumetric flow coefficient
nD3
ρnD2
π3 = = Reynold number NRe
µ
D
π4 = = ratio between diameter and “heat”.
H

6. Explain under what condition

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

Consider the diffusion equation


∂T ∂ 2T
ρcv =k 2
∂t ∂z
where ρ is density, cv is heat capacity at constant volume, T = T (t, z) is tempera-
ture, t is time, k is diffusion constant, and z is spatial location. Together with this
partial differential equation (PDE), we assume the initial condition T (t = 0, z) =
T0 (z). Thus it makes sense to postulate that the solution is a relation

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.

Under what condition can we conclude that there is a mapping

π2 = F̃ (π1 ) ?

7. Show that one possible set of dimensionless groups is


z
π1 = √
k
ρcv
t
T
π2 = .
T0

8. With the suggested set of dimensionless groups, we find that

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

Models and Model Solution†

3.1 Learning goals


After working through this chapter, a basic understanding of how scientific comput-
ing relates to model development and simulation should be acquired, see also Linge
& Langtangen (2016) for an introduction.1 The following concepts are covered.
• What model types are relevant in systems modeling?

• What are the basic properties and solution methods for algebraic equations?

• What are the basic ideas for solving ordinary differential equations?

• How is interpolation used in systems modeling?

• How can partial differential equations be reduced to a set of ordinary differ-


ential equations?

• What are the advantages and disadvantages of various scientific computation/-


modeling/simulation tools?

3.2 Model Types


The simplest models in engineering are of type

y = ax + b

or more general polynomial mappings


N
y= cj x j .
j=0

The concept of polynomials can be generalized to multivariate polynomials where


x ∈ Rn and the basis functions (replacing xj ) are linear combinations of all possible
1
The chapter title is marked with the † symbol to indicate that this is mainly an overview
chapter.

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

— or the integrated form


ˆ t
x (t1 ) − x (t0 ) = f (x, u) dt,
t0

then the model can be used with random


´ t1 input u. And if the mapping f (x, u) is
such that there is an assurance that t0 f (x, u) dt is maintained within the rational
numbers, then the integrated form can probably also be used for such variables.
In general, models in integrated form can be written as

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

with boundary conditions



∂T
=0
∂r r=0
T |r=R = Tm

(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̄.

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
.

Thus, we have rearranged the model into the form


( ) ( )2
∂ T̄ ∂ T̄ 1 ∂ ∂ T̄ ∂v̄
+ v̄ = −π1 r̄ + π2
∂ t̄ ∂ z̄ r̄ ∂r̄ ∂r̄ ∂r̄
50 CHAPTER 3. MODELS AND MODEL SOLUTION†

which is in dimensionless form, with


kL
π1 =
ρcv R2 v ς
µL
π2 = .
cv Tmς R
The boundary conditions become

∂ T̄
=0
∂r̄ r=0

T̄ r=R = T̄m .
One use of models in dimensionless form is that if they are scaled properly such
that the dimensionless variables typically vary in the interval [0, 1], the numeric
values of the dimensionless groups, e.g., π1 and π2 , say something about the relative
importance of the terms in the model. Thus, models in dimensionless form can be
used for further simplifying the model by neglecting insignificant terms.
Above, we chose to make the model completely dimensionless, even with di-
mensionless time t̄. In some systems, the typical time duration is naturally in the
order of 1 (unity), and for models in those fields, one may choose to not make time
dimensionless. A typical example is in electrical power engineering. Models that
are dimensionless except for the time variable are sometimes referred to as per unit
models.
Models of complex systems are composed of a multitude of sub-models. For such
composed systems, it is necessary that shared variables, e.g., time, either are dimen-
sional, or are scaled with the same scaling factor. Thus, models in dimensionless
form are somewhat inconvenient for simulation.

3.3 Algebraic Equations


3.3.1 Linear equations
Linear scalar equations are of form
ax = b
and can be solved if a ̸= 0. Multivariable linear equations can be formulated as the
matrix equation
Ax = b.
If the only unknowns in the model are x, then matrix A must be square and have
full rank in order to admit a solution. In this case, A can be inverted, and the
solution written as x = A−1 b. In practice, the solution is found by writing matrix A
as the product of two matrices L and U , A = LU , where L is lower triangular with
unit elements on the main diagonal2 and U is upper triangular. LU is known as the
LU factorization of matrix A. Thus
Ax = b ⇒ LU x = b.
2
Lower triangular implies that all elements above the main diagonal are zero.
3.3. ALGEBRAIC EQUATIONS 51

Next, introduce z = U x, such that the equations become

Lz = b.

Due to the structure of L, this implies

z1 = b1
ℓ2,1 z1 + z2 = b2
ℓ3,1 z1 + ℓ3,2 z2 + z3 = b3
..
.

n−1
ℓn,j zj + zn = bn .
j=1

Now zj can be found recursively: z1 is already found, z2 = b2 − ℓ2,1 z1 , z3 = b3 −


ℓ3,1 z1 − ℓ3,2 z2 , etc. With z found this way, we then use the structure of U in the
equation U x = z, which implies:

u1,1 x1 + u1,2 x2 + · · · + u1,n xn = z1


u2,2 x2 + u2,3 x3 + · · · + u2,n xn = z2
..
.
un−1,n−1 xn−1 + un−1,n xn = zn−1
un,n xn = zn .

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

1 runfile ( ’C :/ Users /.../ PyModelica / factorLU . py ’ , wdir = ’C :/ Users


/... PyModelica ’)
2 P:
3 [[ 0. 1.]
4 [ 1. 0.]]
5 L:
6 [[ 1. 0. ]
7 [ 0.33333333 1. ]]
8 U:
9 [[ 3. 4. ]
10 [ 0. 0.66666667]]
thus ( ) ( )( )( )
1 2 0 1 1 0 3 4
A= = 1 .
3 4 1 0 1 0 23
| {z }| {z }| {z }
3
P L U

If we have a DAE of the special form

dx
= f (x, y, u)
dt
Ax + By = b

we can rearrange this into

dx
= f (x, y, u)
dt
By = b − Ax

and solve the equation


By = b̃ = b − Ax
where we this time take the LU factorization of B, and B must be square and of
full rank (invertible).
Other factorizations may also be useful, e.g., QR factorization Strang (1998).
For numerical algorithms, see Golub & Van Loan (2013).

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.,

xn + a1 xn−1 y + a2 xn−2 y 2 + · · · an y n + b1 xn−1 + b2 xn−1 y + · · · + · · · + c = 0

— 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.

3.3.3 Nonlinear scalar equations


3.3.3.1 Introduction
We consider the problem of finding x ∈ R that satisfies

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.

3.3.3.2 Successive Substitution


The problem at hand can be reformulated as follows

f (x) = 0 ⇒ k · f (x) = 0 ⇒ x = k · f (x) + x,


| {z }
g(x)
54 CHAPTER 3. MODELS AND MODEL SOLUTION†

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 ) .

3.3.3.3 Linear approximation methods


Working directly with the original equation f (x) = 0, the linear approximation
between (x0 , f (x0 )) and (x1 , f (x1 )) can be written as
x − x1
h (x) = f (x1 ) − (f (x1 ) − f (x0 )) ,
x0 − x1
and we compute x2 as
x2 − x1 x1 − x0
h (x2 ) = 0 ⇒ f (x1 )− (f (x1 ) − f (x0 )) = 0 ⇒ x2 = x1 − f (x1 ) .
x0 − x1 f (x1 ) − f (x0 )
The iteration scheme is thus
xn−1 − xn−2
xn = xn−1 − f (xn−1 ) , (3.3)
f (xn−1 ) − f (xn−2 )
and two initial guesses x0 and x1 are needed to start the method.
With arbitrary choices of x0 and x1 — preferably bracketing values such that
signf (x0 ) · signf (x1 ) < 0 — this is known as the secant method. The method
converges faster than successive substitution and may work for cases where successive
substitution does not work, but there is no guarantee of convergence.
A slight modification is the Wegstein method, where only x0 is chosen freely, and
then x1 is computed by substitution,
x1 = x0 + f (x0 )
or other variants. After this, the secant scheme in Eq. 3.3 is used.
Another related method is the regula falsi (false position) method. With regula
falsi, x0 and x1 are required to bracket the solution. After x2 has been computed,
x2 replaces either x0 if signf (x2 ) = signf (x0 ), or else it replaces x1 . Then x3 is
computed from x2 and one of the values (x0 , x1 ), etc. Regula falsi is slower than
secant method, but perhaps more reliable in that the solution is always bracketed.
3.3. ALGEBRAIC EQUATIONS 55

3.3.3.4 Other approximation methods


An obvious refinement of the linear approximation methods would be to use 3 points,
and approximate f (x) by a second order polynomial going through these points.
This would give rise to 2 solutions, and one should probably choose xn as the solu-
tion that makes f (xn ) closest to 0. But this algorithm could get too complicated for
practical use, without improving convergence sufficiently compared to other meth-
ods.
Ridder’s method is a different type of modification of regula falsi Kiusalaas
(2010). Starting with x0 and x1 which brackets the solution, compute the mid-
point x2 :
x0 + x1
x2 = .
2
Next, introduce a new, parameterized function g (x; α)

g (x; α) = f (x) · exp (α (x − x0 )) .

Here, x0 , x1 and x2 are equally spaced, with ∆x = x1 −x 2


0
. Parameter α is now chosen
such that g (x0 ; α), g (x1 ; α) and g (x2 ; α) line on a straight line. In order for these
points to lie on a straight line, it is necessary that
g (x0 ; α) + g (x1 ; α)
g (x2 ; α) = .
2
We find

g (x0 ; α) = f (x0 )
g (x1 ; α) = f (x1 ) · exp (α · 2∆x)
g (x2 ; α) = f (x2 ) · exp (α · ∆x) .

In order to lie on a straight line, we have to require


g (x0 ; α) + g (x1 ; α)
g (x2 ; α) =
2

f (x0 ) + f (x1 ) · exp (α · 2∆x)
f (x2 ) · exp (α · ∆x) = .
2
Because exp (α · 2∆x) , (exp (α · ∆x))2 , this can be rearranged into a quadratic
equation in exp (α · ∆x):

f (x0 ) + f (x1 ) · (exp (α · ∆x))2


f (x2 ) · exp (α · ∆x) =
2

0 = f (x1 ) · (exp (α · ∆x))2 − 2f (x2 ) · exp (α · ∆x) + f (x0 )


f (x2 ) ± f 2 (x2 ) − f (x0 ) f (x1 )
exp (α · ∆x) = .
f (x1 )
56 CHAPTER 3. MODELS AND MODEL SOLUTION†

It is too complicated to solve g (x; α) = 0, so instead we solve the linear approx-


imation of g (x; α) = 0 between points (x0 , g (x0 )) and (x2 , g (x2 )), leading to
x2 − x0
x 3 = x2 − g (x2 )
g (x2 ) − g (x0 )

x2 − x0
x 3 = x2 − f (x2 ) · exp (α · ∆x)
f (x2 ) · exp (α · ∆x) − f (x0 )
x2 − x0
= x2 − f (x2 ) .
f (x2 ) − exp(α·∆x)
f (x0 )

Here, some manipulation leads to


f (x0 ) f (x )
f (x2 ) − = f (x2 ) − √ 2 0 = ···
exp (α · ∆x) f (x2 )± f (x2 )−f (x0 )f (x1 )
f (x1 )

= ± f 2 (x2 ) − f (x0 ) f (x1 ).

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.

3.3.3.5 Newton’s method


Newton’s method is based on solving the original problem

f (x) = 0

with initial guess x0 , by first creating the linear approximation of f (x) at x0 ,3



df
g (x) = f (x0 ) + (x − x0 ) ,
dx x=x0

and then finding x1 from solving g (x) = 0. This leads to



df f (x0 )
0 = f (x0 ) + (x1 − x0 ) ⇒ x1 = x0 − df .
dx x=x0
dx x=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.

3.3.3.6 Homotopy Continuation


Homotopy is the continuous transformation between two functions f (x) and g (x),
e.g.,
h (x, λ) = λf (x) + (1 − λ) g (x) .
Suppose we need to solve f (x) = 0, and that we know the solution x0 to g (x).
It follows that the solution to h (x, 0) is x0 , while the sought solution f (x) = 0 is
identical to the solution of h (x, 1). Homotopy continuation can be considered as
solving
h (x, λn ) = 0
when h (x, λn−1 ) is known. Thus, we know that h (x, 0) = 0 has solution x0 . Next,
we try to find the solution of
h (x, ∆λ) = 0
where ∆λ is a small number. For reasonable functions, this solution will be close to
x0 , and using one of the above methods should quickly lead to the next iterate x1 .
Next, increase λ to 2∆λ and solve

h (x, 2∆λ) = 0

which should be close to x1 , etc.


We see that the homotopy continuation method involves two iteration loops, one
internal loop to search for xn when λn is given and xn lies close to xn−1 , and one
external loop to update λ to λn+1 .
One potential way to handle homotopy continuation is to reformulate this pro-
cedure into an initial value ODE. Thus,

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.

3.3.4 Systems of nonlinear equations


Often, we need to consider systems of AEs, i.e., equations of form
f (x) = 0
where f : Rn → Rn . It may be possible to extend methods such as successive substi-
tution. However, it is common to use extensions of Newton’s method to multivariate
problems. The Taylor series expansion can still be written as

∂f ( 2)
f (x) = f (xn−1 ) + (x − x ) + O (x − x ) ,
∂x x=xn−1
n−1 n−1

where now J , ∂f∂x


∈ Rn×n is the Jacobian matrix of vector function f (x). We use
the linear approximation
g (x) = f (xn−1 ) + Jx=xn−1 (x − xn−1 )
3.4. ORDINARY DIFFERENTIAL EQUATIONS 59

and choose xn such that g (xn ) = 0. This leads to the multivariable equation

Jx=xn−1 (xn − xn−1 ) = −f (xn−1 ) .

Assuming that the Jacobian Jx=xn−1 is invertible, we find


−1
xn = xn−1 − Jx=xn−1
f (xn−1 ) ,

which is the multivariable Newton method.


If it is difficult to compute the analytic Jacobian, using a numeric approximation
of the Jacobian is known as the (multivariable) Quasi-Newton method.
In order to improve convergence, the following idea is often used. Change the
iteration into a two step procedure:

1. The modified Newton method is written as

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.

2. In the second step, we consider the problem as a scalar minimization problem


and choose ω = minω arg ∥f (ω; sN )∥ where ∥·∥ is some vector norm.

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.

3.4 Ordinary Differential Equations


3.4.1 Overview
Differential equations in state space form can be expressed as
dx
= f (x, u; t) .
dt
Here, we consider initial value problems, i.e x (t0 ) together with u (τ ), τ ∈ [t0 , t1 ]
and we seek the solution x (t) for t ∈ [t0 , t1 ].
In order to solve differential equations, they must first be discretized and con-
verted to algebraic equations (AEs). The most common methods for discretization
involve recursive algorithms. An important requirement for discretization is that
the solution of the discretized system is as similar to the solution of the original
differential equation as possible. A problem in this respect, that in general it is not
60 CHAPTER 3. MODELS AND MODEL SOLUTION†

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).

3.4.2 The Explicit Euler method


We denote x (t0 ) by x0 . Because u (τ ) is known for all relevant τ , u (t0 ) = u0 is
known. At t0 , we thus have

dx
= f (x0 , u0 ; t0 ) .
dt t=t0

We now postulate that we can approximate dx as follows,
dt t=t0

x1 − x0 dx
≈ ,
h dt t=t0
where x1 = x (t0 + h). The result is an algorithm for finding x1 :
x1 − x0
≈ f (x0 , u0 ; t0 )
h

x1 = x0 + h · f (x0 , u0 ; t0 )
where ≈ has been changed to = simply because an algorithm can not use the ap-
proximation symbol. We see that as long as f (·) is known together with x0 , u0 , t0
and h, we can compute x1 . This algorithm can be made recursive as
xn = xn−1 + h · f (xn−1 , un−1 ; tn−1 ) (3.4)
and xn ≈ x (t0 + n · h). In principle, we could also vary h with n, and thus replace
h with hn−1 and xn with ( )
∑n
xn ≈ x t0 + hi−1 .
i=1
This algorithm can alternatively be developed by writing the ODE in integral
form: ˆ x1 ˆ t0 +h
dx = f (x, u; t) dt ⇒ dx = f (x, u; t) dt.
x0 t0

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

If h is reasonably small, we have


f (x (τ ) , u (τ ) ; τ ) ≈ f (x0 , u0 ; t0 ) .
Thus, we have arrived at the Euler method, or more precisely the Explicit Euler
method as described in Eq. 3.4. The reason why it is called the explicit Euler method,
is that it gives an explicit expression for computing xn from known information —
xn−1 , un−1 , tn−1 , h and f (·). The method is sometimes also called the Euler forward
method. However, as we will see, this name is slightly inaccurate.
Normally, ODE solver algorithms are analyzed based on a scalar, linear model:
dx
= λx
dt
x (t = 0) = x0
where λ is constant, and x0 is assumed known. This linear model can be solved with
the analytic solution
x (t) = exp (λt) x0 .
Such a model is said to be stable if λ < 0, and unstable if λ > 0. The case of an
unstable model is not that interesting, because the numeric value will go to infinity
rapidly — in engineering, we are much more interested in stable systems.
If we use the Explicit Euler method to solve the model, we get
xn = xn−1 + h · λxn−1 = (1 + h · λ) xn−1 .
This recursive algorithm generates a geometric sequence x0 , x1 , x2 , etc. because
xn
= 1 + h · λ is a constant number. It is well known that geometric series converge

xn−1
n
if xxn−1 < 1, thus the solution from the Explicit Euler method will converge if

|1 + h · λ| < 1 ⇒ (1 + h · λ < 1) ∧ (−1 − h · λ < 1) .


From the first condition:
1 + h · λ < 1 ⇒ h · λ < 0 ⇒ h > 0.
The reason why we have changed the direction of the inequality in the last step, is
that we have divided by λ < 0. This condition is trivial — it simply states that we
need to have a positive step length in the time variable. From the second condition:
2
−1 − h · λ < 1 ⇒ −h · λ < 2 ⇒ h < .
−λ
This basically implies that in order for the solution to converge to a steady value,
there is a limit to how big h can be.
Here it is important to realize that convergence does not imply that the discrete
sequence generated from the Explicit Euler method in any way is similar to the real,
2
analytic solution. Typically, if h is very close to −λ , the sequence will oscillate —
which does not occur in the analytic solution when λ < 0. As a rule of thumb, it is
common to choose
2
h= ·ε
−λ
62 CHAPTER 3. MODELS AND MODEL SOLUTION†
{ 1}
where ε typically is ε ∈ 15 , 10 — in order to achieve convergence and good sim-
ilarity between the solution found by the Explicit Euler method and the analytic
solution.
If we have a multivariable problem of form
dx
= Ax
dt
where x ∈ Rn , then this system has n eigenvalues λi ∈ C. In that case, we need to
re-consider the requirement for h. We still require that

|1 + hλ| < 1,

but this time λ ∈ C.


Introduce w , 1 + hλ √ ∈ C, thus convergence requires that |w| < 1. With
w = exp (j · θ) where j = −1 and θ is an angle in radians, Euler’s formula for
complex numbers gives w = exp (j · θ) = sin θ + j cos θ. It follows that |w| =
sin2 θ + cos2 θ = 1. Thus, by tracing θ ∈ [0, 2π], w = exp (j · θ) should trace the
boundary where |w| = 1. If we next introduce z = hλ ∈ C, z is related to w as
w = 1 + z ⇒ z = w − 1.
The following algorithm should thus give the boundary of the stability (or: con-
vergence) region for the Explicit Euler method.

1. Find w = exp (j · θ) for a large number of angles θ ∈ [0, 2π].

2. Define z = w − 1, and compute z for all values of w.

3. Points (ℜz (θ) , ℑz (θ)) give the boundary of the stability region where |w| < 1,
but in the z variable; z = hλ.

4. With a given eigenvalue λ ∈ C, choose h ∈ R+ such that z = hλ lies within


the given stability region.

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.

13 import matplotlib . pyplot as plt


14
15 w = exp (1 j * linspace (0 ,2* pi ,200) )
16
17 Path = mpath . Path
18
19 fig = plt . figure ()
20 fig . clf ()
21
22 z = w -1
23
24 ax = fig . add_subplot (111)
25
26 verts = map ( lambda z :( real ( z ) , imag ( z ) ) , z )
27 codes =[ Path . MOVETO ]+[ Path . LINETO ]*( len ( verts ) -2) +[ Path .
CLOSEPOLY ]
28
29 path = mpath . Path ( verts , codes )
30 patch = mpatches . PathPatch ( path ,
31 facecolor =[0.8 , 0.7 , 0.7] , edgecolor = ’ black ’ , alpha =1)
32 ax . add_patch ( patch )
33 ax . plot ([ -3 ,2] ,[0 ,0] , ’ -- ’ , color = ’ black ’)
34 ax . plot ([0 ,0] ,[ -2 ,2] , ’ -- ’ , color = ’ black ’)
35 ax . set_xlim ( -3 ,2)
36 ax . set_ylim ( -2 ,2)
37
38 fig . savefig ( " ..// figs / s t a b i l i t y E x p l i c i t E u l e r . eps " )

In order to achieve stability of the multivariable system, it is necessary to choose


h such that ∀i : |1 + hλi | < 1.
Most real models are nonlinear, and choosing step length based on eigenvalues is
64 CHAPTER 3. MODELS AND MODEL SOLUTION†

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.

3.4.3 The Implicit Euler method


In the Explicit Euler method, the clue was to introduce the approximation

x1 − x0 dx
≈ .
h dt t=t0

What if we instead use the approximation



x1 − x0 dx
≈ ?
h dt t=t0 +h

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 .

The first condition leads to


1
< 1 ⇒ 1 − h · λ > 1 ⇒ −h · λ > 0 ⇒ h > 0.
1−h·λ
This is just as for the Explicit Euler method. The second condition leads to
−1 −2
< 1 ⇒ −1 < 1 − h · λ ⇒ −h · λ > −2 ⇒ h > .
1−h·λ −λ
3.4. ORDINARY DIFFERENTIAL EQUATIONS 65

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.

3.4.4 Runge Kutta methods


3.4.4.1 Introduction
An important concept in solving ODEs is their error. Suppose that x (tn ) is the exact
solution of dx
dt
= f (x; t) with x (t0 ) = t0 , at time tn , and that xn is the approximate
solution from the numeric scheme — e.g., from the Euler method. The local error
is defined as
en , xn − x (tn )
when it is assumed that xn−1 , x (tn−1 ), i.e., the local error is the propagation of
error in one step. The global error is defined as

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†

3.4.4.2 Second order explicit Runge Kutta method


With
dx
= f (x; t)
dt
we compute xn as
xn = xn−1 + h · k2
where ( )
h h
k2 = f xn−1 + k1 ; tn−1 +
2 2
and
k1 = f (xn−1 ; tn−1 ) .
If there is an input signal such that in reality

dx
= f (x, u; t) ,
dt
this implies, e.g., that

k1 = f (xn−1 , un−1 ; tn−1 )


( ( ) )
h h h
k2 = f xn−1 + k1 , u tn−1 + ; tn−1 + .
2 2 2

Runge Kutta’s second order method has a global


( order 2.) Stability is not ham-
pered by making the slight approximation that u tn−1 + h2 ≈ u (tn−1 ) = un−1 , so
this is a common simplification.

3.4.4.3 Fourth order explicit Runge Kutta method


With
dx
= f (x; t)
dt
we compute xn as
h
xn = xn−1 + · (k1 + 2k2 + 2k3 + k4 )
6
where

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) .

Runge Kutta’s fourth order method has a global order 4.


3.4. ORDINARY DIFFERENTIAL EQUATIONS 67

3.4.4.4 Solving DAEs


One class of Differential Algebraic Equations can be written as
dx
= f (x, y, u; t)
dt
0 = g (x, y, u; t) .

If it is possible to solve the AEs to yield

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 ].

2. Compute y0 = g̃ (x0 , u0 ; t0 ) – because u (τ ) is known for all relevant τ , clearly


u0 is known.

3. Compute x1 as
x1 = x0 + h · f (x0 , y0 , u0 ; t0 ) .

4. Compute y1 as g̃ (x1 , u1 ; t1 ).

5. Compute x2 from the Euler formula. Etc., etc.


The more general DAE of form
( )
dx
f , u; t = 0
dt

is more difficult to solve. See, e.g., Ascher & Petzold (1998).

3.4.4.5 Closing comments


It is possible to construct Runge Kutta methods of other (and higher) orders. It
should be observed that the so-called “order” of the Runge Kutta methods only give
an upper bound for their global error order. As an example, the fifth order Runge
Kutta method still has fourth order global error.
Implicit Runge Kutta methods of higher order also exist. They share the dif-
ficulties with the Implicit Euler method in that it is necessary to iterate to solve
the nonlinear AEs. Terminating these iterations before the solution has been found
obviously reduces the stability properties of the system.

3.4.5 Other methods


Finally, it should be mentioned that multi-step methods are also useful. In Runge
Kutta methods (one-step methods), a number of intermediate evaluations of the
model are executed (kj ), to compute xn with xn−1 known. These evaluations are
often computationally demanding. In multi-step methods, the attempt is to reduce
68 CHAPTER 3. MODELS AND MODEL SOLUTION†

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.

3.5.2 Use of interpolation in solving models


Suppose we have solved a model dx dt
= f (x, u; θ) using an ODE solver where the step
length h is computed automatically, and where it changes with time. The solution is
a sequence of values x0 , x1 , . . . , xN −1 where x0 = x (t0 ) and xN −1 = x (t1 ). Suppose
next that we change the input u or the parameter θ and re-solve the model. Chances
are that the automatic step length algorithm will use different step lengths, and that
perhaps we only get M values x0 , x1 , . . . , xM −1 with x0 = x (t0 ) and xM −1 = x (t1 ).
Both because the number of solution points differ, and because the intermediate
values x2 , x3 , . . . are computed at different time instances for the two cases — due
to different time steps, it is impossible to compute the difference between the two
solutions.
One way around this problem is to construct interpolation functions for the two
cases, e.g., fN (x) and fM (x). With these interpolation functions, we can evaluate
both solutions at the same time instances, and compute differences between the
solutions.

3.5.3 Basic construction of interpolation functions


There are a number of ways to find f (x). A common one is to propose a parametric
function f (x; θ), and then adjust parameter θ until f (xj ; θ) = y (xj ) for all j ∈
5
“Deterministic” in the sense of knowing the simulation time in advance, under any choice of
inputs and initial conditions.
3.5. INTERPOLATION 69

{0, 1, . . . , n − 1}. Obviously, this requires a minimum of n parameters, i.e., θ ∈ Rn .


Thus, if we choose f (x) to be a polynomial,
f (x; θ) = θ0 + θ1 x + θ2 x2 + · · · θn−1 xn−1 ,
we set f (xj ; θ) = yj and find n equations:
θ0 + θ1 x0 + θ2 x20 + · · · θn−1 xn−1
0 = y0
θ0 + θ1 x1 + θ2 x1 + · · · θn−1 x1 = y1
2 n−1

..
.
θ0 + θ1 xn−1 + θ2 xn−1 + · · · θn−1 xn−1 = yn−1 .
2 n−1

These n equations can be rearranged into a matrix equation:


    
1 x0 · · · xn−10 θ0 y0
 1 x1 · · · xn−1   θ1   y1 
 1    
 .. .. . ..   ..  =  .. ,
 . . . . .  .   . 
1 xn−1 · · · xn−1
n−1
θn−1 yn−1
and θ ∈ Rn is found, e.g., by LU decomposition.
We are now able to use f (x) for interpolation or extrapolation. However, will this
procedure give good results? The quality of interpolation depends to a large degree
on the available data. It is, however, quite common that the resulting polynomial
function f (x) oscillates considerably between the known data points, to such a
degree that interpolation becomes unreliable. The key reason is that using high
order polynomials does not put constraints on the rate of variation of y (x), and for
most physical systems, there are constraints on the rate of variation.
One possible solution is to increase the order of the polynomial while adding
2
constraints on either df dx
or ddxf2 . This will greatly improve the smoothness of the
resulting interpolation function.
A more common approach is to use, e.g., piece-wise linear functions in each in-
terval [xj , xj+1 ], while ensuring that the resulting global function f (x) is continuous.
It is also possible to use, e.g., piece-wise second order polynomials in each interval,
and then adding the constraint that the global function f (x) is differentiable. Etc.
Such interpolating functions are known as spline functions. Spline functions are
somewhat more complex than polynomials, but it is possible to develop efficient
algorithms for computing the necessary parameters. The main advantage of spline
functions, is that they automatically includes some constraints on the rate of change
of f (x).
Extrapolation is more dangerous, in the sense that for regions where no data are
available, it is impossible to define constraints on rate of change. Thus, extrapolation
should be used with extreme care.

3.5.4 General model fitting


A more general way to fit models to data is as follows. Postulate a parametric
function

n−1
f (x; θ) = θj ϕj (x; c)
j=0
70 CHAPTER 3. MODELS AND MODEL SOLUTION†

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

3.6 Partial Differential Equations*


3.6.1 Balance laws and conservation laws
We have seen that balance laws for extensive variables ε can be written as (Eq. 1.1
p. 8)

= ε̇i − ε̇e + β̇i − β̇e + σ̇
dt
or, by introducing φ̇ , ε̇ + β̇, as (Eq. 1.2)


= φ̇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

ε′ varies with time t and position x. Then


ˆ x2
ε (t) = ε′ (t, ξ) dξ. (3.6)
x1

We also introduce

φ̇i = φ̇ (t, x = x1 ) (3.7)


φ̇e = φ̇ (t, x = x2 ) . (3.8)

If we´ consider a small segment with x1 = x and x2 = x + ∆x, then we have


x+∆x ′
ε= x ε (t, ξ) dξ. We can then define an average value of ε′ within this interval,
ε̄′ . If we for now assume that position x is fixed, ε̄′ only depend on time, ε̄′ = ε̄′ (t).
We then have
ε = ε̄′ (t) · ∆x, (3.9)
and ε also becomes a function of time, ε (t). Furthermore, we write φ̇i as φ̇x and φ̇e
as φ̇x+∆x . Likewise, we have
ˆ x+∆x
σ̇ (t) = σ̇ ′ (t, ξ) dξ.
x

If we introduce the average value of σ̇ ′ in interval [x, x + ∆x], we have



σ̇ = σ̇ · ∆x. (3.10)

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

∂ ε̄′ φ̇x − φ̇x+∆x ′


= + σ̇ .
∂t ∆x

If we let ∆x go to zero, then lim∆x→0 ε̄′ → ε′ (the point value), lim∆x→0 σ̇ → σ̇ ′ ,
and
φ̇x − φ̇x+∆x φ̇ (t, x) − φ̇ (t, x + ∆x) φ̇ (t, x + ∆x) − φ̇ (t, x) ∂ φ̇
lim = lim = − lim =− ,
∆x→0 ∆x ∆x→0 ∆x ∆x→0 ∆x ∂x
and the balance law can be written in differential form as
∂ε′ ∂ φ̇
=− + σ̇ ′ ; (3.12)
∂t ∂x
72 CHAPTER 3. MODELS AND MODEL SOLUTION†


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.

3.6.2 Case: scalar advection


The simplest possible PDE based on conservation laws where σ̇ ′ ≡ 0, has flow
function φ̇ = vε′ where v is a constant linear velocity. In this case, ∂ε
∂ φ̇
′ = v, and the

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.

3.6.3 Hyperbolic equations and advection+


Next, consider the general quasi-linear case with σ̇ ′ ≡ 0,
∂ε′ ∂ φ̇ ∂ε′
=− ′ ,
∂t ∂ε ∂x
where ε′ ∈ Rn and x ∈ R. Here, let us denote the Jacobian matrix by A, A ≡ ∂ε ′ ∈
∂ φ̇

R . At a given condition of ε, A is known.


n×n

In general, matrix A has n eigenvalues λ where λj ∈ C. Let (rj , λj ) be the jth


pair of (right) eigenvector and eigenvalue of matrix A, i.e.,
Arj = rj λj ;
in general, rj ∈ Cm .
Let R be the (right) eigenvector matrix of A, thus column j of R is rj , and let Λ
be the eigenvalue matrix, Λ , diag (λ1 , . . . , λn ). It can be shown that if the (right)
eigenvector matrix R is invertible, then we can write
AR = RΛ,
and it follows that matrix A = RΛR−1 can be diagonalized into Λ = R−1 AR. Thus,
if R is invertible/has full rank, matrix A is diagonalizable.
Definition 3.1. Quasi-linear system.
A quasi-linear system of form
∂ε′ ∂ε′
= −A
∂t ∂x
where A is given for the actual operating point, is called hyperbolic if matrix A ∈
Rn×n is diagonalizable with real eigenvalues. N
Suppose that A is diagonalizable. Then
∂ε′ ∂ε′ ∂ε′
= −A = −RΛR−1
∂t ∂x ∂x


∂ε ∂ε′
R−1 = −ΛR−1
∂t ∂x

∂ (R−1 ε′ ) ∂ (R−1 ε′ )
= −Λ
∂t ∂x

∂ψ ∂ψ
= −Λ
∂t ∂x
74 CHAPTER 3. MODELS AND MODEL SOLUTION†

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.

3.6.4 Discretization of balance laws+


According to Eq. 3.11, we found
∂ ε̄′ φ̇x − φ̇x+∆x ′
= + σ̇ .
∂t ∆x
Suppose we have a balance law model defined for x ∈ [0, L]. We can then
partition the x-axis into N grid cells, each of width ∆x = NL . From Eq. 3.11, the
model for cell j can now be written as
dε̄′j φ̇j− 1 − φ̇j+ 1 ′
= 2 2
+ σ̇ j , j ∈ {1, . . . , N } (3.15)
dt ∆x
[( ) ( ) ]
where ε̄′j is the average value of ε′ in the interval x ∈ j − 12 · ∆x, j + 21 · ∆x cen-
( ( ) ) ( ( ) )
tered at j·∆x, while φ̇j− 1 = φ̇ t, x = j − 12 · ∆x and φ̇j+ 1 = φ̇ t, x = j + 21 · ∆x .
2 2
See Fig. 3.2.
Observe in Fig. 3.2 that we have also introduced flows φ̇± j± 1
, where
2
( ( ) )
1
φ̇−
j± 1
, φ̇j± 1 t, x → j ± −
· ∆x ,
2 2 2
3.6. PARTIAL DIFFERENTIAL EQUATIONS* 75

Figure 3.2: Description of continuous function ε′ (x) as a function of x (green line),


with various quantities in the discretization of the conservative 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 boundaries are at positions j − 21 , j + 21 , etc. Cell averages ε̄′j−2 , . . . , ε̄′j+2 are
indicated with olive green lines.

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.

2. Evolve: From an understanding of the wave behavior of hyperbolic equations,


use this knowledge to evolve ε̃′ (t, x) into ε̃′ (t + ∆t, x).

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

to represent ε̄′j (t + ∆t).

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

3.7 Simulation Tools


3.7.1 Assignment vs. equation
When describing models in a computer language, it is important to distinguish
between assignment and equality. Most computer languages use symbol = in the
meaning of an assignment, while some (symbolic) languages use symbol = in the
meaning of equality. Assignments are tightly related to algorithms, while equations
are tightly related to the model itself.

3.7.2 Assignment by example


Languages such as FORTRAN, Pascal, C, MATLAB, and Python use symbol = to
denote assignment. So what is an assignment? An assignment can be thought of as
putting a value into a memory cell. Thus, the statement:

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†

Next, consider the equations


x=y+1
y = 2.
If we reset the computer memory and convert these equations into the assignments

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}
ζ

Setting ζ = (u, v), we have

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.

3.7.3 Assignment based model implementation


Suppose we have the model

dcA V̇
= (cA,i − cA ) − r
dt V
dcB V̇
= − cB + r
dt V
r = kc2A

where V̇ , V and k are known parameters, where cA (t = 0) = c̊A and cB (t = 0) = c̊B


are known initial values, where cA,i (t) is a known input function, and where we seek
cB (t).
Suppose we now want to solve this problem using an assignment based language,
where we implement the Explicit Euler method. Typically, we choose the number
of steps N for the simulation interval t ∈ [0, T ], which means that we will have to
80 CHAPTER 3. MODELS AND MODEL SOLUTION†

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):

1 # Define parameters for the simulation


2 Vd = ...
3 V = ...
4 k = ...
5 T = ...
6 N = ...
7 dt = T / N
8 # Set up arrays for results
9 cA = zeros ( N +1 ,1)
10 cB = zeros ( N +1 ,1)
11 cA (1) = cA0
12 cB (1) = cB0
13 # Define input signal , jumping from
14 # one to zero midway in simulation
15 cAi = ones (N ,1)
16 cAi ( N /2: N ) = 0
17 #
18 for I = 1: N
19 r = k * cA ( I ) ^2
20 dcAdt = Vd *( cAi ( I ) - cA ( I ) ) / V - r
21 dcBdt = - Vd * cB ( I ) / V + r
22 cA ( I +1) = cA ( I ) + dt * dcAdt
23 cB ( I +1) = cB ( I ) + dt * dcBdt
Here, it should be noticed that we solve the differential equations for cA and cB
simultaneously. The order of equations is important: we need to assign a value to r
before we use it to assign values to dcAdt and dcBdt, etc.

3.7.4 Equation based model implementation


With equations, the order of the equations or how well they are polished is not im-
portant. Equation based modeling languages include, e.g., Modelica and gPROMS,
where the first is a general, multi-physics language and the latter is more aimed at
chemical engineering applications.
To illustrate equation based languages, the model above is equally valid if we
write it as
dcA
V − V̇ (cA,i − cA ) = −r
dt
dcB
V + V̇ cB = r
dt
r = kc2A .
7 T
Alternatively, we could specify ∆t and compute N = ∆t , but then there is no guarantee that
N is an integer. We do need to ensure that ∆t is sufficiently short that the discretized system is
stable, though.
3.7. SIMULATION TOOLS 81

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.7.5 Debugging models


Standard computer languages such as C, MATLAB, Python, etc. have available
an IDE8 with powerful debuggers, which are tools to step through code and test
partial expressions — when the model code doesn’t work. Such tools are crucial in
finding errors, and work well for assignment based languages.
Because equation based languages involve a considerable amount of reorgani-
zation of the model before it is converted to assignments, this means that possible
simulation errors can take place in an assignment which is ordered totally differently
than the corresponding equation. This can make it very difficult to find errors in
equation based models. Some work is underway to get around this problem, e.g.,
in the open source tool OpenModelica: lists are used to track how the model is
reorganized in the conversion process, and when an error occurs, it is possible to
back-track and find out in which equation the error is found. Such a debugging tool
is important for making development of equation based models more user friendly.
There are still possibilities for improvements in debugging support for equation
based modeling and simulation tools; this is an active research area.

3.7.6 Scripting of equation based models


Although equation based modeling languages greatly ease the possibilities for im-
plementing and reusing models, simulation includes a lot of repetitive work that it
is advantageous to automate using a scripting language. Typically, equation based
tools have relatively weak support for post-processing of result, for running Monte
Carlo studies, for plotting, etc. Some tools attempts to integrate models described in
an equation based language (e.g., Modelica) with a scripting language (e.g., Python
8
IDE = integrated development environment
82 CHAPTER 3. MODELS AND MODEL SOLUTION†

or MATLAB). In a more general setting, a standard known as the Functional Mock-


up Interface (FMI) is under development to enable the integration of models written
in different tools. Currently, some tools support co-simulation, where models written
in, e.g., Modelica in principle can interact with models written in other languages.
The FMI standard also can be used as a basis for interfacing equation based models
with, e.g., scripting languages, as is done between Modelica and Python using the
JModelica.org tool.

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

Exercise 3.2. Find dz/dx when z (y, dy/dx) is given as follows:

• 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

Exercise 3.4. Consider functions z (x, y) where y is a function of x. Find ∂z/∂x


when:

• z = y 2 , y = sin x.

• z = (x + y)2 , y = sin x.

• z = y 2 , and y (x) is unknown.

• z = (x + y)2 , and y (x) is unknown. N

It is also important to be able to apply mathematics to physical systems.

Exercise 3.5. Let mass m = ρV where density ρ and volume V both vary with
time t.

• Find an expression for dm/dt. N

Exercise 3.6. In the continuity equation


∂ρ ∂
= − (ρv) ,
∂t ∂x
both density ρ and velocity v are functions of (t, x).

• Expand the expression ∂ (ρv) /∂x. N

Exercise 3.7. A chemical reaction rate is given as

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†

Exercise 3.8. Let H̃ (molar enthalpy) be given as:

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

when Ũ is defined as Ũ , H̃ − pṼ . N

Integration is also important.


´
Exercise 3.9. With y (x) given as below, what is y (x) dx?

• 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

Integration is also important for physical systems.

Exercise 3.11. With force F , find the corresponding potential energy P (hint:
F = −dP/dx):

• F = −mg.

• F = −k (x − x0 ). N

Exercise 3.12. With F = −µv where v is velocity:

• Can you find a potential energy P representing F ? N

Exercise 3.13. Suppose that dH̃ = c̃p dT , then


ˆ ˆ T
dH̃ = c̃p dT .
T0

• What are the integration boundaries for the left hand side integral? N

Exercise 3.14. Given dH̃ ig ≡ c̃ig


p (T ) dT , where

c̃ig 2 3
p (T ) = c0 + c1 T + c2 T + c3 T :

• Find H̃ ig (T ).

• What are the integration boundaries for the first integral? N

To be developed.

• Newton method to solve AEs

• reduce second order ODE to first order ODEs

• interpolation to synchronize time series

• integration w/ interpolation

• stability region for Runge Kutta

3.10 Problems*
To be developed
86 CHAPTER 3. MODELS AND MODEL SOLUTION†
Chapter 4

Mass conservation

4.1 Learning goals


After working through this chapter, the following concepts should be mastered.

• What does conservation of total mass mean? When is conservation of total


mass valid? What is the difference between conservation laws and balance
laws?

• How is the idea of mass of a continuum related to a collection of particles?


How is the number of moles related to mass?

• 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?

• What are the implications of assuming homogeneous intensive properties in a


system?

• How can mass conservation be used to find liquid level in tanks and gas pres-
sure in closed volumes?

4.2 The total mass balance


Conservation of mass is a fundamental concept in physics. We consider a system
with fixed geometry and volume V . The mass within the system boundaries is m (t)
(dimension M,1 unit, e.g., kg, g, lb, etc.) at any given time t; for simplicity we often
write this as m. An influent 2 mass flow ṁi (t) (dimension M/T,3 unit, e.g., kg/s,
g/h, etc.) flows across the system boundaries from the environment and into the
system, and an effluent 4 mass flow ṁe (t) flows across the system boundaries out
1
Table 2.5 p. 23
2
Influent, adj., from Latin in = into, in, on, upon, and fluere = to flow.
3
Table 2.5 p. 23
4
Effluent, adj., from Latin ex = out, and fluere = to flow.

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

Then with θ ∈ [t, 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

4.3 Continuum vs particle description


In classical physics, mass is considered a positive real number (including zero),
m ∈ R+ 0 . This implies that mass is assumed to be a continuum, i.e., its numeric value
can take on a continuity of values. Furthermore, mass is continuously distributed in
space. In more modern physics, matter is often considered as consisting of a large
number of particles which are non-negative natural numbers, N ∈ N0 . It is perfectly
possible to do computations with these large integer numbers. We could thus form
a number balance as
ˆ t+∆t [ ]
N (t + ∆t) − N (t) = Ṅi (τ ) − Ṅe (τ ) + Ṅg (τ ) dτ (4.3)
t

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

to include a generation term Ṅg : if N is the number of elephants in the Serengeti


National Park on the border between Tanzania and Kenya, clearly Ṅi is the flow rate
of elephants crossing into the park, while Ṅe is the flow rate of elephants crossing out
of the park; we do, however, need to take into account the possibility of elephants
being born within the park at a rate Ṅg .
Since integer functions are not differentiable, we can not formulate differential
equations for particle numbers. When the particles are atoms, molecules, etc. it is
common to scale the numbers by Avogadro’s number 6 NA , 6.0221415 × 1023 . The
scaled number is often denoted mole n and is defined as n , N/NA . In a strict
definition, n is a non-negative, rational number, n ∈ Q+ 0 , since it is a ratio of two
non-negative integers. It follows that the following integral equation is valid:
ˆ t+∆t
n (t + ∆t) − n (t) = [ṅi (τ ) − ṅe (τ ) + ṅg (τ )] dτ (4.4)
t

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 .

4.4 Extensive vs. intensive variables


In Section 2.2, we saw that it is common to make a distinction between extensive
variables (or: quantities) which has a value that varies with the size or extent of the
system,8 and intensive variables (or: quantities) for which the value is independent
of the size or extent of the system.9
6
As decided at the 24th Conference on Weights and Measures, held in France on October 21,
2011, www.rsc.org/chemistryworld/News/2011/October/31101101.asp
7
Here, we do not consider the possibility of the “particle” being able to eat/grow, a particle to
die, etc.
8
or: if two systems have extensive variables ε1 and ε2 , respectively, then the combined system
has extensive variable ε1 + ε2 .
9
or: if two systems have intensive variables ι1 and ι2 , respectively, then the combined system
has intensive variable ῑ which is some average value of ι1 and ι2 .
90 CHAPTER 4. MASS CONSERVATION

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

In the more general case of a system being in-homogeneous in the intensive


quantities, we have the more general relations:
dm
m′′′ = ρ̂ = ⇔ dm = ρ̂dV = m′′′ dV
dV
dm
m′′ = ⇔ dm = m′′ dA
dA
′ dm
m = ⇔ dm = m′ dL
dL
and
dn
n′′′ = ρ̃ = ⇔ dn = ρ̃dV = n′′′ dV
dV
dn
n′′ = ⇔ dn = n′′ dA
dA
dn
n′ = ⇔ dn = n′ dL.
dL
If we know how ρ̂ varies in space, we can, e.g., find the system mass by integrating
over the volume, ˆ
m= ρ̂dV .
V
Although we have not introduced momentum and energy as conserved quantities,
it is useful to briefly introduce two intensive quantities related to these conserved
quantities. Pressure p is defined as force F per area A. With a uniform 11 force field
on a surface area, pressure can be expressed as
F
p=.
A
In a statistical thermodynamics setting, absolute temperature T is related to ki-
netic energy of particle movement around an ensemble mean. Both pressure and
(absolute) temperature are intensive quantities.
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 density.
However, matter that flows across boundaries can possess an intensive property.
Thus, a matter with flow ṁ can possess a density ρ̂, and thus we have
ṁ = ρ̂V̇
where V̇ is the volumetric flow; V is the extensive property volume.

4.5 Equations of State


4.5.1 Ideal gas
A classical finding in physics is that for an ideal gas, the extensive variables mole
number n and system volume V are related to the intensive variables pressure p and
11
Uniform, adj., from Latin uni = one, and forma = form, i.e., having only one form or shape.
When used about vectors, the vectors have the same length and direction.
92 CHAPTER 4. MASS CONSERVATION

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̇ ,

it follows that in the case of ideal gas we have


ρ̂ p
ṅ = ρ̃V̇ = V̇ = V̇ .
M RT
If we define the so-called compressibility factor z, defined as

pV pṼ
z, = , (4.7)
nRT RT
we see that the ideal gas law can be expressed as

z = 1.

4.5.2 Non-ideal gas+


4.5.2.1 The van der Waals EoS
A problem with the ideal gas law is that in principle, the gas can be compressed
to zero volume. To introduce a finite, minimal molar volume b, van der Waals12
proposed the following modification of the ideal gas law:
RT RT
p= → .
Ṽ Ṽ − b
But more corrections were needed.
Figure 4.1 illustrates the forces acting on the particles in a gas.
Both attractive and repulsive forces are involved. Within the particle cloud (the
gas), forces are operating in all directions. But on the boundary of the particle
cloud, where the forces are measured with measuring devices, the forces are directed
inwards into the gas volume. Because pressure is force per area, this means that the
pressure p measured on the boundary of the volume is lower than the(real pressure
)
away from the boundary. The real pressure was assumed to be RT / Ṽ − b , and
12
... in the late 19th century.
4.5. EQUATIONS OF STATE 93

Figure 4.1: Forces on particles in a gas.

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.

4.5.2.2 Two-parametric Cubic EoS


Van der Waals EoS is two-parametric, in that it can be described by the two pa-
rameters a and b. More generally, two-parametric cubic equations of state can be
expressed as
RT a (T )
p= −( )( )
Ṽ − b Ṽ + εb Ṽ + σb
94 CHAPTER 4. MASS CONSERVATION

pṼ
or z = RT
leading to

Ṽ a (T ) Ṽ
z= −( )( ) , (4.9)
Ṽ − b Ṽ + εb Ṽ + σb RT

where z is the compressibility factor of Eq. 4.7, a is a temperature function, and a


and b can be expressed by parameters specific to the substance. Parameters ε and
σ are specific to the proposed EOS. ( )
The critical point is given by the triplet Tc , pc , Ṽc ; this triplet is substance
specific and is listed in thermodynamic tables Poling et al. (2001). We can also
define the critical point compressibility factor as zc , pRT c Ṽc
c
. The critical point is
characterized by being an inflection point when the ( pressure
) is considered a function
of molar volume at given temperature, i.e., for p Ṽ ; T . Being an inflection point,
( )
this implies that function p Ṽ ; T changes from being convex to being concave in
the critical point, and it follows that in the critical point,

∂p
=0 (4.10)
∂ Ṽ c

∂ 2 p
= 0. (4.11)
∂ Ṽ 2
c

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

here, Ωa and Ωb are constants, Tr is the reduced temperature defined as

T
Tr , , (4.14)
Tc

and ω is the (Pitzer) acentric factor, Poling et al. (2001), defined as



ω , − log10 psat
r
−1 (4.15)
Tr =0.7

where the reduced saturation pressure psat


r is evaluated at reduced temperature Tr =
0.7. Thus, if the acentric factor ω is known, we can easily compute the reduced
saturation pressure at Tr from Eq. 4.15 as

1
psat
r
= .
Tr =0.7 10ω+1
4.5. EQUATIONS OF STATE 95

4.5.2.3 Examples of two-parametric Cubic EoS


Some cubic Equations of State are listed below.

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.

Redlich-Kwong-Soave: The Redlich-Kwong-Soave Equation of State (RKS13 , 1972)


is given by
[ ( √ )]2
α (Tr ; ω) = 1 + κS 1 − Tr
κS = 0.480 + 1.574ω − 0.176ω 2
ε=0
σ=1
Ωa = 0.42748
Ωb = 0.08664.
13
This model is often referred to as Soave-Redlich-Kwong. However, since it represents a mod-
ification of a model by Redlich and Kwong, it seems more reasonable to list the modifier at the
end.
96 CHAPTER 4. MASS CONSERVATION

Thus,
Ṽ a (T ) Ṽ
z= − ( ) .
Ṽ − b Ṽ Ṽ + b RT

Again, the essential contribution by Soave was the introduction of a new α


function. A later modification of the RKS expression for α due to Graboski
and Daubert is as follows
[ ( √ )]2
α (Tr ; ω) = 1 + κGD 1 − Tr
κGD = 0.48508 + 1.55171ω − 0.15613ω 2 .

Hydrogen is often be given special treatment, and a possible expression for α


suitable for RKS is

αH2 = 1.202 exp (−0.30288Tr ) .

Peng-Robinson: The Peng-Robinson Equation of State (PR, 1976) is given by


[ ( √ )]2
α (Tr ; ω) = 1 + κ 1 − Tr
κPR = 0.37464 + 1.54226ω − 0.26992ω 2

ε=1+ 2

σ =1− 2
Ωa = 0.457235
Ωb = 0.077796.

Thus,
Ṽ a (T ) Ṽ
z= − ( ) ( ) .
Ṽ − b Ṽ Ṽ + b + b Ṽ − b RT

The key contribution in the PR EoS, is the modification of the attractive


“force” with both σ ̸= 0 and ε ̸= 0.
Peng-Robinson-Stryjek-Vera: The Peng-Robinson-Stryjek-Vera Equation of State
(PRSV, 1986) is given by modifying κ in the expression for PR. A first proposal
is the PRSV1: ( √ )
κPRSV1 = κ0 + κ1 1 + Tr (0.7 − Tr )
where

κ0 = 0.378893 + 1.489753ω − 0.17131848ω 2 + 0.0196554ω 3

and κ1 is a species specific parameter. For alcohols and water, literature


values for κ1 may be used for Tr ≤ 1, and κ1 = 0 for Tr > 1. For other species,
literature values for κ1 are often used when Tr ≤ 0.7, and κ1 = 0 for Tr > 0.7.
A second proposal is the PRSV2:
[ ( )] ( )
κPRSV2 = κ0 + κ1 + κ2 (κ3 − Tr ) 1 − Tr0.5 1 + Tr0.5 (0.7 − Tr )
4.5. EQUATIONS OF STATE 97

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.

4.5.2.4 Three-parametric Cubic EoS


The two-parametric cubic EoS with Soave-type α functions suffer from several prob-
lem. For one thing, the attractive force — and thus α — must satisfy a number
of requirements to be physically realistic: (i) α must be finite and positive at all
temperatures, (ii) α (Tr = 1) must have unit value, (iii) α must approach zero as Tr
goes to infinity, and (iv) α must be continuous, and have continuous first and second
derivatives wrt. Tr . The Redlich-Kwong α function fails to be finite for Tr = 0+ .
Soave’s α function attains a minimum, and goes to infinity as Tr → ∞; Soave’s α
function also appears in Peng-Robinson’s EoS — with a minor modification.14 An-
other problem with two-parameters cubic EoS is that they are poor at representing
vapor-liquid equilibrium and the molar volume of liquids.
One possible three-parametric cubic EoS is the Patel-Teja EoS, given as
RT a (T )
p= −
Ṽ − b Ṽ + (b + c) Ṽ − bc
2


Ṽ 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

which satisfies the requirements of α when Hi > 0 .


In general, parameters ẑc , H1 and H2 are substance dependent. However, for
simple gases and hydrocarbons, these parameters have been fitted to experimental
data as (Forero G. & Velásquez J. 2013)

ẑc = 0.3272 − 0.0537ω − 0.0147ω 2


h = 1.4563 + 1.26ω − 0.3928ω 2
−0.2981 − 1.9574ω + 0.1789ω 2
H2 = +h
h−1
h−1
H1 = .
H2
For polar fluids, individual triplets (ẑc , H1 , H2 ) are given for each substance
(Forero G. & Velásquez J. 2014). As an example, for water, the following values are
given:

ẑ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.

4.6 The homogeneous system assumption


A key simplifying assumption when making mathematical models, is that the sys-
tem is homogeneous in the intensive variables. In the case of mass balances, this
implies that, e.g., the density ρ (or ρ̂) is the same everywhere in the volume. With
effluent mass flow ṁe = ρe V̇e from the system volume and into the surroundings,
this assumption implies that the density ρe at the outlet from the system volume
is the same as the density everywhere in the volume, hence ρe = ρ = m/V . The
influent mass flow from the environment and into the system volume is ṁi .
The mass balance can then be written as
dm
= ṁi − ṁe
dt
4.7. BERNOULLI’S LAW FOR VALVE FLOW 99

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.

4.7 Bernoulli’s law for valve flow


The well-known Bernoulli law is based on a steady state energy balance15 , and
specifies that for fluids with constant density ρ and negligible friction loss, the energy
15
See Chapter 7 for details.
100 CHAPTER 4. MASS CONSERVATION

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.

which can be written as √


h
ṁ = K (4.24)

where √
A1 A2 2ghς
K=ρ √ 2 . (4.25)
A1 − A22
For control valves, the valve pipe area Av and thereby the exit streamline area
A2 can be changed. If the control signal is u, then A2 is a function of u, A2 (u).
Bernoulli’s law is, strictly speaking not valid for compressible fluids such as gas.
However, if the compression is small, we may perhaps still use Bernoulli’s law in the
form of Eq. 4.21.

4.8 Cases: Liquid level in tanks


4.8.1 Tank with effluent flow
Cases of model development will be structured as follows. First, the model objective
is given, including a functional diagram of the system. Next, detailed and systematic
steps in the model development is given. Then, a model summary is given, and
finally model simulation is discussed.
In model development, it is always necessary to introduce simplifying assump-
tions. In the examples, these assumptions will be given in the model development
102 CHAPTER 4. MASS CONSERVATION

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.

Tank with effluent


mass flow

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.

4.8.1.1 Model objective

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

4.8.1.2 Model development


We assume that the system is homogeneous in the liquid density ρ, and that the
tank has constant cross sectional area A. We divide the model development into four
steps: in the first step, we introduce the needed fundamental law, in the second step
we relate external quantities (inputs, outputs) to the quantities in the fundamental
law, in the third step we manipulate the model into the desired form, and in the
fourth step we relate the computed variables with the output.
Step 1: To find liquid level in a volume, we use 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 ṁ. 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 3: Depending on the computer language for describing/solving the model, we


can keep the model as is, or manipulate it into state space form, e.g.,
√ √
d h dh K h
(ρAh) = −K ς
⇔ =− ,
dt h dt ρA hς
or alternatively into the form
√ √ √
dm h V /A m
= −K ς
= −K ς
= −K .
dt h h ρAhς

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)

4.8.1.3 Model summary


The model can be summarized in a form suitable for implementation in Modelica as
dm
= −ṁe
dt
m = ρV
V = Ah

h
ṁe = K .

To complete the model description, we need to specify model parameters and oper-
ating conditions. Model parameters (constants) are given in Table 4.1.
The operating conditions are given in Table 4.2

4.8.1.4 Model simulation


Using OpenModelica, the results of simulating this system are as shown in Fig. 4.5.
The following Modelica code (file AutoTank.mo) is used to produce the above
figure.

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

Auto tank level


1.4
1.2
1.0
0.8
h [dm]

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.

14 parameter Real rho = 1 " Density of liquid , kg / L ";


15 parameter Real A = 5 " Cross sectional area of tank , dm2 ";
16 parameter Real K = 5 " Valve constant , kg / s ";
17 parameter Real h_s = 3 " Scaling level , dm ";
18 // Initial state parameters
19 parameter Real h0 = 1.5 " Initial tank level , dm ";
20 parameter Real m0 = rho * h0 * A " Initial tank mass , kg ";
21 // Declaring variables
22 // -- states
23 Real m ( start = m0 , fixed = true ) " Mass in tank , kg ";
24 // -- auxiliary variables
25 Real V " Tank liquid volume , L ";
26 Real h " Tank liquid level , dm ";
27 Real md_e " Effluent mass flow from tank , kg / s ";
28 // -- input variables
29
30 // -- output variables
31 output Real _h ;
32 // Initializating in steady state
33 /*
34 initial equation
35 der ( m ) = 0;
36 */
37 // Equations constituting the model
38 equation
39 // Algebraic equations
40 m = rho * V ;
41 V = A*h;
42 md_e = K * sqrt ( h / h_s ) ;
43 // md_e = max ( K * sign ( h ) * sqrt ( abs ( h / h_s ) ) ,0) ;
106 CHAPTER 4. MASS CONSERVATION

44 // Differential equations
45 der ( m ) = - md_e ;
46 // Outputs
47 _h = h ;
48 end SimAutoTank ;
49 // End package
50 end AutoTank ;

4.8.1.5 Refining the model implementation


In OpenModelica, the simulation has been set up to find h (t) in the interval t ∈
[0, 10] s. As Fig. 4.5 shows, the simulation is terminated after ca. 4.2 s Why?
To understand why, a basic understanding
√ of numerics is required. Observe
that the effluent is computed as ṁe = K hhς . What happens if h becomes slightly
negative — due to the numeric algorithm for solving the DAE? This can easily
happen!
The answer is that then, the solver attempts to take the square root of a negative
number, and the solver crashes. How can we get around this problem? We need to
redefine ṁe and use a numerically more robust formulation. What if we use

h
ṁe = K ς ?
h
In this case, we will definitely avoid the problem of taking the square root of a nega-
tive number. However, if the level erroneously becomes negative, this will accelerate
the effluent, making the level even more negative — which doesn’t make sense since
the tank is empty. What if we include the sign of h in the expression?

h
ṁe = Ksign (h) ς ?
h
This time, too, we avoid taking the square root of a negative number. If the level
becomes negative, however, this will lead to the fluid flow changing sign: ṁe becomes
negative, which implies that the fluid is “pumped” back into the tank. This is also
an nonphysical behavior.
The behavior we really want is to avoid problems when h for some reason becomes
slightly negative, and we want the effluent to become zero when h < 0. The following
expression should handle the situation:
( √ )
h
ṁe = max Ksign (h) ς , 0 ,
h

or in the Modelica code: replace the line

md_e = K * sqrt ( h / h_o ) ;


with the line:
4.8. CASES: LIQUID LEVEL IN TANKS 107

Auto tank level, refined


1.4
1.2
1.0
0.8
h [dm]

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.

md_e = max ( K * sign ( h ) * sqrt ( abs ( h / h_o ) ) ,0) ;

The simulation result is shown in Fig. 4.6.


The observed numeric problem discussed here, is only a problem if the level
approaches zero.

4.8.1.6 Exact solution of model

The model was implemented in Modelica in the form

dm
= −ṁe
dt
m = ρV
V = Ah

h
ṁe = K .

Here, we can set

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 .

Tank with influent


and effluent flows

Figure 4.8: Functional diagram of tank with influent and effluent flow.

4.8.2 Tank with influent and effluent flows

4.8.2.1 Model objective

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

4.8.2.2 Model development

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

while ṁi is assumed to be a known function of time.

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.

Step 4: The output h is related to the model state m as


m
h= .
ρA

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

4.8.2.3 Model summary


The model can be summarized in a form suitable for implementation in Modelica as
dm
= ṁi − ṁe
dt
m = ρV
V = Ah

h
ṁe = K .

To complete the model description, we need to specify model parameters and oper-
ating conditions. Model parameters (constants) are given in Table 4.3.
The operating conditions are given in Table 4.4.

4.8.2.4 Model simulation


Using OpenModelica, the results of simulating this system are as shown in Fig. 4.9.
The figure shows the level response with the given initial level h (0) and input
mass flow rate ṁi as given in Table 4.4 (red curve; main program SimDrivenTank).
It is often preferable to start the simulation in steady state with a given input ṁi
(as given in Table 4.4); Fig. 4.9 shows the corresponding step change in ṁi (green
curve) with resulting response in h (blue curve — starting in steady state for the
given ṁi ) using main program SimStepDrivenTank.
The following Modelica code (file DrivenTank.mo) describes the system with
operations.

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

Driven tank, w & w/o step in mi


2.00 h
hstep
1.75 mi
1.50
1.25
1.00
0.75
0.50
0.25
0 2 4 6 8 10 12 14
time t [s]

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

34 // University of South - Eastern Norway


35 // August 26 , 2015
36 // May 11 , 2017
37 //
38 // Instantiate model of * driven tank * ( dt )
39 ModDrivenTank dt ;
40 // Declaring variables
41 // -- inputs
42 Real md_i " Mass flow into tank ";
43 // -- outputs
44 Real _h " Level in tank ";
45 // Initial equations
46 initial equation
47 der ( dt . m ) = 0;
48 // Equations
49 equation
50 // -- input
51 md_i = if time < 1 then 2 else 1.5;
52 dt . md_i = md_i ;
53 // -- output
54 _h = dt . h ;
55 end SimStepDrivenTa nk ;
56 //
57 //
58 model ModDrivenTank
59 // Main Driven Tank model
60 // author : Bernt Lie
61 // University of South - Eastern Norway
62 // August 26 , 2015
63 // May 11 , 2017
64 //
65 // Parameters
66 parameter Real rho = 1 " Density of liquid , kg / L ";
67 parameter Real A = 5 " Cross sectional area of tank , dm2 ";
68 parameter Real K = 5 " Valve constant , kg / s ";
69 parameter Real h_s = 3 " Scaling level , dm ";
70 // Initial state parameters
71 parameter Real h0 = 1.5 " Initial tank level , dm ";
72 parameter Real m0 = rho * h0 * A " Initial tank mass , kg ";
73 // Declaring variables
74 // -- states
75 Real m ( start = m0 ) " Mass in tank , kg ";
76 // -- auxiliary variables
77 Real V " Tank liquid volume , L ";
78 Real h " Tank liquid level , dm ";
79 Real md_e " Effluent mass flow rate from tank , kg / s ";
80 // -- input variables
81 input Real md_i " Influent mass flow rate to tank , kg / s ";
82 // Equations constituting the model
114 CHAPTER 4. MASS CONSERVATION

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.

4.8.3 Tank with varying area


4.8.3.1 Model objective
Next, we consider a liquid tank where the cross sectional area varies with the level
h, Fig. 4.10. We still seek the liquid level h.
Water with initial mass is emptied through a hole in the bottom of a funnel
shaped tank at effluent mass flow rate ṁe , while at the same time water is filled into
the tank at influent mass flow rate ṁi . The funnel shape causes the cross sectional
area A to change with level h. The model objective is illustrated by the functional
diagram in Fig. 4.11.
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, the input variable is the influent mass flow rate
ṁi , while the output variable is the quantity we are interested in, h.

4.8.3.2 Model development


The tank has a surface area A which varies linearly with the level h. Assuming a
homogeneous tank with density ρ, the model development is given by the four steps
19
Inherit in an object oriented meaning.
4.8. CASES: LIQUID LEVEL IN TANKS 115

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 .

Tank with varying


area

Figure 4.11: Functional diagram of tank with varying area and with influent and
effluent flow.
116 CHAPTER 4. MASS CONSERVATION

below.

Step 1: The total mass balance is, as always:


dm
= ṁi − ṁe .
dt

Step 2: The mass is related to the volume as

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

As before, the flow out is given as



h
ṁe = K .

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

and next relate m and h:


( ς )2
π R
m = ρV = ρ h3
3 hς


m
h= 3
π
( ) .
Rς 2
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.

Step 4: The output h is equal to the state h.


4.8. CASES: LIQUID LEVEL IN TANKS 117

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

4.8.3.3 Model summary


The model can be summarized in a form suitable for implementation in Modelica as
dh
ρA = ṁi − ṁe
dt
A = πr2

r= ςh
h√
h
ṁe = K .

To complete the model description, we need to specify model parameters and oper-
ating conditions. Model parameters (constants) are given in Table 4.5.
The operating conditions are given in Table 4.6.

4.8.3.4 Model simulation


Using OpenModelica, the results of simulating this system are as shown in Fig. 4.12.
The figure shows the level response with the given initial level h (0) and input
mass flow rate ṁi as given in Table 4.6 (red curve; main program SimDrivenFunnelTank).
It is often preferable to start the simulation in steady state with a given input ṁi
(as given in Table 4.6); Fig. 4.12 shows the corresponding step change in ṁi (green
curve) with resulting response in h (blue curve — starting in steady state for the
given ṁi ) using main program SimStepDrivenFunnelTank.
The following Modelica code (file DrivenFunnelTank.mo) describes the system
with operations.

1 package DrivenFunnelTank
2 // Package for simulating driven tank
3 // author : Bernt Lie
4 // University of South - Eastern Norway
118 CHAPTER 4. MASS CONSERVATION

Driven funnel tank, w & w/o step in mi


2.00 h
hstep
1.75 mi
1.50
1.25
1.00
0.75
0.50
0.25
0 2 4 6 8 10 12 14
time t [s]

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

32 // Simulation of Driven Funnel Tank model with step input


33 // author : Bernt Lie
34 // University of South - Eastern Norway
35 // August 26 , 2015
36 // May 11 , 2017
37 //
38 // Instantiate model
39 ModD ri ve nF un ne l T an k dft ;
40 // Declaring variables
41 // -- inputs
42 Real md_i " Mass flow into tank ";
43 // -- outputs
44 Real _h " Level in tank ";
45 // Initial equations
46 initial equation
47 der ( dft . h ) = 0;
48 // Equations
49 equation
50 // -- input
51 md_i = if time < 1 then 2 else 1.5;
52 dft . md_i = md_i ;
53 // -- output
54 _h = dft . h ;
55 end S i mS t ep Dr i ve n F u n n e l T a n k ;
56 //
57 //
58 model ModDriven Fu n n el T a nk
59 // Main Driven Funnel Tank model
60 // author : Bernt Lie
61 // University of South - Eastern Norway
62 // August 26 , 2015
63 // May 11 , 2017
64 //
65 // Constants
66 constant Real PI = 3.1415926535 " pi , - -";
67 // Parameters
68 parameter Real rho = 1 " Density of liquid , kg / L ";
69 parameter Real R_s = sqrt (15/ PI ) " Scaling radius , dm ";
70 parameter Real h_s = 3 " Scaling level , dm ";
71 parameter Real K = 5 " Valve constant , kg / s ";
72 // Initial state parameters
73 parameter Real h0 = 1.5 " Initial tank level , dm ";
74 // Declaring variables
75 // -- states
76 Real h ( start = h0 ) " Level in funnel tank , m ";
77 // -- auxiliary variables
78 Real A " Tank liquid surface area , dm2 ";
79 Real r " Radius of surface area , dm ";
80 Real md_e " Effluent mass flow rate from tank , kg / s ";
120 CHAPTER 4. MASS CONSERVATION

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 ;

4.9 Case: Pressure in single gas tank


4.9.1 Model objective
A fixed temperature tank is depicted in Fig. 4.13.
An impeller/propeller is installed in the tank to mix the content. Upstream
from an inlet valve is a gas source with pressure pi , and the influent mass flow rate
is ṁi . The ambient pressure is pa , and the environment receives the effluent mass
flow with rate ṁe . We seek a description of the pressure p within the tank. The
model objective is illustrated by the functional diagram in Fig. 4.14.
The functional diagram depicts the causality of the system (“Tank with effluent
4.9. CASE: PRESSURE IN SINGLE GAS TANK 121

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.

4.9.2 Model development


The purpose of installing impellers, baffles, etc. is to make the tank content ho-
mogeneous; inclusion of the impeller symbol will always imply an assumption of
homogeneous system volume. The driving force across √ inlet and outlet valves is the
pressure drop ∆pk , k ∈ {i, e}; the flow rates are ∝ ∆pk . We will assume that the
gas is an ideal gas.

Step 1: The total mass balance is, as always:

dm
= ṁi − ṁe .
dt

Step 2: The mass is related to the volume as

m = ρV.

With fixed volume and temperature, and an ideal gas, we have

pV = nRT
m
n= .
M

Furthermore

∆pi
ṁi = Ki

∆pi = pi − p

∆pe
ṁe = Ke

∆pe = p − pa

where we will use pς = pa as scaling pressure.

Step 3: For implementation in an equation based, no model manipulation is neces-


sary. But let us illustrate how to manipulate the model into state space form,
122 CHAPTER 4. MASS CONSERVATION

with p as state. We have


dm
= ṁi − ṁe
dt

d
(nM ) = ṁi − ṁe
dt

( ) √ √
d pV pi − p p − pa
M = Ki − K e
dt RT pς pς

( √ √ )
dp RT pi − p p − pa
= Ki − Ke .
dt VM pς pς
Alternatively, we could have used density ρ or total mass m as states, and
compute p from these.

Step 4: The output p is related to state m as pV = nRT = M m


RT ⇒ p = m VRT M
.
However, in our DAE description, pressure p is already an internal variable,
and is readily available.

4.9.3 Model summary


The model can be summarized in a form suitable for implementation in Modelica as
dm
= ṁi − ṁe
dt
m = nM
pV = nRT
∆pi = pi − p
∆pe = p − pa

∆pi
ṁi = Ki


∆pe
ṁe = Ke .

We choose the following parameters for the model, Table 4.7.


The operating conditions (initial state, input) are defined in Table 4.8.

4.9.4 Model simulation


Using OpenModelica, the results of simulating this system are as shown in Fig. 4.15.
The figure shows the pressure response with the given initial pressure p (0) and
input pressure pi as given in Table 4.8 (red curve; main program simGasTank). It
is often preferable to start the simulation in steady state with a given input pi (as
4.9. CASE: PRESSURE IN SINGLE GAS TANK 123

Table 4.7: Parameters for gas tank with fixed temperature.


Parameter Value Unit Comment
R 8.31 J K−1 mol−1 Universal gas constant
M 28 g mol−1 Molar mass for Nitrogen
pa 1.03 × 10 Pa
5
Ambient (atmospheric) pressure
pς = pa Pa Scaling pressure
−3
V 50 × 10 m 3
Volume of tank
Ki 3 g/s Inlet valve constant
Ke 3 g/s Outlet valve constant
T 300 K Gas temperature

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

Gas Tank, w & w/o step in pi


1200000

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 ) ;

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 ;

4.10 Case: Pressure in gas pipe


4.10.1 Model objective
Consider a gas pipe of length L and cross sectional area A as depicted in Fig. 4.16.
The influent mass flow rate is ṁ0 ,20 while the inlet pressure is p0 . Mass flow
20
Notice that we are free to choose any symbol for variables, thus there is no requirement that
the influent mass flow rate should be denoted ṁi . Here, it is convenient to associate the influent
4.10. CASE: PRESSURE IN GAS PIPE 127

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 .

4.10.2 Model development


We assume that the gas is an ideal gas.
Here, we assume that the velocity v is constant across the cross sectional area A,
and v and temperature T are constant along x — but both v and T will be allowed
to vary with time. If v and T vary with time, we do, however, assume that the
changes propagate infinitely fast along x so that v and T still have the same value
for all x values.
When it comes to mass flow and pressure, however, the system is assumed to be
distributed in these quantities, i.e., their values vary in space: ṁ and p vary with x.
In order to develop the model, we first consider a hypothetical homogeneous volume
with x ∈ [ξ, ξ + ∆x], see Fig. 4.16. This development involves exactly the same first
three steps as in the previous “concentrated” models (i.e., non-distributed systems):
i.e., the total mass balance, defining the terms in the total mass balance, and a
(possible) step with manipulation of the model.
However, with a distributed system, we need two additional small steps: a fourth
step where we generalize the model to any position [x, x + ∆x], and a fifth step where
we let ∆x → 0. A final sixth step defines the output variables.
Thus, with a homogeneous volume in x ∈ [ξ, ξ + ∆x]:

Step 1: The total mass balance is, as always:


dm
= ṁi − ṁe .
dt

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:

(pV )ξ+∆x = nξ+∆x RT


mξ+∆x = nξ+∆x M
Vξ+∆x = ∆xA.

The flow rates are given by

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:

dpξ+∆x (t) ∂px+∆x (t, x)


→ .
dt ∂t
The generalization thus becomes

∂px+∆x (t, x) px − px+∆x px+∆x − px


=v = −v ,
∂t ∆x ∆x
with the so-called boundary condition

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

4.10.3 Model summary


A traditional model summary would state the model based on step 5 and 6 above
as
∂p ∂p
= −v , x ∈ (0, L]
∂t ∂x
p (t, x = 0) = p0 (t)
pL (t) = p (t, x = L)
vAM
ṁL = pL .
RT
In traditional solution strategies, the partial differential equation (PDE) above
is discretized in both time and space to lead to an iterative scheme. An alternative
is to only discretize the model in space and leave the model as a large number of
ordinary partial differential equations (ODE). There are many ways to carry out
130 CHAPTER 4. MASS CONSERVATION

Table 4.9: Parameters for gas tube with homogeneous temperature.


Parameter Value Unit Comment
R 8.31 J K−1 mol−1 Universal gas constant
M 28 g mol−1 Molar mass for Nitrogen
pa 1.03 × 10 Pa
5
Ambient (atmospheric) pressure; used to define initial pre
A 5 dm2 Cross sectional area
L 10 dm Length of gas tube (V = 50 × 10−3 m3 )
T 300 K Gas temperature
N 10 – Number of slices/sections in the tube
L
∆x N
dm Length of each slice/section

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.

4.10.4 Model simulation


Using OpenModelica, the results of simulating this system using model/class SimGasPipe
(N = 10) are as shown in Fig. 4.18.
The result with N = 10 while starting in steady state, and with a step in the
inlet pressure p0 is generated using class SimStepGasPipe is shown in Fig. 4.19.
4.10. CASE: PRESSURE IN GAS PIPE 131

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

Gas Pipe, pressure distribution


1000000
p(x = 0, t)
800000 pL
p1
p2
600000 p3
p4
p5
400000 p6
p7
200000 p8
p9
0 20 40 60 80 100 120 140
time t [s]

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.

Gas Pipe w/ step in input pressure, pressure distribution

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

Gas Pipe: pL depending on N


pL, N = 10
pL, N = 30
1200000 pL, N = 90
pL, N = 300

1150000

1100000

1050000

0 20 40 60 80 100 120 140


time t [s]

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

19 Real p_0 " Upstream ( inlet ) pressure , Pa ";


20 Real v " Velocity through pipe , m / s ";
21 // -- outputs
22 output Real _pL10 , _pL30 , _pL90 , _pL300 " Pressure at pipe
end , Pa ";
23 output Real _mdL10 , _mdL30 , _mdL90 , _mdL300 " Mass flow
rate at exit , kg / s ";
24 // Initial equations
25 initial equation
26 der ( gp10 . m [:]) = zeros ( gp10 . N ) ;
27 der ( gp30 . m [:]) = zeros ( gp30 . N ) ;
28 der ( gp90 . m [:]) = zeros ( gp90 . N ) ;
29 der ( gp300 . m [:]) = zeros ( gp300 . N ) ;
30 // Equations
31 equation
32 // -- input
33 p_0 = if time < 25 then 10* gp10 . p_a else 12* gp10 . p_a ;
34 gp10 . p_0 = p_0 ;
35 gp30 . p_0 = p_0 ;
36 gp90 . p_0 = p_0 ;
37 gp300 . p_0 = p_0 ;
38 v = 2e -2 " Velocity , m / s ";
39 gp10 . v = v ;
40 gp30 . v = v ;
41 gp90 . v = v ;
42 gp300 . v = v ;
43 // -- output
44 _pL10 = gp10 . p [ gp10 . N ];
45 _pL30 = gp30 . p [ gp30 . N ];
46 _pL90 = gp90 . p [ gp90 . N ];
47 _pL300 = gp300 . p [ gp300 . N ];
48 _mdL10 = gp10 . md [ gp10 . N ];
49 _mdL30 = gp30 . md [ gp30 . N ];
50 _mdL90 = gp90 . md [ gp90 . N ];
51 _mdL300 = gp300 . md [ gp300 . N ];
52 end Sim St ep Comp a r e G a s P ip e ;
53 //
54 model SimGasPipe
55 // Simulation of Gas Pipe model
56 // author : Bernt Lie
57 // University of South - Eastern Norway
58 // August 27 , 2015
59 // May 11 , 2017
60 //
61 // Instantiate model
62 ModGasPipe gp ;
63 // Declaring variables
64 // -- inputs
65 Real p_0 " Upstream ( inlet ) pressure , Pa ";
134 CHAPTER 4. MASS CONSERVATION

66 Real v " Velocity through tube , m / s ";


67 // -- outputs
68 output Real _pL " Pressure at tube end , Pa ";
69 output Real _mdL " Mass flow rate at exit , kg / s ";
70 // Equations
71 equation
72 // -- input
73 p_0 = 10* gp . p_a ;
74 gp . p_0 = p_0 ;
75 v = 2e -1 " Velocity , m / s ";
76 gp . v = v ;
77 // -- output
78 _pL = gp . p [ gp . N ];
79 _mdL = gp . md [ gp . N ];
80 end SimGasPipe ;
81 //
82 model SimStepGasPipe
83 // Simulation of Gas Pipe model with step input
84 // author : Bernt Lie
85 // University of South - Eastern Norway
86 // August 27 , 2015
87 // May 11 , 2017
88 //
89 // Instantiate model
90 ModGasPipe gp ;
91 // Declaring variables
92 // -- inputs
93 Real p_0 " Upstream ( inlet ) pressure , Pa ";
94 Real v " Velocity through pipe , m / s ";
95 // -- outputs
96 output Real _pL " Pressure at tube end , Pa ";
97 output Real _mdL " Mass flow rate at exit , kg / s ";
98 // Initial equations
99 initial equation
100 der ( gp . m [:]) = zeros ( gp . N ) ;
101 // Equations
102 equation
103 // -- input
104 p_0 = if time < 25 then 10* gp . p_a else 12* gp . p_a ;
105 gp . p_0 = p_0 ;
106 v = 2e -2 " Velocity , m / s ";
107 gp . v = v ;
108 // -- output
109 _pL = gp . p [ gp . N ];
110 _mdL = gp . md [ gp . N ];
111 end SimStepGasPipe ;
112 //
113 //
114 model ModGasPipe
4.10. CASE: PRESSURE IN GAS PIPE 135

115 // Underlying Gas Pipe model


116 // author : Bernt Lie
117 // University of South - Eastern Norway
118 // August 27 , 2015
119 // May 11 , 2017
120 //
121 // Constants
122 constant Real R = 8.31 " Ideal gas constant , J /( K . mol ) ";
123 // Parameters
124 parameter Real M = 28 " Molar mass of gas , g / mol ";
125 parameter Real p_a = 1.03 e5 " Ambient pressure , Pa ";
126 parameter Real A = 5e -2 " Pipe cross sectional area , m2 ";
127 parameter Real L = 10 e -1 " Pipe length , m ";
128 parameter Integer N = 10 " Number of slices in pipe , -";
129 parameter Real dx = L / N " Slice length / thickness , m ";
130 parameter Real T = 300 " Temperature , K ";
131 parameter Real V = dx * A " Slice volume , m3 ";
132 // Initial state parameters
133 parameter Real p0 = 1.2* p_a " Initial time slice pressure ,
Pa ";
134 parameter Real m0 = p0 * dx * A * M /( R * T ) " Initial time slice
mass , g ";
135 // Declaring variables
136 // -- states
137 Real m [ N ]( each start = m0 ) " Mass in each slice , g ";
138 // -- auxiliary variables
139 Real p [ N ] " Pressure in slices , Pa ";
140 Real n [ N ] " Mole in slices , mol ";
141 Real md [ N ] " Mass flow rate in slices , m / s ";
142 Real md_0 " Mass flow rate at inlet , m / s ";
143 Real Vd " Volumetric flow rate , m3 / s ";
144 // -- input variables
145 input Real p_0 " Inlet pressure at x =0 , Pa ";
146 input Real v " Velocity through pipe , m / s ";
147 // Equations constituting the model
148 equation
149 // Algebraic equations
150 p [:]* V = n [:]* R * T ;
151 m [:] = n [:]* M ;
152 Vd = v * A ;
153 md [:] = Vd * M * p [:]/( R * T ) ;
154 md_0 = Vd * M * p_0 /( R * T ) ;
155 // Differential equations
156 der ( m [1]) = md_0 - md [1];
157 der ( m [2: end ]) = md [1: end -1] - md [2: end ];
158 end ModGasPipe ;
159 // End package
160 end GasPipe ;
136 CHAPTER 4. MASS CONSERVATION

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.

Problem 4.1. [Solution E.6 p. 589] Continuity equation

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

5.1 Learning goals


After working through this chapter, the following concepts should be mastered.

• What do we mean by species?

• What is the structure of species balance laws with mass and mole as basis?

• What extensive and intensive quantities are relevant for species balances?

• How can gas mixtures be described wrt. Equations of State?

• How can we quantify rates of generation for species in chemical reactions?

• How can diffusion of species be described?

• How can species balances be used to find concentrations?

5.2 The concept of “species”


5.2.1 Matter with attributes
In many cases, it is of interest to further detail the content of a system volume. As
an example: if the system consists of living creatures on the surface of the earth, it
is common to classify the system content into groups such as mammals, insects, etc.
However, this system can be further subdivided, e.g., the mammals can be classified
into the species humans, apes, zebras, elephants, etc. Even further subdivision is
possible, e.g., for humans we can classify them using attributes such as age, height,
weight, hair color, use of glasses, etc.
Lipoproteins in the blood plasma are particles which are a combination of fat
(cholesterol) and proteins, and are grouped into small particles HDL (high density
lipoproteins), medium sized particles LDL (low density lipoproteins), and large par-
ticles VLDL (very LDL). This subdivision of lipoproteins can be further refined by
realizing that there is a range of particle sizes within each group.

139
140 CHAPTER 5. SPECIES BALANCE

In chemical engineering, it is not common to make a distinction between different


types of hydrogen molecules, oxygen molecules, water molecules, etc. In some cases
this could be done: a detailed study shows that, e.g., a water molecule is not a
unique thing: liquid water consists of molecules H2 O, and various combinations of
hydrogen dioxide molecules bonded together — almost like polymers.
Polymers is another group of molecules where there is no fixed chemical formula:
if we consider, e.g., polyethylene, these can contain an arbitrary number of carbon
molecules. Their main feature is that they contain ethylene as a building block.
Also in biochemistry, we face a situation where a “species” is not well defined. The
substrate in biochemical system may, e.g., consist of sugar — but this sugar is not
well defined — it can be glucose, fructose, etc.

5.2.2 Species and balance laws


In systems science, it is common to extend the meaning of species 1 from biology to
denote any quality that we want to quantify. A species could be used to define a
human with certain attributes, a lipoprotein particle of certain size, etc. A species
is thus a fraction of the total mass of a system or the total number of “particles”,
equipped with certain attributes. It follows that if we sum up the mass of species
over all attributes, we find the total mass.
It follows that with a given system, there may be an influent flow rate of a species,
and an effluent flow rate of the species. However, species are more complex: species
may change into other species. A simple example: a person with attribute glasses
may doff his/her glasses and change into a person without glasses. A more complex
example: two lipoprotein particles may collide and stick together into a new, larger
particle, or one particle may split into two smaller particles.
This implies that in a balance law, we need to include influent and effluent flow
rates, and add the possibility of birth and death of the species; in these notes, birth
and death will be combined into generation. If the birth rate is higher than the
death rate, the generation rate is positive, while if the birth rate is lower than the
death rate, the generation rate is negative.

5.2.3 Species and substance


First, let us be more precise with what we mean by species and substance, see also
Smith & Missen (1991).

Definition 5.1. Chemical Species. A chemical species is an entity which can be


distinguished from other entities by:

1. The molecular formula of the entity, or by

2. The molecular structure of the entity, or by

3. The phase in which the entity occurs. N


1
The word “species” is a peculiarity in that the same form is used in singular and plural, thus:
one species, many species.
5.2. THE CONCEPT OF “SPECIES” 141

H H O
H C C H
H OH

ethanol dimethyl ether

Figure 5.1: Isomeric realizations of ethanol (left) and dimethyl ether (right).

Figure 5.2: Barn dance with species M, F, and P.

Example 5.1. Chemical species.


Examples of chemical species distinguished by molecular formula are: H2 , H2 O, H+ ,
OH− , etc. Examples of chemical species distinguished by molecular structure are:
ethanol C2 H6 O (often written C2 H5 OH), and dimethyl ether C2 H6 O (sometimes
written (CH3 )2 O) — although these molecules have the same formula, the structure
and properties are quite different; see Fig. 5.1.
Finally, H2 can exists, e.g., both in gas phase and in liquid phase, where we can
write H2 (g) and H2 (l) to distinguish between these two species. N
Example 5.2. Barn dance.
Suppose we want to describe participants in a barn dance. We may then consider
both male persons, female persons, and a dance pair as species, Fig. 5.2.
Here, P is shorthand notation for MF. The case of a barn dance and the dance
floor in some respect resembles the movement of chemical species in a volume. N
This example indicates that the concept of a species can be used in a wide variety
of applications.
Example 5.3. Barn dance 2.
Let us also consider more elaborate examples of barn dancing: suppose we have
the following species: F, M, P1 , P2 , T, where P1 is shorthand notation for MF, P2
is shorthand notation for F2 , while T is shorthand notation for MF2 , Fig. 5.3.
Although species P1 is the most common constellation on the dance floor, the
constellations P2 and T are also observed, and sometimes explained by a certain
lack of affinity to dancing among elements of species M.
142 CHAPTER 5. SPECIES BALANCE

P1

P2

Figure 5.3: Barn dance with species M, F, P1 , P2 , and T.

Figure 5.4: Ring dance with 3 species: M, F, and R.

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

Example 5.4. Ring dance.

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?

Definition 5.2. Chemical Substance. A chemical substance is an entity which is


distinguishable by molecular formula or molecular structure, but not by phase. N

Example 5.5. Substance.

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

5.3 Mass species balance


In a species balance, we must also include a term for the generation of mass. The
mass species balance can be written as
dmj
= ṁj,i − ṁj,e + ṁj,g
dt
where subscript j indicates the particular species we are considering, while ṁg indi-
cates the rate of generation — typically by a chemical reaction. It follows from the
introductory discussion that, in general

m= mj
j

ṁi = ṁj,i
j

ṁe = ṁj,e
j

ṁg = ṁj,g = 0.
j

Because the species balance contains a generation term ṁj,g , we choose to not
refer to species balance as a conservation law.

5.4 Elements and Molar mass


It is common to think of matter as built up from some basic building blocks; in the
simplest model, we imagine that matter is built from atoms. We will denote such
building blocks by elements.
Definition 5.3. Chemical Elements: The atomic theory of substances is based on
the idea of building blocks — a small number of elements — which constitute the
molecules, see Table 5.1.2 N
More refined theories are based on smaller elements, e.g., protons, electrons, and
neutrons, etc.
Depending on the application, we might also consider other elements than the
chemical elements. In the examples of a barn dance, Figures 5.2–5.4, natural building
blocks may be species F and M.
2
Let Z be the atomic number of an element, Table 5.1. Each nucleus (size ≈ 10−4 Å = 10−5 nm)
of an atom contains Z positively charged protons, N neutral neutrons, and a number of negatively
charged electrons spin around the nucleus at a relatively large distance (2–5 Å). For a neutral
element, the number of electrons equals Z. The mass of protons is 1836 times the mass of electrons,
while the mass of neutrons is slightly larger at 1838 times the mass of electrons.
The mass of an element is thus approximately equal to muZ Z + muN N , where muZ is the mass of a
u
single proton and mN is the mass of a single neutron. For Hydrogen (H), N = 0. For most other
elements, N ≥ Z. Avogadro’s number NA is chosen such that the mass of a Carbon (C) atom is
muC = 12 g/NA . For Carbon, Z = 6 and N = 6, thus muZ ≈ muN ≈ 12 g/NA . Some other examples
of atomic masses are muH ≈ 1.008 g/NA , muHe ≈ 4.003 g/NA , muN ≈ 14.01 g/NA , muO ≈ 16.00 g/NA .
CHAPTER 5. SPECIES BALANCE

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.

5.5 Molar species balance


If every member of a species (e.g., every hydrogen molecule under consideration)
has the same unit mass muj , we can find the number of members in each species as

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

the mass species balance can be transformed as follows:


dmj
= ṁj,i − ṁj,e + ṁj,g
dt

d (Mj nj )
= ṁj,i − ṁj,e + ṁj,g
dt

dnj ṁj,i ṁj,e ṁj,g
= − +
dt Mj Mj Mj

dnj
= ṅj,i − ṅj,e + ṅj,g ,
dt
where we have used that ṅj , ṁj /Mj . Observe that we have “cheated” a little:
although Mj nj is a real number and thus can be differentiated, nj is really a non-
differentiable rational number. However, because nj , Nj /NA where both Nj and
NA normally are very large numbers, nj will appear almost as a real number. Ob-
serve also that when we have more than one species, all particles are not identical
any more, and we can have a generation term ṅj,g .
Here, it follows that

n= nj
j

ṅi = ṅj,i
j

ṅe = ṅj,e
j
∑ ∑ ṁj,g
ṅg = ṅj,g = .
j j
Mj

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.

5.6 Population balance†


When talking about a species balance, we usually classify the content of a system
according to the chemical species in the system volume. But sometimes it is of
interest to classify the content according to more general attributes. In such cases,
we usually talk about a population balance. Examples are:
• The species can be human beings in Norway, and we classify a person based
on this person’s height. We can then count the number of persons with a
5.6. POPULATION BALANCE† 147

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.

• A polymer consists of macro-molecules. In a given polymer sample, there are


many such macro-molecules, and they can have different sizes, either measured
by the mass of the macro-molecule, or measured by the number of building
blocks (monomers) in the macro-molecule. We can then formulate a mass
balance or a mole balance, where the attribute is, e.g., the number of monomers
in the macro-molecule.

• 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

5.7 Extensive vs. intensive variables


In Section 2.2, we saw that it is common to make a distinction between extensive
variables (or: quantities) which has a value that varies with the size or extent of the
system, and intensive variables (or: quantities) for which the value is independent
of the size or extent of the system.
Relevant extensive quantities for the species balances (mass, mole) are the quan-
tities species mass mj and number of moles nj . 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., ṁj 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 species balances
are species quantities per system extension, e.g., species mass per volume (density),
species moles per surface area, etc. However, for species balances it is also common
to use species quantities per total amount of matter, in other words: fractional
species quantities.
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 in that
quantity. It follows that for systems homogeneous in the species mass concentration
ρj ,
mj
ρj = ⇔ mj = ρj V .
V
We could alternatively have used the more generic symbol m′′′ j for the species mass
concentration. Similarly, a system which is homogeneous in the surface density or
length density, satisfy
mj
m′′j = ⇔ mj = m′′j A
A
mj
m′j = ⇔ mj = m′j L.
L
Considering the number of moles, for homogeneous intensive variables, we have
nj
n′′′
j = ⇔ nj = n′′′
j V
V
nj
n′′j = ⇔ nj = n′′j A
A
′ nj
nj = ⇔ nj = n′j L.
L
It is relatively common to use symbol cj to denote molar concentration of species
j, i.e., number of moles of species j per volume: cj = n′′′
nj
j = V . Because symbol cj
has many uses in physics, and due to the similarity between m′′′ ′′′
j and nj , we could
alternatively consider using symbol ρj in both cases, and use, e.g., decoration ˆ· to
imply mass basis and decoration ˜· to imply mole basis. Thus we will let ρ̂j = m′′′ j
and ρ̃j = n′′′
j .
5.7. EXTENSIVE VS. INTENSIVE VARIABLES 149

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.

We could also introduce the molar fraction xj as an intensive quantity, defined


by ˆ
nj = xj dn
V
or
dnj
xj , ,
dn
which in a homogeneous system simplifies to

nj = xj n.

For mixtures of substances in a volume, we introduce the partial pressure pj of


species j, defined as the fraction of the force per surface area caused by species j.
It follows that the total pressure p is given as

p= pj .
j
150 CHAPTER 5. SPECIES BALANCE

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.

5.8 Equations of State


We have considered some Equations of State (EoS) for pure substances in Section
4.5. Can these be used in mixtures of multiple substances?
The answer is yes. The ideal gas law simply becomes
pj V = nj RT (5.1)
where pj is the partial pressure of substance j while ∑
nj is the number of moles of
substance j. The total pressure p is then simply p = j pj .
Similarly, for flow, the ideal gas law becomes
pj V̇ = ṅj RT (5.2)
where ṅj is the molar flow rate of substance j.
What about cubic Equations of State? A common strategy is to use the cubic
EoS as in Section 4.5, but to define mixing rules for how to compute parameters
n
a (T ) and b in the models. Let xj , nj be the mole fraction of species j in the gas
phase in question. Then the cubic EoS are often used as in Section 4.5, but with
mixture values a (T ) and b defined as follows:

ns ∑ns
a (T ) = xj xk ajk (T ) (5.3)
j=1 k=1
∑ns
b= x j bj , (5.4)
j=1

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

5.9 Rates of generation


5.9.1 Chemical reactions
Chemical reactions may be described as
ν1 S1 + ν2 S2 + · · · + νns Sns
0
where νj is a number multiplying species Sj , and ns is the number of species. In
this description, we let the products in the reaction have positive number νj while
the reactants have a negative number νj .6
Example 5.6. [Non-stoichiometric reaction]
Consider the following reaction between hydrogen and oxygen:
H2 + O2
H2 O,
which can be written as
−H2 − O2 + H2 O
0,
and we see that we can let (ν1 , S1 ) = (−1, H2 ), (ν2 , S2 ) = (−1, O2 ) and (ν3 , S3 ) =
(+1, H2 O), where ns = 3. Clearly, since ν1 and ν2 are negative numbers, while ν3 is
a positive number, we have assumed that H2 O is the product in the reaction, while
H2 and O2 are the reactants. N
In the above example, we have not utilized that molecules are built up from a
finite number of elements (H, He, etc., i.e., the elements as given in the Periodic
Table of Chemistry, Table 5.1). Thus, the absolute value of νj is unity, i.e., |νj | = 1.
If we include a balance of elements in the chemical reaction, i.e., such that each
element appears with the same number of elements in reactants and products, we
have a stoichiometric reaction.
Example 5.7. [Stoichiometric reaction]
The stoichiometric reaction of hydrogen and oxygen into water is often written
as
2H2 + O2
2H2 O,
which can be written as
−2H2 − O2 + 2H2 O
0.
Here, the number of hydrogen atoms H with negative coefficient νj is 4, and the
number of hydrogen atoms with positive coefficient νj is also 4. A similar balance
is valid for the other element, oxygen. Hence we have a stoichiometric reaction. We
see that for stoichiometric reactions, some reaction coefficients will normally differ
from unity in absolute value. N
Often, several chemical reactions occur simultaneously. These can be written as
ν11 S1 + · · · + ν1ns Sns
0
..
.
νnr 1 S1 + · · · + νnr ns Sns
0
6
Note: ν is the Greek lower-case (minuscule) version of letter N; it is not letter v!
152 CHAPTER 5. SPECIES BALANCE

where nr is the number of chemical reactions/processes taking place. This can be


written in matrix form as
νS
0 (5.6)
where ν is the (stoichiometric) matrix
 
ν11 ··· ν1ns
 .. ... .. 
ν= . . 
νnr 1 · · · νnr ns

and S is the column vector of species


 
S1
 
S =  ...  .
Sns

5.9.2 Reaction rates


For each of nr chemical reactions, we can write down a reaction rate rk , k ∈
{1, 2, . . . , nr }. One theory of how reactions take place, is through collision between
molecules: for a reaction to take place, two (or more) particles must collide. A
certain fraction of the colliding particles react into a new particle. Consider the
reaction
A + B → C.
The number of collisions between particles of species A and species B is proportional
to their molar concentrations, cA and cB , thus the number of collisions is ∝ cA · cB .
A fraction of these collisions lead to a new species C, thus the reaction rate r is

r = kcA cB

according to this collision theory. Furthermore, if the temperature increases, the


movement of the particles become more “agitated”, and the probability of collision
increases. It follows that k is a function of temperature, k (T ). Clearly, the probabil-
ity of more than two particles colliding at the same time is very small, so reactions
involving more than two particles is quite rare.
If the reaction is reversible in that it goes both ways, e.g.,

A + B
C,

we postulate a forward reaction rate r+ for the forward reaction

A+B→C

and a backward reaction rate r− for the backward reaction

A + B ← C.

The total reaction rate is thus r = r+ − r− .


5.9. RATES OF GENERATION 153

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.

Example 5.8. [Stoichiometric reaction and reaction rate]

Consider the single stoichiometric, elementary reaction

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

5.9.3 Reaction equilibrium and rate constants


Assume a single reaction
aA + bB
rR + sS.

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

where pς = 1 atm and p̄ is a scaled, dimensionless pressure. Then

(p̄R )r (p̄S )s
K= = Kp ;
(p̄A )a (p̄B )b

if pς ̸= 1 atm, then Kp ̸= K.8


If a gas reaction rate is elementary, we have
( )a ( )b ( )r ( )s
f f f f
r = k+ − k− .
f◦ A f◦ B f◦ R f◦ S

If we, furthermore, assume fj ≈ pj and use standard state at 1 atm, we have

r = k+ (p̄A )a (p̄B )b − k− (p̄R )r (p̄S )s .

In equilibrium, r = 0 and

k+ (p̄R )r (p̄S )s
= = Kp ⇒ k+ = k− Kp .
k− (p̄A )a (p̄B )b

Thus, if we compute Kp and its dependence of T , and if we know k− (T ), then k+ (T )


is given as
k+ (T ) = k− (T ) · Kp (T ) .

A similar expression may be posed for liquid phase reactions.


8
It is normal to denote the equilibrium constant by Kp when it is given in terms of (partial)
pressures.
5.9. RATES OF GENERATION 155

5.9.4 Reaction rate vs. generation rate


In the molar species balance, we need to relate the reaction rates r defined as
 
r1
 
r ,  ... 
rnr

(one for each reaction) with the molar rates of generation ṅg defined as
 
ṅ1,g
 
ṅg ,  ...  .
ṅns ,g

It can be shown that ˆ


T
ṅg = ν rdV
V

where ν T is the transpose of stoichiometric matrix ν.


Here, we could define a generation rate rg

rg , ν T r,

hence ˆ
ṅg = rg dV .
V

5.9.5 Homogeneous system


In many cases, we consider system volumes where an impeller is used to stir the
volume content in order to have some perfect mixing of the content. The idea of
this perfect or ideal mixing is that the concentrations of the various species as well as
the temperature are the same everywhere in the volume, in other words: the system
is homogeneous in the concentrations and temperature.
The assumption of homogeneous system simplifies the task of developing models
in a number of ways:

1. The relationship between number of moles nj and molar concentration cj sim-


plifies to
n j = cj V ,
and similarly the relationship between mass mj and specific concentration ρj
simplifies to
mj = ρj V .

2. The relationship between molar rate of generation and reaction rates simplifies
to
ṅg = ν T rV .
156 CHAPTER 5. SPECIES BALANCE

3. Here, we can introduce the generation rate rg as

rg = ν T r

where
ṅg = rg V .

If we insist on using mass species balance, we have

ṁg = diag (M1 , . . . Mns ) · ν T rV ,

where r normally is a function of molar concentrations cj , but it is trivial


to convert r to become a function of specific concentrations by utilizing the
relationship cj = ρj /Mj .

4. The molar flow rate out of a system can be written as

ṅ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 .

The idea of a homogeneous system volume is a key simplifying assumption when


developing models of systems. Even when the system volume is not ideally mixed,
we use this assumption: we subdivide the system into many smaller volumes, where
we assume that when these volumes are sufficiently small, each of them can be
assumed homogeneous.

5.9.6 Reaction invariants and variants+


If we stack up the species variables in vectors such that
   
n1 ṅ1,i
   
nS =  ...  , ṅS,i =  ...  ,
nns ṅns ,i
   
ṅ1,e r1,g
   
ṅS,e =  ...  , rS,g =  ... 
ṅns ,e rns ,g

then for a homogeneous system, the molar species balances become


dnS
= ṅS,i − ṅS,e + ν T rS,g V ,
dt
where in general ν ∈ Rnr ×ns is a matrix with nr reaction rates and ns species.
Let us now introduce a linear transformation of the unknowns, i.e., let us con-
struct a new variable z = wT nS where w is a column vector of weights in the
5.9. RATES OF GENERATION 157
∑ns
transformation, i.e., z = j=1 wj nS,j . The differential equation for the new pseudo
species z is given by

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

where Wz ∈ Rnz ×ns .


It turns out that there is a complementary space to N (ν), which is an orthogonal
complement N (ν)⊥ . We can thus similarly find basis vectors Wζ for N (ν)⊥ and
construct another vector of pseudo species ζ ∈ Rns −nz as a linear transformation

ζ = Wζ nS .

This pseudo species ζ has dimension ns − nz = rankν, and is reaction variant. It


follows that we have ( ) ( )
z Wz
= nS
ζ Wζ
| {z }
W

where matrix W is invertible.


In summary, we thus have
 T
≡0
dz z }| {
= żi − że + ν · Wz  rV = żi − że
dt

= ζ̇i − ζ̇e + (ν · Wζ )T rV
dt
158 CHAPTER 5. SPECIES BALANCE

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:

1 >>> from sympy import Matrix % Import the necessary


subpackage of
2 % package sympy
3 >>> A = [[...] , [...] , ... ,[...]] % Define A as a two -
dimensional array
4 >>> A = Matrix ( A ) % Convert the two -
dimensional array
5 % into a matrix
6 >>> A . nullspace () % Use method " nullspace "
to extract
7 % the nullspace
where the answer has matrix elements which are rational numbers.
There is, however, no direct function for computing the column space C (A). To
compute the column space, we can use the QR decomposition of matrices

A = QR

where Q is an orthogonal matrix, QT Q = I and R is an upper triangular matrix.


For the case that matrix A has full column rank, i.e., r = rankA = n, the structure
of Q and R are as follows:
( )
R̃n×n
R=
0(m−n)×n
( )
Q = Q̃m×n Q̄m×(m−n)

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

where v is the velocity component perpendicular to the surface. If the velocity is


orthogonal to the surface and uniform, we simply have

V̇ = vA.

In a mixture of several substances, the various substances will move at different


linear velocities vj . Due to the importance of an average linear velocity in the
momentum balance, it is of interest to relate the individual velocities vj to some
average velocity v. To this end, let us define the mass average velocity v̂ as

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

Similarly, let us define the molar average velocity ṽ as


1∑ s n
ṽ = ρ̃j vj
ρ̃ j=1

where ∑ns
n j=1 nj ∑
ns
ρ̃ = = = ρ̃j .
V V j=1

5.10.2 Diffusion flux


Next, we define the difference between velocity vj of species j, and the average
velocity v̂ by the following expression:
Jˆj = ρ̂j (vj − v̂) ⇔ ρ̂j vj = ρ̂j v̂ + Jˆj .
Here, Jˆj is the diffusion mass flux for species j; it follows that Jˆj has dimension
mass/volume × length/time, or mass/(area·time).
Similarly, we define the difference between velocity vj of species j, and the aver-
age velocity ṽ by the following expression:
J˜j = ρ̃j (vj − ṽ) ⇔ ρ̃j vj = ρ̃j ṽ + J˜j .
Here, J˜j is the diffusion mass flux for species j; it follows that J˜j has dimension
number of mole/volume × length/time, or number of mole/(area·time).

5.10.3 Binary mixtures


In a binary mixture where ns = 2, we have
ρ̂ = ρ̂1 + ρ̂2 ,
and
1
v̂ = (ρ̂1 v1 + ρ̂2 v2 ) ⇔ ρ̂v̂ = ρ̂1 v1 + ρ̂2 v2
ρ̂
Then
Jˆ1 = ρ̂1 (v1 − v̂)
Jˆ2 = ρ̂2 (v2 − v̂) .
We find that
Jˆ1 + Jˆ2 = ρ̂1 (v1 − v̂) + ρ̂2 (v2 − v̂)

Jˆ1 + Jˆ2 = ρ̂1 v1 + ρ̂2 v2 − (ρ̂1 + ρ̂2 )v̂
| {z } | {z }
ρ̂v̂ ρ̂


Jˆ1 + Jˆ2 ≡ 0.
Similarly, for a binary mixture, we also find that
J˜1 + J˜2 ≡ 0.
5.10. DIFFUSION 161

5.10.4 Model of diffusion flux


In order to have a complete model, we must introduce expressions for Jˆj in the case
of species mass balance, and J˜j in the case of species mole balance. The common
strategy is to find expressions for J˜j : it is simpler to argue for the expressions when
we start with the mole concept, since the flux is caused by mechanisms that depend
on the number of particles. The expressions for Jˆj and J˜j are denoted transport laws,
since they describe how certain quantities (here: matter) are transported through
the system.
A common transport law for J˜j is Fick’s law:
∂ ρ̃j
J˜j = −D̃j ,
∂x
where Dj is the diffusion coefficients. In binary mixtures, we have ρ̃2 = ρ̃ − ρ̃1 , and
thus
∂ ρ̃1 ∂ (ρ̃ − ρ̃1 )
J˜1 + J˜2 = −D̃1 − D̃2
∂x ∂x

( ) ∂ ρ̃ ∂ ρ̃
1
J˜1 + J˜2 = − D̃1 − D̃2 − D̃2 .
∂x ∂x
The total mass balance in a distributed system can be expressed as10
∂ ρ̃ ∂ (ṽ ρ̃)
+ = 0,
∂t ∂x
∂ ρ̃
thus in (i) steady state and (ii) assuming constant velocity ṽ, it follows that ∂x
= 0.
Then
( ) ∂ ρ̃ ∂ ρ̃
1
J˜1 + J˜2 = − D̃1 − D̃2 − D̃2 =0
∂x ∂x
|{z}
=0

D̃1 = D̃2 .

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

Figure 5.5: Vessel where two input flows are mixed.

5.11 Case: Liquid level in tank with two species

5.11.1 Model objective

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.

5.11.2 Model development


We assume that the system is homogeneous in the liquid densities ρA and ρB ; this
implies that the liquids are miscible.11 We furthermore assume that the mixture
constitutes an ideal solution. There is no reaction in the system. Also, we assume
that the tank has a constant cross sectional area A.
We divide the model development into four steps: in the first step, we introduce
the needed balance law, in the second step we relate external quantities (influents,
effluents) to the quantities in the fundamental law, in the third step we manipulate
the model into the desired form, and in the fourth step we relate the computed
variables with the outputs.

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

ṁj,ik = ρj,ik V̇ik

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

Table 5.3: Parameters for tank with liquid mixing.


Parameter Value Unit Comment
A 25 dm2 Cross sectional tank area
ρ•A 1 kg/L Pure substance density of A
ρ•B 0.8 kg/L Pure substance density of B

5.11.3 Model summary


The model can be summarized in a form suitable for implementation in Modelica as

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
V̇e
ṁA,e = ρA
V
V̇e
ṁB,e = ρB
V
mA
ρA =
V
mB
ρB =
V
V = VA• + VB•
mA
VA• = •
ρA
mB
VB• = •
ρB
V = Ah.

The outputs are given as


y = (h, ρA , ρB ) .
To complete the model description, we need to specify model parameters and
operating conditions. We choose the following parameters for the model, Table 5.3.
The operating conditions (initial state, input) are defined in Table 5.4.

5.11.4 Model simulation


Using OpenModelica, the results of simulating the system are as in Figs. 5.7–5.8.
166 CHAPTER 5. SPECIES BALANCE

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

Level for liquid mixing tank


4.4
4.3
4.2
4.1
h [dm]

4.0
3.9
3.8
3.7
3.6
0 50 100 150 200 250 300
time t [s]

Figure 5.7: Liquid level h for liquid mixing tank.


5.11. CASE: LIQUID LEVEL IN TANK WITH TWO SPECIES 167

Specific concentrations for liquid mixing tank


0.550 [kg/L]
A
0.525 B [kg/L]
0.500
0.475
0.450
0.425
0.400
0.375

0 20 40 60 80 100 120 140


time t [s]

Figure 5.8: Specific concentrations ρA and ρB for liquid mixing tank.

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

5.11.5 Alternative states


So far, the model has been based on states mA and mB , and from these two states,
we can compute the outputs y = (h, ρA , ρB ). An interesting question is: could we
have chosen to use some of the outputs as states? To answer this, we start by
observing that

V = V̄j
j


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

In the expression for dρdtA , we replace dm dt


A
and dmdt
B
with the right hand side (RHS)
of the original mass balances, and find:
( )
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

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

If we eliminate the algebraic expressions, we get


( )
dρA ρA ( )
Ah = 1− • V̇i1 ρA,i1 + V̇i2 ρA,i2 − V̇e ρA
dt ρ
( A ( ))
ρA • ρA
− • V̇i1 ρB,i1 + V̇i2 ρB,i2 − V̇e ρB 1 − •
ρB ρA
dh 1 ( )
A = • V̇i1 ρA,i1 + V̇i2 ρA,i2 − V̇e ρA
dt ρA
( ( ))
1 • ρA
+ • V̇i1 ρB,i1 + V̇i2 ρB,i2 − V̇e ρB 1 − • .
ρB ρA
172 CHAPTER 5. SPECIES BALANCE

Figure 5.9: Reactor with varying volume V , and reaction aA → B.

5.12 Case: Liquid phase, varying volume reaction


5.12.1 Model objective
We consider the liquid reactor in Fig. 5.9, where a fluid with influent volumetric
flow rate V̇i carries species A at molar concentration cA,i into the tank of varying
volume.
Within the tank, a chemical reaction takes place with stoichiometric reaction
aA → B,
and reaction rate relative to product B given as
r = kcaA .
The liquid is driven out of the tank at volumetric flow rate V̇e .
It is of interest to know how the inputs to the system influences the behavior of
the liquid level h, and the effluent molar concentrations cA and cB .
The model objective is succinctly described in the functional diagram in Fig.
5.10.
The functional diagram depicts the causality of the system (“Liquid phase vary-
ing volume reactor”) where inputs (green arrow) V̇i , cA,i cause a change in the system
which is observed in the outputs (orange arrow) h, cA and cB .

5.12.2 Model development


We assume that the system is homogeneous in the liquid density ρ and the molar
concentrations cA and cB , and that species A and B are present in such small con-
centrations in a solvent that their variation does not influence the total density of
5.12. CASE: LIQUID PHASE, VARYING VOLUME REACTION 173

Liquid phase
varying volume
reactor

Figure 5.10: Functional diagram of varying volume liquid phase 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}.

Step 2: Because the density is not influenced by the molar concentrations cj , we


assume that the influent density equals ρ. With a system homogeneous in the
density, we thus have

m = ρV
ṁi = ρV̇i .

With constant cross sectional area, the volume is given by

V = Ah.

The effluent flow is driven by gravity, thus



h
ṁe = K .
hs

Next, we turn to the molar species balance. In a homogeneous/well mixed


system,

n j = cj V
ṅj,e = cj V̇e
174 CHAPTER 5. SPECIES BALANCE

where
ṁe
V̇e = .
ρ

The influent molar flow rate is

ṅj,i = cj,i V̇i .

Finally, we turn to the generation term. The stoichiometric reaction can be


written as
( )
( ) A
aA → B ⇒ −a 1 ← 0.
| {z } B
ν | {z }
S

The vector of generation rates is then

rg = ν T r,

and
rj,g = νj r

in our case. Finally, in a homogeneous system ṅj,g = rj,g V .

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

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 .

We could summarize the model as


dx
= f (x, z, u; θ)
dt
0 = g (x, z, u; θ)
where
( )
u = V̇i , cA,i
x = (nA , nB )
( )
z = V, h, ṁi , ṁe , cA , cB , ṅA,i , ṅB,i , ṅA,e , ṅB,e , V̇e , ṅA,g , ṅB,g , rA,g , rB,g , r .

The model parameters are


θ = (ρ, A, K, hς , a, k) .

Step 4: The sought properties in the system are h, cA and cB , or


y = (h, cA , cB ) .
We see that all outputs y are among the algebraic variables z, and they are
thus computed from the model. The model thus gives a relation between the
inputs u and the outputs.

5.12.3 Model summary


The model is summarized in Step 3 and Step 4 in the previous section.
To complete the model description, we need to specify model parameters and
operating conditions. We choose the following parameters for the model, Table 5.5.
The operating conditions (initial state, input) are defined in Table 5.6.
176 CHAPTER 5. SPECIES BALANCE

Table 5.5: Parameters for liquid reactor with varying level.


Parameter Value Unit Comment
ρ 1 kg/L Density of liquid
2
A 5 dm Constant cross sectional area
K 5 kg/s Valve constant
hς 3 dm Level scaling
a 2 — Stoichiometric constant
1−α
k 0.1 (mol/L) /s Reaction constant

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

5.12.4 Model simulation


Using OpenModelica, the results of simulating the system are as in Figs. 5.11–5.12.
The following Modelica code (file VaryingVReactor.mo) is used to produce the
figures.

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

Level + concentrations in liquid reactor


2.00
h
1.75 cA
cB
1.50
1.25
1.00
0.75
0.50
0.25
0.00
0 2 4 6 8 10 12 14
time t [s]

Figure 5.11: Varying liquid level h, and molar concentrations cA and cB .

Inputs in liquid reactor


3.0 Vi
cA, i
2.8

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

22 output Real _h " Level in tank , dm ";


23 output Real _cA " Molar concentration of A in tank , mol / L
";
24 output Real _cB " Molar concentration of B in tank , mol / L
";
25 // Equations
26 equation
27 // -- input values
28 Vdi = if time < 5 then 2 else 2.5;
29 // Vde = if time < 100 then 2 else 2.1;
30 cAi = if time < 10 then 3 else 2;
31 // -- injecting input functions to model inputs
32 vvr . Vdi = Vdi ;
33 vvr . cAi = cAi ;
34 // -- outputs
35 _h = vvr . h ;
36 _cA = vvr . cA ;
37 _cB = vvr . cB ;
38 end S imVaryingV Re act or ;
39 //
40 model ModVaryin gV Re ac to r
41 // Model of liquid reactor
42 // author : Bernt Lie
43 // University of South - Eastern Norway
44 // September 9 , 2015
45 // May 11 , 2017
46 //
47 // Parameters
48 parameter Real rho = 1 " Liquid density , kg / L ";
49 parameter Real A = 5 " Cross sectional area of tank , dm2 ";
50 parameter Real K = 5 " Valve constant , kg / s ";
51 parameter Real h_s = 3 " Level scaling , dm ";
52 parameter Real a = 2 " Stoichiometric constant , -";
53 parameter Real k = 0.1 " Reaction constant , ( mol / L ) ^(1 - a ) /
s ";
54 parameter Real [2] nu = { -a , 1} " Stoichiometric matrix ";
55 // Initial state parameters
56 parameter Real h0 = 1.5 " Initial liquid level , dm ";
57 parameter Real m0 = rho * h0 * A " Initial liquid mass , kg ";
58 parameter Real nA0 = 2 " Initial number of moles , species
A ; mol ";
59 parameter Real nB0 = 0 " Initial number of moles , species
B ; mol ";
60 // Declaring variables
61 // -- states
62 Real m ( start = m0 , fixed = true ) " Liquid mass , kg ";
63 Real nA ( start = nA0 , fixed = true ) " Number of moles of
species A , mol ";
64 Real nB ( start = nB0 , fixed = true ) " Number of moles of
5.12. CASE: LIQUID PHASE, VARYING VOLUME REACTION 179

species B , mol ";


65 // -- auxiliary variables
66 Real V " Liquid volume , L ";
67 Real h " Liquid level , dm ";
68 Real mdi " Influent mass flow rate , kg / s ";
69 Real mde " Effluent mass flow rate , kg / s ";
70 Real cA " Molar concentration of species A , mol / L ";
71 Real cB " Molar concentration of species B , mol / L ";
72 Real ndAi " Influent molar flow rate of species A , mol / s ";
73 Real ndBi " Influent molar flow rate of species B , mol / s ";
74 Real ndAe " Effluent molar flow rate of species A , mol / s ";
75 Real ndBe " Effluent molar flow rate of species B , mol / s ";
76 Real Vde " Effluent volumetric flow rate , L / s ";
77 Real ndAg " Molar rate of generation of species A , mol / s ";
78 Real ndBg " Molar rate of generation of species B , mol / s ";
79 Real rAg " Generation rate of species A , mol /( L . s ) ";
80 Real rBg " Generation rate of species B , mol /( L . s ) ";
81 Real r " Reaction rate , mol /( L . s ) ";
82 // -- input variables
83 input Real Vdi " Influent volumetric flow rate , L / s ";
84 input Real cAi " Influent concentration of species A , mol /
L ";
85 // Equations constituting the model
86 equation
87 // Differential equations
88 der ( m ) = mdi - mde ;
89 der ( nA ) = ndAi - ndAe + ndAg ;
90 der ( nB ) = ndBi - ndBe + ndBg ;
91 // Algebraic equations
92 m = rho * V ;
93 V = A*h;
94 mdi = rho * Vdi ;
95 mde = K * sqrt ( h / h_s ) ;
96 nA = cA * V ;
97 nB = cB * V ;
98 ndAi = cAi * Vdi ;
99 ndBi = 0;
100 ndAe = cA * Vde ;
101 ndBe = cB * Vde ;
102 Vde = mde / rho ;
103 ndAg = rAg * V ;
104 ndBg = rBg * V ;
105 rAg = nu [1]* r ;
106 rBg = nu [2]* r ;
107 r = k * cA ^ a ;
108 end M odVaryingV Re act or ;
109 // End package
110 end VaryingVReactor ;
180 CHAPTER 5. SPECIES BALANCE

Concentrations in liquid batch reactor


cA
0.25 cB
0.20

0.15

0.10

0.05

0.00
0 2 4 6 8 10 12 14
time t [s]

Figure 5.13: Molar concentrations cA and cB in the case of a batch reactor.

5.12.5 Batch reactor


In case we want to study a batch reactor, i.e., a closed reactor where there are no
influents and no effluents, we simply set V̇i ≡ 0 and redefine V̇e to always be zero
— e.g., by setting K = 0. In this case, the level is constant, and the concentrations
vary as in Fig. 5.13.
From the stoichiometric reaction aA → B, it is clear that a number of A
molecules disappear each time one molecule of B is generated. Thus, a reduction
of ∆nA moles of species A due to the reaction leads to an increase of a1 ∆nA moles
of species B: ∆nB = − a1 ∆nA , or ∆nA + a∆nB = 0. It follows that for the batch
reactor (nA (t) − nA (t = 0)) + a (nB (t) − nB (t = 0)) = 0, or

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 .

5.12.6 Reaction invariants and reaction variants+


In a more general setting, we could use the ideas from Section 5.9.6 where with
a = 2, matrix ν is given as ( )
ν = −2 1 .
To find the weighting matrices Wz and Wζ in Section 5.9.6, we run the following
Python script reactionInvariantVariant.py:

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:

1 In [1]: runfile ( ’C :/ Users / berntl /.../ r e a c t i o n I n v a r i a n t V a r i a n t


. py ’ ,
2 wdir = ’C :/ Users / berntl /.../ PyModelica ’)
3 Basis for reaction invariant
4 Matrix ([[1/2] , [1]])
5 # reaction variants
6 1
7 Basis for reaction variant - first columns of :
8 Matrix ([[ -2* sqrt (5) /5] , [ sqrt (5) /5]]

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

can be used to find new pseudo species. Thus, species

1
z = nA + nB
2
182 CHAPTER 5. SPECIES BALANCE

should be reaction invariant, while species

ζ = −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

= 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

Figure 5.14: Fixed volume reactor with reaction aA → B.

Liquid phase
fixed volume
reactor

Figure 5.15: Functional diagram of fixed volume liquid phase reactor.

5.13 Case: Liquid phase, constant volume reactor


5.13.1 Model objective
We consider the case in Section 5.12.1, but with a fixed volume, Fig. 5.14.
Again, species A and B are assumed to be diluted in, e.g., water (the third
specie), and their concentrations are assumed to be small. We are interested in how
the influent volumetric flow rate V̇ and the influent concentration of species A, cA,i
influence the effluent concentrations of species A and B, cA and cB .
The model objective is described in the functional diagram in Fig. 5.15, where
the inputs are V̇ and cA,i influence the behavior of the outputs are cA and cB .

5.13.2 Model development


We assume that the system is homogeneous in the liquid density ρ, and that species
A and B are present in so small quantities that their variation does not change the
liquid density ρ. Because of constant density and constant volume, we will see that
this results in equality between the influent and the effluent volumetric flow rates.
The reaction rate is assumed to be as in Section 5.12.1.
The following steps describe the model development.
Step 1: The total mass balance is
dm
= ṁi − ṁe .
dt
To find the molar concentrations, we need the molar species balance,
dnj
= ṅj,i − ṅj,e + ṅj,g
dt
184 CHAPTER 5. SPECIES BALANCE

where j ∈ {A, B}.

Step 2: Because of constant density and constant volume, we find

m = ρV
ṁi = ρV̇i
ṁe = ρV̇e

leading to
d
0= (ρV ) = ρV̇i − ρV̇e ⇒ V̇i = V̇e = V̇ .
dt

Next, we turn to the molar species balance. In a homogeneous/well mixed


system,

n j = cj V
ṅj,e = cj V̇e = cj V̇ .

The influent molar flow rate is

ṅj,i = cj,i V̇i = cj,i V̇ .

Finally, we turn to the generation term. The stoichiometric reaction can be


written as ( )
( ) A
aA → B ⇒ −a 1 ← 0.
| {z } B
ν | {z }
S

The vector of generation rates is then

rg = ν T r,

and
rj,g = νj r

in our case. Finally, in a homogeneous system ṅj,g = rj,g V .

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 .

We could summarize the model as


dx
= f (x, z, u; θ)
dt
0 = g (x, z, u; θ)

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) .

The model parameters are


θ = (V, a, k) .

Step 4: The sought properties in the system are cA and cB , or

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.

5.13.3 Model summary


The model is summarized in Step 3 and Step 4 in the previous section.
To complete the model description, we need to specify model parameters and
operating conditions. We choose the following parameters for the model, Table 5.7.
The operating conditions (initial state, input) are defined in Table 5.8.
186 CHAPTER 5. SPECIES BALANCE

Table 5.7: Parameters for liquid reactor with fixed volume.


Parameter Value Unit Comment
V 15 L Reactor volume
a 2 — Stoichiometric constant
1−α
k 0.1 (mol/L) /s Reaction constant

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

Concentrations in liquid reactor


1.2 cA
cB
1.0

0.8

0.6

0.4

0.2

0.0
0 2 4 6 8 10 12 14
time t [s]

Figure 5.16: Molar concentrations cA and cB in fixed volume reactor.


5.13. CASE: LIQUID PHASE, CONSTANT VOLUME REACTOR 187

Inputs in liquid reactor


3.0 V
cA, i
2.8

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 .

5.13.4 Model simulation


Using OpenModelica, the results of simulating the system are as in Figs. 5.16–5.17.
The following Modelica code (file FixedVReactor.mo) is used to produce the
figures.

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

67 Real rBg " Generation rate of species B , mol /( L . s ) ";


68 Real r " Reaction rate , mol /( L . s ) ";
69 // -- input variables
70 input Real Vd " Volumetric flow rate , L / s ";
71 input Real cAi " Influent concentration of species A , mol /
L ";
72 // Equations constituting the model
73 equation
74 // Differential equations
75 der ( nA ) = ndAi - ndAe + ndAg ;
76 der ( nB ) = ndBi - ndBe + ndBg ;
77 // Algebraic equations
78 nA = cA * V ;
79 nB = cB * V ;
80 ndAi = cAi * Vd ;
81 ndBi = 0;
82 ndAe = cA * Vd ;
83 ndBe = cB * Vd ;
84 ndAg = rAg * V ;
85 ndBg = rBg * V ;
86 rAg = nu [1]* r ;
87 rBg = nu [2]* r ;
88 r = k * cA ^ a ;
89 end ModFixedVReactor ;
90 // End package
91 end FixedVReactor ;

5.14 Case: Gas phase reactor

5.14.1 Model objective


We consider the gas phase reactor in Fig. 5.18, where a gas of pure species A at
influent pressure pi flows into a reactor of volume V at influent volumetric flow rate
V̇i . Within the reactor, species A reacts to species B in the reaction aA → B at a
reaction rate
r = kpaA

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

Figure 5.18: Gas reactor with reaction aA → B.

Gas reactor

Figure 5.19: Functional diagram of gas phase reactor.

5.14.2 Model development


The system is homogeneous in the relevant intensive quantities. The reaction rate
is assumed to be as in Section 5.12.1. The following steps describe the model devel-
opment.
Step 1: To find the partial pressures, we need the molar species balance,
dnj
= ṅj,i − ṅj,e + ṅj,g
dt
where j ∈ {A, B}.

Step 2: From the ideal gas law, we have for j ∈ {A, B} that

pj V = nj RT

p= pj
j

pj,k V̇k = ṅj,k RT

where k ∈ {i, e}, √


∆pk
V̇k = Kk

where we choose scaling pressure pς = pa , and

∆pi = pi − p
∆pe = p − pa .
5.14. CASE: GAS PHASE REACTOR 191

In a homogeneous/well mixed system,


pj,e = pj .
The stoichiometric reaction has a stoichiometric matrix ν
( )
ν = −a 1 .
The vector of generation rates is then
rg = ν T r,
hence
rj,g = νj r
in our case. Finally, in a homogeneous system ṅj,g = rj,g V .
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
where
pA V = nA RT
pB V = nB RT
p = pA + pB

∆pi
V̇i = Ki

∆pi = pi − p
pi V̇i = ṅA,i RT
ṅB,i = 0

∆pe
V̇e = Ke

∆pe = p − pa
pA V̇e = ṅA,e RT
pB V̇e= ṅB,e RT
ṅA,g = rA,g V
ṅB,g= rB,g V
rA,g = ν1 r
rB,g = ν2 r
( )
ν = −a 1
r = kpaA .
192 CHAPTER 5. SPECIES BALANCE

Table 5.9: Parameters for isothermal gas reactor.


Parameter Value Unit Comment
V 15 L Reactor volume
J
R 8.31 mol K
Gas constant
T 300 K Temperature in system and environment
Ki 5 × 10−4 mol
s
Influent valve constant
pa 1.01 × 10 Pa
5
Atmospheric pressure
ς
p = pa Pa Scaling pressure
Ke 5 × 10−4 mol
s
Effluent valve constant
a 2 — Stoichiometric constant
−9 mol/L
k 10 (Pa)α s
Reaction constant

We could summarize the model as


dx
= f (x, z, u; θ)
dt
0 = g (x, z, u; θ)
where
u = (pi )
x = (nA , nB )
( )
z = pA , pB , p, V̇i , ∆pi , ṅA,i , ṅB,i , V̇e , ∆pe , ṅA,e , ṅB,e , ṅA,g , rA,g , ṅB,g , rB,g , r .

The model parameters are


θ = (V, R, T, Ki , pa , Ke , a, k) .

Step 4: The sought properties in the system are pA , pB , and p, or


y = (pA , pB , p) .
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.

5.14.3 Model summary


The model is summarized in Step 3 and Step 4 in the previous section.
To complete the model description, we need to specify model parameters and
operating conditions. We choose the following parameters for the model, Table 5.9.
The operating conditions (initial state, input) are defined in Table 5.10.

5.14.4 Model simulation


Using OpenModelica, the results of simulating the system are as in Figs. 5.20–5.21.
The following Modelica code (file GasReactor.mo) is used to produce the figures.
5.14. CASE: GAS PHASE REACTOR 193

Table 5.10: Operating conditions for isothermal gas reactor.


Quantity Value Unit Comment
nA (0) 3 mol Initial number of moles of species A
nB (0) 0 mol Initial number of moles of species B
pi 10pa Pa Influent pressure (pure species A)

Partial + total pressures in gas reactor


500000 p
pA
400000 pB

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]

Figure 5.21: Influent pressure pi (pure species A) to gas phase reactor.


194 CHAPTER 5. SPECIES BALANCE

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

49 parameter Real Ke = 5e -4 " Effluent valve constant , mol / s


";
50 parameter Real a = 2 " Stoichiometric constant , -";
51 parameter Real [2] nu = { -a ,1} " Stoichiometric matrix , -";
52 parameter Real k = 1e -9 " Reaction constant , ( mol / L ) /( Pa ^ a
. s ) ";
53 // Initial state parameters
54 parameter Real nA0 = 3 " Initial amount of species A , mol
";
55 parameter Real nB0 = 0 " Initial amount of species B , mol
";
56 // Declaring variables
57 // -- states
58 Real nA ( start = nA0 ) " Amount of species A in volume , mol
";
59 Real nB ( start = nB0 ) " Amount of species B in volume , mol
";
60 // -- auxiliary variables
61 Real pA " Partial pressure of species A , Pa ";
62 Real pB " Partial pressure of species B , Pa ";
63 Real p " Pressure in reactor , Pa ";
64 Real Vdi " Influent volumetric flow rate , m3 / s ";
65 Real dpi " Influent valve pressure drop , Pa ";
66 Real ndAi " Influent molar flow rate of A , mol / s ";
67 Real ndBi " Influent molar flow rate of B , mol / s ";
68 Real Vde " Effluent voumetric flow rate , m3 /2";
69 Real dpe " Effluent valve pressure drop , Pa ";
70 Real ndAe " Effluent molar flow rate of A , mol / s ";
71 Real ndBe " Effluent molar flow rate of B , mol / s ";
72 Real ndAg " Molar rate of generation of A , mol / s ";
73 Real rAg " Generation rate of A , mol /( L . s ) ";
74 Real ndBg " Molar rate of generation of B , mol / s ";
75 Real rBg " Generation rate of B , mol /( L . s ) ";
76 Real r " Rate of reaction , mol /( L . s ) ";
77 // -- input variables
78 input Real pi " Influent pressure ( pure A ) , Pa ";
79 // Equations constituting the model
80 equation
81 // Differential equations
82 der ( nA ) = ndAi - ndAe + ndAg ;
83 der ( nB ) = ndBi - ndBe + ndBg ;
84 // Algebraic equations
85 pA * V = nA * R * T ;
86 pB * V = nB * R * T ;
87 p = pA + pB ;
88 Vdi = Ki * sqrt ( dpi / pa ) ;
89 dpi = pi - p ;
90 pi * Vdi = ndAi * R * T ;
91 ndBi = 0;
196 CHAPTER 5. SPECIES BALANCE

Figure 5.22: Pipe with diffusion of dissolved gas in liquid.

Gas diffusion in
Liquid Pipe

Figure 5.23: Functional diagram of diffusion of gas in liquid pipe.

92 Vde = Ke * sqrt ( dpe / pa ) ;


93 dpe = p - pa ;
94 pA * Vde = ndAe * R * T ;
95 pB * Vde = ndBe * R * T ;
96 ndAg = rAg * V ;
97 ndBg = rBg * V ;
98 rAg = nu [1]* r ;
99 rBg = nu [2]* r ;
100 r = k * pA ^ a ;
101 end ModGasReactor ;
102 // End package
103 end GasReactor ;

5.15 Case: Diffusion of gas in liquid pipe

5.15.1 Model objective

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

5.15.2 Model development


We assume that the linear velocity vj , is uniform in a given cross section. Initially,
we allow vj to vary with position x and time t. Likewise, the concentration ρj varies
with x, but is homogeneous in a given cross section. In particular, we consider a
small volume/slice in the interval x ∈ [ξ, ξ + ∆x], and we assume that this volume
is homogeneous in the intensive variables.
Step 1: We need the species balance for species j,
dmj
= ṁj,i − ṁj,e + ṁj,g .
dt
Step 2: In general, we have
mj = ρj V
where for cross sectional area A and length ∆x we have
V = A∆x.
L
With N slices, we have ∆x = N
. The species mass flow rates are

ṁ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

For convenience, we eliminate V̇j,ξ and V̇j,ξ+∆x , and set

ṁj,ξ = ρj,ξ vj,ξ A


ṁj,ξ+∆x = ρj,ξ+∆x vj,ξ+∆x A.

Here,

ρj,ξ vj,ξ = ρj,ξ vξ + Jj,ξ


ρj,ξ+∆x vj,ξ+∆x = ρj,ξ+∆x vξ+∆x + Jj,ξ+∆x .

From Fick’s law, the diffusion fluxes Jj are given as

∂ρj,ξ
Jj,ξ = −Dj,ξ
∂x
∂ρj,ξ+∆x
Jj,ξ+∆x = −Dj,ξ+∆x .
∂x

In a binary mixture where the average velocity v is independent of position,


the diffusion constant is the same for both species. We will introduce this
assumption, and also assume that the diffusion constant is independent of
position. Thus, we reduce the expression for the diffusion fluxes to

∂ρ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:

dmj,ξ+∆x (t) ∂mj,x+∆x (t, x)


→ .
dt ∂t

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

mj,x+∆x = ρj,x+∆x A∆x


ṁj,x = ρj,x vj,x A
ṁj,x+∆x = ρj,x+∆x vj,x+∆x A
ρj,x vj,x = ρj,x vx + Jj,x
ρj,x+∆x vj,x+∆x = ρj,x+∆x vx+∆x + Jj,x+∆x
∂ρj,x
Jj,x = −D
∂x
∂ρj,x+∆x
Jj,x+∆x = −D
∂x
Inserting these expressions into the mass balance, we get


(ρ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

∂ρj,x+∆x ρj,x vx − ρj,x+∆x vx+∆x Jj,x − Jj,x+∆x


= +
∂t ∆x ∆x

∂ρj,x+∆x ρj v|x − ρj v|x+∆x Jj,x − Jj,x+∆x
= +
∂t ∆x ∆x

∂ρj,x+∆x ρj v|x+∆x − ρj v|x Jj,x+∆x − Jj,x
=− − .
∂t ∆x ∆x
Assuming, as in the previous step, that we have a binary solution with the
velocity v being constant wrt. position x, we can summarize the model as

∂ρj,x+∆x ρj,x+∆x − ρj,x Jj,x+∆x − Jj,x


= −v −
∂t ∆x ∆x
where
∂ρj
Jj = −D .
∂x
To have a complete model, we also need boundary conditions — see the next
step.
200 CHAPTER 5. SPECIES BALANCE

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

ρ (t, x = 0) = ρi (t) (5.20)


J (t, x)|x=L = 0. (5.21)

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)

5.15.3 Model summary


A traditional model summary would consist of the PDE with boundary conditions,
i.e., as in Eqs. 5.18–5.21, with the output described according to Eq. 5.22. However,
Modelica can (currently) not transcribe PDE models, and we need to discretize the
model in space and write it as a DAE. A DAE model for a system, i.e., with inputs
and outputs, can often be written in the form
dx
= f (x, z, u; θ)
dt
0 = g (x, z, u; θ)
y = h (x, z, u; θ) .

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.

For the remaining slices:

ṁi = ρi vi A = ρi vA + Ji A

ṁi = ρi V̇i + Ji A
5.15. CASE: DIFFUSION OF GAS IN LIQUID PIPE 203

where V̇i is as above. Furthermore,


∂ρi
Ji = −D .
∂x
However, this equation can not be implemented: we can not have derivatives in
space in a DAE model; we need to discretize this model. Possible alternatives for
approximating the gradient ∂ρ
∂x
i
are the backward differentiation approximation
∂ρi ρi−1 − ρi
≈ ,
∂x ∆x
the forward approximation
∂ρi ρi − ρi+1

∂x ∆x
or the central approximation
∂ρi ρi−1 − ρi+1
≈ .
∂x 2 · ∆x
Because diffusion can spread in both directions, it makes sense to use the central
approximation. Since we have the boundary condition ρ0 = ρi , we are thus able to
compute J1 as
ρi − ρ2
J1 = −D .
2 · ∆x
Furthermore, since
ρN −1 − ρN +1
JN = −D ≡ 0,
2 · ∆x
we do not need the fictitious quantity ρN +1 , and
ρN −2 − ρN
JN −1 = −D
2 · ∆x
is well defined. In general, we thus have
ρi − ρ2
J1 = −D
2 · ∆x
ρi−1 − ρi+1
Ji = −D , i ∈ {2, . . . , N − 1}
2 · ∆x
JN = 0.

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.11: Parameters for study of diffusion of gas in liquid pipe.


Parameter Value Unit Comment
L 10 dm Length of liquid pipe with gas
A 5 dm2 Cross sectional area
D 10−5 cm2 s−1 Diffusion constant; note unit!
N 10 – Number of slices
L
∆x N
dm Slice length
V ∆x · A L Slice volume

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

5.15.4 Model simulation


Using OpenModelica, the results of simulating the system are as in Figs. 5.24–5.27.
Next, let us see how the simulation results depend on the number of slices N .
Figure 5.28 shows ρL for N ∈ {10, 30, 90, 300}.
Finally, let us see how the simulation results depend on the diffusion coefficient
D. Figure 5.29 shows ρL for D ∈ {10−7 , 3 × 103 · 10−7 } dm2 s−1 .
Figure 5.29 indicates that the diffusion is not very important, since an unrealisti-
cally high diffusion coefficient is required to even see the effect of diffusion. However,
the reason for this is most likely that the volumetric flow rate V̇i is relatively large
compared to molecular diffusion, and thus masks out the diffusion.
The following Modelica code (file DiffusionGasLiquid.mo) is used to produce
the figures; simulator model SimDiffusionGasLiquid is used to produce Figs.
5.24–5.27, while simulator model SimCompareDiffusionGasLiquid is used to pro-
duce Figs. 5.28–5.29.

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

Diffusion: specific density of gas


0.010 i
L
0.009 (t = 0, x)

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.

Diffusion: inlet volumetric flow rate


0.010
0.009
0.008
0.007
Vi [L/s]

0.006
0.005
0.004
0.003
0 2 4 6 8 10 12
time t [h]

Figure 5.25: Influent volumetric flow rate V̇i .


206 CHAPTER 5. SPECIES BALANCE

Diffusion: specific density of gas


0.010

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.

1e 10 Diffusion: internal gas diffusion fluxes


1.5
1.0
0.5
0.0
[kg/(dm2.s)]

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]

Figure 5.27: Internal gas diffusion fluxes Ji . N = 10 in simulations.


5.15. CASE: DIFFUSION OF GAS IN LIQUID PIPE 207

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

60 M odDi ff us ion G a s L i q u i d dgl ;


61 // Declaring variables
62 // -- inputs
63 Real _Vdi " Influent volumetric flow rate of mixture , L / s
";
64 Real _rhoi " Influent gas concentration , kg / L ";
65 // -- outputs
66 output Real _rhoL " Effluent gas concentration , kg / L ";
67 // Equations
68 equation
69 // -- setting input values
70 _Vdi = if time < 10000 then 1e -2 else 0.3 e -2;
71 _rhoi = if time < 15000 then 10 e -3 else 7e -3;
72 // -- injecting inputs to underlying model
73 dgl . Vdi = _Vdi ;
74 dgl . rhoi = _rhoi ;
75 // -- output
76 _rhoL = dgl . rho [ dgl . N ];
77 end S im Diff u si o n G a s L i q ui d ;
78 //
79 model Mo dD if fus i o n G a s L i q u i d
80 // Underlying model for Diffusion of gas in liquid
81 // author : Bernt Lie
82 // University of South - Eastern Norway
83 // September 14 , 2015
84 // May 11 , 2017
85 //
86 // Parameters
87 parameter Real L = 10 " Pipe length , dm ";
88 parameter Real A = 5 " Pipe cross sectional area , dm2 ";
89 parameter Real D = 1e -5*0.01 " Diffusion constant , dm2 / s
";
90 parameter Integer N = 10 " Number of slices in pipe , -";
91 parameter Real dx = L / N " Slice length , dm ";
92 parameter Real V = dx * A " Slice volume , L ";
93 // Initial state parameters
94 parameter Real rho0 = 5e -3 " Initial gas concentration ,
kg / L ";
95 parameter Real m0 = rho0 * V " Initial gas mass in a slice ,
kg ";
96 // Declaring variables
97 // -- states
98 Real m [ N ]( each start = m0 ) " Mass in each slice , kg ";
99 // -- auxiliary variables
100 Real rho [ N ] " Concentration of gas in slice , kg / L ";
101 Real mdi " Influent mass flow rate to first slice , kg / s ";
102 Real md [ N ] " Mass flow rate through pipe , kg / s ";
103 Real J [ N ] " Diffusion flux in slice , kg /( dm2 . s ) ";
104 // -- input variables
210 CHAPTER 5. SPECIES BALANCE

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

Figure 5.30: Sketch of process.

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

The valves have the following characteristic:



p − pa
V̇ = Kv u ,
ρ
where pa is atmospheric pressure, while p is the pressure just ahead of the valve in
question. Density ρ is assumed to be constant everywhere.
The liquid volume has cross sectional area A, and the liquid level is h.
A chemical reaction takes place, and is of first order with frequency factor k [s−1 ]
(i.e., the rate of generation of component A is rA = −kcA [mol/m3 ]).

Tasks A model should be formulated that describes level h and concentration


cA and how they evolve over time.
• Formulate dynamic equations for h and cA .

• 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 is it that makes this model a state space model?

• 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

6.1 Learning goals


After working through this chapter, the following concepts should be mastered.

• The mechanics of material descriptions; Newton’s law with variations. Me-


chanical energy.

• The mechanics of spatial descriptions; the momentum balance.

• What extensive and intensive quantities are relevant for the momentum bal-
ance?

• Transport laws for the momentum balance.

• Fluid properties and compressibility. Elasticity of walls.*

• Turbo machines and the momentum balance*.

6.2 Material description


6.2.1 Newton’s law and linear momentum
Newton’s law is often presented as

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

where v is (linear) velocity, which is related to acceleration as a , dv


dt
. We can then
write Newton’s law as
dm
= F.
dt
215
216 CHAPTER 6. MOMENTUM BALANCE

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.

6.2.2 Angular momentum


The concept of torque is well known for rotational movement. As a practical example,
when unscrewing a rusted screw, it is well known that the rotation is easier to enforce
if the force is applied to a large radius screw driver: intuitively, the applied torque
is related to the product of radius and force. More precisely, the torque is a vector,
T⃗ , and is defined as the vector product between radius vector ⃗r and force vector F⃗ ;
T⃗ = ⃗r × F⃗ , Fig. 6.1.
Assume now that we have a mass m rotating at angular velocity ω with constant
radius r around an axis, and that a tangential force F is applied to the mass, Fig.
6.2.
Applying the momentum balance, the momentum is

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

and the momentum balance is


dm
= F.
dt
If we introduce torque T = F r, we get
dm
r = rF = T .
dt
We can now introduce angular momentum a, and write
a = rm = mr2 ω.
Thus, we see that the angular momentum a ∝ ω, and this proportionality factor
is known as the angular moment of inertia, denoted J;1 thus a = Jω and here
J = mr2 .
If the system has a number of masses mi rotating at different ri around the axis,
each with the same angular velocity ω, we will in general have

a= ri × mi v̇i = Jω,
i

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

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 α.

6.2.3 Some conservative forces/torques


Common conservative forces are gravity and spring forces. Assuming constant ac-
celeration of gravity g, the force acting upon mass m is Fg = mg, pointing in the
direction of g, Fig. 6.3.
It is common to use a coordinate system with y-axis pointing in the opposite
direction of g, and the force becomes Fg = −mg: it is still the same force; the minus
sign simply says that the force points in the opposite direction of the y-axis. We
then find the potential function

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.

Similarly, spring force Fs in Fig. 6.3 is given by

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 − α) ,

and find the resulting potential energy to be


1
Ps = κs (α − α0 )2 .
2

6.2.4 System decomposition


Figure 6.4 shows the decomposition of a flow system and a mechanical system into
two subsystems.
From Fig. 6.4, the decomposed flow system can be described by
dm1
= −ṁ1 − ṁ2
dt
dm2
= −ṁ3 − ṁ4
dt
where
ṁ2 + ṁ3 = 0.
With m = m1 + m2 , the total system is then described by
dm
= −ṁ1 − ṁ4 ;
dt
we see that the internal flows ṁ2 and ṁ3 cancel and has no effect on the total mass
balance.
6.2. MATERIAL DESCRIPTION 221

Decomposing flow system:

Decomposing mechanical system:

Figure 6.4: Decomposition of flow system and mechanical system.

The decomposed mechanical system can be described by

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 .

With m = m1 + m2 , the total system is described by

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.

6.2.5 Mechanical energy balance


6.2.5.1 Energy and work. Mechanical energy balance
It is common to introduce kinetic energy for mechanical systems. In the case of
linear movement, the kinetic energy is

1
K = mv 2 ,
2
222 CHAPTER 6. MOMENTUM BALANCE

while in the case of rotational movement, the kinetic energy is


1
K = Jω 2 .
2
We now observe that for linear movement
( )
dK d 1 2 1 d (mv) d (mv) dm
= mv = 2v =v =v ,
dt dt 2 2 dt dt dt
and similarly for rotational movement
( )
dK d 1 2 da
= Jω = ω .
dt dt 2 dt
We have also seen that conservative forces Fc can be expressed via a potential
function P , and we find
dP (x) ∂P dx ∂P
= = v = −Fc v
dt ∂x dt ∂x
dP (α) ∂P dα ∂P
= = ω = −Tc ω.
dt ∂α dt ∂α
We now see that if we multiply the linear momentum balance by the linear
velocity v, we have
dm
v = Fv
dt

dm
v = (Fc + Fnc ) v
dt

dm
v = Fc v + Fnc v,
dt} |{z}
| {z
dK
dP
− dt
dt

where Fnc are non-conservative forces. It follows that


dK dP
=− + Fnc v
dt dt

d
(K + P ) = Fnc v.
dt
We can now introduce total energy E as

E = K + P,

and simply find the (mechanical) energy balance


dE
= Fnc v.
dt
6.2. MATERIAL DESCRIPTION 223

Figure 6.5: Sketch of pendulum.

Similarly, by multiplying the angular momentum balance by the angular velocity,


we have
da
ω = T ω = Tc ω + Tnc ω
dt

dK dP
=− + Tnc ω
dt dt

dE
= Tnc ω
dt
where E = K + P .
In a slight generalization, we observe that the terms Fnc v and Tnc ω are mechanical
work rate (power) terms, which we could denote by Ẇ (dimension: energy/time).
We could thus write the mechanical energy balance as
dE
= Ẇ . (6.1)
dt
It should be noted that if we for some reason choose to exclude some conservative
force terms in the expression for potential energy P , we simply include their effect
in the power term Ẇ . On the other hand, if we include the potential energy of a
conservative force in the total energy E, we can not simultaneously include its work
in the work term Ẇ .
If we have more than one body and more than one degree of freedom, the energy
balance is still valid: energy is an extensive quantity, and we simply sum over the
involved kinetic energies/potential energies and the involved power terms.
Example 6.1. Pendulum model from the energy balance.
Consider the pendulum example in Fig. 6.5.
Here, we can formulate the kinetic energy as
1
K = mv 2 ,
2
and the potential energy as
P = mgy.
224 CHAPTER 6. MOMENTUM BALANCE

The total energy is thus


1
E = K + P = mv 2 + mgy.
2
In a similar manner, we find that the mechanical power Ẇ is given as

Ẇ = F vy .

To complete the model, we need to introduce some geometric constraints:

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

Ẇ = 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


=ω (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

6.2.5.2 Multi-body, one degree of freedom⋆


...under construction...

6.2.5.3 n degrees of freedom⋆


...under construction...

6.2.5.4 Energy balance vs momentum balance⋆


...under construction...

6.2.6 Lagrangian mechanics⋆,+


...under construction...

6.2.7 Beams, torsion⋆,+


...under construction...

6.3 Spatial description


6.3.1 Momentum balance
We have seen that for a closed system/material description, Newton’s law is equiv-
alent to the linear momentum balance
dm
= F.
dt
226 CHAPTER 6. MOMENTUM BALANCE

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 ṁ is the mass flow rate.


The simple formulation above is valid when the velocity vector v is perpendicular
to the surface ∂V through which it flows; v ⊥ ∂V . In a more general case, we can
write ˛
ṁi − ṁe = − ρv · v T n · dA
∂V

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)

6.3.2 Mechanical energy balance


We have seen that in the material description, the mechanical energy balance can
be written as in Eq. 6.1:
dE
= Ẇ,
dt
6.3. SPATIAL DESCRIPTION 227

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)

In Eq. 6.14, K ′′′ is the kinetic energy per volume,


1
K ′′′ = ρ ⟨v⟩2
2
where ρ is density and ⟨v⟩ is the linear velocity average across the cross-section of the
pipe. Furthermore, in Eq. 6.14, Aw is the wetting surface, i.e., the contact surface
between the fluid and the wall; Aw = ℘L where ℘ is the perimeter of the pipe —
℘ = πD for a circular pipe. Finally, in Eq. 6.14, f is Fanning’s friction factor.
Clearly, Eq. 6.14 does not include direction of vectors in the expression. If we
would include the direction of Ff and the direction of the velocity, a more correct
expression would be
Ff = −K ′′′ Aw f
with
1
K ′′′ = ρ ⟨v⟩ · |⟨v⟩| . (6.15)
2
It is common to use the more readable expression in Eq. 6.14, and include an un-
derstanding of the correct direction of friction force vs. velocity in the model de-
velopment. Still, care must be shown if the flow changes direction; in that case the
expression for K ′′′ in Eq. 6.15 must be used.
The so-called Moody diagram depicts the friction factor f as a function of
Reynolds’ number, with the roughness ratio Dϵ as parameter, see Fig. 6.6.
In Fig. 6.6, the turbulent region (NRe > 2.3 × 103 ) is a flow regime where the
velocity across the pipe has a stochastic nature, and where the velocity v is more
or less uniform across the pipe when we average the velocity over some short time
period. von Kármáns “law of the wall”, see subsequent more detailed discussion and
Eq. 6.25, gives a velocity profile which is relatively flat over a large fraction of the
cross sectional pipe area.2 The laminar region (NRe < 2.1 × 103 ) is a flow regime
with a regular velocity v which varies as a parabola with the radius of the pipe, with
zero velocity at the pipe wall and maximal velocity at the center of the pipe.
As discussed above, Fanning’s friction factor will vary with the roughness of the
pipe surface, specified by roughness height ϵ. Table 6.1 indicates the roughness of
some pipe materials.3
Some publications use Darcy’s friction factor fD instead of Fanning’s friction
factor f ; these two friction factors are related as fD = 4f .
2
See https://en.wikipedia.org/wiki/Law_of_the_wall.
3
Selected values taken from https://neutrium.net/fluid_flow/absolute-roughness/.
6.4. FRICTION 229

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).

Table 6.1: Roughness height ϵ for various materials.


Material Roughness ϵ, mm
Drawn tubing (glass, plastic) [0.0015, 0.01]
Flexible rubber tubing (smooth) [0.006, 0.07]
Stainless steel 0.03
Wrought iron (new) 0.045
Carbon steel (new) [0.02, 0.05]
Carbon steel (slightly corroded) [0.05, 0.15]
Carbon steel (moderately corroded) [0.15, 1]
Carbon steel (badly corroded) [1, 3]
Asphalted cast iron [0.1, 1]
Galvanized iron [0.025, 0.15]
Cast iron (new) 0.25
Concrete (very smooth) [0.025, 0.2]
Concrete (fine, floated/brushed) [0.2, 0.8]
Concrete (rough, form marks) [0.8, 3]
230 CHAPTER 6. MOMENTUM BALANCE

6.4.1.2 Friction force and friction loss+


So far, we have treated the expression for the friction force Ff somewhat ad hoc.4
Formally, friction force Ff directed in the opposite direction of the velocity v can be
expressed as the product of shear stress τw between fluid and wall (force per area),
and wall “wetting” surface Aw :

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.

6.4.1.3 Fanning friction+


Shear stress τw has dimension force/area or force-length/volume, which is work/vol-
ume or energy/volume. Studies in hydraulics have indicated that for a fully devel-
oped flow,6 the shear stress τw between the fluid and the wall of a fixed object (e.g., a
wall) is proportional to the kinetic energy of the fluid per volume, K ′′′ ; τw ∝ K ′′′ . In
1877, Fanning7 proposed the dimensionless friction factor/proportionality constant
f,
τw
f , ′′′ ,
K
known as Fanning’s friction factor. Here, it must be observed that f ≥ 0, i.e.,
we should really use the absolute value of the shear stress if we include directional
information in its value. Assuming a Newtonian fluid, Fanning’s friction factor f is
a function of the so-called Reynolds number NRe , Table 2.15 p. 36, here defined as:
ρ ⟨v⟩ D
NRe = ;
µ
here ρ is the fluid density, µ is the fluid viscosity, ⟨v⟩ is the average velocity of the
fluid over a cross sectional area A,8 and D is a characteristic dimension. Typically,
D will be the diameter of the pipe if we are talking about friction against a pipe
wall, while it may be the diameter of a sphere if we are talking about the drag force
on a solid sphere “swimming” in the fluid flow; Bird et al. (2002). Observe that the
Reynolds number NRe is dimensionless.
If we express the friction force as Ff = τw Aw , we find
Ff
Aw
f= .
K ′′′

Ff = K ′′′ Aw f. (6.17)
In this friction law, K ′′′ is defined as
1
′′′ mv 2
1
K = = ρv 2 ,
2
V 2
where ρ is the density of the fluid and v is the linear velocity of the fluid. If the fluid
is allowed to reverse its direction of flow, the more general expression for K ′′′ is
1
K ′′′ = ρv |v| . (6.18)
2
At zero velocity, v → 0, we will have Ff → 0, since K ′′′ → 0 quadratically as
v → 0 while (as we will see) f → ∞ linearly as v → 0.
6
“Fully developed” implies after the entrance effects have disappeared.
7
John Thomas Fanning (1837–1911).
8
Reynolds’ number is positive, thus ⟨v⟩ is the numerical value (absolute value) of the velocity
— in case the direction is included in the value of the velocity.
232 CHAPTER 6. MOMENTUM BALANCE

Figure 6.7: Measuring pressure drop ∆pf = p1 − p2 due to friction, using a manome-
ter.

6.4.1.4 Friction force and pressure drop+


Fanning introduced his friction factor in 1877. Figure 6.7 illustrates how the friction
force is related to the pressure drop.
Assuming steady state conditions and constant density, the mass balance leads
to
dm
= ṁ1 − ṁ2 ⇒ ṁ1 = ṁ2 ⇒ V̇1 = V̇2 = V̇ ⇒ v1 = v2 = v,
dt
where the location of subscripts 1 and 2 are indicated in Fig. 6.7 for the pressures
p1 and p2 . The momentum balance is
dm
= ṁ1 − ṁ2 + F .
dt
In steady state, dm dt
= 0, and ṁ1 = ṁ2 due to constant mass flow and constant
density. The steady momentum balance thus only involves the pressure forces and
the friction force, i.e.,
0 = p1 A − p2 A − Ff ⇒ ∆pf A = (p1 − p2 ) A = Ff .
It follows that the pressure loss due to friction is
1 Aw
∆pf = Ff = τw .
A A

6.4.1.5 Darcy friction+


Prior to Fanning’s work, the pressure loss due to friction was expressed using the
Darcy-Weisbach equation9
∆pf ρ v2
= fD . (6.19)
L 2D
9
Developed by Henry Darcy from the Prony equation of hydraulics, and further refined into the
current form by Julius Weisbach in 1845.
6.4. FRICTION 233

How does the Darcy-Weisbach expression relate to Fanning’s model?


Assuming a cylindrical pipe with diameter D, we find that Aw = πDL, while
A = π D4 . With τw = K ′′′ f , Fanning’s expression gives
2

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.

6.4.1.6 Smooth pipe friction factors+


For laminar flow in a cylindrical pipe, it can be shown that the velocity has a
parabolic profile over the radius, i.e.,
( ( r )2 )
v (r) = vm 1 −
R

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

see Exercises 6.1 and 6.2.


For turbulent flow, NRe > 2.3 × 103 , it is common to rewrite the expression for
the Darcy friction factor as

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̄ ,

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

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

6.4.1.7 Rough pipes and the Colebrook relation+


Nikuradse14 studied turbulent flow in rough pipes, described by the dimensionless
ratio Dϵ of the roughness height ϵ and the pipe diameter D, and fitted the data to
the shape of the von Kármán relation, Eq. 6.26, leading to 15
( ) ( )
1 3.71 ϵ/D
√ = 2 · log10 = −2 · log10 . (6.30)
fD ϵ/D 3.71

Colebrook16 considered how to merge Prandtl’s fitting of von Kármán’s model


for smooth pipes with Nikuradse’s model for rough pipes. The general problem is
how to merge a model of type k log10 f1 (x) with a model of type k log10 f2 (x) into
a global model F (x), with f1 (x) ≫ f2 (x) for small values of x, and f1 (x) ≪ f2 (x)
for large values of x, and with a smooth transition between the two functions.
The relevance is that for small Reynolds numbers, NRe 2.51

fD
≫ 3.71
ϵ/D
, while for large
13
Ludwig Prandtl, 1875 – 1953.
14
Johann Nikuradse (1894–1979) was a PhD student of Ludwig Prandtl in 1920.
15 1 √1
Originally: fD = 2 , but this expression can be rewritten as
fD
= 1.74 +
( (1.74+2)log10 ( Rϵ )) ( ) ( )
(R) √ (R) √
2 log10 ϵ = 2 log10 101.74 + 2 log ϵ or √1f = 2 log 101.74 D
2 ϵ = 2 · log10 3.7066
ϵ/D .
D
16
C.F. Colebrook was at Imperial College, London.
236 CHAPTER 6. MOMENTUM BALANCE

Reynolds numbers, NRe 2.51



fD
≪ 3.71
ϵ/D
. Colebrook’s observation was that with functions
of type f1 (x) and f2 (x) as described above, a reasonable approximation could be
{
k log10 f1 (x) , x is small
F (x) , k log10 (f1 (x) + f2 (x)) ≈
k log10 f2 (x) , x is large.

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

with p > 0, typically p ≥ 1; Colebrook’s model has p = 1. The experimental results


of McKeon et al. (2005) from the Princeton Superpipe seem to indicate that with
p = 1, the estimate of fD is slightly too large in the transition from smooth pipe to
rough pipe dominance, thus it may be better to use p > 1.

6.4.1.8 Solution of Colebrook’s relation by iteration+


As seen, Colebrook’s relation is implicit in the unknown fD , and it is not possible
to find an explicit solution. To find a solution, iteration is thus needed. Iterative
solutions need a first/seed value. Natural seed values could be based
( on explicit ex-
)
−1/4
−0.1508·NRe
pressions, e.g., Blasius’ smooth pipe expression ( 1/4 = −2 · log10 10
0.316
),
NRe
Nikuradse’s rough pipe expression, or a combination of these:
 √

 1/ 0.3161/4 , Blasius

 NRe ( )
1
√ = −2 · log10 3.71 ϵ/D
, Nikuradse (6.33)
(0) 
 ( ( )p )
fD  2
 0.316·p −1/4
− p · log10 10− 2 ·NRe + 3.71 ϵ/D
, Blasius-Nikuradse
6.4. FRICTION 237

and then compute refined approximations by successive substitution:


 p 
( )p
1 2 2.51 1  ϵ/D 
√ = − · log10  √ + . (6.34)
(i+1) p NRe (i) 3.71
fD fD

Using, e.g., the “Nikuradse” seed, successive substitution converges to an accurate


solution in some 7 steps (Brkić 2011b).
Newton iteration is superior to successive substitution. To find a Newton itera-
tion scheme, we introduce the “transmission” T :
1
T ,√
fD
and function f (T ) defined as
2
f (T ) = T + · log10 ((aT )p + bp ) ,
p
where we seek T such that f (T ) = 0. The idea of Newton iteration is essentially
to set the Taylor series expansion of f (T ) evaluated at iteration Ti , truncated after
the linear term, equal to zero, and solve the linear equations to find Ti+1 :

∂f
f (Ti+1 ) ≈ f (Ti ) + (Ti+1 − Ti ) = 0
∂T i

f (Ti )
Ti+1 = Ti − ∂f .

∂T i

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

with the obvious modifications if a or b are changed.


The Moody diagram in Fig. 6.6 is constructed from Eqs. 6.22 and 6.31, where
we convert to Fanning’s friction factor by using the relation fD = 4f .

6.4.1.9 Approximations to Colebrook’s relation+


Approximations to the Colebrook relation are typically based on some direct explicit
expressions, or by using the Lambert W function to solve the implicit expression —
see Section 6.4.1.10 for a discussion on the Lambert W function.
238 CHAPTER 6. MOMENTUM BALANCE

In the sequel, the focus is on simple and efficient approximations of Colebrook’s


relation. Sections 6.4.1.8 gives an overview of iteration methods for Colebrook’s
relation. First, assume that the Blasius seed is used, Eq. 6.33:
1 1
√ =√
1/8
= 1.7789 · NRe .
(0) 0.316
fD 1/4
NRe

With one iteration of successive substitution, Eq. 6.34, this gives


(( )p ( )p )
1 2 2.51 ϵ/D
√ = − · log10
1/8
1.7789 · NRe +
(1) p NRe 3.71
fD

(( )p ( )p )
1 1 2 4.4651 ϵ/D
√ ≈√ = − · log10 0.875
+ , (6.35)
fD (1) p NRe 3.71
fD

where normally p = 1. An alternative approach could be to use the Blasius relation


as the initial guess in an iterator on Prandtl’s smooth pipe relation to get
( ) (( )0.875 )
1 4.4651 5.5292
√ = −2 · log10 0.875
= −2 · log10 .
(1) NRe NRe
fD

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

If we choose the log argument to be linear in 1/NRe , we have p = 0.875 1


≈ 1.1429 and
2
p
= 1.75. Alternatively, we could set p = 1 with 5.5292 0.875
≈ 4.4651. If coefficient
2.51 in the original Colebrook relation is replaced by value 2.825 as indicated in
Eq. 6.28, we find 5.5292 → 6.329 with 6.3290.875 ≈ 5.0254.
Table 6.2 gives a summary of some approximations.
All approximations in Table 6.2 seem to be based on some successive substitution
approach, with 1–2 iterations. It is not really meaningful to compare Haaland’s
gas expression in Table 6.2 with Colebrook’s original relation with p = 1. See
Brkić (2011b) for a comprehensive, updated review of approximations to Colebrook’s
formula.17 Newton iterations would be more accurate, but slightly more complex.
If it is desirable to use Fanning’s friction factor instead of Darcy’s friction factor,
the conversion is simple: f = fD /4.

6.4.1.10 Colebrook’s relation and the Lambert W function+


We consider Colebrook’s relation with Darcy friction as in Eq. 6.31.
17
See also https://en.wikipedia.org/wiki/Darcy_friction_factor_formulae.
6.4. FRICTION 239

Table 6.2: Simple, explicit approximations of Colebrook’s relation, with maximal


deviation (Max dev) from Colebrook’s relation over the region NRe ∈ [104 , 108 ] and
ϵ
D
∈ [10−1 , 10−6 ]. See Brkić (2011b).
Approximation ( ) Max dev Method
√1 = −2 · log10 15
+ϵ/D
8.2% Eck, 1973
fD ( NRe 3.715
)
√1
fD
= −2 · log10 5.7622 ϵ/D
0.9 + 3.71
NRe
2.18% Churchill, 1973. Observe
the similarity to Eq. 6.36
( ) with p = 1.
√1
fD
= −2 · log10 5.74
0.9
NRe
+ ϵ/D
3.7
2.04% Swamee and Jain, 1976;
( ) tuning of Churchill, 1973.
√1
fD
= −2 · log10 5.72
0.9
NRe
+ ϵ/D
3.715
2.05% Jain, 1976; tuning of
( Churchill, 1973.
( )1.11 )
√1
fD
≈ −1.8 · log10 6.9
NRe
+ ϵ/D
3.7
1.4% Haaland, 1983, for liquid;
similar to Eq. 6.36 with
(( 0.875 · p = 1.
)3 ( )1.11·3 )
√1
fD
≈ − 1.8
3
· log10 6.9
NRe
+ ϵ/D
3.7
— Haaland, 1983, for gas;
similar to Eq. 6.36 with
( ) 0.875 · p = 3.
(ϵ/D)1.1098
√1
(0)
= −2.01 · log10 5.8506
0.8981
NRe
+ 2.8257
0.35% Chen, 1979: seed √1 ;
(0)
fD fD
(1)
fD ≈ fD based on Eq. 6.34
with “3.71” replaced by
( ) “3.71065”
√1
(0)
= −2 · log10 13
NRe
+ ϵ/D
3.7
1% Zigrang and Sylvester,
fD
1982: seed √ 1(0) similar to
fD
(1)
Eck, 1973; fD ≈ fD based
on Eq. 6.34 with “3.71”
( ) replaced by “3.7”
√1
(0)
= −2 · log10 13
NRe
+ ϵ/D
3.7
0.13% Zigrang and Sylvester,
fD
1982: seed √ 1(0) similar to
fD
(2)
Eck, 1973; fD ≈ fD with
(1) (2)
fD , fD based on Eq. 6.34
with “3.71” replaced by
“3.7”
240 CHAPTER 6. MOMENTUM BALANCE

Theorem 6.1. Colebrook’s relation can alternatively be expressed as


W · exp (W ) = x
where
( )
NRe ln 10 NRe ln 10 ϵ/D
x= exp
2.51 2 2.51 2 3.71
NRe ln 10
W = z
2.51 2
and
2.51 1 ϵ/D
z= √ + .
NRe fD 3.71
N
Proof. For Colebrook’s relation in Eq. 6.31, introduce z,
2.51 1 ϵ/D
z= √ +
NRe fD 3.71

( )
1 N ϵ/D
√ = Re z− ,
fD 2.51 3.71
which when inserted into Colebrook’s relation gives
( )
NRe ϵ/D
z− = −2 · log10 z
2.51 3.71

( ) ( )
NRe ln 10 ϵ/D 1
z− = − ln z = ln
2.51 2 3.71 z
or ( ) ( )
1 NRe ln 10 NRe ln 10 ϵ/D
= exp z exp −
z 2.51 2 2.51 2 3.71
which can be rewritten into
( ) ( )
NRe ln 10 ϵ/D NRe ln 10
exp = z · exp z
2.51 2 3.71 2.51 2

( ) ( )
NRe ln 10 NRe ln 10 ϵ/D NRe ln 10 NRe ln 10
exp = z · exp z .
2.51 2 2.51 2 3.71 2.51 2 2.51 2
Here, let
NRe ln 10
W = z
2.51 2 ( )
NRe ln 10 NRe ln 10 ϵ/D
x= exp
2.51 2 2.51 2 3.71
and Colebrook’s relation can be written as
W · exp (W ) = x (6.37)
with solution W (x).
6.4. FRICTION 241

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).

Remark 6.1. The solution W (x) to W · exp (W ) = x is given by Lambert’s W func-


tion. Solving Colebrook’s implicit relation has thus been rephrased into solving the
implicit relation in Eq. 6.37. This implicit relation is a standard form in mathemat-
ics, which can be solved using the so-called Lambert W function. There is no magic
in the Lambert W function, though — iterations are necessary to find the solution.
The advantage with using Lambert’s W function, is that it has been thoroughly
studied in (numerical) mathematics. N

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 ···

This recursion can be truncated to given an approximation of W (x) for large x.


In Barry et al. (2000), a relatively simple and accurate approximation W0+∗2 for
W0+ is developed:
 
( )
 6x  2x
W0 (x) = (1 + ε) ln 
+∗2
 [ ]
 − ε ln ln (1 + x) (6.38)
12 x
5 ln 5 ln 1+ 12 x
( 5 )
where ε ≈ 0.4586887, with maximal error 0.196%. A procedure for finding more
accurate approximations is also given.
The procedure for solving Colebrook’s relation using the Lambert W function is
thus as follows, Theorem 6.1:
1. With given ratio ϵ/D and NRe , compute x from
( )
NRe ln 10 NRe ln 10 ϵ/D
x= exp .
2.51 2 2.51 2 3.71

2. Next, with x known, compute W (x), e.g., via the approximation W0+∗2 (x),
Eq. 6.38.
6.4. FRICTION 243

3. Next, find z from


NRe ln 10 2.51 2 2.51 2
W = z⇒z= W ≈ W +∗2 .
2.51 2 NRe ln 10 NRe ln 10 0
4. Finally, find √1 from
fD
( )
2.51 1 ϵ/D 1 NRe ϵ/D
z= √ + ⇒√ = z− .
NRe fD 3.71 fD 2.51 3.71
See also Brkić (2011a).

6.4.1.11 Global friction factor models+


It may be of interest with a friction factor model that spans both the laminar and
the turbulent regions, i.e., global models. One such model is due to Churchill, 1977
(Brkić 2011b), and is valid for 0 < NRe < 108 :
(( )12 ) 121
8 1
fD = 8 +
NRe (C1 + C2 )1.5
where
 16
 1 
C1 = 2.457 ln ( )0.9 
7 ϵ
NRe
+ 0.27 D
( )16
37530
C2 = .
NRe
Alternatively, one could use the idea of Colebrook and write
1/2 1/2
64 1 N 2 N
⇒ √ = Re = − · log10 10− 16 ·p
Re
fD =
NRe fD 8 p
which can then be merged with the Colebrook relation into
( 1/2 ( )p ( )p )
1 2 N
− 16Re ·p 2.51 1 ϵ/D
√ = − · log10 10 + ·√ + . (6.39)
fD p NRe fD 3.71
Yet another possibility is to use some interpolation expression between the lam-
inar value at NRe = 2100 and the turbulent value at NRe = 2300, e.g., linear
interpolation — or if the friction factor should be differentiable: a cubic polyno-
mial fitting with the same slope as laminar friction at NRe = 2100 and turbu-
lent friction at NRe = 2300. To achieve global differentiability, with p (NRe ) =
3 2
aNRe + bNRe + cNRe + d, thus
p (NRe = 2100) = fDℓ (NRe = 2100)
p (NRe = 2300) = fDt (NRe = 2300)

dp dfDℓ
=
dNRe NRe =2100 dNRe NRe =2100

dp ∂fDt
= ,
dNRe NRe =2300 ∂NRe ϵ ,NRe =2300
D
244 CHAPTER 6. MOMENTUM BALANCE

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:

′′′ Ff 1 16 ρ ⟨v⟩2 µ ⟨v⟩


Ff = K Aw f ⇒ = ρ ⟨v⟩ ·
2
= 8 · ρ⟨v⟩D = 8 ·
Aw 2 NRe D
µ

µ ⟨v⟩ µ ⟨v⟩
Ff = 8 · Aw = 8 · πDL = 8π · µ ⟨v⟩ L. (6.40)
D D

where it clear that friction force Ff is directed opposite to ⟨v⟩.

6.4.2 Pressure drop due to constrictions, etc.


We have seen that the pressure drop in a long, straight pipe is

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

∆pf = ϕK ′′′ (6.41)

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.

6.4.3 Liquid friction in open channel+


In open channels, it is common to introduce the co-called (steady) friction slope Sfs ,
which can be expressed as
Ffs′
Sfs , .
ρgAs
6.4. FRICTION 245

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

NRe < 2500: NRe < 4000:


( ) [( )4 ] [ ( )4 ]
ϕsr = 1.2 + 160
NRe
D1
D2
−1 ϕse = 2 1 − DD1
2

NRe ≥ 2500: NRe ≥ 4000:


( ) 2 [( )2 ] [ ( ) 2 ]2
ϕsr = (0.6 + 0.48fD ) D1
D2
D1
D2
−1 ϕse = (1 + 0.8fD ) 1 − D
D1
2

Tapered reduction Tapered expansion

θ ∈ [0, 22.5 ◦ ]: ( ) θ ∈ [0, 22.5 ◦ ]: ( )


ϕtr = 1.6 · sin 4θ · ϕsr ϕte = 2.6 · sin 4θ · ϕse
◦ ◦
θ ∈ (22.5
√ , 90 ): θ ∈ (22.5 ◦ , 90 ◦ ):
(θ)
ϕtr = sin 4 · ϕsr ϕte = ϕse

Figure 6.9: Nomenclature for open channel flow.


246 CHAPTER 6. MOMENTUM BALANCE

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

NRe < 2500: L


≤ 5:
( )
[ ( )2 ( )]
D2

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

ϕso = 2.72 + D1 · NRe · ϕ0so


D2 4000
Square reduction followed by
[ ( )2 ] [ ( )4 ]
where ϕso = 1 − D1
0 D2 D1
D2
−1 . square expansion
6.4. FRICTION 247

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

V̇s 1 2/3 1/2


vs = = R S ,
As kM s fs

where kM is Manning’s friction coefficient (sometimes denoted n) while Rs is the


hydraulic radius defined as
As
Rs =
℘s
— the ratio of the cross sectional area As and the wetting perimeter ℘s . It follows
that we can express Sfs as

V̇s 1 2/3 1/2


= R S
As kM s fs

( )2 ( )2
V̇s V̇s 4/3
As As
℘s
2 2
Sfs = kM 4/3
= kM 4/3
.
Rs As
It is of interest to compare this friction slope with the result obtained by using
the Friction force in Eq. 6.17. If we simplify the expression for Sfs above somewhat
using the approximation
( ) 34
℘s ℘s
≈ ,
As As
we see that the friction slope becomes
( )2
V̇s
As
℘s vs2 ℘s
2 2
Sfs = kM = kM .
As As

On the other hand, from Eq. 6.17, we have

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

We see that Manning’s friction factor kM is approximately

f
2
kM ≈ .
2g
248 CHAPTER 6. MOMENTUM BALANCE

Table 6.5: Examples of values for Manning’s friction factor kM .


Bed material Manning factor kM
Asphalt 0.016
Brick 0.015
Clay tile 0.014
Concrete - steel forms 0.011
Concrete (Cement) - finished 0.012
Concrete - wooden forms 0.015
Earth, smooth 0.018
Earth channel - clean 0.022
Earth channel - gravelly 0.025
Earth channel - weedy 0.030
Earth channel - stony, cobbles 0.035
Floodplains - pasture, farmland 0.035
Floodplains - light brush 0.050
Floodplains - heavy brush 0.075
Floodplains - trees 0.15
Natural streams - clean and straight 0.030
Natural streams - major rivers 0.035
Natural streams - sluggish with deep pools 0.040
Natural channels, very poor condition 0.060
Wood - planed 0.012
Wood - unplaned 0.013
6.5. COMPRESSIBLE FLUID. ELASTICITY OF WALLS⋆ 249

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.

6.4.4 Power consumption in agitated liquid tanks


In Problem 2.3 p. 41, the task is to show that for agitation of a liquid tank,


= 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 =
µ

where µ is the liquid viscosity.


The power consumption essentially is dissipated power by friction between the
impeller blades and the liquid. Thus the shaft power Ẇ essentially is equal to the
friction power Ẇf for the rotating liquid of the tank, hence

Ẇf = −ρDi5 ṅ3i f. (6.42)

Figure 6.10 shows the agitation friction factor (“power number”) for some im-
peller geometries.

6.5 Compressible fluid. Elasticity of walls⋆


...under construction...
19
This is the case, e.g., in the surge tank of a high pressure hydro power plant.
20
In https://neutrium.net/fluid_flow/pressure-loss-from-fittings-expansion-and-
reduction-in-pipe-size/, this “generalized friction factor” is referred to as the K-value, while
Lydersen (1979) refer to is as n.
21
Taken from www.engineeringtoolbox.com/mannings-roughness-d_799.html
22
Normally, Reynolds’ number is expressed as ρvD ωi
µ . Observe that ṅi = 2π where ωi is angular
ρṅi Di2 ρωi Di2 ρvDi 1
velocity, thus the velocity at the impeller tip is v = ωi D2i . Thus, NRe = µ = 2πµ = µ 4π .
250 CHAPTER 6. MOMENTUM BALANCE

Figure 6.10: Agitation friction factor f (“power number”) as a function of Reynolds


number NRe for some impeller geometries (Lydersen 1979). In the upper figure, Di
is the impeller diameter, Dt is the tank diameter, h is the propeller pitch (No. 4),
zi is the height of impeller above bottom, ze is the liquid level in the tank, and B is
the width of baffles. In the curves of the lower figure, the curve numbers (1–4) refer
to the configuration row in the upper figure.
6.6. HYDRAULICS AND SERVO CONTROL+ 251

6.6 Hydraulics and Servo Control+


6.6.1 Introduction
Hydraulics — the science of liquid flow — is of particular interest in the design
and analysis of actuators, in particular in (electro-) hydraulic servo systems. Com-
mon hydraulic liquids have a mineral oil base, a synthetic hydrocarbon base, or a
phosphate-ester base. Hydraulic actuators have a number of advantages over other
types of actuators, but also some disadvantages.
Some advantages include the ability of the fluid to remove generated heat while
simultaneously lubricating the system, possibility of producing small units, high
stiffness, and simple designs. Some disadvantages include that hydraulic power is
less readily available than electric power, small allowable tolerances in production,
fire and explosion hazards, contamination and the need to change oil, and some lack
of flexibility. See Merritt (1967) for more details.
This section is somewhat at odds with the document at large: (i) some model
development is included which requires knowledge of electrical engineering/electro-
magnetism, and the notes do not really discuss these topics, (ii) there is a discussion
of linearization and time constants which is introduced in a later chapter of these
notes, and (iii) there is some discussion of control design, which is outside of the
scope of the notes. Still, the main idea as captured in Fig. 6.18 is useful: that hy-
draulic servo systems can be tuned to approximate a first order system with some
nonlinearities.

6.6.2 Fluid properties


We have seen that the Reynolds number of a fluid is important when studying fluid
flow,
ρvL
NRe =
µ
where ρ is the density, v is the linear velocity and L is a characteristic length23 , while
µ is the viscosity. The ratio ν = µρ is commonly denoted kinematic viscosity. The
density of various hydraulic fluids are typically in the range of ρ ∈ [0.8, 0.9] kg/L, but
some fluids of phosphate-ester base may have density up to ρ = 1.3 kg/L, Merritt
(1967). Kinematic viscosity is typically given in unit centiStoke, cSt = 10−6 m2 /s.
Water at 20 ◦ C has an approximate kinematic viscosity of νH2 O,20 ◦ C ≈ 1 cSt. Vis-
cosity and kinematic viscosity varies widely with temperature, Fig. 6.11.
Figure 6.11 is generated from the following Python code of file hydraulicFluidKinematicViscosity
.py.

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

Kinematic viscosity as a function of temperature T


Univis J-43
Skydrol 500A
103 Oronite 8315

102
(T) [cSt]

101

50 0 50 100 150 200


T [ C]

Figure 6.11: Kinematic viscosity as a function of temperature, ν (T ), for various


hydraulic fluids. Data taken from Merritt (1967) with temperature converted to ◦ C.
In a log-log diagram, the curves are relatively linear.

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

in the region ν ∈ [5, 50] cSt.


When taking the mass balance over a fixed volume, mass m can be expressed
as m = ρV where the volume V of the system normally is taken as constant. The
density ρ depends on temperature and pressure, ρ (T, p) according some Equation
of State24 , and we can express the density differential as
( ) ( )
∂ρ ∂ρ 1 ∂ρ 1 ∂ρ
dρ = dT + dp = −ρ − dT + ρ dp.
∂T ∂p ρ ∂T p ρ ∂p T

Introducing the coefficient of thermal expansion αp and the isothermal compressibil-


ity βT as

1 ∂ρ
αp = −
ρ ∂T p

1 ∂ρ
βT = ;
ρ ∂p T

in Section 7.8, these are alternatively given the equivalent definition



1 ∂V
αp =
V ∂T p

1 ∂V
βT = − .
V ∂p T

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

Initially neglecting changes in the volume/cage due to volume changes, we have


V = Vℓ + Vg , thus the effective isothermal compressibility factor is
( )
1 ∂V 1 Vℓ ∂Vℓ Vg ∂Vg
βT,e =− = − −
V ∂p T V Vℓ ∂p T Vg ∂p T

Vℓ Vg
βT,e = βT,ℓ + βT,g .
V V

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

Example 6.2. Efficient isothermal bulk modulus with rigid volume.

We consider a hydraulic fluid at pressure p = 500 psi ≈ 35 bar containing 1% of


air, this gives an efficient isothermal bulk modulus of typically

1 1
= = 2.98 kbar ≈ 3 kbar,
βT,e (1 − 0.01) · 1
20×103
+ 0.01 · 1
35

which is a considerable change.


If the system instead contains 3% of air, this gives an efficient isothermal bulk
modulus of typically

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

where for a thick-walled cylinder the volume module can be expressed as

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]

Here, it is important to emphasize that βT is the isothermal compressibility factor


of the metal itself, while βT,V is the “isothermal compressibility factor” of the thick-
walled cylinder, which depends on both material properties of the metal (such as
βT ) as well as the pipe geometry. Table 6.6 gives relevant data for some metals.
For thick-walled cylinders where D = Do ≫ Di , we find
1 1
≈E·
βT,V 2 (1 + νP )

while for thin-walled cylinders where Do ≈ Di = D and the wall thickness is ∆R =


Do −Di
2
, we find
1 ∆R
≈E· .
βT,V D
Example 6.3. Efficient isothermal bulk modulus with flexible volume.

We consider a hydraulic fluid at pressure p = 500 psi ≈ 35 bar containing 1% of


air, within a thick-walled stainless steel cylinder. This gives an efficient isothermal
bulk modulus of typically
1 1
= = 2.97 kbar ≈ 3 kbar.
βT,e (1 − 0.01) · 1
20×103
+ 0.01 · 1
35
+ 2(1+0.3)
200×104

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

6.6.3 Flow through orifices


We consider flow through an orifice as indicated in Fig. 6.12.
26
The Young modulus E is the relationship between stress (force per unit area) and strain
(proportional deformation) in a material.
27
The Poisson ratio νP is the signed ratio of transverse strain to axial strain.
256 CHAPTER 6. MOMENTUM BALANCE

(a)

"1" "2" "3"


(b)

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

the volumetric flow rate is



2
V̇ = Cd A0 (u) (p1 − p2 )
ρ

where u is some valve signal. With A0 ≪ A1 , this gives Cd ≈ 0.6.


If we have turbulent flow, but the sharp-edged orifice instead is replaced with
a circular orifice with opening D and length L, the discharge coefficient can be
expressed as

 1
 √1.5+13.74√ L ,
D·NRe
L
> 50
D·NRe
Cd = ,

 √
1
, D·NRe
< 50
L
2.28+64 D·N L
Re

where NRe is the Reynolds number, Merritt (1967).


In the case of low temperature fluid (i.e., viscosity µ is large), low pressure drop
(i.e., low velocity), etc., the Reynolds number can be sufficiently small so that the
flow is laminar. For laminar flow, the volumetric flow rate V̇ can be shown to be
linear in the pressure drop p1 − p2 . It has been found that for a small circular orifice
of diameter d,
πd3
V̇ = (p1 − p2 )
50.4µ
while for flow through a rectangular slit of width w and breadth b where w ≫ b
while b is much smaller than the breadth of the pipe, the flow rate is

πb2 w
V̇ = (p1 − p2 ) .
32µ
258 CHAPTER 6. MOMENTUM BALANCE

spool
house

land head
side

Supply
Servo valve

rod
Return side

Servo valve Piston

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

6.6.4 Valve and Servo system


6.6.4.1 Overview
Figure 6.13 depicts a combined hydraulic servo valve with piston.
The three-land-four-way spool valve is discussed at length in Merritt (1967).
With a “critical center” valve where the middle land is precisely manufactured to
have the same height as the corresponding opening, the gain of the flow to the
piston,V̇p , achieves maximal linearity wrt. the spool stroke xs . With some manufac-
turing inaccuracies so that the middle land height deviates from that of the opening,
either some dead band is observed (too high land) or some permanent “leakage” is
observed (too low land).

6.6.4.2 Servo valve


For the servo valve, Fig. 6.13 indicates that for xs > 0 (the middle land is below the
initial position),
V̇s,1 = fs,1 (ps − p1 )
V̇s,ℓ1 = fs,ℓ1 (p1 − pr )
V̇s,ℓ2 = fs,ℓ2 (p1 − p2 )
V̇r,2 = fr.2 (p2 − pr )
V̇s = V̇s,1 + V̇s,ℓ2
V̇s,1 = V̇p + V̇s,ℓ1
V̇r,2 = V̇s,ℓ2 + V̇p
V̇r = V̇r,2 + V̇s,ℓ1 .
From the above, it follows that
V̇s = V̇s,1 + V̇s,ℓ2 = V̇p + V̇s,ℓ1 + V̇s,ℓ2 = V̇r,2 + V̇s,ℓ1 = V̇r ,
thus V̇r ≡ V̇s — this is true under the assumption that there are only interior
leakages, and no leakage to the surroundings.
Because the leakage flows V̇s,ℓ1 and V̇s,ℓ2 are small, they may be described by
assuming laminar flow. If so, a “rectangular” slit of “width” ws = πd and breadth
bs = d−d
2
s
may be used. Then for xs ≥ 0,
πb2s ws
V̇s,ℓ1 = (p1 − pr )
32µ
πb2 ws
V̇s,ℓ2 = s (ps − p2 ) ,
32µ
where we have neglected the pressure drop dependence on xs . In reality, the leakage
rates will depend on xs because the friction drop will increase with the contact
surface xs · ws , so a more realistic expression would be (xs ≥ 0):
V̇s,ℓ1 = Ks,ℓ xs (p1 − pr )
V̇s,ℓ2 = Ks,ℓ xs (ps − p2 ) .
260 CHAPTER 6. MOMENTUM BALANCE

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 .

By defining the pressure difference across the piston as

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

Here, the discharge coefficient is defined as

Cc Cv
Cd , √ ( )2 ,
1 − A1
Cc wx

where Cv ≈ 1and Cc ≈ 0.6. In practice, the expression for Cd will normally be


independent of x.

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 ,

while the external force Fe acts as a disturbance.


The mass balance for the respective piston chambers are

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

Similarly for piston volume 2,

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

V1 + V2 = V10 + Ap xp + V20 + Ap (Lp − xp ) = V10 + V20 + Ap Lp .

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

Figure 6.14: Possible layouts for solenoids.

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

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


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).

Inductance To assess the dependence of the inductance on x, we utilize Ampere’s


law, which states that ˛
Hdℓ = N i
C

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

Since the impedance is defined via ψ = Li, it follows that L is

N 2A
L= ℓc 2(ℓ−x) ℓp
.
µc
+ µ0
+ µp

It is now convenient to define L0 , L (x = ℓ), thus

N 2A
L0 = ℓc ℓp
µc
+ µp

and thus L can be expressed as


ℓc
µc
+ µℓpp
L = L0 · .
ℓc
µc
+ 2(ℓ−x)
µ0
+ µℓpp

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

With µc = µ0 µr , this gives


ℓc
L = L0 · .
ℓc + (µr − 1) (Lp − x)

Finally, we have
∂L (µr − 1) ℓc
= L0 · .
∂x [ℓc + (µr − 1) (Lp − x)]2

Energy and forces The electric power added to the coil is Ė = ei = i dψ


dt
. The
dE
power is related to energy E as Ė = dt , and it follows that
ˆ ˆ
dψ dE ψ
i = ⇒ dE = idψ ⇒ E = idψ = dψ.
dt dt L
If we first assume that the plunger position is fixed at x, this gives
11 2 1
E= ψ + k = i2 L + k.
L2 2
Next, we assume that this stored energy E can be released as the plunger moves.
Thus a small change dE = F dx, or
∂E 1 ∂L
F = = i2 .
∂x 2 ∂x
Again, we see that we need the dependence of L on x.
The spool stroke xs is determined by excerting a force Fs on the spool. The spool
force Fs may be caused by some electric motor or by a solenoid/magnetic system,
and is then denoted an electro-hydraulic valve, or it may be set up by another
hydraulic servo valve with a piston system to change the spool position.
In Fig. 6.13, the indicated volumetric flow rate V̇s,1 will lead to a force operating
on the lands and forcing the land upwards. This force F will be given by the
momentum flow,
F = ṁv
6.6. HYDRAULICS AND SERVO CONTROL+ 267

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= .
A2
With A2 = Cc A0 and Cc ≈ 0.6, we find for xs ≥ 0
ρ
Fℓ = V̇ 2 cos θ.
Cc A0 s,1

Inserting the expression for V̇s,1 , we find

ρ 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

Fℓ ≈ 2Cd A0 · 0.358 · (ps − p1 ) .

With Cd ≈ 0.6 and A0 = wxs , this gives

Fℓ ≈ 2 · 0.6 · 0.358 · wxs (ps − p1 ) = 0.43wxs (ps − p1 ) .

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.

6.6.4.5 Complete servo system


Modern servo systems typically use solenoids as core actuators for the valve. If a
single solenoid is used, this may be equipped with a strong spring, and the steady
solenoid voltage is chosen so that the electromagnetic force balances the spring force
and the hydraulic forces on the valve. Then, to adjust the spool position of the valve,
the solenoid voltage is changed slightly so that the spool position changes.
As an alternative, two solenoids may be used to give the possibility of forces
acting in both directions, and thus a more direct way of moving the spool. In this
case, there are two basic control inputs: the voltage to each solenoid.
268 CHAPTER 6. MOMENTUM BALANCE

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.

The servo valve may be a one-stage, a two-stage or a three-stage system. Fig-


ure 6.15 indicates a two stage servo system with solenoid as basic actuator, and two
controllers.

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

6.6.5 Servo control design


6.6.5.1 Overview of model
For the purpose of studying the servo control system, it is instructive to depict this
system in a block diagram, Fig. 6.16.
In Fig. 6.16, the control input is xs , while ps − pr and Fe are disturbances. The
controlled variable is position xp — or in the case of using the piston to control the
guide vane, the controlled variable is the guide vane inlet angle α1 .

6.6.5.2 Linearized model


When linearizing a model, it is convenient to choose a steady state operating point
so that the system matrices are constant. For the servo system model, the following
operating point is useful:

• 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
ρ

dpδp 1 V1∗ + V2∗ ( δ ) V̇ ∗ − Ap v ∗ V ∗ + V ∗ ( 1 1


)
p p 1
= V̇p − Ap vp +
δ 2
Ap − xδ
dt βT V1∗ V2∗ βT V1∗ V2∗ V2∗ V1∗ p
| {z }
=0
dvpδ
mℓ = Ap pδp − Feδ
dt
dxδp
= vpδ .
dt
Here, V1∗ + V2∗ = V10 + V20 + Ap Lp = Vp is constant28 , and with our choice of x∗p , we
have V1∗ = V2∗ = V2p . Thus,
V1∗ + V2∗ 4
∗ ∗
= .
V1 V2 Vp
28
This is the total volume of hydraulic fluid in the piston and hoses.
CHAPTER 6. MOMENTUM BALANCE

control input disturbance


disturbance
piston leakage
Figure 6.16: Nonlinear block diagram of servo system, with linear blocks, nonlinear blocks and control inputs as well as disturbances.
270
6.6. HYDRAULICS AND SERVO CONTROL+ 271

Introducing the steady driving pressure ∆p∗ in the valve as



∆p∗ = p∗a − p∗p ,

and with x∗s = 0 we can now rewrite the model as



1 ∗ δ
V̇pδ = Cd w ∆p · xs
ρ
dpδp 4 ( )
= V̇pδ − Ap vpδ
dt βT V p
dvpδ
1 ( )
= Ap pδp − Feδ
dt mℓ
δ
dxp
= vpδ ,
dt

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

the controlled output is y = xδp , so the output description is

δ
 
( ) 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

hence it follows that V̇pδ is constrained by


[ ]
V̇pδ ∈ −V̇pmax , V̇pmax .

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

6.6.5.3 Basic system analysis


By Laplace transformation of the linear parts with V̇pδ as input and piston position
xδp as output, we find that we can write the system as

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.

6.6.5.4 Decoupling control design


i
In decoupling control design, the starting point is to find ddtyi which is affine in the
control input such that i ≥ 1 is as small as possible.
In our case, we will use the linearized model, and we find:

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

Next, we specify the closed loop dynamics to be

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.

6.6.5.5 Closed loop approximation


The key result here is, however, that it is possible to design a controller which
essentially gives first order closed loop dynamics from piston reference position xδp,r
to piston position xδp . The closed loop time constant of this system is T , which should
be chosen so that the piston flow rate V̇pδ doesn’t directly go into saturation. With
these constraints, the servo system can be represented by the first order constrained
system in Fig. 6.18.

6.6.6 Servo system nonlinearities


The saturation nonlinearity due to the limited piston flow rate can be neglected in
the controller design as long as this flow rate is not reached. In the indication of
6.7. TURBO MACHINES+,∗ 277

Control structure

Valve + piston

Controller

Approximate closed loop

Figure 6.18: Approximate servo system description.

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.

6.7 Turbo machines+,∗


A turbo-machine is a machine which transfers energy between a continuous stream
of a fluid and an element rotating about a fixed axis, Turton (1995). Examples of
turbo-machines are pumps, fans, compressors, and turbines. In pumps (liquid) and
fans and compressors (gas), mechanical power is added through the rotating axis
and leads to an increase in the fluid pressure over the equipment, while turbines
convert a pressure drop in the fluid across the machine into mechanical power on
the rotating axis.
...under construction...
• Start with dimensionless model/dimensional analysis
• Transport equipment: fan (gas, low pressure), compressor (gas, high pressure),
pump (liquid) ... role of energy balance?
• Energy extraction: turbine (gas, liquid)
Pump model: providing power to pump the fluid, fluid flows through the pump at
volumetric flow rate V̇p while increasing the pressure over the pump by ∆pp . A
278 CHAPTER 6. MOMENTUM BALANCE

Turbine

Figure 6.19: Key quantities in a turbine.

typical model for the pressure increase is


 ( )2 
V̇p
∆pp = f (u) ∆pςp − δpV̇p 
V̇pς

where u is an input signal that governs the provided power.

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.

6.7.2 Mechanistic hydro turbine models*


Turbine types The two main classes of turbines are the impulse turbines and the
reaction turbine. The most common impulse turbine is the Pelton turbine (1870s),
while the two most common reaction turbines are the Francis turbine and the Kaplan
turbine. Figure 6.20 gives a typical selection chart for hydro turbines depending on
the relation between volumetric flow rate V̇ (“Q” in the figure) and height difference
between reservoir level and level downstream from the turbine (“H” in the figure)
— the figure also includes a fourth turbine type, the Bulb turbine.
As seen from Fig. 6.20, the Pelton turbine is used for “small” flow rates V̇ and
pressure drops with equivalent water height of [100, 2000] m. A needle is used to
adjust a nozzle opening and thereby increasing the water velocity. High velocity
water hits a bucket with two cups31 and the energy is released as an impulse to
atmospheric pressure, causing the wheel to rotate. A water flow deflector is used for
additional and quick control of over-speed. See the paragraph on the Pelton turbine,
p. 284, for details.
In reaction turbines, a rotor is forced to rotate by a high water flow rate, much
like the propeller of a boat will rotate if the boat is towed. Two common types of
reaction turbines are the Francis turbine (1848) and the Kaplan turbine (1912). The
Francis turbine is used for medium to large flow rates V̇ and waterfalls in the interval
[20, 500] m. Water enters through a spiral casing that surrounds the runner (rotor).
31
Pelton invented the use of two cups.
280 CHAPTER 6. MOMENTUM BALANCE

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.

Fundamental relations In developing models for turbines, it is useful to split


the description into one part for the fluid guiding equipment (nozzle, guide vane,
etc.) and one part for the stator/rotor/turbine shaft, Fig. 6.21.
Using steady conservation of energy, we have
1 2 1
ṁv0 + p0 V̇ = ṁv12 + p1 V̇1 + Ẇf1
2 2
1 2 1
ṁv1 + p1 V̇1 = ṁv22 + p2 V̇2 + Ẇf2 + Ẇs
2 2
where Ẇf1 is the (positive) friction loss in the fluid guide apparatus and Ẇf2 is
the (positive) friction loss in the stator/rotor. By summing these two expressions,
clearly,
Ẇt = Ẇs + Ẇf1 + Ẇf2 .
If we neglect friction loss in the fluid guide apparatus, i.e., Ẇf1 ≡ 0, it is not
important whether we use (p1 , v1 ) or (p0 , v0 ) in the development of the model for
Ẇs .
282 CHAPTER 6. MOMENTUM BALANCE

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

Ẇi = Ti ω = vρ,i · ṁi vit


Ẇe = Te ω = vρ,e · ṁe vet

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:

Ẇa = Ẇfw + Ẇfb + Ẇfg + Ẇg .

Turbine geometry*** (How much is general?) In the development of models,


absolute velocity v in an earth bound reference system will be essential, together
with a reference velocity vρ in the same reference system, and a velocity v̌ relative
to the reference velocity, Fig. 6.22.

Example 6.4. Absolute and relative velocity

If a horse/rider moves at velocity v = 20 km/h in parallel to a train moving at


reference velocity vρ = 15 km/h, the passengers of the train will perceive the cowboy
to move at a velocity v̌ = v − vρ = 5 km/h relative to themselves. N
For turbine models, we are interested in relating XXX
6.7. TURBO MACHINES+,∗ 283

Figure 6.22: The absolute (earth bound) velocity v of a horse/rider is observed as


a relative velocity v̌ by passengers in a train moving with a reference velocity vρ .
More generally, an absolute velocity vector ⃗v is observed as relative velocity ⃗v̌ for
an observer moving with reference velocity ⃗vρ ; ⃗v = ⃗vρ + ⃗v̌ .

In general vector form, we relate absolute velocity (vector) ⃗v with reference


velocity ⃗vρ and relative velocity ⃗v̌ as follows,

⃗v = ⃗vρ + ⃗v̌ .

If we decompose the vectors into an orthogonal coordinate system of x- and y-axes,


and skip the vector symbol for the decomposed vectors, we get

v x = vρx + v̌ x
v y = vρy + v̌ y .

If we specifically choose x ∥ ⃗vρ and denote this by t (“tangential”), thus y ⊥ ⃗vρ


denoted r (“radial”), we have vρx = vρt = vρ , and vρy = vρr = 0:

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)

where it follows that


v t = v r cot α. (6.51)
Furthermore, from the sine law, we have
v v v̌
= = . (6.52)
sin (π − γ) sin γ sin α
284 CHAPTER 6. MOMENTUM BALANCE

Figure 6.23: Some key concepts of the impulse turbine.

By combining Eq. 6.45 with Eqs. 6.47 and 6.48 to get

v · cos α = vρ + v̌ · cos γ, (6.53)

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 :

cos α · sin γ − sin α · cos γ v r


vρ =
sin γ sin α

vρ = (cot α − cot γ)v r . (6.55)

The Pelton turbine: impulse transfer*

Overview The impulse turbine is a conceptually simple type of turbine, where


the Pelton turbine is the most commonly used one today. Figure 6.23 illustrates the
main concepts.
The impulse turbine consists of a nozzle (“0”–“1”) where a needle in position Y
can be moved to change the cross sectional area at position “1”, and thus the velocity
6.7. TURBO MACHINES+,∗ 285

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

K̇0 + Ẇ0 = K̇1 + Ẇ1 + Ẇf

where
1
K̇ = ṁv 2
2
Ẇ = pV̇ .

With constant ṁ and V , and v = V̇ /A, this leads to


( )2 ( )2
1 V̇ 1 V̇
ṁ + p0 V̇ = ṁ + p1 V̇ + Ẇf
2 A0 2 A1

( )
1 1 1
(p0 − p1 ) V̇ = ṁV̇ 2 2
− 2 + Ẇf .
2 A1 A0

Here, ∆pn , p0 − p1 is the pressure drop across the nozzle. It is common to


assume that Ẇf ∝ V̇ 2 , e.g.,
1
Ẇf = ρkf V̇ 2 .
2
Finally, A1 is a function of needle position Y ; A1 = A1 (Y ). Thus
[ ( ) ]
1 2 1 1
∆pn V̇ = V̇ ṁ − + ρkf .
2 A21 (Y ) A20

By utilizing that ṁ = ρV̇ , we can alternatively find


[ ( ) ]
1 2 1 1
∆pn V̇ = ρV̇ V̇ − + kf
2 A21 (Y ) A20

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


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

v2t = vR + k (v1 − vR ) cos β.

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

The transferred power can then be written as


Ẇs = ṁvR (v1 − vR ) (1 − k cos β) .
It is of interest to see how we can maximize the performance of the turbine.
Although the reference velocity vR is given since vR = Rω and ω normally is con-
strained by the grid frequency, let us consider the case when v1 is known and we can
vary vR . To this end, the transferred power Ẇs (vR ) is maximized when ∂∂vẆRs = 0,
leading to (vR )max = 12 v1 or
v12
Ẇs (vR )max = ṁ (1 − k cos β) .
4
Similarly, the maximal torque is given from Ẇ = T ω = T vRR = T 2R
v1
, or
v1
Ts (vR )max = ṁR (1 − k cos β) .
2
The real shaft power transferred is the ideal power given by Euler’s equation
reduced by friction loss,
Ẇs = Ẇt − Ẇft ,
where for the case that Ẇft ≡ 0, Ẇs = Ẇt . Similarly, the real shaft torque Ts ω = Ẇs .
Figure 6.24 illustrates how the friction free model Ẇs (vR ) fits with experimental
data.
Possible explanations for the mismatch between the theoretical model and the
actual data in Fig. 6.24 could be friction loss, the fact that there is not a continuum
of buckets, etc. A common way to represent this mismatch is to say that there is a
power loss proportional to ṁvR2 , thus
Ẇf2 = K ′ ṁvR2 = K (1 − k cos β) ṁvR2 .
Because the theoretic shaft work Ẇs is based on an assumption of no (friction) loss,
the actually observed data must be compared to Ẇs − Ẇf2 . The reason why this is
so, is that when we include the friction term Ẇf2 in the momentum balance for the
hydro power pressure shaft, this will reduce the velocities and pressure drops that
are involved in the the expression for Ẇs — this implies that when the friction term
is included in the flow model, we should still use the expression for Ẇs . We find
Ẇs − Ẇf2 = ṁvR [v1 − (1 + K) vR ] (1 − k cos β) .

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

Figure 6.25: Principle drawing and illustration of Francis turbine. From


Harinaldi, http://staff.ui.ac.id/system/files/users/harinaldi.d/material/
fluidsystem09-reactionturbine-francisandkaplan.pdf.

From Fig. 6.24, we see that in that figure,


1 1 − 0.8
≈ 0.8 ⇒ K ≈ = 0.25.
1+K 0.8
Furthermore, from the expression for Ẇs − Ẇf2 , we see that Ẇs − Ẇf2 = 0 when
vR = 0 ∨ vR = 1+K 1
v1 = 0.8v1 , which also fits well with Fig. 6.24.
In practical installations, there will be a deflector mechanism to reduce the ve-
locity v1 δ (uδ ) to avoid over-speed. A final expression for the shaft work and friction
could thus be

Ẇs = ṁvR [δ (uδ ) · v1 − vR ] (1 − k cos β)


Ẇf2 = K (1 − k cos β) ṁvR2 .

The Francis turbine: reaction transfer*

Overview The Francis turbine is a radial flow turbine, and is illustrated in


Fig. 6.25.
Figure 6.26 shows how the so-called guide vanes affect the flow of water towards
the turbine stator.
In Fig. 6.26, the spiralling cage is designed so that the flow through each of N
V̇ 32
opening pairs of guide vanes is (approximately) the same, N ; the linear velocity v1
is also the same through each opening. The distance between each hinge point for
32
In the figure, only 3 openings are shown; the N openings are spread equidistantly around the
stator entrance.
290 CHAPTER 6. MOMENTUM BALANCE

Turbine
entrance
flow

Guide
vanes

Spiralling
cage

Rotor

Stator

Figure 6.26: Effect of guide vane angle α1 on stator inlet velocity v1 .

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;

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:

K̇0 + p0 V̇ = K̇1 + p1 V̇ + Ẇf1 ;

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

With V̇ = ṁ/ρ, we then have

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.

may alternatively be included in some overall efficiency of the turbine. Of course,


if there is no friction loss across the guide vanes, the guide vanes do not influence
the efficiency of the turbine and one can instead just replace the expression for ∆pv
with some standard valve model.

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

As an example, we could postulate (V̇ ≥ 0)

Ẇf2,1 = kf2,1 V̇ (cot γ1 − cot β1 )2 .

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

Ẇf2,2 = kf2,2 V̇ cot2 α2 .

Model summary Produced shaft power Ẇs is given as


( ( ))
V̇ V̇
Ẇs = ṁω R1 cot α1 − R2 ωR2 + cot β2
A1 A2

while, e.g.,

Ẇf2 = kf2,1 V̇ (cot γ1 − cot β1 )2 + kf2,2 V̇ cot2 α2 + kf2,3 V̇ 2

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 .

If useful, we can write Ẇs as Ẇs = η Ẇt where

Ẇ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 .

Turbine design algorithm The Francis model contains a number of design/-


geometry parameters θ = (β1 , β2 , R1 , R2 , w1 ), and it is of interest to have available
an algorithm for selecting these parameters.
Typical design algorithms are based on steady state values of volumetric flow rate
V̇ and net water head Ht across the turbine, defined by turbine pressure drop ∆pt ;
∆pt = ρgHt . The gross water head H is the difference in magazine water level and
∆p
downstream water level, thus Ht = H − ρgf,c where ∆pf,c is the friction pressure drop
in conduits outside of the turbine. Because variables ( vary during
) season/operation,
n n
design is based on nominal values of the variables, V̇ , Ht . Alternatively, we can
base the design(on the nominal
) volumetric flow rate and the nominal total turbine
n n n
work rate Ẇt , V̇ , Ẇt .
? discusses design algorithms for hydro power ( turbines,)amongst
( them the) Fran-
n n n n n n
cis turbine; see also ?. The input information V̇ , Ht , fe or V̇ , Ẇt , fe where
fen is nominal electric grid frequency, as well as computed design parameters θ and
resulting nominal inlet guide vane angle α1n are depicted in Fig. 6.28.
In Fig. 6.28, with nominal volumetric flow rate V̇ n and net head Htn given,
we can design the turbine. If, on the other hand, the volumetric flow rate V̇ n is
given together with the total turbine turbine Ẇtn , we can deduce the net heat Htn :
Htn Ẇ n Ẇ n Ẇ n
Hn
= Ẇtn ⇒ Htn = ρgH nt V̇ n H n = ρgV̇t n .
It is convenient to define the hypothetical inlet velocity v ς to the turbine
√ from
converting net head power to kinetic power: 2 ṁ (v ) = ṁgHt ⇒ v = 2gHt . In
1 ς 2 n ς n
v
the algorithm below, a scaled/dimensionless velocity v̄j , vjς occurs.
With nominal electric frequency fen = 50 Hz, the nominal electric angular fre-
quency is ωen = 2πfen . Assuming Np pole pairs in then generator, the nominal angular
ωe
frequency of the aggregate/turbine rotor is ω n = N p
.
The design algorithm consists of the following steps:
296 CHAPTER 6. MOMENTUM BALANCE

1. Parameter β2 . ? suggests that β2 ∈ [158◦ , 165◦ ]. Outlet blade angle β2 takes


a higher value for higher heads. ? suggests a standard value of β2 = 162.5◦ .

2. Parameter R2 . ? suggests a design value for rotor velocity vω,2 at radius R2 of


vω,2 ∈ [35, 42] m/s. ? suggests a value of vω,2 = 41 m/s. We need to consider
two cases: (a) the number of pole pairs Np is known, and (b) Np is unknown.
ωen vω,2 n
(a) Np is known, thus ω n = is known. Then v2r = − cot = − cot
ω R2
and
Np
√ β2 β2
V̇ n
v2r = πR 2 , which when combined leads to R2 =
3
− πω
V̇ n
n cot β2 . Reinsert-
2
n
ing R2 leads to vω,2 = ω R2 , which for a properly designed system should
give vω,2 ∈ [35, 42] m/s.
ωen
(b) Np is unknown, thus ω n = is unknown. First we find Np . Initially, set
Np
v0
√ n
2
0
vω,2 = 41 m/s, thus v2r,0 = − cotω,2β2and V̇ d = π (R20 ) v2r,0 ⇒ R20 = πvV̇ r,0 ,
2
0
vω,2 ωen
and finally 0
vω,2 = R20 ω 0 ⇒ ω = 0
0
0
. With ω =
choose Np by ,
R2
⌈ n⌉ Np
ωen 2πfen
rounding ω0
= upwards to the nearest integer: Np = 2πf
ω0 ω0
e
. With

ωen
Np and ω n = N p
thus fixed, compute R2 = 3 − πωV̇ n
n cot β2 and check that
ω n R2
vω,2 = ω R2 has a reasonable value. Finally, v2 = − cot
n n r
β2
.

3. Parameter R1 . ? suggests that v̄ω,1 = vvω,1


ς ∈ [0.7, 0.75]; v̄ω,1 = 0.725 is a
common
√ value (?). The inlet radius is thus found from vω,1 = R1 ω n ⇒ R1 =
v̄ω,1 2gHtn
ωn
.

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.

5. Operating point α1n . ? suggests to choose √ the dimensionless tangential inlet


0.48
velocity as v̄1 = v̄ω,1 , and thus v1 = v̄1 2gHtn . From geometry, v1t = v1r cot α1n ,
t t t
( t)
vt
thus the nominal inlet vane angle should be cot α1n = v1r ⇒ α1n = cot−1 v1r .
v
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

Example 6.5. Francis turbine design for Sundsbarm power plant.

The Sundsbarm hydro power plant in Telemark, Norway, has the following nom-
inal conditions:

• Nominal flow rate, V̇ n = 24.3 m3 /s,

• Nominal net head, Htn = 460 m,

• Nominal electric frequency, fen = 50 Hz.

We can now compute turbine parameters and operating inlet guide vane angle:

1. Parameter β2 . We choose β2 = 162.5◦ .


0
2. Parameter R2 . The number of pole pairs Np is unknown. We choose vω,2 =
v 0 √
41 m/s, find v2r,0 = − cotω,2β2 = − cot 41 ≈ 12.93 m/s, then R20 = V̇ n
162.5 πv2r,0
=

v0
24.3
≈ 0.7735 m and ω 0 = Rω,2 0 =
41
≈ 53.00 rad/s. Next, the number
π·12.93
⌈ n ⌉ ⌈ 2 ⌉ 0.7735
of pole pairs is Np = 2πf ω0
e
= 2π·50 = ⌈5.927⌉ = 6. Finally, we find radius
√ √
53

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 .

6. Parameter β1 . For zero nominal inlet shock,


( ) ( 2π·50 )
−1 v1t − R1 ω n −1 62.90 − 1.315 · 6
β1 = cot = cot
v1r 11.66

β1 ≈ −62.85◦ + 180◦ = 117.15◦ .

In summary, θ = (β1 , β2 , R1 , R2 , w1 ) = (117.15◦ , 162.5◦ , 1.315 m, 0.7767 m, 0.2522 m)


and α1n = 10.50◦ ; Np = 6. N
298 CHAPTER 6. MOMENTUM BALANCE

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

Table 6.7: Example parameters for Guide Vane system.


Parameter Value Parameter Value
rv 1.5 m rY 1.6 m
Rv √2m RY 3m
(Rv −rv )2
ℓ 1.8 · 2

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

RY2 = rY2 + Y02


rY
cos θ0 = .
RY
Clearly, d0 = Rv − rv .Next, moving the actuator to position Y , Fig. 6.29 (b) with
the cosine law gives
Y 2 = rY2 + RY2 − 2rY RY cos θ,
thus specifying angle θ. We introduce the change in angle θ as (Fig. 6.29 (b), (c))
as
∆θ ≡ θ − θ0 .
Then, applying the cosine law to Fig. 6.29 (c) gives length d from35

d2 = rv2 + Rv2 − 2rv Rv cos ∆θ

and then angle ψ from


rv2 = d2 + Rv2 − 2d · Rv cos ψ;
here it is necessary to ensure that the sign of ψ equals the sign of ∆θ.
From Fig. 6.29 (d) and applying the cosine law, we find
d
ℓ2 = ℓ2 + d2 − 2ℓd · cos ϕ ⇒ cos ϕ = .
2ℓ
Finally, we find the guide vane angle as

α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

90 Guide Vane angle α1 as a function of actuator position Y

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

Figure 6.31: Principle drawing and illustration of Kaplan turbine. From


Harinaldi, http://staff.ui.ac.id/internal/132048279/material/FluidSystem09-
ReactionTurbine-FrancisandKaplan.pdf.

angle α1 , a setpoint to sin α1 , or a setpoint to Y . The closed servo loop normally


adds a time constant of about 1 s to the system.

The Kaplan turbine: reaction transfer*

Overview The Kaplan turbine is an axial flow turbine, and is illustrated in


Fig. 6.31.
Figure 6.32 shows some velocities in the Kaplan turbine.

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

Figure 6.32: Key quantities in the Kaplan turbine model.

Adjusting the pitch of the blades will change the inlet angle β1 of the relative velocity
v̌1 . From simple geometry, we find that

v̌1a = v̌1 sin (180 − β1 ) = v̌1 sin β1


v̌1t = −v̌1 cos (180 − β1 ) = v̌1 cos β1 .

By combining these, we find that


v̌1a
v̌1t = cos β1 = v1a cot β1 .
sin β1
We finally then find that

v1t = vr + v̌1t = vr + v1a cot β1 .

For the exit from the propeller area, we have that

v2t = vr − v̌2t .

It is a common assumption that v2t = 0, known as the no whirl condition.


We can now formulate the expression for the power produced by the water for
radius r. Normally, this expression would be
( )
Ẇs = ṁ vr v1t − vr v2t .

However, by considering the expression for v1t we see that


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 .

Servo system for actuator positioner


• Newton’s law, PD controller, 1.order system
• Flow limiter, a la Linn Saarinen
• Positioner back-lash a la Linn Saarinen

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:
[ ]

Ẇ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
[ ]

ẆsKaplan = ṁω R̄ (− cot β1 ) − ω R̄ , β1 ≥ 90◦ =⇒ cot β1 ≤ 0
A
6.8. CASES: MATERIAL DESCRIPTION⋆ 305

Table 6.8: Parameters in the generic turbine model.


Parameter Pelton Francis Kaplan
k0j R R2 R̄
k1j δ (1 − k cos β) R1
R2
cot α1 + cot β2 − cot β1
k2j (1 + K) R (1 − k cos β) R2 R̄

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.

6.8 Cases: Material description⋆


...under construction...

6.8.1 “Car” with mass and shock-dampers⋆


...under construction...
• Vogging
306 CHAPTER 6. MOMENTUM BALANCE

Figure 6.33: Pipe transporting water from a dam through a pipe and a valve.

6.8.2 Two rotational masses w/ turbine⋆


...under construction...

• Turbin, generator

6.8.3 Particle feeder⋆


...under construction...

• Yara, prilletårn, Babak

6.8.4 Elastic beam⋆,+


...under construction...

• Elastisk aksling?

6.9 Case: Incompressible liquid pipe flow


6.9.1 Model objective
We consider the system in Fig. 6.33, where water from a dam flows through a pipe at
volumetric flow rate V̇ and is released to the atmosphere through a valve. The dam
level is h above the pipe intake, and the release valve opening can be manipulated
via an input signal u.
We are interested in seeing how an input signal u to the release valve can be
used to manipulate the volumetric flow rate V̇ through the pipe. It is reasonable to
assume that the liquid density ρ is the same everywhere. Atmospheric pressure is
pa . The mass of water in the pipe, mp , is subjected to forces of gravity Fg , friction
6.9. CASE: INCOMPRESSIBLE LIQUID PIPE FLOW 307

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̇ .

6.9.2 Model development


We assume that the liquid is homogeneous wrt. density ρ. Within the pipe, we
assume a uniform velocity field v across the cross sectional area Ap .

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

Step 2: Assuming homogeneous density, pipe mass is related to pipe volume as

m = ρV

where the pipe volume is


V = Ap L.
It follows that m is constant, and thus that

ṁi = ṁe = ṁ.

Mass flow rate is related to volumetric flow rate as

ṁ = ρV̇ ,

while linear velocity v is related to volumetric flow rate V̇ as

V̇ = vAp .
308 CHAPTER 6. MOMENTUM BALANCE

Effluent flow through the release valve is



∆pe
ṁe = Ke (u)

where we set the scaling pressure pς = pa , and
∆pe = pe − pa .
For simplicity, we let
Ke (u) = Ke0 · u.
Here,
pe = p + ρgH
while
p = pa + ρgh.
For the pipe, the momentum is
m = mv
Because
ṁ = ṁv = constant,
it follows that ṁi = ṁe . The forces are
F = −Ff + Fg + Fp
where the friction force is
Ff = kv |v| ,
gravity is
H
Fg = mg
L
while the pressure force is
Fp = pAp − pe Ap .

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

∆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.

We can write this model as a DAE in the form


dx
= f (x, z, u; θ)
dt
0 = g (x, z, u; θ)

where

x = (m)
( )
z = v, V̇ , ṁ, ∆pe , pe , F, Ff , Fg , Fp , p
u = (u, h)
( )
θ = ρ, Ap , L, m, Ke0 , pa , k, g, H .

Step 4: With the DAE formulation, the output y = V̇ is automatically computed.

6.9.3 Model summary


The model can be summarized as in Step 3 and Step 4 in the previous section.
To complete the model description, we need to specify model parameters and
operating conditions. We choose the following parameters for the model, Table 6.9.
The operating conditions (initial state, input) are defined in Table 6.10.
310 CHAPTER 6. MOMENTUM BALANCE

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

Pipe flow: volumetric flow rate


3.0

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]

Figure 6.35: Volumetric flow rate V̇ through pipe/valve.

6.9.4 Model simulation


Using OpenModelica, the results of simulating the system are as in Figs. 6.35–6.39.
Figure 6.37 illustrates how the pressure upstream from the valve makes a sudden
increase when we close the valve. Operational care should be shown to avoid too
high pressure drop across the valve.
The following Modelica code (file PipeDam.mo) is used to produce the figures.

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

Pipe flow: valve signal


0.50

0.48

0.46
u

0.44

0.42

0.40
0 1 2 3 4 5 6 7 8
time t [s]

Figure 6.36: Valve input signal u.

Pipe flow: pressures


1600000
pe
1400000 pa
1200000
1000000
[Pa]

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

Pipe flow: forces


1500000 F
Ff
1000000 Fg
500000 Fp
0
[N]

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).

Pipe flow: momentum


600000

580000

560000
[Nm]

540000

520000

500000

0 1 2 3 4 5 6 7 8
time t [s]

Figure 6.39: Momentum m (our chosen state).


6.9. CASE: INCOMPRESSIBLE LIQUID PIPE FLOW 313

15 // Instantiate model of flow in pipe from dam ( pd )


16 ModPipeDam pd ;
17 // Declaring variables
18 // -- inputs
19 Real _u " Valve input signal , -";
20 Real _h " Dam level above pipe inlet , m ";
21 // -- outputs
22 output Real _Vd " Volumetric flow rate , m3 / s ";
23 // Equations
24 equation
25 // -- input values
26 _u = if time < 4 then 0.5 else 0.4;
27 _h = 5;
28 // -- injecting input functions to model inputs
29 pd . u = _u ;
30 pd . h = _h ;
31 // -- outputs
32 _Vd = pd . Vd ;
33 end SimPipeDam ;
34 //
35 model ModPipeDam
36 // Model of flow in pipe from dam
37 // author : Bernt Lie
38 // University of South - Eastern Norway
39 // September 23 , 2015
40 // May 12 , 2017
41 //
42 // Constants
43 constant Real g = 9.81 " Acceleration of gravity , m / s2 ";
44 // Parameters
45 parameter Real Ap = 1.5 " Cross sectional area of pipe , m2
";
46 parameter Real H = 100 " Level drop of pipe , m ";
47 parameter Real k = 4 e4 " Friction coefficient , N /( m / s ) 2";
48 parameter Real Keo = 2 e3 " Valve coefficient , kg / s ";
49 parameter Real L = 200 " Pipe length , m ";
50 parameter Real m = rho * Ap * L " Mass of liquid in pipe , kg ";
51 parameter Real pa = 1.01 e5 " Atmospheric pressure , Pa ";
52 parameter Real rho = 1 e3 " Liquid density , kg / m3 ";
53 // Initial state parameters
54 parameter Real v0 = 2 " Initial linear velocity of water ,
m / s ";
55 parameter Real M0 = m * v0 " Initial momentum of pipe fluid ,
N . s ";
56 // Declaring variables
57 // -- states
58 Real M ( start = M0 , fixed = true ) " Momentum of pipe fluid ,
N . s ";
59 // -- auxiliary variables
314 CHAPTER 6. MOMENTUM BALANCE

60 Real v " Linear velocity in pipe , m / s ";


61 Real Vd " Volumetric flow rate , m3 / s ";
62 Real md " Mass flow rate , kg / s ";
63 Real dpe " Pressure drop over valve , Pa ";
64 Real pe " Pressure in front of valve , Pa ";
65 Real p " Pressure at pipe inlet , Pa ";
66 Real F " Net force , N ";
67 Real Ff " Friction force , N ";
68 Real Fg " Gravitational force , N ";
69 Real Fp " Net pressure force , N ";
70 // -- input variables
71 input Real u " Input signal to valve , -";
72 input Real h " Dam level above pipe inlet , m ";
73 // Equations constituting the model
74 equation
75 // Differential equations
76 der ( M ) = F ;
77 // Algebraic equations
78 M = m*v;
79 Vd = v * Ap ;
80 md = rho * Vd ;
81 md = Keo * u * sqrt ( dpe / pa ) ;
82 dpe = pe - pa ;
83 //
84 F = - Ff + Fg + Fp ;
85 Ff = k * v * abs ( v ) ;
86 Fg = m * g * H / L ;
87 Fp = (p - pe ) * Ap ;
88 p = pa + rho * g * h ;
89 end ModPipeDam ;
90 // End package
91 end PipeDam ;

6.10 Case: Two tanks with basin and pump


6.10.1 Model objective
We consider the system in Fig. 6.40, where liquid (water) from a basin is pumped
up into an upper tank, flows by gravity down to a lower tank, and then flows by
gravity back to the basin.
We are interested in seeing how an input signal u to the pump can be used to
manipulate the level in the lower tank, hℓ . It is a reasonably assumption that the
liquid density ρ is the same everywhere. Atmospheric pressure is pa . The mass of
water in the pipe, mp , is subjected to forces of gravity Fg , friction Ff , and liquid
pressure Fp . The length of the filled pipe is L, and the height difference which the
pump lifts the liquid is H.
The functional diagram in Fig. 6.41 depicts the causality of the system where
pump input u cause a change in the observed level of the lower tank, hℓ .
6.10. CASE: TWO TANKS WITH BASIN AND PUMP 315

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.

Two tanks with


basin and pump

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

6.10.2 Model development


We assume that the liquid is homogeneous wrt. density ρ, and that the liquid levels
are even without any waves, etc. Within the pipe, we assume a uniform velocity
field v across the cross sectional area Ap .

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 ,

and assuming constant cross sectional areas Aj , volume is related to level as

Vj = hj Aj .

We assume that flow by gravity is given by (j ∈ {u, ℓ})



hj
ṁe,j = Kj
hςj

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

where the friction force is


Ff = kvp |vp | ,
gravity is
H
Fg = mp g
L
while the pressure force is

Fp = pp Ap − pa Ap .

Energy input to the pump leads to a pressure increase ∆pp given by


 ( )2 
V̇p 
∆pp = f (u) ∆pςp − δpV̇p
V̇pς

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ς

We can write this model as a DAE in the form


dx
= f (x, z, u; θ)
dt
0 = g (x, z, u; θ)
where
x = (mu , mℓ , mb , mp )
( )
z = ṁi,u , ṁe,u , ṁi,ℓ , ṁe,ℓ , ṁi,b , ṁe,b , F, Vu , hu , Vℓ , hℓ , Vb , hb , vp , ṁp , V̇p , Ff , Fg , Fp , pp , pb , ∆pp
u = (u)
θ = (ρ, Au , Aℓ , Ab , mp , Ap , L, Ku , hςu , Kℓ , hςℓ , k, g, H, pa , c1 , c2 ) .

Step 4: With the DAE formulation, the output y = hℓ is automatically computed.

6.10.3 Model summary


The model can be summarized as in Step 3 and Step 4 in the previous section.
To complete the model description, we need to specify model parameters and
operating conditions. We choose the following parameters for the model, Table 6.11.
The operating conditions (initial state, input) are defined in Table 6.12.
6.10. CASE: TWO TANKS WITH BASIN AND PUMP 319

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

Two tanks with basin: levels


0.26
0.24
0.22
0.20
[m]

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.

6.10.4 Model simulation


Using OpenModelica, the results of simulating the system are as in Figs. 6.42–6.44.
Observe the quick response in the fourth state, ṁp , both at initial time and at
the jump in the input signal u; see Fig. 6.43–6.44. It turns out that the model
can be simplified by assuming steady state in the momentum balance, while still
getting (almost) the same overall response in the levels hj . If the length of the
pipe increases, however, this will increase the inertia of the mass in the pipe, and
assuming steady state momentum balance may not be valid any more.
The following Modelica code (file PipeTwoTank.mo) is used to produce the fig-
ures.

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

Two tanks with basin: influent mass flow rates


mi,
mi, u
0.10 mi, b

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.

Two tanks with basin: pump input signal


0.5200
0.5175
0.5150
0.5125
0.5100
u

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]

Figure 6.44: Input signal u to pump.


322 CHAPTER 6. MOMENTUM BALANCE

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

56 parameter Real mp = rho * Ap * L " Mass of liquid in pipe , kg


";
57 parameter Real pa = 1.01 e5 " Atmospheric pressure , Pa ";
58 parameter Real rho = 1 e3 " Liquid density , kg / m3 ";
59 // Initial state parameters
60 parameter Real hb0 = 0.25 " Initial level of basin , m ";
61 parameter Real hl0 = 0.2 " Initial level of lower tank , m
";
62 parameter Real hu0 = 0.2 " Initial level of upper tank , m
";
63 parameter Real mdp0 = 0.1 " Initial mass flow rate in pipe
, kg / s ";
64 parameter Real Vdp0 = mdp0 / rho " Initial volumetric flow
rate pipe , m3 / s ";
65 parameter Real vp0 = Vdp0 / Ap " Linear velocity in pipe , m /
s ";
66 parameter Real mb0 = rho * Ab * hb0 " Initial mass in basin ,
kg ";
67 parameter Real ml0 = rho * Al * hl0 " Initial mass in lower
tank , kg ";
68 parameter Real mu0 = rho * Au * hu0 " Initial mass in upper
tank , kg ";
69 parameter Real Mp0 = mp * vp0 " Initial momentum of pipe
fluid , N . s ";
70 // Declaring variables
71 // -- states
72 Real mb ( start = mb0 ) " Mass of liquid in basin , kg ";
73 Real ml ( start = ml0 ) " Mass of liquid in lower tank , kg ";
74 Real mu ( start = mu0 ) " Mass of liquid in upper tank , kg ";
75 Real Mp ( start = Mp0 ) " Momentum of pipe fluid , N . s ";
76 // -- auxiliary variables
77 Real mdiu " Influent mass flow rate to upper tank , kg / s ";
78 Real mdeu " Effluent mass flow rate from upper tank , kg / s
";
79 Real mdil " Influent mass flow rate to lower tank , kg / s ";
80 Real mdel " Effluent mass flow rate from lower tank , kg / s
";
81 Real mdib " Influent mass flow rate to basin , kg / s ";
82 Real mdeb " Effluent mass flow rate from basin , kg / s ";
83 Real F " Total force acting on pipe fluid , N ";
84 Real Vu " Liquid volume of upper tank , m3 ";
85 Real hu " Liquid level of upper tank , m ";
86 Real Vl " Liquid volume of lower tank , m3 ";
87 Real hl " Liquid level of lower tank , m ";
88 Real Vb " Liquid volume of basin , m3 ";
89 Real hb " Liquid level of basin , m ";
90 Real vp " Linear velocity of liquid in pipe , m / s ";
91 Real mdp " Mass flow rate of liquid in pipe , kg / s ";
92 Real Vdp " Volumetric flow rate of liquid in pipe , m3 / s ";
324 CHAPTER 6. MOMENTUM BALANCE

93 Real Ff " Friction force acting on liquid in pipe , N ";


94 Real Fg " Gravitational force acting on liquid in pipe , N
";
95 Real Fp " Net pressure force acting on liquid in pipe , N ";
96 Real pp " Pressure in liquid at entrance to pipe / after
pump , Pa ";
97 Real pb " Pressure in liquid at bottom of basin / before
pump , Pa ";
98 Real dpp " Pressure increase over pump , Pa ";
99 // -- input variables
100 input Real u " Input signal to pump , -";
101 // Equations constituting the model
102 equation
103 // Differential equations
104 der ( mu ) = mdiu - mdeu ;
105 der ( ml ) = mdil - mdel ;
106 der ( mb ) = mdib - mdeb ;
107 der ( Mp ) = F ;
108 // Algebraic equations
109 mu = rho * Vu ;
110 Vu = Au * hu ;
111 ml = rho * Vl ;
112 Vl = Al * hl ;
113 mb = rho * Vb ;
114 Vb = Ab * hb ;
115 Mp = mp * vp ;
116 vp = Vdp / Ap ;
117 mdp = rho * Vdp ;
118 //
119 mdiu = mdp ;
120 mdeu = Ku * sqrt ( hu / hsu ) ;
121 mdil = mdeu ;
122 mdel = Kl * sqrt ( hl / hsl ) ;
123 mdib = mdel ;
124 mdeb = mdp ;
125 //
126 F = -Ff - Fg + Fp ;
127 Ff = k * vp * abs ( vp ) ;
128 Fg = mp * g * H / L ;
129 Fp = ( pp - pa ) * Ap ;
130 //
131 pp - pb = dpp ;
132 pb = pa + rho * g * hb ;
133 dpp = u *( dpp0 - delpVd *( Vdp / Vdpo ) ^2) ;
134 end ModPipeTwoTank ;
135 // End package
136 end PipeTwoTank ;
6.11. CASE: GAS PIPELINE⋆,+ 325

Figure 6.45: Pipe for transporting gas.

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 .

6.11 Case: Gas pipeline⋆,+

6.11.1 Model objective

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

6.11.2 Model development


We assume that the gas is homogeneous wrt. density ρ and pressure p in a given
cross section36 , and that the velocity field v is uniform across the cross sectional
area Ap .

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

Step 2: In general, we have


m = ρV ,
and assuming constant cross sectional areas A, volume is related to length ℓ
as
V = Aℓ.
Pressure is related to density by the ideal gas law:

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.

The involved forces are pressure force, gravity, and friction:

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:

dmξ+∆x (t) ∂mx+∆x (t, x)



dt ∂t
dmξ+∆x (t) ∂mx+∆x (t, x)
→ .
dt ∂t

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

6.11.3 Model summary


The model can be summarized as in Step 3 and Step 4 in the previous section.
However, this is a tricky problem to solve numerically, and we will not attempt to
do so here.

6.11.4 Model analysis


Instead of simulating the model, we will turn to the simpler problem of considering
the steady state of the model. By setting the PDEs in Steps 3.c-3.d above in steady
state, we have
RT dṁ
0=−
M Ap dx
( )
RT d ṁ2 dp gH Ap M 1 RT ℘ ṁ2
0=− − Ap + p− f .
Ap M dx p dx L RT 2 M A2p p
From the first of these equations, it follows that ddx

= 0 ⇒ ṁ = ṁi = ṁe =
constant. The second equation then leads to
( )
dp 2 RT d 1 gH Ap M 1 RT ℘ ṁ2
Ap + ṁ = p− f
dx Ap M dx p L RT 2 M A2p p

( 2
)
ṁ RT dp gH Ap M 1 RT ℘ ṁ2
Ap − 2 = p− f .
p Ap M dx L RT 2 M A2p p
In the case of a horizontal pipe, H → 0, we find
( )
ṁ2 RT dp 1 RT ℘ ṁ2
Ap − 2 =− f
p Ap M dx 2 M A2p p

p2 − RT
A2p M
ṁ2
2 ℘
dp = −dx.
p ART
2 M ṁ 2A f
p
p

The solution is found to be


ˆ pe RT
ṁ2 − p2 ˆ L
A2p M RT ℘
dp = 2 ṁ2 f dx
pi p Ap M 2Ap 0


[ ]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

The pressure drop due to friction is

∆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

6.12 Case: Under-balanced drilling⋆


...under construction...

6.13 Case: Penstock with compressible water/e-


lastic wall⋆,+
...under construction...

6.14 Case: Open channel flow⋆,+


...under construction...

6.15 Concluding comments


Let us finally comment on the application of the momentum balance. As we have
seen, the momentum balance is used to compute velocities in (fluid) flow. In the
simple case, we have uniform velocity across pipes (turbulent flow) leading to one-
dimensional problems, but in more complicated cases, we compute the velocity fields
everywhere in space. Examples of more complicated computations are meteorolog-
ical computations, computation of velocity flows in tanks around an impeller, etc.
In these more complex cases, two-dimensional and three-dimensional models will be
needed.
In these notes, only the simple case of one-dimensional variation is treated. We
will thus normally assume uniform flow, and either assume that the flow velocity is
known, e.g., via a known pump velocity, or by using simple, one-dimensional flow
models as in the examples of this lesson.
334 CHAPTER 6. MOMENTUM BALANCE

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

parabolic profile with maximum value vm at the center line r = 0:


( ( r )2 )
v (r) = vm 1 −
R
Show that the average velocity across the pipe, ⟨v⟩, is related to vm as ⟨v⟩ = vm /2.
N
Exercise 6.2. [Solution D.16 p. 585] Darcy friction factor for laminar flow.
Darcy’s friction factor is given as
4τw
fD = .
K ′′′
With Newtonian fluid,
∂v
τw = µ
∂r r=R
where the contact between fluid and wall is at r = R.
Show that Darcy’s friction factor for laminar flow in a cylindrical pipe is given
as
64
fD =
NRe
where NRe = ρ⟨v⟩D
µ
; see also Exercise 6.1. N
Exercise 6.3. [Solution D.17 p. 585] Blasius’ Darcy friction factor for turbulent
flow.
We have √ ˆ ( ȳ ) (
8 ⟨v⟩ 1
ȳ ) ( ȳ )
= =2 v̄ · 1− d
fD vτ 0 R̄ R̄ R̄
were we assume
( )1/7 ( ȳ )1/7
v̄ = k · R̄ .

Show that
8 1
fD = ( )7/4 1/4
.
98k NRe
120·21/7
N
Exercise 6.4. [Solution D.18 p. 586] Prandtl’s Darcy friction factor for turbulent
flow.
We have √ ˆ ( ȳ ) (
8 ⟨v⟩ 1
ȳ ) ( ȳ )
= =2 v̄ · 1− d
fD vτ 0 R̄ R̄ R̄
were we assume
1
v̄ = ln (ȳ) + C̄.
κ
Show that ( 
√ √ ) ln(10)

1 2·2 2 4κ 2 3 −κC̄

= −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 .

Mass m is hanging in a spring, which has spring constant k, and is affected by


a damper (force Fd ) with damping constant µ. In addition, mass m is affected by
gravity with gravitation constant g, as well as an external force F . The length of
the spring at rest (i.e., without any mass hanging in it) is x0 .
Let v be the velocity of the mass, v = dx/dt = ẋ. Kinetic energy of the mass is
K given as:
1
K = mv 2 .
2
6.18. PROBLEMS* 337

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

Problem 6.5. [Solution E.13 p. 597] Water pump system.

We consider a process as displayed in Fig. 6.48.


The process consists of a pump which pumps liquid from a dam, through a pipe
of length L, and into a vessel. The deliverance pressure from the pump is p, and
the volumetric flow through the pump is V̇i .
Assume that the density of the liquid is constant and equal to ρ. The accumu-
lated liquid mass in the pipe is mp , which is constant. The cross sectional area of
the pipe is Ap . During the transport of liquid through the pipe, a friction force Ff
works on the liquid from the pipe wall.
The cross sectional area of the vessel is A, and the liquid level is h. The volu-
metric flow V̇i flows into the vessel, while the flow V̇e flows out of the vessel.

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 .

3. Assume that the pump characteristics is given as


( )
∆p = p − pa = u c1 − c2 V̇i 2

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 according to the expression

u = us + Kp (hr − h)

where us is such that u ≥ 0. Explain why it makes sense to require Kp > 0,


and insert the controller law in the total model (hr is a set point/reference
value for h, i.e., a desired value for h). N

Solve the following problem using OpenModelica and/or Python.

Problem 6.6. [Solution E.14 p. 599] Simulation of water pump system.

The system that is considered in Problem 6.5, can be modeled as follows:


dh 1( )
= V̇i − V̇e
dt A
dV̇i Ap
= (Ap · ∆p − Ff )
dt mp

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.

## entrance level/flow from tank to flume — steady state, Cornelius’ idea N


340 CHAPTER 6. MOMENTUM BALANCE

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*

7.1 Learning goals


After working through this chapter, the following concepts should be mastered.

• Energy conservation in closed and isolated systems. The difference between


accumulation terms and flow terms.

• Energy conservation in open systems. Total energy.

• Internal energy, work rate and heat flow.

• Pressure work rate, volume work rate, and friction work rate.

• Heat flow by conduction, radiation and convection. Heat transfer.

• The thermal energy balance. Internal energy vs. enthalpy.

• Basic thermodynamics, computation of enthalpy and internal energy for pure


substances. Ideal solutions. Heat exchangers.

• Practical formulation and solution of dynamic models through examples.

7.2 Energy balance for closed and isolated sys-


tems
So far, we have studied the use of mass conservation (total mass balance), species
balances, and the momentum balance. These balances are typically used to com-
pute level (total mass balance for liquid) or density (total mass balance for gas),
concentrations or partial pressures (species balances), and velocity (momentum bal-
ance). Often it is also of interest to find the temperature of a system. To find the
temperature, we typically use the energy balance.
The First Law of Thermodynamics for a closed system, i.e., for a system under
material description, states that

∆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

We recall that if we set Q̇ ≡ 0, we have the mechanical energy balance as stated


in Eq. 6.1 p. 223. It is useful to reflect on what is new in the energy balance as
stated in the first law of thermodynamics, as compared to the mechanical energy
balance.
First, the total energy E — as in the mechanical energy balance — includes
kinetic energy K, and may include potential energy P if conservative power terms
are moved out of the power term Ẇ (work rate) and included as a potential in the
total energy E. However, the total energy may also include other energy terms, such
as internal energy, surface energy, electric and magnetic energy, etc.
The work rate Ẇ includes non-conservative work and possibly conservative work
that has not been included in potential energy. Thus work rate Ẇ includes mechan-
ical work as in the mechanical energy balance, except terms that are converted into
internal energy. However, because the total energy E also includes energy from
other regimes, Ẇ will also include electro-mechanical power, etc.
Heat flow Q̇ is a novelty in the more general energy balance of the first law of
thermodynamics, as compared to the mechanical energy balance. Heat flow is essen-
tially work rate, but at the particle/molecular level. If molecules in the surrounding
part of the system boundary oscillate around a mean position and invoke some os-
cillation in the system part of the system boundary, this is known as heat transfer
by conduction, which could be denoted Q̇c . Similarly, conduction may include some
diffusion at the molecular level. Typically, heat flow by conduction is related to the
thermal gradient of the matter, Q̇c ∝ ∂T ∂x
,3 and heat flows from a higher temperature
to a lower temperature.
Work rate into the system by motion of charged particles through matter, pro-
duces electromagnetic radiation. The result is known as heat flow by radiation,
Q̇r . Typically, heat flow by radiation is related to the fourth power of the absolute
temperature, Q̇r ∝ T 4 .

7.3 Energy balance for open systems


Often, the spatial description is more useful than the material description. In the
spatial description, the control volume is fixed in size and spatial position, and we
must allow for influent and effluent mass flow. In some cases, we will also allow for
the system volume to change if this change is not accompanied by a change of mass.
In the case of the energy balance, we must thus include terms for the transport of
energy via mass flows. Such transport of energy will be denoted Ė, hence in the
spatial description, the energy balance becomes

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.

7.4 Internal energy


If we consider an amount of material consisting of a large number N of particles,
kinetic energy can be written as

N
1
K= mj vj2 ,
j=1
2

where mj is the mass of particle j, while vj is the velocity of particle j. In practice,


it is impossible to keep track of the velocity of every single particle, and we must
operate with a mean velocity v defined as
∑N
j=1 mj vj
v= ,
m
4
Convective: according to Landrø & Wangensteen (1986), the term convective comes from the
Latin word convehere, which means “carry together”. More precisely: the verb with infinitive tense
vehere has the present tense veho in first person singular, and the form vecto in perfect participle
first person singular. The verb means to carry, to lead, (to pull, to draw, to drive); to transport,
to haul, to freight; to bring along, see Kaggerud & Tosterud (1998) (form: veho). The preposition
cum means with, and as a prefix, cum is changed to con. In other words: convehere means to carry
with, to freight with, to drive with, to transport with. It is thus reasonable to interpret convection
such that it means something that is carried by something else. In a sum: convective energy is the
energy which is carried by the mass or by the movement of mass.
In some fields, the term advection is used instead of convection. The preposition ad means
to. Thus, advection means to carry something to a place. Advection is thus used if we want to
emphasize where something is carried, while convection is more used when we want to emphasize
by what something is carried. Example: we have advection through a bio-film, but we have
convection by means of water. (Expert help from Latin maestra Eliana Zamprogna is appreciated.
Any misunderstandings are due to this author.)
5
Accumulate: from Latin ad cumulus, where ad = to, and cumulus = heap, pile, mass; but also
addition, growth, increase. Thus, ad cumulus means something that goes to the pile, something
that goes to increase an amount.
6
In some literature, dE/dt is described as accumulation (of energy), but it is more correct
to describe dE/dt as the rate of accumulation. More correctly, dE is the accumulated energy,
alternatively E − E0 is the accumulated energy where E0 is some reference energy level.
7.4. INTERNAL ENERGY 345

where the total mass m is



N
m= mj .
j=1

Defining the kinetic energy of the mass center, ⟨K⟩, as


1
⟨K⟩ = mv 2 ,
2
we have K − ⟨K⟩ given as


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

where Pj is the potential energy of individual particles. Potential energy is even


more complex than kinetic energy, in that each particle may interact with every
other particle. Imagine potential energy caused by tiny relocations of particles, e.g.,
as in ∑
chemical reactions, etc. Suppose we consider spring-like potential energies,
Pj = ℓ̸=j 12 kjℓ (yjℓ − yj,0 )2 . We thus have


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:

Ėi = K̇i + Ṗi + U̇i


Ėe = K̇e + Ṗe + U̇e .

7.5 Work rate


In the mechanical energy balance, energy was set equal to kinetic energy plus po-
tential energy — where the latter represented the mechanical power added to the
system by conservative forces such as gravity, etc. In this chapter, we have used
symbols E and W to represent total energy and total mechanical power, respec-
tively. Thus, let us use symbols Em , K + P for total mechanical energy, and Ẇm
for mechanical power so that the mechanical energy balance can be written

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.

Example 7.1. Friction power in shock damper.


7.5. WORK RATE 347

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,

where µ ≥ 0. It follows that the energy balance is


dEm
= −µv 2 ,
dt
or
dEm
= Ẇf
dt
where the friction power is Ẇf
Ẇf = −µv 2 .
Here, two things must be observed:

1. The friction power Ẇf is negative, causing the mechanical energy to decrease
over time.

2. The friction power can not disappear; it has to go somewhere.

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

This volume-internal compression work is converted to a change in internal energy,


and when summing mechanical and internal energy balances, the term will sum to
zero.
Next, external power Ẇv used to change the system volume can be expressed as

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 .

7.6 Heat flow


7.6.1 Overview
As stated above, heat flow Q̇ is composed of heat conduction and heat radiation.
These energy flows are not caused by moving mass. Heat conduction is typically a
result of temperature gradients (∂T /∂x in one dimension, and ∇T more generally),
and works in such a way that temperature differences are reduced. Heat radiation
is typically proportional to the fourth power of absolute temperature, T 4 .
In some literature, heat convection is also presented as heat flow. Because the
term convection implies the movement of mass, this term is in some respect a mis-
nomer: “heat” is not moved by mass flow. Instead, heat convection is really a
combination of heat conduction (Q̇c ) and energy convection due to mass movement
(Ė) caused by density variation due to temperature changes.

7.6.2 Continuous phase


A simple, one dimensional model is to describe the conductive heat flux Q̇′′c [ener-
gy/(time area)] as
∂T
Q̇′′c = −k ,
∂x
7.6. HEAT FLOW 349

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.

The heat flux is given by

∂T k
Q̇′′c = −k = (T0 − T1 ) ,
∂x δ
and is thus independent of position x through the slab.

7.6.3 Phase boundary


Figure 7.2 illustrates the mechanism of heat convection.
Throughout the fluid (i.e., in the y direction), temperature/heat flow varies
continuously. Specifically, this is true at the wall/boundary layer and boundary
layer/bulk interfaces. Due to variations in fluid density near the wall, the fluid
moves in a thin boundary layer, providing convective energy flow (Ė) across the
boundary layer. Then in a (hypothetically) uniformly moving bulk volume7 , the
temperature settles to a homogeneous temperature.
7
...possibly a stagnant bulk volume
7.6. HEAT FLOW 351

Table 7.2: Approximate value of some heat transfer coefficients. Data taken from
Geankoplis (1993), p. 219. [ ]
Mechanism Range of values h mW 2K

Condensing steam 5700 – 28000


Condensing organics 1100 – 2800
Boiling liquids 1700 – 28000
Moving water 280 – 17000
Moving hydrocarbons 55 – 1700
Still air 2.8 – 23
Moving air 11.3 – 55

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

NNu = F (NRe , NPr , L/D, µb /µw ) (7.6)

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.

7.6.4 Overall heat transfer


In real systems, we often have several layers of solid material and may as well have
fluid layers in between, e.g., Fig. 7.3.
We will assume that the layers between fluids with bulk temperatures Tb,1 and
Tb,2 are in steady state. Furthermore, we will initially assume that the fluid of thick-
ness δ3 is completely stagnant so that it can be described by pure heat conduction.
7.6. HEAT FLOW 353

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

Continuing with this insertion leads to


( ( ) ) ( )
′′ δ4 1 ′′ δ3 δ4 1
Q̇s = T2 − Tb,2 −
+
+ Q̇s ⇒ T2 = Tb,2 +
+
+ + Q̇′′s ,
k4 h2 k3 k4 h2
etc., until finally
( ( ) )
δ1 δ2 δ3 δ4 1
Q̇′′s = h1 Tb,1 − Tb,2 − + + + + Q̇′′s
k1 k2 k3 k4 h2

1
Q̇′′s = 1 δ1 δ2 δ3 δ4 1
(Tb,1 − Tb,2 ) .
h1
+ k1
+ k2
+ k3
+ k4
+ h2

We can now define an overall heat transfer coefficient U by8


Q̇′′s , U (Tb,1 − Tb,2 )
which implies that in our example,
1
U= 1 δ1 δ2 δ3 δ4 1
h1
+ k1
+ k2
+ k3
+ k4
+ h2

1 1 δ1 δ2 δ3 δ4 1 ∑ 1 ∑ δj 2 4
= + + + + + = + .
U h1 k1 k2 k3 k4 h2 h
j=1 j
k
j=1 j

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

We see that in generally, we have

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.

7.7 Thermal energy balance


7.7.1 Overview of Thermal energy balance
By combining the total energy balance in Eq. 7.2,
dE
= Ėi − Ėe + Ẇ + Q̇,
dt
with the mechanical energy balance in Eq. 7.3, a “Thermal energy balance” can be
developed as
d
U = Ḣi − Ḣe − Ẇf − Ẇv + Q̇. (7.17)
dt
Here, Ḣ = U̇ +pV̇ is enthalpy flow rate, Ẇf ≤ 0 is friction dissipation9 and Ẇv = p dV
dt
is the work rate reduction by increasing the system volume. The Thermal energy
9
...thus −Ẇf ≥ 0 and heats up the system.
356 CHAPTER 7. ENERGY BALANCE*

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.

7.7.2 Development of Thermal energy balance+


The total energy balance has been stated as
dE
= Ėi − Ėe + Ẇ + Q̇.
dt
In Section 7.5, the power Ẇ for the total energy balance was found to consists of
pressure work Ẇp and miscellaneous boundary power Ẇb that does not influence
the internal energy, Ẇ = Ẇp + Ẇb . With mechanical power Ẇm = Ẇp + Ẇf + Ẇc +
Ẇv + Ẇb , it follows that Ẇ = Ẇm − Ẇf − Ẇc − Ẇv . Here, Ẇf ≤ 0 is friction power,
Ẇc is volume-internal compression work, while Ẇv is added mechanical power to
change the system volume.
At the same time, E = Em + U and Ė = Ėm + U̇ . We thus have:
dE
= Ėi − Ėe + Ẇ + Q̇
dt

dEm dU
+ = Ėm,i + U̇i − Ėm,e − U̇e
dt dt
+ Ẇm − Ẇf − Ẇc − Ẇv + Q̇

=0
z( }| ){
dU dEm
= Ėm,i − Ėm,e + Ẇm −
dt dt
+ U̇i − U̇e − Ẇf − Ẇc − Ẇv + Q̇

dU
= U̇i − U̇e − Ẇf − Ẇc − Ẇv + Q̇. (7.18)
dt
The internal energy balance and variations thereof will be denoted thermal energy
balance in the sequel.
For flow in a pipe, we have already seen that typically Ff = K ′′′ Aw f operating
against the movement, thus
1
Ẇf = −Ff v = − ρv 2 |v| Aw f ≤ 0
2
where f is Fanning’s friction factor. If the friction instead is due to dissipation of
power because of agitation in a tank, a typical expression could be

Ẇf = −ρDi5 ṅ3i f ≤ 0


7.7. THERMAL ENERGY BALANCE 357

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

Here, ∇ · v in Eq. 7.19 is the sum of gradients of the velocity coordinates, ∇ · v =


∑ ∂vxi
i ∂xi . For a well mixed volume, it is difficult to use this expression directly,

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

Technically speaking, it is immaterial whether we use the thermal energy balance


in the internal energy form (Eq. 7.18), the mixed form (Eq. 7.23), or in the enthalpy
form (Eq. 7.24) — we should get the same result since they are equivalent. Histori-
cally, perhaps the internal energy form is used more in physics, while the enthalpy
form is used more in chemical engineering.12 In practice, physical parameters may
be more easily available for the enthalpy formulation. In these notes, the mixed
form of Eq. 7.23 will be the preferred form, because it is more suitable for a DAE
description than Eq. 7.24 is.

7.8 Basic thermodynamics


7.8.1 Overview of thermodynamics
Thermodynamic development is rather technical for the un-initiated, so it is useful
to summarize the most important results.
We have already seen that for ideal gas, pressure p, volume V , mole number n
and absolute temperature T are related as

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.

Let F denote a general extensive thermodynamic quantity. Then for an ideal


solution of substances, the total quantity is given as

F = Fj•
j

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̃

with the obvious extensions to Ḟj• . It follows that Ḣ = U̇ − pV̇ .


The following physically measurable thermodynamic quantities are important.
By assuming that specific enthalpy is a function of pressure and temperature only,
Ĥ (T, p),13 specific heat capacity at constant pressure can be expressed as

∂ Ĥ
ĉp = .
∂T
p

∂ H̃
∂T
Similarly, molar heat capacity is c̃p = . Typically, ĉp and c̃p are given as
p
polynomials in temperature, see, e.g., Appendix C.2.
We also need the physically measurable quantities isothermal compressibility βT ,
and the coefficient of thermal expansion αp :
( ) ( ) ( )
1 ∂ Ṽ 1 ∂ V̂ 1 ∂V
βT , − =− =−
Ṽ ∂p V̂ ∂p V ∂p T
( ) T
( ) T
( )
1 ∂ Ṽ 1 ∂ V̂ 1 ∂V
αp , = = .
Ṽ ∂T V̂ ∂Tp
V ∂T p
p

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◦

where H̃ ◦ is the molar enthalpy at a standard state of (T ◦ , p◦ ) — typically, p◦ = 1 atm


while T ◦ = 273.15 K. The expression for specific enthalpy follows in the obvious way.
For ideal, constant density liquid/solid:
ˆ T

dH̃ = c̃p dT + Ṽ dp ⇒ H̃ = H̃ + c̃p dT + Ṽ (p − p◦ ) .
T◦
13
This presumes a pure substance.
7.8. BASIC THERMODYNAMICS 361

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

Ḣj• = ṅj H̃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.

7.8.2 Kinetic theory of ideal gas+


We consider a cube where each side is of length L, thus the volume is V = L3 .
The cube contains N particles, each of mass m̆, moving in three dimensions with
vj,x being the velocity of particle j in the x-direction. For simplicity, we assume
the particles are simple, monatomic particles, hence there is no need to consider
spin/rotation of the particles.
The momentum balance in the x-direction for particle j hitting the y-z wall at
time t is

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

dmxj = m̆vj,x − m̆ (−vj,x ) = 2m̆vj,x ;

this collision takes place in a time interval dt = t+ − t− .


The instantaneous force Fjx is an impulse for the infinitesimal short collision time
dt. We are rather interested in the average force F̄jx in the interval between each
collision, where particle j bounces back and forth within volume V . Traveling a
length 2L between each time the particle hits the same wall in the y-z plane, the
average time interval between each hit is ∆tj given as

2L
∆tj = .
vj,x
362 CHAPTER 7. ENERGY BALANCE*

It follows that

dmxj = Fjx dt = F̄jx ∆tj



2L
2m̆vj,x = F̄jx
vj,x

2
m̆vj,x
F̄jx = .
L
This force, F̄jx , is the average force that particle j exerts on the wall over time.

The total force from all particles in the x-direction is Fx = N x
j=1 F̄j , hence

=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

where kB = 1.3806488(13) × 10−23 J/K is Boltzmann’s constant and m̆ is the mass


of a particle. It follows that

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*

The above discussion gives an introduction to the relationship between tem-


perature and the internal energy of particles, and develops the ideal gas law in
simple way. Statistical mechanics takes a similar approach of treating matter as a
collection of particles (Peters 2005), (Billing & Mikkelsen 1996). A modern, compu-
tational approach approximates theoretical statistical mechanics and kinetic theory
with computer simulation of a large number of particles, based on the momentum
balance/Newton’s law (Frenkel & Smit 2001), (Haile 1997).

7.8.3 Fundamental thermodynamic relations+


7.8.3.1 Postulates
So far, we have considered internal energy U , and we have briefly looked into equa-
tions of state. Thermodynamics can be introduced in a variety of ways. A simple and
elegant way of introducing equilibrium thermodynamics, is the so-called axiomatic
thermodynamics which starts by stating 4 axioms or postulates,14 and from these
postulates build the entire theory using relatively simple calculus, Callen (1985).
The following postulates are proposed:

Postulate I. There exist particular states (equilibrium states) of simple systems,


that are completely described by internal energy U , volume V , and the mole
numbers n1 , ..., nns of the ns substances of the system.

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 means that if S (α) is


∑the entropy of subsystem α, then the total entropy for
the entire system is S = α S (α) . Note that one subsystem could be the gas phase
volume of a mixture, while another subsystem could be the liquid phase volume of
a mixture. However, if we have a mixture of substances A and B, then we can not
separate this mixture into two hypothetical volumes and talk about a pure volume
of A as one of the subsystems — this is not what is meant by subsystem.
14
An axiom or postulate is a statement that is taken to be true, to serve as a premise or starting
point for further reasoning and arguments. Thus, axioms/postulates are not to be proved.
7.8. BASIC THERMODYNAMICS 365

Furthermore we have that


( )
∂S
> 0.
∂U V,n1 ,...,nns

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

This state is the zero temperature state.

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.

7.8.3.2 Alternative fundamental relations


The following partial derivatives are defined for function U (S, V, n1 , . . . , nns ):
( )
∂U
T ,
∂S V,nj
( )
∂U
p,−
∂V S,nj
( )
∂U
µj ,
∂nj S,V,nk̸=j

where T is absolute temperature, p is pressure, and µj is electrochemical potential


of substance j. It follows that T , p and µj are functions of the same arguments as
U , in other words: of S, V , nj .
From this, it follows that we could, e.g., solve T (S, V, . . . nj , . . .) = T wrt. S to
get S = S (T, V, . . . nj , . . . ) and eliminate S in the function for internal energy, i.e.,
write
U = U1 (T, V, . . . , nj , . . .) .
This is certainly possible, but the functional form of U (·) would be different for the
functional form of U1 (·). What is more important, is that while U (S, V, . . . , nj , . . .)
contains all possible thermodynamic information about the system, function U1 (T, V, . . . nj , . . .)
does not contain the same information! Essentially, since T is a partial derivative
of U wrt. S, some integration constant information has been lost. This means that
we can not change the arguments of function U (·) without loosing information.
366 CHAPTER 7. ENERGY BALANCE*

Table 7.3: Interpretation of partial derivatives of thermodynamic quantities.


Partial derivatives of fundamental
( ) quantities
( )
( ∂A ) ( ∂G )
S = − ∂T V,nj = − ∂T p,nj V = ∂p ∂H
= ∂G
∂p
( ∂H ) ( ∂U ) ( ∂A )S,nj ( ∂UT,n
)j
T = ∂S p,nj = ∂S V,nj p = − ∂V T,nj = − ∂V S,nj
( ) ( ) ( ) ( )
∂H ∂A ∂G ∂U
µj = ∂nj = ∂nj = ∂nj = ∂n j
S,p,nk̸=j T,V,nk̸=j T,p,nk̸=j S,V,nk̸=j

However, by introducing some transformation trick15 , it can be shown that if we


insist on using T , V and . . . , nj , . . . as arguments, we can define a new quantity, the
Helmholtz free energy A, as
A , U − TS
and then

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

where H is enthalpy and G is Gibb’s free energy, where both

H = H (S, p, . . . , nj , . . .)
G = G (T, p, . . . , nj , . . .)

contain all thermodynamic information about the system.


In the development, the following partial derivatives are used, Table 7.3.
See Callen (1985) for a readable treatment.
In summary, relations U (S, V, . . . , nj , . . .), H (S, p, . . . , nj , . . .), G (T, p, . . . , nj , . . .)
and A (T, V, . . . , nj , . . .) are fundamental relations and hold complete thermody-
namic information — if we know the relations. However, we can also choose other
arguments, e.g., U (T, V, . . . , nj , . . .) or H (T, p, . . . , nj , . . .), but then we only have
incomplete thermodynamic information.

7.8.3.3 Molar relations


Extensive quantities vary linearly with mass or mole number. It then follows from
the so-called Euler Theorem (Modell & Reid 1983) that an extensive quantity F
which is a function of an extensive quantity ε, an intensive quantity ι, and the
extensive mole numbers nj , satisfies

F (ε, ι, . . . , nj , . . .) = n · F̃ (ε̃, ι, . . . , xj , . . .) (7.30)


15
Using the Legendre transform
7.8. BASIC THERMODYNAMICS 367

where n = j nj , xj = nj /n, and F̃ and ε̃ are molar quantities. This means that
( )
U (S, V, . . . , nj , . . .) = n · Ũ S̃, Ṽ , . . . , xj , . . .
( )
A (T, V, . . . , nj , . . .) = n · Ã T, Ṽ , . . . , xj , . . .
( )
H (S, p, . . . , nj , . . .) = n · H̃ S̃, p, . . . , xj , . . .
G (T, p, . . . , nj , . . .) = n · G̃ (T, p, . . . , xj , . . .) .

It follows that

à = Ũ − T S̃
H̃ = Ũ + pṼ
G̃ = Ũ − T S̃ + pṼ = Ã + pṼ = H̃ − T S̃.

7.8.3.4 Physically measurable thermodynamic relations


In practice, it is easier to measure functions of temperature and pressure than
functions of volume, or entropy. Thus, Gibb’s free energy is important, since
G (T, p, . . . , nj , . . .) is a fundamental relation. We can, of course, also express, e.g.,
H (T, p, . . . , nj , . . .), but this would not be a fundamental relation, and thus contains
less information.
To this end, we can measure molar heat capacity at constant pressure, c̃p , as well
as isothermal compressibility βT , and the coefficient of thermal expansion αp . These
pure substance quantities are related to thermodynamic properties as follows:
( ) ( )
∂ S̃ T ∂S
c̃p , T = (7.31)
∂T n ∂T p
p
( ) ( ) ( )
1 ∂ Ṽ 1 ∂ V̂ 1 ∂V
βT , − =− =− (7.32)
Ṽ ∂p V̂ ∂p V ∂p T
( ) T ( ) T
( )
1 ∂ Ṽ 1 ∂ V̂ 1 ∂V
αp , = = , (7.33)
Ṽ ∂T p V̂ ∂T p V ∂T p

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 .

7.8.3.5 Expressions for G̃, S̃, H̃ and Ũ


Let us illustrate the use of c̃p , βT and αp for computing Gibb’s free energy. Before
doing so, we need some second-order partial derivative expressions.
368 CHAPTER 7. ENERGY BALANCE*

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)

With molar entropy a function of temperature and pressure, S̃ (T, p) (not a


fundamental relation!), we have

( ) ( )
∂ 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◦

Thus, we finally find G̃ as


ˆ T ˆ p

G̃ = G̃ − S̃dT + Ṽ dp. (7.37)
T◦ p◦

(In a )similar manner, we can express non-fundamental relations for H̃ (T, p) and
Ũ T, Ṽ as

dH̃ = c̃p dT + Ṽ (1 − αp T ) dp (7.38)


( )
∂p
dŨ = c̃v dT + T − p dṼ (7.39)
∂T Ṽ

and it can be shown that c̃v and c̃p are related as

αp2
c̃p − c̃v = Ṽ · T. (7.40)
βT

7.8.3.6 Subsystem equilibrium. Non equilibrium


Using standard calculus to maximize entropy S (U, V, . . . , nj , . . .) for a system com-
posed of subsystems α and β (e.g., liquid and gas phases, or two immiscible liquid
phases), leads to the thermodynamic equilibrium conditions:

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)

where G̃◦j (T ) is molar Gibb’s free energy at a standard state.


For transport across phase boundaries, it is quite common to use a so-called “two
film approach”, where equilibrium conditions are assumed on the interphase. Next,
the transport between the “bulk” of the phase and the interphase itself is given by
Q̇′′b2i ∝ T (b) − T (i) , Fb2i ∝ pb − pi and ṅj,b2i ∝ µj − µj where index b indicates the
(b) (i)

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

7.8.3.7 Reaction equilibrium


As in Section 5.9.3, assume a single reaction16

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

where aj is the activity of species j ∈ {B, C, R, S}.


At equilibrium, r = 0, and we have

0 = r = k+ abB acC − k− arR asS



k+ ar as
K, = bR cS (7.45)
k− aB aC
where K is the equilibrium constant, the equilibrium ratio between the forward
reaction rate k+ and the backwards reaction rate k− .
When considering a chemical reaction, the change in molar Gibb’s free energy is
given as ∑
G̃ = −S̃dT + Ṽ dp + µj dnj .
j
17
The change dnj due to the reaction is given as

dnj = V νj rdt

leading to ( )

G̃ = −S̃dT + Ṽ dp + νj µ j V rdt.
j

At equilibrium with fixed T and p, it follows that



νj µj ≡ 0. (7.46)
j

Inserting Eq. 7.41, we thus have


∑ ∑
νj G̃◦j + νj RT · ln aj = 0. (7.47)
j j

In general, we can define a molar thermodynamic quantity of reaction as



∆r F̃ , νj F̃j .
j

As an example, the standard state molar Gibb’s free energy of reaction, ∆r G̃◦ , is

∆r G̃◦ , νj G̃◦j ,
j

and we can rewrite Eq. 7.47 into


( )
∆r G̃◦ ∏ ν
exp − = aj j . (7.48)
RT 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*

For the example above, we have:

∆r G̃◦ = r · G̃◦R + s · G̃◦S − b · G̃◦B − c · G̃◦C


∏ ν ar as
aj j = bR cS = K.
j
aB aC

The equilibrium constant of the reaction, K, is then defined as

∆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

∆r H̃ = r · H̃R + s · H̃S − b · H̃B − c · H̃C .

Because we have k+ = k− · K where K is given by thermodynamic equilibrium


considerations, k+ and k− can not be chosen independently. Thus, if we find k−
from theoretical considerations on reaction kinetics, or from experimental data, k+
needs to be computed as k+ = k− · K in order to be correct at equilibrium.
We will return to some discussion of reaction equilibrium. See, e.g., Modell &
Reid (1983) and ? for more information from a thermodynamic and a reaction
engineering perspective, respectively.

7.8.4 Practical thermodynamics+


7.8.4.1 Core quantities in general Equations of State
We have previously seen that energy forms (E, K, P, U, H) as well as mass (m),
volume (V ) and momentum (m) are extensive variables since their numeric value
increases linearly with the extension of the system. We have also seen that density
(ρ) and concentrations (ρj , cj ) as well as material fraction (ωj , xj ), pressure (p) and
temperature (T ) are intensive variables since their numeric value is independent of
the system extension.
7.8. BASIC THERMODYNAMICS 373

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

but for homogeneous system volumes this simplifies to

U = mÛ
H = mĤ.

Similarly, we find

U̇ = ṁÛ
Ḣ = ṁĤ.

Here, Û and Ĥ are intensive variables.


We can also introduce the intensive molar internal energy Ũ and molar enthalpy
H̃ such that
ˆ

U = Ũ dn = nŨ
ˆn

H = H̃dn = nH̃
n


where = is taken to denote “equal when the system is perfectly well mixed”. Simi-
larly, we have

U̇ = ṅŨ
Ḣ = ṅH̃.

Here, it is clear that M · Ĥ = H̃ and M · Û = Ũ where M is the molar mass.


Hence, what is said about H̃ is also valid for Ĥ with the appropriate modification,
and similarly for Û and Ũ . Regarding molar enthalpy H̃, in the one substance
case, this can be expressed as a function of temperature T and pressure p, thus
H̃ = H̃ (T, p). If we fix the pressure, H̃ (T, p) will typically look as in Fig. 7.4.
If we assume that there is no phase change, the differential of H̃ can be given as
in Eq. 7.38, and similarly for other quantities.
If a phase change is involved, we need to include the relevant enthalpy of phase
change, e.g., vaporization or melting, see Fig. 7.4 p. 374. Enthalpies for vaporization
and melting are given in Table C.3.
374 CHAPTER 7. ENERGY BALANCE*

Figure 7.4: Variation of molar enthalpy H̃ (T, p◦ ) with temperature T ; pressure p◦


is assumed fixed at a standard pressure. If the substance normally is in the liquid
phase, the molar enthalpy at some reference point (T ◦ , p◦ ) is H̃ (T ◦ , p◦ ) which equals
the molar enthalpy of formation ∆H̃f◦ for the liquid phase. If there is a phase change
at some temperature (e.g., T ◦ or T1 ), the molar enthalpy increases with the molar
enthalpy of vaporization, ∆H̃v — which depends on the temperature.

7.8.4.2 Enthalpy and internal energy in mixtures


The general mixture We have seen that for single species volumes18 , we have
that enthalpy H is given as
H = mĤ = nH̃ (7.51)
where

Ĥ = Ĥ (T, p)
H̃ = H̃ (T, p) .

How do we express the enthalpy of a mixture of ns species? For mixture, we find


that Eq. 7.51 is still valid with

ns
m= mj
j=1

ns
n= nj ,
j=1

but we need to express the specific and molar enthalpies as

Ĥ = Ĥ (T, p, ω1 , . . . , ωns )
H̃ = H̃ (T, p, x1 , . . . , xns )

where ωj and xj are the


∑nmass fraction
∑ns and the molar fraction, respectively. It should
s
be remembered that j=1 ωj = j=1 xj = 1.
18
Including a single “pseudo-species”, e.g., air.
7.8. BASIC THERMODYNAMICS 375

Equivalent for
Ideal Solution

Mixed volume Hypothetically


separated/layered
volumes

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*

Assuming an ideal solution, we thus have


Hj• = mj Ĥj• = nj H̃j• ,
and we can express
( )
Ĥj• (T, p) ⇒ dĤj• (T, p) = ĉ•p,j dT + V̂j• 1 − αp,j

T dp
( )
H̃j• (T, p) ⇒ dH̃j• (T, p) = c̃•p,j dT + Ṽj• 1 − αp,j

T dp.

Assuming ideal gas or ideal solution, we can compute αp,j and thus H̃j• as in
Table 7.6 p. 380.

7.8.4.3 Expressions for c̃p , βT , αp and c̃v


The molar heat capacity c̃p is often given as a polynomial in absolute temperature.
As an example, Poling et al. (2001) gives dimensionless molar heat capacity c̃Rp as a
temperature expansion,
c̃p
= a0 + a1 T + a2 T 2 + a3 T 3 + a4 T 4
R
for 468 pure substances, where c̃Rp is the dimensionless ratio of the molar heat ca-
pacity and the ideal gas constant, R = 8.31 molJ K . If needed, from c̃p we can easily
compute ĉp as
ĉp = c̃p M
where M is the molar mass. See Table C.1 in Appendix C.2 for molar mass and
molar heat capacity data for selected species.
It may be of interest to compare this dimensionless molar heat capacity expansion
ĉp (T )
R
with the theoretical expressions for ideal gas given in Eq. 7.29 p. 363, where
we observe that
c̃ig
p c̃ig + R c̃ig
= v = v + 1.
R R R
c̃ig
Figure 7.6 shows c̃pR(T ) vs. Rp for some gases.
As indicated, we can compute isothermal compressibility βT , and the coefficient
of thermal expansion αp by knowing the Equation of State relating p, V and T . In
the case of gases, we can assume ideal gas, or any of the more realistic non-ideal
gas models in Section 4.5. For liquids, we can assume that the molar volume Ṽ is
constant and independent of T and p. Table 7.8.4.3 summarizes results for ideal gas
and constant density liquid.
Sometimes we may need to take into account the dependence of Ṽ on T and p for
liquids. We can then either uses the cubic non-ideal gas models which lead to three
roots Ṽ where one is for liquid, Section 4.5, or we can use some special correlations
for the molar volume of liquids.
The Tait equation is a simple, explicit correlation for the density of liquids; Hoang
et al. (2015) proposes a corresponding state formulation which can be re-phrased as

Ṽ p+B
= 1 − C · ln ,
Ṽ0 p0 + B
7.8. BASIC THERMODYNAMICS 377

Dimensionless molar heat capacity vs. temperature


5

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.

Table 7.5: Isothermal compressibility βT , coefficient of thermal expansion αp , and


difference c̃p − c̃v for ideal gas and for constant density liquid (“ideal liquid”).
Ideal gas Ideal liquid Reference
1
βT p
0 Examples 7.2 p. 379, 7.3 p. 380
1
αp T
0 Examples 7.2 p. 379, 7.3 p. 380
c̃p − c̃v R 0 Examples 7.4 p. 380, 7.5 p. 380
378 CHAPTER 7. ENERGY BALANCE*

where Ṽ is molar volume, p is pressure, and C and B are temperature functions;


subscript 0 indicates a reference point. It follows that the isothermal compressibility
is ( )
1 ∂ Ṽ Ṽ0 /Ṽ
βT = − =C .
Ṽ ∂p p0 + B
T
At the reference point,
C
βT,0 = ⇒ C = βT,0 (p0 + B) ,
p0 + B
and the Tait equation can be rewritten as
Ṽ p+B
= 1 − βT,0 (p0 + B) · ln .
Ṽ0 p0 + B

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

where xj = nj /n is the mole fraction of substance j.


From the above, it follows that the isothermal compressibility is
( )
1 ∂ Ṽ Ṽ0
βT = − = βT,0 . (7.55)
Ṽ ∂p Ṽ
T
7.8. BASIC THERMODYNAMICS 379

Likewise, the coefficient of thermal expansion can be evaluated from


( )
1 ∂ Ṽ
αp = ;
Ṽ ∂T p
this leads to a rather complex expression, though.
Water is a very important liquid.20 Unfortunately, water is hardly “weakly po-
lar”, so the above expressions probably lead to a poor model. In Fine & Millero
(1975), the following correlation for specific volume V̂ is proposed:21
V̂ p̄ − p̄1 atm
=1−
V̂ 0 B + A1 (p̄ − p̄1 atm ) + A2 (p̄ − p̄1 atm )2
1 B − A2 (p̄ − p̄1 atm )2
βT = ·[ 2 ]2
,

V̂ 0 B + A1 (p̄ − p̄ 1 atm ) + A2 (p̄ − p̄ 1 atm )
where
p
p̄ =
pς1 bar
p1 atm
p̄1 atm = ,
pς1 bar
and where p1 atm is a pressure equivalent to 1 atm in the chosen pressure unit, while
pς1 bar is a scaling pressure equivalent to 1 bar in the chosen unit. The unit atmosphere
specific volume, V̂ ◦ , as well as the other temperature θ ({θ} = ◦ C) dependent
parameters B, A1 and A2 are given as
1 + 18.159725 × 10−3 θ
V̂ 0 (θ) =
c (θ)
c (θ) = 0.9998396 + 18.224944 × 10−3 θ − 7.92221 × 10−6 θ2
− 55.44846 × 10−9 θ3 + 149.7562 × 10−12 θ4 − 393.2952 × 10−15 θ5
B (θ) = 19654.32 + 147.037θ − 2.21554θ2 + 1.0478 × 10−2 θ3 − 2.2789 × 10−5 θ4
A1 (θ) = 3.2891 − 2.391 × 10−3 θ + 2.8446 × 10−4 θ2 − 2.82 × 10−5 θ3 + 8.477 × 10−9 θ4
A2 (θ) = 6.24 × 10−5 − 3.913 × 10−6 θ − 3.499 × 10−8 θ2 + 7.942 × 10−10 θ3 − 3.299 × 10−12 θ4 .
{ }
Here, V̂ = kg L
, and {θ} = ◦ C.
Example 7.2. Ideal gas βT and αp
In the case of ideal gas, we have pV = nRT ⇒ Ṽ = RTp
. It follows that
( ) ( )
1 ∂ Ṽ 1 RT RT 1 1
βT = − =− − 2 = · =
Ṽ ∂p Ṽ p pṼ p p
( ) T
1 ∂ Ṽ 1R 1 RT 1 1
αp = = = = .
Ṽ ∂T p Ṽ p Ṽ p T T
20
The isothermal compressibility factor βT is important in high pressure hydro power systems
where the compressibility of water is taken into account for the pressure shaft.
21
The expression below is changed from specific to molar volume, and with dimensionless pres-
sures.
380 CHAPTER 7. ENERGY BALANCE*

Table 7.6: Molar enthalpy and internal energy with arguments


(T, p) for ideal gas

and for constant density liquid (“ideal liquid). F̃ − F̃ ◦ implies constant heat ca-
c
pacity.
Ideal gas Ideal liquid Reference
´T ´T
H̃ − H̃ ◦ T◦ p
c̃ dT c̃ dT + Ṽ (p − p◦ )
T◦ p
Exs. 7.6–7.7, p. 381–381

H̃ − H̃ c̃p (T − T ◦ ) c̃p (T − T ◦ ) + Ṽ (p − p◦ ) Exs. 7.6–7.7, p. 381–381
c ´T ´T
Ũ − Ũ ◦ T◦
(c̃p − R) dT c̃ dT
T◦ p
Exs. 7.8–7.9, p. 381–381

Ũ − Ũ ◦ (c̃p − R) (T − T ◦ ) c̃p (T − T ◦ ) Exs. 7.8–7.9, p. 381–381
c

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.

7.8.4.4 Expressions for H̃ and Ũ


Expressions for H̃ and Ũ as functions of (T, p) for ideal gas and constant density
liquid (“ideal liquid”) are summarized in Table 7.6. These expressions are developed
through examples.
Similar expressions for molar entropy S̃ and molar Gibb’s free energy G̃ of ideal
gas and ideal liquid are discussed in Problems 7.1 p. 460 – 7.4 p. 461.
7.8. BASIC THERMODYNAMICS 381

Example 7.6. Ideal gas molar enthalpy

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◦

If the heat capacity is independent of temperature, then

H̃ (T, p) = H̃ (T ◦ , p◦ ) + c̃p (T − T ◦ ) .

Example 7.7. Constant density liquid molar enthalpy

For constant density liquid, αp = 0, thus


ˆ T
◦ ◦
dH̃ = c̃p dT + Ṽ dp ⇒ H̃ (T, p) = H̃ (T , p ) + c̃p dT + Ṽ (p − p◦ ) .
T◦

If the heat capacity is independent of temperature, then

H̃ (T, p) = H̃ (T ◦ , p◦ ) + c̃p (T − T ◦ ) + Ṽ (p − p◦ ) .

Example 7.8. Ideal gas molar internal energy


( ∂p )
We need to compute ∂T Ṽ
. For ideal gas, we have
( ) ( ( ))
∂p ∂ RT R RT 1 p
= = = · = .
∂T Ṽ ∂T Ṽ Ṽ Ṽ Ṽ T T

∂p
It follows that T ∂T Ṽ
− p = T · Tp − p = 0, hence
( ) ( ) ˆ T
◦ ◦
dŨ = c̃v dT = (c̃p − R) dT ⇒ Ũ T, Ṽ = Ũ T , Ṽ + (c̃p − R) dT.
T◦

If the heat capacity is independent of temperature, we find


( ) ( )
Ũ T, Ṽ = Ũ T ◦ , Ṽ ◦ + (c̃p − R) (T − T ◦ ) .

Example 7.9. Constant density liquid molar internal energy

For constant density liquid, Ṽ is constant, so Ũ can not depend on Ṽ . It follows


that
( ) ( ) ˆ T

dŨ = c̃v dT = c̃p dT ⇒ Ũ T, Ṽ = Ũ T , Ṽ + c̃p dT.
T◦
382 CHAPTER 7. ENERGY BALANCE*

If the heat capacity is independent of temperature, then


( ) ( )
Ũ T, Ṽ = Ũ T ◦ , Ṽ + c̃p (T − T ◦ ) .

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)

Taking the total differential on each side leads to d (ab) = 0, or


( ) ( )
0 = 3pṼ − 2 (RT + bp) Ṽ + a dṼ + Ṽ
2 2
Ṽ − b dp − RṼ 2 dT . (7.57)

We now have two possibilities:


( ) we can either consider H̃ (T, p) with dH̃ = c̃p dT +
( ∂p )
Ṽ (1 − αp T ) dp, or Ũ T, Ṽ with dŨ = c̃v dT + T ∂T − p dṼ . As we will see, it

is actually simpler to operate with Ũ when we have
( a )cubic EoS.
First, we consider dH̃, where we need αp = Ṽ ∂∂TṼ . Thus, from Eq. 7.57 with
1
p
constant pressure, dp = 0, and letting dṼ → ∂ Ṽ and dT → ∂T :
( )
0 = 3pṼ − 2 (RT + bp) Ṽ + a ∂ Ṽ − RṼ 2 ∂T
2


( )
∂ Ṽ 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

constant molar volume, dṼ = 0, and letting dp → ∂p and dT → ∂T :


=0
→∂p →∂T
( ) z}|{ ( ) z}|{ z}|{
0 = 3pṼ − 2 (RT + bp) Ṽ + a dṼ + Ṽ Ṽ − b dp − RṼ dT
2 2 2


( )
∂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*

If we still want to find H̃, we have H̃ = Ũ + pṼ . Of course, if we actually know


(T, p), we need to compute Ṽ by solving the cubic equation in Eq. 7.56. But ( the)
expressions for Ũ and H̃ are reasonably simple. And if we happen to know T, Ṽ
the above formalism via Ũ is very simple. The alternative, to find H̃ when knowing
(T, p) at the outset, is very complicated. ( )
Here, we have developed H̃ (T, p) and Ũ T, Ṽ , and we have seen that with a
( )
cubic EoS, it is easier to operate with independent variables T, Ṽ . Neither H̃ (T, p)
( ) ( )
nor Ũ T, Ṽ are fundamental relations, so operating with G̃ (T, p) or à T, Ṽ
would actually give more information. And because cubic EoSs are so common in
practice, it is easier to develop the relation for Helmholz’ free energy Ã.
The development for other cubic Equations of State will be even more com-
plicated than for the van der Waals EoS, since for those, a and b will depend on
temperature.

7.8.4.5 Expressions for activity


Following Smith et al. (1996), for gases with standard state being pure gas at atmo-
spheric pressure p◦ , the activity can be expressed as
pj
aj = ϕj (7.59)
p◦
where pj is the partial pressure of the substance while ϕj is the so-called fugacity co-
efficient of substance j in the mixture. For hypothetically pure species, the fugacity
coefficient is given as ˆ p
dp
ln ϕj = (zj − 1) (7.60)
0 p
where p is the pressure and zj is the pure species compressibility factor. For ideal
gas, zj ≡ 1 ⇒ ln ϕj = 0, thus ϕj = 1 ⇒ aj = p◦j , where p◦ is 1 atm in the chosen
p

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◦

which for constant molar volume leads to


( )

Ṽ (p − p )
a•j = exp .
RT

Unless pressure p is extremely high, a•j ≈ 1.


7.8. BASIC THERMODYNAMICS 385

If the liquid mixture constitutes an ideal solution, then the activity coefficient is
γj = 1, thus for reasonable pressures,

aj = xj a•j ≈ xj .

However, liquids are often not ideal solutions.


If the mixture is non-ideal, then for high concentration species j, we still have
aj = xj . However, for low concentration species j, typically the activity is a ratio of
the molality 22 of the low concentration species and the molality of the pure species,
i.e.,
nj nj
mS mS Mj nj
aj ≈ n◦ = 1 = ≈ ωj
j
◦ M j
m S
mj

where Mj is the molar mass of substance j, nj is the number of moles of species j,


mS is the mass of solvent, and ωj is the mass fraction of species j.

7.8.4.6 Quantities of formation


So far, we have assumed that the molar quantities F̃j◦ are known in the standard
state, e.g., that H̃j◦ , Ũj◦ , G̃◦j , etc., are known. The standard state is defined as
a pure substance at a specified pressure but with unspecified temperature, thus
F̃j◦ is a function of temperature, F̃j◦ (T ). For gases, the standard state pressure is
p◦ = 1 atm. For liquids, the standard state is also often given at pressure p◦ = 1 atm,
but not always.
Even though the standard state does not specify the temperature, data are nor-
mally given at a specified temperature. Because specifying the temperature is a
restriction on the standard state, we will denote a standard state with specified
temperature by F̃T◦◦ ,j . Quite often, the data are specified at T ◦ = 298.15 K = 25 ◦ C;

for simplicity we will denote this by F̃298,j .
In order to find H̃, we need H̃ . Similarly, in order to find Ũ , we need Ũ ◦ . To

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


∆f F̃j , F̃j − ηi F̃εi . (7.64)
i=1

This definition of ∆f F̃j is valid in any state.


From Eq. 7.63, it follows that the quantities of formation are related as

∆f G̃j = ∆f H̃j − T · ∆f S̃j , (7.65)

which is valid in any state, also in the standard state.

Example 7.10. Molar thermodynamic quantity of formation.

To clarify this idea, consider two examples: j = NO (nitric oxide)


( 1 1 )and j = NO2
(nitrogen dioxide). For j = NO, εNO = (N2 , O2 ) while ηNO = 2 , 2 : the stable
elements are N2 and O2 (listed in εNO ) while their numbers are 12 ( 21 N2 = N) and 12
( 21 O2 = O), (numbers listed in ηNO ). Thus,

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.

Example 7.11. Practical computation with molar quantities of formation.

Consider the following reaction example:

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*

find ∆f G̃1j bar and then G̃1298,j


bar
to be

∆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

7.8.4.7 Reaction equilibrium


Referring to the “standard” reaction in Eq. 7.42 with reaction rate as in Eq. 7.44 and
reaction equilibrium constant as in Eq. 7.45, it is of interest to relate the activities
to quantities in the balance equations.
For gas, we have seen that the activities can be written as
pj
aj = ϕj
p◦
where pj is the partial pressure in a chosen unit, computed from some Equation of
State, p◦ is the standard pressure of 1 atm in the chosen unit, while the fugacity
coefficient ϕj is computed from Eq. 7.62 in combination with a chosen EoS. For
ideal gas, ϕj ≡ 1, thus with p̄j being dimensionless pressure scaled with atmospheric
pressure, the reaction rate is

r = k+ (p̄B )b (p̄C )c − k− (p̄R )r (p̄S )s

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 Ṽ .

If the pressure term is negligible, the temperature dependence of the equilibrium


constant is the same for liquid as for gas.

Example 7.14. Equilibrium constants in Nitrogen-Oxygen reactions.

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:

∆r G̃◦1 = 2 · G̃◦298,NO2 − 2 · G̃◦298,NO − ∆G̃◦298,O2


( ) ( )
= 2 · 51.31 − 32.618 × 10−3 − 2 · 86.55 − 32.618 × 10−3
= −70.48 kJ mol−1
( ) ( )
∆r G̃◦2 = G̃◦298,N2 O4 − 2 · G̃◦298,NO2 = 97.89 − 32.618 × 10−3 − 2 · 51.31 − 32.618 × 10−3
= −4.697 4 kJ mol−1 .

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

7.9 Distributed heat exchangers


7.9.1 Overview with heat exchanger configurations
Figure 7.7 depicts a generic distributed tube and shell heat exchanger.
Many heat exchanger configurations exist. A typical one involves flow of fluid
inside a tube, and flow of another fluid outside of the tube, on the so-called shell side.
With tube-and-shell heat exchangers, it is common to distinguish between cross-
current, co-current, and counter-current heat exchangers. Other heat exchangers
involve a heat exchanger fluid in a thin jacket outside of a tank, or re-circulation
of a gas (mixture) with condensation caused by a heat exchanger. In this section,
the focus is on tube-and-shell heat exchangers. Figure 7.8 illustrates cross-current,
co-current, and counter-current heat exchanger configurations.
In the following sections, models for the cross-, co- and counter-current heat
exchangers are developed. In all cases, it is assumed that the mass balance is in
steady state for both the shell side and the tube side, hence
dm
= 0 = ṁi − ṁe ⇒ ṁ = ṁi = ṁe .
dt
392 CHAPTER 7. ENERGY BALANCE*

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:

Q̇t2s = UAx ∆Tlm


1,2

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

Figure 7.9: Detailed depiction of cross-current heat exchanger.

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.

3. If the flow-sheet involves resirculation so that one of the input temperatures


is not really known, the use of the logarithmic mean temperature leads to
implicit nonlinear expressions with even more equations — while the direct
solutions then can be posed as linear implicit equations that can be trivially
solved using matrix formulations.

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.

7.9.2 Cross-current heat exchanger+


7.9.2.1 Dynamic model
Details of a cross-current heat exchanger is given in Fig. 7.9.
396 CHAPTER 7. ENERGY BALANCE*

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

Ḣξt = ṁt Ĥξt


t t
Ḣξ+∆x = ṁt Ĥξ+∆x

ξ+∆x = Q̇t2s,ξ+∆x · ∆x.
Q̇t2s
Observe that we have neglected heat diffusion in the x-direction! This leads to
t
dÛξ+∆x
ρt ∆x · At = ṁt Ĥξt − ṁt Ĥξ+∆x
t
− Q̇′t2s,ξ+∆x · ∆x
dt

t
dÛξ+∆x t
Ĥξ+∆x − Ĥξt
ρt At = −ṁt − Q̇′t2s,ξ+∆x .
dt ∆x
This expression is not only valid for x = ξ, but for any x ∈ (0, Lx ),24 leading to
t
∂ Ûx+∆x t
Ĥx+∆x − Ĥxt
ρt At = −ṁt − Q̇′t2s,∆x .
∂t ∆x
By letting ∆x → 0, we find
∂ Ût ∂ Ĥt
= −ṁt
ρt At − Q̇′t2s .
∂t ∂x
With negligible pressure drop and fluid density change, we have approximately
∂ Ût ≈ ĉv,t ∂Tt
∂ Ĥt ≈ ĉp,t ∂Tt ,
leading to
∂Tt ∂Tt
= −ṁt ĉp,t
ρt At ĉv,t − Q̇′t2s .
∂t ∂x
For the shell side, assuming that Ts is independent of x, we get
dUs
= Ḣis − Ḣes + Q̇t2s .
dt
With similar assumptions for U and Ḣ for the shell side as for the tube side, and
integrating the expression for dĤs , we find
dTs
= ṁs ĉp,s (Tis − Tes ) + Q̇t2s .
ρs As ĉv,s
dt
where Tes = Ts in a perfectly stirred volume and
ˆ Lx
Q̇t2s = Q̇′t2s dx. (7.67)
0
24
Lx is the Length of the heat eXchanger.
7.9. DISTRIBUTED HEAT EXCHANGERS 397

7.9.2.2 Steady model


In many cases, the dynamics of the heat exchanger is much faster than that of the
dynamics of interest in the rest of the system. Because of this, it is quite common
to assume that the heat exchanger energy balance is steady, in other words setting
∂Tt ≡ 0 and thus ∂T
∂x
t
→ dT
dx
t
. With Q̇′t2s given as

Q̇′t2s = U℘ (Tt − Tes ) ,


we find
dTt
0 = −ṁt ĉp,t − U℘ (Tt − Tes )
dx

dTt U℘
=− (Tt − Tes ) . (7.68)
dx ṁt ĉp,t

7.9.2.3 Solution of steady model


dTes
We have already assumed that Tes is independent of x such that dx
= 0. Setting
αt ≡ ṁUt ĉ℘p,t , we can rewrite Eq. 7.68 as
dΘt
= −αt Θt ,
dx
where
Θt ≡ Tt − Tes .
If we assume that αt is independent of x, the solution to this equation is
Θt (x) = exp (−αt x) Θt (0) . (7.69)

7.9.2.4 Heat transfer


We can then write Q̇′t2s as
Q̇′t2s (x) = U℘Θt (x) = U℘ exp (−αt x) Θt (0) ,
and we find the total heat transfer using Eq. 7.67 as
ˆ Lx
Q̇t2s = Q̇′t2s dx
0

ˆ Lx
Q̇t2s = U℘ exp (−αt x) Θt (0) dx
0

U℘
Q̇t2s = − [exp (−αt x)]x=Lx
x=0 Θt (0)
αt

U℘
Q̇t2s = [1 − exp (−αt Lx )] Θt (0) . (7.70)
αt
398 CHAPTER 7. ENERGY BALANCE*

Here, we have
U℘ U℘
= U ℘ = ṁt ĉp,t ,
αt ṁ ĉ t p,t

Θt (0) = Tit − Tes ,


U℘Lx
αt Lx = .
ṁt ĉp,t
Introducing the heat transfer area Ax as Ax , ℘Lx , it follows that αt Lx = NSt
t
, the
Stanton number from the tube side of the heat exchanger
[ ( )] ( t )
Q̇t2s = ṁt ĉp,t 1 − exp −NSt
t
Ti − Tes (7.71)
where the tube side Stanton number is
t UAx
NSt = . (7.72)
ṁt ĉp,t

7.9.2.5 Effluent temperatures


Next, we consider the steady thermal energy balance for the shell side:
0 = Ḣis − Ḣes + Q̇t2s
where
Ḣis = ṁs Ĥis
Ḣes = ṁs Ĥes .
We thus get
0 = ṁs Ĥis − ṁs Ĥes + Q̇t2s

( )
0 = ṁs Ĥi − Ĥe + Q̇t2s .
s s

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

7.9.2.6 Computational procedures


The computational procedure for the heat exchanger model depends on the use. As
one example, if we have a tube coil going through a stirred tank where the shell side
is the stirred tank volume, the procedure is typically:
1. The shell side effluent temperature (Tes ) is equal to the tank temperature —
which is a system state.
2. The tube side inlet temperature (Tit ) may be an input to the system.
3. The added heat Q̇t2s to the stirred tank (shell side) is given by Eq. 7.71; this
heat is needed in the energy balance for the stirred tank.
4. If we need to find Tes , this temperature is found from Eq. 7.73.
5. It may not be particularly interesting to compute the tube side effluent tem-
perature (Tet ) using Eq. 7.74 — unless a sensor signal measures this tempera-
ture. With Tet measured, it may be possible to improve the system model by
comparing it with the result from Eq. 7.74.
If none of the involved temperatures are states, we have the general procedure
1. First, compute Tes from Eq. 7.73,
2. Next, compute Q̇t2s from Eq. 7.71.
3. If needed, compute Tet from Eq. 7.74.
Here, we observe the following from Eq. 7.73
lim Tes = Tis .
ṁs →∞

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 →∞

in the case of “large” tube side flow rate.


To recapture: the above results are based on four key assumptions:
1. Ts (and Tes ) are independent of x, which means that the shell side is well mixed
across x. If this is not the case, the model becomes slightly more complicated.
2. αt ≡ ṁUt ĉ℘p,t is independent of x. Assuming that ṁt is independent of x is
realistic. However, the assumption of αt being independent of x breaks down
if the overall heat transfer coefficient U or perimeter ℘ varies with x, or if the
heat capacity ĉp,t varies with x. Clearly, in the realistic case of ĉp,t depending
on Tt , αt will vary with x, and the model will become more complicated.
400 CHAPTER 7. ENERGY BALANCE*

3. Heat diffusion in the x-direction has been neglected.

4. Inertia/dynamics in the heat exchanger has been neglected.

7.9.2.7 Logarithmic mean temperature difference approach


Equation 7.71 can be rewritten as
( )
Q̇t2s UAx ( t )
= Ti − Te − exp −
t s
Ti − Tes .
ṁt ĉp,t ṁt ĉp,t
Combining this expression with the solution in Eq. 7.74, we get

Q̇t2s ( )
= Tit − Tes − Tet − Tes
ṁt ĉp,t

[( ) ( )]
Q̇t2s = ṁt ĉp,t Tit − Tes − Tet − Tes .

From Eq. 7.74 we also have


( )
UAx Tit − Tes
exp =
ṁt ĉp,t Tet − Tes

UAx T t − Tes
= ln it
ṁt ĉp,t Te − Tes

UAx
ṁt ĉp,t = T t −T s .
ln Tit −Tes
e e

Thus, we have
(Tit − Tes ) − (Tet − Tes )
Q̇t2s = UAx T t −T s
.
ln Tit −Tes
e e

By defining

∆Ti = Tit − Tes


∆Te = Tet − Tes ,

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

Figure 7.10: Detailed depiction of co-current heat exchanger.

In order to utilize the logarithmic mean temperature difference expression, we


must first compute Tet by solving the equation
( )
Q̇t2s = ĉp,t ṁt Tit − Tet = ĉp,s ṁs (Tes − Tis ) .

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 .

7.9.3 Co-current heat exchanger+


7.9.3.1 Dynamic model

Details of a co-current heat exchanger is given in Fig. 7.10.


If we assume steady conditions for the mass balance, this leads to ṁti = ṁte =
ṁt (x) = ṁt and likewise ṁsi = ṁse = ṁs (x) = ṁs . When neglecting friction and
volume work, the simplified energy balance becomes

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

Ḣit = ṁt Ĥξt


Ḣet = ṁt Ĥξ+∆x
t

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 .

7.9.3.2 Steady model


It is a common assumption that the heat exchange is fast compared to the reac-
tor dynamics, and that we can assume steady state for the heat exchanger. This
assumption leads to the steady model

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

7.9.3.3 Solution of steady model


Introducing

U℘
αt ,
ĉp,t ṁt
U℘
αs , ,
ĉp,s ṁs

we have ( ) ( )( )
d Tt −αt αt Tt
= ,
dx Ts αs −αs Ts
| {z }
A

with boundary conditions

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

At x = Lx we have Tt (x = Lx ) = Tet and Ts (x = Lx ) = Tes , thus Eqs. 7.76–7.77 give

1 [( −(αs +αt )Lx ) ( ) ]


Tet = αt e + αs Tit + αt − αt e−(αs +αt )Lx Tis (7.78)
αt + αs
1 [( ) ( ) ]
Tes = αs − αs e−(αs +αt )Lx Tit + αt + αs e−(αs +αt )Lx Tis . (7.79)
α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*

7.9.3.4 Heat transfer


Using Eqs. 7.76–7.77, we find the following expression for Tt − Ts after some ma-
nipulation:
( )
Tt − Ts = e−(αs +αt )x Tit − Tis .
We can thus find the total transfer of heat as
ˆ Lx ˆ Lx ˆ

Lx ( )
Q̇t2s = Q̇t2s dx = U℘ (Tt − Ts ) dx = U℘e−(αs +αt )x Tit − Tis dx
0 0 0

ˆ [ ]x=Lx
( ) Lx
−(αs +αt )x
( ) 1
Q̇t2s = U℘ Tit − Tes e dx = U℘ Tit − Tis e−(αs +αt )x
0 − (αs + αt ) x=0

U℘ ( t )[ ]
Q̇t2s = Ti − Tis e−(αs +αt )Lx − 1
− (αs + αt )

[ ]
1 − e−(αs +αt )Lx (Tit − Tis )
Q̇t2s = UAx . (7.84)
(αs + αt ) Lx
Inserting the expression for αt and αs , we get
1 [ ]( )
−(NSt
s +N t
)
Q̇t2s = 1 1 − e St Ti
t
− Ti
s
. (7.85)
ĉp,s ṁs
+ ĉp,t1ṁt

7.9.3.5 Logarithmic mean temperature approach


From the expression for Tt − Ts , it follows that
( )
Tet − Tes = e−(αs +αt )Lx Tit − Tis

T t − Tis
(αs + αt ) Lx = ln it .
Te − Tes
We can thus rewrite the expression for Q̇t2s into the form
(Tit − Tis ) − e−(αs +αt )Lx (Tit − Tis )
Q̇t2s = UAx
(αs + αt ) Lx

(T t − Tis ) − (Tet − Tes )
Q̇t2s = UAx i T t −T s
.
ln Tit −Tis
e e

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

Figure 7.11: Detailed depiction of counter-current heat exchanger.

7.9.4 Counter-current heat exchanger+


7.9.4.1 Dynamic model
Details of a counter-current heat exchanger is given in Fig. 7.11.
If we assume steady conditions for the mass balance, this leads to ṁti = ṁte =
ṁt (x) = ṁt and likewise ṁsi = ṁse = ṁs (x) = ṁs . When neglecting friction and
volume work, the simplified energy balance becomes
dU
= Ḣi − Ḣe + Q̇.
dt
With perfect mixing in the volume defined by x ∈ [ξ, ξ + ∆x], the tube flow volume
has
Ḣit = ṁt Ĥξt
Ḣet = ṁt Ĥξ+∆x
t

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*

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 negative x-direction and that the heat
flow Q̇′t2s enters the shell volume. The boundary conditions are Tt (x = 0) = Tit and
Ts (x = Lx ) = Tis .

7.9.4.2 Steady model


It is a common assumption that the heat exchange is fast compared to the reac-
tor dynamics, and that we can assume steady state for the heat exchanger. This
assumption leads to the steady model
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.4.3 Solution of steady model


Introducing
U℘
αt ,
ĉp,t ṁt
U℘
αs , ,
ĉp,s ṁs
we have ( ) ( )( )
d Tt −αt αt Tt
= .
dx Ts −αs αs Ts
| {z }
A
Problem 8.2 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 Tes (7.86)
αt − αs
1 [( (αs −αt )x ) ( ) ]
Ts (x) = αs e − αs Tit + αt − αs e(αs −αt )x Tes . (7.87)
αt − αs
At x = Lx we have Tt (x = Lx ) = Tet and Ts (x = Lx ) = Tis , thus
1 [( (αs −αt )Lx ) ( ) ]
Tet = αt e − αs Tit + αt − αt e(αs −αt )Lx Tes (7.88)
αt − αs
1 [( (αs −αt )Lx ) ( ) ]
Tis = αs e − αs Tit + αt − αs e(αs −αt )Lx Tes . (7.89)
αt − αs
7.9. DISTRIBUTED HEAT EXCHANGERS 407

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

Alternatively, if we want explicit expressions, Eq. 406 leads to


( (α −α )L ) t
(αt − αs ) Te
t
− α t e s t x
− α s Ti
Tes =
αt (1 − e (α s −α t )L x )

while Eq. 406 leads to


( )
(αt − αs ) Tis − αs e(αs −αt )Lx − 1 Tit
Tes = .
(αt − αs e(αs −αt )Lx )

Equating these two expressions leads to


( ) ( )
(αt − αs ) Tet − αt e(αs −αt )Lx − αs Tit (αt − αs ) Tis − αs e(αs −αt )Lx − 1 Tit
= ,
αt (1 − e(αs −αt )Lx ) (αt − αs e(αs −αt )Lx )

which can be solved to yield


( )
t αt 1 − e(αs −αt )Lx Tis + (αt − αs ) e(αs −αt )Lx Tit
Te = .
αt − αs e(αs −αt )Lx
408 CHAPTER 7. ENERGY BALANCE*

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

7.9.4.4 Heat transfer


Using Eqs. 7.86–7.87, we find the following expression for Tt − Ts after some ma-
nipulation:
( )
Tt − Ts = e(αs −αt )x Tit − Tes .
We can thus find the total transfer of heat as
ˆ Lx ˆ Lx ˆ

Lx ( )
Q̇t2s = Q̇t2s dx = U℘ (Tt − Ts ) dx = U℘e(αs −αt )x Tit − Tes dx
0 0 0

ˆ [ ]x=Lx
( ) Lx
(αs −αt )x
( ) 1
Q̇t2s = U℘ Tit − Tes e dx = U℘ Tit − Tes e(αs −αt )x
0 αs − αt x=0

U℘ ( t )[ ]
Q̇t2s = Ti − Tes e(αs −αt )Lx − 1
αs − αt

[ (α −α )L ]
e s t x − 1 (Tit − Tes )
Q̇t2s = UAx . (7.90)
(αs − αt ) Lx

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

After some manipulation, we find


[ (α −α )L ]
e s t x − 1 (αt − αs ) (Tit − Tis )
Q̇t2s = UAx
[αt − αs e(αs −αt )Lx ] (αs − αt ) Lx

[ ]
UAx e(αs −αt )Lx − 1 ( t )
Q̇t2s = T − T s
(7.91)
[αs e s t x − αt ] Lx
(α −α )L i i

Inserting the expression for αt and αs , we get

e(NSt −NSt ) − 1 ( )
s t

Q̇t2s = Tit − Tis . (7.92)


e(NSt −NSt ) −
s t
1 1
ĉp,s ṁs ĉp,t ṁt

7.9.4.5 Logarithmic mean temperature difference approach


From the expression for Tt − Ts , it follows that
( )
Tet − Tis = e(αs −αt )Lx Tit − Tes

Tet − Tis
(αs − αt ) Lx = ln t .
Ti − Tes

We can thus rewrite the expression for Q̇t2s into the form

e(αs −αt )Lx (Tit − Tes ) − (Tit − Tes )


Q̇t2s = UAx
(αs − αt ) Lx

(Tet − Tis ) − (Tit − Tes )
Q̇t2s = UAx T t −T s
.
ln Tet −Tis
i e

Thus, with

∆T1 = Tet − Tis


∆T2 = Tit − Tes ,

we have
Q̇t2s = UAx ∆Tlm
1,2
.
Again, it is much simpler to use the explicit expression in Eq. 7.92 directly.

7.9.5 Final comments


In the heat exchanger models developed in preceding sections, the metal separating
the tube and the shell has been included in the overall heat transfer coefficient U.
Because of the high heat conductivity of metals, this is normally acceptable. If the
dynamics of the heat exchanger is important, including the accumulation of internal
energy in the metal, there is no problem in keeping the dynamic model of the system:
410 CHAPTER 7. ENERGY BALANCE*

System boundary

Figure 7.12: Sketch of ideally stirred tank with heating.

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.

7.10 Case: Heated liquid tank


7.10.1 Model objective
We consider an open liquid tank of constant cross sectional area A, with influent
mass flow rate ṁi at temperature Ti , and effluent mass flow rate ṁe driven by gravity.
The liquid volume is heated by some device such that the heat flow per level h, Q̇′ ,
is given. See Fig. 7.12. We seek the level h of the tank and the temperature T of
the tank, and how these vary with ṁi , Ti , Q̇′ , and effluent valve opening υ.
The model objective is described by the functional diagram in Fig. 7.13.

7.10.2 Model development


We assume constant density ρ, and constant cross sectional area A. We neglect
the air within the system volume, and the constant liquid mass in the exit pipe
(before the valve). Possible ripples in the level are neglected; the level is assumed
7.10. CASE: HEATED LIQUID TANK 411

Heated liquid
tank

Figure 7.13: Functional diagram of heated liquid tank.

to be h across A. Kinetic and potential energy is neglected. We assume a low


viscosity liquid, and neglect the friction work. We assume that the heat capacity ĉp
is independent of temperature.

Step 1: We need the total mass balance


dm
= ṁi − ṁe
dt
as well as the thermal energy balance
dU
= Ḣi − Ḣe + Ẇf + Ẇv + Q̇.
dt

Step 2: In general,

m = ρV
V = Ah.

Due to gravity driven effluent, we have



h
ṁe = Ke υ

where hς is some scaling level.
Internal energy is given as
U = mĤ − pV
where
ˆ T

Ĥ = Ĥ + ĉp (T ) dT + V̂ (p − p◦ )
T◦

1
Ĥ (T, p) = Ĥ ◦ (T ◦ , p◦ ) + ĉp (T − T ◦ ) + (p − p◦ ) .
ρ
Furthermore,
Ḣ = ṁĤ (T, p)
We have
Ẇf ≡ 0,
412 CHAPTER 7. ENERGY BALANCE*

while
dV p dm −p
Ẇv = −p =− = (ṁi − ṁe ) .
dt ρ dt ρ
Finally,
Q̇ = Q̇′ · h.

Step 3: The model can be compiled as follows:


dm
= ṁi − ṁe
dt
dU
= Ḣi − Ḣe + Ẇv + Q̇
dt
m = ρV
V = Ah

h
ṁe = Ke υ

U = mĤ − pV
1
Ĥ (T, p) = Ĥ ◦ (T ◦ , p◦ ) + ĉp (T − T ◦ ) + (p − p◦ )
ρ
Ḣi = ṁi Ĥ (Ti , pa )
Ḣe = ṁe Ĥ (T, p)
−p
Ẇv = (ṁi − ṁe )
ρ
Q̇ = Q̇′ · h.

Finally, we set
p = pa + ρgh.

We can write the model in DAE form


dx
= f (x, z, u; θ)
dt
0 = g (x, z, u; θ)

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

Table 7.7: Parameters for heated liquid tank.


Parameter Value Unit Comment
ρ 1 kg/L Density of liquid
A 5 dm2 Constant cross sectional area
Ke 2 kg/s Valve constant
hς 3 dm Level scaling

Ĥ 0 J/kg Standard state specific enthalpy
ĉp 4.2 × 103 J
kg K
Specific heat capacity of liquid
T◦ 298.15 K Standard state temperature
p◦ 1.01 × 105 Pa Standard state pressure
pa 1.01 × 105 Pa Ambient pressure
g 9.81 m/s2 Acceleration of gravity

Table 7.8: Operating conditions for heated liquid tank.


Quantity Value Unit Comment
h (0) 1.5 dm Initial level
m (0) ρh (0) A kg Initial mass (alternative initial condition)
T (0) 293.15 K Initial temperature in liquid
p (0) pa Pa Initial pressure
◦ ◦
Ĥ (0) Ĥ + ĉp (T (0) − T ) J/kg Initial specific enthalpy

+ ρ (p (0) − p )
1

U (0) m (0) Ĥ (0) − p (0) m(0)


ρ
J Initial internal energy
ṁi 1 + 0.5H2 s kg/s Nominal influent mass flow rate; may be varied
υ 1 − 0.2H15 s – Valve control signal, typically υ ∈ [0, 1]
Ti 288.15 + 5H10 s K Inlet liquid temperature
Q̇′ 105 H5 s W
m
Heat flow per unit length

7.10.3 Model summary


The model can be summarized as in Step 3 and Step 4 of the previous section.
To complete the model description, we need to specify model parameters and
operating conditions. We choose the following parameters for the model, Table 7.7.
The operating conditions (initial state, input) are defined in Table 7.8.
In Table 7.8, Hτ is the Heaviside function.25

7.10.4 Model simulation


Using OpenModelica, the results of simulating the system are as in Figs. 7.14–7.17.
Note that the figures also include the results of the reduced description into an ODE
model as in Section 7.10.5.
25
The Heaviside function Hτ is the unit step function
{
0, t < τ
Hτ (t) = ,
1, t ≥ τ

named after Oliver Heaviside.


414 CHAPTER 7. ENERGY BALANCE*

Heated tank: level


0.26 h
0.24 hode

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.

Heated tank: temperature


24 T
Tode
22

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

Heated tank: mass flor rates + input


1.5
1.4
1.3
1.2
1.1
1.0
mi [kg/s]
0.9 me [kg/s]
0.8 u
0 5 10 15 20 25 30
time t [s]

Figure 7.16: Influent mass flow ṁi [kg/s] (solid red), valve signal υ [–] (solid blue)
and effluent mass flow ṁe [kg/s] (solid green).

Heated tank: heat flux


100

80

60
Q0 [kW/m]

40

20

0
0 5 10 15 20 25 30
time t [s]

Figure 7.17: Heat flow per length, Q̇′ [kW/m].


416 CHAPTER 7. ENERGY BALANCE*

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*

85 Real Hdi " Influent enthalpy flow , J / s ";


86 Real Hde " Effluent enthalpy flow , J / s ";
87 Real Wdv " Volume work , W ";
88 Real Qd " Heat flow , W ";
89 Real V " Liquid volume , m3 ";
90 Real h " Liquid level , m ";
91 Real Hh " Specific enthalpy , J / kg ";
92 Real p " Pressure in heated tank , Pa ";
93 Real T " Absolute temperature in heated tank , K ";
94 Real Hhi " Specific enthalpy of influent , J / kg ";
95 // -- input variables
96 input Real mdi " Influent mass flow rate , kg / s ";
97 input Real u " Input signal to valve , -";
98 input Real Ti " Influent temperature , K ";
99 input Real Qdp " Heat flow per unit length , W / m ";
100 // Equations constituting the model
101 equation
102 // Differential equations
103 der ( m ) = mdi - mde ;
104 der ( U ) = Hdi - Hde + Wdv + Qd ;
105 // Algebraic equations
106 m = rhs * V ;
107 V = A*h;
108 mde = Ke * u * sqrt ( h / hs ) ;
109 U = m * Hh - p * V ;
110 Hhi = Hhdd + chp *( Ti - Tdd ) + ( pa - pdd ) / rhs ;
111 Hdi = mdi * Hhi ;
112 Hh = Hhdd + chp *( T - Tdd ) + (p - pdd ) / rhs ;
113 Hde = mde * Hh ;
114 Wdv = -p *( mdi - mde ) / rhs ;
115 Qd = Qdp * h ;
116 p = pa + rhs * g * h ;
117 end ModHeatedTank ;
118 //
119 model ModHeatedTankODE
120 // ODE Model of Heated liquid Tank
121 // author : Bernt Lie
122 // University of South - Eastern Norway
123 // October 22 , 2015
124 // May 12 , 2017
125 //
126 // Constants
127 constant Real g = 9.81 " Acceleration of gravity , m / s2 ";
128 // Parameters
129 parameter Real rhs = 1 e3 " Liquid density , kg / m3 ";
130 parameter Real A = 1.5 e -2 " Cross sectional area of tank ,
m2 ";
131 parameter Real Ke = 2 " Effluent valve constant , kg / s ";
132 parameter Real hs = 3e -1 " Level scaling , m ";
7.10. CASE: HEATED LIQUID TANK 419

133 parameter Real chp = 4.2 e3 " Specific heat capacity of


liquid , J / kg / K ";
134 // Initial state parameters
135 parameter Real h0 = 1.5 e -1 " Initial liquid level , m ";
136 parameter Real T0 = 293.15 " Initial temperature , K ";
137 // Declaring variables
138 // -- states
139 Real h ( start = h0 , fixed = true ) " Level in tank , m ";
140 Real T ( start = T0 , fixed = true ) " Temperature in tank , K
";
141 // -- input variables
142 input Real mdi " Influent mass flow rate , kg / s ";
143 input Real u " Input signal to valve , -";
144 input Real Ti " Influent temperature , K ";
145 input Real Qdp " Heat flow per unit length , W / m ";
146 // Equations constituting the model
147 equation
148 // Differential equations
149 der ( h ) = ( mdi - Ke * u * sqrt ( h / hs ) ) /( rhs * A ) ;
150 der ( T ) = ( mdi *( chp *( Ti - T ) -g * h ) + Qdp * h ) /( rhs * A * h * chp ) ;
151 end ModHeatedTankODE ;
152 // End package
153 end HeatedTank ;

7.10.5 ODE formulation

7.10.5.1 Model reduction to ODE

It is of interest to reduce the DAE model to an ODE model by keeping h and T as


states. We get

dm
= ṁi − ṁe
dt


d h
(ρAh) = ṁi − Ke υ
dt hς


dh ṁi − Ke υ 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

Thus, the temperature equation finally is


dT
mĉp = ṁi ĉp (Ti − T ) − ṁi gh + Q̇′ h
dt

dT ṁi [ĉp (Ti − T ) − gh] + Q̇′ h
= .
dt ρAhĉp

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 ).

7.10.5.2 Model summary


The model can be summarized as

dh ṁi − Ke υhς
h

=
dt ρA
dT ṁi [ĉp (Ti − T ) − gh] + Q̇′ h
= .
dt ρAhĉp

In the general state space form


dx
= f (x, u; θ)
dt
we have

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.

7.10.6 ODE model simulation


The simulation results are shown in Figs. 7.14–7.17. As these figures show, the
resulting outputs (h, T ) are identical for the two model formulations. Also, notice
422 CHAPTER 7. ENERGY BALANCE*

Figure 7.18: Sketch of gas tank with heating.

Heated gas
tank

Figure 7.19: Functional diagram of 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.

7.11 Case: Heated gas tank


7.11.1 Model objective
We consider a closed gas tank of constant volume V , with influent pressure pi and
temperature Ti driving the influent mass flow rate ṁi due to a pressure difference
over a valve, and a similar mechanism for driving the effluent mass flow rate ṁe to
the ambient pressure pa . The gas volume is heated by some device at heat flow Q̇.
See Fig. 7.18.
We seek the pressure p and temperature T of the gas in the tank.
The model objective is described by the functional diagram in Fig. 7.19.

7.11.2 Model development


Because of the impeller symbol in Fig. 7.18, we will assume a homogeneous tank
volume, i.e., the temperature and pressure is the same everywhere. To simplify the
development, we will assume that the gas can be described as an ideal gas. Finally,
7.11. CASE: HEATED GAS TANK 423

we assume that the flow across the valves can be described by a Bernoulli type
model.

Step 1: We need the total mass balance

dm
= ṁi − ṁe
dt

and the thermal energy balance

dU
= Ḣi − Ḣe + Ẇf + Ẇv + Q̇.
dt

Step 2: In general, the ideal gas law gives

pV = nRT

with
m = nM .

Furthermore, we have

∆pj
ṁj = Kj

where the scaling pressure is pς = pa , and ∆pj is the pressure drop over the
relevant valve.

For ideal gas,


U = mĤ − pV

with
ˆ T
◦ ◦
Ĥ (T, p) = Ĥ (T , p ) + ĉp (T ) dT .
T◦

We will assume that ĉp is constant. Furthermore,

Ḣj = ṁj Ĥj .

For a low viscosity gas, Ẇf ≈ 0. With constant volume, Ẇv = −p dV


dt
= 0. Q̇
is an input.
424 CHAPTER 7. ENERGY BALANCE*

Step 3: The model can be compiled as follows:


dm
= ṁi − ṁe
dt
dU
= Ḣi − Ḣe + Q̇
dt
pV = nRT
m = nM

∆pi
ṁi = Ki


∆pe
ṁe = Ke

∆pi = pi − p
∆pe = p − pa
U = mĤ − pV
Ĥ = Ĥ ◦ + ĉp (T − T ◦ )
Ĥi = Ĥ ◦ + ĉp (Ti − T ◦ )
Ḣi = ṁi Ĥi
Ḣe = ṁe Ĥ.

We can write the model in DAE form


dx
= f (x, z, u; θ)
dt
0 = g (x, z, u; θ)
where
x = (m, U )
( )
z = ṁi , ṁe , Ḣi , Ḣe , p, n, T, ∆pi , ∆pe , Ĥ, Ĥi
( )
u = Q̇, pi , pa , Ti
( )
θ = V, R, M, Ki , pς , Ke , Ĥ ◦ , ĉp , 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.

7.11.3 Model summary


The model can be summarized as in Step 3 and Step 4 of the previous section.
To complete the model description, we need to specify model parameters and
operating conditions. We choose the following parameters for the model, Table 7.9.
The operating conditions (initial state, input) are defined in Table 7.10.
In Table 7.10, Hτ is the Heaviside function.
7.11. CASE: HEATED GAS TANK 425

Table 7.9: Parameters for heated gas tank.


Parameter Value Unit Comment
−3
V 50 × 10 m3 Volume of tank
J
R 8.31 mol K
Universal gas constant
M 28 g/mol Molar mass for Nitrogen
Ki 3 g/s Inlet valve constant
pa 1.03 × 105 Pa Ambient pressure
pς = pa Pa Scaling pressure
Ke 3 g/s Outlet valve constant
Ĥ ◦ 0 J/g The standard state specific enthalpy can
be set to zero for non-reacting cases
J
ĉp 1 gK
Specific heat capacity at constant pressure
of air
T◦ 298.15 K Typical standard temperature

Table 7.10: Operating conditions for heated gas tank.


Quantity Value Unit Comment
p (0) 1.2pa Pa Initial pressure of tank
T (0) 293.15 K Initial temperature of tank
p(0)V
m (0) RT (0)
M g Initial mass (alternative)
Ĥ (0) Ĥ ◦ + ĉp (T (0) − T ◦ ) J/g Initial specific enthalpy
U (0) m (0) Ĥ (0) − p (0) V J Initial internal energy
Q̇ (t) 200H120 s W Heating power
pi (t) 10pς − 2pς H180 s Pa Inlet tank pressure
pa (t) 1.03 × 10 5
Pa Ambient (atmospheric) pressure
Ti (t) 313.15 − 10H240 s K Influent temperature
426 CHAPTER 7. ENERGY BALANCE*

Heated gas tank: temperatures


360
T
350 Ti

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).

7.11.4 Model simulation


Using OpenModelica, the results of simulating this system are as shown in Figs.
7.20–7.22.
In Figs. 7.20–7.21, the initial transient up to time 120 s is entirely due to the
system not starting in steady state, i.e., it is due to the initial conditions.
The following Modelica code (file HeatedGasTank.mo) describes the system with
operations. Notice that the ambient pressure pa has not been changed in the simu-
lation setup.

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

Heated gas tank: pressures


1000000 p
pi
800000

600000
[Pa]

400000

200000

0 50 100 150 200 250 300 350 400


time t [s]

Figure 7.21: Pressure p [Pa] in heated gas tank (red) and influent gas pressure pi
[Pa] (blue).

Heated gas tank: heat flow


200
175
150
125
Q [W]

100
75
50
25
0
0 50 100 150 200 250 300 350 400
time t [s]

Figure 7.22: Added heat flow Q̇ [W] to gas tank.


428 CHAPTER 7. ENERGY BALANCE*

19 Real _Qd " Added heat flow to gas tank , W ";


20 Real _pi " Influent gas pressure , Pa ";
21 Real _pa " Ambient pressure , Pa ";
22 Real _Ti " Influent gas temperature , K ";
23 // -- outputs
24 output Real _p " Tank pressure , P ";
25 output Real _T " Heated tank temperature , K ";
26 // Equations
27 equation
28 // -- input values
29 _Qd = if time < 120 then 0 else 2 e2 ;
30 _pi = if time < 180 then 10* hgt . ps else 8* hgt . ps ;
31 _pa = hgt . ps ;
32 _Ti = if time < 240 then 313.15 else 303.15;
33 // -- injecting input functions to model inputs
34 hgt . Qd = _Qd ;
35 hgt . pi = _pi ;
36 hgt . pa = _pa ;
37 hgt . Ti = _Ti ;
38 // -- outputs
39 _p = hgt . p ;
40 _T = hgt . T ;
41 end SimHeatedGasTank ;
42 //
43 model ModHeatedGasTank
44 // Model of Heated gas Tank
45 // author : Bernt Lie
46 // University of South - Eastern Norway
47 // October 26 , 2015
48 // May 12 , 2017
49 //
50 // Constants
51 constant Real R = 8.31 " Ideal gas constant , J .K -1. mol -1";
52 // Parameters
53 parameter Real V = 50 e -3 " Gas tank volume , m3 ";
54 parameter Real M = 28 " Molar mass of gas , g . mol -1";
55 parameter Real Ki = 3 " Influent valve constant , g / s ";
56 parameter Real ps = 1.03 e5 " Scaling pressure , Pa ";
57 parameter Real Ke = 3 " Effluent valve constant , g / s ";
58 parameter Real Hhdd = 0 " Standard state specific enthalpy
, J / g ";
59 parameter Real chp = 1 " Specific heat capacity at
constant pressure , J .g -1. K -1";
60 parameter Real Tdd = 298.15 " Standard state temperature ,
K ";
61 // Initial state parameters
62 parameter Real p0 = 1.2* ps " Initial gas pressure , Pa ";
63 parameter Real T0 = 293.15 " Initial temperature , K ";
64 parameter Real m0 = p0 * V * M /( R * T0 ) " Initial mass , g ";
7.11. CASE: HEATED GAS TANK 429

65 parameter Real Hh0 = Hhdd + chp *( T0 - Tdd ) " Initial


specific enthalpy , J / g ";
66 parameter Real U0 = m0 * Hh0 - p0 * V " Initial internal
energy , J ";
67 // Declaring variables
68 // -- states
69 Real m ( start = m0 , fixed = true ) " Mass in gas tank , kg ";
70 Real U ( start = U0 , fixed = true ) " Internal energy in gas
tank , J ";
71 // -- auxiliary variables
72 Real mdi " Influent mass flow rate , g / s ";
73 Real mde " Effluent mass flow rate , g / s ";
74 Real Hdi " Influent enthalpy flow , J / s ";
75 Real Hde " Effluent enthalpy flow , J / s ";
76 Real p " Pressure in heated gas tank , Pa ";
77 Real n " Number of moles in heated gas tank , mol ";
78 Real T " Absolute temperature in heated gas tank , K ";
79 Real dpi " Influent valve pressure drop , Pa ";
80 Real dpe " Effluent valve pressure drop , Pa ";
81 Real Hh " Specific enthalpy in gas tank / of effluent , J / g ";
82 Real Hhi " Specific enthalpy of influent gas , J / g ";
83 // -- input variables
84 input Real Qd " Heat added to gas tank , W ";
85 input Real pi " Influent pressure , Pa ";
86 input Real pa " Ambient pressure , Pa ";
87 input Real Ti " Influent temperature , K ";
88 // Equations constituting the model
89 equation
90 // Differential equations
91 der ( m ) = mdi - mde ;
92 der ( U ) = Hdi - Hde + Qd ;
93 // Algebraic equations
94 p*V = n*R*T;
95 m = n*M;
96 mdi = Ki * sqrt ( dpi / ps ) ;
97 mde = Ke * sqrt ( dpe / ps ) ;
98 dpi = pi - p ;
99 dpe = p - pa ;
100 U = m * Hh - p * V ;
101 Hh = Hhdd + chp *( T - Tdd ) ;
102 Hhi = Hhdd + chp *( Ti - Tdd ) ;
103 Hdi = mdi * Hhi ;
104 Hde = mde * Hh ;
105 end ModHeatedGasTank ;
106 // End package
107 end HeatedGasTank ;
430 CHAPTER 7. ENERGY BALANCE*

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

Figure 7.24: Functional diagram of metal rod.

7.12 Case: Heat diffusion in metal rod

7.12.1 Model objective

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

7.12.2 Model development


We assume that the metal rod temperature T only varies with time t and vertical
position x. The metal density is ρ and its heat conductivity is k. We consider
the interval x ∈ [ξ, ξ + ∆x] of the metal rod, and we assume that this volume is
homogeneous in the intensive variables, with constant density, heat conductivity
and specific enthalpy.

Step 1: In principle, we need the total mass balance. However, if we consider a


fixed system volume with fixed position in space, and neglect density changes
in the solid metal, there is no flow of mass into or out of the system volume.
Then the mass within the system volume will be constant. If the density of
the metal changes, e.g., due to a temperature change, we must either operate
with a system volume that changes in size (so that there is still no mass flow
into or out of the system), or we must operate with a fixed system volume
but take into account mass “flow” due to density changes. Here, we assume
constant density.
We need the thermal energy balance

dU
= Ḣi − Ḣe + Ẇv + Ẇf + Q̇.
dt

Step 2: We neglect expansion of the volume V = A·∆x, thus Ẇv = 0. Furthermore,


there is no movement of matter, thus Ḣ ≡ 0, and Ẇf ≡ 0. Furthermore, we
have
U = H − pV .
Here, both the pressure p and the volume V are constants, and this reduces
to U = H. We can then use
H = mĤ
where
m = ρV .
For the fixed density metal rod,
ˆ T

Ĥ = H + ĉp (T ) dT + V̂ (p − p◦ ) ,
T◦

where both terms H ◦ and V̂ (p − p◦ ) are constant.


We assume that Fourier’s law applies to heat conduction in homogeneous
metal,
∂T
Q̇′′ = −k .
∂x
Simultaneously, we assume that in a discontinuity in phase such as at x = L
where we go from solid (metal) to gas (air), we have

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.

The specific enthalpy is


1
Ĥξ+∆x = H ◦ +ĉp (Tξ+∆x − T ◦ )+V̂ (pξ+∆x − p◦ ) = H ◦ +ĉp (Tξ+∆x − T ◦ )+ (pξ+∆x − p◦ )
ρ
where we set

H◦ = 0
pξ+∆x = p◦ ,

thus
Ĥξ+∆x = ĉp (Tξ+∆x − T ◦ ) .
The heat flow is given by

Q̇ξ+∆x = Q̇ξ − Q̇ξ+∆x

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

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
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:

dUξ+∆x (t) ∂Ux+∆x (t, x)


→ .
dt ∂t

Thus we get
∂Ux+∆x (t, x)
= Q̇x+∆x (7.93)
∂t
where

Ux+∆x = mĤx+∆x (7.94)


m = ρV (7.95)
V = A · ∆x (7.96)
Ĥx+∆x = ĉp (Tx+∆x − T ◦ ) (7.97)
( )
′′ ′′
Q̇x+∆x = Q̇x − Q̇x+∆x A (7.98)

∂T
Q̇′′x = −k (7.99)
∂x x

′′ ∂T
Q̇x+∆x = −k . (7.100)
∂x x+∆x

We could insert the expressions into the energy balance to get

∂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

∂Tx+∆x 1 Q̇′′x+∆x − Q̇′′x


ĉp =−
∂t ρ ∆x

∂Tx+∆x 1 Q̇′′x+∆x − Q̇′′x
=−
∂t ρĉp ∆x

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

is one of the boundary conditions. Furthermore, the problem description dic-


tates that the air temperature Ta is known. In the phase transition from solid
to air, we have
Q̇′′x=L = h (Tx=L − Ta ) ,
hence we have that Q̇′′ is given at x = L. The boundary conditions are
thus given by Tx=0 and Q̇′′x=L . In summary, with ∆x → 0, the model can be
summarized as for x ∈ (0, L)

∂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)

7.12.3 Model summary


A traditional model summary would consist of the PDE with boundary conditions,
i.e., as in Eqs. 7.101–7.104, with the output described according to Eq. 7.105. How-
ever, we can (currently) not transcribe PDE models in Modelica, and we need to
discretize the model in space and write it as a DAE. A DAE model for a system,
i.e., with inputs and outputs, can often be written in the form
dx
= f (x, z, u; θ)
dt
0 = g (x, z, u; θ)
y = h (x, z, u; θ) .

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*

Ux by Ui·∆x where i = 0 leads to U0 and UN ·∆x leads to UL . To further simplify


the notation, we let Ui·∆x → Ui , and let the slice thickness be implied. The same
goes for the other quantities. We can thus write the model in Eqs. 7.93–7.100 with
i ∈ {1, . . . , N } as
dUi
= Q̇i
dt
Ui = mĤi
m = ρV
V = A · ∆x
Ĥi = ĉp (Ti − T ◦ )
( )
Q̇i = Q̇′′i−1 − Q̇′′i A

′′ ∂T
Q̇i−1 = −k
∂x i−1

∂T
Q̇′′i = −k .
∂x i

We also need to discretize the temperature gradient ∂T


∂x
. Some possible alternatives
∂Ti
for approximating the gradient ∂x are the backward differentiation approximation
∂Ti Ti − Ti−1
≈ ,
∂x ∆x
the forward approximation
∂Ti Ti+1 − Ti

∂x ∆x
or the central approximation
∂Ti Ti+1 − Ti−1
≈ .
∂x 2 · ∆x
Because the diffusion spreads in both directions, it is probably best to use the central
approximation. We need Q̇′′0 to compute Q̇1 and Q̇′′1 to compute Q̇2 , and thus get
T1 − T−1
Q̇′′0 ≈ −k
2 · ∆x
T 2 − T0
Q̇′′1 ≈ −k .
2 · ∆x
Here, T0 = Tp , but we must also set T−1 to Tp . Thus, the boundary condition at
x = 0 leads to
T1 − Tp
Q̇′′0 ≈ −k
2 · ∆x
T 2 − Tp
Q̇′′1 ≈ −k .
2 · ∆x
At x = L, we have heat transfer to the air, hence have
Q̇′′N = h (TN − Ta ) .
7.12. CASE: HEAT DIFFUSION IN METAL ROD 437

The DAE model can thus be summarized i ∈ {1, . . . , N } as ∆x = L


N
with

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.

Finally, the fluxes Q̇′′i are


T1 − Tp
Q̇′′0 ≈ −k
2 · ∆x
T 2 − Tp
Q̇′′1 ≈ −k
2 · ∆x
′′ Ti+1 − Ti−1
Q̇i ≈ −k , i ∈ {2, 3, . . . , N − 1}
2 · ∆x
Q̇′′N = h (TN − Ta ) .

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 .

To complete the model description, we need to specify model parameters and


operating conditions. We choose the following parameters for the model, Table 7.11.
The operating conditions (initial state, input) are defined in Table 7.12.

7.12.4 Model simulation


Using OpenModelica, the results of simulating the system are as in Figs. 7.25–7.28.
The results in Fig. 7.28 indicate that we should choose N ≥ 100 to get a reason-
ably accurate result of the transient behavior of TL .
The following Modelica code (file MetalRod.mo) is used to produce the figures;
simulator model SimMetalRod is used to produce Figs. 7.25–7.27, while simulator
model SimCompareMetalRod is used to produce Fig. 7.28.
438 CHAPTER 7. ENERGY BALANCE*

Table 7.11: Parameters for study of temperature diffusion in metal rod.


Parameter Value Unit Comment
L 4 dm Length of metal rod
2
A 2 dm Cross sectional area
ρ 7.8 kg/L Density of metal rod
N 10 – Number of slices
L
∆x N
dm Slice length
V ∆x · A L Slice volume
m ρ·V kg Slice mass
J
ĉp 450 kg K
Specific heat capacity of metal at constant pressure

T 293.15 K Standard state temperature
W
k 45 mK
Thermal conductivity of metal rod

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

Metal rod diffusion: temperatures


50

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

Metal rod diffusion: heat transfer coefficient


30

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.

Metal rod diffusion: temperature distribution


50
45
40
35
[ C]

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*

Metal rod diffusion: temperature dependence on N


50

45

40
TL, 10 TL, 90 Tp
35
[ C]

TL, 30 TL, 300 Ta


30

25

20
0 5 10 15 20 25 30
time t [min]

Figure 7.28: Temperature TL at end of metal rod as a function of the number of


slices N , and with heated plate temperature Tp and air temperature Ta , all given in
K.

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

26 // -- setting input values


27 _Tp = if time < 100 then 293.15 else 323.15;
28 _Ta = if time < 750 then 293.15 else 298.15;
29 _h = if time < 500 then 3 else 30;
30 // -- injecting inputs to underlying model
31 mr10 . Tp = _Tp ;
32 mr10 . Ta = _Ta ;
33 mr10 . h = _h ;
34 mr30 . Tp = _Tp ;
35 mr30 . Ta = _Ta ;
36 mr30 . h = _h ;
37 mr90 . Tp = _Tp ;
38 mr90 . Ta = _Ta ;
39 mr90 . h = _h ;
40 mr300 . Tp = _Tp ;
41 mr300 . Ta = _Ta ;
42 mr300 . h = _h ;
43 // -- outputs
44 _TL10 = mr10 . T [ mr10 . N ];
45 _TL30 = mr30 . T [ mr30 . N ];
46 _TL90 = mr90 . T [ mr90 . N ];
47 _TL300 = mr300 . T [ mr300 . N ];
48 end SimCompareM et alR od ;
49 //
50 model SimMetalRod
51 // Simulation of Temperature diffusion in metal rod
52 // author : Bernt Lie
53 // University of South - Eastern Norway
54 // October 29 , 2015
55 // May 12 , 2017
56 //
57 // Instantiate model
58 ModMetalRod mr ;
59 // Declaring variables
60 // -- inputs
61 Real _Tp " Temperature of heated plate , K ";
62 Real _Ta " Temperature of air , K ";
63 Real _h " Heat transfer coefficient , J .m -2. K -1";
64 // -- outputs
65 output Real _TL " Temperature of metal rod at x =L , K ";
66 // Equations
67 equation
68 // -- setting input values
69 _Tp = if time < 100 then 293.15 else 323.15;
70 _Ta = if time < 750 then 293.15 else 298.15;
71 _h = if time < 500 then 3 else 30;
72 // -- injecting inputs to underlying model
73 mr . Tp = _Tp ;
74 mr . Ta = _Ta ;
442 CHAPTER 7. ENERGY BALANCE*

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

115 // Equations constituting the model


116 equation
117 // Differential equations
118 der ( U [:]) = Qd [:];
119 // Algebraic equations
120 U [:] = m * Hh [:];
121 Hh [:] = chp *( T [:] - Tdd * oneN [:]) ;
122 Qd [:] = ( Qdpp [1: N ] - Qdpp [2: N +1]) * A ;
123 Qdpp [1] = -k *( T [1] - Tp ) /(2* dx ) ;
124 Qdpp [2] = -k *( T [2] - Tp ) /(2* dx ) ;
125 Qdpp [3: N ] = -k *( T [3: N ] - T [1: N -2]) /(2* dx ) ;
126 Qdpp [ N +1] = h *( T [ N ] - Ta ) ;
127 end ModMetalRod ;
128 // End package
129 end MetalRod ;

7.13 Case: Hot water accumulator⋆


7.13.1 Model objective
7.13.2 Model development
7.13.3 Model summary
7.13.4 Model simulation
...

7.14 Cases: Liquid phase reactor


7.14.1 Model objective
We consider a liquid reactor of constant volume V and constant overall density ρ,
with influent volumetric flow rate V̇ , influent concentration of reactant A given as
cA,i , and influent temperature Ti . It is of interest to convert species A into species B
through an exothermal reaction aA → B. Species A and B are carried through the
reactor by an inert27 solvent S. To keep control of the temperature T , the reactor is
cooled with “heating” rate Q̇ (i.e., Q̇ < 0). The rate of reaction r is assumed to be
given as
r = kcaA
where k is given by the Arrhenius expression
( )
E
k = k0 exp − .
RT
27
Inert implies non-reacting.
444 CHAPTER 7. ENERGY BALANCE*

Figure 7.29: Cooled liquid reactor with reaction aA → B.

Cooled liquid
reactor

Figure 7.30: Functional diagram of 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.

7.14.2 Model development


Because of the impeller symbol in Fig. 7.29, we will assume a homogeneous tank
volume, i.e., the temperature and concentrations are the same everywhere. To
simplify the development, we will assume that species A and B are dissolved in
an inert solvent such that the overall density ρ is constant. We furthermore assume
that the mixture constitutes an ideal solution. Thus, there is no need to model the
mass accumulation of the inert solvent S. Still, we need to know the (constant) mass
mS as well as the flow rates ṁS,i and ṁS,e .
Step 1: We need the species balances for species A and B,
dnj
= ṅj,i − ṅj,e + ṅj,g
dt
and the thermal energy balance
dU
= Ḣi − Ḣe + Ẇf + Ẇv + Q̇.
dt
Step 2: In general, mole and molar concentration are related as
n j = cj V .
7.14. CASES: LIQUID PHASE REACTOR 445

Molar flow rates are given as


ṅj = cj V̇ .
Molar generation rate with a single reaction is given as
ṅj,g = νj rV
where νj is element j of the stoichiometric matrix ν, here given as
( )
ν = −a 1 .

For the liquid,


U = H − pV
where for an ideal solution28

H= Hj•
j

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

H̃A• = H̃A◦ + c̃•p,A (T − T ◦ )


H̃B• = H̃B◦ + c̃•p,B (T − T ◦ )
ĤS• = ĤS◦ + ĉ•p,S (T − T ◦ )

• • •
Ḣ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• .

We can write the model in DAE form


dx
= f (x, z, u; θ)
dt
0 = g (x, z, u; θ)

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.

7.14.3 Model summary


The model can be summarized as in Step 3 and Step 4 of the previous section.
To complete the model description, we need to specify model parameters and
operating conditions. We choose the following parameters for the model, Table 7.13.
The operating conditions (initial state, input) are defined in Table 7.14.
In Table 7.14, Hτ is the Heaviside function.

7.14.4 Model simulation


Using OpenModelica, the results of simulating this system are as shown in Figs.
7.31–7.34.
The following Modelica code (file CooledLiquidReactor.mo) describes the sys-
tem with operating conditions. The code also contains the ODE formulation of
Section 7.14.5 in model ModCooledLiquidReactorODE.

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.13: Parameters for liquid reactor with varying temperature.


Parameter Value Unit Comment
V 15 L Reactor volume
ρ 1 kg/L Density of liquid
a 2 — Stoichiometric constant
1−α
k0 0.1 (mol/L) /s Reaction constant
E 3
R
10 K Activation energy per gas constant

H̃A 100 kJ/mol Molar enthalpy of species A at (T, p◦ )

H̃B −150 kJ/mol Molar enthalpy of species B at (T, p◦ )
ĤS◦ 0 kJ/mol Specific enthalpy of species S at (T, p◦ )
c̃•p,A 50 × 10−3 kJ
mol K
Molar heat capacity of species A
• −3
c̃p,B 100 × 10 kJ
mol K
Molar heat capacity of species B
ĉ•p,S 4.2 kJ
mol K
Specific heat capacity of species S

T 293.15 K Standard state temperature

p 1.01 × 105
Pa Standard state pressure

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

Cooled liquid reactor: concentrations


4.0 cA
3.5 cB
cA, i
3.0
2.5
[mol/L]

2.0
1.5
1.0
0.5
0.0
0 20 40 60 80 100 120
time t [s]

Figure 7.31: Molar concentrations cA (red), cB (blue), and influent concentration


cA,i (green), all given in [mol/L].

Cooled liquid reactor: temperatures


20 T
Ti
18
16
14
[ C]

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*

Cooled liquid reactor: heat flow


0

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.

Cooled liquid reactor: volumetric flow rate


3.0

2.8

2.6
V [L/s]

2.4

2.2

2.0
0 20 40 60 80 100 120
time t [s]

Figure 7.34: Volumetric flow rate V̇ [L/s] through the reactor.


7.14. CASES: LIQUID PHASE REACTOR 451

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*

129 input Real Vd " Volumetric flow rate through reactor , L / s


";
130 input Real cAi " Influent molar concentration of A , mol / L
";
131 input Real Ti " Influent temperature , K ";
132 input Real Qd " Added ’ heat ’ , kW ";
133 // Equations constituting the model
134 equation
135 // Differential equations
136 der ( nA ) = ndAi - ndAe + ndAg ;
137 der ( nB ) = ndBi - ndBe + ndBg ;
138 der ( U ) = Hdi - Hde + Qd ;
139 // Algebraic equations
140 nA = cA * V ;
141 nB = cB * V ;
142 ndAi = cAi * Vd ;
143 ndBi = 0;
144 mdSi = rho * Vd ;
145 ndAe = cA * Vd ;
146 ndBe = cB * Vd ;
147 mdSe = mdSi ;
148 ndAg = -a * r * V ;
149 ndBg = r * V ;
150 r = k * cA ^ a ;
151 k = k0 * exp ( - EdR / T ) ;
152 U = H - pdd * V ;
153 H = HAp + HBp + HSp ;
154 HAp = nA * HtAp ;
155 HBp = nB * HtBp ;
156 HSp = mS * HhSp ;
157 HtAp = HtAdd + cptA *( T - Tdd ) ;
158 HtBp = HtBdd + cptB *( T - Tdd ) ;
159 HhSp = HhSdd + cphS *( T - Tdd ) ;
160 Hdi = HdApi + HdBpi + HdSpi ;
161 HdApi = ndAi * HtApi ;
162 HdBpi = ndBi * HtBpi ;
163 HdSpi = mdSi * HhSpi ;
164 HtApi = HtAdd + cptA *( Ti - Tdd ) ;
165 HtBpi = 0;
166 HhSpi = HhSdd + cphS *( Ti - Tdd ) ;
167 Hde = HdApe + HdBpe + HdSpe ;
168 HdApe = ndAe * HtAp ;
169 HdBpe = ndBe * HtBp ;
170 HdSpe = mdSe * HhSp ;
171 end M od C oo le d L i q u i d R e a c t o r ;
172 //
173 model 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
174 // Model of Cooled Liquid Reactor
175 // author : Bernt Lie
7.14. CASES: LIQUID PHASE REACTOR 455

176 // University of South - Eastern Norway


177 // October 27 , 2015
178 // May 12 , 2017
179 //
180 // Parameters
181 parameter Real V = 15 " Reactor volume , L ";
182 parameter Real rho = 1 " Liquid density , kg / L ";
183 parameter Real a = 2 " Stoichiometric constant , -";
184 parameter Real k0 = 0.1 " Pre - exponential factor , ...";
185 parameter Real EdR = 1 e3 " Activation temperature , K ";
186 parameter Real HtAdd = 300 " Molar enthalpy of A at std
cond , kJ / mol ";
187 parameter Real HtBdd = -400 " Molar enthalpy of B at std
cond , kJ / mol ";
188 parameter Real HhSdd = 0 " Specific enthalpy of solvent at
std cond , kJ / kg ";
189 parameter Real cptA = 50 e -3 " Molar heat capacity of A , kJ
. mol -1. K -1";
190 parameter Real cptB = 100 e -3 " Molar heat capacity of B ,
kJ . mol -1. K -1";
191 parameter Real cphS = 4.2 " Specific heat capacity of
solvent , kJ . kg -1. K -1";
192 parameter Real Tdd = 293.15 " Temperature in std state , K
";
193
194 // Initial state parameters
195 parameter Real nA0 = 2 " Initial number of moles of A , mol
";
196 parameter Real nB0 = 0 " Initial number of moles of B , mol
";
197 parameter Real cA0 = nA0 / V " Initial molar concentration
of A , mol / L ";
198 parameter Real cB0 = nB0 / V " Initial molar concentration
of B , mol / L ";
199 parameter Real T0 = 288.15 " Initial temperature , K ";
200 // Declaring variables
201 // -- states
202 Real cA ( start = cA0 , fixed = true ) " Initializing
concentration of A in reactor , mol / L ";
203 Real cB ( start = cB0 , fixed = true ) " Initializing
concentration of B in reactor , mol / L ";
204 Real T ( start = T0 , fixed = true ) " Initializing
temperature in reactor , K ";
205 // -- auxiliary variables
206 Real r " Rate of reaction , mol /( L . s ) ";
207 Real k " Reaction ’ constant ’ , ...";
208 Real dHtr " Molar enthalpy of reaction , kJ / mol ";
209 // -- input variables
210 input Real Vd " Volumetric flow rate through reactor , L / s
456 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 ;

7.14.5 ODE formulation


7.14.5.1 Model reduction to ODE
It is of interest to reduce the DAE model to an ODE model by keeping, e.g., cA , cB
and T as states. We get
dnA
= ṅA,i − ṅA,e + ṅA,g
dt

d
(cA V ) = cA,i V̇ − cA V̇ − arV
dt

dcA cA,i V̇ − cA V̇ − arV
=
dt V
where ( )
E
r = kcA = k0 exp −
a
caA .
RT
Furthermore
dnB
= ṅB,i − ṅB,e + ṅB,g
dt

d
(cB V ) = 0 − cB V̇ + rV
dt

dcB −cB V̇ + rV
= ,
dt V
7.14. CASES: LIQUID PHASE REACTOR 457

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 ∆r H̃ is the molar enthalpy of reaction. We thus find


( ) dT ( ) ( )
nA c̃•p,A + nB c̃•p,B + mS ĉ•p,S = cA,i V̇ c̃•p,A + ρV̇ ĉ•p,S (Ti − T ) + −∆r H̃ rV + Q̇
dt

( ) ( )
• •
dT c A,i V̇ c̃ p,A + ρV̇ ĉ p,S (Ti − T ) + −∆ r H̃ rV + Q̇
=
dt nA c̃•p,A + nB c̃•p,B + mS ĉ•p,S

where

∆r H̃ = H̃B• − aH̃A• = H̃B◦ + c̃•p,B (T − T ◦ ) − aH̃A◦ − ac̃•p,A (T − T ◦ )



( ) ( )
∆r H̃ = H̃B◦ − aH̃A◦ + c̃•p,B − ac̃•p,A (T − T ◦ ) .

7.14.5.2 Model summary


In summary, the model in ODE form is

dcA cA,i V̇ − cA V̇ − arV


=
dt V
dcB −cB V̇ + rV
=
dt ( V ) ( )
• •
dT cA,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 ◦ ) .
◦ ◦
7.15. CASE: GAS PHASE REACTOR⋆ 459

In the general state space form


dx
= f (x, u; θ)
dt
y = g (x, u; θ)

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.14.6 ODE model simulation


The simulation results are identical to those in Figs. 7.31–7.32.

7.15 Case: Gas phase reactor⋆


7.15.1 Model objective
• Basic ammonia reactor?

7.15.2 Model development


7.15.3 Model summary
7.15.4 Model simulation

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 temperatures in layers of overall heat exchanger

• Reduce DAE models to ODE models

Problem 7.1. [Solution E.16 p. 602] Ideal gas molar entropy

Find expressions for molar entropy S̃ for ideal gas (ref: Section 7.8):

• by assuming that molar heat capacity c̃p is a function of temperature, and


7.18. PROBLEMS* 461

• by assuming that molar heat capacity c̃p is constant. N


Problem 7.2. [Solution E.17 p. 603] Constant density liquid molar entropy
Find expressions for molar entropy S̃ for constant density liquid (“ideal liquid”, ref:
Section 7.8):
• by assuming that molar heat capacity c̃p is a function of temperature, and

• by assuming that molar heat capacity c̃p is constant. N


Problem 7.3. [Solution E.18 p. 603] Ideal gas molar Gibb’s free energy
Find expressions for molar Gibb’s free energy G̃ for ideal gas (ref: Section 7.8):
• by assuming that molar heat capacity c̃p is a function of temperature, and

• by assuming that molar heat capacity c̃p is constant. N


Problem 7.4. [Solution E.19 p. 604] Constant density liquid Gibb’s free energy
Find expressions for molar Gibb’s free energy G̃ for constant density liquid (“ideal
liquid”, ref: Section 7.8):
• by assuming that molar heat capacity c̃p is a function of temperature, and

• by assuming that molar heat capacity c̃p is constant. N


Problem 7.5. [Solution E.20 p. 604] Singular counter-current heat exchanger.
The general expression for heat transfer in the counter-current heat exchanger is
given by Eq. 7.91 p. 409. Effluent temperatures for the tube side and the shell side
are given by Eqs. 7.88 and 7.89, respectively.
These expression are based on the assumption that αt ̸= αs , see Section 7.9.4.
What if αt ≡ αs ?
• Find valid expressions for the singular case when αs → αt .

• Are the expressions in Eqs. 7.88 and 7.89 still valid if αs → αt ? N


Problem 7.6. [Solution E.21 p. 607] Approximations of the LMTD heat exchanger
approach.
In the literature, it has been argued that computing the logarithm in the LMTD
approach is not very efficient. It is thus proposed that
(T s − Tet ) − (Tes − Tit ) 1 (( s ) ( s )) 2 √ s
∆Tlm = i Tis −Tet
≈ Ti − Te
t
+ Te − Ti
t
+ (Ti − Tet ) (Tes − Tit )
ln T s −T t 2 3
e i

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*

As discussed in Section 7.9, it is not really necessary to introduce the LMTD in


computing the heat transfer or the effluent temperatures. However, let us re-evaluate
the expressions for a counter-current heat exchanger with effluent temperatures for
the tube side and the shell side given by Eqs. 7.88 and 7.89, respectively, and heat
transfer given by Eq. 7.91.
These expressions for Tet , Tes and Q̇t2s all require evaluation of the exponential
function exp (·), which — with limited computational resources — perhaps may be
a problem. Let us consider the case when |αt − αs | is small, and then use a first
order Padé approximation for exp z valid when z is small:
exp z2 1 + z2
exp z = ( z) ≈ .
exp − 2 1 − z2

To this end, consider the following tasks:


• Find simplified expressions for Tet and Tes under the assumption that |αt − αs |
is small and a first order Padé approximation is used.

• 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) .

Here, hr is a reference (desired) level, and Kp is a constant, while us is a


positive and constant signal.

• 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

The proportional controller (P-controller) has the following form:

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).

We consider a system as sketched in Fig. 7.36 (a CSTR31 ).


The reactor content is in the liquid phase, and consists of the components A and
B dissolved in a solvent S. The feed (input material) consists of components A and
S. Components A and B are present in so small concentrations that they do not
affect the total density ρ of the reactor content.
Within the reactor, the reaction mA → B takes place (in Fig. 7.36, m = 1;
use the more general case with m in this problem). The basic reaction rate in the
reactor (mol/volume) is r given by

r = kcm
A,

where cA is the molar concentration of component A, defined as cA , nA /V in a


well stirred reactor. Here, nA is the number of moles of component A within the
reactor, while V is the volume of the reactor. m is the reaction order.
The reactor is exothermic, i.e., the reaction heats up the reactor. It is thus
necessary to cool the reactor with a heat flow Q̇ from the cooling water to the
reactor content. Cooling implies that Q̇ is negative. We can not control Q̇ directly,
but we can vary Q̇ by varying the volumetric flow rate V̇c of the cooling water. It is
31
CSTR = continuous, stirred tank reactor. “Continuous” indicates that mass is flowing into
and out of the system all the time.
7.18. PROBLEMS* 465

shown in Section 7.9 that Q̇ can be expressed as


( ( ))
UΩL
Q̇ = V̇c ρc ĉp,c 1 − exp − (Tc,i − T )
ρc ĉp,c V̇c

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.

• Formulate a dynamic model which describes the (molar) concentration cA of


component A.
(Hint: Use the mole balance for component A.)

• Formulate a similar model for the number of moles nB of component B, and


the mass mS of the solvent S.
(Hint: You need the mole balance for component B and the mass balance of
component S in the subsequent formulation of the energy balance.)

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

where k0 is known as the pre-exponential factor, E is the activation energy, R is the


ideal gas constant, while T is the absolute temperature (i.e., given in K when the
SI system is used). Added heat to the reactor from the cooling system is Q̇ (Q̇ will
be negative, in order to cool the reactor).

• Introduce necessary additional assumptions, and formulate a model describing


cA when the temperature varies, as you assume that the reactor content is an
ideal solution.
(Hint 1: You must also formulate an equation for T . This equation is found
by using the energy balance.
Hint 2: With the assumption of an ideal solution, this means that, e.g., the
enthalpy can be written as the sum of the enthalpy for each component:

H = HS + HA + HB ,

where Hj represents the enthalpy of component j as if component is alone in


the volume. Notice that for non-ideal solutions such as water/ethanol, this
assumption is not valid.) N

Problem 7.10. [Solution E.25 p. 617] Reaction equilibrium constant for Haber
Bosch synthesis.

...to be developed. Give literature expression. Check tabular data. N


466 CHAPTER 7. ENERGY BALANCE*

c A, c B

Figure 7.36: Sketch of reactor (CSTR) with distributed heat transfer.


Chapter 8

Model analysis*

8.1 Learning goals


• Solvability and model classification. Stability. Numeric vs. analytic solvabil-
ity.
• Linearization through truncated Taylor series expansion. Linear Time Invari-
ant (LTI) vs. Linear Time Variant (LTV) systems.
• Solution of LTIs.
• Analysis of linear systems behavior. Eigenvalues, time constants, oscillation.
• Analysis of nonlinear systems by numeric simulation. Discretization princi-
ples, choice of step length, automatic step length determination. Steady state
vs. stationary solutions. Sensitivity. Stochastic systems and Monte Carlo
simulation.
• Zero dynamics.
• Singular perturbation vs. regular perturbation. Model order reduction.
• Laplace transform of LTI systems and transfer function models. Poles and
zeros.
• Examples.

8.2 Model types, solvability and stability


8.2.1 Classification of models
8.2.1.1 General Differential Algebraic Equations
Models for dynamic systems typically consist of differential and algebraic equations,
DAEs. In the most general form, these can be written as
( )
dx
f , x, z, u; θ, t = 0 (8.1)
dt

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

A linear, time invariant DAE can in general be posed as


dx
E = Ax + Bu + Cz (8.4)
dt
where matrix multiplication between constant valued matrices (A, B, C, E) and col-
umn vectors ( dx
dt
, x, u, z) has been assumed. If we allow for the matrices to vary with
time, we have a linear, time variant DAE.

8.2.1.2 Structured Differential Algebraic Equations


In this course, we have considered a simpler, structured form of DAEs which is
explicit in the time derivatives,
dx
= f (x, z, u; θ) (8.5)
dt
0 = g (x, z, u; θ) ; (8.6)

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*

8.2.1.3 Ordinary Differential Equations


In some modeling examples, we have seen how we can reduce DAEs to ordinary
differential equations, ODEs, through manipulation and elimination of algebraic
variables. A general, time variant ODEs can be written as

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, θ) ,

then the model is linear, but time variant.


In the design of feedback controllers, the following structure is also interesting:

f (x, u; t, θ) = f1 (x; t, θ) + f2 (x; t, θ) u.

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

8.2.2 Solvability of models


8.2.2.1 The concept of state
The concept of state is of some importance. Consider the structured DAE form in
Eqs. 8.5–8.6, where we have described the states as “the variables which are differ-
entiated wrt. time”. This is really a too vague “definition”. What if we differentiate
the algebraic equation in Eq. 8.6 to yield
∂g dx ∂g dz ∂g du
0= + +
∂x dt ∂z dt ∂u dt

∂g ∂g dz ∂g du
0= f (x, z, u; θ) + +
∂x ∂z dt ∂u dt
and where du
dt
is a known function of time (since u (t) is assumed to be known). If
we can invert the Jacobian ∂g
∂z
, we can write this as
( )−1 ( )
dz ∂g ∂g ∂g du
=− f (x, z, u; θ) + . (8.11)
dt ∂z ∂x ∂u dt

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.

Example 8.2. Boundary condition for scalar ODE.

Consider the scalar ODE


dx
= −x.
dt
The solution is x (t) = exp (− (t − t1 )) x (t1 ). To make the solution well defined, we
need to know the “boundary condition” x (t1 ), which basically implies that we need
to know the solution at a certain point in time — e.g., the initial value, the final
value, or the value at some other time. N
The needed “boundary condition” (often: “initial condition”) can be interpreted
as containing the history of the system. Thus, if we know the initial condition (or
final condition, etc.), we know everything about the past of the system and the
model allows us to compute the future of the system. In this respect, we can more
precisely say that the state is the minimum number of variables which contain the
history of the system.
We now see that in the above system, we can not include z as states. Why?
Because in the original model of Eqs. 8.5–8.6, we only need to know the initial value
of x. The initial value of z can then be computed by solving Eq. 8.6, provided
472 CHAPTER 8. MODEL ANALYSIS*

that the Jacobian ∂g


∂z
is invertible. This means that only the initial values of x are
independent, while the initial values of z can be found by solving the model (Eq.
8.6). Thus dim x is the minimum number of independent initial values/conditions,
and the state only consists of x.

8.2.2.2 Required information


In order to solve a structured DAE model as in Eqs. 8.5–8.6, it is necessary to know:

• 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,

• some initial value x (t0 ) of the state x, often t0 is taken to be t0 = 0,3

• 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 ],

• all model parameters θ.

8.2.2.3 Required model properties


With DAEs in the form of Eqs. 8.5–8.6, we can often solve Eq. 8.6 to yield z —
either analytically as
z = g̃ (x, u; θ)
where g̃ (·) is a known vector of functions, or numerically by some iteration proce-
dure. We can then insert the expression for z into Eq. 8.5 and find

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 solution is unique if function F (x, t; θ) is so-called Lipschitz continuous 4 in x,


which basically implies that there exist some constant K such that

|F (x1 , t; θ) − F (x2 , t; θ)| < K |x1 − x2 | .

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.

8.2.2.4 Random systems/Stochastic Differential Equations+


So far, we have considered systems where the input variable u (t) changes in such
a way that the DAE model formulation is valid, and we have considered determin-
istic systems, where x (t0 ), θ, and u (t) are known exactly. Let us first discuss the
problem of inputs u (t) that may invalidate the DAE formulation. We do this by
recapturing the transition from integral formulation to differential formulation of
the mass balance.

Example 8.3. Mass conservation integral vs. differential formulation.

We have seen that mass conservation is expressed by the integral formulation


ˆ t+∆t
m (t + ∆t) = m (t) + [ṁi (τ ) − ṁe (τ )] dτ .
t

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; θ) ,

but must instead write it in integral form as

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.

8.2.2.5 Random systems in practice


How can we handle these cases? Conceptually, we can handle them by Monte
Carlo simulation. The cases of x (t0 ) and θ belonging to probability distributions
5
E.g., by event detection in the simulation tool.
6
We can talk about a countable number of changes even if we have an infinite number of changes
taking place at times ti — the key point is that as long as i is an integer number, the number of
changes are countable.
8.2. MODEL TYPES, SOLVABILITY AND STABILITY 475

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

= lim [x (t) − µx (t)] [x (t) − µx (t)]T . (8.15)


NMC →∞ NMC − 1 i=1

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.

8.2.3 Stability concepts


A complete definition of stability requires a certain level of mathematical apparatus,
and we will therefore restrict the discussion to a somewhat simplified definition of
stability.
In general, it is common to talk about point stability vs. solution stability.

Definition 8.1. [Point stability:]

Let x∗ be a constant point solution of system

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

∥x (t0 ) − x∗ ∥ < δ ⇒ ∥x (t) − x∗ ∥ < ϵ

for all t > t0 where x (t) is the solution with x (t = t0 ) = x (t0 ).


A system which is not stable (at the point), is unstable. N
Remark 8.1. Here, ∥x∥ denotes some norm of vector x, e.g., the 2-norm ∥x∥2 =
∑ x 2 12 8
( ni=1 xi ) . In the definition, “for any ϵ > 0” means that we, e.g., can choose ϵ
arbitrarily small and require that for a stable point x∗ , there exists some δ such that
if ∥x (t0 ) − x∗ ∥ < δ, then all future solutions satisfy ∥x (t) − x∗ ∥ < ϵ.
Figure 8.1 illustrates the idea of stability.
Let us illustrate the concept of stability.

7
For autonomous systems, a point x∗ such that dx ∗
dt = f (x , t) = 0 is sometimes denoted an
equilibrium point.
8
A norm ∥x∥ can be thought of as a generalization of absolute value. The absolute value, |x|,
gives a positive scalar number for scalar x and is only zero when scalar x is zero. A norm, ∥x∥,
gives a positive scalar number for vector x, and is only zero when vector x is the zero vector.
8.2. MODEL TYPES, SOLVABILITY AND STABILITY 477

Example 8.4. Stability of hanging pendulum.

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

Example 8.5. Stability of inverted pendulum.

Consider an inverted pendulum, where x∗ = (α∗ , ω ∗ ) and the angle is α∗ = 180 ◦


(standing straight up) while the angular velocity is ω ∗ = 0 ◦ /s. If we perturb the
initial position slightly to x (0), where ∥x (0) − x∗ ∥ < δ, the pendulum will start to
fall, and will oscillate around α = 0 ◦ with a maximum deviation around x∗ contained
in ∥x (t) − x∗ ∥ < ϵ. However, it is not possible to shrink ϵ to an arbitrarily small
number and require that the oscillations become arbitrarily small around x∗ no
matter how much we shrink the positive number δ — the pendulum will still fall
down, and oscillate violently around xI = (0, 0) ̸= x∗ . Thus, the system is not
stable; it is unstable. N
We could specialize the definition of point stability to the concepts asymptotic
stability and exponential stability.

Definition 8.2. Asymptotic point stability. A system

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

Definition 8.3. Exponentially point stability.

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*

8.3 Analytic solution of nonlinear models


In some cases, it is possible to find an analytic solution of ODEs. This is mainly
the case for single variable models, i.e., where x is a scalar variable. In particular,
suppose that we have an autonomous model with the following structure:

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).

Example 8.6. Solution of batch reactor model.

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)

Taking the exponentiation function (anti-logarithm) on each side, we have

nA (t)
= exp (−kt)
nA (0)

nA (t) = exp (−kt) nA (0) .

For a ̸= 1, we have a nonlinear, time invariant, autonomous model:


[ ]nA (t)
1
1 ak
− a−1 =− t
nA a − 1 nA (0)
V a−1

1 1 1 1 ak
− + = − a−1 t
nA (t) a−1
a − 1 nA (0)a−1
a−1 V

1 1 a (a − 1) k
a−1 = a−1 + t.
nA (t) nA (0) V a−1

Example 8.7. Solution of autonomous tank model.

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ς

In this system, we see that h (tfin ) = 0 when



2ρA hς √
tfin = h (0);
K
at the time tfin , the tank is empty and Eq. 8.16 is invalid for t > tfin ; for t > tfin ,
h (t) ≡ 0. N

8.4 Linearization by Taylor series expansion


8.4.1 Motivation
As we have seen, it is only for simple nonlinear systems that we can find an analytic
solution. We will see in a subsequent section that linear, time invariant systems
admit a general solution. Thus it is of interest to develop linear approximations of
nonlinear systems, and then see if we can later use linear analysis techniques to say
something about the behavior of the nonlinear system. To this end, we consider
driven ODE models of type
dx
= f (x, u; θ)
dt
y = g (x, u; θ) ,

where x ∈ Rnx , u ∈ Rnu , and y ∈ Rny . The idea is simple to extend to DAEs.

8.4.2 Scalar Taylor series expansion


As an introduction, consider a scalar, nonlinear function y = f (x) where x ∈ R and
y ∈ R. If this function is sufficiently differentiable, we can write the Taylor series
expansion at operating point x∗ as

∗ df (x) ∗ 1 d2 f (x)
f (x) = f (x ) + (x − x ) + (x − x∗ )2
dx x=x∗ 2 dx2 x=x∗

1 d3 f (x)
+ 3 (x − x∗ )3 + · · ·
6 dx x=x∗


∑∞
1 di f (x)
f (x) = (x − x∗ )i ,
i=0
i! dxi ∗ x=x
8.4. LINEARIZATION BY TAYLOR SERIES EXPANSION 481

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∗ ”.

Example 8.8. Accuracy of power series expansions.


10
An analytic function can be defined to be a function for which the Taylor series expansion is
valid.
482 CHAPTER 8. MODEL ANALYSIS*

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

8.4.3 Scalar function with multivariable argument


Even in the simple case of nx = 1 and nu = 1, we need to use the multivariable
Taylor series expansion to find the expansion of f (x, u) around (x∗ , u∗ ). We find

∗ ∗ ∂f (x, u) ∗ ∂f (x, u)
f (x, u) = f (x , u ) + (x − x ) + (u − u∗ )
∂x x=x∗∗ ∂u x=x∗∗
u=u
u=u
1 ∂ 2 f (x, u) 1 ∂ 2
f (x, u)

+ (x − x∗ )2 + 2 (x − x∗ ) (u − u∗ )
2 ∂x2 x=x∗∗ 2 ∂x∂u x=x∗∗
u=u u=u
2
1 ∂ f (x, u)
+ 2 (u − u∗ )2
2 ∂u x=x ∗
u=u∗

1 ∂ 3 f (x, u) ∗ 3 1 ∂ 3 f (x, u)
+ (x − x ) + 3 (x − x∗ )2 (u − u∗ ) +
6 ∂x3 x=x∗∗ 6 ∂x2 ∂u x=x∗∗

u=u u=u

3
1 ∂ f (x, u) ∗ ∗ 2 1 ∂ f (x, u)
3
+3 2 (x − x ) (u − u ) + 3 (u − u∗ )3 + · · · .
6 ∂x∂u x=x∗∗ 6 ∂u ∗
x=x∗
u=u u=u

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 ∗

If we have a scalar function with multiple arguments z, dim z = nz , we will in general


find the linear approximation as

∑nz
∂f (z)

f (z) ≈ f (z ) + (zi − zi∗ ) .
i=1
∂z i ∗

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*

8.4.4 Vector of functions with multivariate argument


What then if we have a vector f (x, u) of functions? In other words: what if
 
f1 (x, u)
 .. 
f (x, u) =  . 
fn (x, u)

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 ∗

We thus find that


 
  ∂f1 (x,u) ∂f1 (x,u)
f1 (x, u) f1 (x∗ , u∗ ) + (x − x∗ ) + (u − u∗ )
 ∂x

∂u
∗ 
 ..   .. 
f (x, u) =  . ≈
  . 
 
fn (x, u) ∂fn (x,u)
fn (x∗ , u∗ ) + ∂x (x − x∗ ) +
∂f n (x,u)
∂u (u − u∗ )
∗ ∗

 
    ∂f1 (x,u)
f1 (x, u) ∗ ∗
f1 (x , u ) (x − x∗ )
 ∂x
∗ 
 ..   ..   .. 
f (x, u) =  .  ≈ .  
+ 
 . 
fn (x, u) ∗ ∗
fn (x , u ) ∂fn (x,u) ∗
∂x (x − x )

 
∂f1 (x,u) ∗
(u − u )
 ∂u
∗ 
 .. 
+ 
 . 
∂fn (x,u) ∗
∂u (u − u )


 
    ∂f1 (x,u)
f1 (x, u) f1 (x∗ , u∗ )
 ∂x  ∗
 ..   ..   .. 
f (x, u) =  .  ≈  .  +  .  (x − x∗ )
 
fn (x, u) ∗ ∗
fn (x , u ) ∂fn (x,u)
∂x

 
∂f1 (x,u)

 ∂u
∗ 
 .. 
+ .  (u − u∗ ) .
 
∂fn (x,u)
∂u

Here, we can write  


f1 (x∗ , u∗ )
 ..  ∗ ∗
 .  = f (x , u ) .
fn (x∗ , u∗ )
8.4. LINEARIZATION BY TAYLOR SERIES EXPANSION 485

Furthermore, the expression  


∂f1 (x,u)

 ∂x  ∗
 .. 
 . 
 
∂fn (x,u)
∂x

will now be an n × nx matrix, since ∂fi (x,u)


∂x
is a row vector with nx elements. We
can thus introduce the following notation
 
∂f1 (x,u)

∂f (x, u)  ∂x
∗ 
 . 
, .
. .
∂x  
∗ ∂fn (x,u)
∂x

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.

8.4.5 Linearization of model


We now consider the nonlinear model
dx
= f (x, u; θ) ,
dt
where we assume that we have chosen an operating point (x∗ , u∗ ). If the Taylor
series expansion of f (x, u; θ) is valid at (x∗ , u∗ ), we find that

∗ ∗ ∂f (x, u; θ) ∗ ∂f (x, u; θ)
f (x, u; θ) ≈ f (x , u ; θ) + (x − x ) + (u − u∗ ) .
∂x ∗ ∂u ∗

We now introduce the simplifying notation



∂f (x, u; θ)
A=
∂x

∂f (x, u; θ)
B= ,
∂u ∗
486 CHAPTER 8. MODEL ANALYSIS*

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

Similarly, we can linearize the equation from state x to output variable y,

y = g (x, u) .

We find that

∂g ∂g
y = g (x) ≈ g (x∗ ) + (x − x∗ ) + (u − u∗ ) .
∂x ∗ ∂u ∗

By defining y ∗ = g (x∗ , u∗ ), and



∂g
C=
∂x ∗

∂g
D= ,
∂u ∗

we get
y δ = Cxδ + Duδ ,
where y δ , y − y ∗ .

8.5 Solution of linear systems


8.5.1 Linear, time invariant systems
We will restrict the discussion to finite dimensional linear, time invariant systems
(LTI), more precisely to systems of form

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*

8.5.2 Scalar, autonomous system


We first consider the scalar, autonomous case where
dx
= ax,
dt
and where x is a scalar function of time t, while a is a scalar, real constant, and
v = bu ≡ 0.
This system can be solved by the method of separation of variables:
dx dx
= ax ⇔ = adt.
dt x
By integrating on both sides of the equality sign, we find
ˆ x(t) ˆ t
dx x(t) x (t)
= adt ⇔ [ln x]x(0) = [at]t0 ⇔ ln x (t) − ln x (0) = at ⇔ ln = at.
x(0) x 0 x (0)

Thus,
x (t)
= exp (at)
x (0)

x (t) = exp (at) x (0) .

8.5.3 Scalar, driven system


Next, we consider the case
dx
= ax + v.
dt
This case can be solved by either of two methods.

8.5.3.1 Guessing the solution structure


We make the ansatz 11 that the solution has the following form

x (t) = exp (at) k (t) .

For t = 0 we find that

x (0) = exp (a · 0) k (0) ⇒ k (0) = x (0) .

If k (t) is differentiable, we find


dx d dk d exp (at)
= (exp (at) k (t)) = exp (at) + k (t)
dt dt dt dt

dx dk
= exp (at) + ak (t) exp (at) . (8.20)
dt dt
11
Ansatz (German): Intelligent guess, based on experience from the history of mathematics.
8.5. SOLUTION OF LINEAR SYSTEMS 489

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

Since function exp (at) can always be inverted, we have

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

In conclusion, we have thus found that the differential equation

dx
= ax + v
dt

has the general solution


( ˆ t )
x (t) = exp (at) x (0) + exp (−aτ ) v (τ ) dτ .
0

We can, of course, re-introduce v = bu to get


( ˆ t )
x (t) = exp (at) x (0) + exp (−aτ ) bu (τ ) dτ
0

as the solution for


dx
= ax + bu.
dt
12
RHS = right hand side.
490 CHAPTER 8. MODEL ANALYSIS*

8.5.3.2 Series expansion of exponential


For the driven model, we have
dx
= ax + v
dt

dx
exp (−at) = exp (−at) (ax + v)
dt

dx
exp (−at) − exp (−at) ax = exp (−at) v. (8.22)
dt
d
We have already used that for a scalar system, dt exp (at) = a exp (at). However,
as a preparation for the more general case, let us show this. We have the following
MacLaurin series13 for exp (at):
1 1
exp (at) = 1 + at + a2 t2 + . . . + (at)n + . . . .
2 n!
Thus,
( )
d d 1 22 1 n
exp (at) = 1 + at + a t + . . . + (at) + . . .
dt dt 2 n!

d 2 n
exp (at) = a + a2 t + . . . + an tn−1 + . . .
dt 2 n!

( )
d 1 n−1
exp (at) = a 1 + at + . . . + (at) + . . . = a exp (at) .
dt (n − 1)!

We now consider the derivative of exp (−at) · x:

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.

8.5.4 Multivariable systems


We consider the multivariable system
dx
= Ax + v
dt
where v = Bu. In the development, we will need function exp (At). Function
exp (at) where at is a scalar, is well defined. But how should a function of a matrix
be interpreted? The common way to expand such scalar functions to take on matrix
arguments, is via a power series (the MacLaurin series). Thus, consider a general
function f (a) with power series


f (a) = c i ai .
i=0

Then the same function with a matrix argument is defined as




f (A) , ci A i
i=0

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*

However, we also have


( )
d 1
exp (At) = I + At + · · · + (At) n−1
+ . . . A = exp (At) A.
dt (n − 1)!
Thus,
d
exp (At) = A exp (At) = exp (At) A.
dt
Although matrix multiplication normally does not commute14 , we see that for A exp (At),
it does.
We now proceed as in the scalar case:
dx
= Ax + v
dt

dx
exp (−At) = exp (−At) Ax + exp (−At) v
dt

dx
exp (−At) − exp (−At) Ax = exp (−At) v.
dt
Here, we utilize that
d dx dx
(exp (−At) x) = exp (−At) − A exp (−At) x = exp (−At) − exp (−At) Ax.
dt dt dt
Thus,
dx
exp (−At) − exp (−At) Ax = exp (−At) v
dt

d
(exp (−At) x) = exp (−At) v
dt

ˆ t
t
[exp (−At) x]t0 = exp (−Aτ ) v (τ ) dτ .
t0

The solution is thus


ˆ t
x (t) = exp (A (t − t0 )) x (t0 ) + exp (At) exp (−Aτ ) v (τ ) dτ .
t0

For the special case of t = 0, and by re-introducing v = Bu, we get


( ˆ t )
x (t) = exp (At) x (0) + exp (−Aτ ) Bu (τ ) dτ . (8.25)
t0

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

8.5.5 Diagonalizable multivariable system


A complication of the general solution found in the previous section, is that it is not
always convenient to relate to the power series expansion of exp (At) which is an
infinite series. We will thus consider an alternative way to solve the system, which
gives more insight into the meaning of exp (At) and its computation.
Thus, we again consider the multivariable system

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:

Ar1 = λ1 r1 , . . . , Arnx = λnx rnx .

These nx equations can be written in matrix form as


 
..
( ) ( )  λ1 . 0
r1 · · · rnx r1 · · · rnx . .
 .. .. .. 
A = . .
0 · · · λnx

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*

matrix A is diagonalizable. In this section, we will assume that A is diagonalizable,


and that we have found matrices R and Λ such that

A = RΛR−1 .

The linear differential equation can now be written as


dx
= Ax + v = RΛR−1 x + v
dt

dx
R−1 = ΛR−1 x + R−1 v
dt

d ( −1 )
R x = ΛR−1 x + R−1 v.
dt
We introduce new variables z and w as

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

Because we have R−1 R = I, we can proceed and write


( ˆ )
t
R−1 x (t) = exp (Λt) R−1 x (0) + R −1
| {zR} exp (−Λτ ) R−1 v (τ ) dτ
0
=I

( ˆ t )
−1 −1 −1
R x (t) = exp (Λt) R x (0) + R exp (−Λτ ) R v (τ ) dτ
0

( ˆ t )
−1 −1
x (t) = R exp (Λt) R x (0) + R exp (−Λτ ) R v (τ ) dτ . (8.28)
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

exp (At) = R exp (Λt) R−1 . (8.29)

The solution x (t) of the LTI model is then still


( ˆ t )
x (t) = exp (At) x (0) + exp (−Aτ ) v (τ ) dt ,
0

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*

8.6 Linear system analysis


8.6.1 Stability
8.6.1.1 Overview
A general definition of point stability has been given in Section 8.2.3. By combining
this definition with the known solution of linear, time invariant systems as in Eq.
8.30 with exp (At) as in Eq. 8.29, it is possible to find simple criteria for stability
of LTI systems. Even simpler, we consider the decoupled system as in 8.26, and
remember that x = Rz.
Thus, consider the LTI system with output,
dx
= Ax + Bu
dt
y = Cx + Du.

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

With wi (τ ) ≡ 0, we thus have

zi (t) = exp (λi t) zi (0) .

8.6.1.2 Real eigenvalues, autonomous case


First, we assume that every eigenvalue is real, i.e., λi ∈ R. Then all eigenvectors
must also be real, i.e., R ∈ Rnx ×nx . Assuming a constant operating point/solution

z ∗ with dzdt = 0, and with w∗ ≡ 0, we see that z ∗ (0) = 0. In order for the system to
be stable, we must require that for arbitrary ϵ > 0, it must be possible to find δ > 0
such that for t > 0,
|zi (0) − z ∗ | < δ ⇒ |zi (t) − z ∗ | < ϵ.
With z ∗ = 0, we see that this is equivalent to finding δ > 0 such that for arbitrary
ϵ,
|zi (0)| < δ ⇒ exp (λi t) · |zi (0)| < ϵ.
Clearly, we can only achieve this if exp (λi t) is bounded, i.e., if λi ≤ 0.
Because x = Rz, i.e., x is a linear combination of all diagonal “modes” zi , it
follows that for an LTI autonomous system, a requirement for (point) stability with
real eigenvalues only, is that ∀i : λi ≤ 0.

8.6.1.3 Complex eigenvalues, autonomous case


Next, we consider the possibility of complex eigenvalues. Because matrix A is real,
A ∈ Rnx ×nx , any complex eigenvalue λi of A must have a complex conjugate “twin”,
λ̄i . Let ri be the eigenvector of λi , Ari = ri λi . Thus Ari = ri λi ⇒ Ar̄i = r̄i λ̄i , and it
follows that the corresponding eigenvector of λ̄i must be r̄i , the complex conjugate
8.6. LINEAR SYSTEM ANALYSIS 497

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

x (t) = exp (At) x (0) ,

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

exp (λt) = exp (αt) exp (jβt)


( )
exp λ̄t = exp (αt) exp (−jβt)

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,

exp (±jβt) = cos (βt) ± j sin (βt)



exp (jβt) − exp (−jβt) = 2j sin (βt)
exp (jβt) + exp (−jβt) = 2 cos (βt) .

This gives
( )
exp (λt) − exp λ̄t = 2j exp (αt) sin (βt) .

Next, with complex element r of the eigenvector,

r = γ + jδ,

we have

r̄ = γ − jδ
rr̄ = (γ + jδ) (γ − jδ) = γ 2 + δ 2
r̄ − r = −2jδ.

Use of these relations leads to


( )
r̄ exp (λt) − r exp λ̄t = 2j exp (αt) [γ sin (βt) − δ cos (βt)]
( )
−r exp (λt) + r̄ exp λ̄t = −2j exp (αt) [γ sin (βt) + δ cos (βt)] .

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

γ sin (βt) − δ cos (βt) sin (βt)


x1 (t) = − exp (αt) x1 (0) + exp (αt) x2 (0)
δ δ
(γ 2 + δ 2 ) sin (βt) γ sin (βt) + δ cos (βt)
x2 (t) = − exp (αt) x1 (0) + exp (αt) x2 (0) .
δ δ

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

8.6.1.4 General LTI systems


So far, we have considered linear time invariant (LTI), autonomous systems which
can be diagonalized,
dx
= Ax
dt
where
AR = RΛ,
Λ is the diagonal matrix of eigenvalues and R is the corresponding (right) eigenvector
matrix which is assumed to be invertible. Such systems are stable provided that
∀i : ℜ (λi ) ≤ 0. Furthermore, they are both asymptotically and exponentially
(point) stable at x∗ = 0 provided that ∀i : ℜ (λi ) < 0.
For systems where the eigenvector matrix R can not be inverted, the situation
is more complicated. It can be shown that such systems may be unstable if ∃i :
ℜ (λi ) = 0 — specifically, if there are multiple eigenvalues with the same value λi
which simultaneously have ℜ (λi ) = 0, then the system is unstable. However, if every
eigenvalue with ℜ (λi ) = 0 are simple, then the system is still stable. In any way, if
∀i : ℜ (λi ) < 0 the linear system is stable, asymptotically stable, and exponentially
stable.
What if the LTI system is non-autonomous, i.e., that we have
dx
= Ax + Bu?
dt
Assume a fixed operating point (x∗ , u∗ ) which satisfies the model. The we have

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*

define xδ = x (t) − x∗ and uδ = u (t) − u∗ . Thus, xδ (0) ̸= 0, while t ≥ 0 : uδ (t) ≡ 0.


This implies that we have
dxδ
= Axδ ,
dt
and the stability condition for the autonomous case with step change in the input
is identical to that of the non-autonomous case.

8.6.2 Time constant and oscillations


8.6.2.1 Time constant defined
We consider an exponentially stable LTI system with real eigenvalues λ1 , . . . , λnr .
Let us assume that we can decouple the system into
dzi
= λi zi + wi ,
dt
where λi < 0. It is of interest to find what we can say about the system behavior
without solving the differential equation. First we consider the case of wi ≡ 0. We
know that the solution is zi (t) = exp (λi t) zi (0), and let us compare this known
solution with the linear function ziℓ (t) = zi (0) + ct which is tangent to zi (t) at
t = 0. The tangent of zi (t) at t = 0 is given by

dzi
= λi zi |t=0 = λi zi (0) .
dt t=0

This is to be equated with the tangent of ziℓ at t = 0, i.e.,



dziℓ
= c|t=0 = c.
dt t=0

i dziℓ
dt
Equating dzdt t=0
with leads to
t=0

c = λi zi (0) ,

and it follows that


ziℓ (t) = (1 + λi t) zi (0) .
Figure 8.4 illustrates the behavior of zi (t) and ziℓ (t) for λi = − 12 , and zi (0) = 1.
We now introduce the concept time constant T , defined as the time when ziℓ (t = T ) =
0, see Fig. 8.4. From the expression for ziℓ (t), we see that this gives T as

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 |

8.6.2.2 Experimental determination of time constant


The value of the actual system (not the tangent slope approximation) at t = Ti is
1
zi (Ti ). By inserting Ti = −λ i
, we find
( )
1
zi (Ti ) = exp (λi Ti ) zi (0) = exp −λi zi (0) = exp (−1) zi (0)
λi

zi (Ti ) 1
= exp (−1) = ≈ 0.367 88.
zi (0) exp (1)
zi (0)−zi (Ti )
With zi (0) = 1, Fig. 8.4 confirms this result. We could also find zi (0)
:

zi (0) − zi (Ti ) = (1 − exp (−1)) zi (0)



zi (0) − zi (Ti ) 1
= 1 − exp (−1) = 1 − ≈ 0.632 12.
zi (0) exp (1)
502 CHAPTER 8. MODEL ANALYSIS*

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.

8.6.2.3 Time constant in non-autonomous systems


In the discussion above, we have assumed that the system is autonomous, i.e., that
wi (t) ≡ 0. What if the input is non-zero but constant, i.e., wi (t) = wi∗ ? We can
then find the steady state solution zi∗ as follows:
dzi∗ 1 ∗
= 0 = λi zi∗ + wi∗ ⇒ zi∗ = w .
dt −λi i
Next, instead of considering the mode
dzi
= λi zi + wi ,
dt
we consider the deviation from the operating point, with ziδ , zi − zi∗ and wiδ =
wi − wi∗ ≡ 0. The model then reduces to
dziδ
= λi ziδ ,
dt
8.6. LINEAR SYSTEM ANALYSIS 503

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.

8.6.2.4 Oscillatory systems


Many systems have complex eigenvalues. These will always occur in complex con-
jugate pairs, and they will incur oscillatory behavior.

Example 8.9. Oscillatory system with step input.

We consider the system


A B
z( }| ){ z( }| ){
dx 0 1 0
= x+ u (8.34)
dt −ω0 −2ζω0
2
1
( )
y = 1 0 x, (8.35)
| {z }
C

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

For eigenvalue λ, it follows that det (λI − A) = 0 and



−2ζω0 ± 4ζ 2 ω02 − 4ω02 √
λ= = −ζω0 ± ζ 2 − 1 · ω0 .
2

With ζ < 1, we thus have two complex conjugate eigenvalues λ, λ̄ where



λ = −ζω0 + j 1 − ζ 2 ω0 .

√ this to the “standard form” in Section 8.6.1.3, we see that α = −ζω0


Comparing
and β = 1 − ζ 2 · ω0 .
18
H0 (t) is the unit step function at t = 0.
504 CHAPTER 8. MODEL ANALYSIS*

The eigenvectors are given from Ar = rλ, leading to


( )( ) ( )
0 1 r1 r1
= λ
−ω02 −2ζω0 r2 r2

( ) ( )
r2 r1 λ
= .
−2r2 ζω0 − ω02 r1 r2 λ
Here, the first equation in the vector equation is r2 = r1 λ. In the second equation,
inserting r2 = r1 λ leads to
−2r2 ζω0 − ω02 r1 = r2 λ

−2r1 λζω0 − ω0 r1 = r1 λλ
2


( 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

With x (0) = C T y0 and assuming that we are interested in y = Cx, leads to


ˆ t
T
y (t) = C exp (At) C y0 + C exp (A (t − τ )) Bu (τ ) dτ .
0
Here, we find
α sin (βt) − β cos (βt)
C exp (At) C T y0 = − exp (αt) y0
β
exp (α (t − τ ))
C exp (A (t − τ )) B = sin (β (t − τ )) .
β
With u (t) = ua H0 (t), u (t) = ua in the integration interval [0, t] of interest:
ˆ t[ ]
α sin (βt) − β cos (βt) 1
y (t) = − exp (αt) y0 + exp (α (t − τ )) sin β (t − τ ) ua dτ
β 0 β

α sin (βt) − β cos (βt) 1 − exp (αt) β1 (β cos (βt) − α sin (βt))
y (t) = − exp (αt) y0 + ua .
β α2 + β 2
8.6. LINEAR SYSTEM ANALYSIS 505

Partially inserting the values α = −ζω0 and β = 1 − ζ 2 ω0 leads to
( )
α2 + β 2 = ζ 2 ω02 + 1 − ζ 2 ω02 = ω02 ,

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

sin (θ ± ψ) = sin θ cos ψ ± cos θ sin ψ.

Thus, in the expression



ζ sin (βt) + 1 − ζ 2 cos (βt) ,

is there an angle ψ such that

cos ψ = ζ

sin ψ = 1 − ζ 2 ?

Clearly, sin2 ψ + cos2 ψ = ζ 2 + (1 − ζ 2 ) = 1, so yes, this is possible. Thus with


ψ = arccos ζ, we have

ζ sin (βt) + 1 − ζ 2 cos (βt) = sin (βt + ψ) .

In conclusion, we have

1 − exp (−ζω0 t) √ 1 2 sin (βt + ψ)


sin (βt + ψ) 1−ζ
y (t) = exp (−ζω0 t) √ y0 + 2
ua
1−ζ 2 ω0

(√ ) (√ )
sin 1 − ζ ω0 t + ψ
2 1 − exp (−ζω 0 t) √ 1
sin 1 − ζ 2ω t + ψ
0
1−ζ 2
y (t) = exp (−ζω0 t) √ y0 + ua
1 − ζ2 ω02
(8.36)

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

Example 8.10. Oscillatory system with sinusoidal input.


506 CHAPTER 8. MODEL ANALYSIS*

Linear oscillator: damped system


1.0 y
ya
0.8
0.6
0.4
y

0.2
0.0
0.2
0.4
0 20 40 60 80 100
time t [s]

Figure 8.5: Comparison of solution of differential equation (solid, red y) with


analytic solution (dotted, blue ya ) with step change in input, with ζ = 0.3 and
u (t) = 0.1H0 (t). The ODE solution and the analytic solution are identical.

We reconsider the previous example, with u (t) = ua sin ωt. Then


ˆ t
y (t) = C exp (At) C y0 + T
[C exp (A (t − τ )) Bua sin (ωτ )] dτ
0

ˆ
α sin (βt) − β cos (βt) t
y (t) = − exp (αt) y0 + [C exp (A (t − τ )) Bua sin (ωτ )] dτ .
β 0

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

Next, we want to consider the case that ω → ω0 , and simultaneously ζ → 0. It


is convenient to start with Eq. 8.38, which can be reformulated into
(√ ) (√ )
sin 1 − ζ 2 ω0 t + ψ exp (−ζω0 t) sin 1 − ζ 2ω t
0
y (t) = exp (−ζω0 t) √ y0 + √ 2
ua
1 − ζ2 1 − ζ2 2ω0
√ (√ )
exp (−ζω0 t) 1 − ζ 2 cos 1 − ζ 2ω t
0 cos (ω0 t)
+ √ 2
ua − ua .
1 − ζ2 2ζω0 2ζω02
508 CHAPTER 8. MODEL ANALYSIS*

With ζ → 0, the expressions on the first line of the RHS become


(√ )
sin 1 − ζ ω0 t + ψ
2
lim exp (−ζω0 t) √ y0 = cos (ω0 t) y0
ζ→0 1 − ζ2
(√ )
exp (−ζω0 t) sin 1 − ζ ω0 t
2
sin (ω0 t)
lim √ 2
ua = ua .
ζ→0 1−ζ 2 2ω0 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

It follows that for ω → ω0 and ζ → 0, y (t) becomes


1
y (t) = cos (ω0 t) y0 + [sin (ω0 t) − ω0 t cos (ω0 t)] ua .
2ω02
We see that the amplitude of y (t) grows linearly without bound; because of
this, ω0 is known as the resonance frequency of the system. As soon as ζ > 0, this
unbounded growth stops. Because of this, ζ is known as the damping of the system.
It should be observed that this growth without bound at the resonance frequency
only occurs when the system is excited by a sinusoidal signal at the resonance
frequency. As soon as the excitation frequency ω ̸= ω0 , this unbounded growth
disappears. And as soon as the system has a positive damping, the unbounded
growth stops.
Figure 8.6 compares the solution of the differential equation in Eqs. 8.34–8.35
with the analytic solution for y (t) in Eq. 8.37.
8.6. LINEAR SYSTEM ANALYSIS 509

Linear oscillator: undamped system


150 y1
y2
100 y3
50

0
y

50

100

150
0 100 200 300 400 500 600
time t [s]

Figure 8.6: Comparison of solution of differential equation with sinusoidal input


and ζ = 0. Cases u = 0.1 sin (0.9ω0 t) (red, y1 ), u = 0.1 sin (ω0 t) (blue, y2 ), and
u = 0.1 sin (1.1ω0 t) (green, y3 ). In all cases, the expressions for the analytic solution
give identical results.

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*

109 end LinearOscillator ;

In general, thus, we can draw the following conclusions:

1. Systems with pairs of complex conjugate eigenvalues λ, λ̄ where λ = α + jβ


will have a normal behavior where transients from initial conditions and step
changes in inputs include terms of form exp (αt) sin (βt) and exp (αt) cos (βt)
where α < 0 for stable systems.

2. In general, this implies that systems with ∀j : ℜλj < 0, are guaranteed to be
stable for small deviation from the operating point.

8.6.3 Linearized nonlinear system


Assume that we have a system

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.

8.6.4 Stability analysis based on steady-state model


Perlmutter, etc.
8.7. NONLINEAR ANALYSIS BY SIMULATION* 513

8.7 Nonlinear analysis by simulation*


8.7.1 Steady state vs. stationary solution⋆
8.7.2 Sensitivity analysis⋆
8.7.3 Stochastic systems and discretization⋆

8.8 Zero dynamics+


8.8.1 What is zero dynamics?
Consider a system with input u ∈ Rnu , output y ∈ Rny , and input-output mapping
given by the DAE model
dx
dt
= f (x, z, u; θ)
0 = g (x, z, u; θ) (8.39)
y = h (x, z, u; θ) .

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

In the case of an ODE model, the zero dynamics is defined by

dx
= f (x, u; θ)
dt
y = g (x, u; θ)

where requiring y ≡ 0 leads to the DAE

dx
= f (x, u; θ)
dt
0 = g (x, u; θ) .

In the case of an LTI model, we have

dx
= Ax + Bu
dt
y = Cx + Du
514 CHAPTER 8. MODEL ANALYSIS*

where A, B, C, D are constant coefficient matrices of appropriate dimensions. The


zero dynamics is given by requiring y ≡ 0, i.e.,
dx
= Ax + Bu
dt
0 = Cx + Du.
Again, we simply have a linear DAE defining the zero dynamics.
Because the zero dynamics is given by DAEs, DAE solvers such as Modelica are
capable of solving them.

8.8.2 Interpretation of zero dynamics


What is the meaning of the zero dynamics? We observe that the idea of the zero
dynamics is to seek u such that y ≡ 0. If we are free to choose u at will, u is normally
denoted a control variable. In control, the idea is to choose u such that the output y
gets a certain quality. The quality y ≡ 0 can be considered a requirement of perfect
control, i.e., that the controlled system gets infinitely high “bandwidth”. Thus, the
zero dynamics can be interpreted as finding u such that we have perfect control.
It turns out that the zero dynamics can be either stable or unstable. If the
zero dynamics is stable, this simply means that it is possible to construct a control
systems such that perfect control is possible.
On the other hand: if the zero dynamics is unstable, this means that although we
may be able to choose u such that y ≡ 0, something within the system is unstable,
and sooner or later the system will be “destroyed”. In other words: with unstable zero
dynamics, it is not in practice possible to achieve perfect control. However, unstable
zero dynamics does, of course, not mean that the system can not be controlled. It
simply means that there will be bandwidth limitations as to how fast the system
can be controlled.
What if we don’t want the output to be zero, but instead want y to follow some
reference signal r? In that case, perfect control implies (nonlinear ODE model)
y ≡ r⇒y − r ≡ 0.
We can thus simply introduce a modified output
ey = y − r,
and pose the zero dynamics DAE as ey ≡ 0:
dx
= f (x, u; θ)
dt
0 = g (x, u; θ) − r.
Here, the idea of perfect control described as a system with infinite bandwidth
becomes clear: since we can choose r freely, e.g., r = ra sin (ωt), stable zero dynamics
ensures that we can find the necessary u such that ey ≡ 0 even when ω → ∞.
The concept of zero dynamics is important in the analysis of control systems.
It should be noted that even if the zero dynamics is stable, the resulting necessary
control input u may not be achievable in practice due to saturation/constraints in
the input u.
8.9. SINGULAR PERTURBATION+,⋆ 515

8.8.3 Nonlinear feedback control


Examples

8.9 Singular perturbation+,⋆


• Linear example
• Nonlinear example
• Reaction invariants?

8.10 Transfer function models


8.10.1 Laplace transform
Let the Laplace transform of x (t) be denoted by X (s). The Laplace transform
operator Lt (·) wrt. t is defined as
ˆ ∞
X (s) = Lt (x (t)) , exp (−st) x (t) dt.
0

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

4. The Initial Value Theorem states that


lim x (t) = lim sX (s) .
t→0+ s→∞

5. The Laplace transform of the Heaviside function19 H0 (t) is


1
Lt (H0 (t)) = .
s
19
The Heaviside function Hτ (t) is defined as
{
0, t<τ
Hτ (t) = .
1, t≥τ
516 CHAPTER 8. MODEL ANALYSIS*

For proofs, see standard university level books on mathematics.


It may be of interest to consider limt→0+ (dx/dt), i.e., an extension of the initial
value theorem. Furthermore, it may be of interest to consider how the Laplace
transform operates on functions of two variables, e.g., x (t, z).
Corollary 8.1. Laplace transform extensions

1. From Theorem 8.1, it follows that


( )
dx dx ( ( ))
lim+ = lim sLt = lim s2 X (s) − sx t = 0+ .
t→0 dt s→∞ dt s→∞

( ∂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).

8.10.2 Transfer function. Poles and zeros


We consider the system
dx
= Ax + Bu
dt
y = Cx + Du
8.10. TRANSFER FUNCTION MODELS 517

where x ∈ Rnx , u ∈ Rnu , y ∈ Rny , and where A, B, C, and D are compatible


matrices with real elements. If we Laplace transform the system, we find
( )
sx (s) − x t = 0+ = Ax (s) + Bu (s)

( )
(sI − A) x (s) = x t = 0+ + Bu (s)

( )
x (s) = (sI − A)−1 x t = 0+ + (sI − A)−1 Bu (s) .
We can thus express y (s) = Cx (s) + Du (s) as
( )
y (s) = C (sI − A)−1 x t = 0+ + C (sI − A)−1 Bu (s) + Du (s) .
It is common to introduce
Hu (s) = C (sI − A)−1 B + D
Hx0 (s) = C (sI − A)−1
such that ( )
y (s) = Hu (s) u (s) + Hx0 (s) x t = 0+ .
Definition 8.5. Transfer function.
Consider the linear, time invariant system
dx
= Ax + Bu
dt
y = Cx + Du.
The transfer function from u (s) to y (s) is defined as Hu (s) = C (sI − A)−1 B + D,
while the transfer function from initial state x (t = 0+ ) to y (s) is defined as Hx0 (s) =
C (sI − A)−1 . If the transfer function is a matrix, it is common to denote it a transfer
matrix.
Example 8.12. Transfer function
For the system in Example 8.10.1, we find the transfer function Hu (s) from input
u (s) to state x (s) as
1
Hu (s) = − ,
4 (s + 10)
while the transfer function from initial state to the state is
1
Hx0 (s) = .
s + 10
N
We notice that we (of course!) are free to use any symbol to denote the transfer
function. It is common to use both H (s) and G (s). Normally, upper case letters are
used when we have a transfer matrix (i.e., H (s) or G (s)), while lower case letters
are used for scalar transfer functions (i.e., h (s) or g (s)).
From the examples above, we notice that the elements of the transfer function
typically consist of a fraction where numerator and denominator are polynomials in
s.
518 CHAPTER 8. MODEL ANALYSIS*

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.

8.10.3 Standard forms of the poles and zeros


8.10.3.1 Overview
We consider scalar transfer functions where the numerator and denominator are
polynomials in s. Both numerator polynomial n (s) and denominator polynomial
d (s) have real coefficients, and it follows that their roots are either real, or appear in
complex conjugate pairs. The roots of n (s) are denoted the zeros of the system, and
the roots of d (s) are denoted poles of the system. The roots of the pole polynomial
d (s) are a subset of the eigenvalues of the underlying A-matrix.

8.10.3.2 Poles: time constants and resonance frequencies


Assume that d (s) is a second order polynomial where the roots are complex conju-
gate such that we can write the roots as
s = α ± jβ,
8.10. TRANSFER FUNCTION MODELS 519

where j = −1, i.e., j 2 = −1.20 Here, the system is stable if α < 0, since ℜs = α.
We then have that the polynomial can be written as

d (s) = K (s − α − jβ) (s − α + jβ)

where K is some constant. Thus


d (s)
= (s − α − jβ) (s − α + jβ) = s2 − 2αs + α2 + β 2 .
K
It is common to write such products of complex conjugate poles as

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

while a complex conjugate pole pair λc,i is given as



λc,i = −ζi ω0,i ± jω0,i 1 − ζi2 .

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*

An alternative standard form for d (s) is


( ( )2 )
s s
d (s) = K ′ (1 + T1 s) × · · · × (1 + Tnr s) × 1 + 2ζ1 + × ···
ω0,1 ω0,1
( ( )2 )
s s
··· × 1 + 2ζnc + .
ω0,nc ω0,nc

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.

8.10.3.3 Zeros and zero dynamics


A similar factorization is possible for the numerator polynomial n (s); in that case
Ti and ω0,i have other interpretations. It turns out that the “time constants” and
“resonance frequencies” of the zeros are identical to the time constants and resonance
frequencies of the zero dynamics of the system. In other words, if we assume the
LTI system
dx
= Ax + Bu
dt
y = Cx + Dx,

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.

8.11 Cases: Solution of linear models


Example 8.14. Diagonalizable system
Assume that we have the following linear system:
 7 
−4 33 ( )
dx  4
x + 1 u
=
dt 0
11
− 29 | {z }
| 4
{z 4
} B
A

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

Note that we have purely real eigenvalues. We thus have


( ) ( )
−10 0 −1 3
Λ= , R= .
0 1 1 1

Then ( )
exp (−10t) 0
exp (Λt) = ,
0 exp (t)
and exp (At) is given as

exp (At) = R exp (Λt) R−1



( )( )( )−1
−1 3 exp (−10t) 0 −1 3
exp (At) =
1 1 0 exp (t) 1 1

 1 −10t

4
e + 34 et − 34 e−10t + 43 et
exp (At) =  .
− 14 e−10t + 1 t
4
e 3 −10t
4
e + 1 t
4
e

Similarly

exp (−At) = R exp (−Λt) R−1



 1 10t 3 −t 3 −t

4
e + 4
e − 3 10t
4
e + 4
e
exp (−At) =  .
1 −t 1 −t
−4e + 4e
1 10t 3 10t
4
e + 4e
( ´t )
Then we find x (t) = exp (At) x (0) + 0 exp (−At) Bu (t) dt as follows:
 1 −10t

4
e + 34 et − 34 e−10t + 34 et
x (t) =   x (0)
− 14 e−10t + 14 et 3 −10t
e + 14 et
 1 10t 3 −t 4

ˆ t e + 4e − 34 e10t + 43 e−t ( )
4 1
+   u (t) dt
0
0 − 14 e10t + 14 e−t 3 10t
4
e + 1 −t
4
e

 1 −10t

4
e + 34 et − 34 e−10t + 34 et
x (t) =   x (0)
− 14 e−10t + 14 et 3 −10t
e + 1 t
e
 1 10t 3 −t 4 4
ˆ t 4
e + 4e
+   u (t) dt.
1 −t
0 − 41 e10t + 4
e

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*

Solutions with constant input u(t) = 1


x1
10
x2

−5

−10

0.0 0.1 0.2 0.3 0.4 0.5 0.6


t

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:

Let u (t) = 1. This gives:

   
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

The temporal evolution of x (t) is shown in Fig. 8.7.


8.11. CASES: SOLUTION OF LINEAR MODELS 523

Solutions with input u(t) = sin( 10t )

1.00 x1
x2
0.75

0.50

0.25

0.00

−0.25

−0.50

−0.75

−1.00

0.0 0.1 0.2 0.3 0.4 0.5 0.6


t

(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*

if we change the definition of exp (At) to



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

The eigenvalues and eigenvectors of the A matrix are:


( ) ( )
1 1
λ1 = 0, r1 = ; λ2 = 0, r2 = .
0 0

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

For this particular case, it turns out that


( )0 ( )
0 0 t 1 0
(At) = = =I
0 0 0 1
( )1 ( )
1 0 t 0 t
(At) = =
0 0 0 0
( )2 ( )
2 0 t 0 0
(At) = = .
0 0 0 0

Consequently, ∀i ≥ 2 : (At)i = 0, and in this special case we thus have that


∞ ∑
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

We then find that


ˆ t
y (t) = exp (At) y (0) + exp (−At) Bu (t) dt
0

( ) ˆ t( )( )
1 t 1 −t 0
y (t) = y (0) + u (t) dt
0 1 0 0 1 1

( ) ˆ t( )
1 t −t
y (t) = y (0) + u (t) dt.
0 1 0 1

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

The temporal evolution


( 1 ) of x (t) and v (t) are shown in Fig. 8.9.
Let u (t) = sin 10 t . This gives
( )( ) ˆ t( ) ( )
1 t 1 −t 1
y (t) = + · sin t dt
0 1 −1 0 1 10

 (1 ) (1 ) 
( ) −100 sin t + 10t cos 10 t
1−t 10
y (t) = + (1 )

−1
−10 cos 10 t + 10

 (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*

Solutions, non-diagonalizable system with constant input u(t) = 1


5
x
v

−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 .

Solutions, non-diagonalizable system with input u(t) = sin( 10t )

−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

8.12 Cases: Stability of linear systems


Example 8.18. Stable subsystem of diagonalizable system

The diagonal system of Example 8.11 can be written as


( ) ( 1 )
dz −10 0 −4
= z+ 1 u.
dt 0 1
| {z } | {z }
4
Λ R−1 B

Let us consider the subsystem


dz1 1
= −10z1 − u.
dt 4
Assume that we consider the case u = u∗ = 1, and that z1∗ = −1/40. Let z1δ denote
the deviation between z1 and z1∗ , and let uδ denote the deviation between u and u∗ .
Since ( 1) ( )
dz1∗ ∗ 1 ∗ d − 40 −1 1
= −10z1 − u ⇔ = −10 − · 1 ⇔ 0 = 0,
dt 4 dt 40 4
we see that the pair (z1∗ , u∗ ) fulfills the differential equation. Furthermore,
( )
dz1 dz1∗ 1 ∗ 1 ∗
− = −10z1 − u − −10z1 − u
dt dt 4 4

d δ 1
z1 = −10z1δ − uδ .
dt 4
Since we can choose the input variable, assume that we choose uδ = 0. Then the
model for z1δ becomes

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

Example 8.19. Unstable subsystem of diagonalizable system

In Example 8.12, we saw an example of a stable system. Let us consider the


other part of the system:
dz2 1
= z2 + u.
dt 4
( )
We now choose as (operating) point (z2∗ , u∗ ) = − 14 , 1 , which fulfills the model:
( )
d 1 1 1
− = − + · 1 ⇔ 0 = 0.
dt 4 4 4
528 CHAPTER 8. MODEL ANALYSIS*

The deviation between z2 and z2∗ is described by

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.

Example 8.20. System with stable and unstable subsystems

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

Here, one of the decoupled systems is stable:


dz1 1
= −10z1 − u,
dt 4
while the other system is stable:
dz2 1
= z2 + u.
dt 4
Because the original state x is a linear combination of the decoupled states z:

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

As Example 8.12 shows, a system is unstable if at least one eigenvalue is positive.


At the same time, we see that the system is stable if every eigenvalue is negative.
What remains to study, is to consider systems with complex eigenvalues, and
systems with eigenvalue zero. The case of complex eigenvalues is illustrated in the
pendulum example of Example 8.13. But let us consider systems with eigenvalue
equal to zero.
Example 8.21. System with zero eigenvalue
We first consider the system
dx
= u,
dt
where x ∈ R. Furthermore, we consider the operating point (x∗ , u∗ ) = (0, 0), which
satisfies the model. The deviation from the operating point is then described by
d δ
x = uδ ,
dt
which has the solution ˆ t
δ δ
x (t) = x (0) + uδ (t) dt.
0
δ δ δ
By choosing u (t) = 0, we see that x (t) = x (0), which means that we can ensure
that xδ (t) has an arbitrarily small value for all t ≥ 0 by choosing xδ (0) sufficiently
small.
Thus, this system with a zero eigenvalue is stable according to our definition. N
Example 8.22. System with singular eigenvector matrix
Let us next consider the system in Example 8.11. The system is given by
( ) ( )( ) ( )
d x 0 1 x 0
= + u,
dt v 0 0 v 1
| {z } | {z } | {z }
y A B

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*

Here, we see that with v δ (0) ̸= 0, xδ (t) will go towards −∞ or +∞ when t → ∞,


irrespective of how small v δ (0) is. Thus, the state x (the position) will be unstable.
At the same time, we see that in fact v is stable.
However, we will always talk about stability or instability of a system, and not
of single states. This means that the system at hand in fact is unstable. N

8.13 Cases: Analysis of nonlinear systems


Example 8.23. Linear analysis of driven tank

In Example 4.8.2, a model of a tank was developed:


dm
= ṁi − ṁe
dt
m = ρV
V = Ah

h
ṁe = K ,

which can be reduced to an ODE for the level h:
dh 1 ( ′
√ )
= ṁi − K h = f (h, ṁi )
dt ρA
where
K
K′ = √ .

Here, h is the state, and ṁi is the input variable. We assume that ρA and K ′
are constants. Let ṁ∗i be a constant operating point for the input variable. The
constant operating point h∗ for the state (height), is then found as follows

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

In the same way


∂f (h, ṁi )
B= ,
∂ ṁi ∗
where
∂f (h, ṁi ) 1
= .
∂ ṁi ρA
We thus have
dhδ 1 (K ′ )2 δ 1 δ
=− ∗
h + ṁ .
dt 2ρA ṁi ρA i
For scalar systems, the eigenvalue of “matrix” A is identical to the matrix, i.e., the
eigenvalue for our system is
1 (K ′ )2
λ=− .
2ρA ṁ∗i
When ṁ∗i is positive, we find that the operating point is stable, and the time constant
of the system is
1 2ρA ∗
T = =
2
ṁ .
− 1

(K )

(K ′ )2 i
2ρA ṁi
N
Example 8.24. Linear analysis of pendulum
A model of a pendulum is given in Eqs. 6.3–6.4 p. 225:

= ω = f1 (α, ω, F )
dt
dω g F
= − sin α + sin α = f2 (α, ω, F ) .
dt ℓ mℓ
Here, the state is x = (α, ω), and F is an input variable. A natural choice of oper-
ating point is the case when the pendulum is hanging at rest, pointing downwards.
Then α∗ = 0 and ω ∗ = 0. Assume that we seek F ∗ such that the model is fulfilled.
We find
dω ∗ g F∗
= 0 = − sin α∗ + sin α∗ .
dt ℓ mℓ
Since sin 0 = 0, we see that the model is fulfilled for any force F ∗ . Let us for
simplicity choose F ∗ = 0. The linearized model is then
dxδ
= Axδ + BF δ .
dt
Here
 
 ∂f1 ∂f1
 ∂ω ∂ω
∂α ∂ω
∂f ∂α ∂ω  
= = ( ) ( ) 
∂x  g F g F 
∂f2
∂α
∂f2
∂ω

∂α
− sin α + sin α ∂
∂ω
− sin α + sin α
ℓ mℓ ℓ mℓ

 
0 1
∂f
= .
∂x
− gm−F
mℓ
cos α 0
532 CHAPTER 8. MODEL ANALYSIS*

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 ∗

This time, the eigenvalues are found as


{√ √ }
g g
λ (A) = ,− ,
ℓ ℓ
and we see that the system is unstable because one of the eigenvalues has a positive
real part. This instability is hardly unexpected! N
Example 8.25. Stability of heated tank
In Section 7.10.5, the model of a heated liquid tank was reduced to ODE form
as

dh ṁi − Ke υ hς
h

= = 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̃ ◦

( The state)vector consists of x = (cA , cB , T ), while the vector of inputs is u =


V̇ , cA,i , Ti , Q̇ . Let us see how we can linearize this system using the jacobian
method of Matrix objects in SymPy. Consider the Python script linearizeReactor.py:

1 from sympy import exp , Symbol , Matrix


2 # State symbols
3 cA = Symbol ( ’ cA ’)
4 cB = Symbol ( ’ cB ’)
5 T = Symbol ( ’T ’)
6 # Input symbols
7 Vd = Symbol ( ’ Vd ’)
8 cAi = Symbol ( ’ cAi ’)
9 Ti = Symbol ( ’ Ti ’)
10 Qd = Symbol ( ’ Qd ’)
11 # Various variables
12 r = Symbol ( ’r ’)
13 dHr = Symbol ( ’ dHr ’)
14 Cp = Symbol ( ’ Cp ’)
15 # Parameters
16 a = Symbol ( ’a ’)
17 V = Symbol ( ’V ’)
18 cpA = Symbol ( ’ cpA ’)
8.13. CASES: ANALYSIS OF NONLINEAR SYSTEMS 535

19 cpB = Symbol ( ’ cpB ’)


20 cpS = Symbol ( ’ cpS ’)
21 rho = Symbol ( ’ rho ’)
22 k0 = Symbol ( ’ k0 ’)
23 EdR = Symbol ( ’ EdR ’)
24 Tdd = Symbol ( ’ Tdd ’)
25 dHrdd = Symbol ( ’ dHrdd ’)
26 # Equations
27 r = k0 * exp ( - EdR / T ) * cA ** a
28 dHr = dHrdd + ( cpB - a * cpA ) *( T - Tdd )
29 Cp = cA * V * cpA + cB * V * cpB + rho * V * cpS
30 # Vector field
31 f = Matrix ([( cAi * Vd - cA * Vd - a * r * V ) /V , ( - cB * Vd + r * V ) /V , \
32 (( cAi * cpA + rho * cpS ) * Vd *( Ti - T ) +( - dHr ) * r * V + Qd ) / Cp ])
33 # States
34 x = Matrix ([ cA , cB , T ])
35 # Inputs
36 u = Matrix ([ Vd , cAi , Ti , Qd ])
37 # Jacobians
38 A = f . jacobian ( x )
39 B = f . jacobian ( u )
40 # Printing A , B
41 print ( ’ - - - - - - - - - - - - - ’)
42 print ( ’A ␣ = ␣ ’)
43 print ( A )
44 print ( ’ - - - - - - - - - - - - - ’)
45 print ( ’B ␣ = ␣ ’)
46 print ( B )
47 print ( ’ - - - - - - - - - - - - - ’)
When running this script, the response is:23

1 In [1]: % run " C :\ Users \ berntl \...\ PyModelica \ linearizeReactor


. py "
2 -------------
3 A =
4 Matrix ([[( - V * a **2* cA ** a * k0 * exp ( - EdR / T ) / cA - Vd ) /V , 0 , \
5 - EdR * a * cA ** a * k0 * exp ( - EdR / T ) / T **2] ,
6 [ a * cA ** a * k0 * exp ( - EdR / T ) / cA , - Vd /V , EdR * cA ** a * k0 * exp ( - EdR / T ) / T
**2] ,
7 [ V * a * cA ** a * k0 *( - dHrdd - ( T - Tdd ) *( - a * cpA + cpB ) ) * exp ( - EdR / T )
/( cA *( V * cA * cpA \
8 + V * cB * cpB + V * cpS * rho ) ) \
9 - V * cpA *( Qd + V * cA ** a * k0 *( - dHrdd - ( T - Tdd ) *( - a * cpA +
cpB ) ) * exp ( - EdR / T ) \
10 + Vd *( - T + Ti ) *( cAi * cpA + cpS * rho ) ) /( V * cA * cpA + V * cB * cpB
+ V * cpS * rho ) **2 ,
23
Symbol \ implies continuation, i.e., the following lines should really continue on the same line,
and is used when there is no natural breaks such as comma , etc.
536 CHAPTER 8. MODEL ANALYSIS*

11 -V * cpB *( Qd + V * cA ** a * k0 *( - dHrdd - ( T - Tdd ) *( - a * cpA + cpB


) ) * exp ( - EdR / T ) \
12 + Vd *( - T + Ti ) *( cAi * cpA + cpS * rho ) ) /( V * cA * cpA + V * cB * cpB
+ V * cpS * rho ) **2 ,
13 ( EdR * V * cA ** a * k0 *( - dHrdd - ( T - Tdd ) *( - a * cpA + cpB ) ) * exp ( -
EdR / T ) / T **2 \
14 + V * cA ** a * k0 *( a * cpA - cpB ) * exp ( - EdR / T ) - Vd *( cAi * cpA +
cpS * rho ) ) /( V * cA * cpA \
15 + V * cB * cpB + V * cpS * rho ) ]])
16 -------------
17 B =
18 Matrix ([[( - cA + cAi ) /V , Vd /V , 0 , 0] ,
19 [ - cB /V , 0 , 0 , 0] ,
20 [( - T + Ti ) *( cAi * cpA + cpS * rho ) /( V * cA * cpA + V * cB * cpB + V * cpS *
rho ) ,
21 Vd * cpA *( - T + Ti ) /( V * cA * cpA + V * cB * cpB + V * cpS * rho ) ,
22 Vd *( cAi * cpA + cpS * rho ) /( V * cA * cpA + V * cB * cpB + V * cpS *
rho ) ,
23 1/( V * cA * cpA + V * cB * cpB + V * cpS * rho ) ]])
24 -------------

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

8.14 Cases: Analysis by simulation⋆


• Modelica vs. Python, choice of time step, scalar vs. multivariable, steady vs.
stationary, linear approximation vs. nonlinear solution, sensitivity, stochastic,
Monte Carlo

8.15 Cases: Zero dynamics⋆


• linear, nonlinear, stable, unstable, analysis, simulation, inverse response

8.16 Cases: Transfer function models


Example 8.27. Multivariable system

We consider the system


( ) ( )
dx − 74 33
4
1
= x+ u.
dt 11
− 29 0
| 4
{z 4
} | {z }
A B
8.16. CASES: TRANSFER FUNCTION MODELS 537

We find
( )
dx
Lt = Lt (Ax + Bu)
dt

( )
sx (s) − x t = 0 +
= Ax (s) + Bu (s) .

We want to find an expression for x (s). When operating on matrix products, we


remember that matrix multiplication is non-commutative, i.e., Ax (s) ̸= x (s) A —
x (s) A doesn’t even exist according to the standard matrix multiplication rule. We
find ( )
sx (s) − Ax (s) = x t = 0+ + Bu (s) .
Here, sx (s) = sIx (s), and sx (s) − Ax (s) = (sI − A) x (s). We thus find that
( )
x (s) = (sI − A)−1 x t = 0+ + (sI − A)−1 Bu (s) .

If we want to, we can insert numerical values for A and B, e.g.,


  −1  
( ) − 47 33 1 4s+29
4 (s+10)(s−1)
33
4(s+10)(s−1)
1 0 4
(sI − A)−1 = s −  = 
0 1 11
4
− 29
4
11
4(s+10)(s−1)
1 4s+7
4 (s+10)(s−1)
   1 4s+29 
1 4s+29
4 (s+10)(s−1)
33
4(s+10)(s−1)
( ) 4 (s+10)(s−1)
1
(sI − A)−1 B =   = ,
11 1 4s+7 0 11
4(s+10)(s−1) 4 (s+10)(s−1) 4(s+10)(s−1)

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)

Example 8.28. Transfer matrix

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*

Example 8.29. Transfer function for PDE


Let us consider the partial differential equation
∂T ∂T
= −v ,
∂t ∂x
where T = T (t, x), v is constant, and T (t, x = 0) = Ti (t) is known. We seek
TL (t) = T (t, x = L). Here, influent temperature Ti (t) is the input (u (t)), while
effluent temperature TL (t) is the output, y (t).
We find
ˆ ∞
Lt (T (t, x)) = exp (−st) T (t, x) dt = T (s, x)
( ) 0
∂T ( )
Lt = sT (s, x) − T t = 0+ , x
∂t
( )
∂T dT (s, x)
Lt = .
∂x dx
Thus
( ) ( )
∂T ∂T
Lt = Lt −v
∂t ∂x

( ) dT (s, x)
sT (s, x) − T t = 0+ , x = −v
dx

dT (s, x) s 1 ( )
= − T (s, x) + T t = 0+ , x .
dx v v
This is a linear differential equation with x as free variable, and we find
( s )( ˆ x (s ) 1 ( )
)
T (s, x) = exp − x T (s, x = 0) + +
exp x T t = 0 , x dx .
v 0 v v
More specifically
( s )( ˆ L (s ) 1 ( )
)
TL (s) = T (s, L) = exp − L T (s, x = 0) + +
exp x T t = 0 , x dx .
v 0 v v
If T (t = 0+ , x) = T0 (x) = T0 = constant, and with T (s, x = 0) = Ti (s), we find
( s )( 1
ˆ L (s ) )
TL (s) = exp − L Ti (s) + T0 exp x dx
v v 0 v

( s )( s
eL v − 1
)
TL (s) = exp − L Ti (s) + T0
v s

( s ) ( )
1 − exp − vs L
TL (s) = exp − L Ti (s) + T0 .
v s
8.16. CASES: TRANSFER FUNCTION MODELS 539

Here, we see that the transfer function


( from) the input/influent temperature Ti (s)
to the output temperature TL is exp − Lv s , while the transfer function from initial
1−exp(− vs L)
time temperature T0 to the output temperature TL is s
. N
Example 8.30. Transfer function model vs. time behavior
We consider a transfer function of form
1
h (s) = K,
1 + Ts
where we assume that T > 0. Output y can then be written as

y (s) = h (s) u (s) ,

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*

When u (t) is a unit step function at t = 0, we find


( )( ˆ t ( ) )
t t K
y (t) = exp − y (0) + exp · 1dt
T T T
( ) 0
t ( ( t ))
= exp − y (0) + K e − 1 .
T
T

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

It follows that the time it takes before yℓ (t) = y (∞) is:

yℓ (t∞ ) = y (∞)


dy
y (0) + t∞ = y (∞)
dt t=0

y (∞) − y (0) K −0
t∞ =
dy
= K = T.
dt t=0 T

Finally, it is of interest to consider the value of y (t) at t = t∞ :


( ( ))
T
y (t∞ ) = y (T ) = K 1 − exp − ≈ 0.632K.
T

Example 8.31. Zero dynamics and zero in transfer function


8.16. CASES: TRANSFER FUNCTION MODELS 541

We consider the system


 
− 74 33 ( )
dx  4
x + 1
= u
dt 0
11
− 29 | {z }
| 4 {z 4 } B
( )A
y= 1 0 x.
| {z }
C

In Example 8.16, we found the transfer function from u to x as


 1 4s+29 
4 (s+10)(s−1)
x (s) =   u (s) .
11
4(s+10)(s−1)

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.

From the output equation y = Cx = 0, we have that

x1 = 0,

while the state space model dx/dt = Ax + Bu leads to


dx1 7 33
= − x1 + x2 + u
dt 4 4
dx2 11 29
= x1 − x2 .
dt 4 4
By combining these 3 equations, we find the differential equation for x2 :
dx2 11 29 29
= x1 − x2 = − x2 ,
dt 4 |{z} 4 4
=0

and from the differential equation for x1 , we have


=0
z}|{
d x1 7 33 −33
= − x1 + x2 + u ⇔ u = x2 .
dt 4 |{z} 4 4
=0
542 CHAPTER 8. MODEL ANALYSIS*

The zero dynamics is thus given by the system

dx2 29
= − x2
dt 4
−33
u= x2 .
4

It follows that the eigenvalue of the zero dynamics is λ = − 29


4
, which is identical to
the zero we have found. N

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; θ)

where the “conserved” quantities/balanced extensive variables such as total mass,


species mass/species amount (in mole), momentum, and energy are states (x), while
additional algebraic variables (z) are related to the states via constitutive/material
laws such as Equations of State, definitions of intensive variables, transport laws,
etc. Normally, one should choose a minimal number of states; these states play the
rôle of a memory of the history of the system. Thus, initial values of the states must
be known in order to solve the model, in addition to inputs (u), model parameters
(θ) and — of course — the model equations themselves. Natural laws are time
invariant, thus models are normally time invariant, i.e., with no explicit dependence
of time. However, reducing the model order via solving analytically parts of the
model leads to explicit time dependence and hence time variant models.
In order to allow for existence and uniqueness of solution of models, some re-
strictions must be put on the models. Obviously, the number of unknowns and the
number of equations must be equal. Suppose that we consider the structured DAE
reduced to ODE with insertion of the time functions u (t),

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; θ)

is invincible to the outputs (which — by definition — are identically equal to zero).


For the zero dynamics, the inputs u become algebraic variables in the problem.
In control theory, transfer function models are often used to describe systems.
Transfer function models can be developed by Laplace transforming LTI approxima-
tions of nonlinear models around an operating point. Transfer function models for
544 CHAPTER 8. MODEL ANALYSIS*

finite dimensional systems can be written as a polynomial fraction in the Laplace


variable s. Infinite dimensional linear system models, i.e., models involving par-
tial differential equations, will still have transfer function models, but their form
are more complex, and will involve time delays or more complicated elements. For
transfer function models involving polynomials in s in numerator and denominator,
the numerator polynomial is known as the zero polynomial while the denominator
polynomial is known as the pole polynomial. The poles of the system are the roots
of the pole (denominator) polynomial, and is equal to (a subset of) the eigenval-
ues of the system. The zeros of the system are the roots of the zero (numerator)
polynomial, and the zeros equal the eigenvalues of the zero dynamics of the system.
A number of examples are given to illustrate the various concepts.

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.

• It is particularly interesting to also compare the cases when V̇c is increased


13%, 14%, and 15% from the nominal value. Again, let the change in V̇c take
place at t = 1 min. Comment the results. N

Problem 8.4. [Solution E.29 p. 622] Controlled reactor analysis.


546 CHAPTER 8. MODEL ANALYSIS*

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

Problem 8.5. [Solution E.30 p. 623] Water pump system analysis.


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 ( )
= Ap · V̇i − Ff
dt mp
8.19. PROBLEMS 547

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

• Analyze the stability of the system.

• 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

The proportional controller (P-controller) has the following form:

u = us − Kp (hr − h) ,

where us was chosen as us = 0.


548 CHAPTER 8. MODEL ANALYSIS*
( )
With a given operating point specified by states (h∗ , T ∗ ) and inputs V̇i∗ , h∗r , Ti∗ , Th∗ ,
a linear approximation can be written as:
( δ ) ( )( δ )
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δ
• Analyze the stability of the system. (Hint: for a triangular matrix, the eigen-
values are found on the main diagonal.)
• 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̇i , hr , Ti , Th . Compare your sketch to the relevant figure in the
solution of Problem 7.8 (Solution E.24 p. 614). N
Problem 8.7. [Solution E.32 p. 626] Linearization of controlled reactor.
The system that is considered in Problem 5.1, and simulated in Problem 5.2, 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 = Kc (cA,r − cA )
uℓ = Kℓ (h − hr ) .
• Assume
( that an operating ) point with fixed (time invariant) values (h∗ , c∗A ) and
V̇ic∗ , c∗A,i , p∗A , h∗r , c∗A,r is given, and find a linear approximation

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 A and B are the relevant Jacobian matrices.


8.19. PROBLEMS 549

• Assume that the inputs are given as:


( ) ( )
V̇ic∗ , c∗A,i , p∗A , h∗r , c∗A,r = 50, 2, 3, 2, 10−2 ,

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

Problem 8.8. [Solution E.33 p. 626] Linearization of water pump system.

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 ,

and A and B are the relevant Jacobian matrices.

• Assume that the inputs are given as:


( )
∗ ∗
V̇e , hr = (2, 55) ,
( )
and find the steady state value of the states, i.e., find h∗ , V̇i∗ .
550 CHAPTER 8. MODEL ANALYSIS*

• 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

The proportional controller (P-controller) has the following form:

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 A and B are the relevant Jacobian matrices.


• Assume that the inputs are given as:
( )
∗ ∗ ∗ ∗
V̇i , hr , Ti , Th = (50, 2, 300, 450) ,

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.1 Learning goals*


...

9.2 Calibration*
• Information/data, DAQ, outlier detection, smoothing, filtering, prediction,
prefiltering.

• Least squares, Prediction error methods, Bayes methods

• Identifiability analysis. Theoretic analysis. Numeric analysis.

• Experiment design.

• Model uncertainty. Parameter uncertainty.

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

Models in a Wider Perspective†

10.1 Data and models


Empiricism is data or knowledge which is based on sensor information and/or ex-
perience from experiments. As a philosophical doctrine, empiricism claims that all
knowledge is derived from sensor information in a wide sense. Adjective empirical
implies something based upon experience and observations alone, without using sci-
entific method or theory. But empirical also implies something that is verifiable by
experience or experiment. Empiricism as a doctrine is to be contrasted with ratio-
nalism, which holds that reason alone is the source of knowledge and is independent
of experience. The line between these two philosophies is blurred, though, and im-
portant historical rationalists such as Descartes1 and Leibniz2 were also advocates
of the empirical “scientific method”.
Prior to Newton3 , many people had empiric information about apples falling
from apple trees. Some researchers had attempted to time rocks and feathers falling
from towers, and had set up tabular (empirical) data of how long time it took for
objects to fall a certain distance.
What Newton was able to do, was to distill this information, and extract some
very general laws about the movement of objects — into Newton’s laws of motion.
Newton’s work was key in developing the scientific field of mechanics, and initiated
work that is still on-going on formulating general laws about how our world operates.
Modern science takes ideas from both empiricism and rationalism in that the
source of knowledge is empirical data, but that it is possible to reason/rational-
ize over extracted models and develop new results from these. Still, Leonardo da
Vinci4 stated that “If you find from your own experience that something is a fact
and it contradicts what some authority has written down, then you must abandon
the authority and base your reasoning on your own findings.” da Vinci’s view has
been extended, and the current thinking is that any valid scientific theory must be
falsifiable. What this means is that any valid scientific theory must be formulated
in such a way that the theory can be tested against empirical data, and if there is a
1
René Descartes (1596–1650), known, e.g., for the Cartesian product of sets.
2
Gottfried Wilhelm (von) Leibniz (1646–1716), known, e.g., for developing differential calculus.
3
Sir Isaac Newton (1642–1726/27)
4
Renaissance artist and scientist (1452–1519).

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.

10.2 Mechanistic models


One of Newton’s many important contributions to science was the idea of extracting
information from empirical data and construct relatively simple yet general laws of
how the world operates. Such laws can be said to describe the underlying mecha-
nisms that drive the world; in short a mechanistic law.
This course has emphasized the use of such mechanistic laws and how they can
be used to develop models that describe the dynamics of systems. By dynamics is
meant how the inertia of systems influence the transient behavior of systems upon
changes in inputs to the systems. A common experience during election years is how
politicians promise instant changes if they win the election; then practice shows that
changes in society are very slow, if there are changes at all. The reason is, of course,
that society normally is has inertia, with rather slow dynamics.
To this end, the mechanistic laws that have been introduced are based on the
conservation of mass, with subsequent species balance to handle matter with specific
attributes, the momentum balance — which is a generalization of Newton’s law, and
the general energy balance with specialization into the thermal energy balance. With
these mechanistic laws as the starting point, we have added algebraic relations in
order to relate mass, momentum and energy with other quantities. These algebraic
relations are partially based on simple case studies which have been generalized via
some empirical relations (typical for heat transfer expressions, friction, etc.), but
are also based on macroscopic steady state descriptions of complex systems (e.g.,
thermodynamics).
In summary, we have denoted this combination of mechanistic laws with semi-
mechanistic algebraic relations by mechanistic models.

10.3 Empirical models


Even though the ideas behind mechanistic models represented a big breakthrough
in science, there are phenomena which are difficult to describe by a mechanistic
model. Furthermore, developing mechanistic models have traditionally required
a relatively good command of physics and applied mathematics. Also, we have
seen that developing mechanistic models requires some training in choosing suitable
simplifying assumptions in order to end up with a model that balances accuracy vs.
usefulness.
An alternative to mechanistic models is to step back to the time prior to Newton
with the tables of empirical data, e.g., over how long time it takes for rocks and
feathers to fall a certain distance from a tower. If we are mainly interested in rocks
and have sufficient tabular data, why not simply use an interpolation function? Or:
10.3. EMPIRICAL MODELS 555

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

where ci is a certain constant, and ϕi (x) is a chosen function. The mathematical


field of functional analysis deals with what
∑n requirements we must put on functions
ϕi (x) so that when n → ∞, the sum i=1 ci ϕi (x) will converge to f (x). If this
convergence is achieved, functions ϕi (x) are known as basis functions. Basis func-
tions are not unique; a number of choices may be used. A simple example of such
an approximation is the Fourier series, where the basis functions are sine and co-
sine functions with gradually increasing frequency. As we know, the Fourier series
converges when n → ∞ provided that f (x) is a periodic function, and provided
that f (x) is continuous. We could easily invent other basis functions, which may
be useful in other cases, e.g., ϕi (x) = xi−1 , in other words:

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†

A problem with the above idea of model approximation/model fitting is that


if we have too many basis functions, i.e., n is too large, then in practice we also
attempt to describe noise/model uncertainties/model errors. Because of this, in
practice it is necessary to use some linear algebra ideas from regression analysis
to limit n or the selection of basis functions. Examples of such ideas relate to
something known as Singular Value Decomposition (SVD), Principal Component
Analysis/Regression (PCA/PCR), Partial Least Squares (PLS), and other matrix
conditioning techniques. These techniques try to improve the so-called condition of
matrix Φ by restricting the size of n and/or introducing new basis vectors which are
combinations of ϕi (x).
An important quality of basis functions ϕi (x) is their so-called support. The
support of a function is essentially the range for which the function is different from
zero. Thus, ϕi (x) = xi−1 has global support, meaning that the value of ϕi (x) is
different from zero practically everywhere. Another example of a basis function
could be ϕi (x) = Hxi (x) − Hxi +∆x (x) which is zero for x < xi , then jumps up to 1,
before it jumps down to zero again at x > xi + ∆x5 : this function only differs from
zero for x ∈ [xi , xi + ∆x] — and is therefore ( said to )have local support. We could
(x−µi )2
also envision a basis function ϕi (x) = exp − σ2 — a Gaussian type function
i
as in the Normal distribution: this function really has global support, but because
it drops from 1 to zero exponentially fast, it is said to have exponential support. It
should be said that in neural networks, in addition to tuning the parameters ci for
model fitting, it is also common to tune µi and σi . If we tune either µi or σi or both,
in addition to ci , the model fitting problem is not any longer linear in the unknowns,
and the Normal Equation above is not any longer valid.
A number of basis functions have been developed. In general, the best basis
functions have local support or exponential support, whereas basis functions with
global support often lead to numerical problems. One strategy is based on using
wavelets, where one basis function is the mother basis function, and all the other
basis functions (the daughter basis functions) represent scaling and/or translation
of the mother basis function. A simple wavelet mother function would be akin to
the combination of Heaviside functions above. Another popular basis function is the
Gaussian type above, which is used in radial basis neural networks.
These empirical type models based on model fitting/model approximation can
easily be extended multivarible systems with multiple inputs and outputs, and also
to discrete time dynamics systems of type
( )
yt = F yt−1 , . . . , yt−ny , ut , ut−1 , . . . , ut−nu
where we use approximation theory to find F (·).
Empirical models have the advantage that they are easy to program in computer
systems, require relatively little knowledge of physics, and that model building can
to a large degree be automated. Their disadvantages are that they include a large
number of model parameters, that it is necessary to have available data that really
represents the behavior of the system before the model can be built, and that each
new system requires a refitting of the model — hence, a model fitted to falling rocks
can not be used for falling feathers.
5
Hξ (x) is the Heaviside function.
10.4. “BIG DATA” AND MODELS 557

10.4 “Big data” and models


The last couple of decades have seen the development of standardized instrument
interfaces6 , which have made it dramatically easier to connect sensors to data logging
systems. With the explosion in inexpensive and fast storage systems, internet, cloud
storage, IoT7 , etc., there is virtually no limit to what information can be stored. This
availability of information is known as “big data”.
With the rapid growth in available data, there is a renewed interest in empiri-
cal model development since this can to a large degree be automated without too
deep knowledge of the underlying physics. Simultaneously, there has been impor-
tant development in methods for handling large amounts of data (“big data”) with
empirical models. Building/training of empirical models from such (“big”) data is
known as machine learning.
It is too early to say how important machine learning will be wrt. dynamic
models of industrial systems. One potential problem is that in order to have a
useful model, the data that is used for “learning” the model must be informative.
One example: if we want to model empirically how heat exchanger performance is
reduced by fouling8 in order to plan for heat exchanger maintenance, our data must
include several/many instances of reduced performance by fouling — if not, they
are not sufficiently informative to build such a model. A mechanistic model, on the
other hand, requires less data in order to develop such a maintenance model because
the model includes the mechanism of fouling.
Another problem with empirical models, is that they must be individually fitted
to data for each case: even if we consider two identical production plants, it is
not straightforward to fit a reactor model from data in one plant, and re-use this
model in the other, identical plant. This implies that empirical models are not
well suited to what-if analysis or simulation studies prior to building a system.
Of course, in principle, it may be possible to also develop empirical models that
can be used for simulation studies. It is possible to develop an empirical model
of a distillation column where the packing material is parameterized, the number
of trays is parameterized, the diameter and height is parameterized, etc., but this
would lead to an explosive growth in the required data and in the number of model
parameters.
Because of this, it is of interest to also consider how “big data” can be used
in conjunction with mechanistic models, or in hybrid mechanistic-empirical models.
One problem with mechanistic models is to decide on the complexity level and
introduce the right type of simplifying assumptions. Can we assume perfect mixing,
or is a distributed model needed? Can we assume ideal solution for the mixture of
6
One example: the OPC standard. Prior to these standardized interfaces, each sensor (NS
sensors) required a unique interface to each type of data logger (NL logger types), thus a total
of NS · NL interfaces were required. With standardized interfaces, each instrument only needs an
interface to the standard (e.g., OPC) interface, and each data logger (typically a PC) needed a
single interface to the standard (e.g., OPC), thus a total of NS + NL interfaces are required.
7
IoT = the Internet of Things, sensor that can be connected wirelessly to cloud storage data
bases, can include some local data analysis, etc.
8
Fouling is the gradual growth of particle/dirt on heat exchanger surfaces, which increases heat
transfer resistance.
558 CHAPTER 10. MODELS IN A WIDER PERSPECTIVE†

substances, or do we need a more advanced thermodynamic model? One way around


this could be to start with investigating an empirical model, introduce improved
matrix conditioning in the Normal Equation to find the “right” model order, etc.
Based on this prior study, we can get an idea of how detailed a model needs to be,
i.e., what information we actually can see from the available data. We could also
consider developing a relatively simple mechanistic model which holds the essential
behavior of the system, and then use empirical models to describe deviations between
available data and the simple, mechanistic model.
Finally, “big data” obviously holds the possibility to allow us to really fine-tune
parameters in a mechanistic model, and get a solid statistical description of the
model quality. Also, we “big data”, we are in a good position to use hypothesis
testing to choose among a set of (mechanistic) models. It is important to emphasize
that even with an imperfect model, the model may still be useful if we can use the
model to achieve better operation of a system than without a model.

10.5 Use of models


Mechanistic models have many uses; the same is true about empirical models, but
to a lesser degree. Assuming that we have tuned/fitted/calibrated our model to
experimental (“big”?) data, the following are some uses of models.

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.

2. Estimation/smart sensors [on-line]: because there are limits to what can be


measured by standard sensors (temperature, pressure, flow rates, concentra-
tion, pH, sound samples, images, video, etc.), it is of interest to combine
dynamic models with (“big”?) data.
10.5. USE OF MODELS 559

(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

3. Monitoring [on-line]: by specifying a measure of “quality” for a product (e.g.,


expected value and standard deviation), we can combine a sensor/smart-
sensor/estimator for the system and use this to show how the quality varies
with time. This gives a good overview of whether a product is within specifi-
cations, or if we produce out-of-spec products. Monitoring can also be used to
keep track of the fouling layer thickness in a heat exchanger (or other proper-
ties related to maintenance), to inform the operators about when maintenance
is due.

4. Control [on-line]: control is the act of manipulating inputs to a system in


order to influence the quality of the product/operation. In feedback control,
measurements from sensors or estimators are compared to some desired value,
and the difference is used to adjust the system inputs. In feed forward con-
trol, known or estimated external influences (set points, “known” disturbances,
etc.) are used to adjust the system inputs. Feed forward control is purely based
on the model, hence is sensitive to model imperfections. Feedback control, on
the other hand, may use a model to varying degree, but always includes mea-
surements from the real system, and these observations from the real system
makes feedback control less sensitive to model imperfections.

(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†

holds information about the temperature, the operator processes this


information, and based on experience, adjusts the fuel feed. Observations
has caused a change in the input; this is feedback. The special thing is
that the feedback loop is closed manually.
(b) Automatic feedback control: suppose a camera takes color snapshots of
the flames in a combustion process, the image data are analyzed to find
the color content, this information is fed back electronically to the control
algorithm which computes a new fuel feed and that finally, this informa-
tion is sent to the actuator which adjusts the actual fuel feed. Obviously,
this is also feedback control, but this time, it is done automatically.
(c) Traditional feedback controllers are often so-called proportional controllers
(P controllers), or sometimes proportional + integral controllers (PI con-
trollers). More advanced controllers use PID controllers (D = derivative
action). Various methods for selecting parameters in these controllers (P,
PI, PID) exist, so-called tuning rules. These tuning rules include very
basic ideas of the models of the system under consideration.
(d) Model based controllers often start by finding a model, then specifying
the desired performance, and finally the necessary inputs are computed
by “inverting” the combination of model and performance/on-line data
to give model based feedback control.
i. “Loop shaping” controllers design the feedback control algorithm in
such a way that the closed loop system gets a desired “shape”. Typi-
cal examples include nonlinear decoupling controllers, back-stepping
controllers, etc. “Loop shaping” controllers are very efficient algo-
rithms, but often require a certain mathematical sophistication in
order to understand them. These types of controllers are used ex-
tensively in robot and vehicle (car, ship, aeroplane) control.
ii. Controllers based on on-line optimization attempt to optimize the
performance over a certain future time range based on model predic-
tions. Examples are minimum variance controllers, model predictive
control algorithms (MPC), etc. MPC controllers automatically com-
bine feedback and feed forward control, and is used extensively in
the industry.
Model based controllers often need to know the state of a system. These
controllers must therefore often be combined with state estimators.

10.6 Modeling in the future


These lecture notes discuss modeling of dynamic systems. The concept modeling =
making model. Thus, modeling of dynamic systems implies to develop models for
dynamic systems. Some people use the phrase “dynamic modeling”; this phrase is
not really meaningful — unless one refers to a dynamic way of developing models
(whatever that would mean).
10.6. MODELING IN THE FUTURE 561

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∗

A.1 Running case studies


Case studies in the lectures notes can be run on a server within Jupyter notebooks.
To log into the server, open your web browser, and go to: https://jupyter.dwe.
no. Use password usn to log in, and select the course code for the modeling course
(FM1015). There is one Jupyter notebook for each of Chapters 4–8.

A.2 Coding models on your own


In order to code and run your own models, see ? which is available in pdf format
via a link in LMS system Canvas.

563
564 APPENDIX A. COMPUTER SIMULATION∗
Appendix B

Basic differentiation

B.1 Definitions and basic rules


Definition B.1. If y = f (x) and x is scalar and real (x ∈ R), the derivative of y
wrt. x is given as:
dy f (x + ∆x) − f (x)
= lim .
dx ∆x→0 ∆x
Note that this is valid even if y = (y1 , . . . , ym ), as long as each element in y are real
variables. N
The total differential dy is then given as:
dy df (x)
dy = dx = dx.
dx dx
Proposition B.1. Differentiation is a linear operation. Thus, when x is a scalar
and k1 , k2 are (real) constants:
d dy1 dy2
(k1 y1 + k2 y2 ) = k1 + k2 .
dx dx dx
Furthermore: ( )
d dy d2 y
= 2,
dx dx dx
or more generally: ( )
di dj y d(i+j) y
= ,
dxi dxj dx(i+j)
where i and j are integers.
Often, we use the notation y (n) (x) for the nth derivative:
dn y
y (x) , n .
(n)
dx
Definition B.2. More generally, if x = (x1 , . . . , xn ) where each element in x are
real variables, the partial derivative of y wrt. xi is:
∂y f (x1 , . . . , xi−1 , xi + ∆xi , xi+1 , . . . , xn ) − f (x) f (x + ei ∆xi ) − f (x)
= lim = lim ,
∂xi ∆xi →0 ∆xi ∆xi →0 ∆xi
where ei is the standard basis vector of the same shape as x:1 the elements of ei
1
If x is a column vector, then ei is a column vector. If x is a row vector, then ei is a row vector.

565
566 APPENDIX B. BASIC DIFFERENTIATION

have value 0, except element i which has value 1. N

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

When x ∈ Rn and y ∈ Rm and y is a column vector, we can introduce the


definition:2  ∂y1 
· · · ∂x
∂y1
∂y ( ∂y ) ∂x1
 .. .. ..  .
n

, ∂x1 · · · ∂x
∂y
=  . . . 
∂x n
∂ym
∂x1
··· ∂ym
∂xn

Proposition B.3. With x ∈ Rn and y ∈ Rm , we have:

∂y (v) ∂y ∂v
= · ,
∂x ∂v ∂x
where · denotes ordinary matrix multiplication.

Proof. Assuming that v ∈ Rp , we find:


 ∂y1   ∑p ∂y1 ∂vj ∑p ∂y1 ∂vj

· · · ∂y1 ···
∂y  ∂x. 1 . ∂xn
  j=1 ∂vj ∂x1 j=1 ∂vj ∂xn

=  .. .. .
..  =  .. ... .. .
∂x  ∑ .
∑p
. 
∂ym
∂x1
· · · ∂ym
∂xn
p ∂ym ∂vj
j=1 ∂v ∂x ··· ∂ym ∂vj
j=1 ∂vj ∂xn
j 1

At the same time:


 ∂y1    ∑ ∑p 
∂y1 ∂vj ∂y1 ∂vj
··· ∂y1 ∂v1
··· ∂v1 p
···
..   
∂v1 ∂vp ∂x1 ∂xn j=1 ∂vj ∂x1 j=1 ∂vj ∂xn
∂y ∂v    ..
. = .
· = .. ... .. .. .. ... ..
. .  . .  ∑ . . 
∂v ∂x ∑p
∂ym
∂v1
··· ∂ym
∂vp
∂vp
∂x1
··· ∂vp
∂xn
p ∂ym ∂vj
j=1 ∂vj ∂x1 ··· ∂ym ∂vj
j=1 ∂vj ∂xn

Because the expression for ∂y


∂x
is identical to the expression for ∂y
∂v
· ∂x
∂v
, we have that
∂y
∂x
= ∂y · ∂v .
∂v ∂x

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

where i and j are integers.


We can now introduce the following definition for a multivariable function y (x)
where x ∈ Rn and y ∈ Rm :
 i 
∂ i y1
∂ y1
· · ·
∂ iy ( ∂iy )  ∂x1 i i

.. 
∂xn
, · · · ∂iy
=  .. . . . 
∂xi ∂x i
1 ∂xi
n  . . .
i i
∂ ym
∂xi
· · · ∂∂xyim
1 n

Proposition B.6. We find:


( )
∂i ∂j y ∂ (i+j) y
= .
∂xi ∂xj ∂x(i+j)
3 ∂y
If ∂x is a row vector, it is impossible to take the matrix product between matrix ∂x and row
∂y
vector ∂x, the way ∂x is defined.
568 APPENDIX B. BASIC DIFFERENTIATION

B.2 Some useful rules for differentiation


Proposition B.7. Consider the case: y (x) = u (x) v (x). Then we find:

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

B.3 The derivative of some common functions


Let us consider the case: y = xr , where x is scalar. We then find:
dy d r
= (x ) = r · xr−1 .
dx dx
When y = sin x, we find:
dy d
= (sin x) = cos x.
dx dx
Similarly, with y = cos x:
dy d
= (cos x) = − sin x.
dx dx
With y = exp x, we find:
dy d
= (exp x) = exp x.
dx dx
With y = ln x, we find:
dy d 1
= (ln x) = .
dx dx x
Appendix C

Thermophysical data

C.1 Critical point properties of pure species


Table C.1 gives selected critical point properties of pure species.

C.2 Pure species heat capacity data


Table C.2 gives examples of data for the molar heat capacity Poling et al. (2001).

C.3 Standard State Molar Thermodynamic Quan-


tities
Table C.3 gives additional molar enthalpy data for the species Poling et al. (2001).
We consider the data for the four species + Nitrogen as in Table C.4.

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*

D.1 Chapter: Quantities and their Use


...under construction...

D.2 Chapter: Models and Model Solution


Some mathematical exercises on differentiation.
Solution D.1. We find the derivatives dy/dx, d2 y/dx2 , and d3 y/dx3 when y (x) is
given as follows:

• 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

• y = exp (k/x). Introduce u = k/x:


dy dy du d (exp u) d (kx−1 ) ( ) k
= = = exp u · −kx−2 = − 2 exp (k/x) .
dx du dx du dx x
• y = sin x:
dy d sin x
= = cos x.
dx dx
N

573
574 APPENDIX D. SOLUTION TO EXERCISES*

Solution D.2. Find dz/dx when z (y, dy/dx) is given as follows:

• z = (dy/dx): ( )
dz d dy d2 y
= = .
dx dx dx dx2

• z = (dy/dx)2 . Introduce u = dy/dx:


( ) ( dy )
dz dz du du2 du du dy d dx dy d2 y
= = = 2u =2 =2 · .
dx du dx du dx dx dx dx dx dx2

• z = 1 − (dy/dx)2 . Introduce u = dy/dx, v = 1 − u2 :

dz dz dv du d v d (1 − u2 ) d (dy/dx) 1 d2 y dy/dx d2 y
= = · · = √ (−2u) 2 = − √ .
dx dv du dx dv du dx 2 v dx dx2
1 − (dy/dx)2
( )
• z = 1/ 1 − (dy/dx)2 . Introduce u = dy/dx, v = 1 − u2 :

dz dz dv du d (1/v) d (1 − u2 ) du 1 d (dy/dx) 2dy/dx d2 y


= = = − 2 (−2u) =( )2 2 .
dx dv du dx dv du dx v dx 1 − (dy/dx)2 dx

• z = (y · dy/dx). Introduce u = dy/dx:


( )2
dz d dy du dy d2 y
= (y · u) = u +y = +y .
dx dx dx dx dx dx2
N

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 = (x + y)2 , y = sin x. Introduce u = x + y.


( )
∂z ∂ ( 2 ) ∂u2 ∂u ∂ ∂y
= u = = 2u (x + y) = 2u 1 + = 2 (x + sin x) (1 + cos x) .
∂x ∂x ∂u ∂x ∂x ∂x
576 APPENDIX D. SOLUTION TO EXERCISES*

• z = y 2 , and y (x) is unknown:

∂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.

• z = (x + y)2 , and y (x) is unknown. Introduce u = x + y:


( ) ( )
∂z ∂u2 ∂u ∂u ∂ (x + y) ∂y dy
= = 2u = 2u = 2 (x + y) 1 + = 2 (x + y) 1 + .
∂x ∂u ∂x ∂x ∂x ∂x dx
N

Some exercises with differentiation applied to physics.

Solution D.5. Let mass m = ρV where density ρ and volume V both vary with
time t.

• Find an expression for dm/dt:

dm d dρ dV
= (ρV ) = V +ρ .
dt dt dt dt
N

Solution D.6. In the continuity equation

∂ρ ∂
= − (ρv) ,
∂t ∂x
both density ρ and velocity v are functions of (t, x):

• Expand the expression ∂ (ρv) /∂x:

∂ ∂ρ ∂v
(ρv) = v +ρ .
∂x ∂x ∂x
Thus:
∂ρ ∂ ∂ρ ∂v
= − (ρv) = −v −ρ .
∂t ∂x ∂x ∂x
N

Solution D.7. A chemical reaction rate is given as

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:

dr d ( 2) dk dc2 dcA dk dcA


= kcA = c2A +k A = c2A + k2cA .
dt dt dt dcA dt dt dt

Here, with u = −E/ (RT ), v = 1/T :


( )
dk d d exp u du E dv E dv dT
= (k0 exp u) = k0 = k0 exp u − = −k0 exp u
dt dt du dt R dt R dT dt
( ) ( )
E 1 dT E E dT
= −k0 exp u − 2 = k0 2
exp − .
R T dt RT RT dt
N

Solution D.8. Let H̃ (molar enthalpy) be given as:


( )
H̃ T, p, Ṽ = H̃ ig (T ) + (z − 1) RT

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

Here, H̃ ig only depends on T (indicated by writing H̃ ig (T )), independently of


p. We choose to introduce the definition

ig
∂ H̃ dH̃ ig
c̃ig , = ,
p
∂T dT
p
578 APPENDIX D. SOLUTION TO EXERCISES*

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

Since Ṽ is only a function of T when p is constant, we have


( )
dṼ (T ) R Ṽ − b Ṽ 3
= .
dT RT Ṽ 3 − 2aṼ 2 + 4aṼ b − 2ab2
Finally, we need to compute ∂z/∂T |p . We get
( ) ( )
∂z ∂ pṼ p d Ṽ (T )
= =
∂T p ∂T RT R dT T
p

( )
∂z p Ṽ 1 dṼ (T )
= − 2+
∂T p R T T dT

 ( ) 
− 3
∂z p Ṽ 1 R Ṽ b Ṽ
= − 2 + .
∂T p R T T RT Ṽ 3 − 2aṼ 2 + 4aṼ b − 2ab2
D.2. CHAPTER: MODELS AND MODEL SOLUTION 579

We can write this expression as


 ( ) 
− 2
∂z pṼ  R Ṽ b Ṽ 1
= − .
∂T p RT RT Ṽ 3 − 2aṼ 2 + 4aṼ b − 2ab2 T

Notice that we should have found the same expression if we instead had written
( )

∂z ∂ Ṽ a Ṽ
= −
∂T p ∂T Ṽ − b Ṽ 2 RT
p

— this is so since we have already used that RTpṼ


= ṼṼ−b − Ṽa2 RT

.

∂z
Also notice that in the expression for ∂T p
above, we can not choose p, T
and, Ṽ freely! We have to require that for a specifically given constant p, we
have to relate Ṽ and T by p = ṼRT −b
− Ṽa2 . Thus, if we specify p and T , we
need to solve this equation
for Ṽ in order to find the correct value of Ṽ in
∂z
the expression for ∂T p
. It is easily found that finding Ṽ from p = ṼRT
−b
− Ṽa2
amounts to solving a cubic equation in Ṽ .
Finally, we find that

∂ H̃ ∂z
= c̃p + RT
ig
+ R (z − 1)
∂T ∂T p
p

 ( )  ( )
R Ṽ − b Ṽ 2 1 pṼ
c̃p = c̃ig
p + pṼ
 − +R −1
RT Ṽ 3 − 2aṼ 2 + 4aṼ b − 2ab2 T RT


( )
pṼ Ṽ − b Ṽ 2
c̃p = c̃ig
p +R − R,
RT Ṽ 3 − 2aṼ 2 + 4aṼ b − 2ab2

where we have that for given p and T , we need to solve p = RT


Ṽ −b
− a
Ṽ 2
wrt. Ṽ
to compute c̃p .

• 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 Ṽ

Similarly to the development in the previous problem, we find that with Ṽ


constant, dṼ = 0:
( )
∂p ∂p ∂ RT a ∂p
dp = dT + dṼ = − dT + dṼ
∂T ∂ Ṽ ∂T Ṽ − b Ṽ 2 ∂ Ṽ |{z}
=0

R
dp = dT .
Ṽ − b
Since p is a function of both T and Ṽ , we find that

∂p R
= .
∂T Ṽ Ṽ − b Ṽ

Finally, we need to compute ∂z/∂T |Ṽ . We get


( )
∂z ∂ pṼ ∂ ( p ) Ṽ
= =
∂T Ṽ ∂T RT ∂T T Ṽ R


( ) ( )
∂z 1 ∂p p Ṽ 1 Ṽ pṼ
= − 2 = − .
∂T Ṽ T ∂T T Ṽ R T Ṽ − b RT
D.2. CHAPTER: MODELS AND MODEL SOLUTION 581

∂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

Inserting these relationships into the expression for c̃v , we find:


( )
Ṽ a Ṽ a 1 R
c̃v = c̃ig
v +R − + − Ṽ
Ṽ − b Ṽ 2 RT Ṽ T Ṽ − b

c̃v = c̃ig
v.

This result may seem surprising; however it is correct, see, e.g., Kondepudi &
Prigogine (1998) p. 160. N

Some exercises on integration follow.


´
Solution D.9. With y (x) given as below, what is y (x) dx?

• 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.

where the incomplete Gamma function Γ (n, x) is defined as


ˆ ∞
Γ (n, x) = tn−1 e−t dt,
x

then using the WolframAlpha1 app gives the solution in Fig. D.2, which is
valid for x > 0.

We could alternatively write the solution as


ˆ ( ) ( ) ( )
k k k
exp dx = x exp + k · Ei 1, − .
x x x
This example illustrates that it is often difficult to solve integrals analytically.2
• y = sin x: ˆ ˆ
ydx = sin xdx = − cos x + c.
N
´1
Solution D.10. With y (x) given as below, what is 0
y (x) dx — if it exists?

• 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

Integration is important when working with physical models.

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

Note that here it is understood that P0 , P (x)|x=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

Again, it is understood that P0 , P (x)|x=0 , while P̃0 = P0 − kx20 /2 where x0


may be different from zero. N

Solution D.12. With F = −µv where v is velocity:


584 APPENDIX D. SOLUTION TO EXERCISES*

• Can you find a potential energy P representing F ?


No, that is not possible! The force is only allowed to be a function of posi-
tion/location in order to be explained by a potential. N

Solution D.13. Suppose that dH̃ = c̃p dT , then


ˆ ˆ T
dH̃ = c̃p dT .
T0

• The integration boundaries for the first integral are:


ˆ H̃(T ) ˆ T
dH̃ = c̃p dT .
H̃(0) T0

Solution D.14. Given dH̃ ig ≡ c̃ig


p (T ) dT , where

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

D.3 Chapter: Mass conservation


...under construction...

D.4 Chapter: Species balance


...under construction...

D.5 Chapter: Momentum balance


Solution D.15. [Exercise 6.1 p. 334] Mean velocity in laminar flow.
D.5. CHAPTER: MOMENTUM BALANCE 585

The average velocity is found as


´ ´ 2π ´ R ´R
vdA v (r) rdθdr 2π v (r) rdθdr
⟨v⟩ = ´A = 0 ´ 2π0 ´ R = 0
2
A
dA
0
rdθdr
0
2π R2

´R ( ( r )2 )
0
vm 1 − R
rdθdr 2vm R2 vm
⟨v⟩ = 2 = = .
R2 2
R 4 2
N

Solution D.16. [Exercise 6.2 p. 335] Darcy friction factor for laminar flow.

Darcy’s friction factor is given as

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

The Darcy friction factor then is3

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 ,

586 APPENDIX D. SOLUTION TO EXERCISES*

Figure D.2: Evaluation of “Blasius” integral using WolframAlpha.


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

see Fig. D.2.


NRe vτ
With R̄ = 2 ⟨v⟩
, we then have
( )1/7
⟨v⟩ NRe vτ 49
=2·k·
vτ 2 ⟨v⟩ 120

( )7/8
⟨v⟩ 98k 1/8
= · NRe .
vτ 120 · 21/7

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

Figure D.3: Evaluation of “Prandtl” integral using Maple 2016.


and setting x = ,
we have

ˆ 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⟩

+ 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

D.6 Chapter: Energy balance


...under construction...

D.7 Chapter: Model analysis


...under construction...
588 APPENDIX D. SOLUTION TO EXERCISES*

D.8 Chapter: Model calibration


...under construction...
Appendix E

Solution to Problems*

E.1 Chapter: Quantities and their Use


Solution E.1. [Problem 2.1 p. 40] Units:

Find examples of old units of length from your own culture/background.... N

Solution E.2. [Problem 2.2 p. 40] Pressure loss:

Consider a pressure loss... N

Solution E.3. [Problem 2.3 p. 41] For an agitated liquid volume:

... N

Solution E.4. [Problem 2.4 p. 41] Turbo-machines.

... N

Solution E.5. [Problem 2.5 p. 42] Simplifying PDE to ODE.

... N

E.2 Chapter: Models and Model Solution


...under construction...

E.3 Chapter: Mass conservation


Solution E.6. [Problem 4.1 p. 137] Continuity equation:

...under construction... N

589
590 APPENDIX E. SOLUTION TO PROBLEMS*

E.4 Chapter: Species balance


Solution E.7. [Problem 5.1 p. 211] For the controlled reactor:
• We use the total mass balance to find a model of the level h:
dm
= ṁi − ṁe .
dt
Here:
m = ρAh
ṁi = ρV̇ic + ρV̇iA
ṁe = ρV̇e ,
where A is the cross sectional area. Furthermore:

A pA − pa
V̇i = Kv,A uc
ρ

p − pa
V̇e = Kv,e uℓ ,
ρ
where
uc = uc,s + Kc (cA,r − cA )
uℓ = uℓ,s + Kℓ (h − hr )
p = pa + ρgh.
Inserting these expressions into the mass balance gives:
d ( )
(ρAh) = ρ V̇ic + V̇iA − V̇e .
dt
Assuming that ρ and A are constants wrt. time t gives:
dh 1( c )
= V̇i + V̇iA − V̇e
dt A

[ √ ]
dh 1 pA − pa √
= V̇ + Kv,A (uc,s + Kc (cA,r − cA ))
c
− Kv,e (uℓ,s + Kℓ (h − hr )) gh .
dt A i ρ
To find a dynamic equation for cA , we need to use the mole balance for com-
ponent A:
dnA
= ṅAi − ṅAo + ṅAg ,
dt
where
nA = cA Ah
ṅAi = V̇iA cA,i
ṅAo = V̇e cA
ṅAg = rA V = −kcA Ah.
E.4. CHAPTER: SPECIES BALANCE 591

Inserting these expressions into the mole balance yields:


d
(cA Ah) = V̇iA cA,i − V̇e cA − kcA Ah.
dt
Here, A is a constant, while cA and h varies with time:
dcA dh 1( A )
h + cA = V̇i cA,i − V̇e cA − kcA h.
dt dt A
Inserting the previous expression for dh/dt leads to:
dcA 1( c ) 1( A )
h + cA V̇i + V̇iA − V̇e = V̇i cA,i − V̇e cA − kcA h.
dt A A
The terms relating to flow out of the system (both lhs. and rhs.) cancel, and
we can simplify the expression to:
dcA 1( c ) 1
h + cA V̇i + V̇i = V̇iA cA,i − kcA h,
A
dt A A
or
dcA 1 A 1 ( A )
= V̇i cA,i − V̇i + V̇ic cA − kcA .
dt Ah Ah
Here, we can insert the expressions for V̇iA and V̇e .

• The model is now:


[ √ ]
dh 1 pA − pa √
= V̇ + Kv,A (uc,s + Kc (cA,r − cA ))
c
− Kv,e (uℓ,s + Kℓ (h − hr )) gh
dt A i ρ

dcA 1 pA − pa
= cA,i Kv,A (uc,s + Kc (cA,r − cA ))
dt Ah ρ
( √ )
1 pA − pa
− Kv,A (uc,s + Kc (cA,r − cA )) + V̇i cA − kcA .
c
Ah ρ
Alternatively, we may write the model as:
dh 1( c )
= V̇ + V̇i − V̇e
A
dt A i
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 ) .
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) .

Furthermore, we need to know the time development of the input variables u,


u (t) for t ≥ 0. The concrete meaning of this is that we need to know

V̇ic (t) , cA,r (t) , hr (t) , pa (t) , pA (t) , cA,i (t) .

In addition, we need to know the parameters θ = (A, k, Kv,A , Kv,e , ρ, Kc , Kℓ ).

• 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

This model is also in state space form. However, if we eliminate v by inserting


v = dx/dt, we find:

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

Solution E.8. [Problem 5.2 p. 212] Controlled reactor simulation.


The model is repeated below:
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
E.4. CHAPTER: SPECIES BALANCE 593

+2.10999 Controlled reactor


0.000010

0.000009
h [m]

0.000008

0.0 0.5 1.0 1.5 2.0 2.5 3.0


0.015
cA [mol/m3]

0.010

0.005

0.0 0.5 1.0 1.5 2.0 2.5 3.0


time t [h]

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*

16 parameter Real A = 10 " Vessel surface area , m2 ";


17 parameter Real k = 1 " Reaction rate constant , 1/ h ";
18 parameter Real KvA = 1 " Species A feed valve constant ";
19 parameter Real Kve = KvA " Effluent valve constant ";
20 parameter Real pA = 3 " Feed pressure species A , bar ";
21 parameter Real pa = 1 " Atmospheric pressure , bar ";
22 parameter Real rho = 1 e3 " Density of liquid , kg / L ";
23 parameter Real Kc = 100 " Concentration controller gain ";
24 parameter Real KL = Kc " Level controller gain ";
25 parameter Real ucs = 0 " steady state concentration
control input ";
26 parameter Real uLs = 0 " steady state level control input
";
27 // Controller referance values
28 parameter Real hr = 2 " Level reference , m ";
29 parameter Real cAr = 1e -2 " Concentration reference for
species A , mol / m3 ";
30 // Initial state parameters
31 parameter Real h0 = 2.11 " Initial level , m ";
32 parameter Real cA0 = 1.5 e -2 " Initial concentration of A ,
mol / m3 ";
33 // Declaring variables
34 // -- states
35 Real h ( start = h0 , fixed = true ) ;
36 Real cA ( start = cA0 , fixed = true ) ;
37 Real VdiA " Influent flow rate of species A , m3 / h ";
38 Real Vde " Effluent flow rate , m3 / h ";
39 Real uc " Concentration control input ";
40 Real uL " Level control input ";
41 // -- input flow
42 Real Vdic = 50 " Influent flow of water / catalyst , m3 / h ";
43 Real cAi " Influent concentration of A , mol / m3 ";
44 // Equations constituting the model
45 equation
46 // Concentration input
47 cAi = if time < 1 then 5 else 2;
48 // Controllers
49 uc = max (0 , ucs + Kc *( cAr - cA ) ) ;
50 uL = max (0 , uLs + KL *( h - hr ) ) ;
51 // Valves
52 VdiA = KvA * sqrt (( pA - pa ) / rho ) ;
53 Vde = Kve * uL * sqrt ( g * h ) ;
54 // Differential equations
55 der ( h ) = ( Vdic + VdiA - Vde ) / A ;
56 der ( cA ) = VdiA * cAi /( A * h ) - ( VdiA + Vdic ) * cA /( A * h ) - k * cA ;
57 end M odControll e d R e a c t o r ;
58 // End package
59 end Sp e c i es C o n t r o l l e d R e a ct o r ;

N
E.5. CHAPTER: MOMENTUM BALANCE 595

E.5 Chapter: Momentum balance


Solution E.9. [Problem 6.1 p. 336] Fanning friction factor across laminar-turbulence
gap.

To be developed. N

Solution E.10. [Problem 6.2 p. 336] Shock damper model.

We consider the system in Fig. 6.47 p. 336.


With friction force Fd = −µv, µ ≥ 0:

• When F = 0, the energy balance leads to:


dE
= Fd v = −µv 2 .
dt
– When factor µ = 0 or when the velocity v = 0, the energy of the mass-
spring system is constant: dE/dt = 0.
– When µ > 0 and the system is moving (v ̸= 0), we see that µv 2 > 0.
Thus, the energy of the system must decrease: dE/dt is negative.

• 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!

• From the energy balance, we have


dE
(Fd + F ) v =
dt

dv
(Fd + F ) v = mv + mgv + k (x − x0 ) v.
dt
596 APPENDIX E. SOLUTION TO PROBLEMS*

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.

The second element is


θ2 θ3 u1
f2 (y, u; θ) = − y2 − (y1 − θ4 ) − θ5 +
θ1 θ1 θ1
µ k F
= − v − (x − x0 ) − g + .
m m m

• 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

– All parameters θ, i.e., (m, µ, k, x0 , g),


– The initial state, y (t0 ) where t0 is the initial time instance, i.e., we need
to know (x (t0 ) , v (t0 )),
– The input variable u (t) in the interval t ∈ [t0 , t1 ], i.e., we need to know
F (t). N
Solution E.11. [Problem 6.3p. 337] Shock damper model from Euler Lagrange
equation.
To be developed. N
Solution E.12. [Problem 6.4p. 337] Shock damper analysis.
To be developed. N
Solution E.13. [Problem 6.5 p. 338] Model of water pump system.
For the water pipe system in Fig. 6.48 p. 338, we have:
1. The mass balance for the vessel is:
dm
= ṁi − ṁe .
dt
Here:

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 .

Inserting these expressions into the momentum balance/Newtons law gives:


( )
d V̇i
m = Ap (p − p0 ) − cV̇i2
dt Ap

dV̇i Ap Ap
= Ap (p − p0 ) − c V̇i2 .
dt m m

3. With the pump characteristic, we have


( )
∆p = p − p0 = u c1 − c2 V̇i2 .

Inserting this into the model for V̇i leads to:

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) ,

we can write the total model of the system as


dh 1( )
= V̇i − V̇e
dt A
dV̇i 1 ( ) c 2
= V̇i u c1 − c2 V̇i2 − V̇
dt ρL ρL i
E.5. CHAPTER: MOMENTUM BALANCE 599

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

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*

It follows that Ap ∆p must have the same unit as Ff , i.e.:

{Ff } tonne m h−2


{∆p} = = = tonne m−1 h−2 .
{Ap } m2
Again, this is an uncommon unit for pressure, but a perfectly valid unit.
So far, we have looked at the required units. Let us see what units we end up with
for Ff and ∆p if we use the units specified in the given table. In particle, we observe
that one unit of pressure is Pa = N/m2 = kg sm2 /m2 , thus pressure involves mass
(kg), length (m), and time (s). We observe from the numeric values given in the
Problems that the applied mass unit appears to be tonne, the applied length unit
is m, and the applied time unit is h. Thus, if the model equations are compatible,
the simplest thing is probably to convert the occurrences of unit bar to some unit
involving tonne, m and h.
• We can express the unit of bar as follows:

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:

{c} = bar h2 m−4



tonne m−1 h−2
{κp c} = {κp } · {c} = .bar h2 m−4 = tonne m−5 ,
bar
which is the desired unit.
The model is solved by running Modelica model ModWaterPump in package MomentumWaterPump.
The results are shown in Fig. E.2.
Modelica package MomentumWaterPump is given below.

1 package Mome ntumWa terPum p


2 // Package for simulating water pump system
3 // author : Bernt Lie
4 // University of South - Eastern Norway
5 // May 15 , 2017
6 //
7 model ModWaterPump
8 // Model of water pump system , problems for momentum
balance
9 // author : Bernt Lie
E.5. CHAPTER: MOMENTUM BALANCE 601

Controlled water pumping


1.94

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 .

10 // University of South - Eastern Norway


11 // May 15 , 2017
12 //
13 // Parameters
14 parameter Real A = 10 " Cross sectional area of vessel , m2
";
15 parameter Real Ap = 1e -2 " cross sectional area of pipe ,
m2 ";
16 parameter Real mp = 10 " Mass of liquid in pipe , tonne ";
17 parameter Real kappa_p = 1 e2 *3600^2 " Conversion from bar
to tonne - based pressure ";
18 parameter Real c = 8e -6* kappa_p " Friction coefficient ,
bar . h2 / m4 ";
19 parameter Real c1 = 3e -4* kappa_p " Constant in pump
characteristic , bar ";
20 parameter Real c2 = 4e -8* kappa_p " Constant in pump
characteristic , bar . h2 / m6 ";
21 parameter Real Kp = 100 " Proportional gain in controller ,
1/ m ";
22 parameter Real us = 0 " Constant offset in controller ";
23 // Controller referance value
24 parameter Real hr = 2 " Level reference , m ";
25 // Initial state parameters
26 parameter Real h0 = 1.9 " Initial level , m ";
27 parameter Real Vdi0 = 2 " Influent flow rate , m3 / h ";
28 // Declaring variables
29 // -- states
30 Real h ( start = h0 , fixed = true ) ;
31 Real Vdi ( start = Vdi0 , fixed = true ) ;
602 APPENDIX E. SOLUTION TO PROBLEMS*

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.

From Cornelius’ paper, to be developed. N

E.6 Chapter: Energy balance


Solution E.16. [Problem 7.1 p. 460] Ideal gas molar entropy
1 RT R
With αp Ṽ = T p
= p
and molar heat capacity only depending on temperature,
we find
ˆ T ˆ p
◦ c̃p (T ) R
S̃ = S̃ + dT − dp
T◦ T p◦ p

ˆ T ( )
◦ c̃p (T ) p
S̃ = S̃ + dT − R ln .
T◦ T p◦

If the heat capacity is constant, then


( ) ( )
◦ T p
S̃ = S̃ + c̃p ln ◦
− R ln ◦ .
T p
N
E.6. CHAPTER: ENERGY BALANCE 603

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*

In summary, with constant heat capacity, we have:


[ ( ) ]
p
G̃ = G̃ + R ln ◦ + c̃p − S̃ (T − T ◦ )
◦ ◦
p
( ) ( )
T p
− c̃p T · ln + RT ln .
T◦ p◦
N
Solution E.19. [Problem 7.4 p. 461] Constant density liquid Gibb’s free energy
To find molar Gibb’s free energy, we use
ˆ T ˆ p

G̃ = G̃ − S̃dT + Ṽ dp
T◦ p◦

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.

• The steady model is given as


( ) ( )( )
d Tt −αt αt Tt
= ,
dx Ts −αs αs Ts
| {z }
A

where
U℘
αt ,
ĉp,t ṁt
U℘
αs , .
ĉp,s ṁs
E.6. CHAPTER: ENERGY BALANCE 605

What happens if αs = αt . Thus, we consider the singular case:


( ) ( )( )
d Tt −αt αt Tt
= .
dx Ts −αt αt Ts
Subtracting the two equations leads to
d
(Tt − Ts ) = 0 ⇒ Tt (x) − Ts (x) = Tit − Tes = Tet − Tis .
dx
The heat transfer is then
ˆ Lx ˆ Lx
Q̇t2s = Q̇′t2s dx = U℘ (Tt − Ts ) dx
0 0

ˆ
( ) Lx
Q̇t2s = U℘ Tit − Tes dx
0

( )
Q̇t2s = UAx Tit − Tes .
Here, Tes is unknown at the moment.
Inserting the solution Tt (x) − Ts (x) = Tet − Tis into the differential equation
for Tt leads to
dTt ( )
= −αt (Tt − Ts ) = −αt Tet − Tis
dx

( )
Tt (x) = Tt (x = 0) − αt Tet − Tis x

( )
Tet = Tit − αt Lx Tet − Tis .
From this expression, we can find Tet to be
Tit + αt Lx Tis
Tet = Tit − αt Lx Tet + αt Lx Tis ⇒ Tet = .
1 + αt Lx
Then, by combining this expression for Tet with the equality
Tit − Tes = Tet − Tis

T t + αt Lx Tis
Tit − Tes = i − Tis
1 + αt Lx

T t + αt Lx Tis
Tes = Tit + Tis − i
1 + αt L x

T s + αt Lx Tit
Tes = i .
1 + αt Lx
606 APPENDIX E. SOLUTION TO PROBLEMS*

We can then finally find the heat transfer to be


( )
( t ) Tis + αt Lx Tit
Q̇t2s = UAx Ti − Te = UAx Ti −
s t
1 + αt L x

T t − Tis
Q̇t2s = UAx i .
1 + αt L x

Inserting the expression for αt thus gives


Tit − Tis
Q̇t2s = UAx
1 + ĉUp,tAṁx t
U Ax
Tit + ĉp,t ṁt i
Ts
Tet =
1 + ĉUp,tAṁx t Lx
Tis + ĉUp,tAṁx t Tit
Tes = U Ax
.
1+ ĉp,t ṁt

• 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.

For a counter-current heat exchanger, in general we have


( (αs −αt )Lx
) s
α t 1 − e Ti + (αt − αs ) e(αs −αt )Lx Tit
Tet =
αt − αs e(αs −αt )Lx
( )
s (αt − αs ) Tis − αs e(αs −αt )Lx − αs Tit
Te =
(α − α e(αs −αt )Lx )
[ (α −α t)L s ] t
e s t x − 1 (Ti − Tis )
Q̇t2s = UAx .
[αs e(αs −αt )Lx − αt ] Lx

• Using the first order Padé approximation


1 + z2
exp z ≈ ,
1 − z2

we find for Tet and Tes :


( (αe −αt )Lx
) (αe −αt )Lx
1+ 1+
αt 1 − 2
(αe −αt )Lx Tis + (αt − αs ) 2
(αe −αt )Lx Tit
t 1− 2
1− 2
Te = (αe −αt )Lx
1+
αt − αs 2
(αe −αt )Lx
1−
( (αe −αt )Lx
2
)
1+
(αt − αs ) Ti − αs (αe −αt )Lx − αs Tit
s 2

1−
Tes = 2
(αe −αt )Lx
.
1+
αt − αs 2
(αe −αt )Lx
1− 2

These expressions can be simplified to


( ) t
t αt Lx Tis + 1 − αt Lx −α 2
s Lx
Ti
Te = αt Lx +αs Lx
+1
( 2
αt Lx −αs Lx
) s
1+ Ti + αs Lx Tit
Tes = 2
αt Lx +αs Lx
.
2
+ 1

• 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

which can be simplified to

UAx (Tit − Tis )


Q̇t2s = .
1 + (αt + αs ) L2x
608 APPENDIX E. SOLUTION TO PROBLEMS*

• 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

Solution E.22. [Problem 7.7 p. 461] Model of heated liquid tank.

• To find a model of the liquid level, we use the mass balance:


dm
= ṁi − ṁe .
dt
Here:
( )
D2
m=ρ A−π h
4
ṁi = ρV̇i
ṁe = ρV̇e

pb − pa
V̇e = Kv u
pa
pb = pa + ρgh,

where it is assumed that A and D are independent of h, and that the level h
is well defined (no waves, etc.).

Combining the algebraic equations leads to



ρgh
ṁe = ρKv u .
pa

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

Assuming that ρ, A, and D are constants, leads to


( √ )
dh 1 ρgh
= V̇i − Kv u .
A − π D4
2
dt 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

We assume that E ≈ U and Ė ≈ U̇ , i.e., we neglect kinetic and potential energies.


Next, we write the work term as

Ẇ = Ẇf + pa V̇i − pb V̇e ,

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 ) .

The enthalpy is an extensive quantity, which means that

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

Solution E.23. [Problem 7.9 p. 464] Reactor with distributed cooling.


We assume initially that the temperature of the reactor is constant.
• The general mole balance states:
dnA
= ṅA,i − ṅA,e + ṅA,g .
dt
With a perfectly stirred tank:

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

We introduce the following additional assumptions:

– The reactor content is a liquid which is more or less incompressible, i.e.,


pV ≈ constant.
– The mixture is an ideal mixture, and

H = nA H̃A + nB H̃B + mS ĤS


Ḣi = ṅA,i H̃A,i + ṅB,i H̃B,i + ṁS,i ĤS,i
Ḣe = ṅA,e H̃A + ṅB,e H̃B + ṁS,e ĤS .

Symbolically, we write the expressions as



H= nj H̃j
j

Ḣ = Wj H̃j .
j

– The liquid has low viscosity, such that

Ẇf ≈ 0.

Inserting these expressions into the energy balance, we find

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

Generically, we have that

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

Here, the terms ∑


ṅj,e H̃j
j

cancel out, and we get:


∑ dH̃j ∑ ( ) ∑
nj ≈ ṅj,i H̃j,i − H̃j − H̃j ṅj,g + Q̇.
j
dt j j

Here, we add two more assumptions:


– Let:
dH̃j ≈ c̃p,j dT
ˆ H̃j,i ˆ Ti
H̃j,i − H̃j , dH̃ ≈ c̃p,j dT .
H̃j T
´ Ti
Furthermore, if c̃p,j is independent of T , we have T
c̃p,j dT ≈ c̃p,j (Ti − T ).
Inserting these assumption into the manipulated energy balance leads to:
( ) ( )
∑ dT ∑ ∑
nj c̃p,j ≈ ṅj,i c̃p,j (Ti − T ) − H̃j ṅj,g + Q̇.
j
dt j j

Here, we can introduce the total heat capacity Cp as



Cp = nj c̃p,j = nA c̃p,A + nB c̃p,B + mS ĉp,S .
j

– Normally, there is much more of component S in the mixture, so normally:


Cp ≈ mS ĉp,S ≈ ρV ĉp,S .

Likewise, since ṅB,i = 0:


– With only a tiny fraction of component A in the mixture, we introduce
the approximation:

ṅj,i c̃p,j ≈ ṁS,i ĉp,S = ρV̇ ĉp,S .
j
614 APPENDIX E. SOLUTION TO PROBLEMS*

Inserting these two approximations, we find:


dT ∑
ρV ĉp,S ≈ ρV̇ ĉp,S (Ti − T ) − H̃j ṅj,g + Q̇.
dt j

We thus find:
( )
dT V̇ 1 ∑ 1
= (Ti − T ) + − H̃j ṅj,g + Q̇.
dt V ρV ĉp,S j
ρV ĉp,S

Finally, we can insert the expressions for ṅj,g :


∑ ( )
H̃j ṅj,g = H̃A ṅA,g + H̃B ṅB,g = V H̃A rA + H̃B rB .
j

With rB = r and rA = −mr, this gives:


∑ ( )
H̃j ṅj,g = V H̃B − mH̃A r.
j

Next, we define the enthalpy of reaction, ∆r H̃ as:

∆r H̃ , H̃B − mH̃A .

Thus, we find: ∑
H̃j ṅj,g = V ∆r H̃r,
j

and the equation for T becomes:


( )
dT V̇ −∆r H̃ 1
= (Ti − T ) + kcm
A + Q̇.
dt V ρĉp,S ρV ĉp,S

If ∆r H̃ < 0, the reaction is denoted exothermal (produces heat), while if


∆r H̃ > 0, the reaction is endothermal (consumes heat).
In sum, the model is:
( )
dcA V̇ E
= (cA,i − cA ) − mk0 exp − cm
A
dt V RT
( )
−∆r H̃ ( )
dT V̇ E 1
= (Ti − T ) + k0 exp − cm
A + Q̇.
dt V ρĉp,S RT ρV ĉp,S
Here: ( ( ))
UΩL
Q̇ = V̇c ρc ĉp,c 1 − exp − (Tc,i − T ) .
ρc ĉp,c V̇c
N
Solution E.24. [Problem 7.8 p. 463] Simulation of heated tank with varying level.
E.6. CHAPTER: ENERGY BALANCE 615

The model can be written as:


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

The proportional controller (P-controller) has the following form:

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*

Controlled heated tank


30
20
h [m]
10

0 2 4 6 8 10 12 14

60
T [ C]

40

0 2 4 6 8 10 12 14
time t [h]

Figure E.3: Time evolution of level and temperature.

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

39 Real Vde " Effluent volumetric flow rate , m3 / h ";


40 Real Ti = 300 " Influent temperature , K ";
41 Real Th = 450 " Heat element temperature , K ";
42 Real u " Level control input ";
43 // Equations constituting the model
44 equation
45 // Algebraic equations
46 Vde = Kv * u * sqrt ( rho * g * h / pa ) ;
47 u = us - Kp *( hr - h ) ;
48 // Differential equations
49 der ( h ) = ( Vdi - Vde ) / A1 ;
50 der ( T ) = Vdi *( Ti - T ) /( A1 * h ) + Uh * PI * D *( Th - T ) /( rho * cp * A1 ) ;
51 end ModHeatedTank ;
52 // End package
53 end EnergyHeatedTank ;
N
Solution E.25. [Problem 7.10 p. 465] Reaction equilibrium constant for Haber
Bosch synthesis.
...to be developed. N

E.7 Chapter: Model analysis


Solution E.26. [Problem 8.1 p. 544] 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

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*

From here, it follows that


1 [( −(αs +αt )x ) ( ) ]
Tt (x) = αt e + αs Tit + αt − αt e−(αs +αt )x Tis
αt + αs
1 [( ) ( ) ]
Ts (x) = αs − αs e−(αs +αt )x Tit + αt + αs e−(αs +αt )x Tis .
αt + αs
N
Solution E.27. [Problem 8.2 p. 544] 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

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

Reactor: cooling flow sensitivity


0.125
cA [mol/L] 0.100
0.075
Vc 1.1 Vc 0.9 Vc
0 1 2 3 4 5 6 7 8
175 Vc 1.1 Vc 0.9 Vc
170
T [ C]

165
160
0 1 2 3 4 5 6 7 8
time t [min]

Figure E.4: Time evolution of concentration and temperature.

Solution E.28. [Problem 8.3 p. 544] Analysis of reactor with distributed cooling.

The system from Problem 7.9 can be modeled as:

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 model is given in Modelica model ModReactorHeatExchanger, contained


in Modelica package AnalysisReactorHeatExchanger. The simulation inputs are
described in Modelica model SimReactorHeatExchanger of the same package.

• 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*

Reactor: cooling flow sensitivity


1.13 Vc
0.75
1.14 Vc
cA [mol/L] 0.50 1.15 Vc
0.25

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

Solution E.29. [Problem 8.4 p. 545] Stability of controlled reactor.

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

• The eigenvalues of the system are:


( )
−47.767 −0.44721
{λ1 , λ2 } = eig = {−3.795 2, −47.767} .
−0.0043228 −3.7952
Both eigenvalues are real and negative. The system is then stable wrt. small
perturbations around the chosen operating point.
• The time constants of the system are given by
1 1
T1 = = = 0.263 49
|λ1 | |−3.795 2|
1 1
T2 = = = 2.093 5 × 10−2 .
|λ2 | |−47.767|
In the numerical values of Problem 5.2 p. 212, the time unit is hours, hence
Tj has the unit of h. We see that one time constant has the size of T2 =
2.093 5 × 10−2 h ≈ 75.4 s, while the other time constant has the value of T1 =
0.263 49 h ≈ 15.8 min. Here, the longest time constant is the one of interest,
and the time constant of the system is thus T ≈ 0.26 h.
• Figure E.6 indicates how the exponential decay time evolution of cA (t) can be
sketched based on knowing cA (0), the steady state value limt→∞ cA (t), and
the time constant T .
N
Solution E.30. [Problem 8.5 p. 546] Stability of water pump system.
For the model developed in Problem 6.5 p. 338 and simulated in Problem 6.6
p. 339,(the following
) linearized
( model) gives an approximation of the behavior around
∗ ∗ ∗ ∗
states h , V̇i and input V̇e , hr :
( ) ( )( δ )
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
• The eigenvalues of the system are:
( )
0 0.1
{λ1 , λ2 } = eig = {−0.934 18, −41.597} .
−388.59 −42.531
Both eigenvalues are real and negative. The system is then stable wrt. small
perturbations around the chosen operating point.
• The time constants of the system are given by
1 1
T1 = = = 1.070 5
|λ1 | |−0.934 18|
1 1
T2 = = = 0.024 04.
|λ2 | |−41. 597|
624 APPENDIX E. SOLUTION TO PROBLEMS*

Tangent with slope

Approximate steady state value

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:

{λ1 , λ2 } = {−0.26242, −0.16535} .

Both eigenvalues are real and negative. The system is then stable wrt. small
perturbations around the chosen operating point.

• The time constants of the system are given by


1 1
T1 = = = 3.810 7
|λ1 | |−0.26242|
1 1
T2 = = = 6.047 8.
|λ2 | |−0.16535|

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 ).

Solution E.32. [Problem 8.7 p. 548] Linearization of controlled reactor.

To be developed from pdf file N

Solution E.33. [Problem 8.8 p. 549] Linearization of controlled reactor.

To be developed from pdf file N

Solution E.34. [Problem 8.9 p. 550] Linearization of controlled reactor.

To be developed from pdf file N

E.8 Chapter: Model calibration


E.8. CHAPTER: MODEL CALIBRATION 627

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.

Billing, G. D. & Mikkelsen, K. V. (1996), Introduction to Molecular Dynamics and


Chemical Kinetics, John Wiley & Sons, Inc., New York. ISBN 0-471-12739-6.

Bird, R. B., Stewart, W. E. & Lightfoot, E. N. (2002), Transport Phenomena, second


edn, John Wiley & Sons, New York.

Brkić, D. (2011a), ‘An Explicit Approximation of Colebrook’s Equation for Fluid


Flow Friction Factor’, Petroleum Science and Technology 29, 1596–1602. DOI:
10.1080/10916461003620453.

Brkić, D. (2011b), ‘Review of explicit approximations to the Colebrook relation


for flow friction’, Journal of Petroleum Science and Engineering 77(1), 34–48.
http://dx.doi.org/10.1016/j.petrol.2011.02.006.

Callen, H. (1985), Thermodynamics and an Introduction to Thermostatistics, second


edn, John Wiley & Sons, New York.

Cardarelli, F. (1999), Scientific Unit Conversion, second edn, Springer-Verlag, Lon-


don, UK.

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.

Fine, R. A. & Millero, F. J. (1975), ‘Compressibility of water as a function of


temperature and pressure’, The Journal of Chemical Physics 59(10).

Fogler, H. S. (1992), Elements of Chemical Reaction Engineering, Prentice-Hall,


Inc., Englewood Cliffs, New Jersey.

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.

Frenkel, D. & Smit, B. (2001), Understanding Molecular Simulation. From Algorithm


to Applications, Computational Science. From Theory to Applications, second
edition edn, Academic Press, San Diego. ISBN-13: 978-0122673511.

Fritzson, P. (2011), Introduction to Modeling and Simulation of Technical and Phys-


ical Systems with Modelica (R), Wiley-IEEE, Hoboken, NJ.

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.

Haile, J. (1997), Molecular Dynamics Simulation. Elementary Methods, Wiley Pro-


fessional Paperback Series, John Wiley & Sons, Inc., New York. ISBN-13: 978-
0471184393.

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.

Hosseini, A. M. (2010), A Solenoid-Based Active Hydraulic Engine Mount: Mod-


elling, Analysis, and Verification, Master of applied science, Simon Fraser Univer-
sity.

John, F. (1991), Partial Differential Equations Partial Differential Equations, Vol. 1


of Applied Mathematical Sciences, 4th edn, Springer. ISBN-13: 978-0387906096.

Jordan, D. & Smith, P. (1987), Nonlinear Ordinary Differential Equations, Ox-


ford Applied Mathematics and Computing Science Series, second edn, Clarendon
Press.
BIBLIOGRAPHY 631

Kaggerud, E. & Tosterud, B., eds (1998), Latinsk-Norsk ordbok, fjerde reviderte edn,
J.W. Cappelens Forlag a.s., Oslo, Norway.

Kiusalaas, J. (2010), Numerical Methods in Engineering with Python, second edn,


Cambridge University Press, New York. ISBN 978-0-521-19132-6.

Kondepudi, D. & Prigogine, I. (1998), Modern Thermodynamics, John Wiley &


Sons, Inc., Chichester, England.

Kurode, S., Desai, P. G. & Shiralkar, A. (2013), Modeling of electro-hydraulic servo


valve and Robust Position Control using Sliding Mode Technique, in ‘Proceedings
of the 1st International and 16th National Conference on Machines and Mecha-
nisms (iNaCoMM2013).’.

Landrø, M. I. & Wangensteen, B., eds (1986), Bokmålsordboka. Definisjons- og


Rettskrivningsordbok, Universitetsforlaget AS, Oslo, Norway.

Levenspiel, O. (1972), Chemical Reaction Engineering, second edn, John Wiley &
Sons, New York.

LeVeque, R. J. (2002), Finite Volume Methods for Hyperbolic Problems, Cambridge


Texts in Applied Mathematics, Cambridge University Press, Cambridge, UK.
ISBN 0-521-00924-3.

Linge, S. & Langtangen, H. P. (2016), Programming for Computations - Python,


number 15 in ‘Texts in Computational Science and Engineering’, Springer, Hei-
delberg, Germany. ISBN 978-3-319-32427-2.

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.

Øksendal, B. (1995), Stochastic Differential Equations. An Introduction with Appli-


cations, fourth edn, Springer, Berlin.

Peters, M. H. (2005), Molecular Thermodynamics and Transport Phenomena. Com-


plexities of Scale in Space and Time, McGraw-Hill Nanoscience & Technology
Series, Mc, New York. ISBN 0-07-144561-7.

Poling, B. E., Prausnitz, J. M. & O’Connell, J. P. (2001), The Properties of Gases


and Liquids, 5th edn, McGraw-Hill, Boston.

Resnick, R., Halliday, D. & Krane, K. S. (2002), Physics, Vol. One, Fifth edn, John
Wiley & Sons, New York.
632 BIBLIOGRAPHY

Rohsenow, W. M., Hartnett, J. P. & Cho, Y. I. (1998), Handbook of Heat Transfer,


third edn, McGraw-Hill, New York.

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.

Smith, W. R. & Missen, R. W. (1991), Chemical Reaction Equilibrium Analysis:


Theory and Algorithms, Krieger Publishing Company, Malabar, Florida.

Stichlmair, J. G. (2002), Scale-up Engineering, Begell House, Inc., New York. ISBN
1-56700-160-2.

Strang, G. (1998), Introduction to Linear Algebra, second edn, Wellesley-Cambridge


Press, Wellesley, MA.

Taghizadeh, M., Ghaffari, A. & Najafi, F. (2009), ‘Modeling and identification of a


solenoid valve for PWM control applications’, C. R. Mecanique 337, 131–140.

Turton, R. (1995), Principles of Turbomachinery, second edn, Chapman & Hall,


London, UK.

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.

You might also like