Skip to content

Commit d9aaf83

Browse files
authored
Merge pull request #1 from slayoo/compressed_film
Compressed film
2 parents caed8b3 + 09424cc commit d9aaf83

53 files changed

Lines changed: 1825 additions & 580 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

PySDM_examples/Arabas_and_Shima_2017/fig_5.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"import sys\n",
2626
"if 'google.colab' in sys.modules:\n",
2727
" !pip --quiet install PySDM-examples\\\n",
28-
" notebook==`python -c \"import notebook; print(notebook.__version__)\"` tornado==`python -c \"import tornado; print(tornado.version)\"` \\\n",
28+
" notebook==`python -c \"import notebook; print(notebook.__version__)\"` \\\n",
2929
" tornado==`python -c \"import tornado; print(tornado.version)\"`\n",
3030
" !ldconfig"
3131
]

PySDM_examples/Arabas_and_Shima_2017/settings.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
"""
2-
Created at 29.11.2019
3-
"""
4-
51
from PySDM.physics.constants import si
62
from PySDM.physics import constants as const, formulae as phys
73
from PySDM.dynamics import condensation

PySDM_examples/Arabas_and_Shima_2017/simulation.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,19 @@ def __init__(self, settings, backend=CPU):
3636

3737
builder.add_dynamic(AmbientThermodynamics())
3838
builder.add_dynamic(Condensation(
39-
kappa=settings.kappa,
4039
rtol_x=settings.rtol_x,
4140
rtol_thd=settings.rtol_thd,
4241
dt_cond_range=settings.dt_cond_range
4342
))
4443
attributes = {}
4544
r_dry = np.array([settings.r_dry])
46-
attributes['dry volume'] = settings.formulae.trivia.volume(radius=r_dry)
45+
attributes['dry volume inorganic'] = settings.formulae.trivia.volume(radius=r_dry)
46+
attributes['dry volume organic'] = np.zeros_like(r_dry)
47+
attributes['kappa times dry volume'] = attributes['dry volume inorganic'] * settings.kappa
4748
attributes['n'] = np.array([settings.n_in_dv], dtype=np.int64)
4849
environment = builder.core.environment
49-
r_wet = r_wet_init(r_dry, environment, kappa=settings.kappa)
50+
r_wet = r_wet_init(r_dry, environment,
51+
kappa_times_dry_volume=attributes['kappa times dry volume'])
5052
attributes['volume'] = settings.formulae.trivia.volume(radius=r_wet)
5153
products = [
5254
PySDM_products.ParticleMeanRadius(),

PySDM_examples/Arabas_et_al_2015/example.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from PySDM.exporters import NetCDFExporter
2-
from PySDM_examples.Arabas_et_al_2015.settings import Settings, si
3-
from PySDM_examples.Szumowski_et_al_1998.simulation import Simulation
4-
from PySDM_examples.Szumowski_et_al_1998.storage import Storage
5-
from PySDM_examples.utils import TemporaryFile
2+
from PySDM.physics import si
3+
from PySDM_examples.Arabas_et_al_2015 import Settings, SpinUp
4+
from PySDM_examples.Szumowski_et_al_1998 import Simulation, Storage
5+
from PySDM_examples.utils import TemporaryFile, DummyController
66

77

88
def main():
@@ -13,12 +13,12 @@ def main():
1313
settings.simulation_time = 5400 * si.second
1414

1515
storage = Storage()
16-
simulation = Simulation(settings, storage)
16+
simulation = Simulation(settings, storage, SpinUp)
1717
simulation.reinit()
1818
simulation.run()
1919
temp_file = TemporaryFile('.nc')
2020
exporter = NetCDFExporter(storage, settings, simulation, temp_file.absolute_path)
21-
exporter.run(controller=DummpyController())
21+
exporter.run(controller=DummyController())
2222

2323

2424
if __name__ == '__main__':

PySDM_examples/Arabas_et_al_2015/gui.ipynb

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,22 @@
3232
},
3333
{
3434
"cell_type": "code",
35-
"execution_count": 2,
35+
"execution_count": 3,
3636
"metadata": {
3737
"pycharm": {
3838
"name": "#%%\n"
3939
}
4040
},
4141
"outputs": [
42-
{
43-
"name": "stderr",
44-
"output_type": "stream",
45-
"text": [
46-
"/home/slayoo/devel/PySDM/PySDM/backends/__init__.py:29: UserWarning: CUDA library found but cuInit() failed (error code: 999; message: unknown error)\n",
47-
" warnings.warn(\n"
48-
]
49-
},
5042
{
5143
"data": {
5244
"application/vnd.jupyter.widget-view+json": {
53-
"model_id": "ab38937333f04f44b5ba4fbcf47510ba",
45+
"model_id": "1433d39befd54b3e959d0d4d5bad66f9",
5446
"version_major": 2,
5547
"version_minor": 0
5648
},
5749
"text/plain": [
58-
"Tab(children=(VBox(children=(HBox(children=(FloatProgress(value=0.0, max=1.0), Button(icon='play', style=Butto"
50+
"Tab(children=(VBox(children=(HBox(children=(FloatProgress(value=0.0, max=1.0), Button(description='start simul"
5951
]
6052
},
6153
"metadata": {},
@@ -95,9 +87,9 @@
9587
"name": "python",
9688
"nbconvert_exporter": "python",
9789
"pygments_lexer": "ipython3",
98-
"version": "3.8.7"
90+
"version": "3.8.2"
9991
}
10092
},
10193
"nbformat": 4,
10294
"nbformat_minor": 2
103-
}
95+
}
Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
from typing import Iterable
2-
import numba
3-
import numpy as np
4-
import scipy
52
from pystrict import strict
6-
from PySDM.dynamics import condensation, coalescence
7-
from PySDM.physics import spectra, si, Formulae, constants as const
3+
from PySDM.physics import si
84
from PySDM.backends.numba.conf import JIT_FLAGS
95
from PySDM_examples.Morrison_and_Grabowski_2007.strato_cumulus import StratoCumulus
106

