Efficient Approximation of the Incomplete Gamma Function for Use
Total Page:16
File Type:pdf, Size:1020Kb
Geosci. Model Dev., 3, 329–336, 2010 www.geosci-model-dev.net/3/329/2010/ Geoscientific doi:10.5194/gmd-3-329-2010 Model Development © Author(s) 2010. CC Attribution 3.0 License. Efficient approximation of the incomplete gamma function for use in cloud model applications U. Blahak Institute for Meteorology and Climate Research, Karlsruhe Institute of Technololgy (KIT), Karlsruhe, Germany present address: German Weather Service (DWD), Offenbach, Germany Received: 29 March 2010 – Published in Geosci. Model Dev. Discuss.: 16 April 2010 Revised: 12 July 2010 – Accepted: 13 July 2010 – Published: 23 July 2010 Abstract. This paper describes an approximation to the 1 Introduction lower incomplete gamma function γl(a,x) which has been obtained by nonlinear curve fitting. It comprises a fixed num- In cloud physics (and also in radar meteorology), it is com- ber of terms and yields moderate accuracy (the absolute ap- mon practice to use so-called gamma-distributions or gener- proximation error of the corresponding normalized incom- alized gamma distributions (Deirmendjian, 1975) to describe plete gamma function P is smaller than 0.02 in the range particle size distributions (PSD) of hydrometeors, either to 0.9 ≤ a ≤ 45 and x ≥ 0). Monotonicity and asymptotic be- fit observed distributions (Willis, 1984; Chandrasekar and haviour of the original incomplete gamma function is pre- Bringi, 1987) or to base parametrizations of cloud micro- served. physical processes on it (e.g., Milbrandt and Yau, 2005b; While providing a slight to moderate performance gain on Seifert and Beheng, 2006 and many others). As will be out- scalar machines (depending on whether a stays the same for lined below, this ansatz may lead to the necessity of com- subsequent function evaluations or not) compared to estab- puting ordinary and incomplete gamma functions. Particu- lished and more accurate methods based on series- or con- larly the incomplete gamma function poses certain practical tinued fraction expansions with a variable number of terms, computation problems in the context of cloud microphysi- a big advantage over these more accurate methods is the ap- cal parametrizations used on supercomputers, which up to plicability on vector CPUs. Here the fixed number of terms now hinders developers to apply parametrization equations enables proper and efficient vectorization. The fixed number involving this function. These problems can be alleviated by of terms might be also beneficial on massively parallel ma- using a new approximation of this function that is introduced chines to avoid load imbalances, caused by a possibly vastly in Sect. 2 of this paper, which might ultimately lead to im- different number of terms in series expansions to reach con- provements in cloud microphysical parameterizations. vergence at different grid points. For many cloud microphys- With regard to cloud- and precipitation particles, let y rep- ical applications, the provided moderate accuracy should be resent either the sphere volume equivalent diameter D or the enough. However, on scalar machines and if a is the same for particle mass m. Then, the distribution function f (r,t;y) subsequent function evaluations, the most efficient method describes the number of particles per volume at a specific to evaluate incomplete gamma functions is perhaps interpo- location r at time t having mass/diameter in the interval lation of pre-computed regular lookup tables (most simple [y,y + dy]. Dropping the r- and t-dependence for simpli- example: equidistant tables). city, f (y) is said to be distributed according to a generalized gamma-distribution if it obeys µ ν f (y) = N0 y exp −λy (1) with the four parameters N0, µ, ν and λ. If ν = 1, Eq. (1) reduces to “the” gamma-distribution. Note that if the widely used assumption m ∼ Db with Correspondence to: U. Blahak b > 0 (e.g., Locatelli and Hobbs, 1974, and many others ([email protected]) thereafter) holds (most simple case: water spheres with Published by Copernicus Publications on behalf of the European Geosciences Union. 330 U. Blahak: Efficient approximation of the incomplete gamma function m ∼ D3), the generalized gamma distribution is invariant un- high content of supercooled liquid water drops (high riming der the transformation between the diameter- and the mass- rate), then particles larger than a certain size/mass mwg can- representation; only the values of the parameters are differ- not entirely freeze the collected supercooled water, because ent. the latent heat of fusion cannot be transported away from the The parameters for Eq. (1) are not necessarily independent particles fast enough (e.g., Young, 1993). The non-frozen in natural precipitation. For example, in case of rain drops water might get incorporated into the porous ice skeleton of there has been observed some degree of correlation (Testud the graupel and might refreeze later, leading to an increase et al., 2001; Illingworth and Blackman, 2002). in bulk density (“hail”). Following Ziegler (1985), the cor- Often, cloud microphysics parametrizations require the responding loss of Lg (graupel) to Lh (hail) might be simply computation of (or are – in case of “bulk” parametrizations parameterized by – based entirely on) moments of the PSD functions, leading, in case of infinite moments, to the ordinary gamma function, Z ∞ ∂Lg ∂Lh 1 which is defined as = − = − mg f (mg)dmg ∂t ∂t 1t m ∞ wetgr wetgr wg Z µ +2 ν −t a−1 g g 0(a) = e t dt with a > 0 . (2) N0,gγu ν ,λgmwg = − g µ +2 (5) 0 g νg νg λg 1t For example, the mass content L, which is of primary im- portance, is the first moment of the distribution with respect to the mass representation. Generally the moments M(i) are where the index g denotes graupel and 1t the numerical defined as time step. On the right-hand side, now the upper incom- = − Z ∞ plete gamma function γu(a,x) 0(a) γl(a,x) appears. Va- (i) i M = y f (y)dy lues of mwg are usually in a range equivalent to a diameter 0 & 1 mm, µg is typically between −0.5 and 1, and νg ≈ 1/3. i+µ+ ∞ 1 Both N0,g and λg are > 0 but quite variable, so that the corre- Z ν N0 0 ν = i+µ −λy = sponding value of x in Eq. (4) might take on arbitrary values N0 y e dy i+µ+1 , (3) 0 ν λ ν > 0. hence the name “generalized gamma-distribution” for f (y). Equation (5) is a simple but instructive example of a bulk Such infinite moments, also with non-integer i, enter state- cloud microphysical process parameterization, that com- of-the-art bulk (moment) cloud microphysical parametriza- prises three typical features regarding the parameters a and tions in many ways, e.g., in the computation of collision x of the incomplete gamma function in cloud physics. First, rates, deposition/evaporation rates and so on, which is ex- the parameter a depends on the shape parameters µ and ν tensively described in textbooks (e.g., Pruppacher and Klett, of the assumed distribution Eq. (1) and not on N0 and λ. 1997) or in the relevant literature (e.g., Lin et al., 1983; Now, in most of the established one- or two-moment bulk Seifert and Beheng, 2006; to name just a few). schemes, µ and ν are fixed parameters which do not change However, many cloud microphysical processes involve during a particular model simulation, so that a also remains some sort of spectral cut off, for example, collision processes fixed (only recently, authors start to make at least µ vari- like autoconversion or some 2- and 3-species collisions be- able in a diagnostic way for some of the processes, e.g., tween solid and/or liquid particles. If, in bulk models, one Milbrandt and Yau, 2005a; Seifert, 2008). Second, the in- wishes to parametrize such processes, e.g., the conversion tegration limit respectively size- or mass threshold m of the of particles above a certain size/mass threshold to another process parameterization (mwg in the above Eq. (5) translates species by a certain process (e.g., “wet growth”; collisions of into the x-parameter λmν of the incomplete gamma function. ice particles with drops where the “outcome” depends on cer- That means, even if m is a fixed parameter, x is not fixed be- tain size ranges of the ice particles and the drops as proposed cause λ is variable. Therefore, in cloud physics either a is by Farley et al., 1989), this would require the computation of fixed and x varies during a model simulation (which will be incomplete gamma functions. The lower incomplete gamma of importance later) or both a and x vary; the case of a vari- function is defined as able a and fixed x has not yet occured in literature to the best x knowlegde of the author. Third, a attains non-integer values Z −t a−1 in most cases, depending on the choice of µ and ν. As it γl(a,x) = e t dt with a > 0 . (4) is outlined later, an integer value of a leads to an analytic 0 expression for the incomplete gamma function, which facili- For example, consider the transformation of intermediate- tates its computation. Unfortunately, there is only a chance density graupel particles to high-density hail particles in con- to get integer values of a if one assumes exponential particle ditions of wet growth, which is important for hail forma- size- or mass-distributions, which is a serious and perhaps in tion. That is, if graupel particles are in an environment of many cases unphysical restriction. Geosci. Model Dev., 3, 329–336, 2010 www.geosci-model-dev.net/3/329/2010/ U.