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

Per-column two-stream radiation kernels. More...

#include <algorithm>
#include <cmath>
#include <type_traits>
#include <AMReX_Array4.H>
#include <AMReX_Box.H>
#include <AMReX_Geometry.H>
#include <AMReX_GpuControl.H>
#include <AMReX_Math.H>
#include <AMReX_REAL.H>
#include <ERF_Constants.H>
#include <ERF_EOS.H>
#include <ERF_IndexDefines.H>
#include <ERF_RadStruct.H>
#include <ERF_TwoStreamSW.H>
#include <ERF_TwoStreamLW.H>
#include <ERF_PrognosticCloudFraction.H>
#include <ERF_AerosolOpticalDepth.H>
#include <ERF_OrbCosZenith.H>
#include <ERF_SurfaceTemperature.H>
#include <ERF_TerrainMetrics.H>
Include dependency graph for ERF_TwoStreamColumn.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  TwoStreamParams
 Trivially copyable subset of RadChoice used by the column kernels. More...
 
struct  TwoStreamRoof
 A roof as the lower boundary of a column (erf.ibseb.two_stream_roofs): the column under a building starts at the first cell above the building, on a gray, diffuse surface with the roof face's own albedo, emissivity and skin temperature, in place of the ground under the building seen through the building's cells. More...
 

Namespaces

 TwoStreamScratch
 Per-column scratch the sweep keeps in a caller-provided Array4.
 

Functions

