ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_ForceRestoreSnow.H
Go to the documentation of this file.
1 #ifndef ERF_FORCE_RESTORE_SNOW_H_
2 #define ERF_FORCE_RESTORE_SNOW_H_
3 
4 #include <limits>
5 
6 #include <AMReX_Algorithm.H>
7 #include <AMReX_GpuQualifiers.H>
8 #include <AMReX_Math.H>
9 #include <AMReX_REAL.H>
10 
11 #include <ERF_MicrophysicsConstants.H> // lat_ice, the latent heat of fusion
12 #include <ERF_NumericalConstants.H> // zero
13 
14 /**
15  * @file ERF_ForceRestoreSnow.H
16  * @brief One bulk snow layer on the two-stream force-restore surface
17  * (erf.radiation.seb_snow_enable): the snow routine of the ISBA scheme as Douville,
18  * Royer and Mahfouf (1995, "DRM95") describe it in their Sec. 2.1, for bare ground
19  * (vegetation fraction 0).
20  *
21  * The state is the snow water equivalent W_n [kg/m^2] (1 kg/m^2 of water is 1 mm).
22  *
23  * - Mass (DRM95 Eq. 6):
24  * dW_n/dt = P_n - E_n - F_n,
25  * with P_n the frozen precipitation, E_n the sublimation and F_n the melt.
26  * - Cover fraction (DRM95 Eq. 7):
27  * p_ng = W_n / (W_n + W_crn), W_crn = 10 kg/m^2 (erf.radiation.seb_snow_critical_swe_kg_m2).
28  * - Albedo (DRM95 Eq. 8 with veg = 0):
29  * alpha_t = (1 - p_ng) alpha_g + p_ng alpha_n,
30  * alpha_n = 0.70 (erf.radiation.seb_snow_albedo), "the uniform and constant value of the
31  * snow albedo".
32  * - Sublimation. DRM95 states that p_ng partitions the surface evaporation between the soil
33  * and the snow, without an equation. Here E_n = p_ng E for an upward E = LE / L_v, at most
34  * the snow there is; the soil keeps the rest. A downward flux (dew, frost) stays with the
35  * soil, as in the balance without snow. The latent heat flux itself is not changed: it
36  * uses L_v over the snow too.
37  * - Melt (DRM95 Eq. 12). The balance gives a first estimate T_s* of the surface temperature.
38  * Where snow lies and T_s* > T_00 = 273.16 K,
39  * F_n dt = (T_s* - T_00) / (C_t L_f),
40  * at most the snow there is. C_t [K m^2/J] is the inverse of the surface heat capacity
41  * C_s [J/m^2/K] (erf.radiation.seb_surface_heat_capacity). The melt takes L_f F_n dt from
42  * the surface, so T_s = T_s* - L_f F_n dt / C_s: T_00 while snow remains ("the surface
43  * temperature can only exceed the melting point when all the snow has melted on the
44  * ground", DRM95 Sec. 2.1).
45  * - Melt water and the sublimated water the balance took from the soil go to the soil with
46  * the rain (ERF_ForceRestoreHydrology.H).
47  *
48  * The update is forward Euler, in the order snowfall, sublimation, melt, and satisfies
49  * to round-off W_n_new - W_n_old = snowfall - sublimation - melt.
50  *
51  * Not here (DRM95 Sec. 2.2, their new scheme): prognostic snow density and albedo, the snow
52  * heat capacity, the vegetation masking, and the snow roughness length (DRM95 Eqs. 9-10).
53  *
54  * Reference:
55  * - Douville, H., J.-F. Royer, and J.-F. Mahfouf, 1995: A new snow parameterization for the
56  * Meteo-France climate model. Part I: validation in stand-alone experiments. Climate
57  * Dynamics, 12, 21-35.
58  */
59 
60 /// The melting point T_00 [K] of DRM95 Eq. (12).
61 constexpr amrex::Real force_restore_snow_t_melt = amrex::Real(273.16);
62 
63 /**
64  * @brief Parameters of one snow step (from erf.radiation.seb_*).
65  */
67 {
68  amrex::Real w_crn = amrex::Real(10.0); ///< Critical snow water equivalent W_crn [kg/m^2] (seb_snow_critical_swe_kg_m2)
69  amrex::Real albedo = amrex::Real(0.70); ///< Snow albedo alpha_n [-] (seb_snow_albedo)
70  amrex::Real c_s = amrex::Real(2.0e4); ///< Surface heat capacity C_s = 1 / C_t [J/m^2/K] (seb_surface_heat_capacity)
71  /// Upper bound of T_s after the melt [K] (seb_prognostic_t_max_k); no bound by default
72  amrex::Real t_max = std::numeric_limits<amrex::Real>::max();
73 };
74 
75 /**
76  * @brief What one snow step moved in one column [kg/m^2].
77  */
79 {
80  amrex::Real snowfall = amrex::Real(0.0); ///< Frozen precipitation taken in
81  amrex::Real sublimation = amrex::Real(0.0); ///< Snow sublimated
82  amrex::Real melt = amrex::Real(0.0); ///< Snow melted
83 };
84 
85 /**
86  * @brief Snow cover fraction p_ng of the ground, DRM95 Eq. (7).
87  *
88  * @param[in] w_n snow water equivalent [kg/m^2]
89  * @param[in] w_crn critical snow water equivalent [kg/m^2], > 0
90  * @return W_n / (W_n + W_crn) in [0, 1); zero for no snow or a non-finite W_n.
91  */
92 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
93 amrex::Real force_restore_snow_fraction (amrex::Real w_n, amrex::Real w_crn) noexcept
94 {
95  if (!(w_n > amrex::Real(0.0)) || !amrex::Math::isfinite(w_n)) { return amrex::Real(0.0); }
96  return w_n / (w_n + w_crn);
97 }
98 
99 /**
100  * @brief Surface albedo with snow, DRM95 Eq. (8) with veg = 0.
101  *
102  * @param[in] alb_ground snow-free albedo alpha_g [-]
103  * @param[in] w_n snow water equivalent [kg/m^2]
104  * @param[in] prm parameters
105  * @return (1 - p_ng) alpha_g + p_ng alpha_n
106  */
107 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
108 amrex::Real force_restore_snow_albedo (amrex::Real alb_ground, amrex::Real w_n,
109  const ForceRestoreSnowParams& prm) noexcept
110 {
111  const amrex::Real p_ng = force_restore_snow_fraction(w_n, prm.w_crn);
112  return (amrex::Real(1.0) - p_ng) * alb_ground + p_ng * prm.albedo;
113 }
114 
115 /**
116  * @brief One step of the snow layer of one column, after the balance has updated T_s.
117  *
118  * @param[in,out] w_n snow water equivalent [kg/m^2]
119  * @param[in,out] t_s surface temperature [K]: the balance's estimate in, the value after
120  * the melt out, at most prm.t_max. The estimate of a snow-covered column
121  * comes in without that bound, so the heat above it melts snow first.
122  * @param[in] p_n frozen precipitation [kg/m^2/s]
123  * @param[in] e evaporation LE / L_v [kg/m^2/s], positive upward
124  * @param[in] dt the step [s]
125  * @param[in] prm parameters
126  * @return the snow taken in, sublimated and melted
127  */
128 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
130 force_restore_snow_step (amrex::Real& w_n, amrex::Real& t_s, amrex::Real p_n, amrex::Real e,
131  amrex::Real dt, const ForceRestoreSnowParams& prm) noexcept
132 {
134  if (!(p_n > zero) || !amrex::Math::isfinite(p_n)) { p_n = zero; }
135  if (!(e > zero) || !amrex::Math::isfinite(e)) { e = zero; }
136 
137  // The cover fraction of the snow at the start of the step: DRM95 Eq. (7).
138  const amrex::Real p_ng = force_restore_snow_fraction(w_n, prm.w_crn);
139 
140  // Each term below reports what W_n actually changed by, not the amount asked for: in
141  // single precision an increment below the resolution of a deep pack leaves W_n as it
142  // was, and the soil must then not be handed water the snow did not lose.
143 
144  // Snowfall: DRM95 Eq. (6), first term.
145  amrex::Real w_new = w_n + p_n * dt;
146  out.snowfall = w_new - w_n;
147  w_n = w_new;
148 
149  // Sublimation from the covered fraction: DRM95 Eq. (6), second term. A negative W_n (a
150  // corrupt state, which the caller refuses after the step) gives none.
151  // amrex::max takes references: a namespace-scope constant passed to it is odr-used, which
152  // CUDA refuses in device code, so the constants are passed as temporaries here and below.
153  w_new = w_n - amrex::min(p_ng * e * dt, amrex::max(w_n, amrex::Real(0.0)));
154  out.sublimation = w_n - w_new;
155  w_n = w_new;
156 
157  // Melt: DRM95 Eq. (12), with C_t = 1 / C_s.
158  if (w_n > zero && t_s > force_restore_snow_t_melt) {
159  const amrex::Real potential = prm.c_s * (t_s - force_restore_snow_t_melt) / lat_ice;
160  if (potential < w_n) {
161  w_new = w_n - potential;
162  out.melt = w_n - w_new;
163  w_n = w_new;
164  // The heat of the part W_n did not take stays in T_s for the next step; it is
165  // zero to round-off in double precision.
166  t_s = amrex::max(amrex::Real(force_restore_snow_t_melt),
167  force_restore_snow_t_melt + lat_ice * (potential - out.melt) / prm.c_s);
168  } else {
169  out.melt = w_n;
170  w_n = zero;
171  t_s -= lat_ice * out.melt / prm.c_s;
172  }
173  }
174  // The balance's upper bound, after the melt has taken its heat.
175  if (t_s > prm.t_max) { t_s = prm.t_max; }
176  return out;
177 }
178 
179 #endif // ERF_FORCE_RESTORE_SNOW_H_
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real force_restore_snow_fraction(amrex::Real w_n, amrex::Real w_crn) noexcept
Snow cover fraction p_ng of the ground, DRM95 Eq. (7).
Definition: ERF_ForceRestoreSnow.H:93
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE ForceRestoreSnowFluxes force_restore_snow_step(amrex::Real &w_n, amrex::Real &t_s, amrex::Real p_n, amrex::Real e, amrex::Real dt, const ForceRestoreSnowParams &prm) noexcept
One step of the snow layer of one column, after the balance has updated T_s.
Definition: ERF_ForceRestoreSnow.H:130
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real force_restore_snow_albedo(amrex::Real alb_ground, amrex::Real w_n, const ForceRestoreSnowParams &prm) noexcept
Surface albedo with snow, DRM95 Eq. (8) with veg = 0.
Definition: ERF_ForceRestoreSnow.H:108
constexpr amrex::Real force_restore_snow_t_melt
The melting point T_00 [K] of DRM95 Eq. (12).
Definition: ERF_ForceRestoreSnow.H:61
Physical constants and tuning parameters used only by the moisture and cloud-physics code.
constexpr amrex::Real lat_ice
Definition: ERF_MicrophysicsConstants.H:114
Dimensionless numeric literals and pure mathematical constants.
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
What one snow step moved in one column [kg/m^2].
Definition: ERF_ForceRestoreSnow.H:79
amrex::Real melt
Snow melted.
Definition: ERF_ForceRestoreSnow.H:82
amrex::Real snowfall
Frozen precipitation taken in.
Definition: ERF_ForceRestoreSnow.H:80
amrex::Real sublimation
Snow sublimated.
Definition: ERF_ForceRestoreSnow.H:81
Parameters of one snow step (from erf.radiation.seb_*).
Definition: ERF_ForceRestoreSnow.H:67
amrex::Real c_s
Definition: ERF_ForceRestoreSnow.H:70
amrex::Real w_crn
Critical snow water equivalent W_crn [kg/m^2] (seb_snow_critical_swe_kg_m2)
Definition: ERF_ForceRestoreSnow.H:68
amrex::Real albedo
Snow albedo alpha_n [-] (seb_snow_albedo)
Definition: ERF_ForceRestoreSnow.H:69
amrex::Real t_max
Upper bound of T_s after the melt [K] (seb_prognostic_t_max_k); no bound by default.
Definition: ERF_ForceRestoreSnow.H:72