The Chemical Kinetics Time Step a detailed lecture. Andrew Conley ACOM Division

Similar documents
NUMERICAL SOLUTION OF ODE IVPs. Overview

Math 660 Lecture 4: FDM for evolutionary equations: ODE solvers

CS520: numerical ODEs (Ch.2)

CS 450 Numerical Analysis. Chapter 9: Initial Value Problems for Ordinary Differential Equations

ECE257 Numerical Methods and Scientific Computing. Ordinary Differential Equations

Lecture Notes to Accompany. Scientific Computing An Introductory Survey. by Michael T. Heath. Chapter 9

Scientific Computing: An Introductory Survey

Solving Ordinary Differential equations

Review for Exam 2 Ben Wang and Mark Styczynski

Ordinary differential equations - Initial value problems

Chapter 6 - Ordinary Differential Equations

Solving PDEs with PGI CUDA Fortran Part 4: Initial value problems for ordinary differential equations

ODEs. PHY 688: Numerical Methods for (Astro)Physics

Differential Equations

X i t react. ~min i max i. R ij smallest. X j. Physical processes by characteristic timescale. largest. t diff ~ L2 D. t sound. ~ L a. t flow.

Accuracy and Cost Considerations in Choosing a Chemical Mechanism for Operational Use in AQ Models

Review Higher Order methods Multistep methods Summary HIGHER ORDER METHODS. P.V. Johnson. School of Mathematics. Semester

CHAPTER 10: Numerical Methods for DAEs

16.7 Multistep, Multivalue, and Predictor-Corrector Methods

Multistep Methods for IVPs. t 0 < t < T

Modeling & Simulation 2018 Lecture 12. Simulations

ODEs. PHY 688: Numerical Methods for (Astro)Physics

Scientific Computing with Case Studies SIAM Press, Lecture Notes for Unit V Solution of

Initial value problems for ordinary differential equations

Bindel, Fall 2011 Intro to Scientific Computing (CS 3220) Week 12: Monday, Apr 18. HW 7 is posted, and will be due in class on 4/25.

Lecture IV: Time Discretization

Lecture V: The game-engine loop & Time Integration

Faster Kinetics: Accelerate Your Finite-Rate Combustion Simulation with GPUs

M-RICh v0.5 MATLAB Rate Integrator for Chemical equations

Numerical Methods I Solving Nonlinear Equations

Research Computing with Python, Lecture 7, Numerical Integration and Solving Ordinary Differential Equations

Solving Ordinary Differential Equations

Index. higher order methods, 52 nonlinear, 36 with variable coefficients, 34 Burgers equation, 234 BVP, see boundary value problems

Chapter 9 Implicit Methods for Linear and Nonlinear Systems of ODEs

Scientific Computing with Case Studies SIAM Press, Lecture Notes for Unit VII Sparse Matrix

Differential Equations

MOX EXPONENTIAL INTEGRATORS FOR MULTIPLE TIME SCALE PROBLEMS OF ENVIRONMENTAL FLUID DYNAMICS. Innsbruck Workshop October

Mathematics for chemical engineers. Numerical solution of ordinary differential equations

Applied Numerical Analysis

Numerical Algorithms for ODEs/DAEs (Transient Analysis)

Numerical solution of ODEs

Physically Based Modeling: Principles and Practice Differential Equation Basics

Automation in Complex Systems MIE090

1. Introduction. Many dynamical systems in science and engineering are modeled by ordinary differential equations (ODEs)

CHAPTER 5: Linear Multistep Methods

Ordinary Differential Equations

Physically Based Modeling Differential Equation Basics

Parallel Methods for ODEs

Numerical Methods for Engineers. and Scientists. Applications using MATLAB. An Introduction with. Vish- Subramaniam. Third Edition. Amos Gilat.

Modeling and Experimentation: Compound Pendulum

4.4 Computing π, ln 2 and e

Linear Multistep Methods I: Adams and BDF Methods

Ordinary Differential Equations II

Fourth Order RK-Method

8.1 Introduction. Consider the initial value problem (IVP):

S#ff ODEs and Systems of ODEs

