commit f79d2663ea0eda1ebfb2e782a9e7ff00075e184b
parent 301beadc3a1c046d053022125f40e244910f2ca4
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 2 Sep 2025 14:58:06 +0200
Stardis: define the radiative temperatures
The plugin did not provide the functions needed to retrieve time-varying
radiative temperatures loaded from meteorological data. Stardis
therefore used its default radiative temperature, which was clearly
incorrect for the system being simulated.
In any case, the test that calculates the ground temperature still does
not give the result of the meteorological file. This may be due to
incorrect thermophysical properties, such as the emissivity of the
ground, which is currently assumed to be 1 on long waves.
Diffstat:
5 files changed, 79 insertions(+), 34 deletions(-)
diff --git a/src/stardis_smeteo.c b/src/stardis_smeteo.c
@@ -18,6 +18,7 @@
#include "stardis_smeteo_library.h"
#include <rsys/algorithm.h>
+#include <rsys/math.h>
#include <rsys/mem_allocator.h>
/* FIXME required by the UINT_MAX constant used in the stardis-prog-properties
@@ -249,19 +250,6 @@ stardis_reference_temperature
return stardis_boundary_temperature(frag, data);
}
-/* Range of reference temperature, i.e. range of ground temperature from the
- * entire set of surface temperatures */
-double*
-stardis_t_range(void* data, double range[2] /* [K] */)
-{
- struct boundary_condition* bcond = data;
- ASSERT(data && range);
-
- range[0] = bcond->lib_desc.surface_temperatue_range[0];
- range[1] = bcond->lib_desc.surface_temperatue_range[1];
- return range;
-}
-
/* Ground temperature */
double /* [K] */
stardis_boundary_temperature
@@ -276,6 +264,43 @@ stardis_boundary_temperature
return bcond->lib_desc.smeteo_desc.entries[i].Tsrf;
}
+double /* [K] */
+stardis_radiative_env_temperature
+ (const double time, /* [s] */
+ const double dir[3],
+ void* data)
+{
+ struct boundary_condition* bcond = data;
+ size_t i = 0; /* Index of the meteo entry including fragment time */
+ ASSERT(time && dir && data);
+ (void)data; /* Avoid "unused variable" warning */
+
+ i = get_meteo_entry_id(bcond, time);
+ return bcond->lib_desc.smeteo_desc.entries[i].Trad;
+}
+
+double /* [K] */
+stardis_radiative_env_reference_temperature
+ (const double time, /* [s] */
+ const double dir[3],
+ void* data)
+{
+ return stardis_radiative_env_temperature(time, dir, data);
+}
+
+/* Range of reference temperature, i.e. range of ground temperature from the
+ * entire set of surface temperatures */
+double*
+stardis_t_range(void* data, double range[2] /* [K] */)
+{
+ struct boundary_condition* bcond = data;
+ ASSERT(data && range);
+
+ range[0] = MMIN(bcond->lib_desc.Tsrf_range[0], bcond->lib_desc.Trad_range[0]);
+ range[1] = MMAX(bcond->lib_desc.Tsrf_range[1], bcond->lib_desc.Trad_range[1]);
+ return range;
+}
+
const char*
get_copyright_notice(void* data)
{
diff --git a/src/stardis_smeteo.h b/src/stardis_smeteo.h
@@ -119,8 +119,24 @@ stardis_reference_temperature
(const struct stardis_interface_fragment* frag,
void* data);
-/* Range of reference ground temperatures calculated from the entire set of
- * surface temperatures provided by meteorological data */
+
+/* Radiative temperature obtained from meteorological data. This is the to
+ * calculate radiative exchanges between the ground and the sky */
+STARDIS_API double
+stardis_radiative_env_temperature
+ (const double time, /* [s] */
+ const double dir[3],
+ void* data);
+
+/* Reference sky temperature used to linearized radiative transfert */
+STARDIS_API double
+stardis_radiative_env_reference_temperature
+ (const double time, /* [s] */
+ const double dir[3],
+ void* data);
+
+/* Range of reference temperatures calculated from the entire set of surface
+ * temperatures and the radiative temperatures provided by meteorological data */
STARDIS_API double* /* <=> range */
stardis_t_range
(void* data,
diff --git a/src/stardis_smeteo_library.c b/src/stardis_smeteo_library.c
@@ -28,7 +28,8 @@ struct stardis_smeteo_lib {
struct smeteo* smeteo;
struct str filename; /* Filename of the loaded smeteo file */
double max_convection_coef;
- double surface_temperatue_range[2];
+ double Tsrf_range[2]; /* Range of the surface temperatures [K] */
+ double Trad_range[2]; /* Range of the radiative temperatures [K] */
ref_T ref;
};
@@ -75,7 +76,8 @@ setup_smeteo
struct smeteo_desc desc = SMETEO_DESC_NULL;
double max_H = -DBL_MAX;
- double t_range[2] = {DBL_MAX, -DBL_MAX};
+ double Trad_range[2] = {DBL_MAX, -DBL_MAX};
+ double Tsrf_range[2] = {DBL_MAX, -DBL_MAX};
size_t i = 0;
res_T res = RES_OK;
@@ -94,13 +96,17 @@ setup_smeteo
FOR_EACH(i, 0, desc.nentries) max_H = MMAX(desc.entries[i].H, max_H);
lib->max_convection_coef = max_H;
- /* Retrieve the ground temperature range from meteorological data */
+ /* Retrieve the ground/radiative temperature range from meteorological data */
FOR_EACH(i, 0, desc.nentries) {
- t_range[0] = MMIN(desc.entries[i].Tsrf, t_range[0]);
- t_range[1] = MMAX(desc.entries[i].Tsrf, t_range[1]);
+ Tsrf_range[0] = MMIN(desc.entries[i].Tsrf, Tsrf_range[0]);
+ Tsrf_range[1] = MMAX(desc.entries[i].Tsrf, Tsrf_range[1]);
+ Trad_range[0] = MMIN(desc.entries[i].Trad, Trad_range[0]);
+ Trad_range[1] = MMAX(desc.entries[i].Trad, Trad_range[1]);
}
- lib->surface_temperatue_range[0] = t_range[0];
- lib->surface_temperatue_range[1] = t_range[1];
+ lib->Tsrf_range[0] = Tsrf_range[0];
+ lib->Tsrf_range[1] = Tsrf_range[1];
+ lib->Trad_range[0] = Trad_range[0];
+ lib->Trad_range[1] = Trad_range[1];
exit:
return res;
@@ -193,6 +199,8 @@ stardis_smeteo_lib_get_desc
SMETEO(get_desc(lib->smeteo, &desc->smeteo_desc));
desc->filename = str_cget(&lib->filename);
desc->max_convection_coef = lib->max_convection_coef;
- desc->surface_temperatue_range[0] = lib->surface_temperatue_range[0];
- desc->surface_temperatue_range[1] = lib->surface_temperatue_range[1];
+ desc->Tsrf_range[0] = lib->Tsrf_range[0];
+ desc->Tsrf_range[1] = lib->Tsrf_range[1];
+ desc->Trad_range[0] = lib->Trad_range[0];
+ desc->Trad_range[1] = lib->Trad_range[1];
}
diff --git a/src/stardis_smeteo_library.h b/src/stardis_smeteo_library.h
@@ -22,7 +22,8 @@ struct stardis_smeteo_lib_desc {
const char* filename;
struct smeteo_desc smeteo_desc;
double max_convection_coef;
- double surface_temperatue_range[2];
+ double Tsrf_range[2]; /* Range of surface temperatures [K] */
+ double Trad_range[2]; /* Range of radiative temperatures [K] */
};
#define STARDIS_SMETEO_LIB_DESC_NULL__ {0}
static const struct stardis_smeteo_lib_desc STARDIS_SMETEO_LIB_DESC_NULL =
diff --git a/src/test_stardis_smeteo_ground_temperature.sh b/src/test_stardis_smeteo_ground_temperature.sh
@@ -114,11 +114,8 @@ stardis_input()
# Limit condition
echo 'H_BOUNDARY_FOR_SOLID adiabatic 0 0 0 0 0 ground_xXyY.stl'
echo 'T_BOUNDARY_FOR_SOLID underground 284.0 ground_z.stl'
-
- # FIXME This condition should involve a radiative exchange, but the
- # Stardis syntax does not yet allow this type of connection to be
- # described.
echo 'HF_BOUNDARY_FOR_SOLID_PROG atmosphere Meteo ground_Z.stl'
+ echo 'TRAD_PROG Meteo'
}
########################################################################
@@ -143,8 +140,6 @@ stardis -V3 -M stardis_model.txt -s ground_Z.stl,"${time}"
# surface temperature provided by the Meteorological file at the time of
# observation. The test has not yet been performed because the system
# parameters may not correspond to the system used to generate the input
-# meteorlogical data. For example, the depth of the underground is
-# arbitrarily set at 30 meters with a fixed temperature of 293 K.
-# Similarly, the thermophysical properties of the ground still need to
-# be verified to ensure that they match those used to calculate the
-# surface temperature in the smeteo file.
+# meteorlogical data. For example the thermophysical properties of the
+# ground still need to be verified to ensure that they match those used
+# to calculate the surface temperature in the smeteo file.