|
22 | 22 | }, |
23 | 23 | { |
24 | 24 | "cell_type": "code", |
| 25 | + "execution_count": 7, |
25 | 26 | "id": "93289adf665b5c7f", |
26 | 27 | "metadata": { |
27 | 28 | "ExecuteTime": { |
28 | 29 | "end_time": "2025-05-09T08:27:59.767037Z", |
29 | 30 | "start_time": "2025-05-09T08:27:59.763173Z" |
30 | 31 | } |
31 | 32 | }, |
| 33 | + "outputs": [], |
32 | 34 | "source": [ |
33 | 35 | "import sys\n", |
34 | 36 | "if 'google.colab' in sys.modules:\n", |
35 | 37 | " !pip --quiet install open-atmos-jupyter-utils\n", |
36 | 38 | " from open_atmos_jupyter_utils import pip_install_on_colab\n", |
37 | 39 | " pip_install_on_colab('PySDM-examples')" |
38 | | - ], |
39 | | - "outputs": [], |
40 | | - "execution_count": 1 |
| 40 | + ] |
41 | 41 | }, |
42 | 42 | { |
43 | 43 | "cell_type": "code", |
| 44 | + "execution_count": 8, |
44 | 45 | "id": "e3537b5faa81e11f", |
45 | 46 | "metadata": { |
46 | 47 | "ExecuteTime": { |
47 | 48 | "end_time": "2025-05-09T08:28:06.258130Z", |
48 | 49 | "start_time": "2025-05-09T08:28:00.353771Z" |
49 | 50 | } |
50 | 51 | }, |
| 52 | + "outputs": [], |
51 | 53 | "source": [ |
52 | 54 | "import os\n", |
53 | 55 | "import subprocess\n", |
|
65 | 67 | "# check if Paraview's pvpython works\n", |
66 | 68 | "assert subprocess.check_call(['pvpython', '--version'], env=SUBPROCESS_ENV) == 0\n", |
67 | 69 | "assert subprocess.check_call(['pvpython', '-c', 'import paraview'], env=SUBPROCESS_ENV) == 0" |
68 | | - ], |
69 | | - "outputs": [ |
70 | | - { |
71 | | - "name": "stdout", |
72 | | - "output_type": "stream", |
73 | | - "text": [ |
74 | | - "paraview version 5.13.1\n" |
75 | | - ] |
76 | | - } |
77 | | - ], |
78 | | - "execution_count": 2 |
| 70 | + ] |
79 | 71 | }, |
80 | 72 | { |
81 | 73 | "cell_type": "code", |
| 74 | + "execution_count": 11, |
82 | 75 | "id": "ee889545", |
83 | 76 | "metadata": { |
84 | 77 | "ExecuteTime": { |
85 | 78 | "end_time": "2025-05-09T08:28:08.607057Z", |
86 | 79 | "start_time": "2025-05-09T08:28:06.263583Z" |
87 | 80 | } |
88 | 81 | }, |
| 82 | + "outputs": [], |
89 | 83 | "source": [ |
90 | 84 | "from PySDM_examples.Arabas_et_al_2015 import Settings, SpinUp\n", |
91 | 85 | "from PySDM_examples.utils.kinematic_2d import Simulation, Storage\n", |
92 | 86 | "from PySDM.exporters import VTKExporter\n", |
93 | 87 | "from PySDM_examples.utils import ProgBarController\n", |
| 88 | + "from PySDM.physics import si\n", |
94 | 89 | "from PySDM import products as PySDM_products\n", |
95 | 90 | "import PySDM_examples\n", |
96 | 91 | "import glob\n", |
97 | 92 | "import platform\n", |
98 | 93 | "import pathlib" |
99 | | - ], |
100 | | - "outputs": [], |
101 | | - "execution_count": 3 |
| 94 | + ] |
102 | 95 | }, |
103 | 96 | { |
104 | 97 | "cell_type": "code", |
| 98 | + "execution_count": 2, |
105 | 99 | "id": "f0d2581f", |
106 | 100 | "metadata": { |
107 | 101 | "ExecuteTime": { |
108 | 102 | "end_time": "2025-05-09T08:28:08.617918Z", |
109 | 103 | "start_time": "2025-05-09T08:28:08.615072Z" |
110 | 104 | } |
111 | 105 | }, |
| 106 | + "outputs": [], |
112 | 107 | "source": [ |
113 | 108 | "products = [\n", |
114 | 109 | " PySDM_products.EffectiveRadius(unit='um'),\n", |
115 | 110 | " PySDM_products.FlowVelocityComponent(component = 0, name = 'cx'),\n", |
116 | 111 | " PySDM_products.FlowVelocityComponent(component = 1, name = 'cy')\n", |
117 | 112 | "]" |
118 | | - ], |
119 | | - "outputs": [], |
120 | | - "execution_count": 4 |
| 113 | + ] |
121 | 114 | }, |
122 | 115 | { |
123 | 116 | "cell_type": "markdown", |
|
128 | 121 | ] |
129 | 122 | }, |
130 | 123 | { |
131 | | - "metadata": {}, |
132 | 124 | "cell_type": "code", |
133 | | - "outputs": [], |
134 | 125 | "execution_count": null, |
| 126 | + "id": "c7634bb25cdbbe46", |
| 127 | + "metadata": {}, |
| 128 | + "outputs": [ |
| 129 | + { |
| 130 | + "data": { |
| 131 | + "application/vnd.jupyter.widget-view+json": { |
| 132 | + "model_id": "61d7c35b77214683bb1b3ed29d10c44d", |
| 133 | + "version_major": 2, |
| 134 | + "version_minor": 0 |
| 135 | + }, |
| 136 | + "text/plain": [ |
| 137 | + "FloatProgress(value=0.0, description='progress:', max=1.0)" |
| 138 | + ] |
| 139 | + }, |
| 140 | + "metadata": {}, |
| 141 | + "output_type": "display_data" |
| 142 | + } |
| 143 | + ], |
135 | 144 | "source": [ |
136 | 145 | "settings = Settings()\n", |
| 146 | + "settings.simulation_time = 100 * si.minute\n", |
137 | 147 | "storage = Storage()\n", |
138 | 148 | "simulation = Simulation(settings, storage, SpinUp=SpinUp)\n", |
139 | 149 | "simulation.reinit(products)\n", |
|
142 | 152 | "\n", |
143 | 153 | "simulation.run(ProgBarController(\"progress:\"), vtk_exporter=vtk_exporter)\n", |
144 | 154 | "vtk_exporter.write_pvd()" |
145 | | - ], |
146 | | - "id": "c7634bb25cdbbe46" |
| 155 | + ] |
147 | 156 | }, |
148 | 157 | { |
149 | 158 | "cell_type": "markdown", |
150 | 159 | "id": "066f9c18", |
151 | 160 | "metadata": {}, |
152 | | - "source": "#### 2. execute ``PySDM_examples/utils/pvanim.py`` script using `pvpython`" |
| 161 | + "source": [ |
| 162 | + "#### 2. execute ``PySDM_examples/utils/pvanim.py`` script using `pvpython`" |
| 163 | + ] |
153 | 164 | }, |
154 | 165 | { |
| 166 | + "cell_type": "code", |
| 167 | + "execution_count": 9, |
| 168 | + "id": "154ce67d9a84a51d", |
155 | 169 | "metadata": { |
156 | 170 | "ExecuteTime": { |
157 | 171 | "end_time": "2025-05-09T08:52:00.913288Z", |
158 | 172 | "start_time": "2025-05-09T08:51:55.311337Z" |
159 | 173 | } |
160 | 174 | }, |
161 | | - "cell_type": "code", |
| 175 | + "outputs": [], |
162 | 176 | "source": [ |
163 | 177 | "pvanim = pathlib.Path(PySDM_examples.__file__).parent / \"utils\" / \"pvanim.py\"\n", |
164 | 178 | "result = subprocess.run([\"pvpython\", str(pvanim), '--help'], check=True, env=SUBPROCESS_ENV)" |
165 | | - ], |
166 | | - "id": "154ce67d9a84a51d", |
167 | | - "outputs": [ |
168 | | - { |
169 | | - "name": "stdout", |
170 | | - "output_type": "stream", |
171 | | - "text": [ |
172 | | - "usage: pvanim.py [-h] [--multiplicity_preset MULTIPLICITY_PRESET]\n", |
173 | | - " [--multiplicity_logscale]\n", |
174 | | - " [--effectiveradius_preset EFFECTIVERADIUS_PRESET]\n", |
175 | | - " [--effectiveradius_logscale]\n", |
176 | | - " [--effectiveradius_nan_color EFFECTIVERADIUS_NAN_COLOR EFFECTIVERADIUS_NAN_COLOR EFFECTIVERADIUS_NAN_COLOR]\n", |
177 | | - " [--sd_products_opacity SD_PRODUCTS_OPACITY]\n", |
178 | | - " [--calculator1_opacity CALCULATOR1_OPACITY]\n", |
179 | | - " [--sd_attributes_opacity SD_ATTRIBUTES_OPACITY]\n", |
180 | | - " [--animationframename ANIMATIONFRAMENAME]\n", |
181 | | - " [--animationname ANIMATIONNAME] [--framerate FRAMERATE]\n", |
182 | | - " product_path attributes_path output_path\n", |
183 | | - "\n", |
184 | | - "positional arguments:\n", |
185 | | - " product_path path to pvd products file\n", |
186 | | - " attributes_path path to pvd attributes file\n", |
187 | | - " output_path path where to write output files\n", |
188 | | - "\n", |
189 | | - "options:\n", |
190 | | - " -h, --help show this help message and exit\n", |
191 | | - " --multiplicity_preset MULTIPLICITY_PRESET\n", |
192 | | - " Preset for multiplicity (default: Inferno\n", |
193 | | - " (matplotlib))\n", |
194 | | - " --multiplicity_logscale\n", |
195 | | - " Use log scale for multiplicity (default: True)\n", |
196 | | - " --effectiveradius_preset EFFECTIVERADIUS_PRESET\n", |
197 | | - " Preset for effectiveradius (default: Black, Blue and\n", |
198 | | - " White)\n", |
199 | | - " --effectiveradius_logscale\n", |
200 | | - " Use log scale for effectiveradius (default: True)\n", |
201 | | - " --effectiveradius_nan_color EFFECTIVERADIUS_NAN_COLOR EFFECTIVERADIUS_NAN_COLOR EFFECTIVERADIUS_NAN_COLOR\n", |
202 | | - " Nan color in RGB format for effectiveradius (default:\n", |
203 | | - " [0.666, 0.333, 1.0])\n", |
204 | | - " --sd_products_opacity SD_PRODUCTS_OPACITY\n", |
205 | | - " Opacity for sd_products (default: 0.9)\n", |
206 | | - " --calculator1_opacity CALCULATOR1_OPACITY\n", |
207 | | - " Opacity for calculator1 (default: 0.19)\n", |
208 | | - " --sd_attributes_opacity SD_ATTRIBUTES_OPACITY\n", |
209 | | - " Opacity for sd_attributes (default: 0.77)\n", |
210 | | - " --animationframename ANIMATIONFRAMENAME\n", |
211 | | - " Name of the file with animation last frame (default:\n", |
212 | | - " None)\n", |
213 | | - " --animationname ANIMATIONNAME\n", |
214 | | - " Name of the file with animation (default: None)\n", |
215 | | - " --framerate FRAMERATE\n", |
216 | | - " Number of frame rates. (default: 15)\n" |
217 | | - ] |
218 | | - } |
219 | | - ], |
220 | | - "execution_count": 10 |
| 179 | + ] |
221 | 180 | }, |
222 | 181 | { |
223 | 182 | "cell_type": "code", |
| 183 | + "execution_count": 10, |
224 | 184 | "id": "23e0cf61", |
225 | 185 | "metadata": { |
226 | 186 | "ExecuteTime": { |
227 | 187 | "end_time": "2025-05-09T08:27:54.021909Z", |
228 | 188 | "start_time": "2025-05-09T08:25:42.918680Z" |
229 | 189 | } |
230 | 190 | }, |
| 191 | + "outputs": [], |
231 | 192 | "source": [ |
232 | 193 | "product = pathlib.Path(\"./output/sd_products.pvd\").absolute()\n", |
233 | 194 | "attributes = pathlib.Path(\"./output/sd_attributes.pvd\").absolute()\n", |
234 | 195 | "\n", |
235 | 196 | "try:\n", |
236 | | - " result = subprocess.run(\n", |
237 | | - " [\n", |
238 | | - " \"pvpython\",\n", |
239 | | - " \"--force-offscreen-rendering\",\n", |
240 | | - " str(pvanim),\n", |
241 | | - " str(product),\n", |
242 | | - " str(attributes),\n", |
243 | | - " str(pathlib.Path('./output').absolute()),\n", |
244 | | - " \"--animationname\", \"docs_intro_animation.ogv\",\n", |
245 | | - " \"--animationframename\", \"last_animation_frame.pdf\"\n", |
246 | | - " ],\n", |
247 | | - " check=platform.system() != \"Windows\",\n", |
248 | | - " capture_output=True,\n", |
249 | | - " text=True,\n", |
250 | | - " env=SUBPROCESS_ENV,\n", |
251 | | - " )\n", |
| 197 | + " for mode in ('light', 'dark'):\n", |
| 198 | + " result = subprocess.run(\n", |
| 199 | + " [\n", |
| 200 | + " \"pvpython\",\n", |
| 201 | + " \"--force-offscreen-rendering\",\n", |
| 202 | + " str(pvanim),\n", |
| 203 | + " str(product),\n", |
| 204 | + " str(attributes),\n", |
| 205 | + " str(pathlib.Path('./output').absolute()),\n", |
| 206 | + " \"--animationname\", \"docs_intro_animation.ogv\",\n", |
| 207 | + " \"--mode\", mode,\n", |
| 208 | + " ] + ([\"--animationframename\", \"last_animation_frame.pdf\"] if mode == 'light' else []),\n", |
| 209 | + " check=platform.system() != \"Windows\",\n", |
| 210 | + " capture_output=True,\n", |
| 211 | + " text=True,\n", |
| 212 | + " env=SUBPROCESS_ENV,\n", |
| 213 | + " )\n", |
252 | 214 | "except subprocess.CalledProcessError as e:\n", |
253 | 215 | " print(e.stderr)\n", |
254 | 216 | " assert False" |
255 | | - ], |
256 | | - "outputs": [], |
257 | | - "execution_count": 13 |
| 217 | + ] |
258 | 218 | }, |
259 | 219 | { |
260 | 220 | "cell_type": "markdown", |
|
266 | 226 | }, |
267 | 227 | { |
268 | 228 | "cell_type": "code", |
| 229 | + "execution_count": 16, |
269 | 230 | "id": "3e170fdc", |
270 | 231 | "metadata": { |
271 | 232 | "ExecuteTime": { |
272 | 233 | "end_time": "2025-05-09T08:27:54.022827Z", |
273 | 234 | "start_time": "2025-05-09T08:26:10.268239Z" |
274 | 235 | } |
275 | 236 | }, |
| 237 | + "outputs": [], |
276 | 238 | "source": [ |
277 | 239 | "if platform.system() != 'Windows':\n", |
278 | 240 | " for file in glob.glob('output/anim_frame_*.pdf'):\n", |
279 | 241 | " subprocess.run(['ps2pdf', file, file+'_'], capture_output=True, check=True)\n", |
280 | 242 | " subprocess.run(['mv', file+'_', file], check=True)" |
281 | | - ], |
282 | | - "outputs": [], |
283 | | - "execution_count": 14 |
| 243 | + ] |
284 | 244 | }, |
285 | 245 | { |
286 | 246 | "cell_type": "code", |
287 | | - "id": "9d3e4a35", |
288 | | - "metadata": { |
289 | | - "ExecuteTime": { |
290 | | - "end_time": "2025-05-09T08:27:54.022911Z", |
291 | | - "start_time": "2025-05-09T08:26:10.277448Z" |
292 | | - } |
293 | | - }, |
294 | | - "source": [], |
| 247 | + "execution_count": null, |
| 248 | + "id": "7df317e6", |
| 249 | + "metadata": {}, |
295 | 250 | "outputs": [], |
296 | | - "execution_count": null |
| 251 | + "source": [] |
297 | 252 | } |
298 | 253 | ], |
299 | 254 | "metadata": { |
|
0 commit comments