PySDM_examples.Morrison_and_Grabowski_2007.strato_cumulus

 1import numpy as np
 2from PySDM_examples.Morrison_and_Grabowski_2007.common import Common
 3
 4from PySDM.physics import si
 5
 6
 7class StratoCumulus(Common):
 8    def __init__(self, formulae, rhod_w_max: float):
 9        super().__init__(formulae)
10        self.th_std0 = 289 * si.kelvins
11        self.initial_water_vapour_mixing_ratio = 7.5 * si.grams / si.kilogram
12        self.p0 = 1015 * si.hectopascals
13        self.rhod_w_max = rhod_w_max
14
15    def stream_function(self, xX, zZ, _):
16        X = self.size[0]
17        return (
18            -self.rhod_w_max * X / np.pi * np.sin(np.pi * zZ) * np.cos(2 * np.pi * xX)
19        )
20
21    def rhod_of_zZ(self, zZ):
22        p = getattr(
23            self.formulae.hydrostatics,
24            "p_of_z_assuming_const_th_and_initial_water_vapour_mixing_ratio",
25        )(
26            self.formulae.constants.g_std,
27            self.p0,
28            self.th_std0,
29            self.initial_water_vapour_mixing_ratio,
30            z=zZ * self.size[-1],
31        )
32        rhod = self.formulae.state_variable_triplet.rho_d(
33            p, self.initial_water_vapour_mixing_ratio, self.th_std0
34        )
35        return rhod
 8class StratoCumulus(Common):
 9    def __init__(self, formulae, rhod_w_max: float):
10        super().__init__(formulae)
11        self.th_std0 = 289 * si.kelvins
12        self.initial_water_vapour_mixing_ratio = 7.5 * si.grams / si.kilogram
13        self.p0 = 1015 * si.hectopascals
14        self.rhod_w_max = rhod_w_max
15
16    def stream_function(self, xX, zZ, _):
17        X = self.size[0]
18        return (
19            -self.rhod_w_max * X / np.pi * np.sin(np.pi * zZ) * np.cos(2 * np.pi * xX)
20        )
21
22    def rhod_of_zZ(self, zZ):
23        p = getattr(
24            self.formulae.hydrostatics,
25            "p_of_z_assuming_const_th_and_initial_water_vapour_mixing_ratio",
26        )(
27            self.formulae.constants.g_std,
28            self.p0,
29            self.th_std0,
30            self.initial_water_vapour_mixing_ratio,
31            z=zZ * self.size[-1],
32        )
33        rhod = self.formulae.state_variable_triplet.rho_d(
34            p, self.initial_water_vapour_mixing_ratio, self.th_std0
35        )
36        return rhod
StratoCumulus(formulae, rhod_w_max: float)
 9    def __init__(self, formulae, rhod_w_max: float):
10        super().__init__(formulae)
11        self.th_std0 = 289 * si.kelvins
12        self.initial_water_vapour_mixing_ratio = 7.5 * si.grams / si.kilogram
13        self.p0 = 1015 * si.hectopascals
14        self.rhod_w_max = rhod_w_max
th_std0
initial_water_vapour_mixing_ratio
p0
rhod_w_max
def stream_function(self, xX, zZ, _):
16    def stream_function(self, xX, zZ, _):
17        X = self.size[0]
18        return (
19            -self.rhod_w_max * X / np.pi * np.sin(np.pi * zZ) * np.cos(2 * np.pi * xX)
20        )
def rhod_of_zZ(self, zZ):
22    def rhod_of_zZ(self, zZ):
23        p = getattr(
24            self.formulae.hydrostatics,
25            "p_of_z_assuming_const_th_and_initial_water_vapour_mixing_ratio",
26        )(
27            self.formulae.constants.g_std,
28            self.p0,
29            self.th_std0,
30            self.initial_water_vapour_mixing_ratio,
31            z=zZ * self.size[-1],
32        )
33        rhod = self.formulae.state_variable_triplet.rho_d(
34            p, self.initial_water_vapour_mixing_ratio, self.th_std0
35        )
36        return rhod