commit 9efa0ecaa9672f08a1da087d16cb4316f0944b75
parent 763b8bf10c40e36b54c8448a6cbcd0443ec7494f
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 18 Apr 2024 11:57:46 +0200
Fix external flux test in relation to stardis updates
The external source now has a new parameter to define its diffuse
radiance. This commit updates the stardis input data in relation to
changes in its input format for its stardis-input file and the library
used to program the external source parameters.
Diffstat:
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/src/sadist_external_flux.c b/src/sadist_external_flux.c
@@ -128,7 +128,7 @@ setup_scene(FILE* fp)
pos[0] = cos(elevation) * SOURCE_DISTANCE;
pos[1] = sin(elevation) * SOURCE_DISTANCE;
pos[2] = 0;
- fprintf(fp, "SPHERICAL_SOURCE 6.5991756e8 %f %f %f 3.845e26\n",
+ fprintf(fp, "SPHERICAL_SOURCE 6.5991756e8 %f %f %f 3.845e26 0\n",
pos[0], pos[1], pos[2]);
}
@@ -154,7 +154,7 @@ setup_scene_prog(FILE* fp)
pos[2] = 0;
fprintf(fp, "SPHERICAL_SOURCE_PROG "STR(SOURCE_RADIUS)" source "
- "PROG_PARAMS dummy -p %f,%f,%f -w "STR(SOURCE_POWER)"\n",
+ "PROG_PARAMS dummy -d 0 -p %f,%f,%f -w "STR(SOURCE_POWER)"\n",
pos[0], pos[1], pos[2]);
}
diff --git a/src/sadist_lib_spherical_source.c b/src/sadist_lib_spherical_source.c
@@ -24,8 +24,9 @@
struct source {
double position[3];
double power; /* [W] */
+ double diffuse_radiance; /* [W/m^2/sr] */
};
-#define SOURCE_NULL__ {{0,0,0}, 0}
+#define SOURCE_NULL__ {{0,0,0}, 0, 0}
static const struct source SOURCE_NULL = SOURCE_NULL__;
/*******************************************************************************
@@ -35,7 +36,9 @@ static void
print_usage(FILE* stream, const char* name)
{
ASSERT(name);
- fprintf(stream, "usage: %s [-h] [-p x,y,z] [-w power]\n", name);
+ fprintf(stream,
+ "usage: %s [-h] [-d diffuse_radiance] [-p x,y,z] [-w power]\n",
+ name);
}
static res_T
@@ -51,8 +54,12 @@ parse_args
ASSERT(ctx && source);
optind = 1;
- while((opt = getopt(argc, argv, "hp:w:")) != -1) {
+ while((opt = getopt(argc, argv, "d:hp:w:")) != -1) {
switch(opt) {
+ case 'd':
+ res = cstr_to_double(optarg, &source->diffuse_radiance);
+ if(res == RES_OK && source->diffuse_radiance < 0) res = RES_BAD_ARG;
+ break;
case 'h':
print_usage(stdout, ctx->name);
break;
@@ -150,6 +157,18 @@ stardis_spherical_source_power(const double time /* [s] */, void* data)
return source->power; /* [W] */
}
+double /* [W/m^2/sr] */
+stardis_spherical_source_diffuse_radiance
+ (const double time, /* [s] */
+ const double dir[3],
+ void* data)
+{
+ struct source* source = data;
+ (void)time, (void)dir; /* Avoid "unused variable" warning */
+ ASSERT(source);
+ return source->diffuse_radiance;
+}
+
/*******************************************************************************
* Legal notices
******************************************************************************/