CHAPTER 1 INTRODUCTION TO NUMERICAL METHOD

Acceleration of Time Integration

Initial-Value Problems for ODEs. Introduction to Linear Multistep Methods

Lecture 4: Numerical solution of ordinary differential equations

Getting Started with Communications Engineering

ANALYSIS OF THE MPAS CONVECTIVE-PERMITTING PHYSICS SUITE IN THE TROPICS WITH DIFFERENT PARAMETERIZATIONS OF CONVECTION REMARKS AND MOTIVATIONS

Math 411 Preliminaries

Jim Lambers MAT 772 Fall Semester Lecture 21 Notes

Numerical Analysis. A Comprehensive Introduction. H. R. Schwarz University of Zürich Switzerland. with a contribution by

A First Course on Kinetics and Reaction Engineering Supplemental Unit S5. Solving Initial Value Differential Equations

Applied Math for Engineers

APPLICATIONS OF FD APPROXIMATIONS FOR SOLVING ORDINARY DIFFERENTIAL EQUATIONS

Linear Solvers. Andrew Hazel

The family of Runge Kutta methods with two intermediate evaluations is defined by

NUMERICAL METHODS FOR ENGINEERING APPLICATION

Computational Techniques Prof. Dr. Niket Kaisare Department of Chemical Engineering Indian Institute of Technology, Madras

Review. Numerical Methods Lecture 22. Prof. Jinbo Bi CSE, UConn

[ ] is a vector of size p.

Checking the Radioactive Decay Euler Algorithm

Chapter 5. Formulation of FEM for Unsteady Problems

PARTIAL DIFFERENTIAL EQUATIONS

Initial value problems for ordinary differential equations

Semi-implicit Krylov Deferred Correction Methods for Ordinary Differential Equations

The Plan. Initial value problems (ivps) for ordinary differential equations (odes) Review of basic methods You are here: Hamiltonian systems

An Algorithmic Framework of Large-Scale Circuit Simulation Using Exponential Integrators

16.7 Multistep, Multivalue, and Predictor-Corrector Methods

How not to build a Model: Coupling Cloud Parameterizations Across Scales. Andrew Gettelman, NCAR

ENGI9496 Lecture Notes State-Space Equation Generation

Ordinary Differential Equations

Time stepping methods

Chapter 5 Exercises. (a) Determine the best possible Lipschitz constant for this function over 2 u <. u (t) = log(u(t)), u(0) = 2.

Numerical Methods - Initial Value Problems for ODEs

Exponential integrators and functions of the matrix exponential

Numerical Solution of ODE IVPs

Multistage Methods I: Runge-Kutta Methods

Butcher tableau Can summarize an s + 1 stage Runge Kutta method using a triangular grid of coefficients

Numerical Methods for Engineers

Astronomy 8824: Numerical Methods Notes 2 Ordinary Differential Equations

LINEAR ALGEBRA: NUMERICAL METHODS. Version: August 12,

QUESTIONS FOR THE TESTS-ECI 146

Algebraic Equations. 2.0 Introduction. Nonsingular versus Singular Sets of Equations. A set of linear algebraic equations looks like this:

MTH 452/552 Homework 3

The Direct Transcription Method For Optimal Control. Part 2: Optimal Control

MATHEMATICAL METHODS INTERPOLATION

Transcription:

The Chemical Kinetics Time Step a detailed lecture Andrew Conley ACOM Division

Simulation Time Step Deep convection Shallow convection Stratiform tend (sedimentation, detrain, cloud fraction, microphysics) Aerosol wet chemistry Radiation Couple (land, ice, ocean) Transport Sink/source for chemicals Deposition, kinetics, emissions Vertical diffusion Aerosol dry deposition Gravity wave drag

Trust the solver? Robust It can t break, ever! 1 degree horizontal resolution, 100 yrs, dt = 15mins, 30 levels => 3,079,296,000,000 solves of an ODE -- order(nspecies) When it fails, it does something reasonable that can be handled. Stable Consistent, accurate enough for application Sufficient to capture the relevant behavior Scientists expect to trust results

