fargopy 0.3.0__py3-none-any.whl → 0.3.2__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.
fargopy/__init__.py CHANGED
@@ -196,7 +196,7 @@ def initialize(options='', force=False):
196
196
  Action(s) to be performed. Valid actions include:
197
197
  'configure': configure the package.
198
198
  'download': download FARGO3D directory.
199
- 'compile': attempt to compile FARGO3D in the machine.
199
+ 'check': attempt to compile FARGO3D in the machine.
200
200
  'all': all actions.
201
201
 
202
202
  force: bool, default = False:
@@ -222,9 +222,13 @@ def initialize(options='', force=False):
222
222
  Debug.trace(f"Configuration already in place.")
223
223
 
224
224
  if ('download' in options) or ('all' in options):
225
- print("Downloading FARGOpy...")
226
225
  fargo_dir = f"{Conf.FP_FARGO3D_BASEDIR}/{Conf.FP_FARGO3D_PACKDIR}".replace('//','/')
226
+
227
+ print("Downloading FARGOpy...")
227
228
  if not os.path.isdir(fargo_dir) or force:
229
+ if os.path.isdir(fargo_dir):
230
+ print(f"Directory '{fargo_dir}' already exists. Removing it...")
231
+ os.system(f"rm -rf {fargo_dir}")
228
232
  fargopy.Sys.simple(f"cd {Conf.FP_FARGO3D_BASEDIR};{Conf.FP_FARGO3D_CLONECMD} {Conf.FP_FARGO3D_PACKDIR}")
229
233
  print(f"\tFARGO3D downloaded to {fargo_dir}")
230
234
  else:
@@ -234,12 +238,34 @@ def initialize(options='', force=False):
234
238
  if not os.path.isfile(fargo_header):
235
239
  print(f"No header file for fargo found in '{fargo_header}'")
236
240
  else:
237
- print(f"Header file for FARGO3D is in the fargo directory {fargo_dir}")
241
+ print(f"Header file for FARGO3D found in the fargo directory {fargo_dir}")
242
+
243
+ if ('check' in options) or ('all' in options):
244
+ fargo_dir = f"{Conf.FP_FARGO3D_BASEDIR}/{Conf.FP_FARGO3D_PACKDIR}".replace('//','/')
245
+
246
+ print("Test compilation of FARGO3D")
247
+ if not os.path.isdir(fargo_dir):
248
+ print(f"Directory '{fargo_dir}' does not exist. Please download it with fargopy.initialize('download')")
249
+
250
+ cmd_fun = lambda options,mode:f"make -C {fargo_dir} clean mrproper all {options} 2>&1 |tee /tmp/fargo_{mode}.log"
251
+
252
+ for option,mode in zip(['PARALLEL=0 GPU=0','PARALLEL=0 GPU=1','PARALLEL=1 GPU=0'],
253
+ ['regular','gpu','parallel']):
254
+ cmd = cmd_fun(option,mode)
255
+ print(f"\tChecking normal compilation.\n\tRunning '{cmd}':")
256
+ error,output = Sys.run(cmd)
257
+ if not os.path.isfile(f"{fargo_dir}/{Conf.FP_FARGO3D_BINARY}"):
258
+ print(f"\t\tCompilation failed for '{mode}'. Check log file '/tmp/fargo_{mode}.log'")
259
+ exec(f"Conf.FP_FARGO3D_{mode.upper()} = 0")
260
+ else:
261
+ print(f"\t\tCompilation in mode {mode} successful.")
262
+ exec(f"Conf.FP_FARGO3D_{mode.upper()} = 1")
263
+
264
+ print(f"Summary of compilation modes:")
265
+ print(f"\tRegular: {Conf.FP_FARGO3D_REGULAR}")
266
+ print(f"\tGPU: {Conf.FP_FARGO3D_GPU}")
267
+ print(f"\tParallel: {Conf.FP_FARGO3D_PARALLEL}")
238
268
 
