commit 77d57dc9458b328202a2e7b55b6af2ab0adf898d
parent 957b54083396493815892a5ad51d929d9cfd0bc6
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 23 Oct 2025 22:37:10 +0200
stardis: split the imposed flux solar and latent components
The user can define which part of the flux to take into account when the
plugin is used to define a connection condition or a limit condition.
Thus, the latent flux can be added to the ground interface, while the
solar flux is calculated from an external source representing the sun.
Diffstat:
5 files changed, 44 insertions(+), 30 deletions(-)
diff --git a/Makefile b/Makefile
@@ -274,6 +274,7 @@ Tsrf.pdf: $(PLUGIN) Tsrf.txt src/plot.gp
gnuplot -e "Tsrf='Tsrf.txt'" src/plot.gp > Tsrf.pdf
Tsrf.txt: \
+ libstardis_smeteo.so \
src/test_stardis_smeteo_ground_temperature.sh \
samples/star-meteo_input.txt
$(SHELL) src/test_stardis_smeteo_ground_temperature.sh \
diff --git a/doc/libstardis_smeteo.3 b/doc/libstardis_smeteo.3
@@ -12,7 +12,7 @@
.\"
.\" You should have received a copy of the GNU Lesser General Public License
.\" along with this program. If not, see <http://www.gnu.org/licenses/>.
-.Dd October 17, 2025
+.Dd October 23, 2025
.Dt LIBSTARDIS_SMETEO 3
.Os
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@@ -68,7 +68,7 @@ and
parameters are meaningful to the
.Xr stardis 1
user.
-They reflect the options that it can define via this programmable
+They reflect the options that he can define via this programmable
interface
.Po
see the
@@ -178,7 +178,7 @@ arguments of the
function of a C program whose synopsis would be:
.Pp
.Nm stardis-smeteo-phyprop
-.Op Fl fh
+.Op Fl hls
.Op Fl t Ar temperature
.Pp
except for the name of the program, i.e.
@@ -190,9 +190,6 @@ file.
.Pp
The options are as follows:
.Bl -tag -width Ds
-.It Fl f
-When used to declare a boundary condition or a connection condition,
-solar flux is taken into account as an imposed flux at the interface.
.It Fl h
When used to declare a boundary condition or a connection condition, the
interface convection coefficient is retrieved from the meteorological
@@ -200,6 +197,12 @@ data loaded by the library instance
.Pq see Xr smeteo 5 .
If this option is not defined, the interface convection coefficient is
assumed to be zero.
+.It Fl l
+When used to declare a boundary condition or a connection condition,
+latent flux is taken into account as an imposed flux at the interface.
+.It Fl s
+When used to declare a boundary condition or a connection condition,
+solar flux is taken into account as an imposed flux at the interface.
.It Fl t Ar temperature
When used to declare a Dirichlet boundary condition, set the interface
temperature to
@@ -233,8 +236,8 @@ file, defines a slab whose lower surface has a fixed temperature of
284K.
A Robin+Neumann boundary condition is imposed on its upper surface.
Its convection coefficient, fluid temperature (i.e., atmosphere), and
-imposed flux are retrieved from meteorological data. the latter
-representing the solar flux imposed on the interface.
+imposed flux are retrieved from meteorological data
+.Pq solar and latent .
The other surfaces are adiabatic to simulate an infinite slab:
.Bd -literal -offset Ds
# Configure the plugin to use the meteorological data stored
@@ -247,7 +250,7 @@ SOLID ground 1 1500 1500 0.02 281.85 UNKNOWN 0 FRONT ground.stl
# Use the "Meteo" plugin to define convective exchange between
# the surface and the atmosphere and take into account solar
# contribution by imposing a flux
-HF_BOUNDARY_FOR_SOLID_PROG atm Meteo ground_Z.stl PROG_PARAMS -hf
+HF_BOUNDARY_FOR_SOLID_PROG atm Meteo ground_Z.stl PROG_PARAMS -hls
# Fix the underground temperature to 284 K
T_BOUNDARY_FOR_SOLID underground 284.0 ground_z.stl
@@ -263,6 +266,7 @@ file defines the ground as a slab-shaped geometry immersed in a fluid
whose temperature is retrieved from meteorological data.
A convective exchange is added between the atmosphere and the ground
using the convection coefficient described in the meteorological data.
+The latent flux is defined as a flux imposed on this same interface.
The underground temperature is fixed to 284 K.
The contribution of the sun is modeled by an external spherical source
with a radius of 6.987e8 m, whose position is calculated by
@@ -288,7 +292,7 @@ FLUID_PROG atmosphere Meteo BACK ground.stl
# Use the "Meteo" plugin to add a convective exchange
# between the ground surface and the atmosphere
-SOLID_FLUID_CONNECTION_PROG hdT Meteo ground_Z.stl PROG_PARAMS -h
+SOLID_FLUID_CONNECTION_PROG hdT Meteo ground_Z.stl PROG_PARAMS -hl
# Fix the underground temperature to 284 K
SOLID_FLUID_CONNECTION_PROG ut Meteo ground_z.stl PROG_PARAMS -t284
diff --git a/src/stardis_smeteo.c b/src/stardis_smeteo.c
@@ -35,10 +35,17 @@
#define EARTH_TO_SUN_DST 149.5978707e9 /* [m] */
+enum flux_cpnt {
+ FLUX_SW = BIT(0), /* Shortwave flux */
+ FLUX_LATENT = BIT(1), /* Latent flux */
+ FLUX_ALL = ~0, /* All components are handled in flux computation */
+ FLUX_NONE = 0 /* No flux is imposed */
+};
+
struct args {
double temperature; /* Take precedence on meteorological data [K] */
int convection; /* Enable convection */
- int imposed_flux; /* Enable imposed flux */
+ int imposed_flux; /* Imposed flux mask. combination of flux_cpnt */
};
#define ARGS_DEFAULT__ {STARDIS_TEMPERATURE_NONE, 0, 0}
static const struct args ARGS_DEFAULT = ARGS_DEFAULT__;
@@ -59,8 +66,7 @@ static void
usage(FILE* stream, const char* name)
{
ASSERT(stream && name);
- fprintf(stream, "usage: %s [-fh] [-t temperature]\n", name);
-
+ fprintf(stream, "usage: %s [-hls] [-t temperature]\n", name);
}
static res_T
@@ -73,10 +79,11 @@ args_init(struct args* args, int argc, char* argv[])
*args = ARGS_DEFAULT;
optind = 1;
- while((opt=getopt(argc, argv, "hft:")) != -1) {
+ while((opt=getopt(argc, argv, "hlst:")) != -1) {
switch(opt) {
case 'h': args->convection = 1; break;
- case 'f': args->imposed_flux = 1; break;
+ case 'l': args->imposed_flux |= FLUX_LATENT; break;
+ case 's': args->imposed_flux |= FLUX_SW; break;
case 't':
res = cstr_to_double(optarg, &args->temperature);
break;
@@ -300,28 +307,30 @@ stardis_boundary_flux
void* data)
{
struct boundary_condition* bcond = data;
+ double flux = 0; /* [W/m^2] */
+ size_t i = 0;
ASSERT(frag && data);
- if(!bcond->args.imposed_flux) {
+ if(bcond->args.imposed_flux == FLUX_NONE) {
return STARDIS_FLUX_NONE;
+ }
- } else {
- double net_flux = 0; /* [W/m^2] */
- double SWdn = 0; /* shortwave downward flux [W/m^2] */
- size_t i = 0;
+ i = get_meteo_entry_id(bcond, frag->time);
- i = get_meteo_entry_id(bcond, frag->time);
+ if(bcond->args.imposed_flux & FLUX_LATENT) {
+ flux += -bcond->lib_desc.smeteo_desc.entries[i].LE;
+ }
+ if(bcond->args.imposed_flux & FLUX_SW) {
+ double SWdn = 0; /* shortwave downward flux [W/m^2] */
SWdn = bcond->lib_desc.smeteo_desc.entries[i].SWdn_direct
+ 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
- - bcond->lib_desc.smeteo_desc.entries[i].LE;
-
- return net_flux;
+ /* Flux on the ground side, i.e. the downward flux - upward flux */
+ flux += SWdn - bcond->lib_desc.smeteo_desc.entries[i].SWup;
}
+
+ return flux;
}
double /* [K] */
diff --git a/src/test_stardis_smeteo.c b/src/test_stardis_smeteo.c
@@ -74,7 +74,7 @@ static void*
check_data_api(void* lib)
{
struct stardis_description_create_context ctx = {0};
- char* argv[2] = {"smeteo", "-hf"};
+ char* argv[2] = {"smeteo", "-hls"};
size_t argc = sizeof(argv)/sizeof(char*);
void* data = NULL;
diff --git a/src/test_stardis_smeteo_ground_temperature.sh b/src/test_stardis_smeteo_ground_temperature.sh
@@ -114,7 +114,7 @@ stardis_input_imposed_flux()
# 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'
- echo 'HF_BOUNDARY_FOR_SOLID_PROG atm Meteo ground_Z.stl PROG_PARAMS -hf'
+ echo 'HF_BOUNDARY_FOR_SOLID_PROG atm Meteo ground_Z.stl PROG_PARAMS -hls'
echo 'TRAD_PROG Meteo'
}
@@ -130,7 +130,7 @@ stardis_input_external_source()
echo ''
# Connection
- echo 'SOLID_FLUID_CONNECTION_PROG ground_sky_connect Meteo ground_Z.stl PROG_PARAMS -h'
+ echo 'F_SOLID_FLUID_CONNECTION_PROG ground_sky_connect Meteo ground_Z.stl PROG_PARAMS -hl'
echo 'SOLID_FLUID_CONNECTION adiabatic 300 0 0 0 ground_xXyY.stl'
echo ''