commit 80d87e34fdbfe281bc26eb0bfdc632cfe21188e3
parent 2f14e21128dcc9abf777292619c8ab45afbe191d
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 3 Oct 2022 15:15:40 +0200
Fix mean power calucation when the time range is not zero
Diffstat:
3 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/src/sdis.h b/src/sdis.h
@@ -1315,9 +1315,7 @@ sdis_solve_medium
const struct sdis_solve_medium_args* args,
struct sdis_estimator** estimator);
-/* P = SUM(volumic_power(x)) / Nrealisations * Volume
- * power (in Watt) = time_range[0] == time_range[1]
- * ? P : P / (time_range[1] - time_range[0]) */
+/* power (in Watt) = SUM(volumic_power(x)) / Nrealisations * Volume */
SDIS_API res_T
sdis_compute_power
(struct sdis_scene* scn,
diff --git a/src/sdis_estimator.c b/src/sdis_estimator.c
@@ -163,12 +163,6 @@ sdis_estimator_get_power
return RES_BAD_ARG;
SETUP_MC(power, &estimator->power.power);
power->E *= estimator->power.spread;
-
- if(estimator->power.time_range[0]
- != estimator->power.time_range[1]) {
- power->E /= /* From Joule to Watt */
- (estimator->power.time_range[1]-estimator->power.time_range[0]);
- }
return RES_OK;
}
diff --git a/src/test_sdis_compute_power.c b/src/test_sdis_compute_power.c
@@ -267,7 +267,7 @@ main(int argc, char** argv)
/* Check results for solid 0 */
ref = 4.0/3.0 * PI * POWER0;
- printf("Mean power of the solid0 = %g ~ %g +/- %g\n",
+ printf("Mean power of the solid0 = %g W ~ %g W +/- %g\n",
ref, mpow.E, mpow.SE);
check_intersection(ref, 1.e-3*ref, mpow.E, 3*mpow.SE);
OK(sdis_estimator_ref_put(estimator));
@@ -280,7 +280,7 @@ main(int argc, char** argv)
/* Check results for solid 1 */
OK(sdis_estimator_get_power(estimator, &mpow));
ref = PI * 10 * POWER1;
- printf("Mean power of the solid1 = %g ~ %g +/- %g\n",
+ printf("Mean power of the solid1 = %g W ~ %g W +/- %g\n",
ref, mpow.E, mpow.SE);
check_intersection(ref, 1.e-3*ref, mpow.E, 3*mpow.SE);
OK(sdis_estimator_ref_put(estimator));
@@ -293,8 +293,8 @@ main(int argc, char** argv)
if(is_master_process) {
/* Check for a not null time range */
OK(sdis_estimator_get_power(estimator, &mpow));
- ref = PI * 10 * POWER1 / 10;
- printf("Mean power of the solid1 in [0, 10] s = %g ~ %g +/- %g\n",
+ ref = PI * 10 * POWER1;
+ printf("Mean power of the solid1 in [0, 10] s = %g W ~ %g W +/- %g\n",
ref, mpow.E, mpow.SE);
check_intersection(ref, 1.e-3*ref, mpow.E, 3*mpow.SE);
OK(sdis_estimator_ref_put(estimator));
@@ -317,7 +317,7 @@ main(int argc, char** argv)
if(is_master_process) {
OK(sdis_estimator_get_power(estimator, &mpow));
ref = 4.0/3.0*PI*POWER0 + PI*10*POWER1;
- printf("Mean power of the sphere+cylinder = %g ~ %g +/- %g\n",
+ printf("Mean power of the sphere+cylinder = %g W ~ %g W +/- %g\n",
ref, mpow.E, mpow.SE);
check_intersection(ref, 1e-2*ref, mpow.E, 3*mpow.SE);
OK(sdis_estimator_ref_put(estimator));