ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_SimplifiedSEB.H File Reference

Simplified SEB — Diagnostic mode residual computation. More...

#include <AMReX_GpuControl.H>
#include <AMReX_Math.H>
#include <AMReX_FArrayBox.H>
#include <cmath>
#include <ERF_Constants.H>
#include <ERF_MicrophysicsConstants.H>
Include dependency graph for ERF_SimplifiedSEB.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real diagnose_seb_residual (amrex::Real sw_net, amrex::Real lw_net, amrex::Real hfx, amrex::Real lh, amrex::Real grdflx)
 Diagnose the surface energy balance residual. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real prognostic_dTs_dt (amrex::Real seb_residual, amrex::Real t_s, amrex::Real t_deep, amrex::Real c_s, amrex::Real tau)
 Compute prognostic surface temperature tendency using force-restore formulation. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real prognostic_dqs_dt (amrex::Real le, amrex::Real q_s, amrex::Real q_deep, amrex::Real d_s, amrex::Real tau_q)
 Compute prognostic surface moisture tendency using force-restore formulation. More...
 

Detailed Description

Simplified SEB — Diagnostic mode residual computation.

Implements diagnostic-only surface energy balance residual diagnosis. No prognostic update to surface temperature or fluxes; residual is computed and reported for validation and diagnostic purposes only.

Surface Energy Balance Equation: R_net(i,j) = SW_net(i,j) + LW_net(i,j) = [sw_flux_sfc(i,j)] + [lw_flux_sfc(i,j)]

SEB_residual(i,j) = R_net(i,j) - hfx_sfc(i,j) - lh_sfc(i,j) - grdflx_sfc(i,j)

Where:

  • sw_flux_sfc: net shortwave flux at surface [W/m^2]
  • lw_flux_sfc: net longwave flux at surface [W/m^2]
  • hfx_sfc: sensible heat flux (H) [W/m^2]
  • lh_sfc: latent heat flux (LE) [W/m^2]
  • grdflx_sfc: ground heat flux (G) [W/m^2]

A perfectly closed budget gives SEB_residual = 0; non-zero residual indicates energy not accounted for by the four main SEB terms.

References:

  • Oke, T. R., 1987: Boundary Layer Climates (2nd ed.), Routledge.

Function Documentation

◆ diagnose_seb_residual()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real diagnose_seb_residual ( amrex::Real  sw_net,
amrex::Real  lw_net,
amrex::Real  hfx,
amrex::Real  lh,
amrex::Real  grdflx 
)

Diagnose the surface energy balance residual.

Computes the SEB residual from net radiative flux and turbulent/ground heat fluxes. All inputs are guarded with amrex::Math::isfinite() to safely handle NaN/Inf; if any input is non-finite, returns 0.0 (safe no-op).

GPU Safety:

  • AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
  • No host-side I/O
  • No dynamic allocation
  • Safe for use in device reduction kernels
Parameters
[in]sw_netShortwave net flux at surface [W/m^2]
[in]lw_netLongwave net flux at surface [W/m^2]
[in]hfxSensible heat flux [W/m^2]
[in]lhLatent heat flux [W/m^2]
[in]grdflxGround heat flux [W/m^2]
Returns
SEB residual [W/m^2] = (sw_net + lw_net) - hfx - lh - grdflx Returns 0.0 if any input is non-finite (NaN or Inf)
69 {
70  // Guard all inputs against non-finite values (NaN, Inf)
71  if (!amrex::Math::isfinite(sw_net) || !amrex::Math::isfinite(lw_net) ||
72  !amrex::Math::isfinite(hfx) || !amrex::Math::isfinite(lh) || !amrex::Math::isfinite(grdflx)) {
73  return 0.0; // Safe no-op: return zero residual if any input is invalid
74  }
75 
76  // Compute net radiation
77  amrex::Real r_net = sw_net + lw_net;
78 
79  // Compute SEB residual
80  amrex::Real seb_residual = r_net - hfx - lh - grdflx;
81 
82  return seb_residual;
83 }
amrex::Real Real
Definition: ERF_ShocInterface.H:19

Referenced by TwoStreamRadiation::advance().

Here is the caller graph for this function:

◆ prognostic_dqs_dt()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real prognostic_dqs_dt ( amrex::Real  le,
amrex::Real  q_s,
amrex::Real  q_deep,
amrex::Real  d_s,
amrex::Real  tau_q 
)

Compute prognostic surface moisture tendency using force-restore formulation.

Computes dq_s/dt from latent heat flux and restoring term toward deep soil moisture: dq_s/dt = -(LE / (L_v * rhor * d_s)) - (1/tau_q) * (q_s - q_deep)