Requirements Consistency Resolution->0 Number of reactions and species dt->0 Conservation laws (mass, stoichiometry) Time splitting Positive Definite Stability Engineering Constraints Exothermic reactions Flame fronts Computational time (number of matrix solves and f evals) Computation of f jacobian solves, sparse solves. Complexity of method (implication for adjoint) Robust When things fail Subdividing the time step Context Software/hardware (threading / tasks / compilers) Fundamental kinetics vs simulation of weather/climate Result is good enough testing?

Simple Example (Terminator Chemistry Test) $% & $% + $%! Photolytic Decomposition $% + $% $% & 1 Recombination Rates R(1) =! [$% & ] R(2) = 1 [$%] & Differential Equation )[*+, ] )- )[*+] )- = -! [$% & ] + 1 [$%] & = 2j [$% & ] - 2 [$%] & Assume rate constants don t vary during time step f(solar, T, P, Surface Area Density, ) Lauritzen et. al. 2015

Simple Example $% & $% + $%! Photolytic Decomposition $% + $% $% & 1 Recombination Rates R(1) =! [$% & ] R(2) = 1 [$%] & Differential Equation )[*+, ] )- )[*+] )- = -! [$% & ] + 1 [$%] & = 2j [$% & ] - 2 [$%] & Non-linear Lauritzen et. al. 2015

y = y 2 y(0) = y 0 Solution: y = 1 / (y 0 t) Blows up at t = y 0 Implications? Mass increases without bound Believe that? But mass is bounded (or our list of reactions is wrong.) Don t worry, be happy

y = f(y) Theory! " # exists -> unique solution exists!( #, ') -> More complicated conditions for existence, uniqueness Hope? Seems to work, except when we implement bad collections of reactions Scientists trust the underlying numerical method Learn from linear systems

Linearized (forward sensitivity)![#$ % ]!'![#$]!' Linear Form!. #$%. = #$!' )* + )* + )* ( Photolytic Decomposition )* + )* )* + 1 Recombination = -([)* + ] + 1 [)*] + = 2([)* + ] - 2 [)*] + ( 2[)*] 2( 4[)*] 84 89 = :(4). #$%. #$!2!' =!3!2 4 = 54 Lauritzen et. al. 2015

Linearized (forward sensitivity)![#$ % ]!'![#$]!' Linear Form!. #$%. = #$!' )* + )* + )* ( Photolytic Decomposition )* + )* )* + 1 Recombination = -([)* + ] + 1 [)*] + = 2([)* + ] - 2 [)*] + ( 2[)*] 2( 4[)*]. #$%. #$ 45 46 = 7(5) 45 46 = 47 45 5 = 85 Lauritzen et. al. 2015 Forcing Jacobian

Stiffness!"!# = % ' % ' =! (!" Jordan Normal Form ) *+ % ) =, Diagonal of eigenvalues (- +, - /,..) Rank of A is ~(number of species # conservation laws) Stiffness: - 123 45 > 1 Be Careful. This is a stiff ODE. < 1 Ok < + 6 Smaller is better, but

Stiffness!"!# = % ' % ' =! (!" Stiffness: * +,-./ > 1 Be Careful. This is a stiff ODE. < 1 Ok < 0 1 Smaller is better Eigenvalues vary with mechanism and local environment Time step,./, imposed by external model A-priori estimates are rare Computation can be expensive (Krylov methods) If it is atmospheric chemistry it is probably stiff (or make./ larger) or uninteresting from a solver viewpoint

!!" # $ # = 5 1 % 1 $ * # $ # % + = {0, 5.2} Initial Condition: Solution: # $ # % = 1 5 # $ # % (3) = 1 5 56 " Solution: Initial Condition: # $ # % = 0.5 5.1 # $ # % (3) = 1 5 + 0.1 5 1 5 8(*.%)"

Forward Euler (explicit)! "#!(0) "# = )(! 0 )! * = +! >! "#!(0) "# = +! 0! "# = 1 + + "#! 0! / "# = 1 + + "# 0! 0

Forward Euler! " = 5!

Forward Euler! "#!(0) "# = ) 0 = *! 0 [*"# =,]!. /, = 1 +,.! 0 = 2,. Need 2, = 1 +, < 1

Forward Euler! " = $! = %!! =! & ' ()! *+!(0) *+ = $ 0 = %! 0! *+ = 1 + % *+! 0! 2 *+ = 1 + % *+ 3! 0 [%*+ = 5] Numerical:! 3 ( 5 = 1 + 5 3! 0 Exact:! 3 ( 5 = '3 7! 0

Backward Euler (implicit)! "#!(0) "# = ) "# = *! "#! + *, = 1,./! 0 Exact:! / 0, = 1/ 2! 0 3, = 1,.4

Forward Euler Not A-stable Backward Euler A-stable! "! " " = $ %& " = $ %&

Forward Euler! " = 5!

Concerned: ( > 0? / + Mass conservation But away from equilibrium, could ( > 0? Also, not everything is linear near equilibrium + = ( -.

Popular Methods Trapezoidal (Implicit)! "#$ %! " &' = ) * [, -./) +, -. ] 2 3 = )/$ 4 5 Adams-Bashforth (multistep, explicit)! "#$ %! " &' = 6 *, -. ) *,(-.%)) Runge-Kutta (commonly RK4, explicit) Multistep, but - :';<= depends on, - :';<=%) Reduces to Simpson s rule if, -,? not a function of - )% $ 4 5

