commit aa08810adb2a925ea0ec2a28fadd480ef3a16d5c
parent 35f799e8657165dc46ebbc507c0619bb4f4d2c3e
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 28 Mar 2023 15:27:30 +0200
Fix the calculation of flux density with an imposed flux
The calculated flux density is the flux density that exits the solid.
Although this convention was respected for the convective and radiative
fluxes, the imposed flux was reversed. This commit corrects this
problem.
Diffstat:
4 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/sdis.h b/src/sdis.h
@@ -578,7 +578,7 @@ static const struct sdis_solve_medium_args SDIS_SOLVE_MEDIUM_ARGS_DEFAULT =
struct sdis_solve_probe_boundary_flux_args {
size_t nrealisations; /* #realisations */
size_t iprim; /* Identifier of the primitive on which the probe lies */
- double uv[2]; /* Parametric coordinates of the probe onto the primitve */
+ double uv[2]; /* Parametric coordinates of the probe onto the primitive */
double time_range[2]; /* Observation time */
/* Set the Picard recursion order to estimate the radiative temperature. An
@@ -1128,22 +1128,22 @@ sdis_estimator_get_realisation_time
SDIS_API res_T
sdis_estimator_get_convective_flux
(const struct sdis_estimator* estimator,
- struct sdis_mc* flux);
+ struct sdis_mc* flux); /* In W/m² */
SDIS_API res_T
sdis_estimator_get_radiative_flux
(const struct sdis_estimator* estimator,
- struct sdis_mc* flux);
+ struct sdis_mc* flux); /* In W/m² */
SDIS_API res_T
sdis_estimator_get_imposed_flux
(const struct sdis_estimator* estimator,
- struct sdis_mc* flux);
+ struct sdis_mc* flux); /* In W/m² */
SDIS_API res_T
sdis_estimator_get_total_flux
(const struct sdis_estimator* estimator,
- struct sdis_mc* flux);
+ struct sdis_mc* flux); /* In W/m² */
SDIS_API res_T
sdis_estimator_get_power
diff --git a/src/sdis_heat_path_boundary_Xd_c.h b/src/sdis_heat_path_boundary_Xd_c.h
@@ -889,7 +889,7 @@ XD(handle_net_flux)
CHK(args->h_cond + args->h_conv + args->h_radi > 0);
phi = interface_side_get_flux(args->interf, args->frag);
- if(phi == SDIS_FLUX_NONE) goto exit; /* No flux. Do nothig */
+ if(phi == SDIS_FLUX_NONE) goto exit; /* No flux. Do nothing */
if(args->picard_order > 1 && phi != 0) {
log_err(scn->dev,
diff --git a/src/sdis_solve_boundary_Xd.h b/src/sdis_solve_boundary_Xd.h
@@ -817,10 +817,13 @@ XD(solve_boundary_flux)
continue;
} else if(res_simul == RES_OK) { /* Update accumulators */
const double usec = (double)time_val(&t0, TIME_NSEC) * 0.001;
+ /* Convective flux from solid to fluid */
const double w_conv = hc * (result.Tboundary - result.Tfluid);
+ /* Radiative flux from solid to ambient */
const double w_rad = (result.Tradiative < 0) ?
0 : hr * (result.Tboundary - result.Tradiative);
- const double w_imp = (imposed_flux != SDIS_FLUX_NONE) ? imposed_flux : 0;
+ /* Imposed flux that goes _out_ of the solid */
+ const double w_imp = (imposed_flux != SDIS_FLUX_NONE) ? -imposed_flux : 0;
const double w_total = w_conv + w_rad + w_imp;
/* Temperature */
acc_temp->sum += result.Tboundary;
diff --git a/src/sdis_solve_probe_boundary_Xd.h b/src/sdis_solve_probe_boundary_Xd.h
@@ -611,10 +611,13 @@ XD(solve_probe_boundary_flux)
continue;
} else if(res_simul == RES_OK) { /* Update accumulators */
const double usec = (double)time_val(&t0, TIME_NSEC) * 0.001;
+ /* Convective flux from solid to fluid */
const double w_conv = hc * (result.Tboundary - result.Tfluid);
+ /* Radiative flux from solid to ambient */
const double w_rad = (result.Tradiative < 0) ?
0 : hr * (result.Tboundary - result.Tradiative);
- const double w_imp = (imposed_flux != SDIS_FLUX_NONE) ? imposed_flux : 0;
+ /* Imposed flux that goes _out_ of the solid */
+ const double w_imp = (imposed_flux != SDIS_FLUX_NONE) ? -imposed_flux : 0;
const double w_total = w_conv + w_rad + w_imp;
/* Temperature */
acc_temp->sum += result.Tboundary;