Skip to content

Commit 979e81e

Browse files
committed
get_tau_ave() -> averages the hydrodynamic profiles to get more accurate tau (matches fitted tau better)
1 parent 9f091fa commit 979e81e

5 files changed

Lines changed: 28 additions & 3 deletions

File tree

examples/sparging_standard.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@
5656
]
5757

5858
tau_pred = my_input.get_tau()
59-
dt = (tau_pred * 0.02).to("s") # gives 1% error on tau compared to fine mesh
59+
dt = (tau_pred * 0.02).to(
60+
"s"
61+
) # 2% of tau_pred gives 1% error on tau compared to fine mesh
6062
dx = my_input.dx_from_Pe(2) # grid Pe = 2
61-
63+
my_input.K_s *= 1e-2
6264
print(f"dx={dx:~.2e}, dt={dt:~.2e}")
6365
t_start = time.perf_counter()
6466
output = my_simulation.solve(dt=dt, dx=dx, verbose=True)

src/sparging/correlations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def get_list(self, corr_type: CorrelationType) -> list[Correlation]:
350350
),
351351
corr_type=CorrelationType.LIQUID_PHASE_DISPERSION,
352352
source="Deckwer 1974",
353-
description="liquid phase axial dispersion coefficient, assumed equal to diffusivity of tritium in liquid FLiBe",
353+
description="liquid phase axial dispersion coefficient",
354354
input_units=["m", PROFILE],
355355
output_units="m**2/s",
356356
)

src/sparging/inputs.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,24 @@ def get_tau(self) -> pint.Quantity:
172172
"""characteristic time of the sparger under the small partial pressure (SPP) approximation"""
173173
return (self.eps_l0 / (self.h_l0 * self.a_0)).to("seconds")
174174

175+
def get_tau_ave(self) -> pint.Quantity:
176+
"""characteristic time computed from a, h_l and eps_l profiles integrated
177+
over the tank height, instead of evaluated at the bottom (z=0)."""
178+
from scipy.integrate import quad
179+
180+
def eps_l_integrand(z_m: float) -> float:
181+
return (1 - self.eps_g(z_m * ureg.m)).to("dimensionless").magnitude
182+
183+
def a_h_l_integrand(z_m: float) -> float:
184+
z = z_m * ureg.m
185+
return (self.a(z) * self.h_l(z)).to("1/s").magnitude
186+
187+
height_m = self.height.to("m").magnitude
188+
int_eps_l = quad(eps_l_integrand, 0, height_m)[0] * ureg.m
189+
int_a_h_l = quad(a_h_l_integrand, 0, height_m)[0] * ureg("m/s")
190+
191+
return (int_eps_l / int_a_h_l).to("seconds")
192+
175193
def get_c_T2_SS(self) -> pint.Quantity:
176194
return (self.get_S_T() * 1 / (self.h_l0 * self.a_0)).to("molT2/m^3")
177195

src/sparging/model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def _section_analytical_quantities(self, **_) -> dict:
179179
# each entry wrapped so one failing property doesn't kill the whole export
180180
candidates = {
181181
"tau_predicted": si.get_tau,
182+
"tau_predicted_ave": si.get_tau_ave,
182183
"c_T2_steady_state": si.get_c_T2_SS,
183184
"Pi_number": si.get_Pi_number,
184185
"Bodenstein_number": si.get_Bo,

src/sparging/postprocess.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,10 @@ def summarize_decay(
152152
(tau_fit, n0_fit), (tau_std, n0_std) = fit_exp(inv, times, t_0, t_end, "decay")
153153
tau_real = get_tau_real(inv, times, t_0)
154154
tau_pred = results.sim_input.get_tau()
155+
tau_pred_ave = results.sim_input.get_tau_ave()
155156
residual = get_residual_fraction(inv, times, t_0, t_end)
156157
rel_error = ((tau_fit - tau_pred) / tau_pred).to("dimensionless")
158+
ave_rel_error = ((tau_fit - tau_pred_ave) / tau_pred_ave).to("dimensionless")
157159

158160
logger.info(
159161
f"tau_fitted={tau_fit.to('hour'):.3f}, tau_predicted={tau_pred.to('hour'):.3f}, "
@@ -164,10 +166,12 @@ def summarize_decay(
164166
"tau_fitted": tau_fit,
165167
"tau_fitted_std": tau_std,
166168
"tau_predicted": tau_pred,
169+
"tau_predicted_ave": tau_pred_ave,
167170
"tau_real_1e": tau_real,
168171
"n0_fitted": n0_fit,
169172
"n0_fitted_std": n0_std,
170173
"residual_fraction": residual,
171174
"tau_rel_error": rel_error,
175+
"tau_ave_rel_error": ave_rel_error,
172176
"fit_window": (t_0, t_end),
173177
}

0 commit comments

Comments
 (0)