Skip to content

Commit 324fc29

Browse files
authored
Fig 2c in (new) Adade & Albuquerque 2024 example; new physics submodule: bulk phase partitioning with one impl as in Kaul et al. 2015 (#1365)
1 parent 267eef7 commit 324fc29

File tree

16 files changed

+1981
-2
lines changed

16 files changed

+1981
-2
lines changed

PySDM/formulae.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def __init__( # pylint: disable=too-many-locals
5555
particle_shape_and_density: str = "LiquidSpheres",
5656
terminal_velocity: str = "GunnKinzer1949",
5757
air_dynamic_viscosity: str = "ZografosEtAl1987",
58+
bulk_phase_partitioning: str = "Null",
5859
handle_all_breakups: bool = False,
5960
):
6061
# initialisation of the fields below is just to silence pylint and to enable code hints
@@ -86,6 +87,7 @@ def __init__( # pylint: disable=too-many-locals
8687
self.particle_shape_and_density = particle_shape_and_density
8788
self.air_dynamic_viscosity = air_dynamic_viscosity
8889
self.terminal_velocity = terminal_velocity
90+
self.bulk_phase_partitioning = bulk_phase_partitioning
8991

9092
self._components = tuple(
9193
i
@@ -101,8 +103,18 @@ def __init__( # pylint: disable=too-many-locals
101103
getattr(defaults, k), (numbers.Number, pint.Quantity, pint.Unit)
102104
)
103105
}
106+
107+
physics.constants_defaults.compute_derived_values(constants_defaults)
108+
if constants is not None:
109+
for key in constants:
110+
if key not in constants_defaults:
111+
raise ValueError(
112+
f"constant override provided for unknown key: {key}"
113+
)
114+
104115
constants_defaults = {**constants_defaults, **(constants or {})}
105116
physics.constants_defaults.compute_derived_values(constants_defaults)
117+
106118
constants = namedtuple("Constants", tuple(constants_defaults.keys()))(
107119
**constants_defaults
108120
)

PySDM/physics/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@
4545
ventilation,
4646
air_dynamic_viscosity,
4747
terminal_velocity,
48+
bulk_phase_partitioning,
4849
)
4950
from .constants import convert_to, in_unit, si
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
""" phase partitioning formulae for bulk description of cloud water """
2+
3+
from PySDM.impl.null_physics_class import Null
4+
from .kaul_et_al_2015 import KaulEtAl2015
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
Eq. 1 in [Kaul et al. 2015](https://doi.org/10.1175/MWR-D-14-00319.1)
3+
"""
4+
5+
import numpy as np
6+
7+
8+
class KaulEtAl2015: # pylint: disable=too-few-public-methods
9+
def __init__(self, const):
10+
assert np.isfinite(const.bulk_phase_partitioning_exponent)
11+
12+
@staticmethod
13+
def liquid_fraction(const, T):
14+
return np.minimum(
15+
1,
16+
np.power(
17+
np.maximum(
18+
0,
19+
(T - const.bulk_phase_partitioning_T_cold)
20+
/ (
21+
const.bulk_phase_partitioning_T_warm
22+
- const.bulk_phase_partitioning_T_cold
23+
),
24+
),
25+
const.bulk_phase_partitioning_exponent,
26+
),
27+
)

PySDM/physics/constants_defaults.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,3 +424,7 @@ def compute_derived_values(c: dict):
424424
B80W_G2 = 243.5 * si.K
425425

426426
one_kelvin = 1 * si.K
427+
428+
bulk_phase_partitioning_T_cold = 235 * si.K
429+
bulk_phase_partitioning_T_warm = 273 * si.K
430+
bulk_phase_partitioning_exponent = np.nan
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# pylint: disable=invalid-name
2+
"""
3+
mixed-phase example using parcel environment based on
4+
[Abade & Albuquerque 2024 (QJRMS)](https://doi.org/10.1002/qj.4775)
5+
"""
6+
7+
from .simulation import Simulation
8+
from .settings import Settings

0 commit comments

Comments
 (0)