commit 115bad87c6620c836b7b1540ed4aabc7c91b466b
parent 7a3308ceba47528a8a785dc0de138458f77d054f
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Sun, 14 Apr 2024 14:03:28 +0200
Add t_range function to programmable radiative environment
Stardis automatically calculates the system's temperature range. This is
then used by the solver to linearize the radiative transfer. Stardis
calculates minimum and maximum temperatures from boundary and initial
conditions. Although these are directly accessible by Stardis when using
constants, it relies on a user-side function for programmable
properties. This function returns, for each programmable property, the
range of temperatures it can take.
However, the radiative environment, which is no longer necessarily
constant, did not provide a function returning its temperature range.
Hence this commit, in which we add the stardis_t_range function as an
expected function of a programmable radiative environment. We then call
it during the initialization step to update the temperature range
accordingly.
Diffstat:
3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/src/stardis-parsing.c b/src/stardis-parsing.c
@@ -2063,6 +2063,7 @@ process_radiative_prog(struct stardis* stardis, wordexp_t* pwordexp)
{
struct stardis_description_create_context ctx;
struct radiative_env_prog* radenv = NULL;
+ double radenv_t_range[2] = {DBL_MAX, -DBL_MAX};
char* lib_name = NULL;
char* arg = NULL;
size_t idx = 1;
@@ -2102,6 +2103,8 @@ process_radiative_prog(struct stardis* stardis, wordexp_t* pwordexp)
stardis_radiative_env_temperature);
GET_LIB_SYMBOL(radenv, reference_temperature,
stardis_radiative_env_reference_temperature);
+ GET_LIB_SYMBOL(radenv, t_range,
+ stardis_t_range);
ctx.name = "Radiative environment";
radenv->data = radenv->create
@@ -2113,6 +2116,10 @@ process_radiative_prog(struct stardis* stardis, wordexp_t* pwordexp)
goto error;
}
+ radenv->t_range(radenv->data, radenv_t_range);
+ stardis->t_range[0] = MMIN(stardis->t_range[0], radenv_t_range[0]);
+ stardis->t_range[1] = MMAX(stardis->t_range[1], radenv_t_range[1]);
+
exit:
return res;
error:
diff --git a/src/stardis-prog-properties.h.in b/src/stardis-prog-properties.h.in
@@ -637,6 +637,17 @@ stardis_radiative_env_reference_temperature
(const double dir[3],
void* data);
+/* Computes the expected temperature range for this radiative
+ * environment.
+ * This functions is called once when initializing the computation.
+ * data is the pointer returned by stardis_create_data for this
+ * radiative environment.
+ * Returns its modified range argument. */
+STARDIS_API double*
+stardis_t_range
+ (void* data,
+ double range[2]);
+
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/src/stardis-radiative-env.h b/src/stardis-radiative-env.h
@@ -68,9 +68,14 @@ struct radiative_env_prog {
(*reference_temperature)
(const double dir[3],
void* data);
+
+ double*
+ (*t_range)
+ (void* data,
+ double t_range[2]);
};
#define RADIATIVE_ENV_PROG_NULL__ \
- {{0}, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL}
+ {{0}, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL}
static const struct radiative_env_prog RADIATIVE_ENV_PROG_NULL =
RADIATIVE_ENV_PROG_NULL__;