ATM 562: Numerical Methods and Modeling
Total Page:16
File Type:pdf, Size:1020Kb
ATM 562: Numerical methods and modeling Robert G. Fovell Department of Atmospheric and Environmental Sciences University at Albany, State University of New York [email protected] July 28, 2021 \All models are false, but some are useful." { George E. P. Box 1 Copyright 2000-2018, by Robert G. Fovell. 2 Preface These notes support a course in numerical methods and modeling. The course involves both theory and hands-on practice, the latter leading to a two-dimensional (or better) \cloud model" capable of simulating some interesting phenomena. It was developed as a 10-week course offered to undergraduate seniors at UCLA, in part from a need to provide scientific programming experience, and also to provide opportunities and inspiration for individual research projects, and included six (now seven) \Model Tasks" that lead to a working model. The model you will create based on this guidance is not new, and nowhere near the state of the art with respect to design, formulation, or model physics, but will be new to you, and it will be enabling, and that's what matters. Please feel free to contact me with suggestions and corrections. 3 Contents I Model theory and design 12 1 Introduction and basic tools 13 1.1 Taylor series . 13 1.1.1 Infinite and truncated series . 13 1.1.2 The Mean Value Theorem and definition of the derivative . 14 1.1.3 The basis of forecasting . 14 1.1.4 Multivariate Taylor expansions . 15 1.2 Eulerian and Lagrangian viewpoints . 15 1.3 Ideal gas law and virtual temperature . 16 1.4 The hydrostatic equation . 17 1.5 Potential temperature and nondimensional pressure . 18 1.6 The continuity equation . 18 2 Model equations and waves 21 2.1 Basic equations . 21 2.2 Perturbation method . 22 2.3 Acoustic (sound) waves . 22 2.4 Gravity waves (buoyancy oscillations) . 26 2.4.1 The buoyancy term . 27 4 2.4.2 The gravity wave phase speed . 30 2.4.3 Sound and gravity waves, combined . 31 3 Derivation of the fully compressible model framework 33 3.1 The pressure gradient acceleration terms . 34 3.2 Perturbation analysis applied to the pressure accelerations . 34 3.3 Advantage of π over p .............................. 35 3.4 Converting the continuity equation into a pressure tendency equation . 38 3.4.1 Derivation . 38 3.4.2 Interpretation . 40 3.5 The fully compressible model equations . 41 4 Numerical solution of partial differential equations, Part I: The basics and the upstream scheme 42 4.1 Introduction . 42 4.2 Consistency . 44 4.3 Stability . 46 4.3.1 The analytic solution . 46 4.3.2 The finite difference scheme . 49 5 Numerical solution of partial differential equations, Part II: The leapfrog scheme 54 5.1 Consistency and stability of the second-order leapfrog scheme . 56 5.2 Physical and computational modes, and dealing with \time-splitting" . 59 5.2.1 Behavior of the computational mode . 60 5.2.2 Initialization of the computational mode . 61 5.2.3 Mitigation of the computational mode . 64 5 5.3 Phase error . 65 5.4 The 2D leapfrog scheme . 66 6 Dynamical frameworks 69 6.1 Time-splitting . 70 6.2 Quasi-compressibility . 73 6.3 The anelastic approximation . 73 6.3.1 The anelastic pressure equation . 75 6.3.2 Simplification and interpretation . 76 6.3.3 Decomposition of the anelastic pressure perturbation field . 78 6.3.4 Derivation of the anelastic pressure decomposition . 78 7 Nonlinear computational instability 81 7.1 Origin of the instability . 81 7.2 Controlling nonlinear instability through smoothing . 85 8 Moisture and microphysics 88 8.1 Cloud and rain water . 88 8.1.1 The Marshall-Palmer distribution . 90 8.1.2 Terminal velocity . 92 8.1.3 Accretion of cloud droplets by rain water . 95 8.1.4 Evaporation of rainwater . 96 8.1.5 Reflectivity . 98 8.2 The equations with moisture and diffusion added . 102 8.2.1 Some comments on the above equations . 103 8.2.2 Rewriting the buoyancy term . 104 8.2.3 The latent heating term in the θ0 equation . 105 6 II Model Tasks 109 9 Model Task #0: Solving the 1D wave equation 110 9.1 The upstream or upwind scheme . 110 9.1.1 The scheme . 110 9.1.2 Implementation . 111 9.1.3 Test problem . 112 9.1.4 Errors . 113 9.1.5 Upstream scheme experiments (Model Task #0A) . 114 9.2 The leapfrog and RK3 schemes . 115 9.2.1 The leapfrog scheme . 115 9.2.2 Discussion . 117 9.2.3 An RK3 scheme . 118 9.2.4 Leapfrog and RK3 scheme experiments (Model Task #0B) . 120 10 Model Task #1: Setting up the base state 121 10.1 Vertical grid arrangement . 121 10.2 Base state temperature and moisture . 122 10.3 Derived quantities . 125 10.4 Results for some fields . 128 11 Model Task #2: Assessing convective instability 130 11.1 Lifting and adjusting a parcel on the model grid . 130 11.2 Computing CAPE and CIN on the model grid . 133 11.3 What is CAPE missing? . 135 11.4 Results . 137 7 12 Model Task #3: Grid setup, initial condition and visualization 140 12.1 Grid setup . 140 12.2 Initial condition . 144 12.3 Visualization with GrADS . 147 13 Model Task #4: Implementing the leapfrog scheme 161 13.1 2D linear advection . 161 13.2 Results of example integration . 167 13.3 Specification of the exact solution . 168 13.4 Animations using GrADS . 170 14 Model Task #5: Discretizing the model equations 175 14.1 Equations and flux form . 175 14.2 Discretization . 177 14.2.1 The u equation . 177 14.2.2 The w equation . 181 14.2.3 The θ0 equation (in flux form) . 181 14.2.4 The π0 equation . 182 14.3 Boundary conditions . 182 14.4 A sample integration . 183 15 Model Task #6: Next steps 190 15.1 Final project . 190 15.2 Open lateral boundary conditions . 191 15.2.1 Theoretical basis . 191 15.2.2 Implementation . 193 15.3 Solving the anelastic pressure equation . 194 8 15.3.1 Subroutine BLKTRI ............................ 194 15.3.2 An example application . 200 15.4 Adding a mean horizontal wind or shear . 201 15.5 Diffusion and time smoothing . 203 15.6 Adding a heat source . 204 15.7 Adding a momentum source . 206 15.8 Add a surface heat flux to the lower boundary . 207 15.9 Add a near-surface heat sink to the model . 208 15.10Implementing surface drag (friction) . 209 15.11Adding moisture and microphysics to the model . 209 III Adjoint models 216 16 Theory and construction 217 16.1 The Tangent Linear Model - Introduction . 219 16.2 Construction of the TLM . 220 16.2.1 TLM formulation of a differential equation . 220 16.2.2 A simple example . ..