PySDM-examples 2.73__py3-none-any.whl → 2.76__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PySDM_examples/seeding/__init__.py +2 -0
- PySDM_examples/seeding/settings.py +65 -0
- PySDM_examples/seeding/simulation.py +97 -0
- {PySDM_examples-2.73.dist-info → PySDM_examples-2.76.dist-info}/METADATA +1 -1
- {PySDM_examples-2.73.dist-info → PySDM_examples-2.76.dist-info}/RECORD +7 -4
- {PySDM_examples-2.73.dist-info → PySDM_examples-2.76.dist-info}/WHEEL +0 -0
- {PySDM_examples-2.73.dist-info → PySDM_examples-2.76.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from pystrict import strict
|
|
3
|
+
from PySDM.initialisation.spectra import Lognormal
|
|
4
|
+
from PySDM.initialisation.sampling.spectral_sampling import ConstantMultiplicity
|
|
5
|
+
from PySDM.physics import si
|
|
6
|
+
from PySDM import Formulae
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@strict
|
|
10
|
+
class 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
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
from PySDM_examples.seeding.settings import Settings
|
|
4
|
+
|
|
5
|
+
from PySDM import Builder
|
|
6
|
+
from PySDM.backends import CPU
|
|
7
|
+
from PySDM.environments import Parcel
|
|
8
|
+
from PySDM.dynamics import Condensation, AmbientThermodynamics, Coalescence, Seeding
|
|
9
|
+
from PySDM.dynamics.collisions.collision_kernels import Geometric
|
|
10
|
+
from PySDM.initialisation.sampling.spectral_sampling import ConstantMultiplicity
|
|
11
|
+
from PySDM import products
|
|
12
|
+
from PySDM.physics import si
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Simulation:
|
|
16
|
+
def __init__(self, settings: Settings):
|
|
17
|
+
builder = Builder(
|
|
18
|
+
n_sd=settings.n_sd_seeding + settings.n_sd_initial,
|
|
19
|
+
backend=CPU(
|
|
20
|
+
formulae=settings.formulae, override_jit_flags={"parallel": False}
|
|
21
|
+
),
|
|
22
|
+
environment=Parcel(
|
|
23
|
+
dt=settings.timestep,
|
|
24
|
+
mass_of_dry_air=settings.mass_of_dry_air,
|
|
25
|
+
w=settings.updraft,
|
|
26
|
+
initial_water_vapour_mixing_ratio=settings.initial_water_vapour_mixing_ratio,
|
|
27
|
+
p0=settings.initial_total_pressure,
|
|
28
|
+
T0=settings.initial_temperature,
|
|
29
|
+
),
|
|
30
|
+
)
|
|
31
|
+
builder.add_dynamic(AmbientThermodynamics())
|
|
32
|
+
builder.add_dynamic(Condensation())
|
|
33
|
+
if settings.enable_collisions:
|
|
34
|
+
builder.add_dynamic(Coalescence(collision_kernel=Geometric()))
|
|
35
|
+
builder.add_dynamic(
|
|
36
|
+
Seeding(
|
|
37
|
+
super_droplet_injection_rate=settings.super_droplet_injection_rate,
|
|
38
|
+
seeded_particle_multiplicity=settings.seeded_particle_multiplicity,
|
|
39
|
+
seeded_particle_extensive_attributes=settings.seeded_particle_extensive_attributes,
|
|
40
|
+
)
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
r_dry, n_in_dv = ConstantMultiplicity(
|
|
44
|
+
settings.initial_aerosol_dry_radii
|
|
45
|
+
).sample(n_sd=settings.n_sd_initial, backend=builder.particulator.backend)
|
|
46
|
+
attributes = builder.particulator.environment.init_attributes(
|
|
47
|
+
n_in_dv=n_in_dv, kappa=settings.initial_aerosol_kappa, r_dry=r_dry
|
|
48
|
+
)
|
|
49
|
+
self.particulator = builder.build(
|
|
50
|
+
attributes={
|
|
51
|
+
k: np.pad(
|
|
52
|
+
array=v,
|
|
53
|
+
pad_width=(0, settings.n_sd_seeding),
|
|
54
|
+
mode="constant",
|
|
55
|
+
constant_values=np.nan if k == "multiplicity" else 0,
|
|
56
|
+
)
|
|
57
|
+
for k, v in attributes.items()
|
|
58
|
+
},
|
|
59
|
+
products=(
|
|
60
|
+
products.SuperDropletCountPerGridbox(name="sd_count"),
|
|
61
|
+
products.Time(),
|
|
62
|
+
products.WaterMixingRatio(
|
|
63
|
+
radius_range=(settings.rain_water_radius_threshold, np.inf),
|
|
64
|
+
name="rain water mixing ratio",
|
|
65
|
+
),
|
|
66
|
+
products.EffectiveRadius(
|
|
67
|
+
name="r_eff",
|
|
68
|
+
unit="um",
|
|
69
|
+
radius_range=(0.5 * si.um, 25 * si.um),
|
|
70
|
+
),
|
|
71
|
+
products.ParticleConcentration(
|
|
72
|
+
name="n_drop",
|
|
73
|
+
unit="cm^-3",
|
|
74
|
+
radius_range=(0.5 * si.um, 25 * si.um),
|
|
75
|
+
),
|
|
76
|
+
),
|
|
77
|
+
)
|
|
78
|
+
self.n_steps = int(settings.t_max // settings.timestep)
|
|
79
|
+
|
|
80
|
+
def run(self):
|
|
81
|
+
output = {
|
|
82
|
+
"attributes": {"water mass": []},
|
|
83
|
+
"products": {key: [] for key in self.particulator.products},
|
|
84
|
+
}
|
|
85
|
+
for step in range(self.n_steps + 1):
|
|
86
|
+
if step != 0:
|
|
87
|
+
self.particulator.run(steps=1)
|
|
88
|
+
for key, attr in output["attributes"].items():
|
|
89
|
+
data = self.particulator.attributes[key].to_ndarray(raw=True)
|
|
90
|
+
data[data == 0] = np.nan
|
|
91
|
+
attr.append(data)
|
|
92
|
+
for key, prod in output["products"].items():
|
|
93
|
+
prod.append(float(self.particulator.products[key].get()))
|
|
94
|
+
for out in ("attributes", "products"):
|
|
95
|
+
for key, val in output[out].items():
|
|
96
|
+
output[out][key] = np.array(val)
|
|
97
|
+
return output
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PySDM-examples
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.76
|
|
4
4
|
Summary: PySDM usage examples reproducing results from literature and depicting how to use PySDM from Python Jupyter notebooks
|
|
5
5
|
Home-page: https://github.com/open-atmos/PySDM
|
|
6
6
|
Author: https://github.com/open-atmos/PySDM/graphs/contributors
|
|
@@ -136,6 +136,9 @@ PySDM_examples/deJong_Mackay_et_al_2023/settings_0D.py,sha256=ksclyxZ0sZNeLS-QZC
|
|
|
136
136
|
PySDM_examples/deJong_Mackay_et_al_2023/simulation1D.py,sha256=xDA7I3EBoeAw_sHfp7MuBzoDrCbkF4wOKDR2BRePZxk,2430
|
|
137
137
|
PySDM_examples/deJong_Mackay_et_al_2023/simulation_0D.py,sha256=RFXtnCsQDqB1c3yU7LJYmmWwEcCuP42D1Z8SeC9GUPw,4586
|
|
138
138
|
PySDM_examples/deJong_Mackay_et_al_2023/simulation_ss.py,sha256=fYE5LRPbt5qIYC3NaXhC-qsq9GDETBxmXf2Ih3ezFyw,5864
|
|
139
|
+
PySDM_examples/seeding/__init__.py,sha256=3iMpMdkdy_BEBBhjD9WR-2HbRHn7dop8kEk2uJJYe9U,66
|
|
140
|
+
PySDM_examples/seeding/settings.py,sha256=_dD_0YrWsXkqWpTuSHXDTUE9xktSd9196h6bpsLDNC4,2217
|
|
141
|
+
PySDM_examples/seeding/simulation.py,sha256=VQEoLnl4hwsWnZHq9hjv2DLWClKcmAXG0c7QNrcxaQc,3972
|
|
139
142
|
PySDM_examples/utils/__init__.py,sha256=MayUnfhdnjWwc5Ept-yYfCS_tuSR8yqe-RdBl8FO3Xk,258
|
|
140
143
|
PySDM_examples/utils/basic_simulation.py,sha256=4EdgD0p8EKNNcqYYVSlGm1MG2ac7_6heQdwS-kp-Tmw,698
|
|
141
144
|
PySDM_examples/utils/dummy_controller.py,sha256=f1AjVNXPnDhhD15GkBFtJthDf7jZivDrppj79guYc_w,741
|
|
@@ -145,7 +148,7 @@ PySDM_examples/utils/read_vtk_1d.py,sha256=7_3sagEbX_FxqFuGkFWdwQapd1-9echFghU8T
|
|
|
145
148
|
PySDM_examples/utils/widgets/__init__.py,sha256=U67WZ2YDcXSocMraI7pzcMxCfcxzXNqehDzoG6ogsh4,519
|
|
146
149
|
PySDM_examples/utils/widgets/freezer.py,sha256=tFlZWShXUzA2X0cxgeE44N1g9kD33q3KQWZBqkgBP0A,407
|
|
147
150
|
PySDM_examples/utils/widgets/progbar_updater.py,sha256=3uhG32QkAiSM3dTV7DoROJl7fAUNA6ZsJEIKSg3tdmk,267
|
|
148
|
-
PySDM_examples-2.
|
|
149
|
-
PySDM_examples-2.
|
|
150
|
-
PySDM_examples-2.
|
|
151
|
-
PySDM_examples-2.
|
|
151
|
+
PySDM_examples-2.76.dist-info/METADATA,sha256=nk71ql5tYDKlQILzESc_b5pHI55YGkhoRAGosCn9m-c,40750
|
|
152
|
+
PySDM_examples-2.76.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
153
|
+
PySDM_examples-2.76.dist-info/top_level.txt,sha256=axw2inuuYKPWkQhzBYtkZJTPDlo5LrpGLOA0iSAf9v0,15
|
|
154
|
+
PySDM_examples-2.76.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|