Linear Stability A-stable If! " < 1 includes all negative real numbers L-stable If, additionally! " 0 '( " B-stability Stability for Runge-Kutta methods No explicit method is linearly A-stable

Choose Trapezoidal (Implicit)! "#$ %! " &' = ) * [, -./) +, -. ] 2 3 = )/$ 4 5 Adams-Bashforth (multistep, explicit)! "#$ %! " &' = 6 *, -. ) *,(-.%)) Runge-Kutta (commonly RK4, explicit) Multistep, but - :';<= depends on, - :';<=%) Reduces to Simpson s rule if, -,? not a function of - )% $ 4 5

Requirements Consistency Resolution->0 Number of reactions and species Order of Approximation Conservation laws (mass, stoichiometry) Stability! " < 1! " 0 Engineering Constraints dt > 0 Positive Definite Time splitting Exothermic reactions Flame fronts Computational time (number of matrix solves and f evals) Computation of f jacobian solves, sparse solves. Complexity of method (implication for adjoint) Robust When things fail Subdividing the time step Context Software/hardware (threading / tasks / compilers) Fundamental kinetics vs simulation of weather/climate Result is good enough testing?

Accuracy (consistency) Adams-Bashforth! "#$ %! " &' = ( ) * +,. ) *(+,%.) Taylor expand and get errors relative to + 1 = * + Error < 4(&')5 max( * 111 ).) Local order 3, global order 2 Consistent, not A-stable Order has to have local order larger than 1 to be consistent Error terms can drive subdivision of time step (Rosenbrock method) Convergence = Stabile + Consistent So what? (dt > 0)

Conservation Stoichiometry implies atoms are conserved. "# $ "# + "# ( Photolytic Decomposition "# + "# "# $ 1 Recombination 2 "# $ + "# = Constant As many 0 eigenvalues as atoms perhaps. Numerical conservation?

Other consistency-like considerations Do we have all the relevant reactions to support study? chemical resolution/consistency Horizontal resolution: Nonlinear <v 1 > <v 2 >?=? <v 1 v 2 >

MPAS Biogenic Emissions, chemistry, CONUS refinement CESM-SE Rebecca Schwantes, Forrest Lacey, In Development

Requirements Consistency Resolution->0 Number of reactions and species Order of Approximation Conservation laws (mass, stoichiometry) Stability! " < 1 Engineering Constraints Positive Definite Time splitting Exothermic reactions Flame fronts Computational time (number of matrix solves and f evals) Computation of f jacobian solves, sparse solves. Complexity of method (implication for adjoint) Robust When things fail Subdividing the time step Context Software/hardware (threading / tasks / compilers) Fundamental kinetics vs simulation of weather/climate Result is good enough testing?

Trust the solver? Global simulation: 1 degree horizontal resolution, 100 yrs, dt = 15mins, 30 levels => 3,079,296,000,000 solves of an ODE of order(nspecies) When it fails, it does something reasonable that can be handled. Stable, accurate Sufficient to capture the relevant behavior

