fargopy 0.3.4__tar.gz → 0.3.5__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.4 → fargopy-0.3.5}/PKG-INFO +26 -15
- {fargopy-0.3.4 → fargopy-0.3.5}/README.md +25 -14
- {fargopy-0.3.4 → fargopy-0.3.5}/fargopy/__init__.py +19 -0
- {fargopy-0.3.4 → fargopy-0.3.5}/fargopy/simulation.py +84 -17
- {fargopy-0.3.4 → fargopy-0.3.5}/fargopy/sys.py +39 -0
- fargopy-0.3.5/fargopy/version.py +1 -0
- {fargopy-0.3.4 → fargopy-0.3.5}/fargopy.egg-info/PKG-INFO +26 -15
- {fargopy-0.3.4 → fargopy-0.3.5}/setup.py +1 -1
- fargopy-0.3.4/fargopy/version.py +0 -1
- {fargopy-0.3.4 → fargopy-0.3.5}/LICENSE +0 -0
- {fargopy-0.3.4 → fargopy-0.3.5}/fargopy/bin/ifargopy +0 -0
- {fargopy-0.3.4 → fargopy-0.3.5}/fargopy/fields.py +0 -0
- {fargopy-0.3.4 → fargopy-0.3.5}/fargopy/util.py +0 -0
- {fargopy-0.3.4 → fargopy-0.3.5}/fargopy.egg-info/SOURCES.txt +0 -0
- {fargopy-0.3.4 → fargopy-0.3.5}/fargopy.egg-info/dependency_links.txt +0 -0
- {fargopy-0.3.4 → fargopy-0.3.5}/fargopy.egg-info/entry_points.txt +0 -0
- {fargopy-0.3.4 → fargopy-0.3.5}/fargopy.egg-info/requires.txt +0 -0
- {fargopy-0.3.4 → fargopy-0.3.5}/fargopy.egg-info/top_level.txt +0 -0
- {fargopy-0.3.4 → fargopy-0.3.5}/pyproject.toml +0 -0
- {fargopy-0.3.4 → fargopy-0.3.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: fargopy
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.5
|
|
4
4
|
Summary: FARGO3D Wrapping
|
|
5
5
|
Home-page: https://pypi.org/project/fargopy
|
|
6
6
|
Author: Jorge Zuluaga, Matias Montesinos
|
|
@@ -71,7 +71,7 @@ import fargopy as fp
|
|
|
71
71
|
%autoreload 2
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
Running FARGOpy version 0.3.
|
|
74
|
+
Running FARGOpy version 0.3.4
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
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:
|
|
@@ -197,14 +197,12 @@ Or check the progress of the simulation:
|
|
|
197
197
|
sim.status('progress')
|
|
198
198
|
```
|
|
199
199
|
|
|
200
|
-
Progress of the simulation (numstatus = 5):
|
|
201
|
-
1:OUTPUTS
|
|
202
|
-
2:OUTPUTS
|
|
203
|
-
3:OUTPUTS
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
Running status of the process:
|
|
207
|
-
The process is running.
|
|
200
|
+
Progress of the simulation (numstatus = 5, interrupting may stop the process):
|
|
201
|
+
1:OUTPUTS 0 at date t = 0.000000 OK [output pace = 0.1 secs]
|
|
202
|
+
2:OUTPUTS 1 at date t = 6.283185 OK [output pace = 0.1 secs]
|
|
203
|
+
3:OUTPUTS 2 at date t = 12.566371 OK [output pace = 1.6 secs]
|
|
204
|
+
4:OUTPUTS 3 at date t = 18.849556 OK [output pace = 4.9 secs]
|
|
205
|
+
5:OUTPUTS 4 at date t = 25.132741 OK [output pace = 4.9 secs]
|
|
208
206
|
|
|
209
207
|
|
|
210
208
|
You may stop the simulation at any time using:
|
|
@@ -214,7 +212,7 @@ You may stop the simulation at any time using:
|
|
|
214
212
|
sim.stop()
|
|
215
213
|
```
|
|
216
214
|
|
|
217
|
-
Stopping FARGO3D process (pid =
|
|
215
|
+
Stopping FARGO3D process (pid = 18717)
|
|
218
216
|
|
|
219
217
|
|
|
220
218
|
Check the status of the simulation using:
|
|
@@ -224,7 +222,7 @@ Check the status of the simulation using:
|
|
|
224
222
|
sim.status('summary')
|
|
225
223
|
```
|
|
226
224
|
|
|
227
|
-
The simulation has been ran for
|
|
225
|
+
The simulation has been ran for 6 time-steps (including the initial one).
|
|
228
226
|
|
|
229
227
|
|
|
230
228
|
Once stopped you may resume the simulation at any snapshot or at the latest resumable snapshot:
|
|
@@ -234,8 +232,8 @@ Once stopped you may resume the simulation at any snapshot or at the latest resu
|
|
|
234
232
|
sim.resume()
|
|
235
233
|
```
|
|
236
234
|
|
|
237
|
-
Resuming from snapshot
|
|
238
|
-
Running asynchronously (test = False): ./fargo3d_SETUP-fargo_PARALLEL-0_GPU-0 -m -t -S
|
|
235
|
+
Resuming from snapshot 4...
|
|
236
|
+
Running asynchronously (test = False): ./fargo3d_SETUP-fargo_PARALLEL-0_GPU-0 -m -t -S 4 -t -S 4 -t setups/fargo/fargo.par
|
|
239
237
|
Now you are connected with output directory '/home/jzuluaga/fargo3d/outputs/fargo'
|
|
240
238
|
|
|
241
239
|
|
|
@@ -367,13 +365,26 @@ fp.Simulation.download_precomputed(setup='fargo')
|
|
|
367
365
|
Downloading...
|
|
368
366
|
From: https://docs.google.com/uc?export=download&id=1YXLKlf9fCGHgLej2fSOHgStD05uFB2C3
|
|
369
367
|
To: /tmp/fargo.tgz
|
|
370
|
-
100%|██████████| 54.7M/54.7M [
|
|
368
|
+
100%|██████████| 54.7M/54.7M [01:14<00:00, 738kB/s]
|
|
371
369
|
|
|
372
370
|
|
|
373
371
|
Uncompressing fargo.tgz into /tmp/fargo
|
|
374
372
|
Done.
|
|
375
373
|
|
|
376
374
|
|
|
375
|
+
Once downloaded you may connect with simulation using:
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
```python
|
|
379
|
+
sim = fp.Simulation(output_dir = '/tmp/fargo')
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Your simulation is now connected with '/home/jzuluaga/fargo3d/'
|
|
383
|
+
Now you are connected with output directory '/tmp/fargo'
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
and perform the postprocessing as explained before.
|
|
387
|
+
|
|
377
388
|
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](https://drive.google.com/drive/folders/1NRdNOcmxRK-pHv_8vR-aAAJGWXxIOY0J?usp=sharing):
|
|
378
389
|
|
|
379
390
|
|
|
@@ -48,7 +48,7 @@ import fargopy as fp
|
|
|
48
48
|
%autoreload 2
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
Running FARGOpy version 0.3.
|
|
51
|
+
Running FARGOpy version 0.3.4
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
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:
|
|
@@ -174,14 +174,12 @@ Or check the progress of the simulation:
|
|
|
174
174
|
sim.status('progress')
|
|
175
175
|
```
|
|
176
176
|
|
|
177
|
-
Progress of the simulation (numstatus = 5):
|
|
178
|
-
1:OUTPUTS
|
|
179
|
-
2:OUTPUTS
|
|
180
|
-
3:OUTPUTS
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
Running status of the process:
|
|
184
|
-
The process is running.
|
|
177
|
+
Progress of the simulation (numstatus = 5, interrupting may stop the process):
|
|
178
|
+
1:OUTPUTS 0 at date t = 0.000000 OK [output pace = 0.1 secs]
|
|
179
|
+
2:OUTPUTS 1 at date t = 6.283185 OK [output pace = 0.1 secs]
|
|
180
|
+
3:OUTPUTS 2 at date t = 12.566371 OK [output pace = 1.6 secs]
|
|
181
|
+
4:OUTPUTS 3 at date t = 18.849556 OK [output pace = 4.9 secs]
|
|
182
|
+
5:OUTPUTS 4 at date t = 25.132741 OK [output pace = 4.9 secs]
|
|
185
183
|
|
|
186
184
|
|
|
187
185
|
You may stop the simulation at any time using:
|
|
@@ -191,7 +189,7 @@ You may stop the simulation at any time using:
|
|
|
191
189
|
sim.stop()
|
|
192
190
|
```
|
|
193
191
|
|
|
194
|
-
Stopping FARGO3D process (pid =
|
|
192
|
+
Stopping FARGO3D process (pid = 18717)
|
|
195
193
|
|
|
196
194
|
|
|
197
195
|
Check the status of the simulation using:
|
|
@@ -201,7 +199,7 @@ Check the status of the simulation using:
|
|
|
201
199
|
sim.status('summary')
|
|
202
200
|
```
|
|
203
201
|
|
|
204
|
-
The simulation has been ran for
|
|
202
|
+
The simulation has been ran for 6 time-steps (including the initial one).
|
|
205
203
|
|
|
206
204
|
|
|
207
205
|
Once stopped you may resume the simulation at any snapshot or at the latest resumable snapshot:
|
|
@@ -211,8 +209,8 @@ Once stopped you may resume the simulation at any snapshot or at the latest resu
|
|
|
211
209
|
sim.resume()
|
|
212
210
|
```
|
|
213
211
|
|
|
214
|
-
Resuming from snapshot
|
|
215
|
-
Running asynchronously (test = False): ./fargo3d_SETUP-fargo_PARALLEL-0_GPU-0 -m -t -S
|
|
212
|
+
Resuming from snapshot 4...
|
|
213
|
+
Running asynchronously (test = False): ./fargo3d_SETUP-fargo_PARALLEL-0_GPU-0 -m -t -S 4 -t -S 4 -t setups/fargo/fargo.par
|
|
216
214
|
Now you are connected with output directory '/home/jzuluaga/fargo3d/outputs/fargo'
|
|
217
215
|
|
|
218
216
|
|
|
@@ -344,13 +342,26 @@ fp.Simulation.download_precomputed(setup='fargo')
|
|
|
344
342
|
Downloading...
|
|
345
343
|
From: https://docs.google.com/uc?export=download&id=1YXLKlf9fCGHgLej2fSOHgStD05uFB2C3
|
|
346
344
|
To: /tmp/fargo.tgz
|
|
347
|
-
100%|██████████| 54.7M/54.7M [
|
|
345
|
+
100%|██████████| 54.7M/54.7M [01:14<00:00, 738kB/s]
|
|
348
346
|
|
|
349
347
|
|
|
350
348
|
Uncompressing fargo.tgz into /tmp/fargo
|
|
351
349
|
Done.
|
|
352
350
|
|
|
353
351
|
|
|
352
|
+
Once downloaded you may connect with simulation using:
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
```python
|
|
356
|
+
sim = fp.Simulation(output_dir = '/tmp/fargo')
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
Your simulation is now connected with '/home/jzuluaga/fargo3d/'
|
|
360
|
+
Now you are connected with output directory '/tmp/fargo'
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
and perform the postprocessing as explained before.
|
|
364
|
+
|
|
354
365
|
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](https://drive.google.com/drive/folders/1NRdNOcmxRK-pHv_8vR-aAAJGWXxIOY0J?usp=sharing):
|
|
355
366
|
|
|
356
367
|
|
|
@@ -8,6 +8,7 @@ from fargopy.version import *
|
|
|
8
8
|
###############################################################
|
|
9
9
|
import warnings
|
|
10
10
|
import os
|
|
11
|
+
import json
|
|
11
12
|
import numpy as np
|
|
12
13
|
|
|
13
14
|
###############################################################
|
|
@@ -122,6 +123,24 @@ class Fargobj(object):
|
|
|
122
123
|
self.fobject = True
|
|
123
124
|
self.kwargs = kwargs
|
|
124
125
|
|
|
126
|
+
def save_object(self,filename=None,verbose=False):
|
|
127
|
+
"""Save Fargobj into a filename in JSON format
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
filename: string, default = None:
|
|
131
|
+
Path of the file where the object will be saved.
|
|
132
|
+
If None the filename will be '/tmp/fargobj_{hash}.json'
|
|
133
|
+
where {hash} is the hash of the object attributes dictionary.
|
|
134
|
+
"""
|
|
135
|
+
if filename is None:
|
|
136
|
+
object_hash = str(abs(hash(str(self.__dict__))))
|
|
137
|
+
filename = f"/tmp/fargobj_{object_hash}.json"
|
|
138
|
+
if verbose:
|
|
139
|
+
print(f"Saving object to {filename}...")
|
|
140
|
+
with open(filename,'w') as file_object:
|
|
141
|
+
file_object.write(json.dumps(self.__dict__,default=lambda obj:'<not serializable>'))
|
|
142
|
+
file_object.close()
|
|
143
|
+
|
|
125
144
|
def set_property(self,property,default,method=lambda prop:prop):
|
|
126
145
|
"""Set a property of object using a given method
|
|
127
146
|
|
|
@@ -7,6 +7,7 @@ import fargopy
|
|
|
7
7
|
# Required packages
|
|
8
8
|
###############################################################
|
|
9
9
|
import os
|
|
10
|
+
import json
|
|
10
11
|
import numpy as np
|
|
11
12
|
import re
|
|
12
13
|
import subprocess
|
|
@@ -68,7 +69,31 @@ class Simulation(fargopy.Fargobj):
|
|
|
68
69
|
super().__init__(**kwargs)
|
|
69
70
|
|
|
70
71
|
# Load simulation configuration from a file
|
|
71
|
-
|
|
72
|
+
if ('load' in kwargs.keys()) and kwargs['load']:
|
|
73
|
+
if not 'setup' in kwargs.keys():
|
|
74
|
+
raise AssertionError(f"You must provide a setup name.")
|
|
75
|
+
else:
|
|
76
|
+
setup = kwargs['setup']
|
|
77
|
+
if 'fargo3d_dir' in kwargs.keys():
|
|
78
|
+
fargo3d_dir = kwargs['fargo3d_dir']
|
|
79
|
+
else:
|
|
80
|
+
fargo3d_dir = fargopy.Conf.FP_FARGO3D_DIR
|
|
81
|
+
|
|
82
|
+
load_from = f"{fargo3d_dir}/setups/{setup}".replace('//','/')
|
|
83
|
+
if not os.path.isdir(load_from):
|
|
84
|
+
print(f"Directory for loading simulation '{load_from}' not found.")
|
|
85
|
+
json_file = f"{load_from}/fargopy_simulation.json"
|
|
86
|
+
print(f"Loading simulation from '{json_file}'")
|
|
87
|
+
if not os.path.isfile(json_file):
|
|
88
|
+
print(f"Loading data '{json_file}' not found.")
|
|
89
|
+
with open(json_file) as file_handler:
|
|
90
|
+
attributes = json.load(file_handler)
|
|
91
|
+
self.__dict__.update(attributes)
|
|
92
|
+
self.set_fargo3d_dir(self.fargo3d_dir)
|
|
93
|
+
self.set_setup(self.setup)
|
|
94
|
+
self.set_output_dir(self.output_dir)
|
|
95
|
+
return
|
|
96
|
+
|
|
72
97
|
# Set units by default
|
|
73
98
|
self.set_units(UL=AU,UM=MSUN)
|
|
74
99
|
|
|
@@ -207,7 +232,7 @@ class Simulation(fargopy.Fargobj):
|
|
|
207
232
|
print(f"Cleaning FARGO3D directory {self.fargo3d_dir}...")
|
|
208
233
|
cmd = f"make -C {self.fargo3d_dir} clean mrproper"
|
|
209
234
|
compl = f"rm -rf {self.fargo3d_dir}/fargo3d_*"
|
|
210
|
-
error,
|
|
235
|
+
error,output_clean = fargopy.Sys.run(cmd + '&&' + compl)
|
|
211
236
|
|
|
212
237
|
# Prepare compilation
|
|
213
238
|
compile_options = f"SETUP={self.setup} PARALLEL={parallel} GPU={gpu} "+options
|
|
@@ -215,9 +240,10 @@ class Simulation(fargopy.Fargobj):
|
|
|
215
240
|
|
|
216
241
|
# Compile binary
|
|
217
242
|
print(f"Compiling {fargo3d_binary}...")
|
|
218
|
-
cmd = f"cd {self.fargo3d_dir};make {compile_options}"
|
|
243
|
+
cmd = f"cd {self.fargo3d_dir};make {compile_options} 2>&1 |tee {self.setup_dir}/compilation.log"
|
|
219
244
|
compl = f"mv fargo3d {fargo3d_binary}"
|
|
220
|
-
|
|
245
|
+
pipe = f""
|
|
246
|
+
error,output_compilation = fargopy.Sys.run(cmd+' && '+compl)
|
|
221
247
|
|
|
222
248
|
# Check compilation result
|
|
223
249
|
if os.path.isfile(f"{self.fargo3d_dir}/{fargo3d_binary}"):
|
|
@@ -229,7 +255,7 @@ class Simulation(fargopy.Fargobj):
|
|
|
229
255
|
options=options
|
|
230
256
|
)
|
|
231
257
|
else:
|
|
232
|
-
print(f"Something failed when compiling FARGO3D. For details check
|
|
258
|
+
print(f"Something failed when compiling FARGO3D. For details check '{self.setup_dir}/compilation.log")
|
|
233
259
|
|
|
234
260
|
def run(self,
|
|
235
261
|
mode='async',
|
|
@@ -237,7 +263,8 @@ class Simulation(fargopy.Fargobj):
|
|
|
237
263
|
mpioptions='-np 1',
|
|
238
264
|
resume=False,
|
|
239
265
|
cleanrun=False,
|
|
240
|
-
test=False
|
|
266
|
+
test=False,
|
|
267
|
+
unlock=True):
|
|
241
268
|
|
|
242
269
|
if self.fargo3d_binary is None:
|
|
243
270
|
print("You must first compile your simulation with: <simulation>.compile(<option>).")
|
|
@@ -271,8 +298,12 @@ class Simulation(fargopy.Fargobj):
|
|
|
271
298
|
|
|
272
299
|
# Preparing command
|
|
273
300
|
run_cmd = f"{precmd} ./{self.fargo3d_binary} {options} setups/{self.setup}/{self.setup}.par"
|
|
274
|
-
|
|
301
|
+
|
|
302
|
+
self.json_file = f"{self.setup_dir}/fargopy_simulation.json"
|
|
275
303
|
if mode == 'sync':
|
|
304
|
+
# Save object
|
|
305
|
+
self.save_object(self.json_file)
|
|
306
|
+
|
|
276
307
|
# Run synchronously
|
|
277
308
|
cmd = f"cd {self.fargo3d_dir};{run_cmd} |tee {self.logfile}"
|
|
278
309
|
print(f"Running synchronously: {cmd}")
|
|
@@ -289,6 +320,16 @@ class Simulation(fargopy.Fargobj):
|
|
|
289
320
|
# Launch process
|
|
290
321
|
print(f"Running asynchronously (test = {test}): {run_cmd}")
|
|
291
322
|
if not test:
|
|
323
|
+
|
|
324
|
+
# Check it is not locked
|
|
325
|
+
lock_info = fargopy.Sys.is_locked(dir=self.setup_dir)
|
|
326
|
+
if lock_info:
|
|
327
|
+
if unlock:
|
|
328
|
+
self._unlock_simulation(lock_info)
|
|
329
|
+
else:
|
|
330
|
+
print(f"Output directory {self.setup_dir} is locked by a running process")
|
|
331
|
+
return
|
|
332
|
+
|
|
292
333
|
process = subprocess.Popen(run_cmd.split(),cwd=self.fargo3d_dir,
|
|
293
334
|
stdout=logfile_handler,stderr=logfile_handler)
|
|
294
335
|
# Introduce a short delay to verify if the process has failed
|
|
@@ -298,16 +339,29 @@ class Simulation(fargopy.Fargobj):
|
|
|
298
339
|
# Check if program is effectively running
|
|
299
340
|
self.fargo3d_process = process
|
|
300
341
|
|
|
301
|
-
#
|
|
302
|
-
|
|
342
|
+
# Lock
|
|
343
|
+
fargopy.Sys.lock(
|
|
344
|
+
dir=self.setup_dir,
|
|
345
|
+
content=dict(pid=self.fargo3d_process.pid)
|
|
346
|
+
)
|
|
303
347
|
|
|
304
348
|
# Setup output directory
|
|
305
349
|
self.set_output_dir(f"{self.outputs_dir}/{self.setup}".replace('//','/'))
|
|
350
|
+
|
|
351
|
+
# Save object
|
|
352
|
+
self.save_object(self.json_file)
|
|
306
353
|
else:
|
|
307
354
|
print(f"Process running failed. Please check the logfile {self.logfile}")
|
|
355
|
+
else:
|
|
356
|
+
print(f"Mode {mode} not recognized (valid are 'sync', 'async')")
|
|
357
|
+
return
|
|
308
358
|
|
|
309
359
|
def stop(self):
|
|
360
|
+
# Check if the directory is locked
|
|
361
|
+
lock_info = fargopy.Sys.is_locked(self.setup_dir)
|
|
362
|
+
|
|
310
363
|
if not self._check_process():
|
|
364
|
+
self._unlock_simulation(lock_info)
|
|
311
365
|
return
|
|
312
366
|
|
|
313
367
|
poll = self.fargo3d_process.poll()
|
|
@@ -317,13 +371,16 @@ class Simulation(fargopy.Fargobj):
|
|
|
317
371
|
del self.fargo3d_process
|
|
318
372
|
self.fargo3d_process = None
|
|
319
373
|
else:
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
374
|
+
self._unlock_simulation(lock_info)
|
|
375
|
+
print(f"The process has finished. Check logfile {self.logfile}.")
|
|
376
|
+
|
|
377
|
+
def _unlock_simulation(self,lock_info):
|
|
378
|
+
if lock_info:
|
|
379
|
+
pid = lock_info['pid']
|
|
380
|
+
fargopy.Debug.trace(f"Unlocking simulation (pid = {pid})")
|
|
381
|
+
error,output = fargopy.Sys.run(f"kill -9 {pid}")
|
|
382
|
+
fargopy.Sys.unlock(self.setup_dir)
|
|
383
|
+
|
|
327
384
|
def status(self,mode='isrunning',verbose=True,**kwargs):
|
|
328
385
|
"""Check the status of the running process
|
|
329
386
|
|
|
@@ -350,6 +407,10 @@ class Simulation(fargopy.Fargobj):
|
|
|
350
407
|
if poll is None:
|
|
351
408
|
vprint("\tThe process is running.")
|
|
352
409
|
else:
|
|
410
|
+
# Unlock any remaining process
|
|
411
|
+
lock_info = fargopy.Sys.is_locked(self.setup_dir)
|
|
412
|
+
self._unlock_simulation(lock_info)
|
|
413
|
+
|
|
353
414
|
vprint(f"\tThe process has ended with termination code {poll}.")
|
|
354
415
|
else:
|
|
355
416
|
vprint(f"\tThe process is stopped.")
|
|
@@ -489,6 +550,11 @@ class Simulation(fargopy.Fargobj):
|
|
|
489
550
|
error,output = fargopy.Sys.run(cmd)
|
|
490
551
|
|
|
491
552
|
def _is_running(self,verbose=False):
|
|
553
|
+
if not self.has('fargo3d_process'):
|
|
554
|
+
if verbose:
|
|
555
|
+
print("The simulation has not been run before.")
|
|
556
|
+
return False
|
|
557
|
+
|
|
492
558
|
if self.fargo3d_process:
|
|
493
559
|
poll = self.fargo3d_process.poll()
|
|
494
560
|
if poll is None:
|
|
@@ -795,7 +861,8 @@ class Simulation(fargopy.Fargobj):
|
|
|
795
861
|
return comps
|
|
796
862
|
|
|
797
863
|
def __repr__(self):
|
|
798
|
-
|
|
864
|
+
repr = f"""FARGOPY simulation (fargo3d_dir = '{self.fargo3d_dir}', setup = '{self.setup}')"""
|
|
865
|
+
return repr
|
|
799
866
|
|
|
800
867
|
def __str__(self):
|
|
801
868
|
str = f"""Simulation information:
|
|
@@ -7,6 +7,7 @@ import fargopy
|
|
|
7
7
|
# Required packages
|
|
8
8
|
###############################################################
|
|
9
9
|
import os
|
|
10
|
+
import json
|
|
10
11
|
import subprocess
|
|
11
12
|
import inspect
|
|
12
13
|
import signal
|
|
@@ -142,3 +143,41 @@ class Sys(object):
|
|
|
142
143
|
print(f"There is a lockfile in {fargopy.FP_FARGO3D_LOCKFILE}")
|
|
143
144
|
return True
|
|
144
145
|
return False
|
|
146
|
+
|
|
147
|
+
@staticmethod
|
|
148
|
+
def lock(dir,content=dict()):
|
|
149
|
+
"""Lock a directory using content information
|
|
150
|
+
"""
|
|
151
|
+
if not os.path.isdir(dir):
|
|
152
|
+
print(f"Locking directory '{dir}' not found.")
|
|
153
|
+
return
|
|
154
|
+
filename = f"{dir}/fargopy.lock"
|
|
155
|
+
|
|
156
|
+
with open(filename,'w') as file_object:
|
|
157
|
+
file_object.write(json.dumps(content,default=lambda obj:'<not serializable>'))
|
|
158
|
+
file_object.close()
|
|
159
|
+
|
|
160
|
+
@staticmethod
|
|
161
|
+
def unlock(dir):
|
|
162
|
+
"""UnLock a directory
|
|
163
|
+
"""
|
|
164
|
+
if not os.path.isdir(dir):
|
|
165
|
+
print(f"Locking directory '{dir}' not found.")
|
|
166
|
+
return
|
|
167
|
+
filename = f"{dir}/fargopy.lock"
|
|
168
|
+
if os.path.isfile(filename):
|
|
169
|
+
fargopy.Sys.simple(f"rm -rf {filename}")
|
|
170
|
+
|
|
171
|
+
@staticmethod
|
|
172
|
+
def is_locked(dir,verbose=False):
|
|
173
|
+
if not os.path.isdir(dir):
|
|
174
|
+
if verbose:
|
|
175
|
+
print(f"Locking directory '{dir}' not found.")
|
|
176
|
+
return False
|
|
177
|
+
filename = f"{dir}/fargopy.lock"
|
|
178
|
+
if os.path.isfile(filename):
|
|
179
|
+
if verbose:
|
|
180
|
+
print(f"The directory '{dir}' is locked")
|
|
181
|
+
with open(filename) as file_handler:
|
|
182
|
+
info = json.load(file_handler)
|
|
183
|
+
return info
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
version='0.3.5'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: fargopy
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.5
|
|
4
4
|
Summary: FARGO3D Wrapping
|
|
5
5
|
Home-page: https://pypi.org/project/fargopy
|
|
6
6
|
Author: Jorge Zuluaga, Matias Montesinos
|
|
@@ -71,7 +71,7 @@ import fargopy as fp
|
|
|
71
71
|
%autoreload 2
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
Running FARGOpy version 0.3.
|
|
74
|
+
Running FARGOpy version 0.3.4
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
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:
|
|
@@ -197,14 +197,12 @@ Or check the progress of the simulation:
|
|
|
197
197
|
sim.status('progress')
|
|
198
198
|
```
|
|
199
199
|
|
|
200
|
-
Progress of the simulation (numstatus = 5):
|
|
201
|
-
1:OUTPUTS
|
|
202
|
-
2:OUTPUTS
|
|
203
|
-
3:OUTPUTS
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
Running status of the process:
|
|
207
|
-
The process is running.
|
|
200
|
+
Progress of the simulation (numstatus = 5, interrupting may stop the process):
|
|
201
|
+
1:OUTPUTS 0 at date t = 0.000000 OK [output pace = 0.1 secs]
|
|
202
|
+
2:OUTPUTS 1 at date t = 6.283185 OK [output pace = 0.1 secs]
|
|
203
|
+
3:OUTPUTS 2 at date t = 12.566371 OK [output pace = 1.6 secs]
|
|
204
|
+
4:OUTPUTS 3 at date t = 18.849556 OK [output pace = 4.9 secs]
|
|
205
|
+
5:OUTPUTS 4 at date t = 25.132741 OK [output pace = 4.9 secs]
|
|
208
206
|
|
|
209
207
|
|
|
210
208
|
You may stop the simulation at any time using:
|
|
@@ -214,7 +212,7 @@ You may stop the simulation at any time using:
|
|
|
214
212
|
sim.stop()
|
|
215
213
|
```
|
|
216
214
|
|
|
217
|
-
Stopping FARGO3D process (pid =
|
|
215
|
+
Stopping FARGO3D process (pid = 18717)
|
|
218
216
|
|
|
219
217
|
|
|
220
218
|
Check the status of the simulation using:
|
|
@@ -224,7 +222,7 @@ Check the status of the simulation using:
|
|
|
224
222
|
sim.status('summary')
|
|
225
223
|
```
|
|
226
224
|
|
|
227
|
-
The simulation has been ran for
|
|
225
|
+
The simulation has been ran for 6 time-steps (including the initial one).
|
|
228
226
|
|
|
229
227
|
|
|
230
228
|
Once stopped you may resume the simulation at any snapshot or at the latest resumable snapshot:
|
|
@@ -234,8 +232,8 @@ Once stopped you may resume the simulation at any snapshot or at the latest resu
|
|
|
234
232
|
sim.resume()
|
|
235
233
|
```
|
|
236
234
|
|
|
237
|
-
Resuming from snapshot
|
|
238
|
-
Running asynchronously (test = False): ./fargo3d_SETUP-fargo_PARALLEL-0_GPU-0 -m -t -S
|
|
235
|
+
Resuming from snapshot 4...
|
|
236
|
+
Running asynchronously (test = False): ./fargo3d_SETUP-fargo_PARALLEL-0_GPU-0 -m -t -S 4 -t -S 4 -t setups/fargo/fargo.par
|
|
239
237
|
Now you are connected with output directory '/home/jzuluaga/fargo3d/outputs/fargo'
|
|
240
238
|
|
|
241
239
|
|
|
@@ -367,13 +365,26 @@ fp.Simulation.download_precomputed(setup='fargo')
|
|
|
367
365
|
Downloading...
|
|
368
366
|
From: https://docs.google.com/uc?export=download&id=1YXLKlf9fCGHgLej2fSOHgStD05uFB2C3
|
|
369
367
|
To: /tmp/fargo.tgz
|
|
370
|
-
100%|██████████| 54.7M/54.7M [
|
|
368
|
+
100%|██████████| 54.7M/54.7M [01:14<00:00, 738kB/s]
|
|
371
369
|
|
|
372
370
|
|
|
373
371
|
Uncompressing fargo.tgz into /tmp/fargo
|
|
374
372
|
Done.
|
|
375
373
|
|
|
376
374
|
|
|
375
|
+
Once downloaded you may connect with simulation using:
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
```python
|
|
379
|
+
sim = fp.Simulation(output_dir = '/tmp/fargo')
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Your simulation is now connected with '/home/jzuluaga/fargo3d/'
|
|
383
|
+
Now you are connected with output directory '/tmp/fargo'
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
and perform the postprocessing as explained before.
|
|
387
|
+
|
|
377
388
|
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](https://drive.google.com/drive/folders/1NRdNOcmxRK-pHv_8vR-aAAJGWXxIOY0J?usp=sharing):
|
|
378
389
|
|
|
379
390
|
|
fargopy-0.3.4/fargopy/version.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
version='0.3.4'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|