PySDM_examples.deJong_Mackay_et_al_2023.settings1D

 1from typing import Iterable
 2
 3import numpy as np
 4from PySDM_examples.Shipway_and_Hill_2012 import Settings as SettingsSH
 5
 6from PySDM import Formulae
 7from PySDM.dynamics.collisions.breakup_efficiencies import ConstEb
 8from PySDM.dynamics.collisions.breakup_fragmentations import Gaussian, Straub2010Nf
 9from PySDM.dynamics.collisions.coalescence_efficiencies import ConstEc, Straub2010Ec
10from PySDM.physics import si
11
12
13class Settings1D(SettingsSH):
14    def __dir__(self) -> Iterable[str]:
15        return (
16            "n_sd_per_gridbox",
17            "p0",
18            "kappa",
19            "rho_times_w_1",
20            "particles_per_volume_STP",
21            "dt",
22            "dz",
23            "precip",
24            "breakup",
25            "stochastic_breakup",
26            "z_max",
27            "t_max",
28            "cloud_water_radius_range",
29            "rain_water_radius_range",
30            "r_bins_edges_dry",
31            "r_bins_edges",
32            "save_spec_at",
33        )
34
35    def __init__(
36        self,
37        *,
38        n_sd_per_gridbox: int,
39        p0: float = 1007 * si.hPa,  # as used in Olesik et al. 2022 (GMD)
40        kappa: float = 1,
41        rho_times_w_1: float = 2 * si.m / si.s * si.kg / si.m**3,
42        particles_per_volume_STP: int = 50 / si.cm**3,
43        dt: float = 1 * si.s,
44        dz: float = 25 * si.m,
45        z_max: float = 3000 * si.m,
46        t_max: float = 3600 * si.s,
47        precip: bool = True,
48        breakup: bool = False,
49        stochastic_breakup: bool = False,
50        warn_breakup_overflow: bool = False,
51        output_every_n_steps: int = 1,
52        save_spec_at=()
53    ):
54        if stochastic_breakup:
55            self.coalescence_efficiency = Straub2010Ec()
56            self.fragmentation_function = Straub2010Nf(vmin=1 * si.um**3)
57        else:
58            self.coalescence_efficiency = ConstEc(Ec=0.95)
59            frag_scale_r = 30 * si.um
60            frag_scale_v = frag_scale_r**3 * 4 / 3 * np.pi
61            self.fragmentation_function = Gaussian(
62                mu=frag_scale_v,
63                sigma=frag_scale_v / 2,
64                vmin=(1 * si.um) ** 3,
65                nfmax=20,
66            )
67
68        super().__init__(
69            n_sd_per_gridbox=n_sd_per_gridbox,
70            p0=p0,
71            kappa=kappa,
72            rho_times_w_1=rho_times_w_1,
73            particles_per_volume_STP=particles_per_volume_STP,
74            dt=dt,
75            dz=dz,
76            z_max=z_max,
77            t_max=t_max,
78            precip=precip,
79            formulae=Formulae(
80                fragmentation_function=self.fragmentation_function.__class__.__name__
81            ),
82            save_spec_and_attr_times=save_spec_at,
83        )
84        self.breakup = breakup
85        self.stochastic_breakup = stochastic_breakup
86
87        self.breakup_efficiency = ConstEb(Eb=1.0)
88
89        self.warn_breakup_overflow = warn_breakup_overflow
90        self.output_steps = range(0, self.nt, output_every_n_steps)
14class Settings1D(SettingsSH):
15    def __dir__(self) -> Iterable[str]:
16        return (
17            "n_sd_per_gridbox",
18            "p0",
19            "kappa",
20            "rho_times_w_1",
21            "particles_per_volume_STP",
22            "dt",
23            "dz",
24            "precip",
25            "breakup",
26            "stochastic_breakup",
27            "z_max",
28            "t_max",
29            "cloud_water_radius_range",
30            "rain_water_radius_range",
31            "r_bins_edges_dry",
32            "r_bins_edges",
33            "save_spec_at",
34        )
35
36    def __init__(
37        self,
38        *,
39        n_sd_per_gridbox: int,
40        p0: float = 1007 * si.hPa,  # as used in Olesik et al. 2022 (GMD)
41        kappa: float = 1,
42        rho_times_w_1: float = 2 * si.m / si.s * si.kg / si.m**3,
43        particles_per_volume_STP: int = 50 / si.cm**3,
44        dt: float = 1 * si.s,
45        dz: float = 25 * si.m,
46        z_max: float = 3000 * si.m,
47        t_max: float = 3600 * si.s,
48        precip: bool = True,
49        breakup: bool = False,
50        stochastic_breakup: bool = False,
51        warn_breakup_overflow: bool = False,
52        output_every_n_steps: int = 1,
53        save_spec_at=()
54    ):
55        if stochastic_breakup:
56            self.coalescence_efficiency = Straub2010Ec()
57            self.fragmentation_function = Straub2010Nf(vmin=1 * si.um**3)
58        else:
59            self.coalescence_efficiency = ConstEc(Ec=0.95)
60            frag_scale_r = 30 * si.um
61            frag_scale_v = frag_scale_r**3 * 4 / 3 * np.pi
62            self.fragmentation_function = Gaussian(
63                mu=frag_scale_v,
64                sigma=frag_scale_v / 2,
65                vmin=(1 * si.um) ** 3,
66                nfmax=20,
67            )
68
69        super().__init__(
70            n_sd_per_gridbox=n_sd_per_gridbox,
71            p0=p0,
72            kappa=kappa,
73            rho_times_w_1=rho_times_w_1,
74            particles_per_volume_STP=particles_per_volume_STP,
75            dt=dt,
76            dz=dz,
77            z_max=z_max,
78            t_max=t_max,
79            precip=precip,
80            formulae=Formulae(
81                fragmentation_function=self.fragmentation_function.__class__.__name__
82            ),
83            save_spec_and_attr_times=save_spec_at,
84        )
85        self.breakup = breakup
86        self.stochastic_breakup = stochastic_breakup
87
88        self.breakup_efficiency = ConstEb(Eb=1.0)
89
90        self.warn_breakup_overflow = warn_breakup_overflow
91        self.output_steps = range(0, self.nt, output_every_n_steps)
Settings1D( *, n_sd_per_gridbox: int, p0: float = 100700.0, kappa: float = 1, rho_times_w_1: float = 2.0, particles_per_volume_STP: int = 49999999.99999999, dt: float = 1.0, dz: float = 25.0, z_max: float = 3000.0, t_max: float = 3600.0, precip: bool = True, breakup: bool = False, stochastic_breakup: bool = False, warn_breakup_overflow: bool = False, output_every_n_steps: int = 1, save_spec_at=())
36    def __init__(
37        self,
38        *,
39        n_sd_per_gridbox: int,
40        p0: float = 1007 * si.hPa,  # as used in Olesik et al. 2022 (GMD)
41        kappa: float = 1,
42        rho_times_w_1: float = 2 * si.m / si.s * si.kg / si.m**3,
43        particles_per_volume_STP: int = 50 / si.cm**3,
44        dt: float = 1 * si.s,
45        dz: float = 25 * si.m,
46        z_max: float = 3000 * si.m,
47        t_max: float = 3600 * si.s,
48        precip: bool = True,
49        breakup: bool = False,
50        stochastic_breakup: bool = False,
51        warn_breakup_overflow: bool = False,
52        output_every_n_steps: int = 1,
53        save_spec_at=()
54    ):
55        if stochastic_breakup:
56            self.coalescence_efficiency = Straub2010Ec()
57            self.fragmentation_function = Straub2010Nf(vmin=1 * si.um**3)
58        else:
59            self.coalescence_efficiency = ConstEc(Ec=0.95)
60            frag_scale_r = 30 * si.um
61            frag_scale_v = frag_scale_r**3 * 4 / 3 * np.pi
62            self.fragmentation_function = Gaussian(
63                mu=frag_scale_v,
64                sigma=frag_scale_v / 2,
65                vmin=(1 * si.um) ** 3,
66                nfmax=20,
67            )
68
69        super().__init__(
70            n_sd_per_gridbox=n_sd_per_gridbox,
71            p0=p0,
72            kappa=kappa,
73            rho_times_w_1=rho_times_w_1,
74            particles_per_volume_STP=particles_per_volume_STP,
75            dt=dt,
76            dz=dz,
77            z_max=z_max,
78            t_max=t_max,
79            precip=precip,
80            formulae=Formulae(
81                fragmentation_function=self.fragmentation_function.__class__.__name__
82            ),
83            save_spec_and_attr_times=save_spec_at,
84        )
85        self.breakup = breakup
86        self.stochastic_breakup = stochastic_breakup
87
88        self.breakup_efficiency = ConstEb(Eb=1.0)
89
90        self.warn_breakup_overflow = warn_breakup_overflow
91        self.output_steps = range(0, self.nt, output_every_n_steps)
breakup
stochastic_breakup
breakup_efficiency
warn_breakup_overflow
output_steps