htrdr

Solving radiative transfer in heterogeneous media
git clone git://git.meso-star.fr/htrdr.git
Log | Files | Refs | README | LICENSE

commit ba48d2de98321966d59961a2bcbc51a6ad103fa7
parent 32d231f97abea09e0aac1feb0e2361f3e45411cd
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 20 Feb 2025 14:45:22 +0100

planets: fixing the longwave volume radiation balance

In longwave, the gas temperature at the sampled position must be treated
as a source. But this position position may be outside the gas. This
commit handles this case by returning a zero source.

Diffstat:
Msrc/planets/htrdr_planets_solve_volrad_budget.c | 16++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/planets/htrdr_planets_solve_volrad_budget.c b/src/planets/htrdr_planets_solve_volrad_budget.c @@ -131,19 +131,27 @@ get_source switch(cmd->spectral_domain.type) { case HTRDR_SPECTRAL_SW: /* In shortwave, the source is external to the system */ - source = 0; + source = 0; /* [W/m^2/sr/m] */ break; case HTRDR_SPECTRAL_LW: RNATM(fetch_cell(cmd->atmosphere, pos, RNATM_GAS, &cell_pos)); - RNATM(cell_get_gas_temperature(cmd->atmosphere, &cell_pos, &temperature)); - source = htrdr_planck_monochromatic(wlen_m, temperature); /* [W/m^2/sr/m] */ + + if(SUVM_PRIMITIVE_NONE(&cell_pos.prim)) { + /* The position is not in the gas */ + source = 0; /* [W/m^2/sr/m] */ + + } else { + /* Fetch the source temperature */ + RNATM(cell_get_gas_temperature(cmd->atmosphere, &cell_pos, &temperature)); + source = htrdr_planck_monochromatic(wlen_m, temperature); /* [W/m^2/sr/m] */ + } break; default: FATAL("Unreachable code\n"); break; } - return source; + return source; /* [W/m^2/sr/m] */ } /* Return the total absorption coefficient,