Skip to content

Commit

Permalink
Fig 2c in (new) Adade & Albuquerque 2024 example; new physics submodu…
Browse files Browse the repository at this point in the history
…le: bulk phase partitioning with one impl as in Kaul et al. 2015 (#1365)
  • Loading branch information
slayoo authored Jul 25, 2024
1 parent 267eef7 commit 324fc29
Show file tree
Hide file tree
Showing 16 changed files with 1,981 additions and 2 deletions.
12 changes: 12 additions & 0 deletions PySDM/formulae.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def __init__( # pylint: disable=too-many-locals
particle_shape_and_density: str = "LiquidSpheres",
terminal_velocity: str = "GunnKinzer1949",
air_dynamic_viscosity: str = "ZografosEtAl1987",
bulk_phase_partitioning: str = "Null",
handle_all_breakups: bool = False,
):
# initialisation of the fields below is just to silence pylint and to enable code hints
Expand Down Expand Up @@ -86,6 +87,7 @@ def __init__( # pylint: disable=too-many-locals
self.particle_shape_and_density = particle_shape_and_density
self.air_dynamic_viscosity = air_dynamic_viscosity
self.terminal_velocity = terminal_velocity
self.bulk_phase_partitioning = bulk_phase_partitioning

self._components = tuple(
i
Expand All @@ -101,8 +103,18 @@ def __init__( # pylint: disable=too-many-locals
getattr(defaults, k), (numbers.Number, pint.Quantity, pint.Unit)
)
}

physics.constants_defaults.compute_derived_values(constants_defaults)
if constants is not None:
for key in constants:
if key not in constants_defaults:
raise ValueError(
f"constant override provided for unknown key: {key}"
)

constants_defaults = {**constants_defaults, **(constants or {})}
physics.constants_defaults.compute_derived_values(constants_defaults)

constants = namedtuple("Constants", tuple(constants_defaults.keys()))(
**constants_defaults
)
Expand Down
1 change: 1 addition & 0 deletions PySDM/physics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@
ventilation,
air_dynamic_viscosity,
terminal_velocity,
bulk_phase_partitioning,
)
from .constants import convert_to, in_unit, si
4 changes: 4 additions & 0 deletions PySDM/physics/bulk_phase_partitioning/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
""" phase partitioning formulae for bulk description of cloud water """

from PySDM.impl.null_physics_class import Null
from .kaul_et_al_2015 import KaulEtAl2015
27 changes: 27 additions & 0 deletions PySDM/physics/bulk_phase_partitioning/kaul_et_al_2015.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
Eq. 1 in [Kaul et al. 2015](https://doi.org/10.1175/MWR-D-14-00319.1)
"""

import numpy as np


class KaulEtAl2015: # pylint: disable=too-few-public-methods
def __init__(self, const):
assert np.isfinite(const.bulk_phase_partitioning_exponent)

@staticmethod
def liquid_fraction(const, T):
return np.minimum(
1,
np.power(
np.maximum(
0,
(T - const.bulk_phase_partitioning_T_cold)
/ (
const.bulk_phase_partitioning_T_warm
- const.bulk_phase_partitioning_T_cold
),
),
const.bulk_phase_partitioning_exponent,
),
)
4 changes: 4 additions & 0 deletions PySDM/physics/constants_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,7 @@ def compute_derived_values(c: dict):
B80W_G2 = 243.5 * si.K

one_kelvin = 1 * si.K

bulk_phase_partitioning_T_cold = 235 * si.K
bulk_phase_partitioning_T_warm = 273 * si.K
bulk_phase_partitioning_exponent = np.nan
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# pylint: disable=invalid-name
"""
mixed-phase example using parcel environment based on
[Abade & Albuquerque 2024 (QJRMS)](https://doi.org/10.1002/qj.4775)
"""

from .simulation import Simulation
from .settings import Settings
Loading

0 comments on commit 324fc29

Please sign in to comment.