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 = (
23            1000 * si.kilogram
24        )  # TODO #335 doubled with jupyter si unit
25
26        self.n_steps = int(
27            self.total_time / (5 * si.second)
28        )  # TODO #334 rename to n_output
29        self.n_sd = n_sd
30        self.r_dry, self.n = spectral_sampling.Logarithmic(
31            spectrum=spectra.Lognormal(
32                norm_factor=1000 / si.milligram * self.mass_of_dry_air,
33                m_mode=50 * si.nanometre,
34                s_geom=1.4,
35            ),
36            size_range=(10.633 * si.nanometre, 513.06 * si.nanometre),
37        ).sample(n_sd)
38        self.dt_max = dt_max
39
40        self.dt_output = dt_output
41        self.r_bins_edges = np.linspace(
42            0 * si.micrometre, 20 * si.micrometre, 101, endpoint=True
43        )
44
45        self.backend = CPU
46        self.coord = "VolumeLogarithm"
47        self.adaptive = True
48        self.rtol_x = condensation.DEFAULTS.rtol_x
49        self.rtol_thd = condensation.DEFAULTS.rtol_thd
50        self.dt_cond_range = condensation.DEFAULTS.cond_range
51
52        self.T0 = Jensen_and_Nugent_2017.settings.INITIAL_TEMPERATURE
53        self.RH0 = Jensen_and_Nugent_2017.settings.INITIAL_RELATIVE_HUMIDITY
54        self.p0 = Jensen_and_Nugent_2017.settings.INITIAL_PRESSURE
55        self.z0 = Jensen_and_Nugent_2017.settings.INITIAL_ALTITUDE
56        self.kappa = 0.53  # Petters and S. M. Kreidenweis mean growth-factor derived
57
58        self.t0 = 1200 * si.second
59        self.f0 = 1 / 1000 * si.hertz
60
61    def w(self, t):
62        return (
63            0.5
64            * (
65                np.where(
66                    t < self.t0,
67                    1,
68                    np.sign(-np.sin(2 * np.pi * self.f0 * (t - self.t0))),
69                )
70            )
71            * si.metre
72            / si.second
73        )
@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 = (
24            1000 * si.kilogram
25        )  # TODO #335 doubled with jupyter si unit
26
27        self.n_steps = int(
28            self.total_time / (5 * si.second)
29        )  # TODO #334 rename to n_output
30        self.n_sd = n_sd
31        self.r_dry, self.n = spectral_sampling.Logarithmic(
32            spectrum=spectra.Lognormal(
33                norm_factor=1000 / si.milligram * self.mass_of_dry_air,
34                m_mode=50 * si.nanometre,
35                s_geom=1.4,
36            ),
37            size_range=(10.633 * si.nanometre, 513.06 * si.nanometre),
38        ).sample(n_sd)
39        self.dt_max = dt_max
40
41        self.dt_output = dt_output
42        self.r_bins_edges = np.linspace(
43            0 * si.micrometre, 20 * si.micrometre, 101, endpoint=True
44        )
45
46        self.backend = CPU
47        self.coord = "VolumeLogarithm"
48        self.adaptive = True
49        self.rtol_x = condensation.DEFAULTS.rtol_x
50        self.rtol_thd = condensation.DEFAULTS.rtol_thd
51        self.dt_cond_range = condensation.DEFAULTS.cond_range
52
53        self.T0 = Jensen_and_Nugent_2017.settings.INITIAL_TEMPERATURE
54        self.RH0 = Jensen_and_Nugent_2017.settings.INITIAL_RELATIVE_HUMIDITY
55        self.p0 = Jensen_and_Nugent_2017.settings.INITIAL_PRESSURE
56        self.z0 = Jensen_and_Nugent_2017.settings.INITIAL_ALTITUDE
57        self.kappa = 0.53  # Petters and S. M. Kreidenweis mean growth-factor derived
58
59        self.t0 = 1200 * si.second
60        self.f0 = 1 / 1000 * si.hertz
61
62    def w(self, t):
63        return (
64            0.5
65            * (
66                np.where(
67                    t < self.t0,
68                    1,
69                    np.sign(-np.sin(2 * np.pi * self.f0 * (t - self.t0))),
70                )
71            )
72            * si.metre
73            / si.second
74        )
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 = (
24            1000 * si.kilogram
25        )  # TODO #335 doubled with jupyter si unit
26
27        self.n_steps = int(
28            self.total_time / (5 * si.second)
29        )  # TODO #334 rename to n_output
30        self.n_sd = n_sd
31        self.r_dry, self.n = spectral_sampling.Logarithmic(
32            spectrum=spectra.Lognormal(
33                norm_factor=1000 / si.milligram * self.mass_of_dry_air,
34                m_mode=50 * si.nanometre,
35                s_geom=1.4,
36            ),
37            size_range=(10.633 * si.nanometre, 513.06 * si.nanometre),
38        ).sample(n_sd)
39        self.dt_max = dt_max
40
41        self.dt_output = dt_output
42        self.r_bins_edges = np.linspace(
43            0 * si.micrometre, 20 * si.micrometre, 101, endpoint=True
44        )
45
46        self.backend = CPU
47        self.coord = "VolumeLogarithm"
48        self.adaptive = True
49        self.rtol_x = condensation.DEFAULTS.rtol_x
50        self.rtol_thd = condensation.DEFAULTS.rtol_thd
51        self.dt_cond_range = condensation.DEFAULTS.cond_range
52
53        self.T0 = Jensen_and_Nugent_2017.settings.INITIAL_TEMPERATURE
54        self.RH0 = Jensen_and_Nugent_2017.settings.INITIAL_RELATIVE_HUMIDITY
55        self.p0 = Jensen_and_Nugent_2017.settings.INITIAL_PRESSURE
56        self.z0 = Jensen_and_Nugent_2017.settings.INITIAL_ALTITUDE
57        self.kappa = 0.53  # Petters and S. M. Kreidenweis mean growth-factor derived
58
59        self.t0 = 1200 * si.second
60        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):
62    def w(self, t):
63        return (
64            0.5
65            * (
66                np.where(
67                    t < self.t0,
68                    1,
69                    np.sign(-np.sin(2 * np.pi * self.f0 * (t - self.t0))),
70                )
71            )
72            * si.metre
73            / si.second
74        )