239
- if ('compile' in options) or ('all' in options):
240
- print("Test compilation")
241
- pass
242
-
243
269
  ###############################################################
244
270
  # Initialization
245
271
  ###############################################################
fargopy/fields.py CHANGED
@@ -13,6 +13,9 @@ import re
13
13
  # Constants
14
14
  ###############################################################
15
15
  # Map of coordinates into FARGO3D coordinates
16
+ """This dictionary maps the coordinates regular names (r, phi, theta, etc.) of
17
+ different coordinate systems into the FARGO3D x, y, z
18
+ """
16
19
  COORDS_MAP = dict(
17
20
  cartesian = dict(x='x',y='y',z='z'),
18
21
  cylindrical = dict(phi='x',r='y',z='z'),
fargopy/simulation.py CHANGED
@@ -28,15 +28,35 @@ YEAR = 31557600.0 # s
28
28
  PRECOMPUTED_BASEURL = 'https://docs.google.com/uc?export=download&id='
29
29
  PRECOMPUTED_SIMULATIONS = dict(
30
30
  # Download link: https://drive.google.com/file/d/1YXLKlf9fCGHgLej2fSOHgStD05uFB2C3/view?usp=drive_link
31
- fargo=dict(id='1YXLKlf9fCGHgLej2fSOHgStD05uFB2C3',size=55),
31
+ fargo=dict(
32
+ id='1YXLKlf9fCGHgLej2fSOHgStD05uFB2C3',
33
+ description="""Protoplanetary disk with a Jovian planet in 2D""",
34
+ size=55
35
+ ),
32
36
  # Download link: https://drive.google.com/file/d/1KMp_82ylQn3ne_aNWEF1T9ElX2aWzYX6/view?usp=drive_link
33
- p3diso=dict(id='1KMp_82ylQn3ne_aNWEF1T9ElX2aWzYX6',size=220),
37
+ p3diso=dict(
38
+ id='1KMp_82ylQn3ne_aNWEF1T9ElX2aWzYX6',
39
+ description="""Protoplanetary disk with a Super earth planet in 3D""",
40
+ size=220
41
+ ),
34
42
  # Download link: https://drive.google.com/file/d/14mL2KCcCtjptChiyISGyJxAEOl4KAanI/view?usp=drive_link
35
- p3disof=dict(id='14mL2KCcCtjptChiyISGyJxAEOl4KAanI',size=440),
43
+ p3disof=dict(
44
+ id='14mL2KCcCtjptChiyISGyJxAEOl4KAanI',
45
+ description="""Protoplanetary disk with a a Super earth planet in 3D (increased resolution)""",
46
+ size=440
47
+ ),
36
48
  # Download link: https://drive.google.com/file/d/1KSQyxH_kbAqHQcsE30GQFRVgAPhMAcp7/view?usp=drive_link
37
- fargo_multifluid=dict(id='1KSQyxH_kbAqHQcsE30GQFRVgAPhMAcp7',size=100),
49
+ fargo_multifluid=dict(
50
+ id='1KSQyxH_kbAqHQcsE30GQFRVgAPhMAcp7',
51
+ description="""Protoplanetary disk with several fluids (dust) and a Jovian planet in 2D""",
52
+ size=100
53
+ ),
38
54
  # Download link: https://drive.google.com/file/d/12ZWoQS_9ISe6eDij5KWWbqR-bHyyVs2N/view?usp=drive_link
39
- binary=dict(id='12ZWoQS_9ISe6eDij5KWWbqR-bHyyVs2N',size=140),
55
+ binary=dict(
56
+ id='12ZWoQS_9ISe6eDij5KWWbqR-bHyyVs2N',
57
+ description="""Disk around a binary with the properties of Kepler-38 in 2D""",
58
+ size=140
59
+ ),
40
60
  )
41
61
 
42
62
  ###############################################################
@@ -208,11 +228,9 @@ class Simulation(fargopy.Fargobj):
208
228
  gpu=gpu,
209
229
  options=options
210
230
  )
