fargopy 0.4.0__py3-none-any.whl → 1.0.0__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.
@@ -0,0 +1,425 @@
1
+ Metadata-Version: 2.4
2
+ Name: fargopy
3
+ Version: 1.0.0
4
+ Summary: FARGO3D Wrapper
5
+ Home-page: https://pypi.org/project/fargopy
6
+ Author: Jorge Zuluaga, Alejandro Murillo-González, Matias Montesinos
7
+ Author-email: jorge.zuluaga@udea.edu.co
8
+ License: AGPL-3.0-only
9
+ Keywords: astronomy MHD CFD
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
15
+ Classifier: Topic :: Scientific/Engineering :: Physics
16
+ Requires-Python: >=3.7
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: scipy
20
+ Requires-Dist: matplotlib
21
+ Requires-Dist: PyQt5
22
+ Requires-Dist: tqdm
23
+ Requires-Dist: numpy
24
+ Requires-Dist: ipython
25
+ Requires-Dist: scikit-learn
26
+ Requires-Dist: ipympl
27
+ Requires-Dist: joblib
28
+ Requires-Dist: celluloid
29
+ Requires-Dist: psutil
30
+ Requires-Dist: gdown
31
+ Requires-Dist: pandas
32
+ Requires-Dist: plotly
33
+ Requires-Dist: pytest
34
+ Dynamic: author
35
+ Dynamic: author-email
36
+ Dynamic: classifier
37
+ Dynamic: description
38
+ Dynamic: description-content-type
39
+ Dynamic: home-page
40
+ Dynamic: keywords
41
+ Dynamic: license
42
+ Dynamic: license-file
43
+ Dynamic: requires-dist
44
+ Dynamic: requires-python
45
+ Dynamic: summary
46
+
47
+ <p></p>
48
+ <div align="center">
49
+ <img src="https://raw.githubusercontent.com/seap-udea/fargopy/main/docs/fargopy_logo.webp" alt="FARGOpy Logo" width="600"/>
50
+ </div>
51
+ <p></p>
52
+
53
+ <h2 align="center">A FARGO3D wrapper and more</h2>
54
+
55
+ <!-- This are visual tags that you may add to your package at the beginning with useful information on your package -->
56
+ [![version](https://img.shields.io/pypi/v/fargopy?color=blue)](https://pypi.org/project/fargopy/)
57
+ [![downloads](https://img.shields.io/pypi/dw/fargopy)](https://pypi.org/project/fargopy/)
58
+ [![License](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://github.com/seap-udea/fargopy/blob/master/LICENSE)
59
+ [![python](https://img.shields.io/badge/python-3-grey)](https://pypi.org/project/fargopy/)
60
+ [![Powered by FARGO3D](https://img.shields.io/badge/Powered%20by-FARGO3D-blue)](https://fargo3d.bitbucket.io/)
61
+ <!--[![arXiv](https://img.shields.io/badge/arXiv-0000.00000-orange.svg?style=flat)](https://arxiv.org/abs/0000.00000)-->
62
+ <a target="_blank" href="https://colab.research.google.com/github/seap-udea/fargopy/blob/main/README.ipynb">
63
+ <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
64
+ </a>
65
+
66
+ <div align="center">
67
+ <img src="https://raw.githubusercontent.com/seap-udea/fargopy/main/gallery/pds-70c-disk_densiy-200_orbits_high_resolution.gif" alt="PDS 70c disk density" width="60%"/>
68
+ <!--<img src="https://raw.githubusercontent.com/seap-udea/fargopy/main/gallery/pds-70c-disk_densiy_vertical-200_orbits_high_resolution.gif" alt="PDS 70c disk density (vertical)" width="45%"/>-->
69
+ </div>
70
+
71
+ ## Introducing FARGOpy
72
+
73
+ `FARGOpy` is a Python wrapper and post-processing tool designed for `FARGO3D`, a widely used hydrodynamical code for simulating planet-disk interactions.
74
+
75
+ With `FARGOpy`, you can easily:
76
+
77
+ - Analyze and visualize simulation outputs.
78
+ - Control and run `FARGO3D` simulations directly from Python (optional).
79
+ - Generate complex initial conditions and diverse setups with minimal effort.
80
+
81
+ It streamlines the workflow for researchers, allowing them to focus on the physics rather than the technicalities of setting up and processing simulations.
82
+
83
+ For instance, the animations above show the gas density of the circumstellar disk around the planet **PDS-70c** coming from a `FARGO3D` high resolution simulation. The reading of the simulation output and the generation of the animations, the interpolation of the fields, and the creation of the animations with just a few lines of code.
84
+
85
+ For the code used to generate these animations, see the tutorial notebook [basics with FARGOpy](https://github.com/seap-udea/fargopy/blob/main/examples/fargopy-tutorial-basics.ipynb).
86
+
87
+ ## Resources
88
+
89
+ A complete list of resources and further information about the package and the science relate to it can be found in the following links:
90
+
91
+ - **GitHub Repository**: [https://github.com/seap-udea/fargopy](https://github.com/seap-udea/fargopy)
92
+ - **Documentation**: [https://fargopy.readthedocs.io](https://fargopy.readthedocs.io)
93
+ - **PyPI Page**: [https://pypi.org/project/fargopy/](https://pypi.org/project/fargopy/)
94
+
95
+ ## Installation
96
+
97
+ ### From PyPI
98
+
99
+ `FARGOpy` is available at the `Python` package index and can be installed using:
100
+
101
+ ```bash
102
+ $ pip install fargopy
103
+ ```
104
+ 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.
105
+
106
+ ### From sources
107
+
108
+ You can also install from the [GitHub repository](https://github.com/seap-udea/fargopy):
109
+
110
+ ```bash
111
+ git clone https://github.com/seap-udea/fargopy
112
+ cd fargopy
113
+ pip install .
114
+ ```
115
+
116
+ For development, use an editable installation:
117
+
118
+ ```bash
119
+ cd fargopy
120
+ pip install -e .
121
+ ```
122
+
123
+ ### In Google Colab
124
+
125
+ 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`:
126
+
127
+ <a target="_blank" href="https://colab.research.google.com/github/seap-udea/fargopy/blob/main/README.ipynb">
128
+ <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
129
+ </a>
130
+
131
+ This code only works in Colab and it is intended to install the latest version of `FARGOpy`
132
+
133
+ ```python
134
+ try:
135
+ from google.colab import drive
136
+ %pip install -Uq git+https://github.com/seap-udea/fargopy
137
+ except ImportError:
138
+ print("Not running in Colab, skipping installation")
139
+ ```
140
+
141
+ Not running in Colab, skipping installation
142
+
143
+ ### Running in `IPython`
144
+
145
+ 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:
146
+
147
+ ```bash
148
+ $ ifargopy
149
+ ```
150
+
151
+ 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`.
152
+
153
+ You may also use the commando `ifargopy` to run several interesting commands:
154
+
155
+ - Verify the installation:
156
+
157
+ ```bash
158
+ $ ifargopy --verify
159
+ ```
160
+ ```
161
+ Running FARGOpy version X.Y.Z
162
+ fargopy X.Y.Z is successfully installed.
163
+ Location: /usr/local/lib/pythonX.X/site-packages/fargopy
164
+ ```
165
+
166
+ - Run a battery of tests:
167
+
168
+ ```bash
169
+ $ ifargopy --test
170
+ ```
171
+
172
+ ## Quickstart
173
+
174
+ Here is a quick example of how to use FARGOpy. For more examples, see the [examples](https://fargopy.readthedocs.io/en/latest/examples.html) directory in the documentation.
175
+
176
+ Import the package:
177
+
178
+ ```python
179
+ import fargopy as fp
180
+ ```
181
+
182
+ ### Density map
183
+
184
+ Download a precomputed simulation to test the package:
185
+
186
+ ```python
187
+ fp.Simulation.download_precomputed('fargo')
188
+ ```
189
+
190
+ Downloading fargo.tgz from cloud (compressed size around 55 MB) into /tmp
191
+
192
+ Downloading...
193
+ From: https://docs.google.com/uc?export=download&id=1YXLKlf9fCGHgLej2fSOHgStD05uFB2C3
194
+ To: /tmp/fargo.tgz
195
+ 100%|██████████| 54.7M/54.7M [00:01<00:00, 46.5MB/s]
196
+
197
+ Uncompressing fargo.tgz into /tmp/fargo
198
+ Done.
199
+
200
+ '/tmp/fargo'
201
+
202
+ Connect to the simulation output directory:
203
+
204
+ ```python
205
+ sim = fp.Simulation(output_dir='/tmp/fargo')
206
+ ```
207
+
208
+ Your simulation is now connected with '/Users/jzuluaga/fargo3d/'
209
+ Now you are connected with output directory '/tmp/fargo'
210
+ Found a variables.par file in '/tmp/fargo', loading properties
211
+ Loading variables
212
+ 84 variables loaded
213
+ Simulation in 2 dimensions
214
+ Loading domain in cylindrical coordinates:
215
+ Variable phi: 384 [[0, np.float64(-3.1334114227210694)], [-1, np.float64(3.1334114227210694)]]
216
+ Variable r: 128 [[0, np.float64(0.408203125)], [-1, np.float64(2.491796875)]]
217
+ Variable z: 1 [[0, np.float64(0.0)], [-1, np.float64(0.0)]]
218
+ Number of snapshots in output directory: 51
219
+ Planets found in summary.dat:
220
+ Name: Jupiter, Initial pos: [1.0, 0.001, 0.0], Mass: 0.001
221
+
222
+ Load a field (e.g., gas density) from a specific snapshot:
223
+
224
+ ```python
225
+ gasdens = sim.load_field('gasdens', snapshot=20, interpolate=False)
226
+ ```
227
+
228
+ Crate a 2D slice of a 3D field at $z=0$,
229
+
230
+ ```python
231
+ gasdens_plane, mesh = gasdens.meshslice(slice='z=0')
232
+ ```
233
+
234
+ Plot the fields of the FARGO simulation using a `colormesh` plot:
235
+
236
+ ```python
237
+ import matplotlib.pyplot as plt
238
+ fig, ax = plt.subplots(figsize=(6,6))
239
+ ax.pcolormesh(mesh.x, mesh.y, gasdens_plane, cmap='prism')
240
+ ax.axis('equal')
241
+ ax.set_xlabel('x [au]')
242
+ ax.set_ylabel('y [au]')
243
+
244
+ fp.Plot.fargopy_mark(ax)
245
+ plt.savefig('gallery/readme-gasdens.png')
246
+ plt.show()
247
+ ```
248
+
249
+ <img src="https://raw.githubusercontent.com/seap-udea/fargopy/refactor/gallery/readme-gasdens.png" alt="png">
250
+
251
+ ### Streamlines
252
+
253
+ We can visualize the streamlines of the fluid to observe the flow direction at a specific snapshot by interpolating the velocity field. This visualization provides a detailed representation of the velocity field, enabling us to analyze the fluid dynamics and identify key patterns such as vortices, flow separations, or other phenomena of interest. By combining this with contour plots of other fields, such as density or energy, we can gain deeper insights into the interactions and behavior of the simulated system.
254
+
255
+ We will use the 3D simulation of a disk with a Jovian planet:
256
+
257
+ ```python
258
+ fp.Simulation.download_precomputed('p3disoj')
259
+ sim = fp.Simulation(output_dir='/tmp/p3disoj')
260
+ ```
261
+
262
+ Precomputed output directory '/tmp/p3disoj' already exist
263
+ Your simulation is now connected with '/Users/jzuluaga/fargo3d/'
264
+ Now you are connected with output directory '/tmp/p3disoj'
265
+ Found a variables.par file in '/tmp/p3disoj', loading properties
266
+ Loading variables
267
+ 85 variables loaded
268
+ Simulation in 3 dimensions
269
+ Loading domain in spherical coordinates:
270
+ Variable phi: 128 [[0, np.float64(-3.117048960983623)], [-1, np.float64(3.117048960983623)]]
271
+ Variable r: 64 [[0, np.float64(0.5078125)], [-1, np.float64(1.4921875)]]
272
+ Variable theta: 32 [[0, np.float64(1.4231400767948967)], [-1, np.float64(1.5684525767948965)]]
273
+ Number of snapshots in output directory: 11
274
+ Planets found in summary.dat:
275
+ Name: Jupiter, Initial pos: [1.0, 0.001, 0.0], Mass: 0.001
276
+
277
+ First load the density and velocity fields at snapshot 6:
278
+
279
+ ```python
280
+ data = sim.load_field(
281
+ fields=['gasv'],
282
+ slice="phi=0",
283
+ snapshot=(0,10)
284
+ )
285
+ ```
286
+
287
+ Now is necesary create a regular mesh where the value of the field is interpolated:
288
+
289
+ ```python
290
+ import numpy as np
291
+
292
+ # This is the snapshot number where the streamplot will be computed
293
+ time = 6
294
+
295
+ # Get the minimum and maximum values of var1 and var3 (x and z coordinates)
296
+ xmin=data.var1_mesh[time].min()
297
+ xmax=data.var1_mesh[time].max()
298
+ zmin=data.var3_mesh[time].min()
299
+ zmax=data.var3_mesh[time].max()
300
+
301
+ # Create a grid of points
302
+ resolution = 120
303
+ xs = np.linspace(xmin, xmax, resolution)
304
+ zs = np.linspace(zmin, zmax, resolution)
305
+ X, Z = np.meshgrid(xs, zs, indexing='ij')
306
+ ```
307
+
308
+ Using the mesh we can evaluate the field at any point in space:
309
+
310
+ ```python
311
+ vxs, vys, vzs = data.evaluate(field='gasv', time=6, var1=X, var3=Z)
312
+
313
+ # Velocity magnitude at each mesh point
314
+ v_mag = np.sqrt(vxs**2 + vzs**2).T *sim.UV / 1e5
315
+ ```
316
+
317
+ Now we can plot the streamlines of the gas velocity:
318
+
319
+ ```python
320
+ fig,axs = plt.subplots(1,1,figsize=(6,6))
321
+
322
+ cmap = 'Spectral_r'
323
+
324
+ strm = axs.streamplot(X.T, Z.T, vxs.T, vzs.T,
325
+ color=v_mag, linewidth=0.7, density=3.0, cmap='viridis')
326
+
327
+ fig.colorbar(strm.lines, ax=axs, label="|v| [km/s]")
328
+
329
+ axs.set_xlim(xmin, xmax)
330
+ axs.set_ylim(zmin, zmax)
331
+ axs.set_xlabel('$x$ [au]')
332
+ axs.set_ylabel('$z$ [au]')
333
+
334
+ fp.Plot.fargopy_mark(axs)
335
+ plt.savefig('gallery/readme-streamlines.png') # Save figure
336
+ ```
337
+
338
+ <img src="https://raw.githubusercontent.com/seap-udea/fargopy/refactor/gallery/readme-streamlines.png" alt="png">
339
+
340
+ ### Accretion rate (mass flux)
341
+
342
+ We compute the mass flux through a closed surface S around the planet. The mass flux (accretion rate) is:\n
343
+ $$\dot{M}=\int_S\rho(\mathbf{v}\cdot\hat{n})\,dS$$
344
+ where $\rho$ is the density, $\mathbf{v}$ the velocity vector and $\hat{n}$ the outward normal to the surface. We evaluate this integral by interpolating fields at triangle centers and summing $\rho (\mathbf{v}dotat{n}) A_{i}$ over tessellation triangles.
345
+
346
+ ### Define Planet and Surface for Accretion Calculation
347
+
348
+ Set up the planet and surface objects for the accretion rate calculation.
349
+
350
+ For this example we will calculate the total flux going through a sphere with a radius equal to the planet's hill radius. For this purpose we need the location and the value of Hill radius of the planet at the snapchot we are interested in:
351
+
352
+ ```python
353
+ snap = 10
354
+ planet = sim.load_planets(snapshot=snap)[0]
355
+ r_hill = planet.hill_radius
356
+ print(f"Jupiter Hill Radius: {r_hill * sim.UL / fp.AU:.3f} AU")
357
+ ```
358
+
359
+ Jupiter Hill Radius: 0.068 AU
360
+
361
+ Now we define the surface over which you want to compute the fluxes:
362
+
363
+ ```python
364
+ sphere = fp.Surface(
365
+ type='sphere',
366
+ radius=r_hill,
367
+ subdivisions=6,
368
+ )
369
+ ```
370
+
371
+ The computation is performed with `follow_planet=True`, ensuring that the integration surface co-moves with the planet. This choice is required because the Hill radius evolves in time as a consequence of planetary migration, and therefore the associated control volume must be updated consistently to remain centered on the planet.
372
+
373
+ ```python
374
+ acc_rate = sphere.mass_flux(sim=sim, snapshot=[0,snap], follow_planet=True)
375
+ ```
376
+
377
+ Calculating mass flux: 100%|██████████| 11/11 [00:37<00:00, 3.44s/it]
378
+
379
+ And we can plot it:
380
+
381
+ ```python
382
+ snaps = np.linspace(0, snap, len(acc_rate))
383
+
384
+ fig, ax = plt.subplots(figsize=(10, 6))
385
+ ax.plot(snaps, acc_rate * sim.UM / sim.UT, color='dodgerblue')
386
+ ax.set_xlabel('Planet Orbits', size=15)
387
+ ax.set_ylabel(r'$\dot{M}$ [kg/s]', size=15)
388
+ ax.legend(fontsize=12)
389
+ fp.Plot.fargopy_mark(ax)
390
+ plt.savefig('gallery/readme-accretion.png')
391
+
392
+ ```
393
+
394
+ <img src="https://raw.githubusercontent.com/seap-udea/fargopy/refactor/gallery/readme-accretion.png" alt="png">
395
+
396
+ ## What's New
397
+
398
+ For a detailed list of changes and new features in each version, please see the [WHATSNEW.md](https://github.com/seap-udea/fargopy/blob/main/WHATSNEW.md) file.
399
+
400
+ ## Authors and Licensing
401
+
402
+ This project is developed by members the **Solar, Earth and Planetary Physics Group (SEAP)** at Universidad de Antioquia, Medellín, Colombia and the the **Department of Physics** of the Universidad Técnica Federico Santa María, Valdivia, Chile. The main developers are:
403
+
404
+ - **Jorge I. Zuluaga** (SEAP/FACom/UdeA) - jorge.zuluaga@udea.edu.co
405
+ - **Alejandro Murillo-González** (SEAP/FACom/UdeA) - alejandro.murillo1@udea.edu.co
406
+ - **Matías Montesinos** (Physics/USM) - matias.montesinosa@usm.cl
407
+
408
+ This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) - see the [LICENSE](LICENSE) file for details.
409
+
410
+ ## Contributing
411
+
412
+ We welcome contributions! If you're interested in contributing to MultiNEAs, please:
413
+
414
+ 1. Fork the repository
415
+ 2. Create a feature branch
416
+ 3. Make your changes
417
+ 4. Submit a pull request
418
+
419
+ Please read the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information.
420
+
421
+ ---
422
+ *Powered by fargopy*. For more examples see [fargopy GitHub repo](https://github.com/seap-udea/fargopy/tree/main/examples).
423
+
424
+ Jorge I. Zuluaga, Alejandro Murillo-González and Matías Montesinos © 2023-present
425
+
@@ -0,0 +1,21 @@
1
+ fargopy/__init__.py,sha256=iDTM6BooJ71W_B-rnhbxxyVUdx9mP-8LeiFUM3MI-GE,613
2
+ fargopy/base.py,sha256=Fh1vDHJgTtghevkkbPyZsrYftynpo-AG3uk_HMRhhU8,12572
3
+ fargopy/fields.py,sha256=pmw0pebpWdJsIBtqEDJpaW7_8yj3edsXQKuRtj-VsAc,72964
4
+ fargopy/flux.py,sha256=CLp4H-XO0Fi2NiSd5c35t_xnf8A9oc8Y-Y4bw35VsPM,37213
5
+ fargopy/plot.py,sha256=WIB-v0Z03isErypqvTeE9cukary8qnKUydUXmImT83U,25625
6
+ fargopy/simulation.py,sha256=SVDfB0pkJz_a7xpOEjGtziI6k23wK-_yiDw2o-36IfY,77985
7
+ fargopy/sys.py,sha256=ZHNsCS1Bw2HQam1XMMm-rWAs7EZUyqypsswez4DbZ_I,6554
8
+ fargopy/bin/ifargopy,sha256=SYUD6brYhNcIk3HNJoJ_gtS8hsPtlF4SaVK1Gpw_9Ak,3307
9
+ fargopy/bin/vfargopy,sha256=DTcxKjbHnBb37B82aloDxTnEHaT2It5yLX0_y_3ReSk,88179
10
+ fargopy/data/fargopy_logo.png,sha256=OK1YihA4mAVhX3qYLXWk6DIxxHf6J5qbRj0K0Csmp6w,2226937
11
+ fargopy/tests/test_base.py,sha256=39gFFAwsI8696UKXwpn0aeU_X87-zU4wkKkPsPjE-iU,163
12
+ fargopy/tests/test_flux.py,sha256=R404ObzVKvPyrHK_ER_qeqjrEvVLfafNlBW3Wn6x3Jw,2798
13
+ fargopy/tests/test_interp.py,sha256=D8h_nmU7a6fyc8r0l34XL4OJQDYVrJ87ddzNFFIFaOA,3879
14
+ fargopy-1.0.0.data/scripts/ifargopy,sha256=BKfjbWUAeK-EkF344erOV0jMtDZLzrYbxgkFsoJEz4g,3293
15
+ fargopy-1.0.0.data/scripts/vfargopy,sha256=itKwyLv_yzYigTN9rKV_6--ukAC5D0W8Z_7ZjWLPveA,88165
16
+ fargopy-1.0.0.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
17
+ fargopy-1.0.0.dist-info/METADATA,sha256=DP1vDjWDBpoaZqymakn9medxNepJqo7GH_jy8EhQwWw,15749
18
+ fargopy-1.0.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
19
+ fargopy-1.0.0.dist-info/entry_points.txt,sha256=555NPKYbLCN0fgJbdW4b4azZ5sqjhqVqTUxujBBYEJY,49
20
+ fargopy-1.0.0.dist-info/top_level.txt,sha256=_r66v1_-9T7dB5sQa12AdxaAdsv9-OTwtR-vft4OPBU,8
21
+ fargopy-1.0.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5