Skip to content

Commit 4e1deda

Browse files
Add new examples from Jouzel and Merlivat '84 and Fisher '91 with kinetic fractionation factor; clean up ventilation_factor handling (separate mass & heat ventilation); introduce physics.drop_growth.Howell1949 (replacement for physics.drop_growth.Mason1951) and physics.drop_growth.Fick (#1568)
Co-authored-by: Elise Rosky <emrosky@mtu.edu> Co-authored-by: Elise Rosky <elise.rosky@gmail.com>
1 parent 371009b commit 4e1deda

File tree

26 files changed

+983
-216
lines changed

26 files changed

+983
-216
lines changed

PySDM/backends/impl_numba/methods/condensation_methods.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ def minfun( # pylint: disable=too-many-arguments,too-many-locals
388388
pvs,
389389
D,
390390
K,
391-
ventilation_factor,
391+
mass_ventilation_factor,
392+
heat_ventilation_factor,
392393
):
393394
if x_new > formulae.diffusion_coordinate__x_max():
394395
return x_old - x_new
@@ -410,9 +411,8 @@ def minfun( # pylint: disable=too-many-arguments,too-many-locals
410411
RH,
411412
lv,
412413
pvs,
413-
D,
414-
K,
415-
ventilation_factor,
414+
D * mass_ventilation_factor,
415+
K * heat_ventilation_factor,
416416
)
417417
dm_dt = formulae.particle_shape_and_density__dm_dt(r=r_new, r_dr_dt=r_dr_dt)
418418
return (
@@ -469,12 +469,13 @@ def calculate_ml_new( # pylint: disable=too-many-branches,too-many-arguments,to
469469
):
470470
Dr = formulae.diffusion_kinetics__D(DTp, r_old, lambdaD)
471471
Kr = formulae.diffusion_kinetics__K(KTp, r_old, lambdaK)
472-
ventilation_factor = formulae.ventilation__ventilation_coefficient(
472+
mass_ventilation_factor = formulae.ventilation__ventilation_coefficient(
473473
sqrt_re_times_cbrt_sc=formulae.trivia__sqrt_re_times_cbrt_sc(
474474
Re=attributes.reynolds_number[drop],
475475
Sc=Sc,
476476
)
477477
)
478+
heat_ventilation_factor = mass_ventilation_factor # TODO #1588
478479
args = (
479480
x_old,
480481
timestep,
@@ -487,17 +488,17 @@ def calculate_ml_new( # pylint: disable=too-many-branches,too-many-arguments,to
487488
pvs,
488489
Dr,
489490
Kr,
490-
ventilation_factor,
491+
mass_ventilation_factor,
492+
heat_ventilation_factor,
491493
)
492494
r_dr_dt_old = formulae.drop_growth__r_dr_dt(
493495
RH_eq,
494496
T,
495497
RH,
496498
lv,
497499
pvs,
498-
Dr,
499-
Kr,
500-
ventilation_factor,
500+
mass_ventilation_factor * Dr,
501+
heat_ventilation_factor * Kr,
501502
)
502503
mass_old = formulae.diffusion_coordinate__mass(x_old)
503504
dm_dt_old = formulae.particle_shape_and_density__dm_dt(

PySDM/backends/impl_numba/methods/deposition_methods.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@ def body( # pylint: disable=too-many-arguments
5757

5858
capacity = formulae.diffusion_ice_capacity__capacity(diameter)
5959

60-
ventilation_factor = formulae.ventilation__ventilation_coefficient(
60+
mass_ventilation_factor = formulae.ventilation__ventilation_coefficient(
6161
sqrt_re_times_cbrt_sc=formulae.trivia__sqrt_re_times_cbrt_sc(
6262
Re=reynolds_number[i],
6363
Sc=schmidt_number[cid],
6464
)
6565
)
66+
heat_ventilation_factor = mass_ventilation_factor # TODO #1588
6667

6768
Dv_const = formulae.diffusion_thermics__D(temperature, pressure)
6869
lambdaD = formulae.diffusion_ice_kinetics__lambdaD(
@@ -93,9 +94,8 @@ def body( # pylint: disable=too-many-arguments
9394
RH=saturation_ratio_ice,
9495
lv=latent_heat_sub,
9596
pvs=pvs_ice,
96-
D=diffusion_coefficient,
97-
K=thermal_conductivity,
98-
ventilation_factor=ventilation_factor,
97+
D=mass_ventilation_factor * diffusion_coefficient,
98+
K=heat_ventilation_factor * thermal_conductivity,
9999
)
100100
* formulae.constants.rho_w
101101
)

PySDM/backends/impl_numba/test_helpers/scipy_ode_condensation_solver.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,13 @@ def _impl( # pylint: disable=too-many-arguments,too-many-locals
132132
r = jit_formulae.trivia__radius(v)
133133
Dr = jit_formulae.diffusion_kinetics__D(DTp, r, lambdaD)
134134
Kr = jit_formulae.diffusion_kinetics__K(KTp, r, lambdaK)
135-
ventilation_factor = jit_formulae.ventilation__ventilation_coefficient(
135+
mass_ventilation_factor = jit_formulae.ventilation__ventilation_coefficient(
136136
sqrt_re_times_cbrt_sc=jit_formulae.trivia__sqrt_re_times_cbrt_sc(
137137
Re=reynolds_number[i],
138138
Sc=schmidt_number,
139139
)
140140
)
141+
heat_ventilation_factor = mass_ventilation_factor # TODO #1588
141142
sgm = jit_formulae.surface_tension__sigma(T, v, dry_volume[i], f_org[i])
142143
r_dr_dt = jit_formulae.drop_growth__r_dr_dt(
143144
jit_formulae.hygroscopicity__RH_eq(
@@ -147,9 +148,8 @@ def _impl( # pylint: disable=too-many-arguments,too-many-locals
147148
RH,
148149
lv,
149150
pvs,
150-
Dr,
151-
Kr,
152-
ventilation_factor,
151+
mass_ventilation_factor * Dr,
152+
heat_ventilation_factor * Kr,
153153
)
154154
dm_dt = jit_formulae.particle_shape_and_density__dm_dt(r, r_dr_dt)
155155
dy_dt[idx_x + i] = jit_formulae.diffusion_coordinate__dx_dt(m, dm_dt)

PySDM/backends/impl_thrust_rtc/methods/condensation_methods.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"_pvs",
2626
"Dr",
2727
"Kr",
28-
"ventilation_factor",
28+
"mass_ventilation_factor",
2929
)
3030

3131

@@ -125,10 +125,9 @@ def __update_drop_masses(self):
125125
RH=args("_RH"),
126126
lv=args("_lv"),
127127
pvs=args("_pvs"),
128-
D=args("Dr"),
129-
K=args("Kr"),
130-
ventilation_factor=args("ventilation_factor"),
131-
)};
128+
D=f'{args("mass_ventilation_factor")}*{args("Dr")}',
129+
K=f'{args("mass_ventilation_factor")}*{args("Kr")}',
130+
)}; // TODO #1588
132131
auto dm_dt = {phys.particle_shape_and_density.dm_dt.c_inline(
133132
r="r_new", r_dr_dt="r_dr_dt"
134133
)};
@@ -167,7 +166,7 @@ def __update_drop_masses(self):
167166
real_type Dr=0;
168167
real_type Kr=0;
169168
real_type qrt_re_times_cbrt_sc=0;
170-
real_type ventilation_factor=0;
169+
real_type mass_ventilation_factor=0;
171170
real_type r_dr_dt_old=0;
172171
real_type dm_dt_old=0;
173172
real_type dx_old=0;
@@ -186,12 +185,13 @@ def __update_drop_masses(self):
186185
Re="reynolds_number[i]",
187186
Sc="_schmidt_number",
188187
)};
189-
ventilation_factor = {phys.ventilation.ventilation_coefficient.c_inline(
188+
mass_ventilation_factor = {phys.ventilation.ventilation_coefficient.c_inline(
190189
sqrt_re_times_cbrt_sc="qrt_re_times_cbrt_sc"
191190
)};
191+
auto heat_ventilation_factor = mass_ventilation_factor; // TODO #1588
192192
r_dr_dt_old = {phys.drop_growth.r_dr_dt.c_inline(
193-
RH_eq="RH_eq", T="_T", RH="_RH", lv="_lv", pvs="_pvs", D="Dr", K="Kr",
194-
ventilation_factor="ventilation_factor",
193+
RH_eq="RH_eq", T="_T", RH="_RH", lv="_lv", pvs="_pvs",
194+
D="mass_ventilation_factor*Dr", K="heat_ventilation_factor*Kr",
195195
)};
196196
dm_dt_old = {phys.particle_shape_and_density.dm_dt.c_inline(r="r_old", r_dr_dt="r_dr_dt_old")};
197197
dx_old = dt * {phys.diffusion_coordinate.dx_dt.c_inline(

PySDM/physics/constants_defaults.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,12 @@ def compute_derived_values(c: dict):
681681
- [IAPWS Guidelines](http://www.iapws.org/relguide/fundam.pdf)
682682
"""
683683

684+
c["M_1H2_16O"] = c["M_1H"] * 2 + c["M_16O"]
685+
c["M_2H_1H_16O"] = c["M_2H"] + c["M_1H"] + c["M_16O"]
686+
c["M_3H_1H_16O"] = c["M_3H"] + c["M_1H"] + c["M_16O"]
687+
c["M_1H2_17O"] = c["M_1H"] * 2 + c["M_17O"]
688+
c["M_1H2_18O"] = c["M_1H"] * 2 + c["M_18O"]
689+
684690
c["Mv"] = (
685691
(
686692
1
@@ -689,19 +695,15 @@ def compute_derived_values(c: dict):
689695
- 1 * Trivia.mixing_ratio_to_specific_content(c["VSMOW_R_17O"])
690696
- 1 * Trivia.mixing_ratio_to_specific_content(c["VSMOW_R_18O"])
691697
)
692-
* (c["M_1H"] * 2 + c["M_16O"])
698+
* c["M_1H2_16O"]
693699
+ 2
694700
* Trivia.mixing_ratio_to_specific_content(c["VSMOW_R_2H"])
695-
* (c["M_2H"] + c["M_1H"] + c["M_16O"])
701+
* c["M_2H_1H_16O"]
696702
+ 2
697703
* Trivia.mixing_ratio_to_specific_content(c["VSMOW_R_3H"])
698-
* (c["M_3H"] + c["M_1H"] + c["M_16O"])
699-
+ 1
700-
* Trivia.mixing_ratio_to_specific_content(c["VSMOW_R_17O"])
701-
* (c["M_1H"] * 2 + c["M_17O"])
702-
+ 1
703-
* Trivia.mixing_ratio_to_specific_content(c["VSMOW_R_18O"])
704-
* (c["M_1H"] * 2 + c["M_18O"])
704+
* c["M_3H_1H_16O"]
705+
+ 1 * Trivia.mixing_ratio_to_specific_content(c["VSMOW_R_17O"]) * c["M_1H2_17O"]
706+
+ 1 * Trivia.mixing_ratio_to_specific_content(c["VSMOW_R_18O"]) * c["M_1H2_18O"]
705707
)
706708

707709
c["eps"] = c["Mv"] / c["Md"]

PySDM/physics/drop_growth/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
Formulation of the coupled heat-moisture diffusion problem
33
"""
44

5-
from .mason_1951 import Mason1951
5+
from .fick import Fick
6+
from .howell_1949 import Howell1949
67
from .mason_1971 import Mason1971

PySDM/physics/drop_growth/fick.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""
2+
Fickian diffusion only drop growth
3+
"""
4+
5+
6+
class Fick: # pylint: disable=too-few-public-methods
7+
def __init__(self, _):
8+
pass
9+
10+
# pylint: disable=too-many-arguments
11+
@staticmethod
12+
def r_dr_dt(const, RH_eq, T, RH, lv, pvs, D, K): # pylint: disable=unused-argument
13+
return (RH - RH_eq) / const.rho_w / (const.Rv * T / D / pvs)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
single-equation approximation of the vapour and heat diffusion problem
3+
as proposed in [Howell 1949](https://doi.org/10.1175/1520-0469(1949)006%3C0134:TGOCDI%3E2.0.CO;2)
4+
same as in [Mason 1951](https://doi.org/10.1088/0370-1301/64/9/307)
5+
"""
6+
7+
8+
class Howell1949: # pylint: disable=too-few-public-methods
9+
def __init__(self, _):
10+
pass
11+
12+
# pylint: disable=too-many-arguments
13+
@staticmethod
14+
def r_dr_dt(const, RH_eq, T, RH, lv, pvs, D, K):
15+
return (
16+
(RH - RH_eq)
17+
/ const.rho_w
18+
/ (const.Rv * T / D / pvs + lv**2 / K / T**2 / const.Rv)
19+
)

PySDM/physics/drop_growth/mason_1951.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

PySDM/physics/drop_growth/mason_1971.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ def __init__(self, _):
1111

1212
# pylint: disable=too-many-arguments
1313
@staticmethod
14-
def r_dr_dt(const, RH_eq, T, RH, lv, pvs, D, K, ventilation_factor):
14+
def r_dr_dt(const, RH_eq, T, RH, lv, pvs, D, K):
1515
return (
16-
ventilation_factor
17-
* (RH - RH_eq)
16+
(RH - RH_eq)
1817
/ const.rho_w
1918
/ (const.Rv * T / D / pvs + lv / K / T * (lv / T / const.Rv - 1))
2019
)

0 commit comments

Comments
 (0)