commit 931d1ca82ae4bbc34a39072d2f707c9c322ac4b2
parent 66589442b2056899e5abf99d4a8712544df9ebd9
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Fri, 10 Oct 2025 16:15:15 +0200
stardis: fix the calculation of solar power
Diffstat:
1 file changed, 7 insertions(+), 0 deletions(-)
diff --git a/src/stardis_smeteo.c b/src/stardis_smeteo.c
@@ -413,7 +413,14 @@ stardis_spherical_source_power(const double time /* [s] */, void* data)
compute_sun_position(data, time, &sun);
i = get_meteo_entry_id(bcond, time);
+
+ /* W/m^2 of surface perpendicular to the incident direction */
power = bcond->lib_desc.smeteo_desc.entries[i].SWdn_direct / sin(sun.zenith);
+ /* Limit to 0 to avoid negative power, i.e., when the sun is below the horizon. */
+ power = MMAX(power, 0);
+ /* Overall solar power */
+ power = power * 4*PI*EARTH_TO_SUN_DST*EARTH_TO_SUN_DST;
+
return power;
}