-
Notifications
You must be signed in to change notification settings - Fork 4
Home
diskpy is a python package for generating, analyzing, and managing NBody simulations of protoplanetary disks (PPDs). diskpy contains:
- ICgen Package for generating PPD initial conditions (ICs)
- utils Various utilities
- clumps Modules for finding, tracking, and analyzing fragments in unstable PPDs
- disk Modules for analyzing disks
- pdmath PyDiskMath, general math routines
- plot Plotting routines
- pychanga Modules for interacting with ChaNGa
Check out the useful tools
Before using diskpy, there are probably a few things worth knowing.
First, diskpy depends heavily on pynbody. Users should familiarize themselves with pynbody, in particular, users should be comfortable with SimSnaps
and SimArrays
. In particular, this is worth reading
SimSnaps
are simulation snapshot objects that handle all the information and arrays for simulation snapshots used with ChaNGa.
SimArrays
are very useful wrappers around numpy ndarrays which allow units. Units are incredibly useful checks to verify that your algebra and basic coding are correct AND units conversion is very frequently messed up or accidentally omitted. For this reason, I try whenever possible to use SimArrays
. While they can be a little more clunky than normal arrays, this has saved me endless headaches.
All the simulations, snapshots, and some of the analysis are built around/for ChaNGa. If the user has access to the ChaNGa UW Branch they should use that.
Python dependencies:
- Python 2.x (preferably 2.7). Sorry, this is only a python 2 package!
- numpy
- scipy [version >= 0.16.0]
- pynbody [version >= 0.40]
- matplotlib
Other dependencies:
- ChaNGa or if you have access: changa_uw (Required for ICgen) If you have access, changa_uw is recommended. If you don't have changa_uw, then sink parameters which are set in the .param file will cause ChaNGa to crash and should be commented out.
- [SKID] (https://github.com/N-BodyShop/skid) (Required for clump finding)
You can clone the repo using https://github.com/ibackus/diskpy.git
Then make sure to add the cloned folder diskpy
to your PYTHONPATH.
ChaNGa is required by diskpy. To allow diskpy to properly execute ChaNGa, you'll have to edit or create a preset for running ChaNGa. This can be done in python and is pretty simple. This only needs to be done once, the settings will be saved.
ChaNGa presets are stored as a 4 element list (or tuple). These basically supply the command-line arguments which are used for executing ChaNGa and they are all strings [runner, runner_arguments, ChaNGa, ChaNGa_arguments]
- runner e.g., 'charmrun' or 'mpirun', etc...
- runner_arguments Additional arguments used by the runner. For no extra arguments, set to an empty string ''
- ChaNGa Command for running ChaNGa, e.g. 'ChaNGa' or '~/bin/ChaNGa_uw'
- ChaNGa_arguments Additional arguments supplied to ChaNGa. For no extra arguments, set to an empty string ''
Here's an example of setting up the 'local' preset.
from diskpy import global_settings
# Echo the default global settings if you want
global_settings()
# Edit the 'local' changa preset
global_settings['changa_presets']['local'] = \
['charmrun', '++local', 'ChaNGa', '-D 3']
# Change which preset is used by default
global_settings['changa_presets']['default'] = 'local'
# Save settings
global_settings.save()
If needed, the default settings can be restored:
global_settings.restore_defaults()
global_settings.save()
ICgen uses ChaNGa to calculate particle velocities. To make this calculation faster, you can have it use a smaller subset of particles by setting:
# Use 10^5 particles (minimum reasonable number here. 10^6 is better)
diskpy.global_settings['misc']['max_particles'] = int(1e5)
# To make the change persist:
diskpy.global_settings.save()