PySDM_examples.seeding.settings

 1import numpy as np
 2from pystrict import strict
 3from PySDM.initialisation.spectra import Lognormal
 4from PySDM.initialisation.sampling.spectral_sampling import ConstantMultiplicity
 5from PySDM.physics import si
 6from PySDM import Formulae
 7
 8
 9@strict
10class Settings:
11    def __init__(
12        self,
13        *,
14        super_droplet_injection_rate: callable,
15        n_sd_initial: int,
16        n_sd_seeding: int,
17        rain_water_radius_threshold: float,
18        formulae: Formulae,
19        enable_collisions: bool = True,
20    ):
21        self.enable_collisions = enable_collisions
22        self.formulae = formulae
23        self.n_sd_initial = n_sd_initial
24        self.n_sd_seeding = n_sd_seeding
25        self.rain_water_radius_threshold = rain_water_radius_threshold
26
27        self.t_max = 25 * si.min
28        self.w_max = 3 * si.m / si.s
29        self.w_min = 0.025 * si.m / si.s
30
31        self.timestep = 15 * si.s
32        self.mass_of_dry_air = 666 * si.kg
33
34        self.updraft = (
35            lambda t: self.w_min
36            + (self.w_max - self.w_min)
37            * np.maximum(0, np.sin(t / self.t_max * 2 * np.pi)) ** 2
38        )
39        self.initial_water_vapour_mixing_ratio = 666 / 30 * si.g / si.kg
40        self.initial_total_pressure = 1000 * si.hPa
41        self.initial_temperature = 300 * si.K
42        self.initial_aerosol_kappa = 0.5
43        self.initial_aerosol_dry_radii = Lognormal(
44            norm_factor=200 / si.mg * self.mass_of_dry_air,
45            m_mode=75 * si.nm,
46            s_geom=1.6,
47        )
48        self.super_droplet_injection_rate = super_droplet_injection_rate
49
50        r_dry, n_in_dv = ConstantMultiplicity(
51            Lognormal(
52                norm_factor=10 / si.mg * self.mass_of_dry_air,
53                m_mode=1 * si.um,
54                s_geom=1.1,
55            )
56        ).sample(
57            n_sd=n_sd_seeding
58        )  # TODO #1387: does not to be the same?
59        v_dry = self.formulae.trivia.volume(radius=r_dry)
60        self.seeded_particle_multiplicity = n_in_dv
61        self.seeded_particle_extensive_attributes = {
62            "water mass": [0.0001 * si.ng] * n_sd_seeding,
63            "dry volume": v_dry,
64            "kappa times dry volume": 0.8 * v_dry,
65        }
@strict
class Settings:
10@strict
11class Settings:
12    def __init__(
13        self,
14        *,
15        super_droplet_injection_rate: callable,
16        n_sd_initial: int,
17        n_sd_seeding: int,
18        rain_water_radius_threshold: float,
19        formulae: Formulae,
20        enable_collisions: bool = True,
21    ):
22        self.enable_collisions = enable_collisions
23        self.formulae = formulae
24        self.n_sd_initial = n_sd_initial
25        self.n_sd_seeding = n_sd_seeding
26        self.rain_water_radius_threshold = rain_water_radius_threshold
27
28        self.t_max = 25 * si.min
29        self.w_max = 3 * si.m / si.s
30        self.w_min = 0.025 * si.m / si.s
31
32        self.timestep = 15 * si.s
33        self.mass_of_dry_air = 666 * si.kg
34
35        self.updraft = (
36            lambda t: self.w_min
37            + (self.w_max - self.w_min)
38            * np.maximum(0, np.sin(t / self.t_max * 2 * np.pi)) ** 2
39        )
40        self.initial_water_vapour_mixing_ratio = 666 / 30 * si.g / si.kg
41        self.initial_total_pressure = 1000 * si.hPa
42        self.initial_temperature = 300 * si.K
43        self.initial_aerosol_kappa = 0.5
44        self.initial_aerosol_dry_radii = Lognormal(
45            norm_factor=200 / si.mg * self.mass_of_dry_air,
46            m_mode=75 * si.nm,
47            s_geom=1.6,
48        )
49        self.super_droplet_injection_rate = super_droplet_injection_rate
50
51        r_dry, n_in_dv = ConstantMultiplicity(
52            Lognormal(
53                norm_factor=10 / si.mg * self.mass_of_dry_air,
54                m_mode=1 * si.um,
55                s_geom=1.1,
56            )
57        ).sample(
58            n_sd=n_sd_seeding
59        )  # TODO #1387: does not to be the same?
60        v_dry = self.formulae.trivia.volume(radius=r_dry)
61        self.seeded_particle_multiplicity = n_in_dv
62        self.seeded_particle_extensive_attributes = {
63            "water mass": [0.0001 * si.ng] * n_sd_seeding,
64            "dry volume": v_dry,
65            "kappa times dry volume": 0.8 * v_dry,
66        }
Settings( *, super_droplet_injection_rate: <built-in function callable>, n_sd_initial: int, n_sd_seeding: int, rain_water_radius_threshold: float, formulae: PySDM.formulae.Formulae, enable_collisions: bool = True)
12    def __init__(
13        self,
14        *,
15        super_droplet_injection_rate: callable,
16        n_sd_initial: int,
17        n_sd_seeding: int,
18        rain_water_radius_threshold: float,
19        formulae: Formulae,
20        enable_collisions: bool = True,
21    ):
22        self.enable_collisions = enable_collisions
23        self.formulae = formulae
24        self.n_sd_initial = n_sd_initial
25        self.n_sd_seeding = n_sd_seeding
26        self.rain_water_radius_threshold = rain_water_radius_threshold
27
28        self.t_max = 25 * si.min
29        self.w_max = 3 * si.m / si.s
30        self.w_min = 0.025 * si.m / si.s
31
32        self.timestep = 15 * si.s
33        self.mass_of_dry_air = 666 * si.kg
34
35        self.updraft = (
36            lambda t: self.w_min
37            + (self.w_max - self.w_min)
38            * np.maximum(0, np.sin(t / self.t_max * 2 * np.pi)) ** 2
39        )
40        self.initial_water_vapour_mixing_ratio = 666 / 30 * si.g / si.kg
41        self.initial_total_pressure = 1000 * si.hPa
42        self.initial_temperature = 300 * si.K
43        self.initial_aerosol_kappa = 0.5
44        self.initial_aerosol_dry_radii = Lognormal(
45            norm_factor=200 / si.mg * self.mass_of_dry_air,
46            m_mode=75 * si.nm,
47            s_geom=1.6,
48        )
49        self.super_droplet_injection_rate = super_droplet_injection_rate
50
51        r_dry, n_in_dv = ConstantMultiplicity(
52            Lognormal(
53                norm_factor=10 / si.mg * self.mass_of_dry_air,
54                m_mode=1 * si.um,
55                s_geom=1.1,
56            )
57        ).sample(
58            n_sd=n_sd_seeding
59        )  # TODO #1387: does not to be the same?
60        v_dry = self.formulae.trivia.volume(radius=r_dry)
61        self.seeded_particle_multiplicity = n_in_dv
62        self.seeded_particle_extensive_attributes = {
63            "water mass": [0.0001 * si.ng] * n_sd_seeding,
64            "dry volume": v_dry,
65            "kappa times dry volume": 0.8 * v_dry,
66        }
enable_collisions
formulae
n_sd_initial
n_sd_seeding
rain_water_radius_threshold
t_max
w_max
w_min
timestep
mass_of_dry_air
updraft
initial_water_vapour_mixing_ratio
initial_total_pressure
initial_temperature
initial_aerosol_kappa
initial_aerosol_dry_radii
super_droplet_injection_rate
seeded_particle_multiplicity
seeded_particle_extensive_attributes