fargopy 0.3.0__tar.gz → 0.3.2__tar.gz

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.
fargopy-0.3.2/PKG-INFO ADDED
@@ -0,0 +1,433 @@
1
+ Metadata-Version: 2.1
2
+ Name: fargopy
3
+ Version: 0.3.2
4
+ Summary: FARGO3D Wrapping
5
+ Home-page: https://pypi.org/project/fargopy
6
+ Author: Jorge Zuluaga, Matias Montesinos
7
+ Author-email: jorge.zuluaga@gmail.com
8
+ License: MIT
9
+ Keywords: astronomy MHD CFD
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: scipy
16
+ Requires-Dist: matplotlib
17
+ Requires-Dist: tqdm
18
+ Requires-Dist: numpy
19
+ Requires-Dist: ipython
20
+ Requires-Dist: celluloid
21
+ Requires-Dist: psutil
22
+ Requires-Dist: gdown
23
+
24
+ # FARGOpy
25
+ ## Wrapping FRAGO3D
26
+
27
+ <!-- This are visual tags that you may add to your package at the beginning with useful information on your package -->
28
+ [![version](https://img.shields.io/pypi/v/fargopy?color=blue)](https://pypi.org/project/fargopy/)
29
+ [![downloads](https://img.shields.io/pypi/dw/fargopy)](https://pypi.org/project/fargopy/)
30
+
31
+ `FARGOpy` is a python wrapping for [`FARGO3D`](https://fargo3d.bitbucket.io/intro.html), the well-knwon hydrodynamics and magnetohydrodynamics parallel code. This wrapping is intended to facillitate the interaction with FARGO3D, especially for those starting using the code. `FARGOpy` may be also useful for teaching and training purposes. For advanced users, `FARGOpy` provides useful functionalities in the postprocessing of simulation results, derivative calculations and plots.
32
+
33
+ This is an animation created with a few lines of code using `FARGOpy` (for the code and other examples see [this tutorial](https://github.com/seap-udea/fargopy/blob/main/TUTORIAL.ipynb)):
34
+
35
+ <p align="center"><img src="https://github.com/seap-udea/fargopy/blob/main/gallery/fargo-animation.gif?raw=true" alt="Animation""/></p>
36
+
37
+ ## Installing `FARGOpy`
38
+
39
+ `FARGOpy` is available at the `Python` package index and can be installed using:
40
+
41
+ ```bash
42
+ $ pip install fargopy
43
+ ```
44
+ as usual this command will install all dependencies (excluding `FARGO3D` which must be installed indepently as explained before) and download some useful data, scripts and constants.
45
+
46
+
47
+
48
+ Since `FARGOpy` is a python wrap for `FARGO3D` the ideal environment to work with the package is `IPython`/`Jupyter`. It works really fine in `Google Colab` ensuing training and demonstration purposes. This README, for instance, can be ran in `Google Colab`
49
+
50
+ <a target="_blank" href="https://colab.research.google.com/github/seap-udea/fargopy/blob/main/README.ipynb">
51
+ <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
52
+ </a>
53
+
54
+ If you are running in colab use:
55
+
56
+
57
+ ```python
58
+ #!pip install fargopy
59
+ ```
60
+
61
+ If you are working in `Jupyter` or in `Google Colab`, the configuration directory and its content will be crated the first time you import the package:
62
+
63
+
64
+ ```python
65
+ import fargopy as fp
66
+
67
+ # These lines are intented for developing purposes; drop them in your code
68
+ %load_ext autoreload
69
+ %autoreload 2
70
+ ```
71
+
72
+ Configuring FARGOpy for the first time
73
+ Running FARGOpy version 0.3.1
74
+
75
+
76
+ If you are working on a remote Linux server, it is better to run the package using `IPython`. For this purpose, after installation, `FARGOpy` provides a special initialization command:
77
+
78
+ ```bash
79
+ $ ifargopy
80
+ ```
81
+
82
+ The first time you run this script, it will create a configuration directory `~/.fargopy` (with `~` the abbreviation for the home directory). This directory contains a set of basic configuration variables which are stored in the file `~/.fargopy/fargopyrc`. You may change this file if you want to customize the installation. The configuration directory also contains the `IPython` initialization script `~/.fargopy/ifargopy.py`.
83
+
84
+ ## Downloading and installing FARGO3D
85
+
86
+ It is important to understand that `FARGO3D` works especially well on Linux plaforms (including `MacOS`). The same condition applies for `FARGOpy`. Because of that, most of the internal as well as the public features of the packages are designed to work in a `Linux` environment. For working in other operating systems, especially on MS Windows, please consider using virtual machines ow WSL.
87
+
88
+ Being an independent project, `FARGOpy` is not provided with a working version of `FARGO3D`. You need to download the C package and their prerequisites (compilers, third-party libraries, etc.) and configure them, by yourself. For a detailed guide please see the [FARGO3D documentation](https://fargo3d.bitbucket.io/index.html) or the [project repo at bitbucket](https://bitbucket.org/fargo3d/public/src/ae0fcdc67bb7c83aed85fc9a4d4a2d5061324597/?at=release%2Fpublic).
89
+
90
+ Still `FARGOpy` provides a simple way to get the latest version of the source code of `FARGO3D` from its public GitHub repository. The source code will be downloaded into the home directory and stored as `~/fargo3d/`.
91
+
92
+ > **WARNING**: If you want to change the final location of the source code or the name of the `FARGO3D` directory, before executing the following command, please change the corresponding configuration variables in `~/.fargopy/fargopyrc`
93
+
94
+ To download the `FARGO3D` source code execute:
95
+
96
+
97
+ ```python
98
+ fp.initialize('download',force=True)
99
+ ```
100
+
101
+ Running FARGOpy version 0.3.0
102
+ Downloading FARGOpy...
103
+ Directory '/home/jzuluaga/fargo3d/' already exists. Removing it...
104
+
105
+
106
+ Cloning into 'fargo3d'...
107
+
108
+
109
+ FARGO3D downloaded to /home/jzuluaga/fargo3d/
110
+ Header file for FARGO3D found in the fargo directory /home/jzuluaga/fargo3d/
111
+
112
+
113
+ Once download it you may check if the source code is compiling in your machine. For that purpose run:
114
+
115
+
116
+ ```python
117
+ fp.initialize('check')
118
+ ```
119
+
120
+ Test compilation of FARGO3D
121
+ Checking normal compilation.
122
+ Running 'make -C /home/jzuluaga/fargo3d/ clean mrproper all PARALLEL=0 GPU=0 2>&1 |tee /tmp/fargo_regular.log':
123
+ Compilation in mode regular successful.
124
+ Checking normal compilation.
125
+ Running 'make -C /home/jzuluaga/fargo3d/ clean mrproper all PARALLEL=0 GPU=1 2>&1 |tee /tmp/fargo_gpu.log':
126
+ Compilation in mode gpu successful.
127
+ Checking normal compilation.
128
+ Running 'make -C /home/jzuluaga/fargo3d/ clean mrproper all PARALLEL=1 GPU=0 2>&1 |tee /tmp/fargo_parallel.log':
129
+ Compilation in mode parallel successful.
130
+ Summary of compilation modes:
131
+ Regular: 1
132
+ GPU: 1
133
+ Parallel: 1
134
+
135
+
136
+ If you have some error at compiling `FARGO3D` in some of the possible modes (regular, gpu and/or parallel) please check the corresponding logfile and correct the problems. Compiling problems will normally arise because of a lacking of an important dependency, for instance a compiler, a driver (in the case of GPU) or a third-party library or tool (eg. openmpi).
137
+
138
+ ## Quickstart
139
+
140
+ Here we will illustrate the minimal commands you may run to test the package. A more detailed set of examples can be found in [this tutorial](https://github.com/seap-udea/fargopy/blob/main/TUTORIAL.ipynb). In depth examples are available in the [examples directory](https://github.com/seap-udea/fargopy/tree/main/examples) of the `GitHub` repository.
141
+
142
+ There are two complimentary modes when using `FARGOpy`:
143
+
144
+ - **Control mode**: Using this mode you can run and control `FARGO3D` from your notebook. This mode requires a working copy of `FARGO3D` ready to be compiled and run. This mode is ideal for training or testing purposes.
145
+
146
+ - **Postprocessing mode**: Using `FARGOpy` in this mode allows you to process some of the output files produced by a `FARGO3D` simulation. This mode does not necesarily requires that a working copy of `FARGO3D` be installed in the machine where you are performing the postprocessing analysis. This mode is ideal for advanced users.
147
+
148
+ ### Control mode
149
+
150
+ Create a simulation:
151
+
152
+
153
+ ```python
154
+ sim = fp.Simulation(setup='fargo')
155
+ ```
156
+
157
+ Your simulation is now connected with '/home/jzuluaga/fargo3d/'
158
+ Now your simulation setup is at '/home/jzuluaga/fargo3d/setups/fargo'
159
+
160
+
161
+ Compile the `FARGO3D` binary to run the simulation:
162
+
163
+
164
+ ```python
165
+ sim.compile(parallel=0,gpu=0)
166
+ ```
167
+
168
+ Compiling fargo3d_SETUP-fargo_PARALLEL-0_GPU-0...
169
+ Succesful compilation of FARGO3D binary fargo3d_SETUP-fargo_PARALLEL-0_GPU-0
170
+
171
+
172
+ Run the simulation:
173
+
174
+
175
+ ```python
176
+ sim.run(cleanrun=True)
177
+ ```
178
+
179
+ Cleaning output directory /home/jzuluaga/fargo3d/outputs/fargo
180
+ Running asynchronously (test = False): ./fargo3d_SETUP-fargo_PARALLEL-0_GPU-0 -m -t setups/fargo/fargo.par
181
+ Now you are connected with output directory '/home/jzuluaga/fargo3d/outputs/fargo'
182
+
183
+
184
+ You may check the status:
185
+
186
+
187
+ ```python
188
+ sim.status()
189
+ ```
190
+
191
+
192
+ ################################################################################
193
+ Running status of the process:
194
+ The process is running.
195
+
196
+
197
+ Or check the progress of the simulation:
198
+
199
+
200
+ ```python
201
+ sim.status('progress')
202
+ ```
203
+
204
+ 1:OUTPUTS 1 at date t = 6.283185 OK [output pace = 0.1 secs]
205
+ 2:OUTPUTS 2 at date t = 12.566371 OK [output pace = 0.1 secs]
206
+ 3:OUTPUTS 3 at date t = 18.849556 OK [output pace = 0.8 secs]
207
+ 4:OUTPUTS 4 at date t = 25.132741 OK [output pace = 1.9 secs]
208
+ 5:OUTPUTS 5 at date t = 31.415927 OK [output pace = 1.9 secs]
209
+
210
+
211
+ You may stop the simulation at any time using:
212
+
213
+
214
+ ```python
215
+ sim.stop()
216
+ ```
217
+
218
+ Stopping FARGO3D process (pid = 4412)
219
+
220
+
221
+ Check the status of the simulation using:
222
+
223
+
224
+ ```python
225
+ sim.status('summary')
226
+ ```
227
+
228
+ The simulation has been ran for 7 time steps including the initial one.
229
+
230
+
231
+ Once stopped you may resume the simulation at any snapshot or at the latest resumable snapshot:
232
+
233
+
234
+ ```python
235
+ sim.resume()
236
+ ```
237
+
238
+ Resuming from snapshot 5...
239
+ Running asynchronously (test = False): ./fargo3d_SETUP-fargo_PARALLEL-0_GPU-0 -m -t -S 5 -t setups/fargo/fargo.par
240
+ Now you are connected with output directory '/home/jzuluaga/fargo3d/outputs/fargo'
241
+
242
+
243
+ Once the simulation has been completed you will notice by ran:
244
+
245
+
246
+ ```python
247
+ sim.status()
248
+ ```
249
+
250
+
251
+ ################################################################################
252
+ Running status of the process:
253
+ The process is running.
254
+
255
+
256
+ ### Postprocessing mode
257
+
258
+ Now that you have some results to process, it is time to use the functionalities that `FARGOpy` provides for this purpose.
259
+
260
+ Create the simulation and connect it to the output directory:
261
+
262
+
263
+ ```python
264
+ sim = fp.Simulation(output_dir = '/home/jzuluaga/fargo3d/outputs/fargo')
265
+ ```
266
+
267
+ Your simulation is now connected with '/home/jzuluaga/fargo3d/'
268
+ Now you are connected with output directory '/home/jzuluaga/fargo3d/outputs/fargo'
269
+
270
+
271
+ Load the properties of the simulation:
272
+
273
+
274
+ ```python
275
+ sim.load_properties()
276
+ ```
277
+
278
+ Loading variables
279
+ 84 variables loaded
280
+ Simulation in 2 dimensions
281
+ Loading domain in cylindrical coordinates:
282
+ Variable phi: 384 [[0, -3.1334114227210694], [-1, 3.1334114227210694]]
283
+ Variable r: 128 [[0, 0.408203125], [-1, 2.491796875]]
284
+ Variable z: 1 [[0, 0.0], [-1, 0.0]]
285
+ Number of snapshots in output directory: 51
286
+ Configuration variables and domains load into the object. See e.g. <sim>.vars
287
+
288
+
289
+ Load gas density field from a given snapshot:
290
+
291
+
292
+ ```python
293
+ gasdens = sim.load_field('gasdens',snapshot=20)
294
+ ```
295
+
296
+ Create a `meshslice` of the field:
297
+
298
+
299
+ ```python
300
+ gasdens_r, mesh = gasdens.meshslice(slice='z=0,phi=0')
301
+ ```
302
+
303
+ Plot the slice:
304
+
305
+
306
+ ```python
307
+ import matplotlib.pyplot as plt
308
+ plt.ioff() # Drop this out of this tutorial
309
+ fig,ax = plt.subplots()
310
+
311
+ ax.semilogy(mesh.r,gasdens_r)
312
+
313
+ ax.set_xlabel(r"$r$ [cu]")
314
+ ax.set_ylabel(r"$\rho$ [cu]")
315
+ fp.Util.fargopy_mark(ax)
316
+ fig.savefig('gallery/example-dens_r.png') # Drop this out of this tutorial
317
+ ```
318
+
319
+ <p align="center"><img src="https://github.com/seap-udea/fargopy/blob/main/gallery/example-dens_r.png?raw=true" alt="Animation""/></p>
320
+
321
+ You may also create a 2-dimensional `meshslice`:
322
+
323
+
324
+ ```python
325
+ gasdens_plane, mesh = gasdens.meshslice(slice='z=0')
326
+ ```
327
+
328
+ And plot it:
329
+
330
+
331
+ ```python
332
+ plt.ioff() # Drop this out of this tutorial
333
+ fig,axs = plt.subplots(1,2,figsize=(12,6))
334
+
335
+ ax = axs[0]
336
+
337
+ ax.pcolormesh(mesh.phi,mesh.r,gasdens_plane,cmap='prism')
338
+
339
+ ax.set_xlabel('$\phi$ [rad]')
340
+ ax.set_ylabel('$r$ [UL]')
341
+ fp.Util.fargopy_mark(ax)
342
+
343
+ ax = axs[1]
344
+
345
+ ax.pcolormesh(mesh.x,mesh.y,gasdens_plane,cmap='prism')
346
+
347
+ ax.set_xlabel('$x$ [UL]')
348
+ ax.set_ylabel('$y$ [UL]')
349
+ fp.Util.fargopy_mark(ax)
350
+ ax.axis('equal')
351
+ fig.savefig('gallery/example-dens_disk.png') # Drop this out of this tutorial
352
+ ```
353
+
354
+ <p align="center"><img src="https://github.com/seap-udea/fargopy/blob/main/gallery/example-dens_disk.png?raw=true" alt="Animation""/></p>
355
+
356
+ ### Working with precomputed simulations
357
+
358
+ If you don't have the resources to compile or run `FARGO3D` and still you want to test the postprocessing functionalities of the package you may download a precomputed simulation:
359
+
360
+
361
+ ```python
362
+ fp.Simulation.download_precomputed(setup='fargo')
363
+ ```
364
+
365
+ Downloading fargo.tgz from cloud (compressed size around 55 MB) into /tmp
366
+
367
+
368
+ Downloading...
369
+ From: https://docs.google.com/uc?export=download&id=1YXLKlf9fCGHgLej2fSOHgStD05uFB2C3
370
+ To: /tmp/fargo.tgz
371
+ 100%|██████████| 54.7M/54.7M [00:01<00:00, 31.2MB/s]
372
+
373
+
374
+ Uncompressing fargo.tgz into /tmp/fargo
375
+ Done.
376
+
377
+
378
+ We have prepared a set of precomputed simulations covering some interesting scientific cases. You may see the list of precomputed simulations available in the `FARGOpy` cloud repository:
379
+
380
+
381
+ ```python
382
+ fp.Simulation.list_precomputed()
383
+ ```
384
+
385
+ fargo:
386
+ Description: Protoplanetary disk with a Jovian planet in 2D
387
+ Size: 55 MB
388
+ p3diso:
389
+ Description: Protoplanetary disk with a Super earth planet in 3D
390
+ Size: 220 MB
391
+ p3disof:
392
+ Description: Protoplanetary disk with a a Super earth planet in 3D (increased resolution)
393
+ Size: 440 MB
394
+ fargo_multifluid:
395
+ Description: Protoplanetary disk with several fluids (dust) and a Jovian planet in 2D
396
+ Size: 100 MB
397
+ binary:
398
+ Description: Disk around a binary with the properties of Kepler-38 in 2D
399
+ Size: 140 MB
400
+
401
+
402
+ You may find in the [examples directory](https://github.com/seap-udea/fargopy/tree/main/examples) of the `GitHub` repository, example notebooks illustrating how to use `FARGOpy` for processing the output of this precomputed simulations.
403
+
404
+ ## What's new
405
+
406
+
407
+ Version 0.3.*:
408
+
409
+ - Refactoring of initializing routines.
410
+ - Improvements in documentation of basic classes in `__init__.py`.
411
+ - Precomputed simulations uploaded to FARGOpy Cloud Repository and available usnig `download_precomputed` static method.
412
+
413
+ Version 0.2.*:
414
+
415
+ - First real applications tested with FARGOpy.
416
+ - All basic routines for reading output created.
417
+ - Major refactoring.
418
+
419
+ Version 0.1.*:
420
+
421
+ - Package is now provided with a script 'ifargopy' to run 'ipython' with fargopy initialized.
422
+ - A new 'progress' mode has been added to status method.
423
+ - All the dynamics of loading/compiling/running/stoppìng/resuming FARGO3D has been developed.
424
+
425
+ Version 0.0.*:
426
+
427
+ - First classes created.
428
+ - The project is started!
429
+
430
+ ------------
431
+
432
+ This package has been designed and written mostly by Jorge I. Zuluaga with advising and contributions by Matías Montesinos (C) 2023
433
+