stardis-test

Test Stardis behaviors
git clone git://git.meso-star.fr/stardis-test.git
Log | Files | Refs | README | LICENSE

commit b886d9c03a3a53fb4066a2b5a131a078b50f20a3
parent 7c75e8888de4fbfa9633f2f6623cd248574c2a08
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon,  8 Apr 2024 16:15:20 +0200

Add unsteady profile

This new profile will be used to check the unsteady configuration. Note
that this profile manages power density and therefore provides a
function for calculating power during random walk. Consequently, the
profile offers 2 functions, suffixed by the calculated value, which is
temperature and power. To ensure name consistency, we've also renamed
the trilinear profile function accordingly, suffixing it with
temperature.

Diffstat:
Msrc/sadist.h | 80++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Msrc/sadist_lib_trilinear_profile.c | 2+-
Msrc/sadist_probe_boundary.c | 4++--
3 files changed, 82 insertions(+), 4 deletions(-)

diff --git a/src/sadist.h b/src/sadist.h @@ -17,8 +17,12 @@ #define SADIST_H #include <rsys/rsys.h> +#include <math.h> #include <errno.h> /* EINVAL */ +/******************************************************************************* + * Trilinear profile + ******************************************************************************/ struct sadist_trilinear_profile { /* Spatial range in which the trilinear profile is defined */ double lower[3]; @@ -45,7 +49,7 @@ sadist_trilinear_profile_check(const struct sadist_trilinear_profile* profile) } static INLINE double -sadist_trilinear_profile +sadist_trilinear_profile_temperature (const struct sadist_trilinear_profile* profile, const double p[3]) { @@ -59,6 +63,80 @@ sadist_trilinear_profile + w * (profile->c[1] - profile->c[0]) + profile->c[0]; } +/******************************************************************************* + * Unsteady profile + ******************************************************************************/ +struct sadist_unsteady_profile { + double A; /* Influence of the thermal source */ + double B1; /* Influence of space variation */ + double B2; /* Influence of spatio-temporal variations */ + + double kx; /* Spatio-temporal periodicity in X */ + double ky; /* Spatio-temporal periodicity in Y */ + double kz; /* Spatio-temporal periodicity in Z */ + + double lambda; /* Thermal conductivity [W/m/K] */ + double rho; /* Volumic mass [kg/m^3] */ + double cp; /* Calorific capacity [J/K/kg] */ +}; +#define SADIST_UNSTEADY_PROFILE_NULL__ {0,0,0,0,0,0,0,0,0} +static const struct sadist_unsteady_profile SADIST_UNSTEADY_PROFILE_NULL = + SADIST_UNSTEADY_PROFILE_NULL__; + +static INLINE double +sadist_unsteady_profile_temperature + (const struct sadist_unsteady_profile* profile, + const double pos[3], + const double time) +{ + double alpha; /* Diffusivity */ + double kx, ky, kz; + double x, y, z, t; + double a, b, c; + double temp; + + ASSERT(profile && pos); + + x = pos[0]; + y = pos[1]; + z = pos[2]; + t = time; + + alpha = profile->lambda / (profile->rho*profile->cp); + + kx = profile->kx; + ky = profile->ky; + kz = profile->kz; + + a = (x*x*x*z-3*x*y*y*z); + b = sin(kx*x)*sin(ky*y)*sin(kz*z)*exp(-alpha*(kx*kx + ky*ky + kz*kz)*t); + c = x*x*x*x * y*y*y * z*z; + + temp = (profile->B1*a + profile->B2*b - profile->A*c) / profile->lambda; + return temp; +} + +static INLINE double +sadist_unsteady_profile_power + (const struct sadist_unsteady_profile* profile, + const double pos[3]) +{ + double x, y, z; + double p; + ASSERT(profile && pos); + + x = pos[0]; + y = pos[1]; + z = pos[2]; + + p = 12*x*x*y*y*y*z*z + 6*x*x*x*x*y*z*z + 2*x*x*x*x*y*y*y; + p = profile->A * p; + return p; +} + +/******************************************************************************* + * Miscellaneous + ******************************************************************************/ static INLINE void sadist_write_stl (FILE* stream, diff --git a/src/sadist_lib_trilinear_profile.c b/src/sadist_lib_trilinear_profile.c @@ -227,7 +227,7 @@ stardis_boundary_temperature void* data) { ASSERT(frag && data); - return sadist_trilinear_profile(data, frag->P); + return sadist_trilinear_profile_temperature(data, frag->P); } double* diff --git a/src/sadist_probe_boundary.c b/src/sadist_probe_boundary.c @@ -364,7 +364,7 @@ run1(const struct sadist_trilinear_profile* profile) goto error; } - ref = sadist_trilinear_profile(profile, P); + ref = sadist_trilinear_profile_temperature(profile, P); printf("T = %g ~ %g +/- %g\n", ref, E, SE); if(!eq_eps(ref, E, SE*3)) { err = 1; @@ -443,7 +443,7 @@ runN(const struct sadist_trilinear_profile* profile, const size_t nprobes) const double* P = probes + i*3; const double E = results[i*2 + 0]; const double SE = results[i*2 + 1]; - const double ref = sadist_trilinear_profile(profile, P); + const double ref = sadist_trilinear_profile_temperature(profile, P); printf("T = %g ~ %g +/- %g\n", ref, E, SE); if(!eq_eps(ref, E, SE*3)) {