PySDM_examples.deJong_Mackay_et_al_2023.settings_0D

 1from typing import Optional
 2
 3import numpy as np
 4from pystrict import strict
 5
 6from PySDM.dynamics.collisions import breakup_fragmentations
 7from PySDM.dynamics.collisions.breakup_efficiencies import ConstEb
 8from PySDM.dynamics.collisions.coalescence_efficiencies import Berry1967
 9from PySDM.dynamics.collisions.collision_kernels import Geometric
10from PySDM.formulae import Formulae
11from PySDM.initialisation import spectra
12from PySDM.physics import si
13
14TRIVIA = Formulae().trivia
15
16
17@strict
18class Settings0D:
19    X0 = TRIVIA.volume(radius=30.531 * si.micrometres)
20
21    def __init__(
22        self,
23        fragmentation: object = None,
24        seed: Optional[int] = None,
25        warn_overflows: bool = True,
26    ):
27        self.n_sd = 2**10
28        self.n_part = 100 / si.cm**3
29        self.frag_scale = TRIVIA.volume(radius=100 * si.micrometres)
30        self.dv = 1 * si.m**3
31        self.norm_factor = self.n_part * self.dv
32        self.rho = 1000 * si.kilogram / si.metre**3
33        self.dt = 1 * si.seconds
34        self.adaptive = True
35        self.warn_overflows = warn_overflows
36        self.seed = 44
37        self._steps = [0]
38        self.kernel = Geometric()
39        self.coal_eff = Berry1967()
40        self.fragmentation = fragmentation or breakup_fragmentations.Exponential(
41            scale=self.frag_scale
42        )
43        self.vmin = 0.0
44        self.break_eff = ConstEb(1.0)  # no "bouncing"
45        self.spectrum = spectra.Exponential(norm_factor=self.norm_factor, scale=self.X0)
46        self.radius_bins_edges = np.logspace(
47            np.log10(0.01 * si.um), np.log10(5000 * si.um), num=64, endpoint=True
48        )
49        self.radius_range = [0 * si.um, 1e6 * si.um]
50        self.formulae = Formulae(
51            seed=seed, fragmentation_function=self.fragmentation.__class__.__name__
52        )
53
54    @property
55    def output_steps(self):
56        return [int(step / self.dt) for step in self._steps]
TRIVIA = namespace(__name__='Trivia', H2pH=CPUDispatcher(<function _.H2pH>), air_schmidt_number=CPUDispatcher(<function _.air_schmidt_number>), area=CPUDispatcher(<function _.area>), arrhenius=CPUDispatcher(<function _.arrhenius>), dn_dlogr=CPUDispatcher(<function _.dn_dlogr>), erfinv_approx=CPUDispatcher(<function _.erfinv_approx>), explicit_euler=CPUDispatcher(<function _.explicit_euler>), frozen_and_above_freezing_point=CPUDispatcher(<function _.frozen_and_above_freezing_point>), isotopic_delta_2_ratio=CPUDispatcher(<function _.isotopic_delta_2_ratio>), isotopic_enrichment_to_delta_SMOW=CPUDispatcher(<function _.isotopic_enrichment_to_delta_SMOW>), isotopic_ratio_2_delta=CPUDispatcher(<function _.isotopic_ratio_2_delta>), mixing_ratio_2_mole_fraction=CPUDispatcher(<function _.mixing_ratio_2_mole_fraction>), mixing_ratio_to_specific_content=CPUDispatcher(<function _.mixing_ratio_to_specific_content>), mole_fraction_2_mixing_ratio=CPUDispatcher(<function _.mole_fraction_2_mixing_ratio>), pH2H=CPUDispatcher(<function _.pH2H>), p_d=CPUDispatcher(<function _.p_d>), radius=CPUDispatcher(<function _.radius>), sphere_surface=CPUDispatcher(<function _.sphere_surface>), sqrt_re_times_cbrt_sc=CPUDispatcher(<function _.sqrt_re_times_cbrt_sc>), tdep2enthalpy=CPUDispatcher(<function _.tdep2enthalpy>), th_std=CPUDispatcher(<function _.th_std>), unfrozen_and_saturated=CPUDispatcher(<function _.unfrozen_and_saturated>), vant_hoff=CPUDispatcher(<function _.vant_hoff>), volume=CPUDispatcher(<function _.volume>), volume_of_density_mass=CPUDispatcher(<function _.volume_of_density_mass>), within_tolerance=CPUDispatcher(<function _.within_tolerance>))
@strict
class Settings0D:
18@strict
19class Settings0D:
20    X0 = TRIVIA.volume(radius=30.531 * si.micrometres)
21
22    def __init__(
23        self,
24        fragmentation: object = None,
25        seed: Optional[int] = None,
26        warn_overflows: bool = True,
27    ):
28        self.n_sd = 2**10
29        self.n_part = 100 / si.cm**3
30        self.frag_scale = TRIVIA.volume(radius=100 * si.micrometres)
31        self.dv = 1 * si.m**3
32        self.norm_factor = self.n_part * self.dv
33        self.rho = 1000 * si.kilogram / si.metre**3
34        self.dt = 1 * si.seconds
35        self.adaptive = True
36        self.warn_overflows = warn_overflows
37        self.seed = 44
38        self._steps = [0]
39        self.kernel = Geometric()
40        self.coal_eff = Berry1967()
41        self.fragmentation = fragmentation or breakup_fragmentations.Exponential(
42            scale=self.frag_scale
43        )
44        self.vmin = 0.0
45        self.break_eff = ConstEb(1.0)  # no "bouncing"
46        self.spectrum = spectra.Exponential(norm_factor=self.norm_factor, scale=self.X0)
47        self.radius_bins_edges = np.logspace(
48            np.log10(0.01 * si.um), np.log10(5000 * si.um), num=64, endpoint=True
49        )
50        self.radius_range = [0 * si.um, 1e6 * si.um]
51        self.formulae = Formulae(
52            seed=seed, fragmentation_function=self.fragmentation.__class__.__name__
53        )
54
55    @property
56    def output_steps(self):
57        return [int(step / self.dt) for step in self._steps]
Settings0D( fragmentation: object = None, seed: Optional[int] = None, warn_overflows: bool = True)
22    def __init__(
23        self,
24        fragmentation: object = None,
25        seed: Optional[int] = None,
26        warn_overflows: bool = True,
27    ):
28        self.n_sd = 2**10
29        self.n_part = 100 / si.cm**3
30        self.frag_scale = TRIVIA.volume(radius=100 * si.micrometres)
31        self.dv = 1 * si.m**3
32        self.norm_factor = self.n_part * self.dv
33        self.rho = 1000 * si.kilogram / si.metre**3
34        self.dt = 1 * si.seconds
35        self.adaptive = True
36        self.warn_overflows = warn_overflows
37        self.seed = 44
38        self._steps = [0]
39        self.kernel = Geometric()
40        self.coal_eff = Berry1967()
41        self.fragmentation = fragmentation or breakup_fragmentations.Exponential(
42            scale=self.frag_scale
43        )
44        self.vmin = 0.0
45        self.break_eff = ConstEb(1.0)  # no "bouncing"
46        self.spectrum = spectra.Exponential(norm_factor=self.norm_factor, scale=self.X0)
47        self.radius_bins_edges = np.logspace(
48            np.log10(0.01 * si.um), np.log10(5000 * si.um), num=64, endpoint=True
49        )
50        self.radius_range = [0 * si.um, 1e6 * si.um]
51        self.formulae = Formulae(
52            seed=seed, fragmentation_function=self.fragmentation.__class__.__name__
53        )
X0 = 1.192097279896558e-13
n_sd
n_part
frag_scale
dv
norm_factor
rho
dt
adaptive
warn_overflows
seed
kernel
coal_eff
fragmentation
vmin
break_eff
spectrum
radius_bins_edges
radius_range
formulae
output_steps
55    @property
56    def output_steps(self):
57        return [int(step / self.dt) for step in self._steps]