Scaling of Differential Equations - Springer Link

5 downloads 0 Views 6MB Size Report
Are Magnus Bruaset, Fornebu, Norway. Kimberly Claffy, San Diego, USA. Magne Jorgensen, Fornebu, Norway. Hans Petter Langtangen, Fornebu, Norway.
SIMULA SPRINGER BRIEFS ON COMPUTING 2

Hans Petter Langtangen Geir K. Pedersen

Scaling of Differential Equations

Simula SpringerBriefs on Computing Volume 2

Editor-in-chief Aslak Tveito, Fornebu, Norway Series editors Are Magnus Bruaset, Fornebu, Norway Kimberly Claffy, San Diego, USA Magne Jørgensen, Fornebu, Norway Hans Petter Langtangen, Fornebu, Norway Olav Lysne, Fornebu, Norway Andrew McCulloch, La Jolla, USA Fabian Theis, Neuherberg, Germany Karen Willcox, Cambridge, USA Andreas Zeller, Saarbrücken, Germany

More information about this series at http://www.springer.com/series/13548

Hans Petter Langtangen Geir K. Pedersen •

Scaling of Differential Equations

Hans Petter Langtangen Simula Research Laboratory Center for Biomedical Computing Fornebu Norway

Geir K. Pedersen Department of Mathematics University of Oslo Oslo Norway

Simula SpringerBriefs on Computing ISBN 978-3-319-32725-9 ISBN 978-3-319-32726-6 DOI 10.1007/978-3-319-32726-6

(eBook)

Library of Congress Control Number: 2016937394 Mathematics Subject Classification (2010): 34, 35, 70, 74, 76, 92 © The Editor(s) (if applicable) and The Author(s) 2016. This book is published open access. Open Access This book is distributed under the terms of the Creative Commons Attribution-NonCommercial 2.5 License (http://creativecommons.org/licenses/by-nc/2.5/), which permits any noncommercial use, distribution, and reproduction in any medium, provided the original author(s) and source are credited. The images or other third party material in this book are included in the work’s Creative Commons license, unless indicated otherwise in the credit line; if such material is not included in the work’s Creative Commons license and the respective action is not permitted by statutory regulation, users will need to obtain permission from the license holder to duplicate, adapt, or reproduce the material. This work is subject to copyright. All commercial rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use. The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, express or implied, with respect to the material contained herein or for any errors or omissions that may have been made. Printed on acid-free paper This Springer imprint is published by Springer Nature The registered company is Springer International Publishing AG Switzerland

Foreword

Dear reader, Our aim with the series Simula SpringerBriefs on Computing is to provide compact introductions to selected fields of computing. Entering a new field of research can be quite demanding for graduate students, postdocs, and experienced researchers alike: the process often involves reading hundreds of papers, and the methods, results and notation styles used often vary considerably, which makes for a time-consuming and potentially frustrating experience. The briefs in this series are meant to ease the process by introducing and explaining important concepts and theories in a relatively narrow field, and by posing critical questions on the fundamentals of that field. A typical brief in this series should be around 100 pages and should be well suited as material for a research seminar in a well-defined and limited area of computing. We have decided to publish all items in this series under the SpringerOpen framework, as this will allow authors to use the series to publish an initial version of their manuscript that could subsequently evolve into a full-scale book on a broader theme. Since the briefs are freely available online, the authors will not receive any direct income from the sales; however, remuneration is provided for every completed manuscript. Briefs are written on the basis of an invitation from a member of the editorial board. Suggestions for possible topics are most welcome and can be sent to [email protected]. January 2016

Prof. Aslak Tveito CEO Dr. Martin Peters Executive Editor Mathematics Springer Heidelberg, Germany

v

Preface

Finding proper values of physical parameters in mathematical models is often quite a challenge. While many have gotten away with using just the mathematical symbols when doing science and engineering with pen and paper, the modern world of numerical computing requires each physical parameter to have a numerical value, otherwise one cannot get started with the computations. For example, in the simplest possible transient heat conduction simulation, a case relevant for a real physical material needs values for the heat capacity, the density, and the heat conduction coefficient of the material. In addition, relevant values must be chosen for initial and boundary temperatures as well as the size of the material. With a dimensionless mathematical model, as explained in Chapter 3.2, no physical quantities need to be assigned (!). Not only is this a simplification of great convenience, as one simulation is valid for any type of material, but it also actually increases the understanding of the physical problem. Scaling of differential equations is basically a simple mathematical process, consisting of the chain rule for differentiation and some algebra. The choice of scales, however, is a non-trivial topic, which may cause confusion among practitioners without extensive experience with scaling. How to choose scales is unfortunately not well treated in the literature. Most of the times, authors just state scales without proper motivation. The choice of scales is highly problem-dependent and requires knowledge of the characteristic features of the solution or the physics of the problem. The present notes aim at explaining “all nuts and bolts” of the scaling technique, including choice of scales, the algebra, the interpretation of dimensionless parameters in scaled models, and how scaling impacts software for solving differential equations. Traditionally, scaling was mainly used to identify small parameters in mathematical models, such that perturbation methods based on series expansions in terms of the small parameters could be used as an approximate solution method for differential equations. Nowadays, the greatest practical benefit of scaling is related to running numerical simulations, since scaling greatly simplifies the choice of values for the input data and makes the sim-

vii

viii

Preface

ulations results more widely applicable. The number of parameters in scaled models may be much less than the number of physical parameters in the original model. The parameters in scaled models are also dimensionless and express ratios of physical effects rather than levels of individual effects. Setting meaningful values of a few dimensionless numbers is much easier than determining physically relevant values for the original physical parameters. Another great benefit of scaling is the physical insight that follows from dimensionless parameters. Since physical effects enter the problem through a few dimensionless groups, one can from these groups see how different effects compete in their impact on the solution. Ideally, a good physical understanding should provide the same insight, but it is not always easy to “think right” and realize how spatial and temporal scales interact with physical parameters. This interaction becomes clear through the dimensionless numbers, and such numbers are therefore a great help, especially for students, in developing a correct physical understanding. Since we have a special focus on scaling related to numerical simulations, the notes contain a lot of examples on how to program with dimensionless differential equation models. Most numerical models feature quantities with dimension, so we show in particular how to utilize such existing models to solve the equations in the associated scaled model. Scaling is not a universal mathematical technique as the details depend on the problem at hand. We therefore present scaling in a range of specific applications, starting with simple ODEs, progressing with basic PDEs, before attacking more complicated models, especially from fluid mechanics. Chapter 1 discusses units and how to make programs that can automatically take care of unit conversion (the most frequent mathematical mistake in industry and science?). Section 2.1 introduces the mathematics of scaling and the thinking about scales in a simple ODE problem modeling exponential decay. The ideas are generalized to nonlinear ODEs and to systems of ODEs. Another ODE example, on mechanical vibrations, is treated in Section 2.2, where we cover many different physical contexts and different choices of scales. Scaling the standard, linear wave equation is the topic of Chapter 3.1, with discussion of how boundary and initial conditions influence the choice of scales. Another PDE example, the diffusion equation, appears in Chapter 3.2. Here we progress from a simple linear diffusion equation in 1D to a study of how scales are influenced by an oscillatory boundary condition. Nonlinear diffusion models, as well as convection-diffusion PDEs, are elaborated on. The final Chapter is devoted to many famous PDEs arising from continuum models: elasticity, viscous fluid flow, thermal convection, etc. The mathematics is translated into complete computer codes for the ODE and simpler PDE problems. Experimental fluid mechanics is a field full of relations involving dimensionless numbers such as the Grashof and Prandtl numbers, but none of the textbooks the authors have seen explain how these numbers actually relate to

Preface

ix

dimensionless forms of the governing equations. Consequently, this non-trivial topic is particularly highlighted in the fluid mechanics examples. The mathematics in the first two chapters is very gentle and requires no more background than basic one-variable calculus and preferably some knowledge of differential equation models. The next chapter involves PDEs and assumes familiarity with basic models for wave phenomena, diffusion, and combined convection-diffusion. The final chapter is meant for readers with knowledge of the physics and mathematics of continuum mechanical models. The mathematical level of the text rises quickly after the first two chapters. In the first two chapters, much of the mathematics is accompanied by complete (yet short) computer codes. The programming level requires familiarity with procedural programming in Python. As the mathematical level rises, the computer codes get much more comprehensive, and we refer to some files for computational examples in chapter three. The pedagogy is to saturate the reader with lots of detailed examples to provide an understanding for the topic, primarily because the choice of scales depends on the problem at hand. One can also view the notes as a reference on how to scale many of the most important differential equation models in physics. For the simpler differential equations in Chapters 2 and 3, we present computer code for many computational examples, but the treatment of the advanced models in Chapter 4 is more superficial to limit the size of that chapter. The exercises are named either Exercise or Problem. The latter is a standalone exercise without reference to the rest of the text, while the former typically extends a topic in the text or refers to sections or formulas in the text. What this booklet is and is not Books containing material on scaling and non-dimensionalization very often cover topics not treated in the present notes, e.g., the key topic of dimensional analysis and the famous Buckingham Pi Theorem [1, 8], which we discuss only briefly in section 1.1.3. Similarly, analytical solution methods like perturbation techniques and similarity solutions, which represent classical methods closely related to scaling and nondimensionalization, are not addressed herein. There are numerous texts on perturbation techniques, and these methods build on an already scaled differential equations. Similarity solutions do not fit within the present scope since these involve non-dimensional combinations of the unscaled independent variables to derive new differential equations that are easier to solve. Our scope is to scale differential equations to simplify the setting of parameters in numerical simulations, and at the same time understand

x

Preface

more of the physics through interpretation of the dimensionless numbers that automatically arise from the scaling procedure. With these notes, we hope to demystify the thinking involved in scale determination and encourage numerical simulations to be performed with dimensionless differential equation models. All program and data files referred to in this book are available from the book’s primary web site: URL: http://hplgit.github.io/scaling-book/ doc/web/. This site also features a version of the book with exercises. Acknowledgments. Professor Svein Linge provided very detailed, constructive comments on the entire manuscript and helped improve the reading quality significantly. Yapi Donatien Achou assisted with proof reading. Significant portions of the present text were written when the first author was fed with FOLFIRINOX (and thereby kept alive) by Linda Falch-Koslung, Dr. Olav Dajani, and the rest of the OUS team. There would simply be no booklet without their efforts. It is also a great pleasure to express our sincere thanks to the Springer and Simula team that handled the prompt editing and production of the text: Martin Peters, Ruth Allewelt, Aslak Tveito, and Åsmund Ødegård.

Oslo, November 2015

Hans Petter Langtangen, Geir K. Pedersen

Contents

Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

v

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii 1

Dimensions and units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1 Fundamental concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.1 Base units and dimensions . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2 Dimensions of common physical quantities . . . . . . . . . . . 1.1.3 The Buckingham Pi theorem . . . . . . . . . . . . . . . . . . . . . . . 1.1.4 Absolute errors, relative errors, and units . . . . . . . . . . . . 1.1.5 Units and computers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.6 Unit systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.7 Example on challenges arising from unit systems . . . . . 1.1.8 PhysicalQuantity: a tool for computing with units . . . . 1.2 Parampool: user interfaces with automatic unit conversion . . . 1.2.1 Pool of parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2.2 Fetching pool data for computing . . . . . . . . . . . . . . . . . . . 1.2.3 Reading command-line options . . . . . . . . . . . . . . . . . . . . . 1.2.4 Setting default values in a file . . . . . . . . . . . . . . . . . . . . . . 1.2.5 Specifying multiple values of input parameters . . . . . . . 1.2.6 Generating a graphical user interface . . . . . . . . . . . . . . . .

1 1 1 2 3 5 5 5 6 7 9 10 11 11 12 13 14

2

Ordinary differential equation models . . . . . . . . . . . . . . . . . . . . . 2.1 Exponential decay problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.1 Fundamental ideas of scaling . . . . . . . . . . . . . . . . . . . . . . . 2.1.2 The basic model problem . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.3 The technical steps of the scaling procedure . . . . . . . . . 2.1.4 Making software for utilizing the scaled model . . . . . . . 2.1.5 Scaling a generalized problem . . . . . . . . . . . . . . . . . . . . . . 2.1.6 Variable coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.7 Scaling a cooling problem with constant temperature in the surroundings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

17 17 17 18 19 21 25 31 32 xi

xii

Contents

2.1.8 Scaling a cooling problem with time-dependent surroundings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.9 Scaling a nonlinear ODE . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.10 SIR ODE system for spreading of diseases . . . . . . . . . . . 2.1.11 SIRV model with finite immunity . . . . . . . . . . . . . . . . . . . 2.1.12 Michaelis-Menten kinetics for biochemical reactions . . . 2.2 Vibration problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.1 Undamped vibrations without forcing . . . . . . . . . . . . . . . 2.2.2 Undamped vibrations with constant forcing . . . . . . . . . . 2.2.3 Undamped vibrations with time-dependent forcing . . . . 2.2.4 Damped vibrations with forcing . . . . . . . . . . . . . . . . . . . . 2.2.5 Oscillating electric circuits . . . . . . . . . . . . . . . . . . . . . . . . .

33 37 39 41 42 49 49 53 53 61 67

3

Basic partial differential equation models . . . . . . . . . . . . . . . . . 3.1 The wave equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.1 Homogeneous Dirichlet conditions in 1D . . . . . . . . . . . . . 3.1.2 Implementation of the scaled wave equation . . . . . . . . . 3.1.3 Time-dependent Dirichlet condition . . . . . . . . . . . . . . . . . 3.1.4 Velocity initial condition . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.5 Variable wave velocity and forcing . . . . . . . . . . . . . . . . . . 3.1.6 Damped wave equation . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.7 A three-dimensional wave equation problem . . . . . . . . . 3.2 The diffusion equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.1 Homogeneous 1D diffusion equation . . . . . . . . . . . . . . . . . 3.2.2 Generalized diffusion PDE . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.3 Jump boundary condition . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.4 Oscillating Dirichlet condition . . . . . . . . . . . . . . . . . . . . . . 3.3 Reaction-diffusion equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.1 Fisher’s equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.2 Nonlinear reaction-diffusion PDE . . . . . . . . . . . . . . . . . . . 3.4 The convection-diffusion equation . . . . . . . . . . . . . . . . . . . . . . . . 3.4.1 Convection-diffusion without a force term . . . . . . . . . . . 3.4.2 Stationary PDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.3 Convection-diffusion with a source term . . . . . . . . . . . . .

69 69 69 71 72 75 77 80 81 81 82 83 85 86 89 89 91 92 92 95 97

4

Advanced partial differential equation models . . . . . . . . . . . . . 4.1 The equations of linear elasticity . . . . . . . . . . . . . . . . . . . . . . . . . 4.1.1 The general time-dependent elasticity problem . . . . . . . 4.1.2 Dimensionless stress tensor . . . . . . . . . . . . . . . . . . . . . . . . 4.1.3 When can the acceleration term be neglected? . . . . . . . 4.1.4 The stationary elasticity problem . . . . . . . . . . . . . . . . . . . 4.1.5 Quasi-static thermo-elasticity . . . . . . . . . . . . . . . . . . . . . . 4.2 The Navier-Stokes equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.1 The momentum equation without body forces . . . . . . . . 4.2.2 Scaling of time for low Reynolds numbers . . . . . . . . . . .

99 99 99 101 101 103 105 106 107 109

Contents

4.3

4.4

4.5

4.6

xiii

4.2.3 Shear stress as pressure scale . . . . . . . . . . . . . . . . . . . . . . 4.2.4 Gravity force and the Froude number . . . . . . . . . . . . . . . 4.2.5 Oscillating boundary conditions and the Strouhal number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.6 Cavitation and the Euler number . . . . . . . . . . . . . . . . . . . 4.2.7 Free surface conditions and the Weber number . . . . . . . Thermal convection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3.1 Forced convection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3.2 Free convection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3.3 The Grashof, Prandtl, and Eckert numbers . . . . . . . . . . 4.3.4 Heat transfer at boundaries and the Nusselt and Biot numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Compressible gas dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.1 The Euler equations of gas dynamics . . . . . . . . . . . . . . . . 4.4.2 General isentropic flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4.3 The acoustic approximation for sound waves . . . . . . . . . Water surface waves driven by gravity . . . . . . . . . . . . . . . . . . . . . 4.5.1 The mathematical model . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5.2 Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5.3 Waves in deep water . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.5.4 Long waves in shallow water . . . . . . . . . . . . . . . . . . . . . . . Two-phase porous media flow . . . . . . . . . . . . . . . . . . . . . . . . . . . .

110 110 110 111 112 113 113 114 117 120 121 121 123 124 126 126 127 128 129 130

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

Chapter 1

Dimensions and units

A mechanical system undergoing one-dimensional damped vibrations can be modeled by the equation mu + bu + ku = 0,

(1.1)

where m is the mass of the system, b is some damping coefficient, k is a spring constant, and u(t) is the displacement of the system. This is an equation expressing the balance of three physical effects: mu (mass times acceleration), bu (damping force), and ku (spring force). The different physical quantities, such as m, u(t), b, and k, all have different dimensions, measured in different units, but mu , bu , and ku must all have the same dimension, otherwise it would not make sense to add them.

1.1 Fundamental concepts 1.1.1 Base units and dimensions Base units have the important property that all other units derive from them. In the SI system, there are seven such base units and corresponding physical quantities: meter (m) for length, kilogram (kg) for mass, second (s) for time, kelvin (K) for temperature, ampere (A) for electric current, candela (cd) for luminous intensity, and mole (mol) for the amount of substance. We need some suitable mathematical notation to calculate with dimensions like length, mass, time, and so forth. The dimension of length is written as [L], the dimension of mass as [M], the dimension of time as [T], and the dimension of temperature as [Θ] (the dimensions of the other base units are simply omitted as we do not make much use of them in this text). The dimension of a derived unit like velocity, which is distance (length) divided by time, then becomes [LT−1 ] in this notation. The dimension of force, another © The Author(s) 2016 H.P. Langtangen and G.K. Pedersen, Scaling of Differential Equations, Simula SpringerBriefs on Computing 2, DOI 10.1007/978-3-319-32726-6_1

1

2

1 Dimensions and units

derived unit, is the same as the dimension of mass times acceleration, and hence the dimension of force is [MLT−2 ]. Let us find the dimensions of the terms in (1.1). A displacement u(t) has dimension [L]. The derivative u (t) is change of displacement, which has dimension [L], divided by a time interval, which has dimension [T], implying that the dimension of u is [LT−1 ]. This result coincides with the interpretation of u as velocity and the fact that velocity is defined as distance ([L]) per time ([T]). Looking at (1.1), and interpreting u(t) as displacement, we realize that the term mu (mass times acceleration) has dimension [MLT−2 ]. The term bu must have the same dimension, and since u has dimension [LT−1 ], b must have dimension [MT−1 ]. Finally, ku must also have dimension [MLT−2 ], implying that k is a parameter with dimension [MT−2 ]. The unit of a physical quantity follows from the dimension expression. For example, since velocity has dimension [LT−1 ] and length is measured in m while time is measured in s, the unit for velocity becomes m/s. Similarly, force has dimension [MLT−2 ] and unit kg m/s2 . The k parameter in (1.1) is measured in kg s−2 . Dimension of derivatives The easiest way to realize the dimension of a derivative, is to express the derivative as a finite difference. For a function u(t) we have du u(t + Δt) − u(t) ≈ , dt Δt where Δt is a small time interval. If u denotes a velocity, its dimension is [LT]−1 , and u(t + Δt) − u(t) gets the same dimension. The time interval has dimension [T], and consequently, the finite difference gets the dimension [LT]−2 . In general, the dimension of the derivative du/dt is the dimension of u divided by the dimension of t.

1.1.2 Dimensions of common physical quantities Many derived quantities are measured in derived units that have their own name. Force is one example: Newton (N) is a derived unit for force, equal to kg m/s2 . Another derived unit is Pascal (Pa) for pressure and stress, i.e., force per area. The unit of Pa then equals N/m2 or kg/ms2 . Below are more names for derived quantities, listed with their units.

1.1 Fundamental concepts Name Symbol Physical quantity radian hertz newton pascal joule watt

rad Hz N Pa J W

angle frequency force, weight pressure, stress energy, work, heat power

3 Unit 1 s−1 kg m/s2 N/m2 Nm J/s

Some common physical quantities and their dimensions are listed next. Quantity

Relation

stress force/area pressure force/area density mass/volume strain displacement/length Young’s modulus stress/strain Poisson’s ratio transverse strain/axial strain Lame’ parameters λ and μ stress/strain moment (of a force) distance × force impulse force × time linear momentum mass × velocity angular momentum distance × mass × velocity work force × distance energy work power work/time heat work heat flux heat rate/area temperature base unit heat capacity heat change/temperature change specific heat capacity heat capacity/unit mass thermal conductivity heat flux/temperature gradient dynamic viscosity shear stress/velocity gradient kinematic viscosity dynamic viscosity/density surface tension energy/area

Unit

Dimension

2

[MT−2 L−1 ] MT−2 L−1 ] [ML−3 ] [1] [MT−2 L−1 ] [1] [MT−2 L−1 ] [ML2 T−2 ] [MLT−1 ] [MLT−1 ] [ML2 T−1 ] [ML2 T−2 ] [ML2 T−2 ] [ML2 T−3 ] [ML2 T−2 ] [MT−3 ] [Θ] [ML2 T−2 Θ−1 ] [L2 T−2 Θ−1 ] [MLT−3 Θ−1 ] [ML−1 T −1 ] [L2 T−1 ] [MT−2 ]

N/m = Pa N/m2 = Pa kg/m3 1 N/m2 = Pa 1 N/m2 = Pa Nm Ns kg m/s kg m2 /s Nm = J Nm = J Nm/s = W J Wm−2 K J/K JK−1 kg−1 Wm−1 K−1 kgm−1 s−1 m2 /s J/m2

Prefixes for units. Units often have prefixes1 . For example, kilo (k) is a prefix for 1000, so kg is 1000 g. Similarly, GPa means giga pascal or 109 Pa.

1.1.3 The Buckingham Pi theorem Almost all texts on scaling has a treatment of the famous Buckingham Pi theorem, which can be used to derive physical laws based on unit compatibility 1

https://en.wikipedia.org/wiki/Metric_prefix

4

1 Dimensions and units

rather than the underlying physical mechanisms. This booklet has its focus on models where the physical mechanisms are already expressed through differential equations. Nevertheless, the Pi theorem has a remarkable position in the literature on scaling, and since we will occasionally make references to it, the theorem is briefly discussed below. The theorem itself is simply stated in two parts. First, if a problem involves n physical parameters in which m independent unit-types (such as length, mass etc.) appear, then the parameters can be combined to exactly n − m independent dimensionless numbers, referred to as Pi’s. Second, any unit-free relation between the original n parameters can be transformed into a relation between the n − m dimensionless numbers. Such relations may be identities or inequalities stating, for instance, whether or not a given effect is negligible. Moreover, the transformation of an equation set into dimensionless form corresponds to expressing the coefficients, as well as the free and dependent variables, in terms of Pi’s. As an example, think of a body moving at constant speed v. What is the distance s traveled in time t? The Pi theorem results in one dimensionless variable π = vt/s and leads to the formula s = Cvt, where C is an undetermined constant. The result is very close to the well-known formula s = vt arising from the differential equation s = v in physics, but with an extra constant. At first glance the Pi theorem may appear as bordering on the trivial. However, it may produce remarkable progress for selected problems, such as turbulent jets, nuclear blasts, or similarity solutions, without the detailed knowledge of mathematical or physical models. Hence, to a novice in scaling it may stand out as something very profound, if not magical. Anyhow, as one moves on to more complex problems with many parameters, the use of the theorem yields comparatively less gain as the number of Pi’s becomes large. Many Pi’s may also be recombined in many ways. Thus, good physical insight, and/or information conveyed through an equation set, is required to pick the useful dimensionless numbers or the appropriate scaling of the said equation set. Sometimes scrutiny of the equations also reveals that some Pi’s, obtained by applying the theorem, in fact may be removed from the problem. As a consequence, when modeling a complex physical problem, the real assessment of scaling and dimensionless numbers will anyhow be included in the analysis of the governing equations instead of being a separate issue left with the Pi theorem. In textbooks and articles alike, the discussion of scaling in the context of the equations are too often missing or presented in a half-hearted fashion. Hence, the authors’ focus will be on this process, while we do not provide much in the way of examples on the Pi theorem. We do not allude that the Pi theorem is of little value. In a number of contexts, such as in experiments, it may provide valuable and even crucial guidance, but in this particular textbook we seek to tell the complementary story on scaling. Moreover, as will be shown in this booklet, the dimensionless numbers in a problem also arise, in a very natural way, from scaling the differential

1.1 Fundamental concepts

5

equations. Provided one has a model based on differential equations, there is actually no need for classical dimensional analysis.

1.1.4 Absolute errors, relative errors, and units Mathematically, it does not matter what units we use for a physical quantity. However, when we deal with approximations and errors, units are important. Suppose we work with a geophysical problem where the length scale is typically measured in km and we have an approximation 12.5 km to the exact value 12.52 km. The error is then 0.02 km. Switching units to mm leads to an error of 20,000 mm. A program working in mm would report 2 · 105 as the error, while a program working in km would print 0.02. The absolute error is therefore sensitive to the choice of units. This fact motivates the use of relative error: (exact - approximate)/exact, since units then cancel. In the present example, one gets a relative error of 1.6 · 10−3 regardless of whether the length is measured in km or mm. Nevertheless, rather than relying solely on relative errors, it is in general better to scale the problem such that the quantities entering the computations are of unit size (or at least moderate) instead of being very large or very small. The techniques of these notes show how this can be done.

1.1.5 Units and computers Traditional numerical computing involves numbers only and therefore requires dimensionless mathematical expressions. Usually, an implicit trivial scaling is used. One can, for example, just scale all length quantities by 1 m, all time quantities by 1 s, and all mass quantities by 1 kg, to obtain the dimensionless numbers needed for calculations. This is the most common approach, although it is very seldom explicitly stated. Symbolic computing packages, such as Mathematica and Maple, allow computations with quantities that have dimension. This is also possible in popular computer languages used for numerical computing (Section 1.1.8 provides a specific example in Python).

1.1.6 Unit systems Confusion arises quickly when some physical quantities are expressed in SI units while others are in US or British units. Density could, for instance, be given in unit of ounce per teaspoon. Although unit conversion tables are fre-

6

1 Dimensions and units

quently met in school, errors in unit conversion probably rank highest among all errors committed by scientists and engineers (and when a unit conversion error makes an airplane’s fuel run out2 , it is serious!). Having good software tools to assist in unit conversion is therefore paramount, motivating the treatment of this topic in Sections 1.1.8 and 1.2. Readers who are primarily interested in the mathematical scaling technique may safely skip this material and jump right to Section 2.1.

1.1.7 Example on challenges arising from unit systems A slightly elaborated example on scaling in an actual science/engineering project may stimulate the reader’s motivation. In its full extent, the study of tsunamis spans geophysics, geology, history, fluid dynamics, statistics, geodesy, engineering, and civil protection. This complexity reflects in a diversity of practices concerning the use of units, scales, and concepts. If we narrow the scope to modeling of tsunami propagation, the scaling aspect, at least, may seem simple as we are mainly concerned with length and time. Still, even here the non-uniformity concerning physical units is an encumbrance. A minor issue is the occasional use of non-SI units such as inches, or in old charts, even fathoms. More important is the non-uniformity in the magnitude of the different variables, and the differences in the inherent horizontal and vertical scales in particular. Typically, surface elevations are in meters or smaller. For far-field deep water propagation, as well as small tsunamis (which are still of scientific interest) surface elevations are often given in cm or even mm. In the deep ocean, the characteristic depth is orders of magnitude larger than this, typically 5000 m. Propagation distances, on the other hand, are hundreds or thousands of kilometers. Often locations and computational grids are best described in geographical coordinates (longitude/latitude) which are related to SI units by 1 latitude minute being roughly one nautical mile (1852 m), and 1 longitude minute being this quantity times the cosine of the latitude. Wave periods of tsunamis mostly range from minutes to an hour, hopefully sufficiently short to be well separated from the half-daily period of the tides. Propagation times are typically hours or maybe the better part of a day when the Pacific Ocean is traversed. The scientists, engineers, and bureaucrats in the tsunami community tend to be particular and non-conform concerning formats and units, as well as the type of data required. To accommodate these demands, a tsunami modeler must produce a diversity of data which are in units and formats which cannot be used internally in her models. On the other hand, she must also be prepared to accept the input data in diversified forms. Some data sets may be large, implying that unnecessary duplication, with different units or scal2

http://www.nytimes.com/1983/07/30/us/jet-s-fuel-ran-out-after-metric-conversion-errors.html

1.1 Fundamental concepts

7

ing, should be avoided. In addition, tsunami models are often bench-marked through comparison with experimental data. The lab scale is generally cm or m, at most, which implies that measured data are provided in different units (than used in real earth-scale events), or even in volts, with conversion information, as obtained from the measuring gauges. All the unit particulars in various file formats is clearly a nuisance and give rise to a number of misconceptions and errors that may cause loss of precious time or efforts. To reduce such problems, developers of computational tools should combine a reasonable flexibility concerning units in input and output with a clear and consistent convention for scaling within the tools. In fact, this also applies to academic tools for in-house use. The discussion above points to some best practices that these notes promotes. First, always compute with scaled differential equation models. This booklet tells you how to do that. Second, users of software often want to specify input data with dimension and get output data with dimension. The software should then apply tools like PhysicalQuantity (Section 1.1.8) or the more sophisticated Parampool package (Section 1.2) to allow input with explicit dimensions and convert the dimensions to the right types if necessary. It is trivial to apply these tools if the computational software is written in Python, but it is even straightforward if the software is written in compiled languages like Fortran, C, or C++. In the latter case one just makes an input reading module in Python that grabs data from a user interface and feeds them into the computational software, either through files or function calls (the relevant functions to be called must be wrapped in Python with tools like f2py3 , Cython4 , Weave5 , SWIG6 , Instant7 , or similar, see [7, Appendix C] for basic examples on f2py and Cython wrapping of C and Fortran code).

1.1.8 PhysicalQuantity: a tool for computing with units These notes contain quite some computer code to illustrate how the theory maps in detail to running software. Python is the programming language used, primarily because it is an easy-to-read, powerful, full-fledged language that allows MATLAB-like code as well as class-based code typically used in Java, C#, and C++. The Python ecosystem for scientific computing has in recent years grown fast in popularity and acts as a replacement for more specialized tools like MATLAB, R, and IDL. The coding examples in this booklet requires only familiarity with basic procedural programming in Python. 3

http://docs.scipy.org/doc/numpy-dev/f2py/ http://cython.org/ 5 http://docs.scipy.org/doc/scipy/reference/tutorial/weave.html 6 http://www.swig.org/ 7 https://bitbucket.org/fenics-project/instant 4

8

1 Dimensions and units

Readers without knowledge of Python variables, functions, if tests, and module import should consult, e.g., a brief tutorial on scientific Python8 , the Python Scientific Lecture Notes9 , or a full textbook [4] in parallel with reading about Python code in the present notes. These notes apply Python 2.7 Python exists in two incompatible versions, numbered 2 and 3. The differences can be made small, and there are tools to write code that runs under both versions. As Python version 2 is still dominating in scientific computing, we stick to this version, but write code in version 2.7 that is as close as possible to version 3.4 and later. In most of our programs, only the print statement differs between version 2 and 3. Computations with units in Python are well supported by the very useful tool PhysicalQuantity from the ScientificPython package10 by Konrad Hinsen. Unfortunately, ScientificPython does not, at the time of this writing, work with NumPy version 1.9 or later, so we have isolated the PhysicalQuantity object in a module PhysicalQuantities11 and made it publicly available on GitHub. There is also an alternative package Unum12 for computing with numbers with units, but we shall stick to the former module here. Let us demonstrate the usage of the PhysicalQuantity object by computing s = vt, where v is a velocity given in the unit yards per minute and t is time measured in hours. First we need to know what the units are called in PhysicalQuantities. To this end, run pydoc PhysicalQuantities, or Terminal

Terminal> pydoc Scientific.Physics.PhysicalQuantities

if you have the entire ScientificPython package installed. The resulting documentation shows the names of the units. In particular, yards are specified by yd, minutes by min, and hours by h. We can now compute s = vt as follows: >>> >>> ... >>> >>> >>> 8

# With ScientificPython: from Scientific.Physics.PhysicalQuantities import \ PhysicalQuantity as PQ # With PhysicalQuantities as separate/stand-alone module: from PhysicalQuantities import PhysicalQuantity as PQ

http://hplgit.github.io/bumpy/doc/web/index.html http://scipy-lectures.github.com/ 10 https://bitbucket.org/khinsen/scientificpython 11 https://github.com/hplgit/physical-quantities 12 https://bitbucket.org/kiv/unum/ 9

1.2 Parampool: user interfaces with automatic unit conversion >>> v = PQ(’120 yd/min’) >>> t = PQ(’1 h’) >>> s = v*t >>> print s 120.0 h*yd/min

# # # #

9

velocity time distance s is string

The odd unit h*yd/min is better converted to a standard SI unit such as meter: >>> s.convertToUnit(’m’) >>> print s 6583.68 m

Note that s is a PhysicalQuantity object with a value and a unit. For mathematical computations we need to extract the value as a float object. We can also extract the unit as a string: >>> print s.getValue() 6583.68 >>> print s.getUnitName() m

# float # string

Here is an example on how to convert the odd velocity unit yards per minute to something more standard: >>> v.convertToUnit(’km/h’) >>> print v 6.58368 km/h >>> v.convertToUnit(’m/s’) >>> print v 1.8288 m/s

As another example on unit conversion, say you look up the specific heat capacity of water to be 1 cal g−1 K−1 . What is the corresponding value in the standard unit Jg−1 K−1 where joule replaces calorie? >>> c = PQ(’1 cal/(g*K)’) >>> c.convertToUnit(’J/(g*K)’) >>> print c 4.184 J/K/g

1.2 Parampool: user interfaces with automatic unit conversion The Parampool13 package allows creation of user interfaces with support for units and unit conversion. Values of parameters can be set as a number with a unit. The parameters can be registered beforehand with a preferred 13

https://github.com/hplgit/parampool

10

1 Dimensions and units

unit, and whatever the user prescribes, the value and unit are converted so the unit becomes the registered unit. Parampool supports various type of user interfaces: command-line arguments (option-value pairs), text files, and interactive web pages. All of these are described next. Example application. As case, we want to make software for computing with the simple formula s = v0 t + 12 at2 . We want v0 to be a velocity with unit m/s, a to be acceleration with unit m/s2 , t to be time measured in s, and consequently s will be a distance measured in m.

1.2.1 Pool of parameters First, Parampool requires us to define a pool of all input parameters, which is here simply represented by list of dictionaries, where each dictionary holds information about one parameter. It is possible to organize input parameters in a tree structure with subpools that themselves may have subpools, but for our simple application we just need a flat structure with three input parameters: v0 , a, and t. These parameters are put in a subpool called “Main”. The pool is created by the code def define_input(): pool = [ ’Main’, [ dict(name=’initial velocity’, default=1.0, unit=’m/s’), dict(name=’acceleration’, default=1.0, unit=’m/s**2’), dict(name=’time’, default=10.0, unit=’s’) ] ] from parampool.pool.UI import listtree2Pool pool = listtree2Pool(pool) # convert list to Pool object return pool

For each parameter we can define a logical name, such as initial velocity, a default value, and a unit. Additional properties are also allowed, see the Parampool documentation14 . Tip: specify default values of numbers as float objects Note that we do not just write 1, but 1.0 as default. Had 1 been used, Parampool would have interpreted our parameter as an integer and would therefore convert input like 2.5 m/s to 2 m/s. To ensure that a real-valued parameter becomes a float object inside the pool, we must specify the default value as a real number: 1. or 1.0. (The type of 14

http://hplgit.github.io/parampool/doc/web/index.html

1.2 Parampool: user interfaces with automatic unit conversion

11

an input parameter can alternatively be set explicitly by the str2type property, e.g., str2type=float.)

1.2.2 Fetching pool data for computing We can make a little function for fetching values from the pool and computing s: def distance(pool): v_0 = pool.get_value(’initial velocity’) a = pool.get_value(’acceleration’) t = pool.get_value(’time’) s = v_0*t + 0.5*a*t**2 return s

The pool.get_value function returns the numerical value of the named parameter, after the unit has been converted from what the user has specified to what was registered in the pool. For example, if the user provides the command-line argument –time ’2 h’, Parampool will convert this quantity to seconds and pool.get_value(’time’) will return 7200.

1.2.3 Reading command-line options To run the computations, we define the pool, load values from the command line, and call distance: pool = define_input() from parampool.menu.UI import set_values_from_command_line pool = set_values_from_command_line(pool) s = distance(pool) print ’s=%g’ % s

Parameter names with whitespace must use an underscore for whitespace in the command-line option, such as in --Initial_velocity. We can now run Terminal

Terminal> python distance.py --initial_velocity ’10 km/h’ \ --acceleration 0 --time ’1 h s=10000

Notice from the answer (s) that 10 km/h gets converted to m/s and 1 h to s. It is also possible to fetch parameter values as PhysicalQuantity objects from the pool by calling

12

1 Dimensions and units

v_0 = pool.get_value_unit(’Initial velocity’)

The following variant of the distance function computes with values and units: def distance_unit(pool): # Compute with units from parampool.PhysicalQuantities import PhysicalQuantity as PQ v_0 = pool.get_value_unit(’initial velocity’) a = pool.get_value_unit(’acceleration’) t = pool.get_value_unit(’time’) s = v_0*t + 0.5*a*t**2 return s.getValue(), s.getUnitName()

We can then do s, s_unit = distance_unit(pool) print ’s=%g’ % s, s_unit

and get output with the right unit as well.

1.2.4 Setting default values in a file In large applications with lots of input parameters one will often like to define a (huge) set of default values specific for a case and then override a few of them on the command-line. Such sets of default values can be set in a file using syntax like subpool Main initial velocity = 100 ! yd/min acceleration = 0 ! m/s**2 end

# drop acceleration

The unit can be given after the ! symbol (and before the comment symbol #). To read such files we have to add the lines from parampool.pool.UI import set_defaults_from_file pool = set_defaults_from_file(pool)

before the call to set_defaults_from_command_line. If the above commands are stored in a file distance.dat, we give this file information to the program through the option –poolfile distance.dat. Running just Terminal

Terminal> python distance.py --poolfile distance.dat s=15.25 m

1.2 Parampool: user interfaces with automatic unit conversion

13

first loads the velocity 100 yd/min converted to 1.524 m/s and zero acceleration into the pool system and, and then we call distance_unit, which loads these values from the pool along with the default value for time, set as 10 s. The calculation is then s = 1.524 · 10 + 0 = 15.24 with unit m. We can override the time and/or the other two parameters on the command line: Terminal

Terminal> python distance.py --poolfile distance.dat --time ’2 h’ s=10972.8 m

The resulting calculations are s = 1.524 · 7200 + 0 = 10972.8. You are encouraged to play around with the distance.py program.

1.2.5 Specifying multiple values of input parameters Parampool has an interesting feature: multiple values can be assigned to an input parameter, thereby making it easy for an application to run through all combinations of all parameters. We can demonstrate this feature by making a table of v0 , a, t, and s values. In the compute function, we need to call pool.get_values instead of pool.get_value to get a list of all the values that were specified for the parameter in question. By nesting loops over all parameters, we visit all combinations of all parameters as specified by the user: def distance_table(pool): """Grab multiple values of parameters from the pool.""" table = [] for v_0 in pool.get_values(’initial velocity’): for a in pool.get_values(’acceleration’): for t in pool.get_values(’time’): s = v_0*t + 0.5*a*t**2 table.append((v_0, a, t, s)) return table

In case just a single value was specified for a parameter, pool.get_values returns this value only and there will be only one pass in the associated loop. After loading command-line arguments into our pool object, we can call distance_table instead of distance or distance_unit and write out a nicely formatted table of results: table = distance_table(pool) print ’|-----------------------------------------------------|’ print ’| v_0 | a | t | s |’ print ’|-----------------------------------------------------|’ for v_0, a, t, s in table: print ’|%11.3f | %10.3f | %10.3f | %12.3f |’ % (v_0, a, t, s) print ’|-----------------------------------------------------|’

Here is a sample run,

14

1 Dimensions and units Terminal

Terminal> python distance.py --time ’1 h & 2 h & 3 h’ \ --acceleration ’0 m/s**2 & 1 m/s**2 & 1 yd/s**2’ \ --initial_velocity ’1 & 5’ |-----------------------------------------------------| | v_0 | a | t | s | |-----------------------------------------------------| | 1.000 | 0.000 | 3600.000 | 3600.000 | | 1.000 | 0.000 | 7200.000 | 7200.000 | | 1.000 | 0.000 | 10800.000 | 10800.000 | | 1.000 | 1.000 | 3600.000 | 6483600.000 | | 1.000 | 1.000 | 7200.000 | 25927200.000 | | 1.000 | 1.000 | 10800.000 | 58330800.000 | | 1.000 | 0.914 | 3600.000 | 5928912.000 | | 1.000 | 0.914 | 7200.000 | 23708448.000 | | 1.000 | 0.914 | 10800.000 | 53338608.000 | | 5.000 | 0.000 | 3600.000 | 18000.000 | | 5.000 | 0.000 | 7200.000 | 36000.000 | | 5.000 | 0.000 | 10800.000 | 54000.000 | | 5.000 | 1.000 | 3600.000 | 6498000.000 | | 5.000 | 1.000 | 7200.000 | 25956000.000 | | 5.000 | 1.000 | 10800.000 | 58374000.000 | | 5.000 | 0.914 | 3600.000 | 5943312.000 | | 5.000 | 0.914 | 7200.000 | 23737248.000 | | 5.000 | 0.914 | 10800.000 | 53381808.000 | |-----------------------------------------------------|

Notice that some of the multiple values have dimensions different from the registered dimension for that parameter, and the table shows that conversion to the right dimension has taken place.

1.2.6 Generating a graphical user interface For the fun of it, we can easily generate a graphical user interface via Parampool. We wrap the distance_unit function in a function that returns the result in some nice-looking HTML code: def distance_unit2(pool): # Wrap result from distance_unit in HTML s, s_unit = distance_unit(pool) return ’Distance: %.2f %s’ % (s, s_unit)

In addition, we must make a file generate_distance_GUI.py with the simple content from parampool.generator.flask import generate from distance import distance_unit2, define_input generate(distance_unit2, pool_function=define_input, MathJax=True)

1.2 Parampool: user interfaces with automatic unit conversion

15

Running generate_distance_GUI.py creates a Flask-based web interface15 to our distance_unit function, see Figure 1.1. The text fields in this GUI allow specification of parameters with numbers and units, e.g., acceleration with unit yards per minute squared, as shown in the figure. Hovering the mouse slightly to the left of the text field causes a little black window to pop up with the registered unit of that parameter.

Fig. 1.1 Web GUI where parameters can be specified with units.

With examples shown above, the reader should be able to make use of the PhysicalQuantity object and the Parampool package in programs and thereby work safely with units. For the coming text, where we discuss the craft of scaling in detail, we shall just work in standard SI units and avoid unit conversion so there will be no more use of PhysicalQuantity and Parampool. Open Access This chapter is distributed under the terms of the Creative Commons AttributionNonCommercial 2.5 License (http://creativecommons.org/licenses/by-nc/2.5/), which permits any noncommercial use, distribution, and reproduction in any medium, provided the original author(s) and source are credited. The images or other third party material in this book are included in the work’s Creative Commons license, unless indicated otherwise in the credit line; if such material is not included in the work’s Creative Commons license and the respective action is not permitted by statutory regulation, users will need to obtain permission from the license holder to duplicate, adapt, or reproduce the material.

15 You need to have Flask and additional packages installed. This is easy to do with a few pip install commands, see [5] or [6].

Chapter 2

Ordinary differential equation models

This chapter introduces the basic techniques of scaling and the ways to reason about scales. The first class of examples targets exponential decay models, starting with the simple ordinary differential equation (ODE) for exponential decay processes: u = −au, with constant a > 0. Then we progress to various generalizations of this ODE, including nonlinear versions and systems of ODEs. The next class of examples concerns second-order ODEs for oscillatory systems, where the simplest ODE reads mu + ku = 0, with m and k as positive constants. Various extensions with damping and force terms are discussed in detail.

2.1 Exponential decay problems 2.1.1 Fundamental ideas of scaling Scaling is an extremely useful technique in mathematical modeling and numerical simulation. The purpose of the technique is three-fold: 1. Make independent and dependent variables dimensionless. 2. Make the size of independent and dependent variables about unity. 3. Reduce the number of independent physical parameters in the model. The first two items mean that for any variable, denote it by q, we introduce a corresponding dimensionless variable q¯ =

q − q0 , qc

© The Author(s) 2016 H.P. Langtangen and G.K. Pedersen, Scaling of Differential Equations, Simula SpringerBriefs on Computing 2, DOI 10.1007/978-3-319-32726-6_2

17

18

2 Ordinary differential equation models

where q0 is a reference value of q (q0 = 0 is a common choice) and qc is a characteristic size of |q|, often referred to as “a scale”. Since the numerator and denominator have the same dimension, q¯ becomes a dimensionless number. q | ≤ 1. How to find If qc is the maximum value of |q − q0 |, we see that 0 < |¯ qc is sometimes the big challenge of scaling. Examples will illustrate various approaches to meet this challenge. The many coming examples on scaling differential equations contain the following pedagogical ingredients to meet the desired learning outcomes. • Teach the technical steps of making a mathematical model, based on differential equations, dimensionless. • Describe various techniques for reasoning about the scales, i.e., finding the characteristic sizes of quantities. • Teach how to identify and interpret dimensionless numbers arising from the scaling process. • Provide a lot of different examples on making models dimensionless with physically correct scales. • Show how symbolic software (SymPy) can be used to derive exact solutions of differential equations. • Explain how to run a dimensionless model with software developed for the problem with dimensions.

2.1.2 The basic model problem Processes undergoing exponential reduction can be modeled by the ODE problem u (t) = −au(t),

u(0) = I,

(2.1)

where a, I > 0 are prescribed parameters, and u(t) is the unknown function. For the particular model with a constant a, we can easily derive the exact solution, u(t) = Ie−at , which is helpful to have in mind during the scaling process. Example: Population dynamics. The evolution of a population of humans, animals, cells, etc., under unlimited access to resources, can be modeled by (2.1). Then u is the number of individuals in the population, strictly speaking an integer, but well modeled by a real number in large populations. The parameter a is the increase in the number of individuals per time and per individual. Example: Decay of pressure with altitude. The simple model (2.1) also governs the pressure in the atmosphere (under many assumptions, such air is an ideal gas in equilibrium). In this case u is the pressure, measured in Nm−2 ;

2.1 Exponential decay problems

19

t is the height in meters; and a = M/(R∗ T ), where M is the molar mass of the Nm ), Earth’s air (0.029 kg/mol), R∗ is the universal gas constant (8.314 mol K and T is the temperature in Kelvin (K). The temperature depends on the height so we have a = a(t).

2.1.3 The technical steps of the scaling procedure Step 1: Identify independent and dependent variables. There is one independent variable, t, and one dependent variable, u. Step 2: Make independent and dependent variables dimensionless. We introduce a new dimensionless t, called t¯, defined by t t¯ = , tc

(2.2)

where tc is a characteristic value of t. Similarly, we introduce a dimensionless u, named u ¯, according to u u ¯= , (2.3) uc where uc is a constant characteristic size of u. When u has a specific interpretation, say when (2.1) models pressure in an atmospheric layer, uc would be referred to as characteristic pressure. For a decaying population, uc may be a characteristic number of members in the population, e.g., the initial population I. Step 3: Derive the model involving only dimensionless variables. The next task is to insert the new dimensionless variables in the governing mathematical model. That is, we replace t by tc t¯ and u by uc u ¯ in (2.1). The derivative with respect to t¯ is derived through the chain rule as ¯) dt¯ d¯ u1 u uc d¯ du d(uc u = = uc = . ¯ ¯ dt tc dt¯ dt dt d t tc The model (2.1) now becomes u uc d¯ ¯, = −auc u tc dt¯

uc u ¯(0) = I .

(2.4)

Step 4: Make each term dimensionless. Equation (2.4) still has terms with dimensions. To make each term dimensionless, we usually divide by the coefficient in front of the term with the highest time derivative (but dividing by any coefficient in any term will do). The result is d¯ u ¯, = −atc u dt¯

u ¯(0) = u−1 c I.

(2.5)

20

2 Ordinary differential equation models

Step 5: Estimate the scales. A characteristic quantity like tc reflects the time scale in the problem. Estimating such a time scale is certainly the most challenging part of the scaling procedure. There are different ways to reason. The first approach is to aim at a size of u ¯ and its derivatives that is of order u| is of size unity, we see from (2.5) that unity. If uc is chosen such that |¯ d¯ u/dt¯ is of the size of u ¯ (i.e., unity) if we choose tc = 1/a. Alternatively, we may look at a special case of the model where we have analytical insight that can guide the choice of scales. In the present problem we are lucky to know the exact solution for any value of the input data as long as a is a constant. For exponential decay, u(t) ∼ e−at , it is common to define a characteristic time scale tc as the time it takes to reduce the initial value of u by a factor of 1/e (also called the e-folding time): 1 e−atc = e−a·0 ⇒ e−atc = e−1 , e from which it follows that tc = 1/a. Note that using an exact solution of the problem to determine scales is not a requirement, just a useful help in the few cases where we actually have access to an exact solution. In this example, two different, yet common ways of reasoning, lead to the same value of tc . However, instead of using the e-folding time we could use the half-time of the exponential decay as characteristic time, which is also a very common measure of the time scale in such processes. The half time is defined as the time it takes to halve u: 1 e−atc = e−a·0 ⇒ tc = a−1 ln 2 . 2 There is a factor ln 2 = 0.69 difference from the other tc value. As long as the factor is not an order of magnitude or more different, we do not pay attention factors like ln 2 and skip them, simply to make formulas look nicer. Using tc = a−1 ln 2 as time scale leads to a scaled differential equation u = −(ln 2)u, which is fine, but an unusual form. People tend to prefer the simpler ODE u = −u, which arises from tc = 1/a, and we shall therefore use this time scale. Regarding uc , we may look at the initial condition and realize that the ¯(0) = 1. For t > 0, the differential equation expresses choice uc = I makes u ¯ ∈ (0, 1]. Scaling a variable q such explicitly that u decreases, so uc = I gives u that |¯ q | ∈ [0, 1] is always the ultimate goal, and this goal is in fact obtained here! Next best result is to ensure that the magnitude of |q| is not “big” or “small”, in the sense that the size is neither as large as 10 or 100, nor as small as 0.1 or 0.01. (In the present problem, where we are lucky to have an exact solution u(t) = Ie−at , we may look at this to explicitly see that u ∈ (0, I] such ¯ ∈ (0, 1]). that uc = I gives u With tc = 1/a and uc = I, we have the final dimensionless model d¯ u = −¯ u, dt¯

u ¯(0) = 1 .

(2.6)

2.1 Exponential decay problems

21

This is a remarkable result in the sense that all physical parameters (a and I) are removed from the model! Or more precisely, there are no physical input parameters to assign before using the model. In particular, numerical investigations of the original model (2.1) would need experiments with different a and I values, while numerical investigations of (2.6) can be limited to a single run! As soon as we have computed the curve u ¯(t¯), we can find the solution u(t) of (2.1) by ¯(t/tc ) = I u ¯(at) . u(t) = uc u

(2.7)

This particular transformation actually means stretching the t¯ and u ¯ axes in a plot of u ¯(t¯) by the factors a and I, respectively. It is very common to drop the bars when the scaled problem has been derived and work further with (2.6) simply written as du = −u, u(0) = 1 . dt Nevertheless, in this booklet we have decided to stick to bars for all dimensionless quantities.

2.1.4 Making software for utilizing the scaled model Software for solving (2.1) could take advantage of the fact that only one simulation of (2.6) is necessary. As soon as we have u ¯(t¯) accessible, a simple scaling (2.7) computes the real u(t) for any given input data a and I. Although the numerical computation of u(t) from (2.1) is very fast in this simple model problem, using (2.7) is very much faster. In general, a simple rescaling of a scaled solution is extremely more computationally efficient than solving a differential equation problem. We can compute with the dimensionless model (2.6) in two ways, either make a solver for (2.6), or reuse a solver for (2.1) with I = 1 and a = 1. We will choose the latter approach since it has the advantage of giving us software that works both with a dimensionless model and a model with dimensions (and all the original physical parameters). Software for the original unscaled problem. Assume that we have some module decay.py that offers the following functions: • solver(I, a, T, dt, theta=0.5) for returning the solution arrays u and t, over a time interval [0, T ], for (2.1) solved by the so-called θ rule. This rule includes the Forward Euler scheme (θ = 0), the Backward Euler scheme (θ = 1), or the Crank-Nicolson (centered midpoint) scheme (θ = 12 ). • read_command_line_argparse() for reading parameters in the problem from the command line and returning them: I, a, T, theta (θ), and a list of Δt values for time steps. (We shall only make use of the first Δt value.)

22

2 Ordinary differential equation models

The basic statements for solving (2.1) are then from decay import solver, read_command_line_argparse I, a, T, theta, dt_values = read_command_line_argparse() u, t = solver(I, a, T, dt_values[0], theta) from matplotlib.pyplot import plot, show plot(t, u) show()

The module decay.py is developed and explained in Section 5.1.7 in [3]. To solve the dimensionless problem, just fix I = 1 and a = 1, and choose T¯ and Δt¯: _, _, T, theta, dt_values = read_command_line_argparse() u, t = solver(I=1, a=1, T=T, dt=dt_values[0], theta=theta)

The first two variables returned from read_command_line_argparse are I and a, which are ignored here. To indicate that these variables are not to be used, we use a “dummy name”, often taken to be the underscore symbol in Python. The user can set –I and –a on the command line, since the decay module allows this, but we hope the code above has a form that reminds the user that these options are not to be used. Also note that T and dt_values[0] set on the command line are the desired parameters for solving the scaled problem. Software for the scaled problem. Turning now to the scaled problem, the solver function (originally designed for the unscaled problem) will be reused, but it will only be run if it is strictly necessary. That is, when the user requests a solution, our code should first check whether that solution can be provided by simply scaling a solution already computed and available in a file. If not, we will compute an appropriate scaled solution, find the requested unscaled solution for the user, and also save the new scaled solution to file for possible later use. A very plain solution to the problem is found in the file decay_scaled_ v1.py. The np.savetxt function saves a two-dimensional array (“table”) to a text file, and the np.loadtxt function can load the data back into the program. A better solution to this problem is obtained by using the joblib package as described next. Implementation with joblib. The Python package joblib has functionality that is very convenient for implementing the solver_scaled function. The first time a function is called with a set of arguments, the statements in the function are executed and the return value is saved to file. If the function is called again with the same set of arguments, the statements in the function are not executed, but the return value is read from file (of course, many files may be stored, one for each combination of parameter values). In computer science, one would say that joblib in this way provides memorization functionality for Python functions. This functionality is particularly aimed at

2.1 Exponential decay problems

23

large-scale computations with arrays that one would hesitate to recompute. We illustrate the technique here in a very simple mathematical context. First we make a solver_scaled function for the scaled model that just calls up a solver_unscaled (with I = a = 1) for the problem with dimensions: from decay import solver as solver_unscaled import numpy as np import matplotlib.pyplot as plt def solver_scaled(T, dt, theta): """ Solve u’=-u, u(0)=1 for (0,T] with step dt and theta method. """ print ’Computing the numerical solution’ return solver_unscaled(I=1, a=1, T=T, dt=dt, theta=theta)

Then we create some “computer memory on disk”, i.e., some disk space to store the result of a call to the solver_scaled function. Thereafter, we redefine the name solver_scaled to a new function, created by joblib, which calls our original solver_scaled function if necessary and otherwise loads data from file: import joblib disk_memory = joblib.Memory(cachedir=’temp’) solver_scaled = disk_memory.cache(solver_scaled)

The solutions are actually stored in files in the cache directory temp. A typical use case is to read values from the command line, solve the scaled problem (if necessary), unscale the solution, and visualize the solution with dimension: def unscale(u_scaled, t_scaled, I, a): return I*u_scaled, a*t_scaled from decay import read_command_line_argparse def main(): # Read unscaled parameters, solve and plot I, a, T, theta, dt_values = read_command_line_argparse() dt = dt_values[0] # use only the first dt value T_bar = a*T dt_bar = a*dt u_scaled, t_scaled = solver_scaled(T_bar, dt_bar, theta) u, t = unscale(u_scaled, t_scaled, I, a) plt.figure() plt.plot(t_scaled, u_scaled) plt.xlabel(’scaled time’); plt.ylabel(’scaled velocity’) plt.title(’Universial solution of scaled problem’) plt.savefig(’tmp1.png’); plt.savefig(’tmp1.pdf’) plt.figure() plt.plot(t, u) plt.xlabel(’t’); plt.ylabel(’u’) plt.title(’I=%g, a=%g, theta=%g’ % (I, a, theta)) plt.savefig(’tmp2.png’); plt.savefig(’tmp2.pdf’) plt.show()

24

2 Ordinary differential equation models

The complete code resides in the file decay_scaled.py. Note from the code above that read_command_line_argparse is supposed to read parameters with dimensions (but technically, we solve the scaled problem, if strictly necessary, and unscale the solution). Let us run Terminal

Terminal> python decay_scaled.py --I 8 --a 0.1 --dt 0.01 --T 50

A plot of the scaled and unscaled solution appears in Figure 2.1.

Fig. 2.1 Scaled (left) and unscaled (right) exponential decay.

Note that we write a message Computing the numerical solution inside the solver_scaled function. We can then easily detect when the solution is actually computed from scratch and when it is simply read from file (followed by the unscaling procedure). Here is a demo: Terminal

Terminal> # Very first run Terminal> python decay_scaled.py --T 7 --a 1 --I 0.5 --dt 0.2 [Memory] Calling __main__--home-hpl... solver_scaled-alias(7.0, 0.2, 0.5) Computing the numerical solution Terminal> # No change of T, dt, theta - can reuse solution in file Terminal> python decay_scaled.py --T 7 --a 4 --I 2.5 --dt 0.2 Terminal> # Change of dt, must recompute Terminal> python decay_scaled.py --T 7 --a 4 --I 2.0 --dt 0.5 [Memory] Calling __main__--home-hpl... solver_scaled-alias(7.0, 0.5, 0.5) Computing the numerical solution Terminal> # Change of dt again, but dt=0.2 is already in a file Terminal> python decay_scaled.py --T 7 --a 0.5 --I 1 --dt 0.2

We realize that joblib has access to all previous runs and does not recompute unless it is strictly required. Our previous implementation without

2.1 Exponential decay problems

25

joblib (in decay_scaled_v1.py) used only one file (for one numerical case) and will therefore perform many more calls to solver_unscaled. On the implementation of a simple memoize function A memoized function recalls previous results when the same set of arguments is encountered. That is, the function caches its results. A simple implementation stores the arguments in a function call and the returned results in a dictionary, and if the arguments are seen again, one looks up in the dictionary and returns previously computed results: class Memoize: def __init__(self, f): self.f = f self.memo = {} # map arguments to results def __call__(self, *args): if not args in self.memo: self.memo[args] = self.f(*args) return self.memo[args] # Wrap my_compute_function(arg1, arg2, ...) my_compute_function = Memoize(my_compute_function)

The memoize functionality in joblib.Memory is more sophisticated and can work very efficiently with large array data structures as arguments. Note that the simple version above can only be used when all arguments to the function f are immutable (since the key in a dictionary has to be immutable).

2.1.5 Scaling a generalized problem Now we consider an extension of the exponential decay ODE to the form u (t) = −au(t) + b,

u(0) = I .

(2.8)

One particular model, with constant a and b, is a spherical small-sized organism falling in air,    3πdμ  u+g u =− −1 , (2.9) b V b where d, μ, b , , V , and g are physical parameters. The function u(t) represents the vertical velocity, being positive upwards. We shall use this model in the following.

26

2 Ordinary differential equation models

Exact solution. It can be handy to have the exact solution for reference, in case of constant a and b: ue (t) =

 e−at  at b(e − 1) + aI . a

Solving differential equations in SymPy It can be very useful to use a symbolic computation tool such as SymPy to aid us in solving differential equations. Let us therefore demonstrate how SymPy can be used to find this solution. First we define the parameters in the problem as symbols and u(t) as a function: >>> from sympy import * >>> t, a, b, I = symbols(’t a b I’, real=True, positive=True) >>> u = symbols(’u’, cls=Function)

The next task is to define the differential equation, either as a symbolic expression that is to equal zero, or as an equation Eq(lhs, rhs) with lhs and rhs as expressions for the left- and right-hand side): >>> >>> >>> >>>

# Define differential equation eq = diff(u(t), t) + a*u(t) - b # or eq = Eq(diff(u(t), t), -a*u(t) + b)

The differential equation can be solved by the dsolve function, yielding an equation of the form u(t) == expression. We want to grab the expression on the right-hand side as our solution: >>> sol = dsolve(eq, u(t)) >>> print sol u(t) == (b + exp(a*(C1 - t)))/a >>> u = sol.rhs >>> print u (b + exp(a*(C1 - t)))/a

# grab solution

The solution contains the unknown integration constant C1, which must be determined by the initial condition. We form the equation arising from the initial condition u(0) = I: >>> C1 = symbols(’C1’) >>> eq = Eq(u.subs(t, 0), I) >>> sol = solve(eq, C1) >>> print sol [log(I*a - b)/a]

# substitute t by 0 in u

The one solution that was found (stored in a list!) must then be substituted back in the expression u to yield the final solution:

2.1 Exponential decay problems

27

>>> u = u.subs(C1, sol[0]) >>> print u (b + exp(a*(-t + log(I*a - b)/a)))/a

As in mathematics with pen and paper, we strive to simplify expressions also in symbolic computing software. This frequently requires some trial and error process with SymPy’s simplification functions. A very standard first try is to expand everything and run simplification algorithms: >>> u = simplify(expand(u)) >>> print u (I*a + b*exp(a*t) - b)*exp(-a*t)/a

Doing latex(u) automatically converts the expression to LATEX syntax for inclusion in reports. The reader may wonder why we bother with scaling of differential equations if SymPy can solved the problem in a nice, closed formula. This is true in the present introductory problem, but in a more general problem setting, we have some differential equation where SymPy perhaps can help with finding an exact solution only in a special case. We can use this special-case solution to control our reasoning about scales in the more general setting. Theory. The challenges in our scaling is to find the right uc and tc scales. From (2.8) we see that if u → 0 as t → ∞, u approaches the constant value b/a. It can be convenient to let the scaled u ¯ → 1 as we approach the d¯ u/dt¯ = 0 state. This idea points to choosing uc =

b =g a



 −1  3πdμ −1 . b b V

(2.10)

On the sign of the scaled velocity A little note on the sign of uc is necessary here. With b < , the buoyancy force upwards wins over the gravity force downwards, and the body will move upwards. In this case, the terminal velocity uc > 0. When b > , we get a motion downwards, and uc < 0. The corresponding u is then also negative, but the scaled velocity u/uc , becomes positive. Inserting u = uc u ¯ = b¯ u/a and t = tc t¯ in (2.8) leads to tc d¯ u u + b, = −tc a¯ ¯ uc dt

a u ¯(0) = I . b

28

2 Ordinary differential equation models

We want the scales such that d¯ u/dt¯ and u ¯ are about unity. To balance the size of u ¯ and d¯ u/dt¯ we must therefore choose tc = 1/a, resulting in the scaled ODE problem d¯ u = −¯ u + 1, dt¯ where β is a dimensionless number, β=

u ¯(0) = β,

(2.11)

a I =I , uc b

(2.12)

reflecting the ratio of the initial velocity and the terminal (t → ∞) velocity b/a. Scaled equations normally end up with one or more dimensionless parameters, such as β here, containing ratios of physical effects in the model. Many more examples on dimensionless parameters will appear in later sections. The analytical solution of the scaled model (2.11) reads   u¯e (t) = e−t et − 1 + β = 1 + (β − 1)e−t .

(2.13)

The result (2.11) with the solution (2.13) is actually astonishing if a and b are as in (2.9): the six parameters d, μ, b , , V , and g are conjured to one: β=I

3πdμ 1 b V g



 −1 b

−1 ,

which is an enormous simplification of the problem if our aim is to investigate how u varies with the physical input parameters in the model. In particular, if the motion starts from rest, β = 0, and there are no physical parameters in the scaled model! We can then perform a single simulation and recover all physical cases by the unscaling procedure. More precisely, having computed u ¯(t¯) from (2.11), we can use b ¯(at), (2.14) u(t) = u a to scale back to the original problem again. We observe that (2.11) can utilize a solver for (2.8) by setting a = 1, b = 1, and I = β. Given some implementation of a solver for (2.8), say solver(I, a, b, T, dt, theta), the scaled model is run by solver(beta, 1, 1, T, dt, theta). Software. We may develop a solver for the scaled problem that uses joblib to cache solutions with the same β, Δt, and T . For now we fix θ = 0.5. The module decay_vc.py (see Section 3.1.3 in [3] for details) has a function solver(I, a, b, T, dt, theta) for solving u (t) = −a(t)u(t) + b(t) for t ∈ (0, T ], u(0) = I, with time step dt. We reuse this function and call it with a = b = 1 and I = β to solve the scaled problem:

2.1 Exponential decay problems

29

from decay_vc import solver as solver_unscaled def solver_scaled(beta, T, dt, theta=0.5): """ Solve u’=-u+1, u(0)=beta for (0,T] with step dt and theta method. """ print ’Computing the numerical solution’ return solver_unscaled( I=beta, a=lambda t: 1, b=lambda t: 1, T=T, dt=dt, theta=theta) import joblib disk_memory = joblib.Memory(cachedir=’temp’) solver_scaled = disk_memory.cache(solver_scaled)

If we want to plot the physical solution, we need an unscale function, def unscale(u_scaled, t_scaled, d, mu, rho, rho_b, V): a, b = ab(d, mu, rho, rho_b, V) return (b/a)*u_scaled, a*t_scaled def ab(d, mu, rho, rho_b, V): g = 9.81 a = 3*pi*d*mu/(rho_b*V) b = g*(rho/rho_b - 1) return a, b

Looking at droplets of water in air, we can fix some of the parameters and let the size parameter d be the one for experimentation. The following function sets physical parameters, computes β, runs the solver for the scaled problem (joblib detects if it is necessary), and finally plots the scaled curve u ¯(t¯) and the unscaled curve u(t). def main(dt=0.075, # Time step, scaled problem T=7.5, # Final time, scaled problem d=0.001, # Diameter (unscaled problem) I=0, # Initial velocity (unscaled problem) ): # Set parameters, solve and plot rho = 0.00129E+3 # air rho_b = 1E+3 # density of water mu = 0.001 # viscosity of water # Asumme we have list or similar for d if not isinstance(d, (list,tuple,np.ndarray)): d = [d] legends1 = [] legends2 = [] plt.figure(1) plt.figure(2) betas = []

# beta values already computed (for plot)

30

2 Ordinary differential equation models

for d_ in d: V = 4*pi/3*(d_/2.)**3 a, b = ab(d_, mu, rho, beta = I*a/b # Restrict to 3 digits beta = abs(round(beta,

# volume rho_b, V) in beta 3))

print ’beta=%.3f’ % beta u_scaled, t_scaled = solver_scaled(beta, T, dt) # Avoid plotting curves with the same beta value if not beta in betas: plt.figure(1) plt.plot(t_scaled, u_scaled) plt.hold(’on’) legends1.append(’beta=%g’ % beta) betas.append(beta) plt.figure(2) u, t = unscale(u_scaled, t_scaled, d_, mu, rho, rho_b, V) plt.plot(t, u) plt.hold(’on’) legends2.append(’d=%g [mm]’ % (d_*1000)) plt.figure(1) plt.xlabel(’scaled time’); plt.ylabel(’scaled velocity’) plt.legend(legends1, right’) The most complicated partloc=’lower of the code is related to plotting, but this part

can be skipped when trying to understand how we work with a scaled model to perform the computations. The complete program is found in the file falling_body.py. Since I = 0 implies β = 0, we can run different d values without any need to recompute u ¯(t¯) as long as we assume the particle starts from rest. From the scaling, we see that uc = b/a ∼ d−2 and also that tc = 1/a ∼ d−2 , so plotting of u(t) with dimensions for various d values will involve significant variations in the time and velocity scales. Figure 2.2 has an example with d = 1, 2, 3 mm, where we clearly see the different time and velocity scales in the figure with unscaled variables. Note that the scaled velocity is positive because of the sign of uc (see the box above).

Fig. 2.2 Velocity of falling body: scaled (left) and with dimensions (right).

2.1 Exponential decay problems

31

2.1.6 Variable coefficients When a prescribed coefficient like a(t) in u (t) = −a(t)u(t) varies with time one usually also performs a scaling of this a, a ¯(t¯) =

a(t) − a0 , ac

where the goal is to have the scaled a ¯ of size unity: |¯ a| ≤ 1. This property is obtained by choosing ac as the maximum value of |a(t) − a0 | for t ∈ [0, T ], which is usually a quantity that can be estimated since a(t) is known as a function of t. The a0 parameter can be chosen as 0 here. (It could be tempting ¯ ≤ 1, but then there is at least one point to choose a0 = mint a(t) so that 0 ≤ a where a ¯ = 0 and the differential equation collapses to u = 0.) As an example, imagine a decaying cell culture where we at time t1 change the environment (typically the nutrition) such that the death rate increases by a factor 5. Mathematically, a(t) = d for t < t1 and a(t) = 5d for t ≥ t1 . The model reads u = −a(t)u, u(0) = I. The a(t) function is scaled by letting the characteristic size be ac = d and a0 = 0:  1, t¯ < t1 /tc ¯ a ¯(t) = 5, t¯ ≥ t1 /tc The scaled equation becomes u uc d¯ ¯(t¯)uc u ¯, = ac a tc dt¯

uc u ¯(0) = I .

The natural choice of uc is I. The characteristic time, previously taken as tc = 1/a, can now be chosen as tc = t1 or tc = 1/d. With tc = 1/d we get  1, t¯ < γ au ¯, u ¯(0) = 1, a ¯= (2.15) u ¯ (t¯) = −¯ 5, t¯ ≥ γ where γ = t1 d is a dimensionless number in the problem. With tc = t1 , we get  1, t¯ < 1  ¯ au ¯, u ¯(0) = 1, a ¯= u ¯ (t) = −γ¯ 5, t¯ ≥ 1 The dimensionless parameter γ is now in the equation rather than in the definition of a ¯. Both problems involve γ, which is the ratio between the time when the environmental change happens and the typical time for the decay (1/d).

32

2 Ordinary differential equation models

A computation with the scaled model (2.15) and the original model with dimensions appears in Figure 2.3.

Fig. 2.3 Exponential decay with jump: scaled model (left) and unscaled model (right).

2.1.7 Scaling a cooling problem with constant temperature in the surroundings The heat exchange between a body at temperature T (t) and the surroundings at constant temperature Ts can be modeled by Newton’s law of cooling: T  (t) = −k(T − Ts ),

T (0) = T0 ,

(2.16)

where k is a prescribed heat transfer coefficient. Exact solution. An analytical solution is always handy to have as a control of the choice of scales. The solution of (2.16) is by standard methods for ODEs found to be T (t) = Ts + (T0 − Ts )e−kt . Scaling. Physically, we expect the temperature to start at T0 and then to move toward the temperature of the surroundings (Ts ). We therefore expect that T lies between T0 and Ts . This is mathematically demonstrated by the analytical solution as well. A proper scaling is therefore to scale and translate T according to T − T0 T¯ = . Ts − T0

(2.17)

Now, 0 ≤ T¯ ≤ 1. Scaling time by t¯ = t/tc and inserting T = T0 + (Ts − T0 )T¯ and t = tc t¯ in the problem (2.16) gives

2.1 Exponential decay problems

33

dT¯ = −tc k(T¯ − 1), T¯(0) = 0 . dt¯ A natural choice, as argued in other exponential decay problems, is to choose tc k = 1, which leaves us with the scaled problem dT¯ = −(T¯ − 1), dt¯

T¯(0) = 0 .

(2.18)

No physical parameter enters this problem! Our scaling implies that T¯ starts at 0 and approaches 1 as t¯ → ∞, also in the case Ts < T0 . The physical temperature is always recovered as T (t) = T0 + (Ts − T0 )T¯(k t¯) .

(2.19)

Software. An implementation for (2.16) works for (2.18) by setting k = 1, Ts = 1, and T0 = 0. Alternative scaling. An alternative temperature scaling is to choose T − Ts T¯ = . T0 − Ts

(2.20)

Now T¯ = 1 initially and approaches zero as t → ∞. The resulting scaled ODE problem then becomes dT¯ = −T¯, dt¯

T¯(0) = 1, .

(2.21)

with solution T¯ = e−t¯.

2.1.8 Scaling a cooling problem with time-dependent surroundings Let us apply the model (2.16) to the case when the surrounding temperature varies in time. Say we have an oscillating temperature environment according to Ts (t) = Tm + a sin(ωt),

(2.22)

where Tm is the mean temperature in the surroundings, a is the amplitude of the variations around Tm , and 2π/ω is the period of the temperature oscillations. Exact solution. Also in this relatively simple problem it is possible to solve the differential equation problem analytically. Such a solution may be a good help to see what the scales are, and especially to control other forms for

34

2 Ordinary differential equation models

reasoning about the scales. Using the method of integrating factors for the original differential equation, we have  t −kt −kt +e k ekτ Ts (τ )dτ . T (t) = T0 e 0

With Ts (t) = Tm + a sin(ωt) we can use SymPy to help us with integrations (note that we use w for ω in the computer code): >>> from sympy import * >>> t, k, T_m, a, w = symbols(’t k T_m a w’, real=True, positive=True) >>> T_s = T_m + a*sin(w*t) >>> I = exp(k*t)*T_s >>> I = integrate(I, (t, 0, t)) >>> Q = k*exp(-k*t)*I >>> Q = simplify(expand(Q)) >>> print Q (-T_m*k**2 - T_m*w**2 + a*k*w + (T_m*k**2 + T_m*w**2 + a*k**2*sin(t*w) a*k*w*cos(t*w))*exp(k*t))*exp(-k*t)/((k**2 + w**2))

Reordering the result, we get T (t) = T0 e−kt +Tm (1−e−kt )+(k 2 +ω 2 )−1 (akωe−kt +ak sin(ωt)−akw cos(ωt)) .

Scaling. The scaling (2.17) brings in a time-dependent characteristic temperature scale Ts − T0 . Let us start with a fixed scale, where we take the characteristic temperature variation to be Tm − T0 : T − T0 T¯ = . Tm − T0 We realize by physical reasoning that T sets out at T0 , but with time, it will oscillate around Tm . (This reasoning can be controlled by looking at the exact solution we produced above.) The typical average temperature span is therefore |Tm − T0 |, unless a is much larger than |Tm − T0 | or T0 is very close to Tm . We get from the differential equation, with tc = 1/k as in the former case, k(Tm − T0 )

dT¯ = −k((Tm − T0 )T¯ + T0 − Tm − a sin(ωt), dt¯

resulting in dT¯ = −T¯ + 1 + α sin(β t¯), dt¯ where we have two dimensionless numbers: α=

a , Tm − T 0

β=

T¯(0) = 0,

ω . k

(2.23)

2.1 Exponential decay problems

35

The α quantity measures the ratio of temperatures: amplitude of oscillations versus distance from initial temperature to the average temperature for large times. The β number is the ratio of the two time scales: the frequency of the oscillations in Ts and the inverse e-folding time of the heat transfer. For clear interpretation of β we may introduce the period P = 2π/ω of the oscillations in Ts and the e-folding time e = 1/k. Then β = 2πe/P and measures the e-folding time versus the period. Remark The original problem features five physical parameters: k, T0 , Tm , a, and ω, but only two dimensionless numbers appear in the scaled model (2.23). In fact, this is an example where application of the Pi theorem (see Section 1.1.3) falls short. Since, only time and temperature are involved as unit types, the theorem predicts that the five parameters yields three dimensionless numbers, not two. Scaling of the differential equations, on the other hand, shows us that the two parameters Tm and T0 affect the nature of the problem only through their difference.

Software. Implementations of the unscaled problem (2.16) can be reused for the scaled model by setting k = 1, T0 = 0, and Ts (t) = 1 + α sin(β t¯) (Tm = 1, a = α, ω = β). The file osc_cooling.py contains solvers for the problem with dimensions and for the scaled problem. The figure below shows three cases of β values: small, medium, and large.

For the small β value, the oscillations in the surrounding temperature are slow enough compared to k for the heating and cooling process to follow the

36

2 Ordinary differential equation models

surrounding temperature, with a small time lag. For larger β, the heating and cooling require more time, and the oscillations get smaller. Discussion of the time scale. There are two time variations of importance in the present problem: heat is transferred to the surroundings at a rate k, and the surroundings have a temperature variation with a period that goes like 1/ω. (We can, when we are so lucky that we have an analytical solution at hand, inspect this solution to see that k impacts the problem through a decay factor e−kt , and ω impacts the problem through oscillations sin(ωt).) The k parameter related to temperature decay points to a time scale tc = 1/k, while the temperature oscillations of the surroundings point to a time scale tc = 1/ω. Which one should be chosen? Bringing the temperature from T0 to the level of the surroundings, Tm , goes like e−kt , so in this process tc = 1/k is the characteristic time. Thereafter, the body’s temperature just responds to the oscillations and the sin(ωt) (and cos(ωt)) term dominates. For these large times, tc = 1/ω is the appropriate time scale. Choosing tc = 1/ω results in dT¯ (2.24) = −β −1 (T¯ − (1 + α sin(t¯))), T¯(0) = 0 . dt¯ Let us illustrate another, less effective, scaling. The temperature scale in (2.17) looks natural, so we apply this choice of scale. The characteristic temperature T0 − Ts now involves a time-dependent term Ts (t). The mathematical steps become a bit more technically involved: T (t) = T0 + (Ts (t) − T0 )T¯, dT dTs ¯ dT¯ dt¯ T + (Ts − T0 ) = . dt dt dt¯ dt With t¯ = t/tc = kt we get from the differential equation dT¯ dTs ¯ T + (Ts − T0 ) k = −k(T¯ − 1)(Ts − T0 ), dt dt¯ which after dividing by k(Ts − T0 ) results in T¯ dT¯ dTs , = −(T¯ − 1) − dt k(Ts − T0 dt¯ or dT¯ aω cos(ω t¯/k) T¯ . = −(T¯ − 1) − ¯ dt k(Tm + a sin(ω t¯/k) − T0 ) The last term is complicated and becomes more tractable if we factor out dimensionless numbers. To this end, we scale Ts by (e.g.) Tm , which means to factor out Tm in the denominator. We are then left with

2.1 Exponential decay problems

37

dT¯ cos(β t¯) T¯, = −(T¯ − 1) − αβ dt¯ 1 + α sin(β t¯) − γ

(2.25)

where α, β, and γ are dimensionless numbers characterizing the relative importance of parameters in the problem: α = a/Tm ,

β = ω/k,

γ = T0 /Tm .

(2.26)

We notice that (2.25) is not a special case of the original problem (2.16). Furthermore, the original five parameters k, Tm , a, ω, and T0 are reduced to three dimensionless parameters. We conclude that this scaling is inferior, because using the temperature scale T0 − Tm enables reuse of the software for the unscaled problem and only two dimensionless parameters appear in the scaled model. Let us briefly mention another possible temperature scaling: T¯ = T /Tm , motivated by the fact that as t → ∞, T will oscillate around Tm , so this T¯ will oscillate around unity. We get the dimensionless ODE dT¯ = −(T¯ − (1 + δ sin(β t¯))), dt¯ with a new dimensionless parameter δ = a/Tm . However, the initial condition becomes T¯(0) = T0 /Tm , and the ratio T0 /Tm is a third dimensionless parameter, so this scaling is also inferior to the one above with only two parameters.

2.1.9 Scaling a nonlinear ODE Exponential growth models, u = au, are not realistic in environments with limited resources. However, by letting a depend on u, the effect of limited resources can well be captured by such a simple differential equation model: u = a(u)u,

u(0) = I .

(2.27)

If the maximum value of u is denoted by M , we have that a(M ) = 0. A simple choice fulfilling this requirement is a(u) = (1 − u/M ). The parameter  can be interpreted as the initial exponential growth rate if we assume that I/M 1, since at t = 0 the model then approximates u = u. The choice a(u) = (1−u/M ) is known as the logistic model for population growth: u = u(1 − u/M ),

u(0) = I .

(2.28)

A more complicated choice of a may be a(u) = (1−u/M )p for some exponent p (this function also fulfills a(M ) = 0 and a ≈  for t = 0).

38

2 Ordinary differential equation models

Scaling. Let us scale (2.27) with a(u) = (1 − u/M )p . The natural scale for u is M (uc = M ), since we know that 0 < u ≤ M , and this makes the dimensionless u ¯ = u/M ∈ (0, 1]. The function a(u) is typically varying between 0 and , so it can be scaled as a ¯(¯ u) =

u a(u) = (1 − )p = (1 − u ¯)p .  M

Time is scaled as t¯ = t/tc for some suitable characteristic time tc . Inserted in (2.27), we get u uc d¯ ¯, = ¯ auc u tc dt¯

uc u ¯(0) = I,

resulting in d¯ u I . ¯)p u ¯, u ¯(0) = = tc (1 − u ¯ M dt A natural choice is tc = 1/ as in other exponential growth models since it leads to the term on the right-hand side to be about unity, just as the left-hand side. (If the scaling is correct, u ¯ and its derivatives are of order unity, so the coefficients must also be of order unity.) Introducing also the dimensionless parameter I , M measuring the fraction of the initial population compared to the maximum one, we get the dimensionless model α=

d¯ u ¯, = (1 − u ¯)p u dt¯

u ¯(0) = α .

(2.29)

Here, we have two dimensionless parameters: α and p. A classical logistic model with p = 1 has only one dimensionless variable. Alternative scaling. We could try another scaling of u where we also translate u ¯: u ¯=

u−I . M

This choice of u ¯ results in d¯ u ¯, u ¯(0) = 0 . (2.30) = (1 − α − u ¯)p u dt¯ The essential difference between (2.29) and (2.30) is that u ¯ ∈ [α, 1] in the former and u ¯ ∈ [0, 1 − α] in the latter. Both models involve the dimensionless numbers α and p. An advantage of (2.29) is that software for the unscaled model can easily be used for the scaled model by choosing I = α, M = 1, and  = 1.

2.1 Exponential decay problems

39

2.1.10 SIR ODE system for spreading of diseases The field of epidemiology frequently applies ODE systems to describe the spreading of diseases, such as smallpox, measles, plague, ordinary flu, swine flu, and HIV. Different models include different effects, which are reflected in dimensionless numbers. Most of the effects are modeled as exponential decay or growth of the dependent variables. The simplest model has three categories of people: susceptibles (S) who can get the disease, infectious (I) who are infected and may infect susceptibles, and recovered (R) who have recovered from the disease and gained immunity. We introduce S(t), I(t), and R(t) as the number of people in the categories S, I, and R, respectively. The model, naturally known as the SIR model1 , can be expressed as a system of three ODEs: dS = −βSI, dt dI = βSI − νI, dt dR = νI, dt

(2.31) (2.32) (2.33)

where β and ν are empirical constants. The average time for recovering from the disease can be shown to be ν −1 , but β is much harder to estimate, so working with a scaled model where β is “scaled away” is advantageous. Scaling. It is natural to scale S, I, and R by, e.g., S(0): S S¯ = , S(0)

I¯ =

I , S(0)

¯= R . R S(0)

Introducing t¯ = t/tc , we arrive at the equations dS¯ ¯ = −tc S(0)β S¯I, dt¯ dI¯ ¯ = tc S(0)β S¯I¯ − tc ν I, dt¯ ¯ dR ¯ = tc ν I, dt¯ ¯ ¯ = I0 /S(0) = α, and R(0) ¯ with initial conditions S(0) = 1, I(0) = R(0)/S(0). Normally, R(0) = 0. Taking tc = 1/ν, corresponding to a time unit equal to the time it takes to recover from the disease, we end up with the scaled model 1

https://en.wikipedia.org/wiki/Epidemic_model

40

2 Ordinary differential equation models

dS¯ ¯ = −R0 S¯I, dt¯ dI¯ ¯ = R0 S¯I¯ − I, dt¯ ¯ dR ¯ = I, dt¯

(2.34) (2.35) (2.36)

¯ ¯ = α, R(0) ¯ with S(0) = 1, I(0) = 0, and R0 as the dimensionless number R0 =

S(0)β . ν

(2.37)

¯ t¯ > 0, and thereWe see from (2.35) that to make the disease spreading, dI/d ¯ ¯ fore R0 S(0) − 1 > 0 or R0 > 1 since S(0) = 1. Therefore, R0 reflects the disease’s ability to spread and is consequently an important dimensionless quantity, known as the basic reproduction number2 . This number reflects the number of infected people caused by one infectious individual during the time period of the disease. Looking at (2.32), we see that to increase I initially, we must have dI/dt > 0 at t = 0, which implies βI(0)S(0) − νI(0) > 0, i.e., R0 > 1. Software. Any implementation of the SIR model with dimensions can be reused for the scaled model by setting β = R0 , ν = 1, S(0) = 1 − α, and I(0) = α. Below is a plot with two cases: R0 = 2 and R0 = 5, both with α = 0.02.

Alternative scaling. Adding (2.31)-(2.33) shows that dS dI dR + + =0 dt dt dt 2



S + I + R = const = N,

https://en.wikipedia.org/wiki/Basic_reproduction_number

2.1 Exponential decay problems

41

where N is the size of the population. We can therefore scale S, I, and R by the total population N = S(0) + I(0) + R(0): S I ¯= R. S¯ = , I¯ = , R N N N With the same time scale, one gets the system (2.34)-(2.36), but with R0 replaced by the dimensionless number: ˜0 = N β . R ν

(2.38)

¯ ¯ = α, and R(0) ¯ The initial conditions become S(0) = 1 − α, I(0) = 0. ¯ ˜ 0 S(0) ¯ = ˜ For the disease to spread at t = 0, we must have R0 S(0) > 1, but R N β/ν ·S(0)/N = R0 , so the criterion is still R0 > 1. Since R0 is a more famous ˜ 0 , we can write the ODEs with R0 /S(0) = R0 /(1 − α) instead number than R ˜ of R0 . Choosing tc to make the SI terms balance the time derivatives, tc = ˜ 0 (or R0 if we scale S, I, and R by S(0)) to the I terms: (N β)−1 , moves R dS¯ ¯ = −S¯I, dt¯ dI¯ ¯ ¯ ˜ −1 ¯ = S I − R0 I, dt¯ ¯ dR ˜ −1 I . =R 0 dt¯

2.1.11 SIRV model with finite immunity A common extension of the SIR model involves finite immunity: after some period of time, recovered individuals lose their immunity and become susceptibles again. This is modeled as a leakage −μR from the R to the S category, where μ−1 is the average time it takes to lose immunity. Vaccination is another extension: a fraction pS is removed from the S category by successful vaccination and brought to a new category V (the vaccinated). The ODE model reads

42

2 Ordinary differential equation models

dS dt dI dt dR dt dV dt

= −βSI − pS + μR,

(2.39)

= βSI − νI,

(2.40)

= νI − μR,

(2.41)

= pS .

(2.42)

Using tc = 1/ν and scaling the unknowns by S(0), we arrive at the dimensionless model dS¯ ¯ = −R0 S¯I¯ − δ S¯ + γ R, dt¯ dI¯ ¯ = R0 S¯I¯ − I, dt¯ ¯ dR ¯ = I¯ − γ R, ¯ dt dV¯ ¯ = δ S, dt¯

(2.43) (2.44) (2.45) (2.46)

with two new dimensionless parameters: γ=

μ , ν

δ=

p . ν

The quantity p−1 can be interpreted as the average time it takes to vaccinate a susceptible successfully. Writing γ = ν −1 /μ−1 and δ = ν −1 /p−1 gives the interpretation that γ is the ratio of the average time to recover and the average time to lose immunity, while δ is the ratio of the average time to recover and the average time to successfully vaccinate a susceptible. The plot in Figure 2.4 has γ = 0.05, i.e., loss of immunity takes 20 weeks if it takes one week to recover from the disease. The left plot corresponds to no vaccination, while the right has δ = 0.5 for a vaccination campaign that lasts from day 7 to day 15. The value δ = 0.5 reflects that it takes two weeks to successfully vaccinate a susceptible, but the effect of vaccination is still dramatic.

2.1.12 Michaelis-Menten kinetics for biochemical reactions A classical reaction model in biochemistry describes how a substrate S is turned into a product P with aid of an enzyme E. S and E react to form

2.1 Exponential decay problems

Fig. 2.4 (right).

43

Spreading of a disease with loss of immunity (left) and added vaccination

a complex ES in the first stage of the reaction. In the second stage, ES is turned into E and P. Introducing the amount of S, E, ES, and P by [S], [E], [ES], and [P ], the mathematical model can be written as d[ES] dt d[P ] dt d[S] dt d[E] dt

= k+ [E][S] − kv [ES] − k− [ES],

(2.47)

= kv [ES],

(2.48)

= −k+ [E][S] + k− [ES],

(2.49)

= −k+ [E][S] + k− [ES] + kv [ES] .

(2.50)

The initial conditions are [ES](0) = [P ](0) = 0, and [S] = S0 , [E] = E0 . Three rate constants are involved: k+ , k− , and kv . The above mathematical model is known as Michaelis-Menten kinetics3 . The amount of substance is measured in the unit mole4 (mol). From the equations we can see that k+ is measured in s−1 mol−1 , while k− and kv are measured in s−1 . It is convenient to get rid of the mole unit for the amount of a substance. When working with dimensionless quantities, only ratios of the rate constants and not their specific values are needed. Classical analysis. A common assumption is that the formation of [ES] is very fast and that it quickly reaches an equilibrium state, [ES] = 0. Equation (2.47) then reduces to the algebraic equation k+ [E][S] − kv [ES] − k− [ES] = 0, which leads to 3 4

https://en.wikipedia.org/wiki/Michaelis-Menten_kinetics https://en.wikipedia.org/wiki/Mole_(unit)

44

2 Ordinary differential equation models

[E][S] k− + kv = = K, [ES] k+

(2.51)

where K is the famous Michaelis constant - the equilibrium constant between [E][S] and [ES]. Another important observation is that the ODE system implies two conservation equations, arising from simply adding the ODEs: d[ES] d[E] + = 0, dt dt d[ES] d[S] d[P ] + + = 0, dt dt dt

(2.52) (2.53)

from which it follows that [ES] + [E] = E0 ,

(2.54)

[ES] + [S] + [P ] = S0 .

(2.55)

We can use (2.54) and (2.51) to express [E] by [S]: [E] = E0 − [ES] = E0 −

[E][S] K



[E] =

KE0 . K + [S]

Now (2.49) can be developed to an equation involving [S] only: d[S] = −k+ [E][S] + k− [ES] dt k− )[E][S] = (−k+ + K KE0 k− )[S] = (−k+ + K K + [S] k− E0 . =− [S] + K We see that the parameter K is central. From above expression for [E] and (2.54) it now follows [E] =

KE0 , K + [S]

[ES] =

E0 [S] . K + [S]

If K is comparable to S0 these indicate [E] ∼ E0 ,

[ES] ∼

E0 S 0 , K

(2.56)

2.1 Exponential decay problems

45

as is used for scaling [E] and Qc , subsequently. Provided we exclude the case [S] K, we may infer that [E] will be of magnitude E0 , while [ES] will be of magnitude E0 S0 /K. Dimensionless ODE system. Let us reason how to make the original ODE system (2.47)-(2.50) dimensionless. Aiming at [S] and [E] of unit size, two obvious dimensionless unknowns are [S] S¯ = , S0

¯ = [E] . E E0

For the other two unknowns we just introduce scales to be determined later: [P ] P¯ = , Pc

¯ = [ES] . Q Qc

With t¯ = t/tc the equations become ¯ dQ dt¯ dP¯ dt¯ dS¯ dt¯ ¯ dE dt¯

E0 S 0 ¯ ¯ ¯ E S − tc (kv + k− )Q, Qc Qc ¯ Q, = tc kv Pc ¯ S¯ + tc k− Qc Q, ¯ = −tc k+ E0 E S0 ¯ S¯ + tc (k− + kv ) Qc Q ¯. = −tc k+ S0 E E0 = tc k+

Determining scales. Choosing the scales is actually a quite complicated matter that requires extensive analysis of the equations to determine the characteristics of the solutions. Much literature is written about this, but here we shall take a simplistic and pragmatic approach. Besides the Michaelis constant K, there is another important parameter, =

E0 , S0

because most applications will involve a small . We shall have K and  in mind while choosing scales such that these symbols appear naturally in the scaled equations. Looking at the equations, we see that the K parameter will appear if tc ∼ 1/k+ . However, 1/k+ does not have the dimension [T]−1 as required, so we need to add a factor with dimension mol. A natural choice is t−1 c = k+ S0 or t−1 = k E . Since often S E , the former t is a short time scale and + 0 0 0 c c the latter is a long time scale. If the interest is in the long time scale, we set tc =

1 . k+ E0

46

2 Ordinary differential equation models

The equations then take the form ¯ dQ dt¯ dP¯ dt¯ dS¯ dt¯ ¯ dE dt¯

S0 ¯ ¯ ¯ E S − KE0−1 Q, Qc kv Qc ¯ Q, = k+ E0 Pc

=

¯ S¯ + = −E

k− Qc ¯ Q, k+ E0 S0

¯ S¯ + K = −−1 E

Qc ¯ Q. E02

The [ES] variable starts and ends at zero, and its maximum value can be roughly estimated from the equation for [ES] by setting [ES] = 0, which gives [E][S] E0 S0 ∼ , K K where we have replaced [E][S] by E0 S0 as an identification of magnitude. This magnitude of [ES] at its maximum can be used as the characteristic size Qc : [ES] =

Qc =

E0 S0 . K

The equation for P¯ simplifies if we choose Pc = Qc . With these assumptions one gets ¯ dQ dt¯ dP¯ dt¯ dS¯ dt¯ ¯ dE dt¯

¯ S¯ − Q), ¯ = KE0−1 (E =

kv ¯ Q, k+ E0

¯ S¯ + = −E

k− E0 ¯ Q, k+ E0 K

¯ S¯ + −1 Q ¯. = −−1 E

We can now identify the dimensionless numbers α=

K , E0

β=

kv , k+ E0

γ=

k− , k+ E0

where we see that α = β + γ, so γ can be eliminated. Moreover,

2.1 Exponential decay problems

47

α=

k− + β, k+ E0

implying that α > β. We arrive at the final set of scaled differential equations: ¯ dQ dt¯ dP¯ dt¯ dS¯ dt¯ ¯ dE  dt¯

¯ S¯ − Q), ¯ = α(E

(2.57)

¯ = β Q,

(2.58)

¯ ¯ S¯ + (1 − βα−1 )Q, = −E

(2.59)

¯ S¯ + Q ¯. = −E

(2.60)

¯ = 1 and Q ¯ = P¯ = 0. The initial conditions are S¯ = E The five initial parameters (S0 , E0 , k+ , k− , and kv ) are reduced to three dimensionless constants: • α is the dimensionless Michaelis constant, reflecting the ratio of the production of P and E (kv + k− ) versus the production of the complex (k+ ), made dimensionless by E0 , •  is the initial fraction of enzyme relative to the substrate, • β measures the relative importance of production of P (kv ) versus production of the complex (k+ ), made dimensionless by E0 . Observe that software developed for solving (2.47)-(2.50) cannot be reused for solving (2.57)-(2.60) since the latter system has a slightly different structure. Conservation equations. The counterpart to the conservation equations (2.54)-(2.55) is obtained by adding (2.57) and α times (2.60), and adding (2.57), (2.58), and α times (2.59): ¯ +E ¯ = 1, −1 α−1 Q ¯ + P¯ = α . αS¯ + Q

(2.61) (2.62)

The scaled quantities, as well as the original concentrations, must be pos¯ ∈ [0, 1], S¯ ∈ [0, 1]. Such checks along with the conserved itive variables, and E quantities above should be performed at every time step in a simulation. Analysis of the scaled system. In the scaled system, we may assume  ¯  = 0, and thereby small, which from (2.60) gives rise to the simplification E ¯+ ¯ =E ¯ S. ¯ The conservation equation [ES] + [E] = E0 reads Qc Q the relation Q ¯ = E0 such that E ¯ 0 = 1 − QS ¯ The ¯ = 1 − Qc Q/E ¯ 0 /K = 1 − −1 α−1 Q. E0 E ¯=E ¯ S¯ then becomes relation Q

48

2 Ordinary differential equation models

¯ = (1 − −1 α−1 Q) ¯ S, ¯ Q ¯ which can be solved for Q: ¯= Q

S¯ 1 + −1 α−1 S¯

.

The equation (2.59) for S¯ becomes ¯ dS¯ ¯ = − βS . = −βα−1 Q dt¯ α + −1 S¯

(2.63)

This is a more precise analysis than the one leading to (2.56) since we now realize that the mathematical assumption for the simplification is  → 0. Is (2.63) consistent with (2.56)? It is easy to make algebraic mistakes when deriving scaled equations, so it is always wise to carry out consistency checks. Introducing dimensions in (2.63) leads to kv kv S¯ dS¯ S β S¯ tc dS = − = − = , =− −1 −1 S0 dt k+ E0 KE0 + E0 S0 S¯ k+ K + S dt¯ α + −1 S¯ and hence with t−1 c = k+ E0 , kv E0 S dS =− , dt K +S which is (2.56). Figure 2.5 shows the impact of : with a moderately small value (0.1) we ¯ ≈ 0, which justifies the simplifications performed above. We also see that Q observe that all the unknowns vary between 0 and about 1, indicating that the scaling is successful for the chosen dimensionless numbers. The simulations made use of a time step Δt¯ = 0.01 with a 4th-order Runge-Kutta method, using α = 1.5, β = 1 (relevant code is in the simulate_biochemical_process function in session.py).

Fig. 2.5 Simulation of a biochemical process.

2.2 Vibration problems

49

However, it is of interest to investigate the limit  → 0. Initially, the equa¯ t¯ reads dE/d ¯ t¯ = −−1 , which implies a very fast reduction of tion for dE/d ¯ decays to ¯ Using  = 0.005 and Δt¯ = 10−3 , simulation results show that E E. ¯ ≈ P¯ ≈ 0. This is reasonable approximately zero at t = 0.03 while S¯ ≈ 1 and Q since with very little enzyme in comparison with the substrate ( → 0) very little will happen.

2.2 Vibration problems We shall in this section address a range of different second-order ODEs for mechanical vibrations and demonstrate how to reason about the scaling in different physical scenarios.

2.2.1 Undamped vibrations without forcing The simplest differential equation model for mechanical vibrations reads mu + ku = 0,

u(0) = I, u (0) = V,

(2.64)

where unknown u(t) measures the displacement of the body, This is a common model for a vibrating body with mass m attached to a linear spring with spring constant k (and force −ku). Figure 2.6 shows a typical mechanical sketch of such a system: some mass can move horizontally without friction and is connected to a spring that exerts a force −ku on the body. u(t) ku

m

Fig. 2.6 Oscillating body attached to a spring.

The first technical steps of scaling. The problem (2.64) has one independent variable t and one dependent variable u. We introduce dimensionless versions of these variables:

50

2 Ordinary differential equation models

u ¯=

u , uc

t t¯ = , tc

where uc and tc are characteristic values of u and t. Inserted in (2.64), we get m

¯ u c d2 u + kuc u ¯ = 0, 2 2 ¯ tc d t

uc u ¯(0) = I,

u uc d¯ (0) = V, tc dt¯

resulting in ¯ t2c k d2 u u ¯ = 0, + m dt¯2

u ¯(0) =

I V tc , u ¯ (0) = . uc uc

(2.65)

What is an appropriate displacement scale uc ? The initial condition u(0) = I is a candidate, i.e., uc = I. But how to choose the time scale? Making the coefficient in front of the u ¯ unity, such that both terms balance and are of size unity, is a candidate. The exact solution. To better see what the proper scales of u and t are, we can look into the analytical solution of this problem. Although the exact solution of (2.64) is quite straightforward to calculate by hand, we take the opportunity to make use of SymPy to find u(t). The use of SymPy can later be generalized to vibration ODEs that are harder to solve by hand. SymPy requires all mathematical symbols to be explicitly created: from sympy import * u = symbols(’u’, cls=Function) w = symbols(’w’, real=True, positive=True) I, V, C1, C2 = symbols(’I V C1 C2’, real=True)

To specify the ODE to be solved, we can make a Python function returning all the terms in the ODE: # Define differential equation: u’’ + w**2*u = 0 def ode(u): return diff(u, t, t) + w**2*u diffeq = ode(u(t))

The diffeq variable, defining the ODE, can be passed to the SymPy function dsolve to find the symbolic solution of the ODE: s = dsolve(diffeq, u(t)) # s is an u(t) == expression (Eq obj.), s.rhs grabs the expression u_sol = s.rhs print u_sol

The solution that gets printed is C1*sin(t*w) + C2*cos(t*w), indicating that there are two integration constants C1 and C2 to be determined by the initial conditions. The result of applying these conditions is a 2 × 2 linear system of algebraic equations that SymPy can solve by the solve function. The code goes as follows:

2.2 Vibration problems

51

# The solution u_sol contains integration constants C1 and C2 # but these are not symbols, substitute them by symbols u_sol = u_sol.subs(’C1’, C1).subs(’C2’, C2) # Determine C1 and C2 from the initial conditions ic = [u_sol.subs(t, 0) - I, u_sol.diff(t).subs(t, 0) - V] print ic # 2x2 algebraic system for C1 and C2 s = solve(ic, [C1, C2]) # s is now a dictionary: {C2: I, C1: V/w} # substitute solution back in u_sol u_sol = u_sol.subs(C1, s[C1]).subs(C2, s[C2]) print u_sol

The u_sol variable is now I*cos(t*w) + V*sin(t*w)/w. Since symbolic software is far from bug-free and can give wrong results, we should always check the answer. Here, we insert the solution in the ODE to see if the result is zero, and we insert the solution in the initial conditions to see that these are fulfilled: # Check that the solution fulfills the ODE and init.cond. print simplify(ode(u_sol)), print u_sol.subs(t, 0) - I, diff(u_sol, t).subs(t, 0) - V

There will be many more examples on using SymPy to find exact solutions of differential equation problems. The solution of the ODE in mathematical notation is  k V . u(t) = I cos(ωt) + sin(ωt), ω = ω m More insight arises from rewriting such an expression in the form A cos(wt − φ):  V2 u(t) = I 2 + 2 cos(wt − φ), φ = tan−1 (V /(ωI)) . ω Now we see that the u corresponds to cosine oscillations with a frequency shift φ and amplitude I 2 + (V /ω)2 . Discussion of the displacement scale. The amplitude of u is I 2 + V 2 /ω 2 , and this expression is obviously a candidate for uc . However, the simpler choice uc = max(I, V /ω) is also relevant and more attractive than the square root expression (but potentially a factor 1.4 wrong compared to the exact amplitude). It is not very important to have |u| ≤ 1, the point is to avoid |u| very small or large. Discussion of the time scale. What is an appropriate time scale? Looking ¯ both should be around at (2.65) and arguing that u ¯ and u unity in size, the 2 coefficient tc k/m must equal unity, implying that tc = m/k. Also from the analytical solution we see that the solution goes like the sine or cosine of ωt, so 1/ω = m/k can be a characteristic time scale. Likewise, one period of the oscillations, P = 2π/ω, can be the characteristic time, leading to tc = 2π/ω.

52

2 Ordinary differential equation models

The dimensionless solution. With uc = I and tc = scaled model



¯ d2 u +u ¯ = 0, u ¯(0) = 1, u ¯ (0) = α, dt¯2 where α is a dimensionless parameter:  V m α= . I k

m/k we get the

(2.66)

Note that in case V = 0, we have “scaled away” all physical parameters. The universal solution without physical parameters is then u ¯(t¯) = cos t¯. The unscaled solution is recovered as u(t) = I u ¯( k/mt¯) . (2.67) This expressions shows that the scaling is simply a matter of stretching or shrinking the axes. Alternative displacement scale. Using uc = V /ω, the equation is not changed, but the initial conditions become  I k I Iω = = α−1 , u u ¯(0) = = ¯ (0) = 1 . uc V V m With uc = V /ω and one period as time scale, tc = 2π m/k, we get the alternative model ¯ d2 u + 4π 2 u ¯ = 0, u ¯(0) = α−1 , u ¯ (0) = 2π . 2 ¯ dt The unscaled solution is in this case recovered by  m u(t) = V u ¯(2π k/mt¯) . k

(2.68)

(2.69)

About frequency and dimensions. The solution goes like cos ωt, where ω = m/k must have dimension 1/s. Actually, ω has dimension radians per second: rad/s. A radian is dimensionless since it is arc (length) divided by radius (length), but still regarded as a unit. The period P of vibrations is a more intuitive quantity than the frequency ω. The relation between P and ω is P = 2π/ω. The number of oscillation cycles per period, f , is a more intuitive measurement of frequency and also known as frequency. Therefore, to be precise, ω should be named angular frequency. The relation between f and T is f = 1/T , so f = 2πω and measured in Hz (1/s), which is the unit for counts per unit time.

2.2 Vibration problems

53

2.2.2 Undamped vibrations with constant forcing For vertical vibrations in the gravity field, the model (2.64) must also take the gravity force −mg into account: mu + ku = −mg . How does the new term −mg influence the scaling? We observe that if there is no movement of the body, u = 0, and the spring elongation matches the gravity force: ku = −mg, leading to a steady displacement u = −mg/k. We can then have oscillations around this equilibrium point. A natural scaling for u is therefore u ¯=

u − (−mg/k) uk + mg = . uc kuc

The scaled differential equation with the same time scale as before reads d2 u ¯ t2 t2 +u ¯ − c g = − c g, 2 ¯ uc uc dt leading to d2 u ¯ +u ¯ = 0. dt¯2 The initial conditions u(0) = I and u (0) = V become, with uc = I,  mg d¯ u mV u ¯(0) = 1 + , . (0) = kI k I dt¯ We see that the oscillations around the equilibrium point in the gravity field are identical to the horizontal oscillations without gravity, except for an offset mg/(kI) in the displacement.

2.2.3 Undamped vibrations with time-dependent forcing Now we add a transient forcing term F (t) to the model (2.64): mu + ku = F (t),

u(0) = I, u (0) = V .

(2.70)

Take the forcing to be oscillating: F (t) = A cos(ψt) . The technical steps of the scaling are still the same, with the intermediate result

54

2 Ordinary differential equation models

t2c d2 u ¯ t2c k u ¯ = + A cos(ψtc t¯), m muc dt¯2

u ¯(0) =

I V tc , u ¯ (0) = . uc uc

(2.71)

What are typical displacement and time scales? This is not so obvious without knowing the details of the solution, because there are three parameters (I, V , and A) that influence the magnitude of u. Moreover, there are two time scales, one for the free vibrations of the systems and one for the forced vibrations F (t). Investigating scales via analytical solutions. As we have seen already several times, having access to an exact solution is very fortunate as it allows us to directly examine the scales. Also in the present problem it is possible to derive an exact solution. We continue the SymPy session from the previous section and perform much of the same steps. Note that we use w for ω = k/m in the computer code (to obtain a more direct visual counterpart to ω). SymPy may get confused when coefficients in differential equations contain several symbols. We therefore rewrite the equation with at most one symbol in each coefficient (i.e., symbolic software is in general more successful when applied to scaled differential equations than the unscaled counterparts, but right now our task is to solve the unscaled version). The amplitude A/m in the forcing term is of this reason replaced by the symbol A1. A, A1, m, psi = symbols(’A A1 m psi’, positive=True, real=True) def ode(u): return diff(u, t, t) + w**2*u - A1*cos(psi*t) diffeq = ode(u(t)) u_sol = dsolve(diffeq, u(t)) u_sol = u_sol.rhs # Determine the constants C1 and C2 in u_sol # (first substitute our own declared C1 and C2 symbols, # then use the initial conditions) u_sol = u_sol.subs(’C1’, C1).subs(’C2’, C2) eqs = [u_sol.subs(t, 0) - I, u_sol.diff(t).subs(t, 0) - V] s = solve(eqs, [C1, C2]) u_sol = u_sol.subs(C1, s[C1]).subs(C2, s[C2]) # Check that the solution fulfills the equation and init.cond. print simplify(ode(u_sol)) print simplify(u_sol.subs(t, 0) - I) print simplify(diff(u_sol, t).subs(t, 0) - V) u_sol = simplify(expand(u_sol.subs(A1, A/m))) print u_sol

The output from the last line is A/m*cos(psi*t)/(-psi**2 + w**2) + V*sin(t*w)/w + (A/m + I*psi**2 - I*w**2)*cos(t*w)/(psi**2 - w**2)

With a bit of rewrite this expression becomes

2.2 Vibration problems

55

  A/m A/m V u(t) = 2 cos(ψt) + sin(ωt) + + I cos(ωt) . ω − ψ2 ω ψ2 − ω2 Obviously, this expression is only meaningful for ψ = ω. The case ψ = ω gives an infinite amplitude in this model, a phenomenon known as resonance. The amplitude becomes finite when damping is included, see Section 2.2.4. When the system starts from rest, I = V = 0, and the forcing is the only driving mechanism, we can simplify: A A cos(ψt) + cos(ωt) m(ω 2 − ψ 2 ) m(ψ 2 − ω 2 ) A (cos(ψt) − cos(ωt)) . = m(ω 2 − ψ 2 )

u(t) =

To gain more insight, cos(ψt) − cos(ωt) can be rewritten in terms of the mean frequency (ψ + ω)/2 and the difference in frequency (ψ − ω)/2:     ψ−ω ψ+ω A 2 sin t sin t , (2.72) u(t) = m(ω 2 − ψ 2 ) 2 2 showing that there is a signal with frequency (ψ + ω)/2 whose amplitude has a (much) slower frequency (ψ − ω)/2. Figure 2.7 shows an example on such a signal.

Fig. 2.7 Signal with frequency 3.1 and envelope frequency 0.2.

56

2 Ordinary differential equation models

The displacement and time scales. A characteristic displacement can in the latter special case be taken as uc = A/(m(ω 2 − ψ 2 )). This is also a relevant choice in the more general case I = 0, V = 0, unless I or V is so large that it dominates over the amplitude caused by the forcing. With uc = A/(m(ω 2 − ψ 2 )) we also have three special cases: ω ψ, ω ψ, and ψ ∼ ω. In the latter case we need uc = A/(m(ω 2 − ψ 2 )) if we want |u| ≤ 1. When ω and ψ are significantly different, we may choose one of them and neglect the smaller. Choosing ω means uc = A/k, which is the relevant scale if ω ψ. In the opposite case, ω ψ, uc = A/(mψ 2 ). The time scale is dominated by the fastest oscillations, which are of frequency ψ or ω when these are close and the largest of them when they are distant. In any case, we set tc = 1/ max(ψ, ω). Finding the displacement scale from the differential equation. Going back to (2.71), we may demand that all the three terms in the differential equation are of size unity. This leads to tc = m/k and uc = At2c /m = A/k. The formula for uc is a kind of measure of the ratio of the forcing and the spring force (the dimensionless number A/(kuc ) would be this ratio). Looking at (2.72), we see that if ψ ω, the amplitude can be approximated by A/(mω 2 ) = A/k, showing that the scale uc = A/k is relevant for an excitation frequency ψ that is small compared to the free vibration frequency ω. Scaling with free vibrations as time scale. The next step is to work out the dimensionless ODE for the chosen scales. We first select the time scale based on the free oscillations with frequency ω, i.e., tc = 1/ω. Inserting the expression in (2.71) results in ¯ d2 u +u ¯ = γ cos(δ t¯), u ¯(0) = α, u ¯ (0) = β . dt¯2 Here we have four dimensionless variables I , uc V tc V β= = , uc ωuc A t2 A , γ= c = muc kuc tc ψ δ = −1 = . ψ ω

α=

(2.73)

(2.74) (2.75) (2.76) (2.77)

We remark that the choice of uc has so far not been made. Several different cases will be considered below, and we will see that certain choices reduce the number of independent dimensionless variables to three. The four dimensionless variables above have interpretations as ratios of physical effects:

2.2 Vibration problems

57

• α: ratio of the initial displacement and the characteristic response uc , • β: ratio of the initial velocity and the typical velocity measure uc /tc , • γ: ratio of the forcing A and the mass times acceleration muc /t2c or the ratio of the forcing and the spring force kuc • δ: ratio of the frequencies or the time scales of the forcing and the free vibrations. Software. Any solver for (2.71) can be used for (2.73). More details are provided at the end of Section 2.2.4. Choice of uc close to resonance. Now we shall discuss various choices of uc . Close to resonance, when ψ ∼ ω, we may set uc = A/(m(ω 2 − ψ 2 )). The dimensionless numbers become in this case I I (1 − δ 2 ), = uc A/k √ V V km (1 − δ 2 ), β= = ωuc A A γ= = 1 − δ2 , kuc ψ δ= . ω

α=

With ψ = 0.99ω, δ = 0.99, V = 0, α = γ = 1 − δ 2 = 0.02, we have the problem d2 u ¯ +u ¯ = 0.02 cos(0.99t¯), u ¯(0) = 0.02, u ¯ (0) = 0 . dt¯2 This is a problem with a very small initial condition and a very small forcing, but the state close to resonance brings the amplitude up to about unity, see the result of numerical simulations with δ = 0.99 in Figure 2.8. Neglecting α, the solution is given by (2.72), which here means A = 1 − δ 2 , m = 1, ω = 1, ψ = δ: u ¯(t¯) = 2 sin(−0.005t¯) sin(0.995t¯) . Note that this is a problem which demands very high accuracy in the numerical calculations. Using 20 time steps per period gives a significant angular frequency error and an amplitude of about 1.4. We used 160 steps per period for the results in Figure 2.8. Unit size of all terms in the ODE. Using the displacement scale uc = A/k leads to (2.73) with

58

2 Ordinary differential equation models

Fig. 2.8 Forced undamped vibrations close to resonance.

I I , = uc A/k V Vk β= , = ωuc Aω A γ= = 1, kuc ψ δ= . ω

α=

Simulating a case with δ = 0.5, α = 1, and β = 0 gives the oscillations in Figure 2.9, which is a case away from resonance, and the amplitude is about unity. However, choosing δ = 0.99 (close to resonance) results in a figure similar to Figure 2.8, except that the amplitude is about 102 because of the moderate size of uc . The present scaling is therefore most suitable away from resonance, and when the terms containing cos ωt and sin ωt are important (e.g., ω ψ). Choice of uc when ψ ω. Finally, we may look at the case where ψ ω such that uc = A/(mψ 2 ) is a relevant scale (i.e., omitting ω 2 compared to ψ 2 in the denominator), but in this case we should use tc = 1/ψ since the force varies much faster than the free vibrations of the system. This choice of tc changes the scaled ODE to

2.2 Vibration problems

59

Fig. 2.9 Forced undamped vibrations away from resonance.

d2 u ¯ + δ −2 u ¯ = γ cos(t¯), dt¯2

u ¯(0) = α, u ¯ (0) = β,

(2.78)

where I I 2 δ , = uc A/k √ V tc V km δ, β= = uc A t2 A γ = c = 1, muc ψ tc δ = −1 = . ψ ω

α=

In the regime ψ ω, δ 1, thus making α and β large. However, if α and/or β is large, the initial condition dominates over the forcing, and will also dominate the amplitude of u, thereby making the scaling of u inappropriate. In case I = V = 0 so that α = β = 0, (2.72) predicts (A = m = 1, ω = δ −1 , ψ = 1)

60

2 Ordinary differential equation models

u ¯(t¯) = (δ −2 − 1)−1 2 sin



   1 1 (1 − δ −1 )t¯ sin (1 + δ −1 )t¯ , 2 2

which has an amplitude about 2 for δ 1. Figure 2.10 shows a case.

Fig. 2.10 Forced undamped vibrations with rapid forcing.

With α = 0.05δ 2 = 5, we get a significant contribution from the free vibrations (the homogeneous solution of the ODE) as shown in Figure 2.11. For larger α values, one must base uc on I instead. (The graphs in Figure 2.10 and 2.11 were produced by numerical simulations with 160 time steps per period of the forcing.) Displacement scale based on I. Choosing uc = I gives d2 u ¯ +u ¯ = γ cos(δ t¯), dt¯2 with

u ¯(0) = 1, u ¯ (0) = β,

(2.79)

2.2 Vibration problems

61

Fig. 2.11 Forced undamped vibrations with rapid forcing and initial displacement of 5.

 V tc V m , β= = uc I k tc2 A A A γ= . = = muc kuc kI

(2.80) (2.81)

This scaling is not relevant close to resonance since then uc I.

2.2.4 Damped vibrations with forcing We now introduce a linear damping force bu (t) in the equation of motion: mu + bu + ku = A cos(ψt),

u(0) = I, u (0) = V .

(2.82)

Figure 2.12 shows a typical one-degree-of-freedom mechanical system with a linear dashpot, representing the damper (bu ), a linear spring (ku), and an external force (F ). The standard scaling procedure results in

62

2 Ordinary differential equation models u(t) ku

m

bu

Fig. 2.12 Oscillating body with external force, attached to a spring and damper.

d2 u ¯ tc b d¯ u t2c k t2c u ¯ = + A cos(ψtc t¯), + m dt¯ m muc dt¯2

u ¯(0) =

V tc I , u ¯ (0) = . (2.83) uc uc

The exact solution. As always, it is a great advantage to look into exact solutions for controlling our choice of scales. Using SymPy to solve (2.82) is, in principle, very straightforward: >>> diffeq = diff(u(t), t, t) + b/m*diff(u(t), t) + w**2*u(t) >>> s = dsolve(diffeq, u(t)) >>> s.rhs C1*exp(t*(-b - sqrt(b - 2*m*w)*sqrt(b + 2*m*w))/(2*m)) + C2*exp(t*(-b + sqrt(b - 2*m*w)*sqrt(b + 2*m*w))/(2*m))

This is indeed the correct solution, but it is on a complex exponential function form, valid for all b, m, and ω. We are interested in the case with small damping, b < 2mω, where the solution is an exponentially damped sinusoidal function. Rewriting the expression in the right form is tricky with SymPy commands. Instead, we demonstrate a common technique when doing symbolic computing: general procedures like dsolve are replaced by manual steps. That is, we solve the ODE “by hand”, but use SymPy to assist the calculations. The solution is composed of a homogeneous solution uh of mu + bu + ku = 0 and one particular solution up of the nonhomogeneous equation mu + bu + ku = A cos(ψt). The homogeneous solution with damped oscil√ lations (requiring b < 2 mk) can be found by the following code. We have divided the differential equation by m and introduced B = 12 b/m and let A1 represent A/m to simplify expressions and help SymPy with less symbols in the equation. Without these simplifications, SymPy stalls in the computations due to too many symbols in the equation. The problem is actually a solid argument for scaling differential equations before asking SymPy to solve them since scaling effectively reduces the number of parameters in the equations! The following SymPy steps derives the solution of the homogeneous ODE:

2.2 Vibration problems

63

u = symbols(’u’, cls=Function) t, w, B, A, A1, m, psi = symbols(’t w B A A1 m psi’, positive=True, real=True) def ode(u, homogeneous=True): h = diff(u, t, t) + 2*B*diff(u, t) + w**2*u f = A1*cos(psi*t) return h if homogeneous else h - f # Find coefficients in polynomial (in r) for exp(r*t) ansatz r = symbols(’r’) ansatz = exp(r*t) poly = simplify(ode(ansatz)/ansatz) # Convert to polynomial to extract coefficients poly = Poly(poly, r) # Extract coefficients in poly: a_*t**2 + b_*t + c_ a_, b_, c_ = poly.coeffs() # Assume b_**2 - 4*a_*c_ < 0 d = -b_/(2*a_) if a_ == 1: omega = sqrt(c_ - (b_/2)**2) # nicer formula else: omega = sqrt(4*a_*c_ - b_**2)/(2*a_) # The homogeneous solution is a linear combination of a # cos term (u1) and a sin term (u2) u1 = exp(d*t)*cos(omega*t) u2 = exp(d*t)*sin(omega*t) C1, C2, V, I = symbols(’C1 C2 V I’, real=True) u_h = simplify(C1*u1 + C2*u2) print ’u_h:’, u_h

The print out shows

uh = e−Bt C1 cos( ω 2 − B 2 t) + C2 sin( ω 2 − B 2 t) , where C1 and C2 must be determined by the initial conditions later. It is wise to check that uh is indeed a solution of the homogeneous differential equation: assert simplify(ode(u_h)) == 0

We have previously just printed the residuals of the ODE and initial conditions after inserting the solution, but it is better in a code to let the programming language test that the residuals are symbolically zero. This is achieved using the assert statement in Python. The argument is a boolean expression, and if the expression evaluates to False, an AssertionError is raised and the program aborts (otherwise assert runs silently for a True boolean expression). Hereafter, we will use assert for consistency checks in computer code. The ansatz for the particular solution up is up = C3 cos(ψt) + C4 sin(ψt),

64

2 Ordinary differential equation models

which inserted in the ODE gives two equations for C3 and C4 . The relevant SymPy statements are # Particular solution C3, C4 = symbols(’C3 C4’) u_p = C3*cos(psi*t) + C4*sin(psi*t) eqs = simplify(ode(u_p, homogeneous=False)) # Collect cos(omega*t) terms print ’eqs:’, eqs eq_cos = simplify(eqs.subs(sin(psi*t), 0).subs(cos(psi*t), 1)) eq_sin = simplify(eqs.subs(cos(psi*t), 0).subs(sin(psi*t), 1)) s = solve([eq_cos, eq_sin], [C3, C4]) u_p = simplify(u_p.subs(C3, s[C3]).subs(C4, s[C4])) # Check that the solution is correct assert simplify(ode(u_p, homogeneous=False)) == 0

Using the initial conditions for the complete solution u = uh + up determines C1 and C2 : u_sol = u_h + u_p # total solution # Initial conditions eqs = [u_sol.subs(t, 0) - I, u_sol.diff(t).subs(t, 0) - V] # Determine C1 and C2 from the initial conditions s = solve(eqs, [C1, C2]) u_sol = u_sol.subs(C1, s[C1]).subs(C2, s[C2])

Finally, we should check that u_sol is indeed the correct solution: checks = dict( ODE=simplify(expand(ode(u_sol, homogeneous=False))), IC1=simplify(u_sol.subs(t, 0) - I), IC2=simplify(diff(u_sol, t).subs(t, 0) - V)) for check in checks: msg = ’%s residual: %s’ % (check, checks[check]) assert checks[check] == sympify(0), msg

Finally, we may take u_sol = u_sol.subs(A, A/m) to get the right expression for the solution. Using latex(u_sol) results in a huge expression, which should be manually ordered to something like the following: Am−1 (2Bψ sin (ψt) − Ω cos (ψt)) + 4B 2 ψ 2 + Ω 2  



−Bt 2 2 2 2 e C1 cos t ω − B + C2 sin t ω − B

u=

Am−1 Ω + 4IB 2 ψ 2 + IΩ 2 4B 2 ψ 2 + Ω 2 −Am−1 BΩ + 4IB 3 ψ 2 + IBΩ 2 + 4V B 2 ψ 2 + V Ω 2 √ , C2 = ω 2 − B 2 (4B 2 ψ 2 + Ω 2 )

C1 =

Ω = ψ2 − ω2 .

2.2 Vibration problems

65

The most important feature √ of this solution is that there are two time scales with frequencies ψ and ω 2 − B 2 , respectively, but the latter appears in terms that decay as e−Bt in time. The attention is usually on longer periods of time, so in that case the solution simplifies to Am−1 (2Bψ sin (ψt) − Ω cos (ψt)) 4B 2 ψ 2 + Ω 2 1 (ψω)−1 A cos(ψt + φ) = m 4B 2 ψ 2 + Ω 2 (ψω)−1  − 1 A = Qδ −1 1 + Q2 (δ − δ −1 ) 2 cos(ψt + φ), k

u=

(2.84)

where we have introduced the dimensionless numbers Q=

ω , 2B

δ=

ψ , ω

and  φ = tan−1 −

2B 2 ω − ψ2



= tan−1



Q−1 δ2 − 1

 .

Q is commonly called quality factor and φ is the phase shift. Dividing (2.84) by A/k, which is a common scale for u, gives the dimensionless relation 1 Q u = R(Q, δ) 2 cos(ψt + φ), A/k δ

 −1 R(Q, δ) = 1 + Q2 (δ − δ −1 ) .

(2.85)

Choosing scales. Much of the discussion about scales in the previous sections are relevant √ also when damping is included. Although the oscillations with frequency ω 2 − B 2 die out for t B −1 , we start with using this frequency for the time scale. A highly relevant assumption for √ engineering applications of (2.82) is that the damping is small. Therefore, ω 2 − B 2 is close to ω and we simply apply tc = 1/ω as before (if not the interest in large t for which the oscillations with frequency ω has died out). The coefficient in front of the u ¯ term then becomes 2B b = = Q−1 . mω ω The rest of the ODE is given in the previous section, and the particular formulas depend on the choices of tc and uc . Choice of uc at resonance. The relevant scale for uc at or nearby resonance (ψ = ω) becomes different from the previous section, since with damping, the maximum amplitude is a finite value. For t B −1 , when the sin ψt term is dominating, we have for ψ = ω:

66

2 Ordinary differential equation models

u=

A Am−1 2Bψ A sin(ψt) = sin(ψt) . sin(ψt) = 2 2 4B ψ 2Bmψ bψ

This motivates the choice uc =

A A = . bψ bω

(It is wise during computations like this to stop and check the dimensions: A must be [MLT−2 ] from the original equation (F (t) must have the same dimension as mu ), bu must also have dimension [MLT−2 ], implying that b has dimension [MT−1 ]. A/b then has dimension LT −1 , and A/(bψ) gets dimension [L], which matches what we want for uc .) The differential equation on dimensionless form becomes ¯ d¯ u d2 u + Q−1 +u ¯ = γ cos(δ t¯), 2 ¯ dt dt¯

u ¯(0) = α, u ¯ (0) = β,

(2.86)

with

α= β= γ= δ=

 I Ib k , = uc A m Vb V tc , = uc A t2c A bω , = muc k tc ψ = = 1. −1 ψ ω

(2.87) (2.88) (2.89) (2.90)

Choice of uc when ω ψ. In the limit ω ψ and t B −1 , A A cos ψt = cos ψt, mω 2 k showing that uc = A/k is an appropriate displacement scale. (Alternatively, we get this scale also from demanding γ = 1 in the ODE.) The dimensionless numbers α, β, and δ are as for the forced vibrations without damping. u≈

Choice of uc when ω ψ. In the limit ω ψ, we should base tc on the rapid variations in the excitation: tc = 1/ψ. Software. It is easy to reuse a solver for a general vibration problem also in the dimensionless case. In particular, we may use the solver function in the file vib.py: def solver(I, V, m, b, s, F, dt, T, damping=’linear’):

for solving the ODE problem

2.2 Vibration problems

mu + f (u ) + s(u) = F (t),

67

u(0) = I, u (0) = V, t ∈ (0, T ],

with time steps dt. With damping=’linear’, we have f (u ) = bu , while the other value is ’quadratic’, meaning f (u ) = b|u |u . Given the dimensionless numbers α, β, γ, δ, and Q, an appropriate call for solving (2.73) is u, t = solver(I=alpha, V=beta, m=1, b=1.0/Q, s=lambda u: u, F=lambda t: gamma*cos(delta*t), dt=2*pi/n, T=2*pi*P)

where n is the number of intervals per period and P is the number of periods to be simulated. We way wrap this call in a solver_scaled function and wrap it furthermore with joblib to avoid repeated calls, as we explained in Section 2.1.4: from vib import solver as solver_unscaled def solver_scaled(alpha, beta, gamma, delta, Q, T, dt): """ Solve u’’ + (1/Q)*u’ + u = gamma*cos(delta*t), u(0)=alpha, u’(1)=beta, for (0,T] with step dt. """ print ’Computing the numerical solution’ from math import cos return solver_unscaled(I=alpha, V=beta, m=1, b=1./Q, s=lambda u: u, F=lambda t: gamma*cos(delta*t), dt=dt, T=T, damping=’linear’) import joblib disk_memory = joblib.Memory(cachedir=’temp’) solver_scaled = disk_memory.cache(solver_scaled)

This code is found in vib_scaled.py and features an application for running the scaled problem with options on the command-line for α, β, γ, δ, Q, number of time steps per period, and number of periods (see the main function). It is an ideal application for exploring scaled vibration models.

2.2.5 Oscillating electric circuits The differential equation for an oscillating electric circuit is very similar to the equation for forced, damped, mechanical vibrations, and their dimensionless form is identical. This fact will now be demonstrated. The current I(t) in a circuit having an inductor with inductance L, a capacitor with capacitance C, and overall resistance R, obeys the equation 1 R I = V (t), I¨ + I˙ + L LC where V (t) is the voltage source powering the circuit. We introduce

(2.91)

68

2 Ordinary differential equation models

I I¯ = , Ic

t t¯ = , tc

and get t2 Vc t2 d2 I¯ tc R dI¯ + + c I¯ = c V¯ (t) . 2 L dt¯ LC Ic dt¯ Here, we have scaled V (t) according to V¯ (t¯) =

V (tc t¯) . maxt V (t)

√ The time scale tc is chosen to make I¨ and I/(LC) balance, tc = LC. Choosing Ic to make the coefficient in the source term of unit size, means Ic = LCVc . With  C −1 , Q =R L we get the scaled equation dI¯ d2 I¯ + Q−1 + I¯ = V¯ (t), (2.92) 2 dt¯ dt¯ which is basically the same as we derived for mechanical vibrations. (Two additional dimensionless variables will arise from the initial conditions for I, just as in the mechanics cases.) Open Access This chapter is distributed under the terms of the Creative Commons AttributionNonCommercial 2.5 License (http://creativecommons.org/licenses/by-nc/2.5/), which permits any noncommercial use, distribution, and reproduction in any medium, provided the original author(s) and source are credited. The images or other third party material in this book are included in the work’s Creative Commons license, unless indicated otherwise in the credit line; if such material is not included in the work’s Creative Commons license and the respective action is not permitted by statutory regulation, users will need to obtain permission from the license holder to duplicate, adapt, or reproduce the material.

Chapter 3

Basic partial differential equation models

This chapter extends the scaling technique to well-known partial differential equation (PDE) models for waves, diffusion, and transport. We start out with the simplest 1D models of the PDEs and then progress with additional terms, different types of boundary and initial conditions, and generalizations to 2D and 3D.

3.1 The wave equation A standard, linear, one-dimensional wave equation problem in a homogeneous medium may be written as 2 ∂2u 2∂ u = c , x ∈ (0, L), t ∈ (0, T ], (3.1) ∂t2 ∂x2 where c is the constant wave velocity of the medium. With a briefer notation, where subscripts indicate derivatives, the PDE (3.1) can be written utt = c2 uxx . This subscript notation will occasionally be used later. For any number of dimensions in heterogeneous media we have the generalization

  ∂2u = ∇ · c2 ∇u + f, 2 ∂t where f represents a forcing.

x, y, z ∈ Ω, t ∈ (0, T ],

(3.2)

3.1.1 Homogeneous Dirichlet conditions in 1D Let us first start with (3.1), homogeneous Dirichlet conditions in space, and no initial velocity ut : © The Author(s) 2016 H.P. Langtangen and G.K. Pedersen, Scaling of Differential Equations, Simula SpringerBriefs on Computing 2, DOI 10.1007/978-3-319-32726-6_3

69

70

3 Basic partial differential equation models

u(x, 0) = I(x), ∂ u(x, 0) = 0, ∂t u(0, t) = 0, u(L, t) = 0,

x ∈ [0, L],

(3.3)

x ∈ [0, L],

(3.4)

t ∈ (0, T ], t ∈ (0, T ].

(3.5) (3.6)

The independent variables are x and t, while u is the dependent variable. The rest of the parameters, c, L, T , and I(x), are given data. We start with introducing dimensionless versions of the independent and dependent variables: x ¯=

x , xc

t t¯ = , tc

u ¯=

u . uc

Inserting the x = xc x ¯, etc., in (3.1) and (3.3)-(3.6) gives ∂2u ¯ t2c c2 ∂ 2 u ¯ = 2 , 2 ¯ xc ∂x2 ∂t ¯) I(xc x u ¯(¯ x, 0) = , uc

x ¯ ∈ (0, L/xc ), t¯ ∈ (0, T /tc ],

∂ u ¯(¯ x, 0) = 0, ∂ t¯ u ¯(0, t¯) = 0, u ¯(L/xc , t¯) = 0,

x ¯ ∈ [0, L/xc ], x ¯ ∈ [0, L/xc ], t¯ ∈ (0, T /tc ], t¯ ∈ (0, T /tc ].

The key question is how to define the scales. A natural choice is xc = L since this makes x ¯ ∈ [0, 1]. For the spatial scale and the problem governed by (3.1) we have some analytical insight that can help. The solution behaves like u(x, t) = fR (x − ct) + fR (x + ct),

(3.7)

i.e., a right- and left-going wave with velocity c. The initial conditions con = 0. The strain the choices of fR and fL to fL + fR = I and −cfL + cfR 1 solution is fR = fL = 2 , and consequently 1 1 u(x, t) = I(x − ct) + I(x + ct), 2 2 which tells that the initial condition splits in two, half of it moves to the left and half to the right. This means in particular that we can choose u| ≤ 1, which is a goal. It must be added that uc = maxx |I(x)| and get |¯ boundary conditions may result in reflected waves, and the solution is then more complicated than indicated in the formula above.

3.1 The wave equation

71

Regarding the time scale, we may look at the two terms in the scaled PDE and argue that if |u| and its derivatives are to be of order unity, then the size of the second-order derivatives should be the same, and tc can be chosen to make the coefficient t2c c2 /x2c unity, i.e., tc = L/c. Another reasoning may set tc as the time it takes the wave to travel through the domain [0, L]. Since the wave has constant speed c, tc = L/c. With the described choices of scales, we end up with the dimensionless initial-boundary value problem ¯ ∂2u ¯ ∂2u = , 2 ¯ ∂x2 ∂t u ¯(¯ x, 0) =

I(¯ xL) maxx∈(0,L) |I(x)|

x ¯ ∈ (0, 1), t¯ ∈ (0, T¯],

(3.8)

x ¯ ∈ [0, 1],

(3.9)

x ¯ ∈ [0, 1],

(3.10)

t¯ ∈ (0, T¯], t¯ ∈ (0, T¯].

(3.11)

,

∂ u ¯(¯ x, 0) = 0, ∂ t¯ u ¯(0, t¯) = 0, u ¯(1, t¯) = 0,

(3.12)

Here, T¯ = T c/L. The striking feature of (3.8)-(3.12) is that there are no physical parameters involved! Everything we need to specify is the shape of the initial condition and then scale it such that it is less than or equal to 1. The physical solution with dimension is recovered from u ¯(¯ x, t¯) through ¯(¯ xL, t¯L/c) u(x, t) = max I(x) u

(3.13)

x∈(0,L)

3.1.2 Implementation of the scaled wave equation How do we implement (3.8)-(3.12)? As for the simpler mathematical models, we suggest to implement the model with dimensions and observe how to set parameters to obtain the scaled model. In the present case, one must choose L = 1, c = 1, and scale I by its maximum value. That’s all! Several implementations of 1D wave equation models with different degree of mathematical and software complexity come along with these notes. The simplest version is wave1D_u0.py that implements (3.1) and (3.3)-(3.6). This is the code to be used in the following. It is described in Section 2.3 in [7]. Waves on a string. As an example, we may let the original initial-boundary value problem (3.1)-(3.6) model vibrations of a string on a string instrument (e.g., a guitar). With u as the displacement of the string, the boundary conditions u = 0 at the ends are relevant, as well as the zero velocity condition ∂u/∂t = 0 at t = 0. The initial condition I(x) typically has a triangular shape

72

3 Basic partial differential equation models

for a picked guitar string. The physical problem needs parameters for the amplitude of I(x), the length L of the string, and the value of c for the string. Only the latter is challenging as it involves relating c to the pitch (i.e., time frequency) of the string. In the scaled problem, we can forget about all this. We simply set L = 1, c = 1, and let I(x) have a peak of unity at x = x0 ∈ (0, 1):  I(x) x/x0 , x < x0 , = (1 − x)/(1 − x0 ), otherwise maxx I(x) The dimensionless coordinate of the peak, x0 , is the only dimensionless parameter in the problem. For fixed x0 , one single simulation will capture all possible solutions with such an initial triangular shape. Detecting an already computed case. The file wave1D_u0_scaled.py has functionality for detecting whether a simulation corresponds to a previously run scaled case, and if so, the solution is retrieved from file. The implementation technique makes use of joblib, but is more complicated than shown previously in these notes since some of the arguments to the function that computes the solution are functions, and one must recognized if the function has been used as argument before or not. There is documentation in the wave1D_u0_scaled.py file explaining how this is done.

3.1.3 Time-dependent Dirichlet condition A generalization of (3.1)-(3.6) is to allow for a time-dependent Dirichlet condition at one end, say u(0, t) = UL (t). At the other end we may still have u = 0. This new condition at x = 0 may model a specified wave that enters the domain. For example, if we feed in a monochromatic wave A sin(k(x − ct)) from the left end, UL (t) = A sin(kct). This forcing of the wave motion has its own amplitude and time scale that could affect the choice of uc and tc . The main difference from the previous initial-boundary value problem is the condition at x = 0, which now reads u ¯(0, t¯) =

UL (t¯tc ) uc

in scaled form. Scaling. Regarding the characteristic time scale, it is natural to base this scale on the wave propagation velocity, together with the length scale, and not on the time scale of UL (t), because the time scale of UL basically determines whether short or long waves are fed in at the boundary. All waves, long or short, propagate with the same velocity c. We therefore continue to use tc = L/c. The solution u will have one wave contribution from the initial condition I and one from the feeding of waves at x = 0. This gives us three choices of uc :

3.1 The wave equation

73

maxx |I| + maxt |UL |, maxx |I|, or maxt |UL |. The first seems relevant if the size of I and UL are about the same, but then we can choose either maxx |I| or maxt |UL | as characteristic size of u since a factor of 2 is not important. If I is much less than UL , uc = maxt |uL | is relevant, while uc = maxx |I| is the choice when I has much bigger impact than UL on u. With uc = maxt |UL (t)|, we get the scaled problem ∂2u ¯ ∂2u ¯ = , 2 ¯ ∂x ¯2 ∂t ¯) I(xc x , u ¯(¯ x, 0) = maxt |UL (t)|

x ¯ ∈ (0, 1), t¯ ∈ (0, T¯],

(3.14)

x ¯ ∈ [0, 1],

(3.15)

x ¯ ∈ [0, 1],

(3.16)

t¯ ∈ (0, T¯],

(3.17)

t¯ ∈ (0, T¯].

(3.18)

∂ u ¯(¯ x, 0) = 0, ∂ t¯ u ¯(0, t¯) =

UL (t¯tc ) , maxt |UL (t)|

u ¯(1, t¯) = 0,

Also this problem is free of physical parameters like c and L. The input is completely specified by the shape of I(x) and UL (t). Software. Software for the original problem with dimensions can be reused for (3.14)-(3.18) by setting L = 1, c = 1, and scaling UL (t) and I(x) by maxt |UL (t)|. Specific case. As an example, consider UL (t) = a sin(ωt) for 0 ≤ t ≤ 2 I(x) = Ae−(x−L/2)

2

/σ 2

ω , else 0, 2π

.

That is, we start with a Gaussian peak-shaped wave in the center of the domain and feed in a sinusoidal wave at the left end for two periods. The solution will be the sum of three waves: two parts from the initial condition, plus the wave fed in from the left. Since maxt |UL | = a we get A −(L/σ)2 (¯x− 1 )2 2 e , a u ¯(0, t¯) = sin(t¯ωL/c) .

u ¯(¯ x, 0) =

(3.19) (3.20)

Here, UL models an incoming wave a sin(k(x − ct), with k specified. The result is incoming waves of length λ = 2π/k. Since ω = kc, u ¯(0, t¯) = sin(kLt¯) = sin(2π t¯L/λ). (This formula demonstrates the previous assertion that the time scale of UL , i.e., 1/ω, determines the wave length 1/ω = λ/(2π) in space.) We

74

3 Basic partial differential equation models

realize from the formulas (3.19) and (3.20) that there are three key dimensionless parameters related to these specific choices of initial and boundary conditions: L L A , β = , γ = kL = 2π . a σ λ With α, β, and γ we can write the dimensionless initial and boundary conditions as α=

2

1 2

u ¯(¯ x, 0) = αe−β (¯x− 2 ) , u ¯(0, t¯) = sin(γ t¯) . The dimensionless parameters have the following interpretations: • α: ratio of initial condition amplitude and amplitude of incoming wave at x=0 • β: ratio of length of domain and width of initial condition • γ: ratio of length of domain and wave length of incoming wave Again, these dimensionless parameters tell a lot about the interplay of the physical effects in the problem. And only some ratios count! We can simulate two special cases: 1. α = 10 (large) where the incoming wave is small and the solution is dominated by the two waves arising from I(x), 2. α = 0.1 (small) where the incoming waves dominate and the solution has the initial condition just as a small perturbation of the wave shape. We may choose a peak-shaped initial condition: β = 10, and also a relatively short incoming wave compared to the domain size: γ = 6π (i.e., wave length of incoming wave is L/6). A function simulate_Gaussian_and_incoming_wave in the file session.py applies the general unscaled solver in wave1D_dn. py for solving the wave equation with constant c, and any time-dependent function or ∂u/∂x = 0 at the end points. This solver is trivially adapted to the present case. Figures 3.1 and 3.2 shows snapshots of how u ¯(¯ x, t¯) evolves due to a large/small initial condition and small/large incoming wave at the left boundary. Movie 1: α = 10. https://github.com/hplgit/scaling-book/raw/master/doc/ pub/book/html/mov-scaling/gaussian_plus_incoming/alpha10.mp4 Movie 2: α = 0.1. https://github.com/hplgit/scaling-book/raw/master/doc/ pub/book/html/mov-scaling/gaussian_plus_incoming/alpha01.mp4

3.1 The wave equation

75

Fig. 3.1 Snapshots of solution with large initial condition and small incoming wave (α = 10).

3.1.4 Velocity initial condition Now we change the initial condition from u = I and ∂u/∂t = 0 to u(x, 0) = 0, ∂ u(x, 0) = V (x) . ∂t

(3.21) (3.22)

Impact problems are often of this kind. The scaled version of ut (x, 0) = V (x) becomes ∂ tc xxc ) . u ¯(¯ x, 0) = V (¯ uc ∂ t¯  =V. Analytical insight. From (3.7) we now get fL + fR = 0 and cfL − cfR 1  Introducing W (x) such that W (x) = V (x), a solution is fL = 2 W/c and −fR = 12 W/c. We can express this solution through the formula

76

3 Basic partial differential equation models

Fig. 3.2 Snapshots of solution with small initial condition and large incoming wave (α = 0.1).

u(x, t) =

1 2c



x+ct

V (ξ)dξ = x−ct

1 (W (x + ct) − W (x − ct)) . 2c

(3.23)

Scaling. Since V is the time-derivative of u, the characteristic size of V , call it Vc , is typically uc /tc . If we, as usual, base tc on the wave speed, tc = L/c, we get uc = Vc L/c. Looking at the solution (3.23), we see that uc has size mean(V )L/(2c), where mean(V ) is the mean value of V (W ∼ mean(V )L). This result suggests Vc = mean(V ) and uc = mean(V )L/(2c). One may argue that the factor 2 is not important, but if we want |¯ u| ∈ [0, 1] it is convenient to keep it. The scaled initial condition becomes tc ∂ u ¯(¯ x, 0) = V (¯ xxc ) = uc ∂ t¯

V (¯ xxc ) 1 2 mean(V

)

.

Nonzero initial shape. Suppose we change the initial condition u(x, 0) = 0 to u(x, 0) = I(x). The scaled version of this condition with the above uc based on V becomes u ¯(¯ x, 0) =

2cI(¯ xxc ) . L mean(V )

(3.24)

3.1 The wave equation

77

Check that dimensionless numbers are dimensionless! Is a dimensionless number really dimensionless? It is easy to make errors when scaling equations, so checking that such fractions are dimensionless is wise. The dimension of I is the same as u, here taken to be displacement: [L]. Since V is ∂u/∂t, its dimension is [LT−1 ]. The dimensions of c and L are [LT−1 ] and [L]. The dimension of the right-hand side of (3.24) is then [LT−1 ][L] = 1, [L][LT−1 ] demonstrating that the fraction is indeed dimensionless. ¯ x) = I(¯ One may introduce a dimensionless initial shape, I(¯ xL)/ maxx |I|. Then ¯ x), u ¯(¯ x, 0) = αI(¯ where α the dimensionless number α=

2c maxx |I(x)| . L mean(V )

If V is much larger than I, one expects that the influence of I is small. However, it takes time for the initial velocity V to influence the wave motion, so the speed of the waves c and the length of the domain L also play a role. This is reflected in α, which is the important parameter. Again, the scaling and the resulting dimensionless parameter(s) teach us much about the interaction of the various physical effects.

3.1.5 Variable wave velocity and forcing The next generalization regards wave propagation in a non-homogeneous medium where the wave velocity c depends on the spatial position: c = c(x). To simplify the notation we introduce λ(x) = c2 (x). We introduce homogeneous Neumann conditions at x = 0 and x = L. In addition, we add a force term f (x, t) to the PDE, modeling wave generation in the interior of the domain. For example, a moving slide at the bottom of a fjord will generate surface waves and is modeled by such an f (x, t) term (provided the length of the waves is much larger than the depth so that a simple wave equation like (3.25) applies). The initial-boundary value problem can be then expressed as

78

3 Basic partial differential equation models





∂2u ∂ ∂u = λ(x) + f (x, t), ∂t2 ∂x ∂x

x ∈ (0, L), t ∈ (0, T ],

(3.25)

x ∈ [0, L],

(3.26)

x ∈ [0, L],

(3.27)

t ∈ (0, T ],

(3.28)

t ∈ (0, T ].

(3.29)

u(x, 0) = I(x), ∂ u(x, 0) = 0, ∂t ∂ u(0, t) = 0, ∂x ∂ u(L, t) = 0, ∂x

Non-dimensionalization. We make the coefficient λ non-dimensional by xxc ) ¯ x) = λ(¯ λ(¯ , λc

(3.30)

where one normally chooses the characteristic size of λ, λc , to be the maximum value such that |λ| ≤ 1: λc = max λ(x) . x∈(0,L)

Similarly, f has a scaled version f (¯ xxc , t¯tc ) , f¯(¯ x, t¯) = fc where normally we choose fc = max |f (x, t)| . x,t

Inserting dependent and independent variables expressed by their nondimensional counterparts yields   ∂2u ¯ t2c λc ∂ ¯ t2c fc ¯ ¯ ∂u ¯ = f (¯ x, t), + λ(¯ x ) L2 ∂ x ¯ ∂x ¯ uc ∂ t¯2 I(x) , u ¯(¯ x, 0) = uc ∂ u ¯(¯ x, 0) = 0, ∂ t¯ ∂ u ¯(0, t¯) = 0, ∂x ¯ ∂ u ¯(1, t¯) = 0, ∂x ¯ with T¯ = T c/L.

x ¯ ∈ (0, 1), t¯ ∈ (0, T¯], x ¯ ∈ [0, 1], x ¯ ∈ [0, 1], t¯ ∈ (0, T¯], t¯ ∈ (0, T¯],

3.1 The wave equation

79

Choosing the time scale. The time scale is, as before, chosen as tc = √ L/ λc . Note that the√previous (constant) wave velocity c now corresponds to λ(x). Therefore, λc is a characteristic wave velocity. One could wonder if the time scale of the force term, f (x, t), should influence tc , but as we reasoned for the boundary condition u(0, t) = UL (t), we let the√characteristic time be governed by the signal speed in the medium, i.e., by λc here and not by the time scale of the excitation f , which dictates the length of the generated waves and not their propagation speed. Choosing the spatial scale. We may choose uc as maxx |I(x)|, as before, or we may fit uc such that the coefficient in the source term is unity, i.e., all terms balance each other. This latter idea leads to uc =

L2 fc λc

and a PDE without parameters,   ¯ ∂2u ∂ ¯ ∂u ¯ = + f¯(¯ x, t¯) . λ(¯ x) ∂x ¯ ∂x ¯ ∂ t¯2 The initial condition u(x, 0) = I(x) becomes in dimensionless form ¯ x), ¯ x) = β −1 I(¯ u ¯(¯ x, 0) = u−1 c max |I(x)|I(¯ x

where β=

L2 maxx,t |f (x, t)| . λc maxx |I(x)|

¯ x) and the β parameter appears In the case uc = maxx |I(x)|, u ¯(¯ x, 0) = I(¯ in the PDE instead:   ¯ ∂2u ∂ ¯ ∂u ¯ = λ(¯ x) + β f¯(¯ x, t¯) . ∂x ¯ ∂x ¯ ∂ t¯2 With V = 0, and u = 0 or ux = 0 on the boundaries x = 0, L, this scaling normally gives |¯ u| ≤ 1, since initially |I| ≤ 1, and no boundary condition can increase the amplitude. However, the forcing, f¯, may inherit spatial and temporal scales of its own that may complicate the matter. The forcing may, for instance, be some disturbance moving with a velocity close to the propagation velocity of the free waves. This will have an effect akin to the resonance for the vibration problem discussed in section 2.2.2 and the waves produced by the forcing may be much larger than indicated by β. On the other hand, the forcing may also consist of alternating positive and negative parts (retrogressive slides constitute an example). These may interfere to reduce the wave generation by an order of magnitude. Scaling the velocity initial condition. The initial condition ut (x, 0) = V (x) has its dimensionless variant as

80

3 Basic partial differential equation models

tc V (L¯ x) V¯ (¯ x) = , uc maxx |V (x)| which becomes ∂u ¯ L maxx |V (x)| ¯ V (¯ x), if uc = max |I(x)|, (¯ x, 0) = √ x ∂ t¯ λc maxx |I(x)| or √ ∂u ¯ λc maxx |V (x)| ¯ L2 max |f (x, t)| . (¯ x, 0) = V (¯ x), if uc = t2c fc = L maxx,t |f (x, t)| λc x,t ∂ t¯ Introducing the dimensionless number α (cf. Section 3.1.4), √ λc maxx |V (x)| −1 α = , L maxx,t |f (x, t)| we can write ∂u ¯ (¯ x, 0) = ∂ t¯



x), uc = maxx |I| α−1 V¯ (¯ x), uc = t2c fc α−1 β −1 V¯ (¯

3.1.6 Damped wave equation A linear damping term b ∂u/∂t is often added to the wave equation to model energy dissipation and amplitude reduction. Our PDE then reads   ∂ ∂2u ∂u ∂u = +b λ(x) + f (x, t) . (3.31) ∂t2 ∂t ∂x ∂x The scaled equation becomes   ¯ t2c λc ∂ ¯ ¯ tc ∂ u ∂2u ∂u ¯ t2c fc ¯ ¯ + f (¯ x, t) . = λ(¯ x ) + b ∂ t¯ L2 ∂ x ¯ ∂x ¯ uc ∂ t¯2 The damping term is usually much smaller than the two other terms involv√ ing u ¯. The time scale is therefore chosen as in the undamped case, tc = L/ λc . As in Section 3.1.5, we have two choices of uc : uc = maxx |I| or uc = t2c fc . The former choice of uc gives a PDE with two dimensionless numbers,   ∂2u ¯ ∂u ¯ ∂ ¯ ∂u ¯ +γ = + β f¯(¯ x, t¯), (3.32) λ(¯ x) ¯ ∂x ¯ ∂ t¯2 ∂ t¯ ∂ x where

3.2 The diffusion equation

81

bL γ=√ , λc measures the size of the damping, and β is as given in Section 3.1.5. With uc = t2c fc we get a PDE where only γ enters,   ∂2u ¯ ∂u ¯ ∂ ¯ ∂u ¯ + γ = λ(¯ x ) + f¯(¯ x, t¯) . (3.33) ¯ ∂x ¯ ∂ t¯2 ∂ t¯ ∂ x The scaled initial conditions are as in Section 3.1.5, so in this latter case β appears in the initial condition for u. To summarize, the effects of V , f , and damping are reflected in the dimensionless numbers α, β, and γ, respectively.

3.1.7 A three-dimensional wave equation problem To demonstrate how the scaling extends to in three spatial dimensions, we consider       ¯ ∂2u ∂ ∂u ∂ ∂u ∂ ∂u = λ + λ + λ . (3.34) ∂x ∂x ∂y ∂y ∂z ∂z ∂ t¯2 Introducing x ¯=

x , xc

y¯ =

y , yc

z¯ =

z , zc

t t¯ = , tc

u ¯=

u , uc

¯ = λ(¯ and scaling λ as λ xxc , y¯yc , z¯zc )/λc , we get       ∂2u ¯ t2c λc ∂ ¯ ∂ u ¯ ¯ ¯ t2c λc ∂ ¯ ∂ u t2c λc ∂ ¯ ∂ u = λ λ λ + + . x2c ∂ x ¯ ∂x ¯ yc2 ∂ y¯ ∂ y¯ zc2 ∂ z¯ ∂ z¯ ∂ t¯2 zc = L where L is some characteristic size of the Often, we will set xc = yc = √ domain. As before, tc = L/ λc , and these choices lead to a dimensionless wave equation without physical parameters:       ¯ ∂2u ∂ ¯ ∂u ∂ ¯ ∂u ∂ ¯ ∂u ¯ ¯ ¯ = + + . (3.35) λ λ λ ∂x ¯ ∂x ¯ ∂ y¯ ∂ y¯ ∂ z¯ ∂ z¯ ∂ t¯2 The initial conditions remain the same as in the previous one-dimensional examples.

3.2 The diffusion equation The diffusion equation in a one-dimensional homogeneous medium reads

82

3 Basic partial differential equation models

∂2u ∂u = α 2 , x ∈ (0, L), t ∈ (0, T ], (3.36) ∂t ∂x where α is the diffusion coefficient. The multi-dimensional generalization to a heterogeneous medium and a source term takes the form ∂u = ∇ · (α∇u) + f, x, y, z ∈ Ω, t ∈ (0, T ] . (3.37) ∂t We first look at scaling of the PDE itself, and thereafter we discuss some types of boundary conditions and how to scale the complete initial-boundary value problem.

3.2.1 Homogeneous 1D diffusion equation Choosing the time scale. To make (3.36) dimensionless, we introduce, as usual, dimensionless dependent and independent variables: x ¯=

x , xc

t t¯ = , tc

u ¯=

u . uc

Inserting the dimensionless quantities in the one-dimensional PDE (3.36) results in ∂u ¯ tc α ∂ 2 u ¯ , x ¯ ∈ (0, 1), t¯ ∈ (0, T¯ = T /tc ] . = 2 L ∂x ¯2 ∂ t¯ Arguing, as for the wave equation, that the scaling should result in ∂u ¯ ¯ ∂2u and ¯ ∂x ¯2 ∂t of the same size (about unity), implies tc α/L2 = 1 and therefore tc = L2 /α. Analytical insight. The best way to obtain the scales inherent in a problem is to obtain an exact analytic solution, as we have done in many of the ODE examples in this booklet. However, as a rule this is not possible. Still, often highly simplified analytic solutions can be found for parts of the problem, or for some closely related problem. Such solutions may provide crucial guidance to the nature of the complete solution and to the appropriate scaling of the full problem. We will employ such solutions now to learn about scales in diffusion problems. One can show that u = Ae−pt sin(kx) is a solution of (3.36) if p = αk 2 , for any k. This is the typical solution arising from separation of variables and reflects the dynamics of the space and time in the PDE. Exponential decay in time is a characteristic feature of diffusion processes, and the e-folding time can then be taken as a time scale. This means tc = 1/p ∼ k −2 . Since k

3.2 The diffusion equation

83

is related to the spatial wave length λ through k = 2π/λ, it means that tc depends strongly on the wave length of the sine term sin(kx). In particular, short waves (as found in noisy signals) with large k decay very rapidly. For the overall solution we are interested in how the longest meaningful wave decays and use that time scale for tc . The longest wave typically has half a wave length over the domain [0, L]: u = Ae−pt sin(πx/L) (k = π/L), provided u(0, t) = u(L, t) = 0 (with ux (L, t) = 0, the longest wave is L/4, but we look at the case with the wave length L/2). Then tc = L2 /απ −2 , but the factor π −2 is not important and we simply choose tc = L2 /α, which equals the time scale we arrived at above. We may say that tc is the time it takes for the diffusion to significantly change the solution in the entire domain. Another fundamental solution of the diffusion equation is the diffusion of a Gaussian function: u(x, t) = K(4παt)−1/2 exp (−x2 /(4αt)), for some constant K with the same dimension as u. For the diffusion to be significant at a distance x = L, we may demand the exponential factor to have a value of e−1 ≈ 0.37, which implies t = L2 /(4α), but the factor 4 is not of importance, so again, a relevant time scale is tc = L2 /α. Choosing other scales. The scale uc is chosen according to the initial condition: uc = maxx∈(0,L) |I(x)|. For a diffusion equation ut = αuxx with u = 0 at the boundaries x = 0, L, the solution is bounded by the initial condition I(x). Therefore, the listed choice of uc implies that |u| ≤ 1. (The solution u = Ae−pt sin(kx) is such an example if k = nπ/L for integer n such that u = 0 for x = 0 and x = L.) The resulting dimensionless PDE becomes ¯ ∂u ¯ ∂2u , = ¯2 ∂ t¯ ∂ x

x ¯ ∈ (0, 1), t¯ ∈ (0, T¯],

(3.38)

with initial condition ¯ x) = u ¯(¯ x, 0) = I(¯

¯) I(xc x . maxx |I(x)|

Notice that (3.38) is without physical parameters, but there may be parameters in I(x).

3.2.2 Generalized diffusion PDE Turning the attention to (3.37), we introduce the dimensionless diffusion coefficient ¯, yc y¯, zc z¯), α ¯ (¯ x, y¯, z¯) = αc−1 α(xc x typically with

84

3 Basic partial differential equation models

αc = max α(x, y, z) . x,y,z

The length scales are x ¯=

x , xc

y¯ =

y , yc

z¯ =

z . zc

We scale f in a similar fashion: xxc , y¯yc z¯zc , t¯tc ), f¯(¯ x, y¯, z¯, t¯) = fc−1 f (¯ with fc = max |f (x, y, z, t)| . x,y,z,t

Also assuming that xc = yc = zc = L, and uc = maxx,y,z (I(x, y, z), we end up with the scaled PDE   ∂u ¯ ¯ u + β f¯, ¯· α =∇ ¯ ∇¯ ∂ t¯

¯ t¯ ∈ (0, T¯] . x ¯, y¯, z¯ ∈ Ω,

(3.39)

¯ means differentiation with respect to dimensionless coordinates x Here, ∇ ¯, y¯, and z¯. The dimensionless parameter β takes the form β=

L2 maxx,y,z,t |f (x, y, z, t)| tc fc . = uc α maxx,y,z |I(x, y, z)|

The scaled initial condition is u ¯ = I¯ as in the 1D case. An alternative choice of uc is to make the coefficient tc fc /uc in the source term unity. The scaled PDE now becomes   ∂u ¯ ¯ u + f, ¯· α =∇ ¯ ∇¯ ¯ ∂t but the initial condition features the β parameter: u ¯(¯ x, y¯, z¯, 0) =

(3.40)

I ¯ x, y¯, z¯) . = β −1 I(¯ tc fc

The β parameter can be interpreted as the ratio of the source term and the terms with u: β=

fc |f | , ∼ uc /tc |ut |

β=

fc fc |fc | . = 2 ∼ uc /tc L /tc uc /L2 |α∇2 u|

We may check that β is really non-dimensional. From the PDE, f must have the same dimensions as ∂u/∂t, i.e., [ΘT−1 ]. The dimension of α is more intricate, but from the term αuxx we know that uxx has dimensions [ΘL−2 ], and then α must have dimension [L2 T−1 ] to match the target [ΘT−1 ]. In the expression for β we get [L2 ΘT−1 (L2 T−1 Θ)−1 ], which equals 1 as it should.

3.2 The diffusion equation

85

3.2.3 Jump boundary condition A classical one-dimensional heat conduction problem goes as follows. An insulated rod at some constant temperature U0 is suddenly heated from one end (x = 0), modeled as a constant Dirichlet condition u(0, t) = U1 = U0 at that end. That is, the boundary temperature jumps from U0 to U1 at t = 0. All the other surfaces of the rod are insulated such that a one-dimensional model is appropriate, but we must explicitly demand ux (L, t) = 0 to incorporate the insulation condition in the one-dimensional model at the end of the domain x = L. Heat cannot escape, and since we supply heat at x = 0, all of the material will eventually be warmed up to the temperature U1 : u → U1 as t → ∞. The initial-boundary value problem reads ∂2u ∂u = k 2, ∂t ∂x u(x, 0) = U0 , c

x ∈ (0, L), t ∈ (0, T ],

(3.41)

x ∈ [0, L],

(3.42)

t ∈ (0, T ],

(3.43)

t ∈ (0, T ].

(3.44)

u(0, t) = U1 , ∂ u(L, t) = 0, ∂x

The PDE (3.41) arises from the energy equation in solids and involves three physical parameters: the density , the specific heat capacity parameter c, and the heat conduction coefficient (from Fourier’s law). Dividing by c and introducing α = k/(c) brings (3.41) on the standard form (3.36). We just use the α parameter in the following. The natural dimensionless temperature for this problem is u ¯=

u − U0 , U1 − U0

since this choice makes u ¯ ∈ [0, 1]. The reason is that u is bounded by the initial and boundary conditions (in the absence of a source term in the PDE), and we have u ¯(¯ x, 0) = 0, u ¯(¯ x, ∞) = 1, and u ¯(0, t¯) = 1. The choice of tc is as in the previous cases. We arrive at the dimensionless initial-boundary value problem ∂u ¯ ∂2u ¯ , = ¯2 ∂ t¯ ∂ x u ¯(¯ x, 0) = 0, u ¯(0, t¯) = 1, ∂ u ¯(1, t¯) = 0, ∂x ¯

x ¯ ∈ (0, 1), t¯ ∈ (0, T¯],

(3.45)

x ¯ ∈ [0, 1], t¯ ∈ (0, T¯],

(3.46) (3.47)

t¯ ∈ (0, T¯].

(3.48)

86

3 Basic partial differential equation models

The striking feature is that there are no physical parameters left in this problem. One simulation can be carried out for u ¯(¯ x, t¯), see Figure 3.3, and the temperature in a rod of any material and any constant initial and boundary temperature can be retrieved by u(x/L, tα/L2 ) . u(x, t) = U0 + (U1 − U0 )¯

Fig. 3.3 Scaled temperature in an isolated rod suddenly heated from the end.

3.2.4 Oscillating Dirichlet condition Now we address a heat equation problem where the temperature is oscillating on the boundary x = 0: ∂u ∂2u = α 2, ∂t ∂x u(x, 0) = U0 , u(0, t) = U0 + A sin(ωt), ∂ u(L, t) = 0, ∂x

x ∈ (0, L), t ∈ (0, T ],

(3.49)

x ∈ [0, L],

(3.50)

t ∈ (0, T ],

(3.51)

t ∈ (0, T ].

(3.52)

3.2 The diffusion equation

87

One important physical application is temperature oscillations in the ground, either day and night variations at a short temporal and spatial scale, or seasonal variations in the Earth’s crust. An important modeling assumption is (3.52), which means that the boundary x = L is placed sufficiently far from x = 0 such that the solution is much damped and basically constant so ux = 0 is a reasonable condition. Scaling issues. Since the boundary temperature is oscillating around the initial condition, we expect u ∈ [U0 − A, U0 + A]. The dimensionless temperature is therefore taken as u ¯=

u − U0 , A

such that u ¯ ∈ [−1, 1]. What is an appropriate time scale? There will be two time scales involved, the oscillations sin(ωt) with period P = 2π/ω at the boundary and the “speed of diffusion”, or more specifically the “speed of heat conduction” in the present context, where tc = x2c /α is the appropriate scale, xc being the length scale. Choosing the right length scale is not obvious. As we shall see, the standard choice xc = L is not a good candidate, but to understand why, we need to examine the solution, either through simulations or through a closed-form formula. We are so lucky in this relatively simple pedagogical problem that one can find an exact solution of a related problem. Exact solution. As usual, investigating the exact solution of the model problem can illuminate the involved scales. For this particular initial-boundary value problem the exact solution as t → ∞ (such that the initial condition u(x, 0) = U0 is forgotten) and L → ∞ (such that (3.52) is certainly valid) can be shown to be  ω . (3.53) u(x, t) = U0 − Ae−bx sin(bx − ωt), b = 2α This solution is of the form e−bx g(x − ct), i.e., a damped wave that moves to the right with velocity c and a damped amplitude e−bx . This is perhaps more easily seen if we make a rewrite

−bx

u(x, t) = U0 − Ae

sin (b(x − ct)) ,

c = ω/b =



 2αω, b =

ω . 2α

Time and length scales. The boundary oscillations lead to the time scale tc = 1/ω. The speed of the wave suggests another time scale: the time it takes √ to propagate through the domain, which is L/c, and hence tc = L/c = L/ 2αω. One can argue that L is not the appropriate length scale, because u is damped by e−bx . So, for x > 4/b, u is close to zero. We may instead use

88

3 Basic partial differential equation models

1/b as length scale, which is the e-folding distance of the damping factor, and base tc on the time it takes a signal to propagate one length scale, t−1 c = bc = ω. Similarly, the time scale based on the “speed of diffusion” 1 2 changes to t−1 c = b α = 2 ω if we employ 1/b as length scale. To summarize, we have three candidates for the time scale: tc = L2 /α (diffusion through the entire domain), tc = 2/ω (diffusion through a distance 1/b where u is significantly different from zero), and tc = 1/ω (wave movement over a distance 1/b). Let us look at the dimensionless exact solution to see if it can help with the choice of scales. We introduce the dimensionless parameters  ω , γ = ωtc . β = bxc = xc 2α The scaled solution becomes u ¯(¯ x, t¯; β, γ) = e−β x¯ sin(γ t¯− β x ¯) . The three choices of γ, implied by the three choices of tc , are ⎧ ⎨ 1, tc = 1/ω, γ = 2, tc = 2/ω, ⎩ 2 2β , tc = L2 /α, xc = L

(3.54)

The former two choices leave only β as parameter in u ¯, and with xc = 1/b as length scale, β becomes unity, and there are no parameters in the dimensionless solution: ¯) . u ¯(¯ x, t¯) = e−¯x sin(t¯− x

(3.55)

Therefore, xc = 1/b and tc = 1/ω (or tc = 2/ω, but the factor 2 is of no importance) are the most appropriate scales. To further argue why (3.55) demonstrates that these scales are preferred, think of ω as large. Then the wave is damped over a short distance and there will be a thin boundary layer of temperature oscillations near x = 0 and little changes in u in the rest of the domain. The scaling (3.55) resolves this problem by using 1/b ∼ ω −1/2 as length scale, because then the boundary layer thickness is independent of ω. The length of the domain can be chosen as, e.g., 4/b such that u ¯ ≈ 0 at the end x = L. The length scale 1/b helps us to zoom in on the part of u where significant changes take place. In the other limit, ω small, b becomes small, and the wave is hardly damped in the domain [0, L] unless L is large enough. The imposed boundary condition on x = L in fact requires u to be approximately constant so its derivative vanishes, and this property can only be obtained if L is large enough to ensure that the wave becomes significantly damped. Therefore, the length scale is dictated by b, not L, and L should be adapted to b, typically L ≥ 4/b if ¯ ≈ 0 for the boundary e−4 ≈ 0.018 is considered enough damping to consider u

3.3 Reaction-diffusion equations

89

condition. This means that x ∈ [0, 4/b] and then x ¯ ∈ [0, 4]. Increasing the spatial domain to [0, 6] implies a damping e−6 ≈ 0.0025, if more accuracy is desired in the boundary condition. The scaled problem. Based on the discussion of scales above, we arrive at the following scaled initial-boundary value problem: ∂u ¯ 1 ∂2u ¯ , = ¯ 2 ∂x2 ∂t u ¯(¯ x, 0) = 0, u ¯(0, t¯) = sin(t¯),

x ¯ ∈ (0, 4), t¯ ∈ (0, T¯],

(3.56)

x ¯ ∈ [0, 1], t¯ ∈ (0, T¯],

(3.57) (3.58)

t¯ ∈ (0, T¯].

(3.59)

∂ ¯ t¯) = 0, u ¯(L, ∂x ¯ The coefficient in front of the second-derivative is

1 2

because

tc α b2 α 1 = . = 1/b2 ω 2 We may, of course, choose tc = 2/ω and get rid of the 12 factor, if desired, but then it turns up in (3.58) instead, as sin(2t¯). ¯ is only an approximation and relies on The boundary condition at x ¯=L sufficient damping of u ¯ to consider it constant (∂/∂ x ¯ = 0) in space. We could, ¯ therefore, assign the condition u ¯ = 0 instead at x ¯ = L. Simulations. The file session.py contains a function solver_diffusion_FE for solving a diffusion equation in one dimension. This function can be used to solve the system (3.56)-(3.59), see diffusion_oscillatory_BC. Movie 3: Diffusion wave. https://github.com/hplgit/scaling-book/raw/master/ doc/pub/book/html/mov-scaling/diffusion_osc_BC/movie.mp4

3.3 Reaction-diffusion equations 3.3.1 Fisher’s equation Fisher’s equation is essentially the logistic equation at each point for population dynamics (see Section 2.1.9) combined with spatial movement through ordinary diffusion: ∂2u ∂u = α 2 + u(1 − u/M ) . (3.60) ∂t ∂x This PDE is also known as the KPP equation after Kolmogorov, Petrovsky, and Piskunov (who introduced the equation independently of Fisher).

90

3 Basic partial differential equation models

Setting x ¯=

x , xc

t t¯ = , tc

u ¯=

u , uc

results in ∂u ¯ tc α ∂ 2 u ¯ + tc ¯ u(1 − uc u ¯/M ) . = 2 xc ∂ x ¯2 ∂ t¯ Balance of all terms. If all terms are equally important, the scales can be determined from demanding the coefficients to be unity. Reasoning as for the logistic ODE in Section 2.1.9, we may choose tc = √ 1/. Then the coefficient in the diffusion term dictates the length scale xc = tc α. A natural scale for u is M , since M is the upper limit of u in the model (cf. the logistic term). Summarizing,  α 1 , uc = M, tc = , xc =   and the scaled PDE becomes ∂u ¯ ∂2u ¯ +u ¯(1 − u ¯) . (3.61) = ¯ ∂x ¯2 ∂t With this scaling, the length scale xc = α/ is not related to the domain size, so the scale is particularly relevant for infinite domains. An open question is whether the time scale should be based on the diffusion process rather than the initial exponential growth in the logistic term. The term then diffusion time scale means tc = x2c /α, but demanding the logistic to have a unit coefficient forces x2c /α = 1, which implies xc = α/ and tc = 1/. That is, equal balance of the three terms gives a unique choice of the time and length scale. Fixed length scale. Assume now that we fix the length scale to be L, either the domain size or some other naturally given length. With xc = L, tc = −1 , uc = M , we get ¯ ∂u ¯ ∂2u ¯(1 − u ¯), = β 2 +u ¯ ∂x ¯ ∂t where β is a dimensionless number β=

(3.62)

α −1 = 2 . 2 L L /α

The last equality demonstrates that β measures the ratio of the time scale for exponential growth in the beginning of the logistic process and the time scale of diffusion L2 /α (i.e., the time it takes to transport a signal by diffusion through the domain). For small β we can neglect the diffusion and spatial

3.3 Reaction-diffusion equations

91

movements, and the PDE is essentially a logistic ODE at each point, while for large β, diffusion dominates, and tc should in that case be based on the diffusion time scale L2 /α. This leads to the scaled PDE ¯ ∂u ¯ ∂2u + β −1 u ¯(1 − u ¯), = (3.63) ¯2 ∂ t¯ ∂ x showing that a large β encourages omission of the logistic term, because the point-wise growth takes place over long time intervals while diffusion is rapid. The effect of diffusion is then more prominent and it suffices to solve ¯x¯x¯ . The observant reader will in this latter case notice that uc = M is an u ¯t¯ = u irrelevant scale for u, since logistic growth with its limit is not of importance, so we implicitly assume that another scale uc has been used, but that scale ¯x¯x¯ . cancels anyway in the simplified PDE u ¯t¯ = u

3.3.2 Nonlinear reaction-diffusion PDE A general, nonlinear reaction-diffusion equation in 1D looks like ∂u ∂2u = α 2 + f (u) . ∂t ∂x

(3.64)

By scaling the nonlinear reaction term f (u) as fc f¯(uc u ¯), where fc is a characteristic size of f (u), typically the maximum value, one gets a non-dimensional PDE like ¯ tc fc ¯ ∂u ¯ tc α ∂ 2 u + ¯) . f (uc u = 2 ¯ xc ∂ x ¯2 uc ∂t The characteristic size of u can often be derived from boundary or initial conditions, so we first assume that uc is given. This fact uniquely determines the space and time scales by demanding that all three terms are equally important and of unit size:  αuc uc tc = , xc = . fc fc The corresponding PDE reads ∂u ¯ ∂2u ¯ ¯ + f (uc u ¯) . (3.65) = ¯2 ∂ t¯ ∂ x If xc is based on some known length scale L, balance of all three terms can be used to determine uc and tc : tc =

L2 , α

uc =

L2 fc . α

92

3 Basic partial differential equation models

This scaling only works if f is nonlinear, otherwise uc cancels and there is no freedom to constrain this scale. With given L and uc , there are two choices of tc since it can be based on the diffusion or the reaction time scales. With the reaction scale, tc = uc /fc , one arrives a the PDE ¯ ∂u ¯ ∂2u ¯), = β 2 + f¯(uc u ∂x ¯ ∂ t¯

(3.66)

where β=

αuc uc /fc = 2 L2 fc L /α

is a dimensionless number reflecting the ratio of the reaction time scale and the diffusion time scale. On the contrary, with the diffusion time scale, tc = L2 /α, the scaled PDE becomes ∂u ¯ ∂2u ¯ + β −1 f¯(uc u ¯) . (3.67) = ¯ ∂x ¯2 ∂t The size of β in an application will determine which of the scalings that is most appropriate.

3.4 The convection-diffusion equation 3.4.1 Convection-diffusion without a force term We now add a convection term v · ∇u to the diffusion equation to obtain the well-known convection-diffusion equation: ∂u + v · ∇u = α∇2 u, x, y, z ∈ Ω, t ∈ (0, T ] . (3.68) ∂t The velocity field v is prescribed, and its characteristic size V is normally clear from the problem description. In the sketch below, we have some given flow over a bump, and u may be the concentration of some substance in the fluid. Here, V is typically maxy v(y). The characteristic length L could be the entire domain, L = c + , or the height of the bump, L = D. (The latter is the important length scale for the flow.)

3.4 The convection-diffusion equation

93

v(y) D

c



Inserting x ¯=

u y z t v x ¯= , y¯ = , z¯ = , t¯ = , v¯ = , u xc yc zc tc V uc

in (3.68) yields uc ∂ u ¯ uc V ¯ u = αuc ∇ ¯ 2u v¯ · ∇¯ ¯, + ¯ tc ∂ t L L2

x ¯, y¯, z¯ ∈ Ω, t¯ ∈ (0, T¯] .

For uc we simply introduce the symbol U , which we may estimate from an initial condition. It is not critical here, since it vanishes from the scaled equation anyway, as long as there is no source term present. With some velocity measure V and length measure L, it is tempting to just let tc = L/V . This is the characteristic time it takes to transport a signal by convection through the domain. The alternative is to use the diffusion length scale tc = L2 /α. A common physical scenario in convection-diffusion problems is that the convection term v · ∇u dominates over the diffusion term α∇2 u. Therefore, the time scale for convection (L/V ) is most appropriate of the two. Only when the diffusion term is very much larger than the convection term (corresponding to very small Peclet numbers, see below) tc = L2 /α is the right time scale. The non-dimensional form of the PDE with tc = L/V becomes ∂u ¯ ¯ 2u ¯ u = Pe−1 ∇ ¯, + v¯ · ∇¯ ∂ t¯ where Pe is the Peclet number,

x ¯, y¯, z¯ ∈ Ω, t¯ ∈ (0, T¯],

(3.69)

LV . α Estimating the size of the convection term v · ∇u as V U/L and the diffusion term α∇2 u as αU/L2 , we see that the Peclet number measures the ratio of the convection and the diffusion terms: Pe =

Pe =

V U/L LV convection = . = 2 diffusion αU/L α

94

3 Basic partial differential equation models

In case we use the diffusion time scale tc = L2 /α, we get the nondimensional PDE ∂u ¯ ¯u = ∇ ¯ 2u ¯, + Pe v¯ · ∇¯ ∂ t¯

x ¯, y¯, z¯ ∈ Ω, t¯ ∈ (0, T¯] .

(3.70)

Discussion of scales and balance of terms in the PDE We see that (3.69) and (3.70) are not equal, and they are based on two different time scales. For moderate Peclet numbers around 1, all terms have the same size in (3.69), i.e., a size around unity. For large Peclet numbers, (3.69) expresses a balance between the time derivative term and the convection term, both of size unity, and then there is a very ¯ 2u ¯ 2u small Pe−1 ∇ ¯ term because Pe is large and ∇ ¯ should be of size unity. That the convection term dominates over the diffusion term is consistent with the time scale tc = L/V based on convection transport. In this case, we can neglect the diffusion term as Pe goes to infinity and work with a pure convection (or advection) equation ∂u ¯ ¯ u = 0. + v¯ · ∇¯ ∂ t¯ ¯ 2u For small Peclet numbers, Pe−1 ∇ ¯ becomes very large and can only be balanced by two terms that are supposed to be unity of size. The time-derivative and/or the convection term must be much larger than unity, but that means we use suboptimal scales, since right scales imply ¯ u are of order unity. Switching to a time scale based that ∂ u ¯/∂ t¯ and v¯ · ∇¯ on diffusion as the dominating physical effect gives (3.70). For very small Peclet numbers this equation tells that the time-derivative balances ¯u ¯ is around unity in size, but the diffusion. The convection term v¯ · ∇ multiplied by a very small coefficient Pe, so this term is negligible in the PDE. An approximate PDE for small Peclet numbers is therefore ∂u ¯ ¯ 2u ¯. =∇ ∂ t¯ Scaling can, with the above type of reasoning, be used to neglect terms from a differential equation under precise mathematical conditions.

3.4 The convection-diffusion equation

95

3.4.2 Stationary PDE Suppose the problem is stationary and that there is no need for any time scale. How is this type of convection-diffusion problem scaled? We get VU ¯ 2u ¯ u = αU ∇ ¯, v¯ · ∇¯ L L2 or ¯ 2u ¯ u = Pe−1 ∇ v¯ · ∇¯ ¯.

(3.71)

This scaling only “works” for moderate Peclet numbers. For very small or ¯ u or the diffusion term ∇ ¯ 2u ¯ very large Pe, either the convection term v¯ · ∇¯ must deviate significantly from unity. Consider the following 1D example to illustrate the point: v = vi, v > 0 constant, a domain [0, L], with boundary conditions u(0) = 0 and u(L) = UL . (The vector i is a unit vector in x direction.) The problem with dimensions is now vu = αu ,

u(0) = 0, u(L) = UL .

Scaling results in d¯ u d2 u ¯ = Pe−1 2 , x ¯ ∈ (0, 1), u ¯(0) = 0, u ¯(1) = 1, d¯ x d¯ x if we choose U = UL . The solution of the scaled problem is 1 − ex¯Pe . 1 − ePe Figure 3.4 indicates how u ¯ depends on Pe: small Pe values give approximately a straight line while large Pe values lead to a boundary layer close to x = 1, where the solution changes very rapidly. We realize that for large Pe, u ¯(¯ x) =

d¯ u d2 u ¯ ≈ Pe, max 2 ≈ Pe2 , x ¯ d¯ x ¯ d¯ x x which are consistent results with the PDE, since the double derivative term is multiplied by Pe−1 . For small Pe, max

¯ d¯ u d2 u ≈ 1, max 2 ≈ 0, x ¯ d¯ x ¯ d¯ x x which is also consistent with the PDE, since an almost vanishing second-order derivative is multiplied by a very large coefficient Pe−1 . However, we have a problem with very large derivatives of u ¯ when Pe is large. max

96

3 Basic partial differential equation models

Fig. 3.4 Solution of scaled problem for 1D convection-diffusion.

To arrive at a proper scaling for large Peclet numbers, we need to remove the Pe coefficient from the differential equation. There are only two scales at our disposals: uc and xc for u and x, respectively. The natural value for uc is the boundary value UL at x = L. The scaling of V ux = αuxx then results in α d2 u ¯ d¯ u = , d¯ x V xc d¯ x2

¯ x ¯ ∈ (0, L),

¯ = 1, u ¯(0) = 0, u ¯(L)

¯ = L/xc . Choosing the coefficient α/(V xc ) to be unity results in the where L ¯ becomes Pe. The final, scaled boundary-value problem scale xc = α/V , and L is now ¯ d¯ u d2 u = 2, d¯ x d¯ x

x ¯ ∈ (0, Pe),

u ¯(0) = 0, u ¯(Pe) = 1,

with solution 1 − ex¯ . 1 − ePe Figure 3.5 displays u ¯ for some Peclet numbers, and we see that the shape of the graphs are the same with this scaling. For large Peclet numbers we realize that u ¯ and its derivatives are around unity (1 − ePe ≈ −ePe ), but for small Peclet numbers d¯ u/d¯ x ∼ Pe−1 . u ¯(¯ x) =

3.4 The convection-diffusion equation

Fig. 3.5 number.

97

Solution of scaled problem where the length scale depends on the Peclet

The conclusion is that for small Peclet numbers, xc = L is an appropriate ¯ indicates that u ¯ ≈ 0, and the length scale. The scaled equation Pe u ¯ = u solution is close to a straight line. For large Pe values, xc = α/V is an appropriate length scale, and the scaled equation u ¯ = u ¯ expresses that the terms   ¯ are equal and of size around unity. u ¯ and u

3.4.3 Convection-diffusion with a source term Let us add a force term f (x, t) to the convection-diffusion equation: ∂u + v · ∇u = α∇2 u + f . ∂t

(3.72)

The scaled version reads tc fc ¯ ∂u ¯ tc V ¯ 2u ¯ u = tc α ∇ ¯+ f. + v¯ · ∇¯ 2 ¯ L L uc ∂t We can base tc on convective transport: tc = L/V . Now, uc could be chosen to make the coefficient in the source term unity: uc = tc fc = Lfc /V . This leaves us with

98

3 Basic partial differential equation models

∂u ¯ ¯ 2u ¯ u = Pe−1 ∇ ¯ + f¯. + v¯ · ∇¯ ∂ t¯ In the diffusion limit, we base tc on the diffusion time scale: tc = L2 /α, and the coefficient of the source term set to unity determines uc according to L2 fc =1 αuc



uc =

L2 fc . α

The corresponding PDE reads ∂u ¯ ¯u = ∇ ¯ 2u ¯ + f¯, + Pe v¯ · ∇¯ ∂ t¯ so for small Peclet numbers, which we have, the convective term can be neglected and we get a pure diffusion equation with a source term. What if the problem is stationary? Then there is no time scale and we get V uc ¯ uc α ¯ 2 u ¯ + fc f¯, v¯ · ∇¯ u= 2 ∇ L L or fc L ¯ ¯ 2u ¯ u = Pe−1 ∇ v¯ · ∇¯ ¯+ f. V uc Again, choosing uc such that the source term coefficient is unity leads to uc = fc L/V . Alternatively, uc can be based on the initial condition, with similar results as found in the sections on the wave and diffusion PDEs. Open Access This chapter is distributed under the terms of the Creative Commons AttributionNonCommercial 2.5 License (http://creativecommons.org/licenses/by-nc/2.5/), which permits any noncommercial use, distribution, and reproduction in any medium, provided the original author(s) and source are credited. The images or other third party material in this book are included in the work’s Creative Commons license, unless indicated otherwise in the credit line; if such material is not included in the work’s Creative Commons license and the respective action is not permitted by statutory regulation, users will need to obtain permission from the license holder to duplicate, adapt, or reproduce the material.

Chapter 4

Advanced partial differential equation models

This final chapter addresses more complicated PDE models, including linear elasticity, viscous flow, heat transfer, porous media flow, gas dynamics, and electrophysiology. A range of classical dimensionless numbers are discussed in terms of the scaling.

4.1 The equations of linear elasticity To the best of the authors’ knowledge, it seems that mathematical models in elasticity and structural analysis are almost never non-dimensionalized. This is probably due to tradition, but the following sections will demonstrate the usefulness of scaling also in this scientific field. We start out with the general, time-dependent elasticity PDE with variable material properties. Analysis based on scaling is used to determine under what circumstances the acceleration term can be neglected and we end up with the widely used stationary elasticity PDE. Scaling of different types of boundary conditions is also treated. At the end, we scale the equations of coupled thermo-elasticity. All the models make the assumption of small displacement gradients and Hooke’s generalized constitutive law such that linear elasticity theory applies.

4.1.1 The general time-dependent elasticity problem The following vector PDE governs deformation and stress in purely elastic materials, under the assumption of small displacement gradients: 

∂2u = ∇((λ + μ)∇ · u) + ∇ · (μ∇u) + f . ∂t2

© The Author(s) 2016 H.P. Langtangen and G.K. Pedersen, Scaling of Differential Equations, Simula SpringerBriefs on Computing 2, DOI 10.1007/978-3-319-32726-6_4

(4.1) 99

100

4 Advanced partial differential equation models

Here, u is the displacement vector,  is the density of the material, λ and μ are the Lame elasticity parameters, and f is a body force (gravity, centrifugal force, or similar). We introduce dimensionless variables: ¯ = u−1 u c u,

x ¯=

x L

y¯ =

y L

z¯ =

z , L

f t¯ = . tc

Also the elasticity parameters and the density can be scaled, if they are not constants, ¯= λ, λ λc

μ ¯=

μ , μc

¯ =

 , c

where the characteristic quantities are typically spatial maximum values of the functions: λc = max λ, x,y,z

μc = max μ, x,y,z

c = max  . x,y,z

Finally, we scale f too (if not constant): f¯ = fc−1 f ,

fc = max ||f || . x,y,z,t

Inserting the dimensionless quantities in the governing vector PDE results in ¯ c u c ∂ 2 u ¯ ¯ ¯ · (¯ ¯ u) ¯ · u) ¯ + c fc ¯f¯. ¯ + L−2 uc μc ∇ μ∇ = L−2 uc ∇((λ ¯ )∇ c λ + μc μ t2c ∂ t¯2 Making the terms non-dimensional gives the equation



¯ t2c μc ¯ ¯ t2c μc ¯ t2c fc ¯ t2c λc ¯ ¯ ¯ ∂2u ¯ u) ¯ ¯ ∇( λ ∇ · u ¯ ) + ∇(¯ μ ∇ · u) + ∇ · (¯ μ ∇ + = ¯f . (4.2) L2 c L2 c L2 c uc ∂ t¯2

We may choose tc to make the coefficient in front of any of the spatial derivative terms equal unity. Here we choose the μ term, which implies  c . tc = L μc The scale for u can be chosen from an initial displacement or by making the coefficient in front of the f¯ term unity. The latter means 2 uc = μ−1 c c fc L .

As discussed later, in Section 4.1.4, this might not be the desired uc in applications.

4.1 The equations of linear elasticity

101

The resulting dimensionless PDE becomes ¯ ∂2u ¯ +μ ¯ ¯ ·u ¯ · (¯ ¯ u) ¯ + ¯f¯. = ∇((β λ ¯)∇ ¯) + ∇ μ∇ ∂ t¯2 The only dimensionless parameter is ¯

β=

(4.3)

λc . μc

If the source term is absent, we must use the initial condition or a known boundary displacement to determine uc . Software. Given software for (4.1), we can simulate the dimensionless prob¯ and μ = μ lem by setting  = ¯, λ = β λ, ¯.

4.1.2 Dimensionless stress tensor The stress tensor σ is a key quantity in elasticity and is given by σ = λ∇ · uI + μ(∇u + (∇u)T ) . This σ can be computed as soon as the PDE problem for u has been solved. Inserting dimensionless variables on the right-hand side of the above relation gives ¯∇ ¯u ¯ u) ¯ ·u ¯ + (∇ ¯ T) ¯ + μc uc L−1 μ σ = λc uc L−2 λ ¯ (∇

¯∇ ¯ ·u ¯u ¯ u) ¯ +μ ¯ + (∇ ¯ T) . = μc uc L−1 β λ ¯(∇ The coefficient on the right-hand side, μc uc L−1 , has dimension of stress, since (according to the second table in Section 1.1.2) [MT−2 L−1 )(L)(L−1 )] = [MT−2 L−1 ], which is the dimension of stress. The quantity μc uc L−1 is therefore the natural scale of the stress tensor: ¯= σ

σ , σc

σc = μc uc L−1 ,

and we have the dimensionless stress-displacement relation ¯∇ ¯ ·u ¯u ¯ u) ¯ = βλ ¯ +μ ¯ + (∇ ¯ T ). σ ¯ (∇

(4.4)

4.1.3 When can the acceleration term be neglected? A lot of applications of the elasticity equation involve static or quasi-static deformations where the acceleration term utt is neglected. Now we shall see under which conditions the quasi-static approximation holds.

102

4 Advanced partial differential equation models

The further discussion will need to look into the time scales of elastic waves, because it turns out that the chosen tc above is closely linked to the propagation speed of elastic waves in a homogeneous body without body forces. A relevant model for such waves has constant , λ, and μ, and no force term: ∂2u = (λ + μ)∇∇ · u + μ∇2 u . (4.5) ∂t2 S waves. Let us take the curl of this PDE and notice that the curl of a gradient vanishes. The result is 

∂2 ∇ × u = c2S ∇2 ∇ × u, ∂t2 i.e., a wave equation for ∇ × u. The wave velocity is  μ . cS =  The corresponding waves are called S waves1 . The curl of a displacement field is closely related to rotation of continuum elements. S waves are therefore rotation waves, also sometimes referred to as shear waves. The divergence of a displacement field can be interpreted as the volume change of continuum elements. Suppose this volume change vanishes, ∇ · u = 0, which means that the material is incompressible. The elasticity equation then simplifies to ∂2u = c2S ∇2 u, ∂t2 so each component of the displacement field in this case also propagates as a wave with speed c2S . The time it takes for such a wave to travel one characteristic length L is L/cS , i.e., L /μ, which is nothing but our characteristic time tc . P waves. We may take the divergence of the PDE instead and notice that ∇ · ∇ = ∇2 so ∂2 ∇ · u = c2P ∇2 ∇ · u, ∂t2 with wave velocity  cP =

1

λ + 2μ . 

https://en.wikipedia.org/wiki/S-wave

4.1 The equations of linear elasticity

103

That is, the volume change (expansion/compression) propagates as a wave with speed cP . These types of waves are called P waves2 . Other names are pressure and expansion/compression waves. Suppose now that ∇ × u = 0, i.e., there is no rotation (“shear”) of continuum elements. Mathematically this condition implies that ∇2 u = ∇(∇ · u) (see any book on vector calculus or Wikipedia3 ). Our model equation (4.5) then reduces to ∂2u = c2P ∇2 u, ∂t2 which is nothing but a wave equation for the expansion component of the displacement field, just as (4.1.3) is for the shear component. Time-varying load. Suppose we have some time-varying boundary condition on u or the stress vector (traction), with a time scale 1/ω (some oscillating movement that goes like sin ωt, for instance). We choose tc = 1/ω. The scaling now leads to ¯ ∂2u ¯ +μ ¯ ¯ · u) ¯ · (¯ ¯ u) ¯ +∇ ¯ + ¯f¯. = ∇((β λ ¯)∇ μ∇ ∂ t¯2 where we have set γ

2 uc = μ−1 c fc L c ,

as before, and γ is a new dimensionless number, 2  L c /μc c L2 ω 2 γ= = . μc 1/ω √ The last rewrite shows that γ is the ratio of the time scale for S waves and the time scale for the forced movement on the boundary. The acceleration term can therefore be neglected when γ 1, i.e., when the time scale for movement on the boundary is much larger than the time it takes for the S waves to travel through the domain. Since the velocity of S waves in solids is very large and the time scale correspondingly small, γ 1 is very often the case in applications involving structural analysis.

4.1.4 The stationary elasticity problem Scaling of the PDE. We now look at the stationary version of (4.1) where the utt term is removed. The first step in the scaling is just inserting the dimensionless variables: 2 3

https://en.wikipedia.org/wiki/P-wave https://en.wikipedia.org/wiki/Vector_calculus_identities

104

4 Advanced partial differential equation models

¯ ¯ ¯ · (¯ ¯ u) ¯ · u) ¯ + c fc ¯f¯. ¯ + L−2 uc μc ∇ μ∇ 0 = L−2 uc ∇((λ ¯)∇ c λ + μc μ Dividing by L2 uc μc gives 2

L c fc ¯ ¯ +μ ¯ ¯ · u) ¯ · (¯ ¯ u) ¯ +∇ ¯ + 0 = ∇((β λ ¯)∇ μ∇ ¯f . uc μc Choosing uc = L2 fc /μc leads to ¯ +μ ¯ ¯ · u) ¯ · (¯ ¯ u) ¯ +∇ ¯ + ¯f¯ = 0 . ∇((β λ ¯)∇ μ∇

(4.6)

A homogeneous material with constant λ, μ, and  is an interesting case ¯=μ (this corresponds to μc = μ, λc = λ, c = , ¯ = λ ¯ = 1): ¯ ∇ ¯ · u) ¯ 2 u) ¯ + f¯ = 0 . ¯ +∇ (1 + β)∇( Now β is defined as λ β= = μ



cp cs

2

(4.7)

−2.

It shows that in standard, stationary elasticity, λ/μ is the only significant physical parameter. Remark on the characteristic displacement. The presented scaling may not be valid for problems where the geometry involves some dimensions that are much smaller than others, such as for beams, shells, or plates. Then one more length scale must be defined which gives us non-dimensional geometrical numbers. Global balances of moments and loads then determine how characteristic displacements depend on these numbers. As an example, consider a cantilever beam of length L and squareshaped cross section of width W , deformed under its own weight. From beam theory one can derive uc = 32 gL2 δ 2 /E, where δ = L/W (g is the acceleration of gravity). If we consider E to be of the same size as λ, this implies that γ ∼ δ −2 . So, it may be wise to prescribe a uc in elasticity problems, perhaps from formulas as shown, and keep γ in the PDE. Scaling of displacement boundary conditions. A typical boundary condition on some part of the boundary is a prescribed displacement. For simplicity, we set u = U0 for a constant vector U0 as boundary condition. With uc = L2 fc /μ, we get the dimensionless condition ¯= u

μU0 U0 = . uc L2 fc

In the absence of body forces, the expression for uc has no meaning (fc = 0), so then uc = |U0 | is a better choice. This gives the dimensionless boundary condition U0 , u ¯= |U0 | which is the unit vector in the direction of U0 . The new uc changes the

4.1 The equations of linear elasticity

105

coefficient in front of the body force term, if that term is present, to the dimensionless number L2 fc . δ= μ|U0 | Scaling of traction boundary conditions. The other type of common boundary condition in elasticity is a prescribed traction (stress vector) on some part of the boundary: σ · n = T0 , where, to make it simple, we take T0 as a constant vector. From Section 4.1.2 we have a stress scale σc = μuc /L, but we may alternatively use |T0 | as stress scale. In that case, ¯ ·n = σ

T0 , |T0 |

which is a unit vector in the direction of T0 . Many applications involve large ¯ · n = 0. traction free areas on the boundary, on which we simply have σ

4.1.5 Quasi-static thermo-elasticity Heating solids gives rise to expansion, i.e., strains, which may cause stress if displacements are constrained. The time scale of temperature changes are usually much larger than the time scales of elastic waves, so the stationary equations of elasticity can be used, but a term depends on the temperature, so the equations must be coupled to a PDE for heat transfer in solids. The resulting system of PDEs is known as the equations of thermo-elasticity and reads ∇((λ + μ)∇ · u) + ∇ · (μ∇u) = α∇T − f , ∂T = ∇ · (κ∇T ) + fT , c ∂t

(4.8) (4.9)

where T is the temperature, α is a coefficient of thermal expansion, c is a heat capacity, κ is the heat conduction coefficient, and fT is some heat source. The density  is strictly speaking a function of T and the stress state, but a widely used approximation is to consider  as a constant. Most thermoelasticity applications have fT = 0, so we drop this term. Most applications also involve some heating from a temperature level T0 to some level T0 + ΔT . A suitable scaling for T is therefore T − T0 T¯ = , ΔT so that T¯ ∈ [0, 1]. The elasticity equation has already been scaled and so has the diffusion equation for T . We base the time scale on the diffusion, i.e., the thermal conduction process: tc = cL2 /κc .

106

4 Advanced partial differential equation models

We imagine that κ is scaled as κ ¯ = κ/κc . The dimensionless PDE system then becomes ¯ ¯ · u) ¯ · (¯ ¯ u) ¯ T¯ − ¯ ¯ +∇ ¯ =∇ ∇((1 + β)¯ μ∇ μ∇ f¯, ∂ T¯ ¯ · (¯ ¯ T¯) . =∇ κ∇ ∂ t¯

(4.10) (4.11)

Here we have chosen uc such that the “heating source term” has a unit coefficient, acknowledging that this thermal expansion balances the stress ¯ The corresponding displacement scale is terms with u. uc =

αLΔT . μc

The dimensionless number in the body force term is therefore Lc fc , αΔT which measures the ratio of the body force term and the “heating source term”. A homogeneous body with constant , λ, μ, c, and κ is common. The PDE system reduces in this case to =

¯ T¯ − f¯, ¯ ¯ · u) ¯ 2 u) ¯ =∇ ¯ +∇ ∇((1 + β)∇ ∂ T¯ ¯ 2 T¯ . =∇ ∂ t¯

(4.12) (4.13)

In the absence of body forces, β is again the key parameter. The boundary conditions for thermo-elasticity consist of the conditions for elasticity and the conditions for diffusion. Scaling of such conditions are discussed in Section 3.2 and 4.1.4.

4.2 The Navier-Stokes equations This section shows how to scale various versions of the equations governing incompressible viscous fluid flow. We start with the plain Navier-Stokes equations without body forces and progress with adding the gravity force and a free surface. We also look at scaling low Reynolds number flow and oscillating flows.

4.2 The Navier-Stokes equations

107

4.2.1 The momentum equation without body forces The Navier-Stokes equations for incompressible viscous fluid flow, without body forces, take the form  ∂u + u · ∇u = −∇p + μ∇2 u,  ∂t

(4.14)

∇·u = 0.

(4.15)



The primary unknowns are the velocity u and the pressure p. Moreover,  is the fluid density, and μ is the dynamic viscosity. Scaling. We start, as usual, by introducing a notation for dimensionless independent and dependent variables: x ¯=

x , L

y¯ =

y , L

z¯ =

z , L

t t¯ = , tc

¯= u

u , uc

p¯ =

p , pc

where L is some characteristic distance, tc is some characteristic time, uc is a characteristic velocity, while pc is a characteristic pressure. Inserted in the equations, 

 ¯ u2c uc ∂ u uc ¯ 2 pc ¯ ¯ ¯ ¯ · ∇u ¯ = − ∇¯ p + 2 μ∇ + u u,  tc ∂ t¯ L L L uc ¯ ¯ = 0. ∇·u L

(4.16) (4.17)

For the velocity it is common to just introduce some U for uc . This U is normally implied by the problem description. For example, in the flow configuration below, with flow over a bump, we have some incoming flow with a profile v(y) and U can typically be chosen as U = maxy v(y). The height of the bump influences the wake behind the bump, and is the length scale that really impacts the flow, so it is natural to set L = D. For numerical simulations in a domain of finite extent, [0, c + ], c must be large enough to avoid feedback on the inlet profile, and  must be large enough for the type of outflow boundary condition used. Ideally, c,  → ∞, so none of these parameters are useful as length scales.

108

4 Advanced partial differential equation models

v(y) D

c



For flow in a channel or tube, we also have some inlet profile, e.g., v(r) in a tube, where r is the radial coordinate. A natural choice of characteristic velocity is U = v(0) or to let U be the average flow, i.e., U=

1 πR2



R

2πv(r)rdr, 0

if R is the radius of the tube. Other examples may be flow around a body, where there is some distant constant inlet flow u = U0 i, for instance, and U = U0 is an obvious choice. We therefore assume that the flow problem itself brings a natural candidate for U . Having a characteristic distance L and velocity U , an obvious time measure is L/U so we set tc = L/U . Dividing by the coefficient in front of the time derivative term, creates a pressure term pc ¯ ∇¯ p. U 2 The coefficient suggest a choice pc = U 2 if the pressure gradient term is to have the same size as the acceleration terms. This pc is a very common pressure scale in fluid mechanics, arising from Bernoulli’s equation 1 p + u · u = const 2 for stationary flow. Dimensionless PDEs and the Reynolds number. The discussions so far result in the following dimensionless form of (4.14) and (4.15): ¯ ∂u ¯u ¯ p + Re−1 ∇ ¯ 2 u, ¯ ¯ ·∇ ¯ = −∇¯ +u ∂ t¯ ¯ ·u ¯ = 0, ∇ where Re is the famous Reynolds number, Re =

U L U L = . μ ν

(4.18) (4.19)

4.2 The Navier-Stokes equations

109

The latter expression makes use of the kinematic viscosity ν = μ/. For viscous fluid flows without body forces there is hence only one dimensionless number, Re. The Reynolds number can be interpreted as the ratio of convection and viscosity: convection |u · ∇u| U 2 /L U L = ∼ = Re . = viscosity |μ∇2 u| μU/L2 ν (We have here used that ∇u goes like U/L and ∇2 u goes like U/L2 .)

4.2.2 Scaling of time for low Reynolds numbers As we discussed in Section 3.4 for the convection-diffusion equation, there is not just one scaling that fits all problems. Above, we used tc = L/U , which is appropriate if convection is a dominating physical effect. In case the convection term u · ∇u is much smaller than the viscosity term μ∇2 u, i.e., the Reynolds number is small, the viscosity term is dominating. However, if ¯ must the scaling is right, the other terms are of order unity, and Re−1 ∇2 u ¯ must be small, but then then also be of unit size. This fact implies that ∇2 u the scaling is not right (since a right scaling will lead to u ¯ and its derivatives around unity). Such reasoning around inconsistent size of terms clearly points to the need for other scales. ¯ is dominatIn the low-Reynolds number regime, the diffusion effect of ∇2 u ing, and we should use a time scale based on diffusion rather than convection. Such a time scale is tc = L2 /(μ/) = L2 /ν. With this time scale, the dimensionless Navier-Stokes equations look like ¯ ∂u ¯u ¯ +∇ ¯ 2 u, ¯ ·∇ ¯ = −∇p ¯ + Re u ∂ t¯ ¯ ·u ¯ = 0. ∇

(4.20) (4.21)

As stated in the box in Section 3.4, (4.20) is the appropriate PDE for very low Reynolds number flow and suggests neglecting the convection term. If the flow is also steady, the time derivative term can be neglected, and we end up with the so-called Stokes problem for steady, slow, viscous flow: ¯ +∇ ¯ 2u ¯ = 0, −∇p ¯ ·u ¯ = 0. ∇ This flow regime is also known as Stokes’ flow or creeping flow.

(4.22) (4.23)

110

4 Advanced partial differential equation models

4.2.3 Shear stress as pressure scale Instead of using the kinetic energy U 2 as pressure scale, one can use the shear stress μU/L (U/L reflects the spatial derivative of the velocity, which enters the shear stress expression μ∂u/∂y). Using U as velocity scale, L/U as time scale, and μU/L as pressure scale, results in   ¯ ∂u ¯u ¯p+∇ ¯ 2u ¯ ·∇ ¯ = −∇¯ ¯. +u (4.24) Re ∂ t¯ Low Reynolds number flow now suggests neglecting both acceleration terms.

4.2.4 Gravity force and the Froude number We now add a gravity force to the momentum equation (4.14):   ∂u + u · ∇u = −∇p + μ∇2 u − gk,  ∂t

(4.25)

where g is the acceleration of gravity, and k is a unit vector in the opposite direction of gravity. The new term takes the following form after nondimensionalization: Lg tc gk = 2 k = Fr−2 k, uc U where Fr is the dimensionless Froude number, U Fr = √ . Lg This quantity reflects the ratio of inertia and gravity forces: |u · ∇u| U 2 /L ∼ = Fr2 . |g| g

4.2.5 Oscillating boundary conditions and the Strouhal number Many flows have an oscillating nature, often arising from some oscillating boundary condition. Suppose such a condition, at some boundary x = const, takes the specific form u = U sin(ωt)i .

4.2 The Navier-Stokes equations

111

The dimensionless counterpart becomes L¯ t)i, U if tc = L/U is the appropriate time scale. This condition can be written ¯ = U sin(ω Uu

¯ = sin(St t¯), u

(4.26)

where St is the Strouhal number, ωL . (4.27) U The two important dimensionless parameters in oscillating flows are then the Reynolds and Strouhal numbers. Even if the boundary conditions are of steady type, as for flow around a sphere or cylinder, the flow may at certain Reynolds numbers get unsteady and oscillating. For 102 < Re < 107 , steady inflow towards a cylinder will cause vortex shedding: an array of vortices are periodically shedded from the cylinder, producing an oscillating flow pattern and force on the cylinder. The Strouhal number is used to characterize the frequency of oscillations. The phenomenon, known as von Karman vortex street, is particularly important if the frequency of the force on the cylinder hits the free vibration frequency of the cylinder such that resonance occurs. The result can be large displacements of the cylinder and structural failure. A famous case in engineering is the failure of the Tacoma Narrows suspension bridge4 in 1940, when wind-induced vortex shedding caused resonance with the free torsional vibrations of the bridge. St =

4.2.6 Cavitation and the Euler number The dimensionless pressure in (4.18) made use of the pressure scale pc = U 2 . This is an appropriate scale if the pressure level is not of importance, which is very often the case since only the pressure gradient enters the flow equation and drives the flow. However, there are circumstances where the pressure level is of importance. For example, in some flows the pressure may become so low that the vapor pressure of the liquid is reached and that vapor cavities form (a phenomenon known as cavitation). A more appropriate pressure scale is then pc = p∞ − pv , where p∞ is a characteristic pressure level far from vapor cavities and pv is the vapor pressure. The coefficient in front of the dimensionless pressure gradient is then

4

https://en.wikipedia.org/wiki/Tacoma_Narrows_Bridge_(1940)

112

4 Advanced partial differential equation models

p∞ − pv . U 2 Inspired by Bernoulli’s equation p + 12 u · u = const in fluid mechanics, a factor 12 is often inserted in the denominator. The corresponding dimensionless number, Eu =

p∞ − pv , 1 2 2 U

(4.28)

¯ p. is called the Euler number. The pressure gradient term now reads 12 Eu ∇¯ The Euler number expresses the ratio of pressure differences and the kinetic energy of the flow.

4.2.7 Free surface conditions and the Weber number At a free surface, z = η(x, y, t), the boundary conditions are ∂η + u · ∇η, ∂t  2  ∂ η ∂2η p − p0 ≈ −σ + , ∂x2 ∂y 2 w=

(4.29) (4.30)

where w is the velocity component in the z direction, p0 is the atmospheric air pressure at the surface, and σ represents the surface tension. The approximation in (4.30) is valid under small deformations of the surface. The dimensionless form of these conditions starts with inserting the dimensionless quantities in the equations: L ∂ η¯ ¯ η, ¯ · ∇¯ + uc u tc ∂ t¯  2  ∂ η¯ ∂ 2 η¯ 1 pc p¯ ≈ − σ + . L ∂x ¯2 ∂ y¯2

¯= uc w

The characteristic length L is usually taken as the depth of the fluid when the surface is flat. We have used p¯ = (p − p0 )/pc for making the pressure dimensionless. Using uc = U , tc = L/U , and pc = U 2 , results in ∂ η¯ ¯ η, ¯ · ∇¯ +u ∂ t¯  2  ∂ η¯ ∂ 2 η¯ + p¯ ≈ −We−1 , ∂x ¯2 ∂ y¯2

w ¯=

(4.31) (4.32)

4.3 Thermal convection

113

where We is the Weber number, U 2 L . (4.33) σ The Weber number measures the importance of surface tension effects and is the ratio of the pressure scale U 2 and the surface tension force per area, typically σ/Rx in a 2D problem, which has size σ/L. We =

4.3 Thermal convection Temperature differences in fluid flow cause density differences, and since cold fluid is heavier than hot fluid, the gravity force will induce flow due to density differences. This effect is called free thermal convection and is key to our weather and heating of rooms. Forced convection refers to the case where there is no feedback from the temperature field to the motion, i.e., temperature differences do not create motion. This fact decouples the energy equation from the mass and momentum equations.

4.3.1 Forced convection The model governing forced convection consists of the Navier-Stokes equations and the energy equation for the temperature:   

 ∂u + u · ∇u = −∇p + μ∇2 u − gk, ∂t ∇ · u = 0,  = κ∇2 T .

∂T + u · ∇T c ∂t

(4.34) (4.35) (4.36)

The symbol T is the temperature, c is a heat capacity, and κ is the heat conduction coefficient for the fluid. The PDE system applies primarily for liquids. For gases one may need a term −p∇ · u for the pressure work in (4.36) as well as a modified equation of continuity (4.35). Despite the fact that  depends on T , we treat  as a constant 0 . The major effect of the (T ) dependence is through the buoyancy effect caused by the gravity term −(T )gk. It is common to drop this term in forced convection, and assume the momentum and continuity equations to be independent of the temperature. The flow is driven by boundary conditions (rather than density variations as in free convection), from which we can find a characteristic velocity U .

114

4 Advanced partial differential equation models

Dimensionless parameters are introduced as follows: x ¯=

x u p L T − T0 ¯ = , p¯ = , tc = , u , T¯ = . 2 L U U 0 U Tc

Other coordinates are also scaled by L. The characteristic temperature Tc is chosen as some range ΔT , which depends on the problem and is often given by the thermal initial and/or boundary conditions. The reference temperature T0 is also implied by prescribed conditions. Inserted in the equations, we get ¯ μU ¯ 2 U 2 ∂u U2 0 U 2 ¯ ¯u ¯ ¯ ·∇ ¯=− ∇¯ p+ 2 ∇ + 0 u, u ¯ L ∂t L L L U¯ ¯ = 0, ∇·u L   Tc U ∂ T¯ U Tc ¯ 2 T¯ . ¯ T¯ = κTc ∇ ¯ ·∇ 0 c + u ¯ L ∂t L L2 0

Making each term in each equation dimensionless reduces the system to ¯ ∂u ¯ 2 u, ¯u ¯ p + Re−1 ∇ ¯ ·∇ ¯ = −∇¯ ¯ +u ∂ t¯ ¯ ·u ¯ = 0, ∇ ¯ ∂T ¯ 2 T¯ . ¯ T¯ = Pe−1 ∇ ¯ ·∇ +u ∂ t¯

(4.37) (4.38) (4.39)

The two dimensionless numbers in this system are given by Pe =

0 cU L , κ

Re =

UL ν

(ν =

μ ). 0

The Peclet number is here defined as the ratio of the convection term for heat 0 cU ΔT /L and the heat conduction term κU/L2 . The fraction κ/(0 c) is known as the thermal diffusivity, and if this quantity is given a symbol α, we realize the relation to the Peclet number defined in Section 3.4.

4.3.2 Free convection Governing equations. The mathematical model for free thermal convection consists of the Navier-Stokes equations coupled to an energy equation governing the temperature:

4.3 Thermal convection



115



∂u + u · ∇u = −∇p + μ∇2 u − gk, ∂t ∂ρ + ∇ · (u) = 0,   ∂t ∂T + u · ∇T = κ∇2 T + 2μεij εij , c ∂t 

(4.40) (4.41) (4.42)

where Einstein’s summation convention is implied for the εij εij term. The symbol T is the temperature, c is a heat capacity, κ is the heat conduction coefficient for the fluid. In free convection, the gravity term −(T )gk is essential since the flow is driven by temperature differences and the fact that hot fluid rises while cold fluid falls. For slightly compressible gas flow a term −p∇ · u may be needed in (4.42). Heating by viscous effects. We have also included heating of the fluid due to the work of viscous forces, represented by the term 2μεij εij , where εij is the strain-rate tensor in the flow, defined by   1 ∂ui ∂uj 1 + εij = = (∇u + (∇u)T ), 2 ∂xj ∂xi 2 where ui is the velocity in direction of xi (i = 1, 2, 3 measures the space directions). The term 2μεij εij is actually much more relevant for forced convection, but was left out in Section 4.3.2 for mathematical simplicity. Heating by the work of viscous forces is often a very small effect and can be neglected, although it plays a major role in forging and extrusion of metals where the viscosity is very large (such processes require large external forces to drive the flow). The reason for including the work by viscous forces under the heading of free convection, is that we want to scale a more complete, general mathematical model for mixed force and free convection, and arrive at dimensionless numbers that can tell if this extra term is important or not. Relation between density and temperature. Equations (4.40) has already been made dimensionless in the previous section. The major difference is now that  is no longer a constant, but a function of T . The relationship between  and T is often taken as linear,  = 0 − 0 β(T − T0 ), where 1 β=− 



∂ ∂t

 , p

is known as the thermal expansion coefficient of the fluid, and 0 is a reference density when the temperature is at T0 .

116

4 Advanced partial differential equation models

The Boussinesq approximation. A very common approximation, called the Boussinesq approximation, is to neglect the density variations in all terms except the gravity term. This is a good approximation unless the change in  is large. With the linear (T ) formula and the Boussinesq approximation, (4.40)-(4.42) take the form  0

 ∂u + u · ∇u = −∇p + μ∇2 u − (0 − 0 β(T − T0 ))gk, ∂t

∇ · u = 0,  ∂T + u · ∇T = κ∇2 T + 2μεij εij . 0 c ∂t 

(4.43) (4.44) (4.45)

A good justification of the Boussinesq approximation is provided by Tritton [9, Ch. 13]. Scaling. Dimensionless variables are introduced as x ¯=

u p x L T − T0 ¯ = , p¯ = , tc = , u . , T¯ = L U U U 2 ΔT

The dimensionless y and z coordinates also make use of L as scale. As in forced convection, we assume the characteristic temperature level T0 and the scale ΔT are given by thermal boundary and/or initial conditions. Contrary to Sections 4.2 and 4.3.2, U is now not given by the problem description, but implied by ΔT . Replacing quantities with dimensions by their dimensionless counterparts results in ¯ U 2 ∂u U2 μU ¯ 2 pc ¯ ¯u ¯ − 0 gk + 0 βTc T¯gk, ¯ ·∇ ¯ = − ∇¯ u p+ 2 ∇ u + 0 L ∂ t¯ L L L U¯ ¯ = 0, ∇·u L   Tc U ∂ T¯ U Tc ¯ 2 T¯ + 2 μU ε¯ij ε¯ij . ¯ T¯ = κTc ∇ ¯ ·∇ 0 c + u L ∂ t¯ L L2 L 0

These equations reduce to ¯ ∂u ¯ 2u ¯u ¯ p + Re−1 ∇ ¯ ·∇ ¯ = −∇¯ ¯ − Fr−2 k + γ T¯k, +u ∂ t¯ ¯ ·u ¯ = 0, ∇ ∂ T¯ ¯ 2 T¯ + 2δ ε¯ij ε¯ij . ¯ T¯ = Pe−1 ∇ ¯ ·∇ +u ∂ t¯ The dimensionless numbers, in addition to Re and Fr, are

(4.46) (4.47) (4.48)

4.3 Thermal convection

γ=

117

gβLΔT , U2

Pe−1 =

κ , 0 cU L

δ=

μU . L0 cΔT

The γ number measures the ratio of thermal buoyancy and the convection term: γ=

gβLΔT 0 gβΔT = . 0 U 2 /L U2

The Pe parameter is the fraction of the convection term and the thermal diffusion term: cU L |0 u · ∇T | 0 cU ΔT L−1 ∼ = = Pe . |κ∇2 T | κL−2 ΔT κ The δ parameter is the ratio of the viscous dissipation term and the convection term: |μ∇2 u| μU 2 /L2 μU ∼ = = δ. |0 cu · ∇T | 0 cU ΔT /L L0 cΔT

4.3.3 The Grashof, Prandtl, and Eckert numbers The problem with the above dimensionless numbers is that they involve U , but U is implied by ΔT . Assuming that the convection term is much bigger than the viscous diffusion term, the momentum equation features a balance between the buoyancy term and the convection term: |0 u · ∇u| ∼ 0 gβΔT . Translating this similarity to scales, 0 U 2 /L ∼ 0 gβΔT, gives an U in terms of ΔT : U=



βLΔT .

The Reynolds number with this U now becomes gβL3 ΔT UL ReT = = = Gr1/2 , ν ν2 where Gr is the Grashof number in free thermal convection: Gr = Re2T =

gβL3 ΔT . ν2

118

4 Advanced partial differential equation models

The Grashof number replaces the Reynolds number in the scaled equations of free thermal convection. We shall soon look at its interpretations, which are not as straightforward as for the Reynolds and Peclet numbers. The above choice of U in terms of ΔT results in γ equal to unity: γ=

gβLΔT gβLΔT = 1. = 2 U gβLΔT

The Peclet number can also be rewritten as Pe =

cU L μc U L = = PrRe−1 = PrRe−1 T , κ κ μ

where Pr is the Prandtl number, defined as μc . κ The Prandtl number is the ratio of the momentum diffusivity (kinematic viscosity) and the thermal diffusivity. Actually, more detailed analysis shows that Pr reflects the ratio of the thickness of the thermal and velocity boundary layers: when Pr = 1, these layers coincide, while Pr 1 implies that the thermal layer is much thicker than the velocity boundary layer, and vice versa for Pr 1. The δ parameter is in free convection replaced by a combination of the Eckert number (Ec) and the Reynolds number. We have that Pr =

Ec =

U2 = δReT , cΔT

and consequently −1/2 . δ = EcRe−1 T = EcGr

Writing Ec =

0 U 2 , 0 cΔT

shows that the Eckert number can be interpreted as the ratio of the kinetic energy of the flow and the thermal energy. We use Gr instead of ReT in the momentum equations and also instead of Pe in the energy equation (recall that Pe = PrRe = PrReT = PrGr−1/2 ). The resulting scaled system becomes

4.3 Thermal convection

119

¯ ∂u ¯ 2u ¯u ¯ p + Gr−1/2 ∇ ¯ ·∇ ¯ = −∇¯ ¯ − Fr−2 k + T¯k, +u ∂ t¯ ¯ ·u ¯ = 0, ∇  ¯  ∂T ¯ 2 T¯ + 2EcGr−1/2 ε¯ij ε¯ij . ¯ T¯ = Pr−1 ∇ ¯ ·∇ +u Gr1/2 ∂ t¯

(4.49) (4.50) (4.51)

The Grashof number plays the same role as the Reynolds number in the momentum equation in free convection. In particular, it turns out that Gr governs the transition between laminar and turbulent flow. For example, the transition to turbulence occurs in the range 108 < Gr < 109 for free convection from vertical flat plates. Gr is normally interpreted as a dimensionless number expressing the ratio of buoyancy forces and viscous forces. Interpretations of the Grashof number. Recall that the scaling leading to the Grashof number is based on an estimate of U from a balance of the convective and the buoyancy terms. When the viscous term dominates over convection, we need a different estimate of U , since in this case, the viscous force balances the buoyancy force: μ∇2 u ∼ 0 gβΔT



μU/L2 ∼ 0 gβΔT,

This similarity suggests the scale U=

gβL2 ΔT . ν

Now, |0 u · ∇u| U L gβL3 ΔT ∼ = = Gr . |μ∇2 u| ν ν The result means that Gr1/2 measures the ratio of convection and viscous forces when convection dominates, whereas Gr measures this ratio when viscous forces dominate. The product of Gr and Pr is the Rayleigh number, Ra =

gβL3 ΔT 0 c , νκ

since gβL3 ΔT μc gβL3 ΔT 0 c = = Ra . ν2 κ νκ The Rayleigh number is the preferred dimensionless number when studying free convection in horizontal layers [2, 9]. Otherwise, Gr and Pr are used. GrPr = Re2T Pr =

120

4 Advanced partial differential equation models

4.3.4 Heat transfer at boundaries and the Nusselt and Biot numbers A common boundary condition, modeling heat transfer to/from the surroundings, is ∂T = h(T − Ts ), (4.52) ∂n where ∂/∂n means the derivative in the normal direction (n · ∇), h is an experimentally determined heat transfer coefficient, and Ts is the temperature of the surroundings. Scaling (4.52) leads to −κ



κΔt ∂ T¯ = h(ΔT T¯ + T0 − Ts ), L ∂n ¯

and further to ∂ T¯ hL ¯ Ts − T0 = (T + ) = δ(T¯ − T¯s ), ∂n ¯ κ ΔT where the dimensionless number δ is defined by δ=

hL , κ

and T¯s is simply the dimensionless surrounding temperature, Ts − T0 T¯s = . ΔT When studying heat transfer in a fluid, with solid surroundings, δ is known as the Nusselt number5 Nu. The left-hand side of (4.52) represents in this case heat conduction, while the right-hand side models convective heat transfer at a boundary. The Nusselt number can then be interpreted as the ratio of convective and conductive heat transfer at a solid boundary: h |h(T − Ts )| ∼ = Nu . κT /L κ/L The case with heat transfer in a solid with a fluid as surroundings gives the same dimensionless δ, but the number is now known as the Biot number6 . It describes the ratio of heat loss/gain with the surroundings at the solid body’s boundary and conduction inside the body. A small Biot number indicates that conduction is a fast process and one can use Newton’s law of cooling (see Section 2.1.7) instead of a detailed calculation of the spatio-temporal temperature variation in the body. 5 6

https://en.wikipedia.org/wiki/Nusselt_number https://en.wikipedia.org/wiki/Biot_number

4.4 Compressible gas dynamics

121

Heat transfer is a huge engineering field with lots of experimental investigations that are summarized by curves relating various dimensionless numbers such as Gr, Pr, Nu, and Bi.

4.4 Compressible gas dynamics 4.4.1 The Euler equations of gas dynamics The fundamental equations for a compressible fluid are based on balance of mass, momentum, and energy. When molecular diffusion effects are negligible, the PDE system, known as the Euler equations of gas dynamics, can be written as ∂ + ∇ · (u) = 0, ∂t ∂(u) + ∇ · (uuT ) = −∇p + f , ∂t ∂E + ∇ · (u(E + p)) = 0, ∂t

(4.53) (4.54) (4.55)

with E being 1 (4.56) E = e + u · u . 2 In these equations, u is the fluid velocity,  is the density, p is the pressure, E is the total energy per unit volume, composed of the kinetic energy per unit volume, 12 u · u, and the internal energy per unit volume, e. Assuming the fluid to be an ideal gas implies the following additional relations: e = cv T, p = RT =

(4.57) R 1 (E − u · u), cv 2

(4.58)

where cv is the specific heat capacity at constant volume (for dry air cv = 717.5 J kg−1 K−1 ), R is the specific ideal gas constant (R = 287.14Jkg−1 K−1 ), and T is the temperature. The common way to solve these equations is to propagate , u, and E by an explicit numerical method in time for (4.53)-(4.55), using (4.58) for p. We introduce dimensionless independent variables,

122

4 Advanced partial differential equation models

x ¯=

x , L

y¯ =

y , L

z¯ =

z , L

t t¯ = , tc

and dimensionless dependent variables, ¯= u

u , U

¯ =

 , c

p¯ =

p , pc

¯= E . E Ec

Inserting these expressions in the governing equations gives ∂ ¯ tc U ¯ ¯ = 0, ∇ · (¯ u) + L ∂ t¯ ¯ ∂(¯ u) tc p c tc fc ¯ tc U ¯ ¯u ¯T ) = − ∇ · (¯ u ¯f , ∇¯ p+ + L U Lc U ∂ t¯ ¯ tc U ∂E ¯ · (u(E ¯ + pc p¯)) = 0, ¯ cE ∇ + ∂ t¯ LEc R ¯ − 1 c uc ¯u ¯ · u) ¯ . p¯ = (Ec E cv pc 2 A natural choice of time scale is tc = L/U . A common choice of pressure scale is pc = c U 2 . The energy equation simplifies if we choose Ec = pc = c U 2 . With these scales we get ∂ ¯ ¯ ¯ = 0, + ∇ · (¯ u) ∂ t¯

¯ ∂(¯ u) ¯ · (¯ ¯u ¯ T ) = −∇¯ p + α¯ f¯, +∇ u ¯ ∂t ¯ ∂E ¯ · (u( ¯ + p¯)) = 0, ¯ E +∇ ∂ t¯ R ¯ 1 ¯·u ¯), − ¯u p¯ = (E cv 2 where α is a dimensionless number: Lfc . U2 We realize that the scaled Euler equations look like the ones with dimension, apart from the α coefficient. α=

4.4 Compressible gas dynamics

123

4.4.2 General isentropic flow Heat transfer can be neglected in isentropic flow7 , and there is hence an equation of state involving only  and p: p = F () . The energy equation is now not needed and the Euler equations simplify to



∂ + ∇ · (u) = 0, ∂t

(4.59)

∂u + u · ∇u + ∇p = 0 . ∂t

(4.60)

Elimination of the pressure. A common equation of state is  γ  F () = p0 , 0 where γ = 5/3 for air. The first step is to eliminate p in favor of  so we get a system for  and u. To this end, we must calculate ∇p: 



∇p = F ()∇,

F () =

c20



 0

γ−1 ,

where  c0 =

γp0 0

is the speed of sound within the fluid in the equilibrium state (see the subsequent section). Equation (4.60) with eliminated pressure p reads ∂u + u · ∇u + c20  ∂t



 0

γ−1

∇ = 0 .

(4.61)

The governing equations are now (4.59) and (4.61). Space and time are scaled in the usual way as x ¯=

x , L

y¯ =

y , L

z¯ =

z , L

¯= u

u . U

t t¯ = . tc

The scaled dependent variables are ¯ =

 , c

Then F  () = c20 ¯γ−1 . 7

https://en.wikipedia.org/wiki/Isentropic_process

124

4 Advanced partial differential equation models

Inserting the dimensionless variables in the two governing PDEs leads to c ∂ ¯ c U ¯ ¯ = 0, ∇ · (¯ u) + tc ∂ t¯ L   γ−1 ¯ c U 2 c U ∂ u c c ¯  = 0. ¯u ¯+ ¯u ¯·∇ ¯ c20 ¯γ−1 ∇¯ + tc ∂ t¯ L L 0 The characteristic flow velocity is U so a natural time scale is tc = L/U . This choice leads to the scaled PDEs ∂ ¯ ¯ ¯ = 0, + ∇ · (¯ u) ∂ t¯  γ−1 ¯ c ∂u ¯  = 0, ¯u ¯ ·∇ ¯ + M−2 ¯γ−1 ∇¯ + ¯u ¯ ¯  ∂t 0

(4.62) (4.63)

where the dimensionless number M=

U , c0

is known as the Mach number. The boundary conditions specify the characteristic velocity U and thereby the Mach number. Observe that (4.63) simplifies if c = 0 is an appropriate choice.

4.4.3 The acoustic approximation for sound waves Wave nature of isentropic flow with small perturbations. A model for sound waves can be based on (4.59) and (4.61), but in this case there are small pressure, velocity, and density perturbations from a ground state at rest where u = 0,  = 0 , and p = p0 = F (0 ). Introducing the perturbations ˆ (4.59) and (4.61) take the form ˆ =  − 0 and u, ∂ ˆ ˆ 0 + ˆ) = 0, + ∇ · (u( ∂t  γ−1 ˆ ∂u ˆ 2 ˆ · ∇u ˆ + c0 1 + + (0 + ˆ)u ∇ˆ  = 0. (0 + ˆ) ∂t 0 For small perturbations we can linearize this PDE system by neglecting all ˆ Also, 1 + ˆ/0 ≈ 1. This leaves us with the simplified products of ˆ and u. system

4.4 Compressible gas dynamics

125

∂ ˆ ˆ = 0, + 0 ∇ · u ∂t ˆ ∂u + c20 ∇ˆ 0  = 0. ∂t ˆ by differentiating the first PDE with respect to t and taking Eliminating u the divergence of the second PDE gives a standard wave equation for the density perturbations: ∂ 2 ˆ = c20 ∇2 ˆ . ∂t2 ˆ also with Similarly, ˆ can be eliminated and one gets a wave equation for u, wave velocity c0 . This means that the sound perturbations travel with velocity c0 . Basic scaling for small wave perturbations. Let c and uc be characteristic sizes of the perturbations in density and velocity. The density will then vary in [0 − c , 0 + c ]. An appropriate scaling is ¯ =

 − 0 c

such that ¯ ∈ [−1, 1]. Consequently, ),  = 0 + c ¯ = 0 (1 + α¯

α=

c . 0

Note that the dimensionless α is expected to be a very small number since c 0 . The velocity, space, and time are scaled as in the previous section. Also note that 0 and p0 are known values, but the scales c and U are not known. Usually these can be estimated from perturbations (i.e., sound generation) applied at the boundary. Inserting the scaled variables in (4.59) and (4.61) results in 0 ∂ ¯ 0 U ¯ ¯ = 0, ∇ · ((1 + α¯ )u) + tc ∂ t¯ L ¯ 0 U 2 0 0 U ∂u ¯  = 0. ¯u ¯ + α c20 (1 + α¯ (1 + α¯ )¯ u·∇ (1 + α¯ ) )γ−1 ∇¯ + ¯ tc L L ∂t α

Since we now model sound waves, the relevant time scale is not L/U but the time it takes a wave to travel through the domain: tc = L/c0 . This is a much smaller time scale than in the previous section because c0 U (think of humans speaking: the sound travels very fast but one cannot feel the corresponding very small flow perturbation in the air!). Using tc = L/u0 we get

126

4 Advanced partial differential equation models

α (1 + α¯ )

∂ ¯ ¯ · ((1 + α¯ ¯ = 0, + M∇ )u) ∂ t¯

¯ ∂u ¯u ¯  = 0. ¯ ·∇ ¯ + αM−1 (1 + α¯ )γ−1 ∇¯ + M(1 + α¯ )u ∂ t¯

For small perturbations the linear terms in these equations must balance. This points to M and α being of the same order and we may choose α = M (implying c = 0 M) to obtain ∂ ¯ ¯ ¯ = 0, + ∇ · ((1 + M¯ )u) ∂ t¯

¯ ∂u ¯  = 0. ¯u ¯ ·∇ ¯ + (1 + M¯ + Mu )γ−2 ∇¯ ∂ t¯ Now the Mach number, M, appears in the nonlinear terms only. Letting M → 0 we arrive at the following linearized system of PDEs ∂ ¯ ¯ ¯ = 0, +∇·u ∂ t¯ ¯ ¯ ∂u + ∇¯  = 0, ∂ t¯

(4.64) (4.65)

The velocity u can be eliminated by taking the time derivative of (4.64) and the divergence of (4.65): ∂ 2 ¯ ¯ 2 = ∇ ¯, (4.66) ∂ t¯2 which is nothing but a standard dimensionless wave equation with unit wave velocity. Similarly, we can eliminate  by taking the divergence of (4.64) and the time derivative of (4.65): ¯ ∂2u ¯ 2u ¯. (4.67) =∇ 2 ¯ ∂t We also observe that there are no physical parameters in the scaled wave equations.

4.5 Water surface waves driven by gravity 4.5.1 The mathematical model Provided the Weber number (see section 4.2.7) is sufficiently small, capillary effects may be omitted and water surface waves are governed by gravity.

4.5 Water surface waves driven by gravity

127

For large Reynolds numbers, viscous effects may also be ignored (except in boundary layers close to the bottom or the surface of the fluid). The flow of an incompressible homogeneous fluid under these assumptions is governed by the Euler equations of motion on the form ∇ · u = 0, ∂u 1 + u · ∇u + ∇p + gk = 0 . ∂t ρ

(4.68) (4.69)

When the free surface position is described as z = η(x, y, t), with z as the vertical coordinate, the boundary conditions at the surface read p = ps ,

(4.70)

∂η + u · ∇η = w, ∂t

(4.71)

where ps is the external pressure applied to the surface. At the bottom, z = −h(x, y), there is the no-flux condition ∂h ∂h u+ v = −w . ∂x ∂y In addition to ρ and g we assume that a typical depth hc , a typical wavelength λc , and a typical surface elevation A, which then by definition is a scale for η, are the given parameters. From these we must derive scales for the coordinates, the velocity components, and the pressure.

4.5.2 Scaling First, it is instructive to define a typical wave celerity, cc , which must be linked to the length and time scale according to cc = λc /tc . Since there is no other given parameter that matches the mass dimension of ρ, we express cc in terms of A, λc , hc , and g. Most of the work on waves in any discipline of physics is devoted to linear or weakly nonlinear waves, and the wave celerity must be presumed to remain finite as A goes to zero (see, for instance, Section 4.4.3). Hence, we may assume that cc must depend on g and either hc or λc . Next, the two horizontal directions are equivalent with regard to scaling, implying that we have a common velocity scale, U , for u and v, a common length scale L for x and y. The obvious choice for L is λc , while the “vertical quantities” w and z have scales W and Z, respectively, which may differ from the horizontal counterparts. However, we assume that also the length scale Z remains finite as A → 0 and hence is independent of A. This is less obvious for Z than for cc

128

4 Advanced partial differential equation models

and tc , but may eventually be confirmed by the existence of linear solutions when solving the equation set. From the linear part of (4.71) and (4.68) we obtain two relations between velocity and coordinate scales by demanding the non-dimensionalized terms to be of order unity A = W, tc

W U = . L Z

(4.72)

These relations are indeed useful, but they do not suffice to establish the scaling. The pressure may be regarded as the sum of a large equilibrium part, balancing gravity, and a much smaller dynamic part associated with the presence of waves. To make the latter appear in the equations we define the dynamic pressure, pd , according to p = ps − ρgz + pd , and the pressure scale pc = ρgA for pd then follows directly from the surface condition (4.70). The equation set will be scaled according to y z η u v w t x pd ¯ = , v¯ = , w ¯= , p¯d = t¯ = , x ¯ = , y¯ = , z¯ = , η¯ = , u . tc L L Z A U U W pc In the further development of the scaling we focus on two limiting cases, namely deep and shallow water.

4.5.3 Waves in deep water Deep water means that hc λc . Presumably the waves will not feel the bottom, and h as well as hc are removed from our equations. The bottom boundary condition is replaced by a requirement of vanishing velocity as z →√ −∞. Consequently, cc must depend upon λc and g, leaving us with cc = gλc and Z = λc = L as the only options. Then, tc = λc /g and (4.72) implies U = W = c0 λAc = c0 , where we have introduced the non-dimensional number =

A , λc

which is the wave steepness. The equality of the horizontal and the vertical scale is consistent with the common knowledge that the particle orbits in deep water surface waves are circular. The scaled equations are now expressed with  as sole dimensionless number

4.5 Water surface waves driven by gravity

129

¯ ·u ¯ = 0, ∇

(4.73)

¯ ∂u ¯u ¯ pd = 0 . ¯ ·∇ ¯ + ∇¯ + u ∂ t¯

(4.74)

The surface conditions, at z = η, become p¯d = η¯,

(4.75)

∂ η¯ ¯ η = w, ¯ · ∇¯ + u ¯ ∂ t¯

(4.76)

while the bottom condition is replaced by ¯ → 0, u

(4.77)

as z¯ → −∞.

4.5.4 Long waves in shallow water Long waves imply that the wavelength is large compared to the depth: λc hc . In analogy with the reasoning above, we presume that the speed of the cc must be based on g and hc , which waves remains√finite as λc → ∞. Then, √ leads to cc = ghc and tc = λc / ghc . The natural choice for the vertical length scale is now the depth; Z = hc . Application of (4.72) then leads to W = cc A/λc and U = cc A/hc . Introducing the dimensionless numbers α=

A , hc

μ=

hc , λc

we rewrite the velocity scales as W = μαcc ,

U = αcc .

We observe that W U for shallow water and that particle orbits must be elongated in the horizontal direction. The equation set is now most transparently written by introducing the ¯h = u ¯i + v¯j and the corresponding horizontal components horizontal velocity u ¯ h: of the gradient operator, ∇

130

4 Advanced partial differential equation models

∂w ¯ ¯ ·u ¯h + ∇ = 0, ∂ z¯ ¯h ¯h ¯ ∂u ∂u ¯ hu ¯h · ∇ ¯ h + αw + ∇h p¯d = 0, ¯ + αu ¯ ∂ z¯  ∂ t  ¯ ∂w ∂w ¯ ∂ p¯d ¯ hw ¯h · ∇ ¯ + αw = 0. . + αu μ2 ¯ + ¯ ∂ z¯ ∂ z¯ ∂t

(4.78) (4.79) (4.80)

Surface conditions, at z = αη, now become p¯d = η¯,

(4.81)

∂ η¯ ¯ h η¯ = w, ¯h · ∇ ¯ + αu ∂ t¯

(4.82)

while the bottom condition is invariant with respect to the present scaling ¯h ·u ¯ h = −w ∇ ¯.

(4.83)

An immediate consequence is that p¯d remains equal to η¯ throughout the water column when μ2 → 0, which implies that the pressure is hydrostatic. The above set of equations is a common starting point for perturbation expansions in  and μ2 that lead to shallow water, KdV, and Boussinesq type equations.

4.6 Two-phase porous media flow We consider the flow of two incompressible, immiscible fluids in a porous medium with porosity φ(x). The two fluids are referred to as the wetting8 and non-wetting fluid. In an oil-water mixture, water is usually the wetting fluid. The fraction of the pore volume occupied by the wetting fluid is denoted by S(x, t). The non-wetting fluid then occupies 1 − S of the pore volume (or (1 − S)φ of the total volume). The variable P (x, t) represents the pressure in the non-wetting fluid. It is related to the pressure Pn in the non-wetting fluid through the capillary pressure pc = Pn − P , which is an empirically determined function of S. From mass conservation of the two fluids and from Darcy’s law for each fluid, one can derive the following system of PDEs and algebraic relations that govern the two primary unknowns S and P :

8

https://en.wikipedia.org/wiki/Wetting

4.6 Two-phase porous media flow

131

∇ · v = −(Qn + Qw ), v = −λt ∇P φ

+ λw pc (S)∇S + (λw w + λn n )gk,

∂S  + fw (S)v · ∇S = ∇ · (hw (S)pc (S)∇S)+ ∂t ∂Gw + fw (Qn + Qw ) − Qw , g ∂z qw Qw = , w qn Qn = , n K krw (S), λw (S) = μw K krn (S), λn (S) = μn λt (S) = λw (S) + λn (S),  a S − Swr , krw (S) = Kwm 1 − Snr − Swr  b 1 − S − Snr , krn (S) = Knm 1 − Snr − Swr λw , fw (S) = λt Gw (S) = hw (S)(n − w ), hw (S) = −λn (S)fw (S) .

(4.84) (4.85)

(4.86) (4.87) (4.88) (4.89) (4.90) (4.91) (4.92) (4.93) (4.94) (4.95) (4.96)

The permeability of the porous medium is K (usually a tensor, but here taken as a scalar for simplicity); μw and μn are the dynamic viscosities of the wetting and non-wetting fluid, respectively; w and n are the densities of the wetting and non-wetting fluid, respectively; qw and qn are the injection rates of the wetting and non-wetting fluid through wells, respectively; Swr is the irreducible saturation of the wetting fluid (i.e., S ≥ Swr ); Snr is the corresponding irreducible saturation of the non-wetting fluid (i.e., (1 − S) ≥ Snr ), Kwn and Knr are the maximum values of the relative permeabilities krw and krn , respectively, and a and b are given (Corey) exponents in the expressions for the relative permeabilities. The two PDEs are of elliptic and hyperbolic/parabolic nature: (4.84) is elliptic since it is the divergence of a vector field, while (4.86) is parabolic (hw ≥ 0 because pc (S) ≥ 0 and λn as well as fw are positive since krn > 0 and krw > 0). Very often, pc is small so (4.86) is of hyperbolic nature, and S features very steep gradients that become shocks in the limit pc → 0 and (4.86) is purely hyperbolic. A popular solution technique is based on operator splitting at each time level in a numerical scheme: (4.84) is solved with respect to P , given S, and (4.86) is solved with respect to S, given P .

132

4 Advanced partial differential equation models

The saturation S is a non-dimensional quantity, and so are φ, krw , krn ,  . The quantity v is the total filtration velocity, i.e., Kwm , Knm , fw , and fw the sum of the velocities of the wetting and non-wetting fluid. An associated velocity scale vc is convenient to define. It is also convenient to introduce dimensionless fractions of wetting and non-wetting fluid properties:  ≡ w , n = α,

α=

n , w

β=

μn , μw

μ ≡ μw , μn = μβ, Q ≡ Qw = γ Qn = Q , α

qw , 

γ=

qn . qw

We will benefit from making λw , λn , and λt dimensionless: K ¯ w = krw , ¯ w , λc = K , λ krw (S) = λc λ μ μ K ¯ n = krn , ¯n, λ λn (S) = β −1 krn (S) = λc β −1 λ μ ¯t = λ ¯ w + β −1 λ ¯t, λ ¯n . λt (S) = λw (S) + λn (S) = λc λ

λw (S) =

As we see, λc is the characteristic size of any “lambda” quantity, and a bar indicates as always a dimensionless variable. The above formulas imply ¯ n (S)fw (S), hw (S) = −λc β −1 λ

Gw (S) = hw (S)(α − 1) .

Furthermore, we introduce dimensionless quantities by ¯= x

x , L

v¯ =

v , vc

P P¯ = , Pc

p¯c =

pc . Pc

Inserting the above scaled quantities in the governing PDEs results in

4.6 Two-phase porous media flow

133

¯ · v¯ = − LQ (1 + α−1 γ), ∇ (4.97) vc P c λ c ¯ ¯ ¯ λ c Pc ¯  ¯ λt ∇P + λw p¯c (S)∇S+ v¯ = − vc L vc L gλc  ¯ ¯ n )k, (λw + αβ −1 λ (4.98) vc ∂S tc vc  ¯ n (S)fw (S)¯ ¯ · (−β −1 λ ¯ = t c Pc λ c ∇ ¯ φ fw (S)¯ v · ∇S pc (S)∇S)+ + ¯ L L2 ∂t tc g ∂Gw + tc fw Q(1 + α−1 γ) − tc Q . (4.99) L ∂ z¯ As usual, L is taken as the characteristic length of the spatial domain. Since vc is a velocity scale, a natural time scale is the time it takes to transport a signal with velocity vc through the domain: tc = L/vc . The diffusion term in the equation (4.102) then gets a dimensionless fraction LPc λc . vc L2 Forcing this fraction to be unity gives Pc . L We realize that this is indeed a natural velocity scale if the velocity is given by the pressure term in Darcy’s law. This term is K/μ times the pressure gradient: vc = λc

K Pc Pc K |∇P | ∼ = λc = vc . μ μ L L ¯n ¯ w or λ We have here dropped the impact of the relative permeabilities λ since these are quantities that are less than or equal to unity. The other term in Darcy’s law is the gravity term that goes like λc g (again dropping relative permeabilities). The ratio of the gravity term and the pressure gradient term in Darcy’s law is an interesting dimensionless number: δ=

Lg λc g = . λc Pc /L Pc

This number naturally arises when we discuss the term tc g ∂Gw ¯  (S)fw (S) + λ ¯ n (S)f  (S)) ∂S = −(α − 1)β −1 δ(λ n w L ∂ z¯ ∂ z¯ Introducing another dimensionless variable,  = tc Q =

L2 Q , λ c Pc

134

4 Advanced partial differential equation models

we can write (4.97)-(4.99) in the final dimensionless form as ¯ · v¯ = −(1 + α−1 γ), ∇ (4.100)  −1 ¯ ¯ ¯ ¯ ¯ ¯ ¯ v¯ = −λt ∇P + λw p¯c (S)∇S + δ(λw + αβ λn )k, (4.101) φ

∂S  ¯ n (S)fw (S)¯ ¯ = −∇ ¯ · (−β −1 λ ¯ (S)¯ v · ∇S pc (S)∇S)− + fw ∂ t¯ ¯  (S)fw (S) + λ ¯ n (S)f  (S)) (α − 1)β −1 δ(λ n w fw (1 + α−1 γ) −  .

∂S + ∂ z¯ (4.102)

The eight input parameters L, qw , qn , μw , μn , w , n , and K are reduced to five dimensionless parameters α, β, γ, δ, and . There are six remaining dimensionless numbers to be set: Kwm , Knm , Swr , Snr , a, and b. Open Access This chapter is distributed under the terms of the Creative Commons AttributionNonCommercial 2.5 License (http://creativecommons.org/licenses/by-nc/2.5/), which permits any noncommercial use, distribution, and reproduction in any medium, provided the original author(s) and source are credited. The images or other third party material in this book are included in the work’s Creative Commons license, unless indicated otherwise in the credit line; if such material is not included in the work’s Creative Commons license and the respective action is not permitted by statutory regulation, users will need to obtain permission from the license holder to duplicate, adapt, or reproduce the material.

References

[1] J. F. Douglas, J. M. Gasiorek, and J. A. Swaffield. Fluid Mechanics. Pitman, 1979. [2] P. G. Drazin and W. H. Reid. Hydrodynamic Stability. Cambridge, 1982. [3] H. P. Langtangen. Finite Difference Computing with Exponential Decay Models. Springer, 2016. http://tinyurl.com/nclmcng/web. [4] H. P. Langtangen. A Primer on Scientific Programming with Python. Texts in Computational Science and Engineering. Springer, fifth edition, 2016. [5] H. P. Langtangen and A. E. Johansen. The Parampool tutorial. http: //hplgit.github.io/parampool/doc/web/index.html. [6] H. P. Langtangen and A. E. Johansen. Using web frameworks for scientific applications. http://hplgit.github.io/web4sciapps/doc/web/ index.html. [7] H. P. Langtangen and S. Linge. Finite Difference Computing with Partial Differential Equations. 2016. http://tinyurl.com/ Langtangen-Linge-FDM-book. [8] J. D. Logan. Applied Mathematics: A Contemporary Approach. Wiley, 1987. [9] D. J. Tritton. Physical Fluid Dynamics. Van Nostrand Reinhold, 1977.

© The Author(s) 2016 H.P. Langtangen and G.K. Pedersen, Scaling of Differential Equations, Simula SpringerBriefs on Computing 2, DOI 10.1007/978-3-319-32726-6

135

Index

angular frequency, 52 assert, 63 base unit, 1 Bernoulli’s equation, 108 Biot number, 120 Buckingham Pi theorem, 3 characteristic time, 19 creeping flow, 109

joblib, 22, 28 length, 1 logistic equation, 37 low Reynolds number flow, 109 Mach number, 124 mass, 1 memoize function, 22 multiple software runs, 13

Navier-Stokes equations, 106 dimension of physical quantities, 2 dimensionless number, 27, 31, 34, 37, non-dimensionalization, 17 Nusselt number, 120 77, 97, 107 dimensionless variable, 17, 19 parampool, 9 Peclet number, 92, 113, 118 e-folding time, 20 period (of oscillations), 52 Eckert number, 118 phase shift, 65 Euler number, 111 PhysicalQuantity, 7 exponential decay, 18 Pi theorem, 3 forced convection, 113 quality factor Q, 65 free convection, 114 frequency, 52 radians, 52 frequency, angular, 52 Reynolds number, 97, 107, 108, 113, Froude number, 109 117 graphical web interface, 14 scaling, 17 Grashof number, 117 Stokes problem, 109

© The Author(s) 2016 H.P. Langtangen and G.K. Pedersen, Scaling of Differential Equations, Simula SpringerBriefs on Computing 2, DOI 10.1007/978-3-319-32726-6

137

138

Stokes’ flow, 109 Strouhal number, 110 thermo-elasticity, 105 time, 1 units, 1 British, 5 conversion, 7 software, 7 US, 5 vortex shedding, 111 web interface (Parampool), 14 Weber number, 112

INDEX