commit a4a4845d16c1975d036f1659ce4480ae1308a9dd
parent 503ac4babaa86f968cdc87a526342e6d149f3559
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 1 Sep 2025 15:57:37 +0200
stardis: fix boundary flux and emissivity
Latent flux was not taken into account in the Stardis function returning
the limit flux.
Emissivity was always calculated based on the albedo of the ground, even
though this albedo concerns only short waves. If the radiation source is
internal to the system, the ground is assumed to be a black body, i.e.
its emissivity is equal to 1.
Diffstat:
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/smeteo.h b/src/smeteo.h
@@ -48,7 +48,7 @@ struct smeteo_entry {
double SWup; /* Shortwave upward flux [W/m^2] */
double Trad; /* Radiative temperature [K] */
double H; /* Convection coefficient [W/K/m^2] */
- double LE; /* Latent flux >0 from ground to atmosphere [W/m^2 ] */
+ double LE; /* Latent flux >0 from ground to atmosphere [W/m^2] */
/* Time as a fraction of a day since 00:00 on 1 january 1859 */
double day_1850;
diff --git a/src/stardis_smeteo.c b/src/stardis_smeteo.c
@@ -20,6 +20,10 @@
#include <rsys/algorithm.h>
#include <rsys/mem_allocator.h>
+/* FIXME required by the UINT_MAX constant used in the stardis-prog-properties
+ * header. It should by stardis, not by the caller. */
+#include <limits.h>
+
struct boundary_condition {
struct stardis_smeteo_lib* lib;
struct stardis_smeteo_lib_desc lib_desc;
@@ -189,7 +193,9 @@ stardis_boundary_flux
+ bcond->lib_desc.smeteo_desc.entries[i].SWdn_diffuse;
/* Net flux on the ground side, i.e. the downward flux - upward flux */
- net_flux = SWdn - bcond->lib_desc.smeteo_desc.entries[i].SWup;
+ net_flux = SWdn
+ - bcond->lib_desc.smeteo_desc.entries[i].SWup
+ - bcond->lib_desc.smeteo_desc.entries[i].LE;
return net_flux;
}
@@ -213,9 +219,13 @@ stardis_emissivity
{
struct boundary_condition* bcond = data;
ASSERT(data);
- (void)frag, (void)source_id; /* Avoid "unused variable" warning */
+ (void)frag; /* Avoid "unused variable" warning */
- return 1 - bcond->lib_desc.smeteo_desc.albedo;
+ if(source_id == STARDIS_INTERN_SOURCE_ID) {
+ return 1;
+ } else {
+ return 1 - bcond->lib_desc.smeteo_desc.albedo;
+ }
}
/* Specular part of the BRDF of the ground */
diff --git a/src/test_stardis_smeteo.c b/src/test_stardis_smeteo.c
@@ -140,8 +140,7 @@ check_getters(void* data, const struct smeteo* smeteo)
CHK(stardis_reference_temperature(&frag, data) == entry->Tsrf);
CHK(stardis_boundary_temperature(&frag, data) == entry->Tsrf);
CHK(stardis_medium_temperature(&vtx, data) == entry->Tatm);
- CHK(stardis_emissivity(&frag, STARDIS_INTERN_SOURCE_ID, data)
- == 1.0 - desc.albedo);
+ CHK(stardis_emissivity(&frag, STARDIS_INTERN_SOURCE_ID, data) == 1.0);
}
}