@@ -26,20 +22,3 @@ def __init__(self, fastmath: bool = JIT_FLAGS['fastmath']):
2622
self.simulation_time = 90 * si.minute
2723
self.dt = 5 * si.second
2824
self.spin_up_time = 1 * si.hour
29-
30-
self.mode_1 = spectra.Lognormal(
31-
norm_factor=60 / si.centimetre ** 3 / const.rho_STP,
32-
m_mode=0.04 * si.micrometre,
33-
s_geom=1.4
34-
)
35-
self.mode_2 = spectra.Lognormal(
36-
norm_factor=40 / si.centimetre**3 / const.rho_STP,
37-
m_mode=0.15 * si.micrometre,
38-
s_geom=1.6
39-
)
40-
self.spectrum_per_mass_of_dry_air = spectra.Sum((self.mode_1, self.mode_2))
41-
42-
self.th_std0 = 289 * si.kelvins
43-
self.qv0 = 7.5 * si.grams / si.kilogram
44-
self.p0 = 1015 * si.hectopascals
45-
self.kappa = 1 # TODO #441!
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
from PySDM.dynamics import Displacement
2-
from PySDM.dynamics import Coalescence
3-
import warnings
1+
from PySDM.dynamics import Displacement, Coalescence, Freezing
42

53

64
class SpinUp:
@@ -11,15 +9,15 @@ def __init__(self, core, spin_up_steps):
119
self.core = core
1210
self.set(Coalescence, 'enable', False)
1311
self.set(Displacement, 'enable_sedimentation', False)
12+
self.set(Freezing, 'enable', False)
1413

1514
def notify(self):
1615
if self.core.n_steps == self.spin_up_steps:
1716
self.set(Coalescence, 'enable', True)
1817
self.set(Displacement, 'enable_sedimentation', True)
18+
self.set(Freezing, 'enable', True)
1919

2020
def set(self, dynamic, attr, value):
2121
key = dynamic.__name__
2222
if key in self.core.dynamics:
2323
setattr(self.core.dynamics[key], attr, value)
24-
else:
25-
warnings.warn(f"{key} not found!")

PySDM_examples/Bartman_et_al_2021/demo.ipynb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"import sys\n",
1010
"if 'google.colab' in sys.modules:\n",
1111
" !pip --quiet install PySDM-examples\\\n",
12-
" notebook==`python -c \"import notebook; print(notebook.__version__)\"` tornado==`python -c \"import tornado; print(tornado.version)\"` \\\n",
12+
" notebook==`python -c \"import notebook; print(notebook.__version__)\"` \\\n",
1313
" tornado==`python -c \"import tornado; print(tornado.version)\"`\n",
1414
" !ldconfig"
1515
]
@@ -32,9 +32,8 @@
3232
"from PySDM_examples.Arabas_et_al_2015 import Settings, SpinUp\n",
3333
"from PySDM_examples.Szumowski_et_al_1998 import Simulation, Storage\n",
3434
"from PySDM_examples.Szumowski_et_al_1998.plots import _TimeseriesPlot, _ImagePlot\n",
35-
"from PySDM_examples.utils import TemporaryFile\n",
35+
"from PySDM_examples.utils import TemporaryFile, ProgBarController\n",
3636
"from PySDM_examples.utils.widgets import HTML, display\n",
37-
"from PySDM_examples.Bartman_et_al_2021.progbar_controller import ProgBarController\n",
3837
"import PySDM.products as PySDM_products\n",
3938
"from PySDM.exporters import NetCDFExporter\n",
4039
"\n",

0 commit comments

Comments
 (0)