Implicit Method Example (Trapezoidal)! "#$ %! " &' = ) * [, -./) +, -. ] Algebraic solve for -./) g -./) = 0 Often use Newton method (or peudo-newton Iterations) g 4 = 0 4./) = 4. 6 7 " 6 8 7 " 9 (4. ) is the Jacobian. expensive, Sparse solve, yet more methods Computing 9 = 4. is ~2.5 times as expensive as forcing Factoring/solving Jacobian is very expensive many optimizations Some methods compute these iterates approximately Sometimes Newton iterates diverge

Considerations Solar Terminator Very rapid transients Time-varying rate constants Rosenbrock fails if solar terminus crosses cell during time step Sun can rise inside the chem-solve time step (during dt) Simply use j-values at one end or other of time step Conservation. (CL + 2*CL_2) Positive definite vmr > 0 Convergence constraints scale = max(c, vmr) Y_scale = Y / scale

Contexts Size of Mechanism (2 reactants -> 1e6 reactants) Size of domain (box, 3d global, LES; number of time steps) Efficiency, robustness Need for adjoint Types of dependency on environmental conditions (T, P, SAD, aqueous phase storage) Cost (wallclock vs charges for solution vs energy consumed) Do rate constants vary inside chemistry time step? Exothermic? Might need Jacobian w.r.t. temperature Can you construct a Jacobian? if not, difficult to make stable. Numerical Jacobian or projection controls. Accuracy vs speed of computation Operator splitting (photolysis and kinetics, vs constant photolysis) Software Engineering (thread-safe, thread-aware, multi-tasking, data size and typing, languages/compilers/frameworks) Complexity of representation vs generality of solution method (e.g., Linear Solver) Hardware architecture (vectorization, GPU s, Nspecies/cache size) Optimizations (Hard-coded LU factorization and solves) Restarts due to accuracy constraints (accuracy estimates on solution; solar changes during time step) Absolute and relative tolerances on errors in solution of ODE for each species

NCAR model usage CESM Implicit, except for slowly varying chemicals If Newton iteration fails, subdivide the time step Sparse linear algebra is sophisticated WRF Rosenbrock higher order, a bit more fussy Implicit, similar to Runge-Kutta, with a few other corrections Error estimates lead to subdivisions of the time step Sparse linear algebra is sophisticated GECKO So many chemicals that explicit representation of forcing uses indirect addressing No Jacobian, estimate of unstable directions

Choose among these Fast Computation Fast Development Cycle Robust Extensible code Easy-to-read code Inexpensive to develop

Research Continuous between Implicit and Explicit exposes reasons behind instability! " #$! " 0 = #$ 1 ) *! " 0 + ) *! " #$ GPU s Shove everything into the Chemistry solver Emissions Deposition Microphysics Solve for both concentration and variability of concentration Chemistry solvers in models Unique requirements speed and robustness Use cases (number of solves, consistency of Jacobian form during solve) Non-symmetric Sparse Jacobian Computational cost vs Energy cost Cost relative to other processes (e.g., transport) Test Suites?

In Application Community Familiarity with tools (KPP, mozartpp, fortran, run scripts, software) Tested in many experiments (Trust) Speed/cost Embedding model probably has something implemented Documentation (user, traceability) Access to baseline chemistry mechanisms

Requirements Consistency (Order > 2) Resolution->0 Number of reactions and species Order of Approximation Conservation laws (mass, stoichiometry) Stability! " < 1 Engineering Constraints Time splitting Exothermic reactions Flame fronts Computational time Computation of f jacobian solves, sparse solves. Complexity of method (implication for adjoint) Robust When things fail Subdividing the time step Context Software/hardware (threading / tasks / compilers) Fundamental kinetics vs simulation of weather/climate Result is good enough testing?

Thank you

Resources Stoer, Bulirsch; Introduction to Numerical Analysis Press et. al.; Numerical Recipies Wilkinson; The Algebraic Eigenvalue Problem Golub, VanLoan; Matrix Computations Packages FATODE VSODE KPP