PHYEX 0.9.5
PHYsique EXternalisée
Loading...
Searching...
No Matches
beta_surface.py
Go to the documentation of this file.
1"""
2Simple bulk surface scheme with an evaporation efficiency (beta), following the simple surface
3of LMDZ (LMDZ6, libf/phylmd: calbeta_mod.f90, calcul_fluxs_mod.f90, cdrag_mod.f90):
4 - E = beta * rho * Ch * U * (qsat(Ts, Ps) - q1)
5 - H = rho * Ch * U * (cp * (Ts - T1) - g * z1)
6 - u* = sqrt(Cd) * U
7with U = min_wind + |V| (LMDZ min_wind_speed, gustiness not taken into account), the neutral
8coefficients (kappa / ln(1 + z1/z0))**2 (z0h for heat) and, optionally, the Louis (1982)
9stability functions of the bulk Richardson number (default choice of LMDZ cdrag,
10iflag_corr_sta=iflag_corr_insta=2). Over ocean, z0 can be computed with the Charnock formula
11(as in LMDZ cdrag).
12
13The module also provides a friction velocity with a Monin-Obukhov stability correction computed
14from the surface fluxes (as in SURFEX, COUPLING_IDEAL_FLUX and MODE_SBLS), used when the wind
15forcing is given through a roughness length.
16"""
17
18import math
19
20from . import Cst
21from .wasp import QSAT
22
23# Louis (1982) coefficients (LMDZ cdrag)
24CB, CC, CD = 5., 5., 5.
25F_RI_CD_MIN = 0.1 # minimum value of the stability functions (LMDZ f_ri_cd_min)
26CEPDU2 = 0.1**2 # minimum squared wind speed in the Richardson number (m2 s-2)
27MIN_WIND_SPEED = 1. # added to the wind speed in the fluxes (LMDZ min_wind_speed, m s-1)
28# Charnock formula (LMDZ cdrag): z0 = 0.018 u*^2 / g + 0.11 * nu / u*
29CHARNOCK, NU_AIR = 0.018, 14.E-6
30
31
32def bulk_richardson(z1, t1, q1, ts, qs, speed):
33 """
34 Bulk Richardson number (LMDZ cdrag)
35 :param z1: height of the first atmospheric level (m)
36 :param t1, q1: temperature (K) and specific humidity (kg/kg) at the first level
37 :param ts, qs: surface temperature (K) and specific humidity (kg/kg)
38 :param speed: wind speed at the first level (m/s)
39 """
40 cst = Cst()
41 retv = cst.Rv / cst.Rd - 1.
42 rvtmp2 = cst.Cpv / cst.Cpd - 1.
43 zdu2 = max(CEPDU2, speed**2)
44 tsolv = ts * (1. + retv * max(qs, 0.))
45 tvd = (t1 + cst.g * z1 / cst.Cpd / (1. + rvtmp2 * q1)) * (1. + retv * max(q1, 0.))
46 return cst.g * z1 * (tvd - tsolv) / (zdu2 * tvd)
47
48
49def drag_coefficients(z1, z0, z0h, ri, stability):
50 """
51 Drag coefficients for momentum and heat (LMDZ cdrag)
52 :param z1: height of the first atmospheric level (m)
53 :param z0, z0h: roughness lengths for momentum and heat (m)
54 :param ri: bulk Richardson number
55 :param stability: True to apply the Louis (1982) stability functions
56 :return: (Cd, Ch)
57 """
58 cst = Cst()
59 zzzcd = cst.Karman / math.log(1. + z1 / z0)
60 cdn = zzzcd**2
61 chn = zzzcd * cst.Karman / math.log(1. + z1 / z0h)
62 if not stability:
63 return cdn, chn
64 if ri < 0.:
65 zucf = 1. / (1. + 3. * CB * CC * cdn * math.sqrt(abs(ri) * (1. + z1 / z0)))
66 fm = max(1. - 2. * CB * ri * zucf, F_RI_CD_MIN)
67 fh = max(1. - 3. * CB * ri * zucf, F_RI_CD_MIN)
68 else:
69 ri = min(20., ri)
70 zscf = math.sqrt(1. + CD * abs(ri))
71 fm = max(1. / (1. + 2. * CB * ri / zscf), F_RI_CD_MIN)
72 fh = max(1. / (1. + 3. * CB * ri * zscf), F_RI_CD_MIN)
73 return cdn * fm, chn * fh
74
75
76def charnock_z0(ustar):
77 """
78 Roughness length over ocean (Charnock formula with a smooth flow term, LMDZ cdrag)
79 :param ustar: friction velocity (m/s)
80 """
81 cst = Cst()
82 ustar = max(ustar, 1.E-3)
83 return CHARNOCK * ustar**2 / cst.g + 0.11 * NU_AIR / ustar
84
85
86def beta_fluxes(t1, q1, rho, u, v, z1, ts, ps, beta, z0, z0h, stability):
87 """
88 Surface fluxes of the beta scheme
89 :param t1, q1: temperature (K) and specific humidity (kg/kg) at the first level
90 :param rho: air density at the first level (kg/m3)
91 :param u, v: wind components at the first level (m/s)
92 :param z1: height of the first atmospheric level above the surface (m)
93 :param ts: surface temperature (K)
94 :param ps: surface pressure (Pa)
95 :param beta: evaporation efficiency (0-1)
96 :param z0: roughness length for momentum (m) or 'CHARNOCK'
97 :param z0h: roughness length for heat (m), None to use z0
98 :param stability: True to apply the stability functions
99 :return: (sensible heat flux (W/m2), water vapour flux (kg/m2/s), friction velocity (m/s))
100 """
101 cst = Cst()
102 qsat = QSAT(ts, ps, 'NEW')
103 qs = beta * qsat + (1. - beta) * q1 # surface specific humidity
104 speed = math.sqrt(u**2 + v**2)
105 wind = MIN_WIND_SPEED + speed
106 ri = bulk_richardson(z1, t1, q1, ts, qs, speed)
107 if isinstance(z0, str): # Charnock (z0 and drag coefficient are interdependent)
108 z0_value = 1.E-4
109 for _ in range(5):
110 cdm, _ = drag_coefficients(z1, z0_value, z0h or z0_value, ri, stability)
111 z0_value = charnock_z0(math.sqrt(cdm) * wind)
112 else:
113 z0_value = z0
114 cdm, cdh = drag_coefficients(z1, z0_value, z0h or z0_value, ri, stability)
115 sshf = rho * cdh * wind * (cst.Cpd * (ts - t1) - cst.g * z1)
116 swf = beta * rho * cdh * wind * (qsat - q1)
117 return sshf, swf, math.sqrt(cdm) * wind
118
119
120def paulson_psim(z_o_lmo):
121 """Paulson stability function for momentum (SURFEX MODE_SBLS)"""
122 if z_o_lmo < 0.:
123 x = (1. - 15. * z_o_lmo)**0.25
124 return math.log((1. + x**2) * (1. + x)**2 / 8.) - 2. * math.atan(x) + math.pi / 2.
125 return -4.7 * z_o_lmo
126
127
128def mo_ustar(wind, z, z0, sfth, sfrv, theta, rv):
129 """
130 Friction velocity with a Monin-Obukhov stability correction computed from the surface
131 fluxes (SURFEX COUPLING_IDEAL_FLUX, MODE_SBLS: USTAR and LMO functions)
132 :param wind: wind speed at the first level (m/s)
133 :param z: height of the first level (m)
134 :param z0: roughness length (m)
135 :param sfth: kinematic surface flux of potential temperature (K m/s)
136 :param sfrv: kinematic surface flux of water vapour mixing ratio (kg/kg m/s)
137 :param theta, rv: potential temperature (K) and mixing ratio (kg/kg) at the first level
138 """
139 cst = Cst()
140
141 def ustar_func(lmo):
142 if lmo is None:
143 return wind * cst.Karman / math.log(z / z0)
144 return wind * cst.Karman / (math.log(z / z0) - paulson_psim(z / lmo) +
145 paulson_psim(z0 / lmo))
146
147 def lmo_func(ustar):
148 eps = (cst.Rv - cst.Rd) / cst.Rd
149 thetav = theta * (1. + eps * rv)
150 q0 = sfth + thetav * eps * sfrv
151 if q0 == 0.:
152 return None
153 lmo = - max(ustar, 1.E-6)**3 / (cst.Karman * cst.g / thetav * q0)
154 return None if abs(lmo) > 10000. else lmo
155
156 ustar = ustar_func(None)
157 if sfth != 0. or sfrv != 0.:
158 ustar = max(ustar, 0.01)
159 for _ in range(10):
160 ustar = ustar_func(lmo_func(ustar))
161 return ustar
mo_ustar(wind, z, z0, sfth, sfrv, theta, rv)
beta_fluxes(t1, q1, rho, u, v, z1, ts, ps, beta, z0, z0h, stability)
drag_coefficients(z1, z0, z0h, ri, stability)
bulk_richardson(z1, t1, q1, ts, qs, speed)