TwoStreamParams make_two_stream_params (const RadChoice &rc, const amrex::Real rdOcp)
 Copy the column-kernel parameters out of a RadChoice. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real get_temperature_from_rhotheta (amrex::Real rho_theta, amrex::Real rho, amrex::Real qv=0.0)
 GPU-safe helper to compute absolute temperature from (rho, rho*theta). More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool valid_surface_temperature (amrex::Real value)
 Check whether a heterogeneous absolute surface temperature is valid. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolve_surface_albedo_sw (int i, int j, const amrex::Array4< const amrex::Real > *hetero_alb_sw, const TwoStreamParams &rad_choice, bool has_hetero_alb)
 Resolve per-column shortwave surface albedo from hetero field or fallback. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool two_stream_starts_on_roof (int k_lower, int kbot) noexcept
 Whether a column starts on a roof: the layer on the roof, k_lower, is above the box's bottom layer kbot. The one condition for the sweep and for what the sweep's caller hands the faces of that column (the albedo and the interface the column starts at). More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real grey_surface_lw_up (amrex::Real emissivity, amrex::Real temperature, amrex::Real lw_down, amrex::Real sigma) noexcept
 The longwave a gray surface sends up: what it emits and the part of the longwave coming down that it reflects (Kirchhoff's law). The one expression for the ground and for a roof (TwoStreamRoof), so the two give the same number to the last bit. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolve_surface_albedo_sw_diffuse (amrex::Real alb_dir, amrex::Real surface_albedo_sw_diffuse) noexcept
 The ground's albedo for diffuse shortwave: the input surface_albedo_sw_diffuse, or the direct-beam albedo alb_dir of the column when that input is negative (not set). The one expression for the sweep and for what the sweep hands on (erf.ibseb.ground_sky_view). More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolve_surface_emissivity_lw (int i, int j, const amrex::Array4< const amrex::Real > *hetero_emiss_lw, const TwoStreamParams &rad_choice, bool has_hetero_emiss)
 Resolve per-column longwave surface emissivity from hetero field or fallback. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolve_surface_temp_k (int i, int j, const amrex::Array4< const amrex::Real > *lsm_t_sfc, bool has_lsm_t_sfc, const amrex::Array4< const amrex::Real > *seb_t_sfc, bool has_seb_t_sfc, const amrex::Array4< const amrex::Real > *surface_layer_theta, bool has_surface_layer, const TwoStreamParams &rad_choice, bool &from_surface_layer)
 Resolve the per-column surface-temperature boundary condition. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool is_cloud_level (amrex::Real z_center, const TwoStreamParams &rad_choice)
 GPU-safe helper to determine whether a layer falls within the cloud band [cloud_base_height_m, cloud_top_height_m]. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real get_qv_from_state (int i, int j, int k, const amrex::Array4< const amrex::Real > &state_arr)
 Water-vapor mixing ratio qv = RhoQv / Rho at (i,j,k). More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real get_inverse_exner (int i, int j, int k, const amrex::Array4< const amrex::Real > &state_arr)
 Inverse Exner function 1/pi at (i,j,k) from the state, with pi = (p / p_0)^(R_d/c_p) evaluated by getExnergivenRTh(). Used to convert a temperature tendency dT/dt into the potential-temperature tendency dtheta/dt = (dT/dt) / pi that the RhoTheta source term expects. Returns 1 for unphysical input. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real get_qc_from_state (int i, int j, int k, const amrex::Array4< const amrex::Real > &state_arr)
 Cloud-water mixing ratio qc = RhoQc / Rho at (i,j,k). More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real diagnose_tau_dynamic (amrex::Real tau_base, amrex::Real qv, amrex::Real qc, amrex::Real coeff_qv, amrex::Real coeff_qc)
 Moisture-dependent (dynamic) per-layer optical depth. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real tau_layer_value (amrex::Real z_center, amrex::Real tau_base, const TwoStreamParams &rad_choice, bool apply_cloud)
 GPU-safe helper to compute the per-layer optical depth at level k, given the base (clear-sky) optical depth and cloud-layer parameters. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void select_scattering_props (amrex::Real z_center, const TwoStreamParams &rad_choice, bool apply_cloud, amrex::Real &omega, amrex::Real &g)
 GPU-safe helper to select the single-scattering albedo and asymmetry factor to use for level k's diffuse SW calculation. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real diagnose_cloud_fraction_prognostic (int i, int j, int k, const amrex::Array4< const amrex::Real > &state_arr, const TwoStreamParams &rad_choice)
 GPU-safe helper to diagnose prognostic cloud fraction from per-level relative humidity and cloud liquid water. More...
 
amrex::Box two_stream_scratch_box (const amrex::Box &bx)
 Box of the scratch FArrayBox a sweep over box bx needs. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real diagnose_layer_tau (int i, int j, int k, amrex::Real dz_layer, amrex::Real z_center, const amrex::Array4< const amrex::Real > &state_arr, amrex::Real tau_base, bool is_sw, bool cloudy, const TwoStreamParams &rad_choice)
 GPU-safe helper to assemble the total per-layer optical depth at level k for either the SW or the LW band. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void diagnose_layer_optics (int i, int j, int k, amrex::Real dz_layer, amrex::Real z_center, const amrex::Array4< const amrex::Real > &state_arr, amrex::Real tau_base, bool is_sw, bool cloudy, const TwoStreamParams &rad_choice, amrex::Real &tau, amrex::Real &omega, amrex::Real &g)
 Optical depth, single-scattering albedo and asymmetry factor of layer k for one band, for either optical-depth model. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real two_stream_cos_zenith (int i, int j, const TwoStreamParams &rad_choice, bool has_latlon, const amrex::Array4< const amrex::Real > *lat_arr, const amrex::Array4< const amrex::Real > *lon_arr)
 Cosine of the solar zenith angle over column (i,j) for one call. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void two_stream_land_forcing (int i, int j, int kmin, const amrex::Array4< const amrex::Real > &rad_flux, amrex::Real cos_zenith, amrex::Real &sw_dn, amrex::Real &lw_dn, amrex::Real &coszen)
 The radiative forcing a land-surface model integrates on, for column (i,j). More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void vertical_two_stream_sweep (int i, int j, const amrex::Box &bx, amrex::Real dz_uniform, const amrex::Array4< const amrex::Real > &state_arr, const TwoStreamParams &rad_choice, bool cloudy, const amrex::Array4< amrex::Real > &qheating_arr, amrex::Real &max_heating_rate, amrex::Real &sw_surface_flux, amrex::Real &sw_up_toa, amrex::Real &lw_net_surface, amrex::Real &lw_up_toa, amrex::Real &sw_down_toa, const amrex::Array4< const amrex::Real > &z_phys_nd, const amrex::Array4< amrex::Real > &scratch, bool has_hetero_alb_sw=false, const amrex::Array4< const amrex::Real > *hetero_alb_sw=nullptr, bool has_hetero_emiss_lw=false, const amrex::Array4< const amrex::Real > *hetero_emiss_lw=nullptr, bool has_lsm_t_sfc=false, const amrex::Array4< const amrex::Real > *lsm_t_sfc=nullptr, bool has_seb_t_sfc=false, const amrex::Array4< const amrex::Real > *seb_t_sfc=nullptr, bool has_surface_layer=false, const amrex::Array4< const amrex::Real > *surface_layer_theta=nullptr, bool has_latlon=false, const amrex::Array4< const amrex::Real > *lat_arr=nullptr, const amrex::Array4< const amrex::Real > *lon_arr=nullptr, const amrex::Array4< amrex::Real > *rad_flux_out=nullptr, amrex::Real *cos_zenith_out=nullptr, amrex::Real *sw_beam_absorbed_out=nullptr, const TwoStreamRoof *roof=nullptr)
 GPU-safe per-column vertical integration kernel for two-stream radiation, computing either the clear-sky or cloudy-column fluxes and per-level heating rates, depending on the cloudy flag. More...
 

Variables

constexpr int TwoStreamScratch::DZ = 0
 
constexpr int TwoStreamScratch::Z = 1
 
constexpr int TwoStreamScratch::TAU_SW = 2
 
constexpr int TwoStreamScratch::F_DIR = 3
 
constexpr int TwoStreamScratch::A = 4
 
constexpr int TwoStreamScratch::S = 5
 
constexpr int TwoStreamScratch::LW_UP = 6
 
constexpr int TwoStreamScratch::LW_DN = 7
 
constexpr int TwoStreamScratch::TAU_LW = 8
 
constexpr int TwoStreamScratch::NCOMP = 9
 

Detailed Description

Per-column two-stream radiation kernels.

Everything needed to evaluate one (i,j) column of the two-stream model: temperature from the equation of state, per-column surface properties, per-layer optical depth assembly, and vertical_two_stream_sweep(), which performs the SW and LW sweeps and writes per-level heating rates.

Vertical orientation follows ERF: k = kmin is the surface layer and k = kmax the top layer. SW sweeps downward from kmax to kmin; LW sweeps downward (TOA -> surface) and then upward (surface -> TOA) on layer interfaces. Layer temperature is obtained from rho*theta through the Exner function.

The functions are header-only and GPU-safe so that the column physics can be exercised directly by unit tests (Tests/Unit/Radiation) as well as by the level driver in ERF_TwoStreamRadiation.cpp (TwoStreamRadiation::advance).

Function Documentation

◆ diagnose_cloud_fraction_prognostic()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real diagnose_cloud_fraction_prognostic ( int  i,
int  j,
int  k,
const amrex::Array4< const amrex::Real > &  state_arr,
const TwoStreamParams &  rad_choice 
)

GPU-safe helper to diagnose prognostic cloud fraction from per-level relative humidity and cloud liquid water.

Computes cloud fraction from RH and qc using: cf_rh(k) = linear ramp from 0 at rh_min to 1 at rh_max cf_qc(k) = min(1, qc(k) / qc_scale) cf(k) = min(1, cf_rh + cf_qc) [saturated blend]

Temperature comes from the equation of state (Exner function) and pressure from getPgivenRTh(), both evaluated with the local qv. Returns 0 when cloud_fraction_prog_enable is false.

Parameters
[in]i,j,kGrid indices
[in]state_arrState array proxy (contains Rho, RhoTheta, qv, qc)
[in]rad_choiceRadiation parameters (prognostic cloud fraction settings)
Returns
Diagnosed cloud fraction [0, 1] if enabled; 0 if disabled
605 {
606  if (!rad_choice.cloud_fraction_prog_enable) {
607  return 0.0;
608  }
609 
610  const amrex::Real qv = get_qv_from_state(i, j, k, state_arr);
611  const amrex::Real qc = get_qc_from_state(i, j, k, state_arr);
612 
613  amrex::Real rho = state_arr(i, j, k, Rho_comp);
614  amrex::Real rho_theta = state_arr(i, j, k, RhoTheta_comp);
615  // Unreachable from TwoStreamRadiation::advance, which refuses a state with
616  // a non-finite or non-positive density or rho*theta before the sweep;
617  // kept so a direct kernel caller (unit tests) cannot divide by zero.
618  if (rho <= 0.0 || !amrex::Math::isfinite(rho)) rho = 1.0;
619  if (rho_theta <= 0.0 || !amrex::Math::isfinite(rho_theta)) rho_theta = 288.15;
620 
621  // Temperature (via the Exner function) and pressure from the equation of state
622  amrex::Real T = get_temperature_from_rhotheta(rho_theta, rho, qv);
623  amrex::Real P = getPgivenRTh(rho_theta, qv);
624  if (P <= 0.0 || !amrex::Math::isfinite(P)) P = p_0;
625 
626  const amrex::Real rh = compute_relative_humidity(qv, T, P);
627 
629  rh, qc,
630  rad_choice.cloud_fraction_rh_min,
631  rad_choice.cloud_fraction_rh_max,
632  rad_choice.cloud_fraction_qc_scale);
633 }
constexpr amrex::Real p_0
Definition: ERF_Constants.H:69
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getPgivenRTh(const amrex::Real rhotheta, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:81
#define Rho_comp
Definition: ERF_IndexDefines.H:61
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:62
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real compute_relative_humidity(amrex::Real qv, amrex::Real T, amrex::Real P)
Compute relative humidity from water vapor mixing ratio.
Definition: ERF_PrognosticCloudFraction.H:37
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real diagnose_cloud_fraction_from_rh_qc(amrex::Real rh, amrex::Real qc, amrex::Real rh_min, amrex::Real rh_max, amrex::Real qc_scale)
Diagnose cloud fraction from relative humidity and cloud water.
Definition: ERF_PrognosticCloudFraction.H:99
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real get_qv_from_state(int i, int j, int k, const amrex::Array4< const amrex::Real > &state_arr)
Water-vapor mixing ratio qv = RhoQv / Rho at (i,j,k).
Definition: ERF_TwoStreamColumn.H:436
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real get_qc_from_state(int i, int j, int k, const amrex::Array4< const amrex::Real > &state_arr)
Cloud-water mixing ratio qc = RhoQc / Rho at (i,j,k).
Definition: ERF_TwoStreamColumn.H:472
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real get_temperature_from_rhotheta(amrex::Real rho_theta, amrex::Real rho, amrex::Real qv=0.0)
GPU-safe helper to compute absolute temperature from (rho, rho*theta).
Definition: ERF_TwoStreamColumn.H:200
@ P
Definition: ERF_IndexDefines.H:221
@ rho
Definition: ERF_Kessler.H:25
@ qv
Definition: ERF_Kessler.H:31
@ qc
Definition: ERF_Morrison.H:110
@ T
Definition: ERF_IndexDefines.H:180
amrex::Real cloud_fraction_qc_scale
Definition: ERF_TwoStreamColumn.H:89
amrex::Real cloud_fraction_rh_max
Definition: ERF_TwoStreamColumn.H:88
bool cloud_fraction_prog_enable
Definition: ERF_TwoStreamColumn.H:86
amrex::Real cloud_fraction_rh_min
Definition: ERF_TwoStreamColumn.H:87

Referenced by diagnose_layer_optics(), and diagnose_layer_tau().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ diagnose_layer_optics()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void diagnose_layer_optics ( int  i,
int  j,
int  k,
amrex::Real  dz_layer,
amrex::Real  z_center,
const amrex::Array4< const amrex::Real > &  state_arr,
amrex::Real  tau_base,
bool  is_sw,
bool  cloudy,
const TwoStreamParams &  rad_choice,
amrex::Real &  tau,
amrex::Real &  omega,
amrex::Real &  g 
)

Optical depth, single-scattering albedo and asymmetry factor of layer k for one band, for either optical-depth model.

Per-layer model (default): the optical depth comes from diagnose_layer_tau() and the scattering properties from the clear-sky or cloud-band inputs through select_scattering_props(), exactly as before.

Mass model (tau_model = mass), shortwave: each constituent contributes an extinction optical depth from the layer mass path, dry absorption rho dz sw_kabs_dry (omega = 0) Rayleigh rho dz sw_kscat_dry (omega = 1, g = 0) water vapor rho dz sw_kabs_vapor qv (omega = 0) cloud water rho dz sw_kext_cloud qc (sw_cloud_omega, sw_cloud_g) plus the prescribed cloud-band enhancement (with the cloud-band scattering inputs) and the absorbing moisture-coefficient and aerosol additions. The layer properties are the extinction-weighted mixtures tau = sum tau_i, omega = sum omega_i tau_i / tau, g = sum g_i omega_i tau_i / sum omega_i tau_i. Longwave uses diagnose_layer_tau(), whose clear-sky base is the mass path rho dz (lw_kabs_dry + lw_kabs_vapor qv + lw_kabs_cloud qc) in this model.

Parameters
[in]i,j,kGrid indices (kmin is the surface layer).
[in]dz_layerThickness of this layer [m].
[in]z_centerHeight of the layer center above the surface [m].
[in]state_arrState array (read-only).
[in]tau_basePer-layer-model clear-sky optical depth for this band.
[in]is_swtrue for the shortwave band, false for longwave.
[in]cloudytrue for the cloudy-column evaluation.
[in]rad_choiceColumn-kernel parameters.
[out]tauOptical depth of the layer [unitless].
[out]omegaSingle-scattering albedo of the layer (0 for LW).
[out]gAsymmetry factor of the layer (0 for LW).
804 {
805  omega = 0.0;
806  g = 0.0;
807  if (!is_sw || rad_choice.tau_model != TauModel::Mass) {
808  tau = diagnose_layer_tau(i, j, k, dz_layer, z_center, state_arr, tau_base, is_sw, cloudy, rad_choice);
809  if (is_sw) {
810  select_scattering_props(z_center, rad_choice, cloudy, omega, g);
811  }
812  return;
813  }
814 
815  // Shortwave mass model: constituent extinction optical depths.
816  amrex::Real rho = state_arr(i, j, k, Rho_comp);
817  if (!(rho > 0.0) || !amrex::Math::isfinite(rho)) rho = 0.0;
818  const amrex::Real qv = get_qv_from_state(i, j, k, state_arr);
819  const amrex::Real qc = get_qc_from_state(i, j, k, state_arr);
820  const amrex::Real path = rho * dz_layer;
821 
822  const amrex::Real tau_dry_abs = path * rad_choice.sw_kabs_dry;
823  const amrex::Real tau_rayleigh = path * rad_choice.sw_kscat_dry;
824  const amrex::Real tau_vapor = path * rad_choice.sw_kabs_vapor * qv;
825  const amrex::Real tau_cloud = path * rad_choice.sw_kext_cloud * qc;
826 
827  amrex::Real ext = tau_dry_abs + tau_rayleigh + tau_vapor + tau_cloud;
828  amrex::Real sca = tau_rayleigh + rad_choice.sw_cloud_omega * tau_cloud;
829  amrex::Real gsca = rad_choice.sw_cloud_g * rad_choice.sw_cloud_omega * tau_cloud;
830 
831  // Prescribed cloud band (optionally scaled by the prognostic cloud
832  // fraction) with the cloud-band scattering inputs.
833  amrex::Real band = tau_layer_value(z_center, 0.0, rad_choice, cloudy);
834  if (rad_choice.cloud_fraction_prog_enable && cloudy &&
835  rad_choice.tau_profile_type == TauProfileType::CloudLayer &&
836  is_cloud_level(z_center, rad_choice)) {
837  band = diagnose_cloud_fraction_prognostic(i, j, k, state_arr, rad_choice) * rad_choice.cloud_tau_per_layer;
838  }
839  if (band > 0.0) {
840  ext += band;
841  sca += rad_choice.cloud_single_scattering_albedo * band;
842  gsca += rad_choice.cloud_asymmetry_factor * rad_choice.cloud_single_scattering_albedo * band;
843  }
844 
845  // Absorbing additions (moisture coefficients, aerosol): everything that
846  // diagnose_layer_tau() adds on top of a zero base, minus the band.
847  const amrex::Real additions = diagnose_layer_tau(i, j, k, dz_layer, z_center, state_arr,
848  0.0, /*is_sw=*/true, cloudy, rad_choice) - band;
849  if (additions > 0.0) ext += additions;
850 
851  if (!amrex::Math::isfinite(ext) || ext <= 0.0) {
852  tau = 0.0;
853  return;
854  }
855  tau = ext;
856  omega = sca / ext;
857  if (omega > 1.0) omega = 1.0;
858  if (omega < 0.0) omega = 0.0;
859  g = (sca > 0.0) ? gsca / sca : 0.0;
860  if (g > 1.0) g = 1.0;
861  if (g < -1.0) g = -1.0;
862 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real diagnose_cloud_fraction_prognostic(int i, int j, int k, const amrex::Array4< const amrex::Real > &state_arr, const TwoStreamParams &rad_choice)
GPU-safe helper to diagnose prognostic cloud fraction from per-level relative humidity and cloud liqu...
Definition: ERF_TwoStreamColumn.H:601
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real tau_layer_value(amrex::Real z_center, amrex::Real tau_base, const TwoStreamParams &rad_choice, bool apply_cloud)
GPU-safe helper to compute the per-layer optical depth at level k, given the base (clear-sky) optical...
Definition: ERF_TwoStreamColumn.H:530
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool is_cloud_level(amrex::Real z_center, const TwoStreamParams &rad_choice)
GPU-safe helper to determine whether a layer falls within the cloud band [cloud_base_height_m,...
Definition: ERF_TwoStreamColumn.H:423
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void select_scattering_props(amrex::Real z_center, const TwoStreamParams &rad_choice, bool apply_cloud, amrex::Real &omega, amrex::Real &g)
GPU-safe helper to select the single-scattering albedo and asymmetry factor to use for level k's diff...
Definition: ERF_TwoStreamColumn.H:565
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real diagnose_layer_tau(int i, int j, int k, amrex::Real dz_layer, amrex::Real z_center, const amrex::Array4< const amrex::Real > &state_arr, amrex::Real tau_base, bool is_sw, bool cloudy, const TwoStreamParams &rad_choice)
GPU-safe helper to assemble the total per-layer optical depth at level k for either the SW or the LW ...
Definition: ERF_TwoStreamColumn.H:695
@ omega
Definition: ERF_Morrison.H:57
real(c_double), parameter g
Definition: ERF_module_model_constants.F90:19
amrex::Real sw_cloud_omega
Definition: ERF_TwoStreamColumn.H:102
amrex::Real cloud_single_scattering_albedo
Definition: ERF_TwoStreamColumn.H:70
amrex::Real sw_kabs_vapor
Definition: ERF_TwoStreamColumn.H:100
TauModel tau_model
Definition: ERF_TwoStreamColumn.H:97
amrex::Real cloud_tau_per_layer
Definition: ERF_TwoStreamColumn.H:66
TauProfileType tau_profile_type
Definition: ERF_TwoStreamColumn.H:63
amrex::Real sw_kext_cloud
Definition: ERF_TwoStreamColumn.H:101
amrex::Real sw_kabs_dry
Definition: ERF_TwoStreamColumn.H:98
amrex::Real sw_kscat_dry
Definition: ERF_TwoStreamColumn.H:99
amrex::Real cloud_asymmetry_factor
Definition: ERF_TwoStreamColumn.H:71
amrex::Real sw_cloud_g
Definition: ERF_TwoStreamColumn.H:103

Referenced by vertical_two_stream_sweep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ diagnose_layer_tau()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real diagnose_layer_tau ( int  i,
int  j,
int  k,
amrex::Real  dz_layer,
amrex::Real  z_center,
const amrex::Array4< const amrex::Real > &  state_arr,
amrex::Real  tau_base,
bool  is_sw,
bool  cloudy,
const TwoStreamParams &  rad_choice 
)

GPU-safe helper to assemble the total per-layer optical depth at level k for either the SW or the LW band.

The contributions are applied in the same order for both bands:

  1. clear-sky base value, plus the cloud-layer enhancement when the column is evaluated as "cloudy" and the level lies inside the cloud band;
  2. optional moisture-dependent (dynamic) term from qv and qc;
  3. optional prognostic cloud fraction, which replaces the cloud-band enhancement by cf(k) * cloud_tau_per_layer;
  4. optional prescribed aerosol term (constant, exponential or table).
Parameters
[in]i,j,kGrid indices (k increases upward; kmin is the surface layer).
[in]dz_layerThickness of this layer [m].
[in]z_centerHeight of the layer center above the surface [m] (cloud-band detection and the aerosol profile).
[in]state_arrState array (read-only).
[in]tau_baseClear-sky optical depth per layer for this band (for LW, replaced by the mass-path value when lw_mass_absorption_enable or tau_model = mass is set).
[in]is_swtrue for the shortwave band, false for longwave.
[in]cloudytrue for the cloudy-column evaluation.
[in]rad_choiceRadiation parameters.
Returns
Optical depth of layer k [unitless].
701 {
702  // Longwave option: gray optical depth from the layer mass path,
703  // tau = rho dz (k_dry + k_vapor qv + k_cloud qc),
704  // which makes the column optical depth independent of the vertical
705  // resolution and gives water vapor and cloud water a real greenhouse
706  // effect. Replaces the fixed tau_lw_per_layer as the clear-sky base.
707  amrex::Real base = tau_base;
708  if (!is_sw && (rad_choice.lw_mass_absorption_enable || rad_choice.tau_model == TauModel::Mass)) {
709  amrex::Real rho = state_arr(i, j, k, Rho_comp);
710  if (!(rho > 0.0) || !amrex::Math::isfinite(rho)) rho = 0.0;
711  const amrex::Real qv = get_qv_from_state(i, j, k, state_arr);
712  const amrex::Real qc = get_qc_from_state(i, j, k, state_arr);
713  base = rho * dz_layer * (rad_choice.lw_kabs_dry
714  + rad_choice.lw_kabs_vapor * qv
715  + rad_choice.lw_kabs_cloud * qc);
716  if (!amrex::Math::isfinite(base) || base < 0.0) base = 0.0;
717  }
718 
719  // Base (clear-sky) value, plus cloud-band enhancement for cloudy columns.
720  amrex::Real tau = tau_layer_value(z_center, base, rad_choice, cloudy);
721 
722  // Dynamic (moisture-dependent) contribution.
723  const bool dynamic_enabled = is_sw ? rad_choice.tau_sw_dynamic_enable
724  : rad_choice.tau_lw_dynamic_enable;
725  if (dynamic_enabled) {
726  const amrex::Real qv = get_qv_from_state(i, j, k, state_arr);
727  const amrex::Real qc = get_qc_from_state(i, j, k, state_arr);
728  tau = is_sw ? diagnose_tau_dynamic(tau, qv, qc, rad_choice.tau_sw_coeff_qv, rad_choice.tau_sw_coeff_qc)
729  : diagnose_tau_dynamic(tau, qv, qc, rad_choice.tau_lw_coeff_qv, rad_choice.tau_lw_coeff_qc);
730  }
731 
732  // Prognostic cloud fraction: scale the cloud-band enhancement by cf(k).
733  if (rad_choice.cloud_fraction_prog_enable && cloudy &&
734  rad_choice.tau_profile_type == TauProfileType::CloudLayer &&
735  is_cloud_level(z_center, rad_choice)) {
736  // tau already holds the full cloud-band enhancement (this is a cloudy
737  // column inside the band) plus the dynamic term; scale only the
738  // enhancement by cf(k) and leave the dynamic term in place.
739  amrex::Real cf_prog = diagnose_cloud_fraction_prognostic(i, j, k, state_arr, rad_choice);
740  tau += (cf_prog - 1.0) * rad_choice.cloud_tau_per_layer;
741  }
742 
743  // Prescribed bulk aerosol contribution (added on top of everything above).
744  if (rad_choice.aerosol_enable) {
745  amrex::Real tau_aerosol = 0.0;
746  if (rad_choice.aerosol_profile_type == AerosolProfileType::Constant) {
747  tau_aerosol = diagnose_tau_aerosol_constant(rad_choice.aerosol_tau_per_layer);
748  } else if (rad_choice.aerosol_profile_type == AerosolProfileType::Exponential) {
749  tau_aerosol = diagnose_tau_aerosol_exponential(z_center, dz_layer,
750  rad_choice.aerosol_tau_surface,
751  rad_choice.aerosol_scale_height_m);
752  } else if (rad_choice.aerosol_profile_type == AerosolProfileType::Table) {
753  tau_aerosol = diagnose_tau_aerosol_table(k);
754  }
755  tau += tau_aerosol;
756  }
757 
758  return tau;
759 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real diagnose_tau_aerosol_constant(amrex::Real tau_aerosol_const)
Diagnose aerosol optical depth for Constant profile.
Definition: ERF_AerosolOpticalDepth.H:42
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real diagnose_tau_aerosol_exponential(amrex::Real z_level, amrex::Real dz, amrex::Real tau_surface, amrex::Real scale_height_m)
Diagnose aerosol optical depth for Exponential profile.
Definition: ERF_AerosolOpticalDepth.H:77
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real diagnose_tau_aerosol_table(int k)
Diagnose aerosol optical depth for the Table profile.
Definition: ERF_AerosolOpticalDepth.H:123
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real diagnose_tau_dynamic(amrex::Real tau_base, amrex::Real qv, amrex::Real qc, amrex::Real coeff_qv, amrex::Real coeff_qc)
Moisture-dependent (dynamic) per-layer optical depth.
Definition: ERF_TwoStreamColumn.H:500
bool lw_mass_absorption_enable
Definition: ERF_TwoStreamColumn.H:105
amrex::Real lw_kabs_cloud
Definition: ERF_TwoStreamColumn.H:108
amrex::Real aerosol_tau_per_layer
Definition: ERF_TwoStreamColumn.H:93
bool tau_sw_dynamic_enable
Definition: ERF_TwoStreamColumn.H:79
bool aerosol_enable
Definition: ERF_TwoStreamColumn.H:91
amrex::Real aerosol_tau_surface
Definition: ERF_TwoStreamColumn.H:95
amrex::Real tau_sw_coeff_qc
Definition: ERF_TwoStreamColumn.H:82
amrex::Real aerosol_scale_height_m
Definition: ERF_TwoStreamColumn.H:94
amrex::Real lw_kabs_vapor
Definition: ERF_TwoStreamColumn.H:107
AerosolProfileType aerosol_profile_type
Definition: ERF_TwoStreamColumn.H:92
amrex::Real tau_sw_coeff_qv
Definition: ERF_TwoStreamColumn.H:81
bool tau_lw_dynamic_enable
Definition: ERF_TwoStreamColumn.H:80
amrex::Real lw_kabs_dry
Definition: ERF_TwoStreamColumn.H:106

Referenced by diagnose_layer_optics(), and vertical_two_stream_sweep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ diagnose_tau_dynamic()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real diagnose_tau_dynamic ( amrex::Real  tau_base,
amrex::Real  qv,
amrex::Real  qc,
amrex::Real  coeff_qv,
amrex::Real  coeff_qc 
)

Moisture-dependent (dynamic) per-layer optical depth.

tau = tau_base + coeff_qv * qv + coeff_qc * qc

clamped to [0, 100]. With both coefficients zero this returns tau_base unchanged, so the static configuration is reproduced exactly. Used for both the SW and the LW band with the respective coefficient pair.

Parameters
[in]tau_baseOptical depth before the moisture contribution [unitless].
[in]qvWater-vapor mixing ratio [kg/kg].
[in]qcCloud-water mixing ratio [kg/kg].
[in]coeff_qvOptical depth per unit qv [unitless per kg/kg].
[in]coeff_qcOptical depth per unit qc [unitless per kg/kg].
Returns
Optical depth for this layer [unitless].
502 {
503  if (!(qv > 0.0) || !amrex::Math::isfinite(qv)) qv = 0.0;
504  if (!(qc > 0.0) || !amrex::Math::isfinite(qc)) qc = 0.0;
505  amrex::Real tau = tau_base + coeff_qv * qv + coeff_qc * qc;
506  if (!amrex::Math::isfinite(tau)) return tau_base;
507  if (tau < 0.0) tau = 0.0;
508  if (tau > 100.0) tau = 100.0;
509  return tau;
510 }

Referenced by diagnose_layer_tau().

Here is the caller graph for this function:

◆ get_inverse_exner()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real get_inverse_exner ( int  i,
int  j,
int  k,
const amrex::Array4< const amrex::Real > &  state_arr 
)

Inverse Exner function 1/pi at (i,j,k) from the state, with pi = (p / p_0)^(R_d/c_p) evaluated by getExnergivenRTh(). Used to convert a temperature tendency dT/dt into the potential-temperature tendency dtheta/dt = (dT/dt) / pi that the RhoTheta source term expects. Returns 1 for unphysical input.

457 {
458  amrex::Real rho_theta = state_arr(i, j, k, RhoTheta_comp);
459  if (!(rho_theta > 0.0) || !amrex::Math::isfinite(rho_theta)) return 1.0;
460  const amrex::Real qv = get_qv_from_state(i, j, k, state_arr);
461  const amrex::Real pi = getExnergivenRTh(rho_theta, RdoCp, qv);
462  return (amrex::Math::isfinite(pi) && pi > 0.0) ? 1.0 / pi : 1.0;
463 }
constexpr amrex::Real RdoCp
Definition: ERF_Constants.H:57
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getExnergivenRTh(const amrex::Real rhotheta, const amrex::Real rdOcp, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:156
real(c_double), parameter, private pi
Definition: ERF_module_mp_morr_two_moment.F90:100

Referenced by vertical_two_stream_sweep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_qc_from_state()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real get_qc_from_state ( int  i,
int  j,
int  k,
const amrex::Array4< const amrex::Real > &  state_arr 
)

Cloud-water mixing ratio qc = RhoQc / Rho at (i,j,k).

Returns 0 when the state carries no cloud-water component, or when the stored values are non-finite or negative.

474 {
475  if (state_arr.nComp() <= RhoQ2_comp) return 0.0;
476  amrex::Real rho = state_arr(i, j, k, Rho_comp);
477  amrex::Real rho_qc = state_arr(i, j, k, RhoQ2_comp);
478  if (!(rho > 0.0) || !amrex::Math::isfinite(rho) || !amrex::Math::isfinite(rho_qc)) return 0.0;
479  amrex::Real qc = rho_qc / rho;
480  return (amrex::Math::isfinite(qc) && qc > 0.0) ? qc : 0.0;
481 }
#define RhoQ2_comp
Definition: ERF_IndexDefines.H:79

Referenced by diagnose_cloud_fraction_prognostic(), diagnose_layer_optics(), and diagnose_layer_tau().

Here is the caller graph for this function:

◆ get_qv_from_state()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real get_qv_from_state ( int  i,
int  j,
int  k,
const amrex::Array4< const amrex::Real > &  state_arr 
)

Water-vapor mixing ratio qv = RhoQv / Rho at (i,j,k).

Returns 0 when the state carries no moisture components, or when the stored values are non-finite or negative.

438 {
439  if (state_arr.nComp() <= RhoQ1_comp) return 0.0;
440  amrex::Real rho = state_arr(i, j, k, Rho_comp);
441  amrex::Real rho_qv = state_arr(i, j, k, RhoQ1_comp);
442  if (!(rho > 0.0) || !amrex::Math::isfinite(rho) || !amrex::Math::isfinite(rho_qv)) return 0.0;
443  amrex::Real qv = rho_qv / rho;
444  return (amrex::Math::isfinite(qv) && qv > 0.0) ? qv : 0.0;
445 }
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:78

Referenced by diagnose_cloud_fraction_prognostic(), diagnose_layer_optics(), diagnose_layer_tau(), get_inverse_exner(), and vertical_two_stream_sweep().

Here is the caller graph for this function:

◆ get_temperature_from_rhotheta()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real get_temperature_from_rhotheta ( amrex::Real  rho_theta,
amrex::Real  rho,
amrex::Real  qv = 0.0 
)

GPU-safe helper to compute absolute temperature from (rho, rho*theta).

ERF stores dry density and dry potential temperature. The pressure follows from the equation of state, p = p_0 * (R_d * rho * theta_m / p_0)^gamma, theta_m = theta * (1 + R_v/R_d * qv), and the absolute temperature is recovered through the Exner function, T = theta * (p / p_0)^(R_d / c_p), which getTgivenRandRTh() evaluates as p / (R_d * rho * (1 + R_v/R_d * qv)).

Parameters
[in]rho_thetaRhoTheta component [K·kg/m^3]
[in]rhoDensity [kg/m^3]
[in]qvWater-vapor mixing ratio [kg/kg] (0 for dry air)
Returns
Temperature [K], clamped to [100, 400]; 288.15 for unphysical input.
203 {
204  if (!(rho > 0.0) || !amrex::Math::isfinite(rho) ||
205  !(rho_theta > 0.0) || !amrex::Math::isfinite(rho_theta)) {
206  return 288.15; // Defensive: fallback to standard T
207  }
208  if (!(qv >= 0.0) || !amrex::Math::isfinite(qv)) {
209  qv = 0.0;
210  }
211 
212  amrex::Real T = getTgivenRandRTh(rho, rho_theta, qv);
213  if (!amrex::Math::isfinite(T) || T <= 0.0) {
214  return 288.15; // Defensive: fallback
215  }
216 
217  // Defensive clipping to a sensible terrestrial range
218  T = std::max(T, amrex::Real(100.0));
219  T = std::min(T, amrex::Real(400.0));
220  return T;
221 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getTgivenRandRTh(const amrex::Real rho, const amrex::Real rhotheta, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:46

Referenced by diagnose_cloud_fraction_prognostic(), and vertical_two_stream_sweep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ grey_surface_lw_up()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real grey_surface_lw_up ( amrex::Real  emissivity,
amrex::Real  temperature,
amrex::Real  lw_down,
amrex::Real  sigma 
)
noexcept

The longwave a gray surface sends up: what it emits and the part of the longwave coming down that it reflects (Kirchhoff's law). The one expression for the ground and for a roof (TwoStreamRoof), so the two give the same number to the last bit.

297 {
298  return emissivity * compute_thermal_intensity(temperature, sigma) + (amrex::Real(1.0) - emissivity) * lw_down;
299 }
amrex::Real sigma
Definition: ERF_InitCustomPert_DataAssimilation_ISV.H:11
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real compute_thermal_intensity(amrex::Real T, amrex::Real sigma)
Compute thermal (LW) intensity for a given temperature.
Definition: ERF_TwoStreamLW.H:93

Referenced by vertical_two_stream_sweep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_cloud_level()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool is_cloud_level ( amrex::Real  z_center,
const TwoStreamParams &  rad_choice 
)

GPU-safe helper to determine whether a layer falls within the cloud band [cloud_base_height_m, cloud_top_height_m].

Parameters
[in]z_centerHeight of the layer center above the surface [m].
[in]rad_choiceRadiation parameters.
Returns
true if this layer is inside the configured cloud band.
424 {
425  return (z_center >= rad_choice.cloud_base_height_m &&
426  z_center <= rad_choice.cloud_top_height_m);
427 }
amrex::Real cloud_top_height_m
Definition: ERF_TwoStreamColumn.H:65
amrex::Real cloud_base_height_m
Definition: ERF_TwoStreamColumn.H:64

Referenced by diagnose_layer_optics(), diagnose_layer_tau(), select_scattering_props(), and tau_layer_value().

Here is the caller graph for this function:

◆ make_two_stream_params()

TwoStreamParams make_two_stream_params ( const RadChoice &  rc,
const amrex::Real  rdOcp 
)
inline

Copy the column-kernel parameters out of a RadChoice.

129 {
131  p.sw_enabled = rc.sw_enabled;
132  p.lw_enabled = rc.lw_enabled;
133  p.tau_per_layer = rc.tau_per_layer;
134  p.tau_lw_per_layer = rc.tau_lw_per_layer;
135  p.tau_profile_type = rc.tau_profile_type;
136  p.cloud_base_height_m = rc.cloud_base_height_m;
137  p.cloud_top_height_m = rc.cloud_top_height_m;
138  p.cloud_tau_per_layer = rc.cloud_tau_per_layer;
139  p.single_scattering_albedo = rc.single_scattering_albedo;
140  p.asymmetry_factor = rc.asymmetry_factor;
141  p.cloud_single_scattering_albedo = rc.cloud_single_scattering_albedo;
142  p.cloud_asymmetry_factor = rc.cloud_asymmetry_factor;
143  p.surface_albedo_sw = rc.surface_albedo_sw;
144  p.surface_albedo_sw_diffuse = rc.surface_albedo_sw_diffuse;
145  p.surface_emissivity_lw = rc.surface_emissivity_lw;
146  p.t_sfc_default = rc.rad_t_sfc;
147  p.rdOcp = rdOcp;
148  p.tau_sw_dynamic_enable = rc.tau_sw_dynamic_enable;
149  p.tau_lw_dynamic_enable = rc.tau_lw_dynamic_enable;
150  p.tau_sw_coeff_qv = rc.tau_sw_coeff_qv;
151  p.tau_sw_coeff_qc = rc.tau_sw_coeff_qc;
152  p.tau_lw_coeff_qv = rc.tau_lw_coeff_qv;
153  p.tau_lw_coeff_qc = rc.tau_lw_coeff_qc;
154  p.cloud_fraction_prog_enable = rc.cloud_fraction_prog_enable;
155  p.cloud_fraction_rh_min = rc.cloud_fraction_rh_min;
156  p.cloud_fraction_rh_max = rc.cloud_fraction_rh_max;
157  p.cloud_fraction_qc_scale = rc.cloud_fraction_qc_scale;
158  p.aerosol_enable = rc.aerosol_enable;
159  p.aerosol_profile_type = rc.aerosol_profile_type;
160  p.aerosol_tau_per_layer = rc.aerosol_tau_per_layer;
161  p.aerosol_scale_height_m = rc.aerosol_scale_height_m;
162  p.aerosol_tau_surface = rc.aerosol_tau_surface;
163  p.tau_model = rc.tau_model;
164  p.sw_kabs_dry = rc.sw_kabs_dry;
165  p.sw_kscat_dry = rc.sw_kscat_dry;
166  p.sw_kabs_vapor = rc.sw_kabs_vapor;
167  p.sw_kext_cloud = rc.sw_kext_cloud;
168  p.sw_cloud_omega = rc.sw_cloud_omega;
169  p.sw_cloud_g = rc.sw_cloud_g;
170  p.lw_mass_absorption_enable = rc.lw_mass_absorption_enable;
171  p.lw_kabs_dry = rc.lw_kabs_dry;
172  p.lw_kabs_vapor = rc.lw_kabs_vapor;
173  p.lw_kabs_cloud = rc.lw_kabs_cloud;
174  // Sun: a fixed cosine when given; the date-dependent quantities (calday,
175  // declination and the irradiance of the date) are filled by the driver.
176  p.solar_dynamic = !(rc.fixed_solar_zenith_angle > 0.0);
177  p.cos_zenith_fixed = rc.fixed_solar_zenith_angle;
178  p.S0 = (rc.fixed_total_solar_irradiance >= 0.0) ? rc.fixed_total_solar_irradiance : 1360.9;
179  p.lat_cons_rad = rc.rad_cons_lat * PI / 180.0;
180  p.lon_cons_rad = rc.rad_cons_lon * PI / 180.0;
181  return p;
182 }
const Real rdOcp
Definition: ERF_InitCustomPert_ABL.H:128
constexpr amrex::Real PI
Definition: ERF_NumericalConstants.H:46
constexpr std::array< amrex::Real, num_veg_params > rc
Definition: ERF_SLM_DefaultParams.H:22
@ p
Definition: ERF_WSM6.H:303
Trivially copyable subset of RadChoice used by the column kernels.
Definition: ERF_TwoStreamColumn.H:57

Referenced by TwoStreamRadiation::advance().

Here is the caller graph for this function:

◆ resolve_surface_albedo_sw()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolve_surface_albedo_sw ( int  i,
int  j,
const amrex::Array4< const amrex::Real > *  hetero_alb_sw,
const TwoStreamParams &  rad_choice,
bool  has_hetero_alb 
)

Resolve per-column shortwave surface albedo from hetero field or fallback.

Precedence:

  1. If hetero_alb_sw array available and value at (i,j) is finite ∈ [0,1], use it
  2. Otherwise, use rad_choice.surface_albedo_sw (already clamped by init_params)
  3. Hard default: 0.3
Parameters
[in]i,jColumn index
[in]hetero_alb_swHeterogeneous SW albedo field (may be nullptr)
[in]rad_choiceRadiation parameters with fallback surface_albedo_sw
[in]has_hetero_albtrue if hetero_alb_sw is available
Returns
SW albedo in [0, 1]
250 {
251  amrex::Real alb = rad_choice.surface_albedo_sw; // Default fallback (already clamped)
252 
253  if (has_hetero_alb && hetero_alb_sw != nullptr && hetero_alb_sw->contains(i, j, 0)) {
254  amrex::Real hetero_val = (*hetero_alb_sw)(i, j, 0, 0);
255  if (amrex::Math::isfinite(hetero_val) && hetero_val >= 0.0 && hetero_val <= 1.0) {
256  alb = hetero_val;
257  }
258  }
259 
260  return alb;
261 }
amrex::Real surface_albedo_sw
Definition: ERF_TwoStreamColumn.H:73

Referenced by TwoStreamRadiation::advance(), and vertical_two_stream_sweep().

Here is the caller graph for this function:

◆ resolve_surface_albedo_sw_diffuse()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolve_surface_albedo_sw_diffuse ( amrex::Real  alb_dir,
amrex::Real  surface_albedo_sw_diffuse 
)
noexcept

The ground's albedo for diffuse shortwave: the input surface_albedo_sw_diffuse, or the direct-beam albedo alb_dir of the column when that input is negative (not set). The one expression for the sweep and for what the sweep hands on (erf.ibseb.ground_sky_view).

309 {
310  return (surface_albedo_sw_diffuse >= 0.0) ? surface_albedo_sw_diffuse : alb_dir;
311 }

Referenced by TwoStreamRadiation::advance(), and vertical_two_stream_sweep().

Here is the caller graph for this function:

◆ resolve_surface_emissivity_lw()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolve_surface_emissivity_lw ( int  i,
int  j,
const amrex::Array4< const amrex::Real > *  hetero_emiss_lw,
const TwoStreamParams &  rad_choice,
bool  has_hetero_emiss 
)

Resolve per-column longwave surface emissivity from hetero field or fallback.

Precedence:

  1. If hetero_emiss_lw array available and value at (i,j) is finite ∈ [0,1], use it
  2. Otherwise, use rad_choice.surface_emissivity_lw (already clamped by init_params)
  3. Hard default: 0.99
Parameters
[in]i,jColumn index
[in]hetero_emiss_lwHeterogeneous LW emissivity field (may be nullptr)
[in]rad_choiceRadiation parameters with fallback surface_emissivity_lw
[in]has_hetero_emisstrue if hetero_emiss_lw is available
Returns
LW emissivity in [0, 1]
333 {
334  amrex::Real emiss = rad_choice.surface_emissivity_lw; // Default fallback (already clamped)
335 
336  if (has_hetero_emiss && hetero_emiss_lw != nullptr && hetero_emiss_lw->contains(i, j, 0)) {
337  amrex::Real hetero_val = (*hetero_emiss_lw)(i, j, 0, 0); // Assume single component
338  if (amrex::Math::isfinite(hetero_val) && hetero_val >= 0.0 && hetero_val <= 1.0) {
339  emiss = hetero_val;
340  }
341  }
342 
343  return emiss;
344 }
amrex::Real surface_emissivity_lw
Definition: ERF_TwoStreamColumn.H:75

Referenced by TwoStreamRadiation::advance(), and vertical_two_stream_sweep().

Here is the caller graph for this function:

◆ resolve_surface_temp_k()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolve_surface_temp_k ( int  i,
int  j,
const amrex::Array4< const amrex::Real > *  lsm_t_sfc,
bool  has_lsm_t_sfc,
const amrex::Array4< const amrex::Real > *  seb_t_sfc,
bool  has_seb_t_sfc,
const amrex::Array4< const amrex::Real > *  surface_layer_theta,
bool  has_surface_layer,
const TwoStreamParams &  rad_choice,
bool &  from_surface_layer 
)

Resolve the per-column surface-temperature boundary condition.

The candidates remain separate until this per-cell resolver runs. This is important for an LSM field that exists globally but contains an undefined value in an individual column.

Precedence for each column:

  1. valid LSM absolute temperature;
  2. valid prognostic SEB absolute temperature;
  3. valid SurfaceLayer potential temperature (marked for Exner conversion);
  4. the scalar absolute-temperature fallback, erf.rad_t_sfc.

Only the SurfaceLayer candidate is converted by the caller. The LSM and prognostic SEB candidates already satisfy the absolute-temperature contract.

Parameters
[in]i,jColumn index
[in]lsm_t_sfcLSM absolute-temperature field (may be nullptr)
[in]has_lsm_t_sfctrue if the LSM field is available
[in]seb_t_sfcprognostic SEB absolute-temperature field (may be nullptr)
[in]has_seb_t_sfctrue if the prognostic SEB field is available
[in]surface_layer_thetaSurfaceLayer potential-temperature field (may be nullptr)
[in]has_surface_layertrue if the SurfaceLayer field is available
[in]rad_choiceRadiation parameters with the fallback t_sfc_default
[out]from_surface_layertrue when the returned value is SurfaceLayer theta
Returns
Surface temperature candidate [K]
384 {
385  amrex::Real t_surf = rad_choice.t_sfc_default; // erf.rad_t_sfc (already validated)
386  from_surface_layer = false;
387 
388  if (has_lsm_t_sfc && lsm_t_sfc != nullptr && lsm_t_sfc->contains(i, j, 0)) {
389  const amrex::Real lsm_value = (*lsm_t_sfc)(i, j, 0, 0);
390  if (valid_surface_temperature(lsm_value)) {
391  return lsm_value;
392  }
393  }
394 
395  if (has_seb_t_sfc && seb_t_sfc != nullptr && seb_t_sfc->contains(i, j, 0)) {
396  const amrex::Real seb_value = (*seb_t_sfc)(i, j, 0, 0);
397  if (valid_surface_temperature(seb_value)) {
398  return seb_value;
399  }
400  }
401 
402  if (has_surface_layer && surface_layer_theta != nullptr &&
403  surface_layer_theta->contains(i, j, 0)) {
404  const amrex::Real theta = (*surface_layer_theta)(i, j, 0, 0);
406  from_surface_layer = true;
407  return theta;
408  }
409  }
410 
411  return t_surf;
412 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool valid_surface_temperature(amrex::Real value)
Check whether a heterogeneous absolute surface temperature is valid.
Definition: ERF_TwoStreamColumn.H:225
@ theta
Definition: ERF_Kessler.H:26
amrex::Real t_sfc_default
Definition: ERF_TwoStreamColumn.H:76

Referenced by vertical_two_stream_sweep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ select_scattering_props()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void select_scattering_props ( amrex::Real  z_center,
const TwoStreamParams &  rad_choice,
bool  apply_cloud,
amrex::Real &  omega,
amrex::Real &  g 
)

GPU-safe helper to select the single-scattering albedo and asymmetry factor to use for level k's diffuse SW calculation.

When this column evaluation applies the cloud-layer enhancement (apply_cloud == true, tau_profile_type == CloudLayer, and level k falls within the cloud band), the cloud scattering properties (cloud_single_scattering_albedo, cloud_asymmetry_factor) are used. Otherwise, the clear-sky scattering properties (single_scattering_albedo, asymmetry_factor) are used. Both default to 0.0, so by default this function always yields omega == 0.0 and the layers neither scatter the direct beam nor reflect diffuse light; the diffuse field then consists of the surface-reflected beam only.

Parameters
[in]z_centerHeight of the layer center above the surface [m].
[in]rad_choiceRadiation parameters.
[in]apply_cloudSame flag passed to tau_layer_value(); true for the cloudy-column evaluation, false for the clear-sky column evaluation.
[out]omegaSelected single-scattering albedo for this level.
[out]gSelected asymmetry factor for this level.
568 {
569  bool use_cloud_props = apply_cloud &&
570  rad_choice.tau_profile_type == TauProfileType::CloudLayer &&
571  is_cloud_level(z_center, rad_choice);
572 
573  if (use_cloud_props) {
575  g = rad_choice.cloud_asymmetry_factor;
576  } else {
577  omega = rad_choice.single_scattering_albedo;
578  g = rad_choice.asymmetry_factor;
579  }
580 }
amrex::Real single_scattering_albedo
Definition: ERF_TwoStreamColumn.H:68
amrex::Real asymmetry_factor
Definition: ERF_TwoStreamColumn.H:69

Referenced by diagnose_layer_optics().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tau_layer_value()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real tau_layer_value ( amrex::Real  z_center,
amrex::Real  tau_base,
const TwoStreamParams &  rad_choice,
bool  apply_cloud 
)

GPU-safe helper to compute the per-layer optical depth at level k, given the base (clear-sky) optical depth and cloud-layer parameters.

When rad_choice.tau_profile_type == Constant, returns tau_base unchanged (byte-identical). When == CloudLayer, adds rad_choice.cloud_tau_per_layer whenever the level height falls within [cloud_base_height_m, cloud_top_height_m].

Parameters
[in]z_centerHeight of the layer center above the surface [m].
[in]tau_baseClear-sky optical depth per layer.
[in]rad_choiceRadiation parameters.
[in]apply_cloudIf false, always returns tau_base (used for the clear-sky column computation even when cloud_fraction > 0).
Returns
Optical depth for this layer [unitless].
533 {
534  if (!apply_cloud || rad_choice.tau_profile_type != TauProfileType::CloudLayer) {
535  return tau_base;
536  }
537  if (is_cloud_level(z_center, rad_choice)) {
538  return tau_base + rad_choice.cloud_tau_per_layer;
539  }
540  return tau_base;
541 }

Referenced by diagnose_layer_optics(), and diagnose_layer_tau().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ two_stream_cos_zenith()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real two_stream_cos_zenith ( int  i,
int  j,
const TwoStreamParams &  rad_choice,
bool  has_latlon,
const amrex::Array4< const amrex::Real > *  lat_arr,
const amrex::Array4< const amrex::Real > *  lon_arr 
)

Cosine of the solar zenith angle over column (i,j) for one call.

The fixed value of erf.fixed_solar_zenith_angle, or the sun's position over this column at the calendar time of the call, with the same formula RRTMGP uses (orbital_cos_zenith without the interval average). The latitude and longitude are the column's own where the grid carries them, else the erf.rad_cons_lat/lon constants. Negative when the sun is below the horizon.

879 {
880  if (rad_choice.solar_dynamic) {
881  const amrex::Real lat_rad = (has_latlon && lat_arr != nullptr && lat_arr->contains(i, j, 0))
882  ? (*lat_arr)(i, j, 0) * PI / 180.0 : rad_choice.lat_cons_rad;
883  const amrex::Real lon_rad = (has_latlon && lon_arr != nullptr && lon_arr->contains(i, j, 0))
884  ? (*lon_arr)(i, j, 0) * PI / 180.0 : rad_choice.lon_cons_rad;
885  return static_cast<amrex::Real>(
886  orbital_cos_zenith_instant(rad_choice.calday, lat_rad, lon_rad, rad_choice.declin));
887  }
888  return rad_choice.cos_zenith_fixed;
889 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE double orbital_cos_zenith_instant(double jday, double lat, double lon, double declin)
Definition: ERF_OrbCosZenith.H:507
amrex::Real cos_zenith_fixed
Definition: ERF_TwoStreamColumn.H:114
amrex::Real lat_cons_rad
Definition: ERF_TwoStreamColumn.H:118
amrex::Real calday
Definition: ERF_TwoStreamColumn.H:116
amrex::Real declin
Definition: ERF_TwoStreamColumn.H:117
amrex::Real lon_cons_rad
Definition: ERF_TwoStreamColumn.H:119
bool solar_dynamic
Definition: ERF_TwoStreamColumn.H:113

Referenced by vertical_two_stream_sweep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ two_stream_land_forcing()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void two_stream_land_forcing ( int  i,
int  j,
int  kmin,
const amrex::Array4< const amrex::Real > &  rad_flux,
amrex::Real  cos_zenith,
amrex::Real &  sw_dn,
amrex::Real &  lw_dn,
amrex::Real &  coszen 
)

The radiative forcing a land-surface model integrates on, for column (i,j).

Reads the interface fluxes a sweep wrote in RRTMGP's level layout (see vertical_two_stream_sweep): the surface is the lower interface of the bottom layer, index kmin. What a land model wants there is the downwelling flux – it applies its own albedo and emissivity – not the net flux the surface energy balance uses:

  • sw_dn: total downwelling shortwave, direct plus diffuse (component 1);
  • lw_dn: downwelling longwave (component 3);
  • coszen: cosine of the solar zenith angle, floored at zero, since a sun below the horizon delivers nothing and a land model reads a negative value as a (meaningless) grazing angle. Call it after any clear/cloudy blending of rad_flux, so the fields match the fluxes that heat the atmosphere.
914 {
915  sw_dn = rad_flux(i, j, kmin, 1);
916  lw_dn = rad_flux(i, j, kmin, 3);
917  coszen = (cos_zenith > amrex::Real(0.0)) ? cos_zenith : amrex::Real(0.0);
918 }

Referenced by TwoStreamRadiation::advance().

Here is the caller graph for this function:

◆ two_stream_scratch_box()

amrex::Box two_stream_scratch_box ( const amrex::Box &  bx)
inline

Box of the scratch FArrayBox a sweep over box bx needs.

663 {
664  amrex::Box sbx(bx);
665  sbx.growHi(2, 1);
666  return sbx;
667 }

Referenced by TwoStreamRadiation::advance().

Here is the caller graph for this function:

◆ two_stream_starts_on_roof()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool two_stream_starts_on_roof ( int  k_lower,
int  kbot 
)
noexcept

Whether a column starts on a roof: the layer on the roof, k_lower, is above the box's bottom layer kbot. The one condition for the sweep and for what the sweep's caller hands the faces of that column (the albedo and the interface the column starts at).

285 {
286  return k_lower > kbot;
287 }

Referenced by TwoStreamRadiation::advance(), and vertical_two_stream_sweep().

Here is the caller graph for this function:

◆ valid_surface_temperature()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool valid_surface_temperature ( amrex::Real  value)

Check whether a heterogeneous absolute surface temperature is valid.

226 {
227  return amrex::Math::isfinite(value) && value > 0.0 && value < lsm_undefined;
228 }
constexpr amrex::Real lsm_undefined
Definition: ERF_Constants.H:28

Referenced by resolve_surface_temp_k().

Here is the caller graph for this function:

◆ vertical_two_stream_sweep()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void vertical_two_stream_sweep ( int  i,
int  j,
const amrex::Box &  bx,
amrex::Real  dz_uniform,
const amrex::Array4< const amrex::Real > &  state_arr,
const TwoStreamParams &  rad_choice,
bool  cloudy,
const amrex::Array4< amrex::Real > &  qheating_arr,
amrex::Real &  max_heating_rate,
amrex::Real &  sw_surface_flux,
amrex::Real &  sw_up_toa,
amrex::Real &  lw_net_surface,
amrex::Real &  lw_up_toa,
amrex::Real &  sw_down_toa,
const amrex::Array4< const amrex::Real > &  z_phys_nd,
const amrex::Array4< amrex::Real > &  scratch,
bool  has_hetero_alb_sw = false,
const amrex::Array4< const amrex::Real > *  hetero_alb_sw = nullptr,
bool  has_hetero_emiss_lw = false,
const amrex::Array4< const amrex::Real > *  hetero_emiss_lw = nullptr,
bool  has_lsm_t_sfc = false,
const amrex::Array4< const amrex::Real > *  lsm_t_sfc = nullptr,
bool  has_seb_t_sfc = false,
const amrex::Array4< const amrex::Real > *  seb_t_sfc = nullptr,
bool  has_surface_layer = false,
const amrex::Array4< const amrex::Real > *  surface_layer_theta = nullptr,
bool  has_latlon = false,
const amrex::Array4< const amrex::Real > *  lat_arr = nullptr,
const amrex::Array4< const amrex::Real > *  lon_arr = nullptr,
const amrex::Array4< amrex::Real > *  rad_flux_out = nullptr,
amrex::Real *  cos_zenith_out = nullptr,
amrex::Real *  sw_beam_absorbed_out = nullptr,
const TwoStreamRoof *  roof = nullptr 
)

GPU-safe per-column vertical integration kernel for two-stream radiation, computing either the clear-sky or cloudy-column fluxes and per-level heating rates, depending on the cloudy flag.

Vertical orientation. ERF's vertical index increases upward: k = kmin is the layer adjacent to the surface and k = kmax is the layer adjacent to the top of the domain (TOA for this model). Layer k spans the interfaces m = k - kmin (bottom) and m = k - kmin + 1 (top), so interface m = 0 is the surface and m = nlev is the TOA.

Per (i,j) column:

  1. SW: Beer-Lambert direct beam on the interfaces, then the two-stream diffuse field (upward and downward streams) by the adding method with the surface albedo as the lower boundary condition; the per-level SW heating rate from the net-flux divergence is written to qheating_arr(i,j,k,0).
  2. LW: sweep downward from the TOA (F_down = 0) to the surface, then upward from the surface (F_up = eps * sigma * T_s^4 + (1 - eps) * F_down) to the TOA, storing both interface profiles. The per-level LW heating rate from the net-flux divergence is written to qheating_arr(i,j,k,1).
  3. Scalar diagnostics (max heating rate, surface fluxes) are returned for the reduction in the caller.

Layer temperature is obtained from (rho, rho*theta, qv) through the equation of state, i.e. including the Exner function, so LW emission uses absolute temperature rather than potential temperature.

Integrates per-column heterogeneous surface properties (albedo, emissivity, surface temperature) from optional fields with robust fallback to RadChoice scalar parameters.

Parameters
[in]i,jColumn indices
[in]bxComputational box (cell-centered, full vertical extent)
[in]dz_uniformUniform vertical cell size [m], used when z_phys_cc is unavailable. Passed in rather than taken from a Geometry because Geometry::CellSize() is host-only and this runs on device.
[in]state_arrArray proxy to state data (read-only)
[in]rad_choiceColumn-kernel parameters (TwoStreamParams, built from RadChoice)
[in]cloudyIf true and tau_profile_type == CloudLayer, apply the cloud-layer optical depth enhancement (and cloud scattering properties).
[out]qheating_arrComponent 0 receives the SW and component 1 the LW radiative tendency of potential temperature, dtheta/dt = (dT/dt) / pi [K/s], at every level k in [kmin, kmax]. This is the convention the RhoTheta source term (ERF_MakeSources.cpp) and the RRTMGP path use.
[out]max_heating_rateMaximum |Q_sw|+|Q_lw| of the stored theta tendencies in this column
[out]sw_surface_fluxSW absorbed by the surface, (1 - alb_dir) F_dir + (1 - alb_dif) F_dif [W/m^2]
[out]sw_up_toaUpwelling (reflected) SW at the top of the atmosphere [W/m^2]
[out]lw_net_surfaceNet LW (up - down) at the surface [W/m^2]
[out]lw_up_toaUpwelling LW at the top of the atmosphere (outgoing longwave) [W/m^2]
[out]sw_down_toaIncident SW at the top of the atmosphere, S0 cos(zenith) or zero at night [W/m^2]
[in]z_phys_ndOptional nodal physical heights (layer interfaces on a nonuniform grid)
[in]has_hetero_alb_swtrue if hetero_alb_sw is available
[in]hetero_alb_swOptional per-column SW surface albedo field
[in]has_hetero_emiss_lwtrue if hetero_emiss_lw is available
[in]hetero_emiss_lwOptional per-column LW surface emissivity field
[in]has_lsm_t_sfctrue if the LSM absolute-temperature field is available
[in]lsm_t_sfcOptional LSM absolute surface-temperature field [K]
[in]has_seb_t_sfctrue if the prognostic SEB absolute-temperature field is available
[in]seb_t_sfcOptional prognostic SEB absolute surface-temperature field [K]
[in]has_surface_layertrue if the SurfaceLayer potential-temperature field is available
[in]surface_layer_thetaOptional SurfaceLayer potential-temperature field [K]
[in]has_latlontrue if per-column latitude and longitude fields are available
[in]lat_arrOptional per-column latitude [degrees] (dynamic sun)
[in]lon_arrOptional per-column longitude [degrees, east positive] (dynamic sun)
[out]rad_flux_outOptional 4-component flux output in RRTMGP's level layout: at index k the lower interface of layer k, and at kmax + 1 the top-of-atmosphere interface (the array must extend one cell above the column); component 0 is the upward SW, 1 the downward SW (direct plus diffuse), 2 the upward LW and 3 the downward LW [W/m^2]
[out]cos_zenith_outOptional: the cosine of the solar zenith angle this column was swept with (two_stream_cos_zenith, before any flooring), so a caller that needs the sun the sweep used reads it rather than evaluating it again
[out]sw_beam_absorbed_outOptional: the part of the absorbed shortwave at the surface that the direct beam brings, (1 - direct albedo) times the beam at the surface [W/m^2] (zero with the shortwave off or the sun down), so a caller can take the beam off the ground where something the column does not hold shades it
[in]roofOptional: the roof this column starts on (TwoStreamRoof). The layers and interfaces below roof->k_lower then get no heating and no flux, the surface outputs are the roof's, and heights (the cloud band, the aerosol profile) are still measured from the ground. A roof at or below the box's bottom cell is the ground; one above the top cell leaves the column empty.
1037 {
1038  // Grid bounds: kbot is the box's bottom layer, kmin the layer on the column's lower
1039  // boundary (the ground, or the first layer above a roof), kmax the top layer.
1040  const int kbot = bx.smallEnd(2);
1041  const bool on_roof = (roof != nullptr && two_stream_starts_on_roof(roof->k_lower, kbot));
1042  const int kmin = on_roof ? roof->k_lower : kbot;
1043  const int kmax = bx.bigEnd(2);
1044  const int nlev = kmax - kmin + 1;
1045 
1046  // The scratch box must hold nlev + 1 interface entries for this column,
1047  // and so must the flux output when it is wanted.
1048  AMREX_ASSERT(scratch.contains(i, j, kbot) && scratch.contains(i, j, kmax + 1));
1049  AMREX_ASSERT(rad_flux_out == nullptr ||
1050  (rad_flux_out->contains(i, j, kbot) && rad_flux_out->contains(i, j, kmax + 1)));
1051 
1052  // Per-column scratch accessors (see TwoStreamScratch). Layer fields are
1053  // indexed by layer m in [0, nlev), interface fields by m in [0, nlev].
1054  auto dz_level = [&] (int m) -> amrex::Real& { return scratch(i, j, kmin + m, TwoStreamScratch::DZ); };
1055  auto z_level = [&] (int m) -> amrex::Real& { return scratch(i, j, kmin + m, TwoStreamScratch::Z); };
1056  auto tau_sw_level = [&] (int m) -> amrex::Real& { return scratch(i, j, kmin + m, TwoStreamScratch::TAU_SW); };
1057  auto F_dir = [&] (int m) -> amrex::Real& { return scratch(i, j, kmin + m, TwoStreamScratch::F_DIR); };
1058  auto A = [&] (int m) -> amrex::Real& { return scratch(i, j, kmin + m, TwoStreamScratch::A); };
1059  auto S = [&] (int m) -> amrex::Real& { return scratch(i, j, kmin + m, TwoStreamScratch::S); };
1060  auto F_lw_up_iface = [&] (int m) -> amrex::Real& { return scratch(i, j, kmin + m, TwoStreamScratch::LW_UP); };
1061  auto F_lw_down_iface = [&] (int m) -> amrex::Real& { return scratch(i, j, kmin + m, TwoStreamScratch::LW_DN); };
1062  auto tau_lw_level = [&] (int m) -> amrex::Real& { return scratch(i, j, kmin + m, TwoStreamScratch::TAU_LW); };
1063 
1064  // Physical constants
1065  const amrex::Real sigma = stefan_boltzmann; // Stefan-Boltzmann [W/(m^2·K^4)]
1066  const amrex::Real cp_air = Cp_d; // Dry-air specific heat at constant pressure [J/(kg·K)]
1067 
1068  // ------------------------------------------------------------------
1069  // Layer thickness dz_level(m) and layer-center height z_level(m) above
1070  // the surface. On a stretched or terrain-following grid both come from
1071  // the interface heights: the height of face k over cell (i,j) is the
1072  // mean of its four nodes in z_phys_nd, so the thickness is the distance
1073  // between the layer's two interfaces (not the center-to-center spacing,
1074  // which differs by the stretch ratio) and the top layer gets its own
1075  // thickness. Without z_phys_nd the spacing is uniform. The heating
1076  // divergence dF/(rho cp dz) and the mass path rho dz both use this
1077  // thickness; z_level locates the cloud band and the aerosol profile.
1078  // ------------------------------------------------------------------
1079  if (z_phys_nd) {
1080  auto z_face = [&] (int k) -> amrex::Real {
1081  return 0.25 * (z_phys_nd(i, j, k) + z_phys_nd(i + 1, j, k) +
1082  z_phys_nd(i, j + 1, k) + z_phys_nd(i + 1, j + 1, k));
1083  };
1084  const amrex::Real z_surface = z_face(kbot);
1085  for (int m = 0; m < nlev; ++m) {
1086  const amrex::Real z_lo = z_face(kmin + m);
1087  const amrex::Real z_hi = z_face(kmin + m + 1);
1088  const amrex::Real dz_computed = z_hi - z_lo;
1089  dz_level(m) = (dz_computed > 0.0 && amrex::Math::isfinite(dz_computed)) ? dz_computed : dz_uniform;
1090  z_level(m) = 0.5 * (z_lo + z_hi) - z_surface;
1091  }
1092  } else {
1093  for (int m = 0; m < nlev; ++m) {
1094  dz_level(m) = dz_uniform;
1095  z_level(m) = (static_cast<amrex::Real>(kmin - kbot + m) + 0.5) * dz_uniform;
1096  }
1097  }
1098 
1099  const amrex::Real cos_zenith = two_stream_cos_zenith(i, j, rad_choice, has_latlon, lat_arr, lon_arr);
1100  if (cos_zenith_out != nullptr) { *cos_zenith_out = cos_zenith; }
1101 
1102  // Top-of-atmosphere irradiance of this call (fixed, or 1360.9 W/m^2
1103  // times the Earth-Sun distance factor of the date; set by the driver).
1104  const amrex::Real S0 = rad_choice.S0;
1105  const amrex::Real tau_sw_base = rad_choice.tau_per_layer;
1106  const amrex::Real tau_lw_base = rad_choice.tau_lw_per_layer;
1107 
1108  amrex::Real local_max_heating = 0.0;
1109 
1110  // Zero-initialize this column's heating rate output (covers the
1111  // sw_enabled=false and lw_enabled=false cases), and the interface fluxes
1112  // when they are wanted (a disabled band or night leaves zeros).
1113  for (int k = kbot; k <= kmax; ++k) {
1114  qheating_arr(i, j, k, 0) = 0.0;
1115  qheating_arr(i, j, k, 1) = 0.0;
1116  }
1117  if (rad_flux_out != nullptr) {
1118  for (int k = kbot; k <= kmax + 1; ++k) {
1119  for (int comp = 0; comp < 4; ++comp) { (*rad_flux_out)(i, j, k, comp) = 0.0; }
1120  }
1121  }
1122  sw_down_toa = (rad_choice.sw_enabled && cos_zenith > 0.0) ? S0 * cos_zenith : 0.0;
1123 
1124  // Under a roof the column holds nothing: the beam a caller reads from the scratch
1125  // (the building faces' canopy forcing) is zero there, like the fluxes above.
1126  // (A building that fills the column leaves every interface without a beam, the top one too.)
1127  const int k_dark = (nlev <= 0) ? kmax + 1 : kmin - 1;
1128  for (int k = kbot; k <= k_dark; ++k) {
1129  scratch(i, j, k, TwoStreamScratch::F_DIR) = 0.0;
1130  }
1131  // A building that fills the column to the top leaves no layer to sweep.
1132  if (nlev <= 0) {
1133  max_heating_rate = 0.0;
1134  sw_surface_flux = 0.0;
1135  sw_up_toa = 0.0;
1136  lw_net_surface = 0.0;
1137  lw_up_toa = 0.0;
1138  if (sw_beam_absorbed_out != nullptr) { *sw_beam_absorbed_out = 0.0; }
1139  return;
1140  }
1141 
1142  // ========================================================================
1143  // SHORTWAVE. Interfaces m = 0 (surface) .. nlev (TOA); layer m lies
1144  // between interfaces m and m+1.
1145  // 1. Direct beam F_dir(m) by Beer-Lambert from the TOA downward.
1146  // 2. Adding method, upward pass: A(m) is the albedo of everything below
1147  // interface m for diffuse light, S(m) the upward diffuse flux at m
1148  // produced by the direct beam illuminating everything below m. The
1149  // surface starts the recursion with A(0) = diffuse albedo and
1150  // S(0) = direct albedo * F_dir(0).
1151  // 3. Downward pass from the TOA (no incident diffuse flux): diffuse
1152  // downward d(m), diffuse upward u(m) = A(m) d(m) + S(m), and the net
1153  // flux F_dir + d - u whose divergence gives the heating rate.
1154  // ========================================================================
1155  amrex::Real tau_sw_cum = 0.0; // Column SW optical depth accumulated from the top
1156  amrex::Real sw_surface_absorbed = 0.0; // absorbed direct + diffuse at the surface
1157  amrex::Real sw_up_at_toa = 0.0; // u(nlev)
1158  // Direct-beam albedo (per column, LSM field or fallback) and diffuse albedo
1159  // (surface_albedo_sw_diffuse, or the direct value when negative).
1160  // A roof reflects the beam and the diffuse light alike (one albedo per face).
1161  const amrex::Real alb_dir = on_roof ? roof->albedo
1162  : resolve_surface_albedo_sw(i, j, hetero_alb_sw, rad_choice, has_hetero_alb_sw);
1163  const amrex::Real alb_dif = on_roof ? roof->albedo
1165 
1166  if (rad_choice.sw_enabled && cos_zenith > 0.0) {
1167 
1168  // 1. Per-layer optical depth and the direct beam on the interfaces.
1169  F_dir(nlev) = S0 * cos_zenith;
1170  for (int k = kmax; k >= kmin; --k) {
1171  const int m = k - kmin;
1172  amrex::Real omega_m = 0.0, g_m = 0.0;
1173  diagnose_layer_optics(i, j, k, dz_level(m), z_level(m), state_arr, tau_sw_base,
1174  /*is_sw=*/true, cloudy, rad_choice, tau_sw_level(m), omega_m, g_m);
1175  tau_sw_cum += tau_sw_level(m);
1176  F_dir(m) = compute_sw_direct_flux(tau_sw_cum, S0, cos_zenith);
1177  }
1178 
1179  // Two-stream properties of layer m (evaluated in both passes).
1180  auto layer_props = [&](int m) {
1181  amrex::Real tau_m = 0.0, omega = 0.0, g = 0.0;
1182  diagnose_layer_optics(i, j, kmin + m, dz_level(m), z_level(m), state_arr, tau_sw_base,
1183  /*is_sw=*/true, cloudy, rad_choice, tau_m, omega, g);
1184  return compute_sw_layer_two_stream(tau_sw_level(m), omega, g, cos_zenith);
1185  };
1186 
1187  // The beam the lower boundary takes: all of it at the ground (a shadow there is the
1188  // ground balance's), the lit share on a roof a taller building shades.
1189  const amrex::Real beam_sfc = on_roof ? roof->lit * F_dir(0) : F_dir(0);
1190 
1191  // 2. Upward pass of the adding method.
1192  A(0) = alb_dif;
1193  S(0) = alb_dir * beam_sfc;
1194  for (int m = 0; m < nlev; ++m) {
1195  const TwoStreamLayerSW L = layer_props(m);
1196  amrex::Real denom = 1.0 - L.R_dif * A(m);
1197  if (denom < 1.0e-12) denom = 1.0e-12;
1198  A(m + 1) = L.R_dif + L.T_dif * L.T_dif * A(m) / denom;
1199  S(m + 1) = L.R_dir * F_dir(m + 1)
1200  + L.T_dif * (S(m) + A(m) * L.T_dir * F_dir(m + 1)) / denom;
1201  }
1202 
1203  // 3. Downward pass: fluxes on the interfaces and layer heating rates.
1204  amrex::Real d_above = 0.0; // No diffuse flux incident at the TOA
1205  amrex::Real u_above = S(nlev);
1206  sw_up_at_toa = u_above;
1207  amrex::Real F_net_above = F_dir(nlev) + d_above - u_above;
1208  if (rad_flux_out != nullptr) {
1209  (*rad_flux_out)(i, j, kmax + 1, 0) = u_above; // SW up at the top of the atmosphere
1210  (*rad_flux_out)(i, j, kmax + 1, 1) = F_dir(nlev); // SW down at the top: the incident beam
1211  }
1212  for (int k = kmax; k >= kmin; --k) {
1213  const int m = k - kmin;
1214  const TwoStreamLayerSW L = layer_props(m);
1215  amrex::Real denom = 1.0 - L.R_dif * A(m);
1216  if (denom < 1.0e-12) denom = 1.0e-12;
1217 
1218  const amrex::Real d_m = (L.T_dif * d_above + L.T_dir * F_dir(m + 1) + L.R_dif * S(m)) / denom;
1219  const amrex::Real u_m = A(m) * d_m + S(m);
1220  const amrex::Real F_net_m = F_dir(m) + d_m - u_m;
1221  if (rad_flux_out != nullptr) {
1222  (*rad_flux_out)(i, j, k, 0) = u_m; // SW up at the lower interface of layer k
1223  (*rad_flux_out)(i, j, k, 1) = F_dir(m) + d_m; // SW down, direct plus diffuse
1224  }
1225 
1226  amrex::Real rho = state_arr(i, j, k, Rho_comp);
1227  if (rho <= 0.0 || !amrex::Math::isfinite(rho)) rho = 1.0;
1228 
1229  // dT/dt from the flux divergence, stored as dtheta/dt = (dT/dt)/pi
1230  // (the RhoTheta source term and RRTMGP use the same convention).
1231  const amrex::Real Q_sw = compute_sw_heating_rate(F_net_above, F_net_m,
1232  dz_level(m), rho, cp_air)
1233  * get_inverse_exner(i, j, k, state_arr);
1234  qheating_arr(i, j, k, 0) = Q_sw;
1235  local_max_heating = std::max(local_max_heating, std::abs(Q_sw));
1236 
1237  d_above = d_m;
1238  F_net_above = F_net_m;
1239  if (m == 0) {
1240  sw_surface_absorbed = (1.0 - alb_dir) * beam_sfc + (1.0 - alb_dif) * d_m;
1241  }
1242  }
1243  }
1244 
1245  // ========================================================================
1246  // LONGWAVE: interface flux profiles, index m = 0 at the surface and
1247  // m = nlev at the TOA.
1248  // ========================================================================
1249 
1250  if (rad_choice.lw_enabled) {
1251  // Downward sweep: TOA -> surface. Also caches the per-layer LW optical
1252  // depth for the upward sweep.
1253  F_lw_down_iface(nlev) = 0.0; // No incoming LW from space
1254  for (int k = kmax; k >= kmin; --k) {
1255  const int m = k - kmin;
1256 
1257  amrex::Real rho = state_arr(i, j, k, Rho_comp);
1258  amrex::Real rho_theta = state_arr(i, j, k, RhoTheta_comp);
1259  if (rho <= 0.0 || !amrex::Math::isfinite(rho)) rho = 1.0;
1260  if (rho_theta <= 0.0 || !amrex::Math::isfinite(rho_theta)) rho_theta = 288.15;
1261  amrex::Real qv = get_qv_from_state(i, j, k, state_arr);
1262  amrex::Real T_layer = get_temperature_from_rhotheta(rho_theta, rho, qv);
1263 
1264  tau_lw_level(m) = diagnose_layer_tau(i, j, k, dz_level(m), z_level(m),
1265  state_arr, tau_lw_base, /*is_sw=*/false, cloudy,
1266  rad_choice);
1267 
1268  F_lw_down_iface(m) = compute_lw_flux_down(F_lw_down_iface(m + 1), T_layer, sigma, tau_lw_level(m));
1269  }
1270 
1271  // Upward sweep: surface -> TOA. The surface emits eps * sigma * T_s^4
1272  // and reflects the fraction (1 - eps) of the downwelling flux that
1273  // reaches it (gray surface, Kirchhoff's law).
1274  if (on_roof) {
1275  F_lw_up_iface(0) = grey_surface_lw_up(roof->emissivity, roof->temperature, F_lw_down_iface(0), sigma);
1276  } else {
1277  bool t_sfc_from_surface_layer = false;
1278  amrex::Real t_surface = resolve_surface_temp_k(
1279  i, j, lsm_t_sfc, has_lsm_t_sfc, seb_t_sfc, has_seb_t_sfc,
1280  surface_layer_theta, has_surface_layer, rad_choice,
1281  t_sfc_from_surface_layer);
1282  // The surface layer carries a potential temperature (MOST works in
1283  // theta); the emission needs the temperature, so convert with the
1284  // physical surface pressure diagnosed from the lowest atmospheric
1285  // cell.
1286  if (t_sfc_from_surface_layer) {
1287  const amrex::Real rho = state_arr(i, j, kmin, Rho_comp);
1288  const amrex::Real rho_theta = state_arr(i, j, kmin, RhoTheta_comp);
1289  const amrex::Real qv = get_qv_from_state(i, j, kmin, state_arr);
1290  const amrex::Real delta_z = z_level(0);
1291  const amrex::Real pressure = erf_surface_temperature::pressure_at_surface(
1292  rho, rho_theta, qv, delta_z);
1294  t_surface, pressure, rad_choice.rdOcp, t_surface)) {
1295  t_surface = rad_choice.t_sfc_default;
1296  }
1297  }
1298  amrex::Real emiss_lw = resolve_surface_emissivity_lw(i, j, hetero_emiss_lw, rad_choice, has_hetero_emiss_lw);
1299  F_lw_up_iface(0) = grey_surface_lw_up(emiss_lw, t_surface, F_lw_down_iface(0), sigma);
1300  }
1301  for (int k = kmin; k <= kmax; ++k) {
1302  const int m = k - kmin;
1303 
1304  amrex::Real rho = state_arr(i, j, k, Rho_comp);
1305  amrex::Real rho_theta = state_arr(i, j, k, RhoTheta_comp);
1306  if (rho <= 0.0 || !amrex::Math::isfinite(rho)) rho = 1.0;
1307  if (rho_theta <= 0.0 || !amrex::Math::isfinite(rho_theta)) rho_theta = 288.15;
1308  amrex::Real qv = get_qv_from_state(i, j, k, state_arr);
1309  amrex::Real T_layer = get_temperature_from_rhotheta(rho_theta, rho, qv);
1310 
1311  F_lw_up_iface(m + 1) = compute_lw_flux_up(F_lw_up_iface(m), T_layer, sigma, tau_lw_level(m));
1312  }
1313 
1314  // Per-level LW heating rate from the net-flux divergence across
1315  // each layer (bottom interface m, top interface m+1).
1316  for (int k = kmin; k <= kmax; ++k) {
1317  const int m = k - kmin;
1318  amrex::Real rho = state_arr(i, j, k, Rho_comp);
1319  if (rho <= 0.0 || !amrex::Math::isfinite(rho)) rho = 1.0;
1320  if (rad_flux_out != nullptr) {
1321  (*rad_flux_out)(i, j, k, 2) = F_lw_up_iface(m); // LW up at the lower interface of layer k
1322  (*rad_flux_out)(i, j, k, 3) = F_lw_down_iface(m); // LW down
1323  if (k == kmax) {
1324  (*rad_flux_out)(i, j, kmax + 1, 2) = F_lw_up_iface(nlev); // outgoing LW at the top
1325  (*rad_flux_out)(i, j, kmax + 1, 3) = F_lw_down_iface(nlev); // zero: nothing comes in from space
1326  }
1327  }
1328 
1329  amrex::Real F_net_top = F_lw_up_iface(m + 1) - F_lw_down_iface(m + 1);
1330  amrex::Real F_net_bot = F_lw_up_iface(m) - F_lw_down_iface(m);
1331 
1332  // dT/dt from the net-flux divergence, stored as dtheta/dt = (dT/dt)/pi.
1333  amrex::Real Q_lw = compute_lw_heating_rate(F_net_top, F_net_bot, dz_level(m), rho, cp_air)
1334  * get_inverse_exner(i, j, k, state_arr);
1335  qheating_arr(i, j, k, 1) = Q_lw;
1336 
1337  amrex::Real Q_sw_here = qheating_arr(i, j, k, 0);
1338  local_max_heating = std::max(local_max_heating, std::abs(Q_sw_here) + std::abs(Q_lw));
1339  }
1340  }
1341 
1342  // ========================================================================
1343  // SURFACE AND DIAGNOSTICS
1344  // ========================================================================
1345  if (sw_beam_absorbed_out != nullptr) {
1346  // Select the beam before any arithmetic: with the shortwave off or the sun down
1347  // the scratch was never written, and a product formed ahead of the selection
1348  // would raise the invalid flag on its signaling NaN.
1349  const bool lit = rad_choice.sw_enabled && cos_zenith > 0.0;
1350  const amrex::Real beam_low = lit ? F_dir(0) : amrex::Real(0.0);
1351  const amrex::Real beam_taken = on_roof ? roof->lit * beam_low : beam_low;
1352  *sw_beam_absorbed_out = (amrex::Real(1.0) - alb_dir) * beam_taken;
1353  }
1354  if (rad_choice.sw_enabled) {
1355  // Absorbed direct plus diffuse (see the SW block above)
1356  sw_surface_flux = sw_surface_absorbed;
1357  sw_up_toa = sw_up_at_toa;
1358  } else {
1359  sw_surface_flux = 0.0;
1360  sw_up_toa = 0.0;
1361  }
1362 
1363  if (rad_choice.lw_enabled) {
1364  amrex::Real F_lw_up_sfc = F_lw_up_iface(0);
1365  amrex::Real F_lw_down_sfc = F_lw_down_iface(0);
1366  lw_up_toa = F_lw_up_iface(nlev);
1367  lw_net_surface = F_lw_up_sfc - F_lw_down_sfc;
1368  } else {
1369  lw_net_surface = 0.0;
1370  lw_up_toa = 0.0;
1371  }
1372 
1373  max_heating_rate = local_max_heating;
1374 }
constexpr amrex::Real Cp_d
Definition: ERF_Constants.H:51
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real two_stream_cos_zenith(int i, int j, const TwoStreamParams &rad_choice, bool has_latlon, const amrex::Array4< const amrex::Real > *lat_arr, const amrex::Array4< const amrex::Real > *lon_arr)
Cosine of the solar zenith angle over column (i,j) for one call.
Definition: ERF_TwoStreamColumn.H:874
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real get_inverse_exner(int i, int j, int k, const amrex::Array4< const amrex::Real > &state_arr)
Inverse Exner function 1/pi at (i,j,k) from the state, with pi = (p / p_0)^(R_d/c_p) evaluated by get...
Definition: ERF_TwoStreamColumn.H:455
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolve_surface_albedo_sw(int i, int j, const amrex::Array4< const amrex::Real > *hetero_alb_sw, const TwoStreamParams &rad_choice, bool has_hetero_alb)
Resolve per-column shortwave surface albedo from hetero field or fallback.
Definition: ERF_TwoStreamColumn.H:245
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolve_surface_albedo_sw_diffuse(amrex::Real alb_dir, amrex::Real surface_albedo_sw_diffuse) noexcept
The ground's albedo for diffuse shortwave: the input surface_albedo_sw_diffuse, or the direct-beam al...
Definition: ERF_TwoStreamColumn.H:308
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void diagnose_layer_optics(int i, int j, int k, amrex::Real dz_layer, amrex::Real z_center, const amrex::Array4< const amrex::Real > &state_arr, amrex::Real tau_base, bool is_sw, bool cloudy, const TwoStreamParams &rad_choice, amrex::Real &tau, amrex::Real &omega, amrex::Real &g)
Optical depth, single-scattering albedo and asymmetry factor of layer k for one band,...
Definition: ERF_TwoStreamColumn.H:797
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real grey_surface_lw_up(amrex::Real emissivity, amrex::Real temperature, amrex::Real lw_down, amrex::Real sigma) noexcept
The longwave a gray surface sends up: what it emits and the part of the longwave coming down that it ...
Definition: ERF_TwoStreamColumn.H:295
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool two_stream_starts_on_roof(int k_lower, int kbot) noexcept
Whether a column starts on a roof: the layer on the roof, k_lower, is above the box's bottom layer kb...
Definition: ERF_TwoStreamColumn.H:284
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolve_surface_emissivity_lw(int i, int j, const amrex::Array4< const amrex::Real > *hetero_emiss_lw, const TwoStreamParams &rad_choice, bool has_hetero_emiss)
Resolve per-column longwave surface emissivity from hetero field or fallback.
Definition: ERF_TwoStreamColumn.H:328
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real resolve_surface_temp_k(int i, int j, const amrex::Array4< const amrex::Real > *lsm_t_sfc, bool has_lsm_t_sfc, const amrex::Array4< const amrex::Real > *seb_t_sfc, bool has_seb_t_sfc, const amrex::Array4< const amrex::Real > *surface_layer_theta, bool has_surface_layer, const TwoStreamParams &rad_choice, bool &from_surface_layer)
Resolve the per-column surface-temperature boundary condition.
Definition: ERF_TwoStreamColumn.H:374
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real compute_lw_flux_down(amrex::Real F_down_above, amrex::Real T_layer, amrex::Real sigma, amrex::Real tau_lw)
Compute downwelling LW flux in one layer of a two-stream sweep.
Definition: ERF_TwoStreamLW.H:188
constexpr amrex::Real stefan_boltzmann
Stefan-Boltzmann constant [W/(m^2 K^4)] used by the two-stream LW model.
Definition: ERF_TwoStreamLW.H:11
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real compute_lw_heating_rate(amrex::Real F_net_top, amrex::Real F_net_bot, amrex::Real dz, amrex::Real rho, amrex::Real cp)
Compute LW heating rate from net flux divergence.
Definition: ERF_TwoStreamLW.H:236
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real compute_lw_flux_up(amrex::Real F_up_below, amrex::Real T_layer, amrex::Real sigma, amrex::Real tau_lw)
Compute upwelling LW flux in one layer of a two-stream sweep.
Definition: ERF_TwoStreamLW.H:156
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real compute_sw_direct_flux(amrex::Real tau_cumulative, amrex::Real S0, amrex::Real cos_zenith)
Compute Beer-Lambert direct-beam flux at a given optical depth.
Definition: ERF_TwoStreamSW.H:72
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real compute_sw_heating_rate(amrex::Real flux_top, amrex::Real flux_bot, amrex::Real dz, amrex::Real rho, amrex::Real cp)
Compute the shortwave heating rate of a layer from the net (downward positive) flux at its top and bo...
Definition: ERF_TwoStreamSW.H:101
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE TwoStreamLayerSW compute_sw_layer_two_stream(amrex::Real tau, amrex::Real omega, amrex::Real g, amrex::Real cos_zenith)
Compute the two-stream layer solution for shortwave radiation.
Definition: ERF_TwoStreamSW.H:176
constexpr int F_DIR
Definition: ERF_TwoStreamColumn.H:652
constexpr int A
Definition: ERF_TwoStreamColumn.H:653
constexpr int Z
Definition: ERF_TwoStreamColumn.H:650
constexpr int TAU_LW
Definition: ERF_TwoStreamColumn.H:657
constexpr int LW_UP
Definition: ERF_TwoStreamColumn.H:655
constexpr int LW_DN
Definition: ERF_TwoStreamColumn.H:656
constexpr int S
Definition: ERF_TwoStreamColumn.H:654
constexpr int DZ
Definition: ERF_TwoStreamColumn.H:649
constexpr int TAU_SW
Definition: ERF_TwoStreamColumn.H:651
Definition: ERF_ConsoleIO.cpp:17
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real pressure_at_surface(const amrex::Real rho, const amrex::Real rho_theta, const amrex::Real qv, const amrex::Real delta_z)
Definition: ERF_SurfaceTemperature.H:112
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool theta_to_temperature(const amrex::Real theta, const amrex::Real pressure, const amrex::Real rdOcp, amrex::Real &temperature)
Definition: ERF_SurfaceTemperature.H:136
Two-stream reflectance and transmittance of one homogeneous layer.
Definition: ERF_TwoStreamSW.H:132
amrex::Real T_dir
Definition: ERF_TwoStreamSW.H:136
amrex::Real T_dif
Definition: ERF_TwoStreamSW.H:134
amrex::Real R_dif
Definition: ERF_TwoStreamSW.H:133
amrex::Real R_dir
Definition: ERF_TwoStreamSW.H:135
bool sw_enabled
Definition: ERF_TwoStreamColumn.H:58
amrex::Real tau_lw_per_layer
Definition: ERF_TwoStreamColumn.H:61
amrex::Real S0
Definition: ERF_TwoStreamColumn.H:115
bool lw_enabled
Definition: ERF_TwoStreamColumn.H:59
amrex::Real surface_albedo_sw_diffuse
Definition: ERF_TwoStreamColumn.H:74
amrex::Real rdOcp
Definition: ERF_TwoStreamColumn.H:77
amrex::Real tau_per_layer
Definition: ERF_TwoStreamColumn.H:60
amrex::Real emissivity
Longwave emissivity of the roof [1].
Definition: ERF_TwoStreamColumn.H:273
amrex::Real albedo
Shortwave albedo of the roof, for the beam and for diffuse light [1].
Definition: ERF_TwoStreamColumn.H:272
amrex::Real lit
Share of the direct beam that reaches the roof: 0 where a taller building shades it [1].
Definition: ERF_TwoStreamColumn.H:275
int k_lower
First cell of the column above the roof (the roof is its lower interface)
Definition: ERF_TwoStreamColumn.H:271
amrex::Real temperature
Skin temperature of the roof [K].
Definition: ERF_TwoStreamColumn.H:274

Referenced by TwoStreamRadiation::advance().

Here is the call graph for this function:
Here is the caller graph for this function: