Modelling Physical Phenomena Limitations and Challenges of the Differential Algebraic Equations Approach Olaf Trygve Berglihn Department of Chemical Engineering 30. June 2010
2 Outline Background Classification DAE-types, index and stiffness Model examples Index reduction strategies Modeling guidelines Initialization Discontinuities Industry example Where DAEs do not fit Current research and outlook Conclusion
3 Differential Algebraic Equations Ordinary differential equations with algebraic constraints on the variables. (Drawing by K. Wanner.)
4 Solution approach I ẏ = f(y, x, t), G(y, x, t) = 0 Nested approach Given y n, t n, solve G(y n, x, t n ) = 0, and evolve y n+1 using ODE-methods. Required approach if only explicit integrator is available (Euler, Runge-Kutta, etc). Can be expensive due to inner iterations.
5 Solution approach II F (ẏ, y, x, t) = 0 Simultaneous approach Solve the implicit or semi-explicit form simultaneously using an implicit solver and evolve both x and y in time. Requires an implicit solver. Is much more efficient. Provides for more flexible problem specification. This talk will focus on the simultaneous approach.
6 Typical models using DAE-formulation Chemical engineering processes with equilibrium conditions. Constrained mechanical systems, robots. Electrical circuits and power grids. Heating, ventilating and air-conditioning of buildings.
7 Evolution of DAE-solvers Gear LSODI (Hindmarch) DASSL (Petzold) IDA (Hindmarch, Taylor) ode15s (Shampine, Reichelt) GELDA (Kunkel, Merhmann) MANPACK (Rheinboldt) ode15i (Shampine, Reichelt) RADAU5 (Hairer, Wanner), COLDAE (Ascher, Spiteri) BzzDae (Manca, Buzzi-Ferraris) GENDA (Kunkel, Mehrmann, Seufer) 1970 1980 1990 2000 2010 A selection of the more commonly cited solvers.
8 Papers published containing Differential Algebraic Equations Papers per year 160 140 120 100 80 60 40 20 0 1970 1980 1990 2000 2010 (Source: Scopus)
9 Papers published by discipline Engineering Mathematics Computer Science Other Chemistry Biochemistry, Genetics and Molecular Biology Environmental Science Energy Physics and Astronomy Materials Science Chemical Engineering (Source: Scopus)
10 Classification I DAEs are primarily classified by type, index and stiffness. DAE-types Fully implicit: F (ẏ, y, x, t) = 0. Linearly implicit: A(y, x)ẏ = f(y, x, t), 0 = g(y, x, t) Semi-explicit: ẏ = f(y, x, t), 0 = g(y, x, t)
11 Classification II Differentiation index F (ẏ, y, x, t) = 0 has differentiaion index v = Ind(F ) if v is the minimal number of analytical differentiations F (ẏ, y, x, t) = 0, F (ẏ, y, x, t) x = 0,..., v F (ẏ, y, x, t) x v = 0 (1) such that equations (1) allow us to extract by algebraic manipulations an explicit ordinary differential equations system. Initial conditions must satisfy all intermediate algebraic relations.
12 Classification III Stiffness If both fast and slow processes are included in the model, the model becomes stiff. Consider the following system: ẋ 1 = 10 2 x 1 ẋ 2 = 10 2 x 1 10 4 x 2 x 1 (0) = 1, x 2 (0) = 0 Reduction in x 2 is one million times faster than the reduction in x 1. Stability in integration is dictated by the fastest dynamics. Stiff systems require capable stiff solvers, or exceedingly small time stepping.
13 Hessenberg index 1-form ẏ = f(y, x) If g x is invertible, we can write ( ) x g 1 t = g x y f and have a system of only ODEs. (2a) 0 = g(y, x) (2b)
14 Hessenberg index 2-form I ẏ = f(y, x) (3a) 0 = g(y) (3b) We attempt to convert the set of equations to only ODEs by differentiation of (3b): 0 = g y y t = g y f (4) One differentiation does not do. We see that (4) is a hidden constraint of (3).
15 Hessenberg index 2-form II A second differentiation yields: 0 = 2 g y 2 f + g f y y f + g f x y x t (5) Assuming g y f x is invertible, this yields ( x g t = y ) f 1 ( 2 g x y 2 + g y ) f f. (6) y
16 Consequences of high index Index v > 1 imply constraints on the differential variables. Consider this semi-explicit index-2 system: ẏ = f(y, x) (7a) 0 = g(y) (7b) Initial conditions must satisfy g y f = 0 (8) Hidden constraints presents difficulties for DAE-solvers.
17 Example: Tank with overflow I ˆN (f), z i ˆN (o) N j, x j, v j ˆN Mole flow, f =feed, o=overflow N i Number of moles x i, z i Mole fractions v Molar specific volume i Component index, i {a, b} N a = ˆN (f) z a ˆN (o) x a N b = ˆN (f) z b ˆN (o) x b N = N a + N b N a = x a N N b = x b N v = v a x a + v b x b V = vn INDEX 2
18 Example: Tank with overflow II ˆN (f), z i N a = ˆN (f) z a ˆN (o) x a N b = ˆN (f) z b ˆN (o) x b N j, x j, v j ˆN (o) N = N a + N b N a = x a N N b = x b N v = v a x a + v b x b V = vn ˆN (o) v = ˆN (f) (v a z a + v b z b ) INDEX-1
19 Example: Tank with overflow III ˆN (f), z i N a = ˆN (f) z a ˆN (o) x a N b = ˆN (f) z b ˆN (o) x b N j, x j, v j ˆN (o) N = N a + N b N a = x a N N b = x b N v = v a x a + v b x b V = vn ˆN (o) v = ˆN (f) (v a z a + v b z b ) INDEX-1
20 Example: Pressure vessel with variable volume I ˆN, h x N, U, p, T Ṅ = ˆN U = p V + ˆNh pv = NRT U = Nc v T Linearly-implicit index-1. Requires implicit DAE solver. pa = F x V = Ax F x = kx
21 Example: Pressure vessel with variable volume II V = s ˆN, h x N, U, p, T Ṅ = ˆN U = ps + ˆNh pv = NRT U = Nc v T Introduce dummy variable s. Semi-explicit index-2. Requires index-2 capable DAE solver. pa = F x V = Ax F x = kx
22 Example: Pressure vessel with variable volume III Symbolic differentiation of volume and elimination yields: U = Ṅ = ˆN ( prax 2 ) 1 prax 2 + pc v Ax 2 + V c v k pv = NRT U = Nc v T pa = F x V = Ax F x = kx Semi-explicit index-1. Not intuitive how to do this! ˆNh
23 Causes of high index Imposing constraints on differential variables is the major problem. Assumption of infinitely fast dynamics Pseudo-steady state approximations and equilibrium conditions. Specification on derived states p = ( ) U V S,N If U is a differential variable (in energy balance), specifying impose constraint on U. p = p spec
24 How to handle high index and implicit systems Implicit Use implicit solvers or rewrite to semi-explicit form. High index Use high-index capable solver or reformulate and use symbolic differentiation. Pitfalls Exchanging an algebraic constraint with a differential equation can cause drift. High index capable solvers are very sensitive to scaling. Symbolic derivation and manipulation is error prone. The change from implicit to semi-explicit increases the index.
25 Index reduction strategies a) Remodeling Model round the index problem. Include fast dynamics. Makes the model stiff. Include rate equations for flows and reactions. Transform into other variables (x = r cos θ, y = r sin θ). b) Remove variables and equations or lump control volumes. Implies loss of detail. c) Reduce index by index reduction algorithms Involves symbolic differentiation and manipulation. Several strategies reported in the literature.
26 Modeling guidelines Procedure to reach index-1 models: a) Conservation equations: Formulate dynamic differential equations for the conserved quantities. b) Constitutive equations: Express dependent state variables from the conserved quantities. c) Rate equations: Express rates by difference in potential.
27 Modeling guidelines: Example I Calculate pressure and temperature in a perfectly insulated gas pipe: Assumptions: Ideal gas, constant heat capacity. Adiabatic pipe, neglect heat capacity of walls, constant volume. Sub-sonic, turbulent flow. Simple valve equation for flow. Uniform pressure and temperature in pipe segment.
28 Modeling guidelines: Example II Constitutive equations: express T : express p: N and U U = N Z T pv = NRT T ref c vdt express p: p = 1 (p + p1) 2 Conservation on the number of moles and internal energy: express N: Ṅ = ˆN (0) ˆN (1) express U: U = ˆN (0) h (0) ˆN (1) h (1) ˆN (1) express h 1: h 1 = Z T T ref c pdt Rate equations: express ˆN (1) : ˆN (1) = k 1 q p(p p (1) ) p, p and T
29 Initialization Finding consistent initial conditions is a major obstacle with index > 1 models. Some possible approaches: Structural Successive Linear Programming (SLP) Gauss-Newton-Maquardt methods using singular value decomposition.
30 Initialization: Structural approach Develop derivative array equations: F (ẏ, y, x, t) = 0, F (ẏ, y, x, t) x. = 0, v F (ẏ, y, x, t) x v = 0 Analyze variable occurrence of the complete system, choose pivoting variables among (ẏ, y, x) from among all equations, and solve this set at t(0).
31 Initialization: Successive Linear Programming Develop derivative array equations: Solve G(y, y t,, n y t n, t) = 0 ( min G y, y ) t,, n y t n, 0 1 using Successive Linear Program (SLP).
32 Initialization: Gauss-Newton-Maquardt Develop derivative array equations: Solve G(y, y t,, n y t n, t) = 0 ( min G y, y ) t,, n y t n, 0 2 using Singular Value Decomposition (SVD).
33 Discontinuities Consider this definition of mass m: m(t) = ρ(x, t)dv (9) We write the time differential dm dt = d ρ(x, t)dv dt Ω Equation (10) is only valid if ρ is continuous over Ω. Remedy: Locate discontinuities. Integrate over piecewise smooth segments. Use smooth transition (tanh) Ω? Ω ρ(x, t)dv (10) t Some solvers can locate and traverse discontinuities.
developing a model for predicting the pressure buildup, temperatures etc. in the pipe, such that 34 safe procedures for hydrate removal may be devised. This report documents the current status of the model (July 13, 2005), and documents the assumptions, model equations, numerics and Industry program structure. example: Direct electrical heating of gas hydrate plug Figure 1-1 shows the hydrate melting process schematically. There is a hydrate plug that blocks a pipe, and an external heat flux, Q 10 (t,x), is applied to the pipe in order to remove the plug. The external heat flux may vary with axial position and time. Model of direct heating of pipe line plugged by hydrate. r,z Q 10 θ x Figure 1-1. Melting hydrate plug Very stiff problem pipe elasticity. Discontinuous heating of hydrate vs. melting of hydrate. As a result of the external heating, the hydrate plug will start melting, and melted fluid leaves by axial flow in both directions. The present model assumes that all melted fluid leaves by flowing in the annular Assumptions gap that forms between can lead the pipe to high and the index. plug; i.e. there is no flow of melted fluid inside the plug (conservative assumption). Careful scaling is essential. As the plug is assumed to seal the pipe completely when the heating starts, there will be a
35 Industry example: results x 10 7 Pressure Pressure [Pa] 2.08 2.07 2.06 2.05 2.04 2.03 0 10.52632 21.05263 31.57895 42.10526 52.63158 63.15789 73.68421 84.21053 94.73684 105.2632 115.7895 126.3158 136.8421 147.3684 157.8947 168.4211 178.9474 189.4737 200 2.02 2.01 2 0.7 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 Time [s] x 10 4
36 Limitations of DAEs Where DAEs do not fit: Purely discrete systems. Time discrete event. Cellular automaton Game of Life. Stochastic systems. Can the system be made continuous? Can jumps be made continuous transitions? Model on the continuous parameters of a distribution?
37 Current research and outlook A lot of specialized solvers published in recent years. Focus on model building software to aid modeling. Validated numerics for DAEs: give guaranteed interval for solution. Interval integration: given input set, what is output set? Will the process be stable?
38 Conclusion Modeling dynamic systems with constraints is challenging. Great care must be taken to avoid index problems. A good modeling methodology is essential. Index reduction can be applied, but is not trivial.
39 Selected bibliography I K. E. Brenan, S. L. Campell, and L. R. Petzold. Numerical solution of initial-value problems in differential-algebraic equations. North-Holland, New York, 1989. Charles. W. Gear. Simultaneous numerical solution of differential-algebraic equations. IEEE Trans. Circuit Theory, CT-18:89 95, 1971. E. Hairer, Norsett S. P., and G. Wanner. Solving Ordinary, Differential Equations II. Stiff and Differential-Algebraic Problems, volume 2. 2Ed. Springer-Verlag, 2002, 2002. ISBN 3-540-60452-9. Index.
40 Selected bibliography II Peter Kunkel. Differential-algebraic equations: analysis and numerical solution. European Mathematical Society, 2006. Volker Mehrmann and Lena Wunderlich. Hybrid systems of differential-algebraic equations - analysis and numerical solution. Journal of Process Control, 19(8):1218 1228, 2009. ISSN 0959-1524. Special Section on Hybrid Systems: Modeling, Simulation and Optimization. Håvard Ingvald Moe. Dynamic Process Simulation, Studies on Modeling and Index Reduction. PhD thesis, University of Trondheim, 1995.
41 Selected bibliography III Linda Petzold. Differential/algebraic equations are not ode s. SIAM Journal on Scientific and Statistical Computing, 3(3):367 384, 1982.