Constants:

  • L_v = 2.5e6 J/kg (latent heat of vaporization)
  • rhor = 1000.0 kg/m^3 (water density, from ERF_Constants.H)

All inputs are guarded with amrex::Math::isfinite() to safely handle NaN/Inf; if any input is non-finite, any parameter is non-positive (d_s <= 0, tau_q <= 0), returns 0.0 (safe no-op).

GPU Safety:

  • AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
  • No host-side I/O
  • No dynamic allocation
  • Safe for use in device kernels
Parameters
[in]leLatent heat flux [W/m^2]
[in]q_sCurrent surface moisture [kg/kg]
[in]q_deepDeep soil moisture [kg/kg]
[in]d_sEffective surface moisture layer depth [m]
[in]tau_qMoisture force-restore timescale [s]
Returns
Moisture tendency dq_s/dt [kg/kg/s] Returns 0.0 if any input is non-finite or any parameter is non-positive
169 {
170  // Guard all inputs against non-finite values
171  if (!amrex::Math::isfinite(le) || !amrex::Math::isfinite(q_s) ||
172  !amrex::Math::isfinite(q_deep) || !amrex::Math::isfinite(d_s) || !amrex::Math::isfinite(tau_q)) {
173  return 0.0; // Safe no-op
174  }
175 
176  // Validate parameter ranges
177  if (d_s <= 0.0 || tau_q <= 0.0) {
178  return 0.0; // Safe no-op for invalid parameters
179  }
180 
181  // L_v and rhor both come from ERF_Constants.H. A local L_v here shadowed
182  // the global one, and a local water density duplicated rhor.
183 
184  // Compute tendency: -(LE / (L_v * rhor * d_s)) - (1/tau_q) * (q_s - q_deep)
185  amrex::Real le_term = -(le / (L_v * rhor * d_s));
186  amrex::Real restore_term = (1.0 / tau_q) * (q_s - q_deep);
187  amrex::Real dq_s_dt = le_term - restore_term;
188 
189  return dq_s_dt;
190 }
constexpr amrex::Real L_v
Definition: ERF_Constants.H:51
constexpr amrex::Real rhor
Definition: ERF_MicrophysicsConstants.H:39

Referenced by TwoStreamRadiation::advance().

Here is the caller graph for this function:

◆ prognostic_dTs_dt()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real prognostic_dTs_dt ( amrex::Real  seb_residual,
amrex::Real  t_s,
amrex::Real  t_deep,
amrex::Real  c_s,
amrex::Real  tau 
)

Compute prognostic surface temperature tendency using force-restore formulation.

Computes dT_s/dt from SEB residual and restoring term toward deep soil temperature: dT_s/dt = SEB_residual / C_s - (2*pi/tau) * (T_s - T_deep)

All inputs are guarded with amrex::Math::isfinite() to safely handle NaN/Inf; if any input is non-finite, any parameter is non-positive (C_s <= 0, tau <= 0), returns 0.0 (safe no-op).

GPU Safety:

  • AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
  • No host-side I/O
  • No dynamic allocation
  • Safe for use in device kernels
Parameters
[in]seb_residualSEB residual [W/m^2] = R_net - H - LE - G
[in]t_sCurrent surface temperature [K]
[in]t_deepDeep soil temperature [K]
[in]c_sEffective surface heat capacity [J/(m^2*K)]
[in]tauForce-restore timescale [s]
Returns
Temperature tendency dT_s/dt [K/s] Returns 0.0 if any input is non-finite or any parameter is non-positive
115 {
116  // Guard all inputs against non-finite values
117  if (!amrex::Math::isfinite(seb_residual) || !amrex::Math::isfinite(t_s) ||
118  !amrex::Math::isfinite(t_deep) || !amrex::Math::isfinite(c_s) || !amrex::Math::isfinite(tau)) {
119  return 0.0; // Safe no-op
120  }
121 
122  // Validate parameter ranges
123  if (c_s <= 0.0 || tau <= 0.0) {
124  return 0.0; // Safe no-op for invalid parameters
125  }
126 
127  // Compute tendency: SEB_residual / C_s - (2*pi/tau) * (T_s - T_deep)
128  amrex::Real seb_term = seb_residual / c_s;
129  amrex::Real restore_term = (2.0 * PI / tau) * (t_s - t_deep);
130  amrex::Real dt_s_dt = seb_term - restore_term;
131 
132  return dt_s_dt;
133 }
constexpr amrex::Real PI
Definition: ERF_NumericalConstants.H:39

Referenced by TwoStreamRadiation::advance().

Here is the caller graph for this function: