PySDM_examples.Yang_et_al_2018.settings

 1import numpy as np
 2from pystrict import strict
 3
 4from PySDM_examples import Jensen_and_Nugent_2017
 5
 6from PySDM.backends import CPU
 7from PySDM.dynamics import condensation
 8from PySDM.initialisation import spectra
 9from PySDM.initialisation.sampling import spectral_sampling
10from PySDM.physics import si
11
12
13@strict
14class Settings:
15    def __init__(
16        self,
17        n_sd: int = 100,
18        dt_output: float = 1 * si.second,
19        dt_max: float = 1 * si.second,
20    ):
21        self.total_time = 3 * si.hours
22        self.mass_of_dry_air = 1000 * si.kilogram
23
24        self.n_steps = int(
25            self.total_time / (5 * si.second)
26        )  # TODO #334 rename to n_output
27        self.n_sd = n_sd
28        self.r_dry, self.n = spectral_sampling.Logarithmic(
29            spectrum=spectra.Lognormal(
30                norm_factor=1000 / si.milligram * self.mass_of_dry_air,
31                m_mode=50 * si.nanometre,
32                s_geom=1.4,
33            ),
34            size_range=(10.633 * si.nanometre, 513.06 * si.nanometre),
35        ).sample_deterministic(n_sd)
36        self.dt_max = dt_max
37
38        self.dt_output = dt_output
39        self.r_bins_edges = np.linspace(
40            0 * si.micrometre, 20 * si.micrometre, 101, endpoint=True
41        )
42
43        self.backend = CPU
44        self.coord = "WaterMassLogarithm"
45        self.adaptive = True
46        self.rtol_x = condensation.DEFAULTS.rtol_x
47        self.rtol_thd = condensation.DEFAULTS.rtol_thd
48        self.dt_cond_range = condensation.DEFAULTS.cond_range
49
50        self.T0 = Jensen_and_Nugent_2017.settings.INITIAL_TEMPERATURE
51        self.RH0 = Jensen_and_Nugent_2017.settings.INITIAL_RELATIVE_HUMIDITY
52        self.p0 = Jensen_and_Nugent_2017.settings.INITIAL_PRESSURE
53        self.z0 = Jensen_and_Nugent_2017.settings.INITIAL_ALTITUDE
54        self.kappa = 0.53  # Petters and S. M. Kreidenweis mean growth-factor derived
55
56        self.t0 = 1200 * si.second
57        self.f0 = 1 / 1000 * si.hertz
58
59    def w(self, t):
60        return (
61            0.5
62            * (
63                np.where(
64                    t < self.t0,
65                    1,
66                    np.sign(-np.sin(2 * np.pi * self.f0 * (t - self.t0))),
67                )
68            )
69            * si.metre
70            / si.second
71        )
@strict
class Settings:
14@strict
15class Settings:
16    def __init__(
17        self,
18        n_sd: int = 100,
19        dt_output: float = 1 * si.second,
20        dt_max: float = 1 * si.second,
21    ):
22        self.total_time = 3 * si.hours
23        self.mass_of_dry_air = 1000 * si.kilogram
24
25        self.n_steps = int(
26            self.total_time / (5 * si.second)
27        )  # TODO #334 rename to n_output
28        self.n_sd = n_sd
29        self.r_dry, self.n = spectral_sampling.Logarithmic(
30            spectrum=spectra.Lognormal(
31                norm_factor=1000 / si.milligram * self.mass_of_dry_air,
32                m_mode=50 * si.nanometre,
33                s_geom=1.4,
34            ),
35            size_range=(10.633 * si.nanometre, 513.06 * si.nanometre),
36        ).sample_deterministic(n_sd)
37        self.dt_max = dt_max
38
39        self.dt_output = dt_output
40        self.r_bins_edges = np.linspace(
41            0 * si.micrometre, 20 * si.micrometre, 101, endpoint=True
42        )
43
44        self.backend = CPU
45        self.coord = "WaterMassLogarithm"
46        self.adaptive = True
47        self.rtol_x = condensation.DEFAULTS.rtol_x
48        self.rtol_thd = condensation.DEFAULTS.rtol_thd
49        self.dt_cond_range = condensation.DEFAULTS.cond_range
50
51        self.T0 = Jensen_and_Nugent_2017.settings.INITIAL_TEMPERATURE
52        self.RH0 = Jensen_and_Nugent_2017.settings.INITIAL_RELATIVE_HUMIDITY
53        self.p0 = Jensen_and_Nugent_2017.settings.INITIAL_PRESSURE
54        self.z0 = Jensen_and_Nugent_2017.settings.INITIAL_ALTITUDE
55        self.kappa = 0.53  # Petters and S. M. Kreidenweis mean growth-factor derived
56
57        self.t0 = 1200 * si.second
58        self.f0 = 1 / 1000 * si.hertz
59
60    def w(self, t):
61        return (
62            0.5
63            * (
64                np.where(
65                    t < self.t0,
66                    1,
67                    np.sign(-np.sin(2 * np.pi * self.f0 * (t - self.t0))),
68                )
69            )
70            * si.metre
71            / si.second
72        )
Settings(n_sd: int = 100, dt_output: float = 1.0, dt_max: float = 1.0)
16    def __init__(
17        self,
18        n_sd: int = 100,
19        dt_output: float = 1 * si.second,
20        dt_max: float = 1 * si.second,
21    ):
22        self.total_time = 3 * si.hours
23        self.mass_of_dry_air = 1000 * si.kilogram
24
25        self.n_steps = int(
26            self.total_time / (5 * si.second)
27        )  # TODO #334 rename to n_output
28        self.n_sd = n_sd
29        self.r_dry, self.n = spectral_sampling.Logarithmic(
30            spectrum=spectra.Lognormal(
31                norm_factor=1000 / si.milligram * self.mass_of_dry_air,
32                m_mode=50 * si.nanometre,
33                s_geom=1.4,
34            ),
35            size_range=(10.633 * si.nanometre, 513.06 * si.nanometre),
36        ).sample_deterministic(n_sd)
37        self.dt_max = dt_max
38
39        self.dt_output = dt_output
40        self.r_bins_edges = np.linspace(
41            0 * si.micrometre, 20 * si.micrometre, 101, endpoint=True
42        )
43
44        self.backend = CPU
45        self.coord = "WaterMassLogarithm"
46        self.adaptive = True
47        self.rtol_x = condensation.DEFAULTS.rtol_x
48        self.rtol_thd = condensation.DEFAULTS.rtol_thd
49        self.dt_cond_range = condensation.DEFAULTS.cond_range
50
51        self.T0 = Jensen_and_Nugent_2017.settings.INITIAL_TEMPERATURE
52        self.RH0 = Jensen_and_Nugent_2017.settings.INITIAL_RELATIVE_HUMIDITY
53        self.p0 = Jensen_and_Nugent_2017.settings.INITIAL_PRESSURE
54        self.z0 = Jensen_and_Nugent_2017.settings.INITIAL_ALTITUDE
55        self.kappa = 0.53  # Petters and S. M. Kreidenweis mean growth-factor derived
56
57        self.t0 = 1200 * si.second
58        self.f0 = 1 / 1000 * si.hertz
total_time
mass_of_dry_air
n_steps
n_sd
dt_max
dt_output
r_bins_edges
backend
coord
adaptive
rtol_x
rtol_thd
dt_cond_range
T0
RH0
p0
z0
kappa
t0
f0
def w(self, t):
60    def w(self, t):
61        return (
62            0.5
63            * (
64                np.where(
65                    t < self.t0,
66                    1,
67                    np.sign(-np.sin(2 * np.pi * self.f0 * (t - self.t0))),
68                )
69            )
70            * si.metre
71            / si.second
72        )