211
- return True
212
231
  else:
213
232
  print(f"Something failed when compiling FARGO3D. For details check Simulation.output_compilation")
214
- return False
215
-
233
+
216
234
  def run(self,
217
235
  mode='async',
218
236
  options='-m',
@@ -365,6 +383,10 @@ class Simulation(fargopy.Fargobj):
365
383
  if 'progress' in mode:
366
384
  self._status_progress()
367
385
 
386
+ if 'summary' in mode or mode=='all':
387
+ nsnaps = self._get_nsnaps()
388
+ print(f"The simulation has been ran for {nsnaps} time steps including the initial one.")
389
+
368
390
  def _status_progress(self,minfreq=0.1,numstatus=5):
369
391
  """Show a progress of the execution
370
392
 
@@ -382,8 +404,8 @@ class Simulation(fargopy.Fargobj):
382
404
  time_previous = time.time()
383
405
 
384
406
  # Infinite loop checking for output
385
- i = 0
386
- while True and (i<numstatus):
407
+ n = 0
408
+ while True and (n<numstatus):
387
409
  if not self._is_running():
388
410
  print("The simulation is not running anymore")
389
411
  return
@@ -393,7 +415,8 @@ class Simulation(fargopy.Fargobj):
393
415
  # Get the latest output
394
416
  latest_output = output[-2]
395
417
  if latest_output != previous_output:
396
- print(f"{latest_output} [output pace = {frequency:.1f} secs]")
418
+ print(f"{n+1}:{latest_output} [output pace = {frequency:.1f} secs]")
419
+ n += 1
397
420
  # Fun the number of the output
398
421
  find = re.findall(r'OUTPUTS\s+(\d+)',latest_output)
399
422
  resumable_snapshot = int(find[0])
@@ -408,9 +431,9 @@ class Simulation(fargopy.Fargobj):
408
431
  previous_output = latest_output
409
432
  try:
410
433
  time.sleep(frequency)
411
- i += 1
412
434
  except KeyboardInterrupt:
413
435
  return
436
+
414
437
 
415
438
  def resume(self,snapshot=-1,mpioptions='-np 1'):
416
439
  latest_snapshot_resumable = self._is_resumable()
@@ -788,7 +811,14 @@ class Simulation(fargopy.Fargobj):
788
811
  # Static method
789
812
  # ##########################################################################
790
813
  @staticmethod
791
- def download_precomputed(setup=None,download_dir='/tmp',quiet=True,clean=True):
814
+ def list_precomputed():
815
+ """List the available precomputed simulations
816
+ """
817
+ for key,item in PRECOMPUTED_SIMULATIONS.items():
818
+ print(f"{key}:\n\tDescription: {item['description']}\n\tSize: {item['size']} MB")
819
+
820
+ @staticmethod
821
+ def download_precomputed(setup=None,download_dir='/tmp',quiet=False,clean=True):
792
822
  """Download a precomputed output from Google Drive FARGOpy public repository.
793
823
 
794
824
  Args:
@@ -838,7 +868,6 @@ class Simulation(fargopy.Fargobj):
838
868
  fargopy.Sys.simple(f"cd {download_dir};tar zxf {filename}")
839
869
  print(f"Done.")
840
870
  fargopy.Sys.simple(f"cd {download_dir};rm -rf {filename}")
841
- return output_dir
842
871
 
843
872
 
844
873
 
fargopy/version.py CHANGED
@@ -1 +1 @@
1
- version='0.3.0'
1
+ version='0.3.2'
@@ -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
+
@@ -0,0 +1,13 @@
1
+ fargopy/__init__.py,sha256=rholn6aNA0baxL3WnuhZLQraL9Csb7yhe-s1WuTTXSc,10813
2
+ fargopy/fields.py,sha256=4sBm--gxgMdQcd6lsdPQ7ADnnGL550Cy_H2mNz80A-o,8837
3
+ fargopy/simulation.py,sha256=ckmrKCbdpdmK1oRvnOzKOO7d-sdST9S0KvxIwVewhfo,33865
4
+ fargopy/sys.py,sha256=-RnUZJ5GnYHwIlI7UtjPlnyS88ptnrSBa9FvnF_2gDM,4311
5
+ fargopy/util.py,sha256=y39aTcvK1lM3vbuK11lE2bfj-eCcOzc0lKMvyBRW2-M,1584
6
+ fargopy/version.py,sha256=-koB3-fc-gMdXrslWvqHbCOgzQ3Jio821Mh4ygIZzGs,16
7
+ fargopy-0.3.2.data/scripts/ifargopy,sha256=t5E07jKzOLtNnlNyElQZbzjCW6wnR0bc8uCaZpw9yS8,382
8
+ fargopy-0.3.2.dist-info/LICENSE,sha256=aIckKnNVrkXQMqEKlzGn_REfTwc82TF35BHMCRwPXCI,1097
9
+ fargopy-0.3.2.dist-info/METADATA,sha256=QPvC8lvkIWlw9yGBr5DZbk8eWRC570VFb-f1SCrfXKA,14895
10
+ fargopy-0.3.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
11
+ fargopy-0.3.2.dist-info/entry_points.txt,sha256=555NPKYbLCN0fgJbdW4b4azZ5sqjhqVqTUxujBBYEJY,49
12
+ fargopy-0.3.2.dist-info/top_level.txt,sha256=_r66v1_-9T7dB5sQa12AdxaAdsv9-OTwtR-vft4OPBU,8
13
+ fargopy-0.3.2.dist-info/RECORD,,
@@ -1,243 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: fargopy
3
- Version: 0.3.0
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 ensue the interaction with FARGO3D especially for those starting using the code, for instance for teaching and training purposes, but also provide functionalities for most advanced users in tasks related to the postprocessing of output files and plotting.
32
-
33
- This is an example of what can be done using `FARGOpy`:
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
- ## Install `FARGOpy`
38
-
39
- To install the package run:
40
-
41
- ```bash
42
- $ pip3 install fargopy
43
- ```
44
-
45
- Since `FARGOpy` is a python wrap for `FARGO3D` the ideal environment to work with the package is `IPython` or other similar environments such as `jupyter-lab`, `Google Colab`, etc.
46
-
47
- If you are working on a Linux server it is better to run the package for the first time using the `IPython` initialization command:
48
-
49
- ```bash
50
- $ ifargopy
51
- ```
52
-
53
- The first time you run this command, it will create the configuration directory `$HOME/.fargopy`. This directory contains a set of basic configuration variables `$HOME/.fargopy/fargopyrc`, that can be customized, and the `IPython` initialization script `$HOME/.fargopy/ifargopy.py`.
54
-
55
- 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:
56
-
57
-
58
- ```python
59
- import fargopy as fp
60
- %load_ext autoreload
61
- %autoreload 2
62
- ```
63
-
64
- Running FARGOpy version 0.2.1
65
-
66
-
67
- ## Download and install FARGO3D
68
-
69
- `FARGOpy` can be used either to *control* `FARGO3D`, ie. download, compile and run it, and/or read and manipulate the output of simulations. In either case it would be convenient to obtain a copy of the package and all its prerequisites. For a detailed guide please see the [FARGO documentation](https://fargo3d.bitbucket.io/index.html) or the [project repo at bitbucket](https://bitbucket.org/fargo3d/public/src/ae0fcdc67bb7c83aed85fc9a4d4a2d5061324597/?at=release%2Fpublic).
70
-
71
- > **NOTE**: 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 internal as well as public features of the packages are designed to work in a `Linux` environment. For working in another operating systems, for instance for teaching or training purposes, please consider to use virtual machines.
72
-
73
- `FARGOpy` provides a simple way to get the latest version of `FARGO3D`. In the terminal run:
74
-
75
- ```shell
76
- $ ifargopy download
77
- ```
78
-
79
- A copy of `FARGO3D` will be download in the HOME directory `~/fargo3d/`.
80
-
81
- If you are working in a `Jupyter` environment you may run:
82
-
83
-
84
- ```python
85
- fp.initialize('download')
86
- ```
87
-
88
- Downloading FARGOpy...
89
- FARGO3D directory already present in '/home/jzuluaga/fargo3d/'
90
- Header file for FARGO3D is in the fargo directory /home/jzuluaga/fargo3d/
91
-
92
-
93
- > **NOTE**: As you may see the default directory where FARGO3D is download is `~/` and the name of the directory is `fargo3d`. You may change this by setting the configuration variables `FP_FARGO3D_BASEDIR` or `FP_FARGO3D_PACKDIR` brefore downloading the package.
94
-
95
- ## Quickstart
96
-
97
- 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 file](TUTORIAL.md).
98
-
99
- For this example we will assume that you already have a set of FARGO3D simulation results. You may download a precomputed set of results prepared by the developers of `FARGOpy` using the command:
100
-
101
-
102
- ```python
103
- fp.Simulation.download_precomputed(setup='fargo')
104
- ```
105
-
106
- Precomputed output directory '/tmp/fargo' already exist
107
-
108
-
109
-
110
-
111
-
112
- '/tmp/fargo'
113
-
114
-
115
-
116
- Create a simulation object:
117
-
118
-
119
- ```python
120
- sim = fp.Simulation()
121
- ```
122
-
123
- Your simulation is now connected with '/home/jzuluaga/fargo3d/'
124
-
125
-
126
- Set the output directory (in this case, the directory where the precomputed simulation has been stored):
127
-
128
-
129
- ```python
130
- sim.set_output_dir('/tmp/fargo')
131
- ```
132
-
133
- Now you are connected with output directory '/tmp/fargo'
134
-
135
-
136
- Load the properties of the simulation:
137
-
138
-
139
- ```python
140
- sim.load_properties()
141
- ```
142
-
143
- Loading variables
144
- 84 variables loaded
145
- Simulation in 2 dimensions
146
- Loading domain in cylindrical coordinates:
147
- Variable phi: 384 [[0, -3.1334114227210694], [-1, 3.1334114227210694]]
148
- Variable r: 128 [[0, 0.408203125], [-1, 2.491796875]]
149
- Variable z: 1 [[0, 0.0], [-1, 0.0]]
150
- Number of snapshots in output directory: 51
151
- Configuration variables and domains load into the object. See e.g. <sim>.vars
152
-
153
-
154
- Load gas density from a given snapshot:
155
-
156
-
157
- ```python
158
- gasdens = sim.load_field('gasdens',snapshot=20)
159
- ```
160
-
161
- Create a `meshslice` of the field:
162
-
163
-
164
- ```python
165
- gasdens_r, mesh = gasdens.meshslice(slice='z=0,phi=0')
166
- ```
167
-
168
- And plot the slice:
169
-
170
-
171
- ```python
172
- import matplotlib.pyplot as plt
173
- plt.ioff() # Drop this out of this tutorial
174
- fig,ax = plt.subplots()
175
- ax.semilogy(mesh.r,gasdens_r)
176
- ax.set_xlabel(r"$r$ [cu]")
177
- ax.set_ylabel(r"$\rho$ [cu]")
178
- fp.Util.fargopy_mark(ax)
179
- fig.savefig('gallery/example-dens_r.png') # Drop this out of this tutorial
180
- ```
181
-
182
- <p align="center"><img src="https://github.com/seap-udea/fargopy/blob/main/gallery/example-dens_r.png?raw=true" alt="Animation""/></p>
183
-
184
- You may also create a 2-dimensional slice:
185
-
186
-
187
- ```python
188
- gasdens_plane, mesh = gasdens.meshslice(slice='z=0')
189
- ```
190
-
191
- And plot it:
192
-
193
-
194
- ```python
195
- plt.ioff() # Drop this out of this tutorial
196
- fig,axs = plt.subplots(1,2,figsize=(12,6))
197
-
198
- ax = axs[0]
199
- ax.pcolormesh(mesh.phi,mesh.r,gasdens_plane,cmap='prism')
200
- ax.set_xlabel('$\phi$ [rad]')
201
- ax.set_ylabel('$r$ [UL]')
202
- fp.Util.fargopy_mark(ax)
203
-
204
- ax = axs[1]
205
- ax.pcolormesh(mesh.x,mesh.y,gasdens_plane,cmap='prism')
206
- ax.set_xlabel('$x$ [UL]')
207
- ax.set_ylabel('$y$ [UL]')
208
- fp.Util.fargopy_mark(ax)
209
- ax.axis('equal')
210
- fig.savefig('gallery/example-dens_disk.png') # Drop this out of this tutorial
211
- ```
212
-
213
- <p align="center"><img src="https://github.com/seap-udea/fargopy/blob/main/gallery/example-dens_disk.png?raw=true" alt="Animation""/></p>
214
-
215
- ## What's new
216
-
217
-
218
- Version 0.3.*:
219
-
220
- - Refactoring of initializing routines.
221
- - Improvements in documentation of basic classes in `__init__.py`.
222
-
223
- Version 0.2.*:
224
-
225
- - First real applications tested with FARGOpy.
226
- - All basic routines for reading output created.
227
- - Major refactoring.
228
-
229
- Version 0.1.*:
230
-
231
- - Package is now provided with a script 'ifargopy' to run 'ipython' with fargopy initialized.
232
- - A new 'progress' mode has been added to status method.
233
- - All the dynamics of loading/compiling/running/stoppìng/resuming FARGO3D has been developed.
234
-
235
- Version 0.0.*:
236
-
237
- - First classes created.
238
- - The project is started!
239
-
240
- ------------
241
-
242
- This package has been designed and written mostly by Jorge I. Zuluaga with advising and contributions by Matías Montesinos (C) 2023
243
-
@@ -1,13 +0,0 @@
1
- fargopy/__init__.py,sha256=q_tpw5_Mi4zmowrMUxQFrhHlTPVCUsmU3RX88-pRBE8,9326
2
- fargopy/fields.py,sha256=-f0Q-3J1dq2oZYpmiaAuT-B48qECCLhvmjiIUSjyXhg,8700
3
- fargopy/simulation.py,sha256=NPZes8MZ8xtbmfZqrhuGAGhYvEs2vUdJSpRFNB1hfjo,32901
4
- fargopy/sys.py,sha256=-RnUZJ5GnYHwIlI7UtjPlnyS88ptnrSBa9FvnF_2gDM,4311
5
- fargopy/util.py,sha256=y39aTcvK1lM3vbuK11lE2bfj-eCcOzc0lKMvyBRW2-M,1584
6
- fargopy/version.py,sha256=14vICHbg-AX_96xiJkVH7VdMy15awdqU6glK1dWQttc,16
7
- fargopy-0.3.0.data/scripts/ifargopy,sha256=t5E07jKzOLtNnlNyElQZbzjCW6wnR0bc8uCaZpw9yS8,382
8
- fargopy-0.3.0.dist-info/LICENSE,sha256=aIckKnNVrkXQMqEKlzGn_REfTwc82TF35BHMCRwPXCI,1097
9
- fargopy-0.3.0.dist-info/METADATA,sha256=nUDcNFKH-P0X7UM_cn0JuEaPIpFANqb1wPp_ahdkfeg,7823
10
- fargopy-0.3.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
11
- fargopy-0.3.0.dist-info/entry_points.txt,sha256=555NPKYbLCN0fgJbdW4b4azZ5sqjhqVqTUxujBBYEJY,49
12
- fargopy-0.3.0.dist-info/top_level.txt,sha256=_r66v1_-9T7dB5sQa12AdxaAdsv9-OTwtR-vft4OPBU,8
13
- fargopy-0.3.0.dist-info/RECORD,,