This HTML automatically generated with rman for NEMO
Table of Contents

Description

AMUSE is the Astrophysical MUltipurpose Software Environment. With it, you can simulate many astrophysical systems.

The user interacts with AMUSE in python, so there is currently no amuse command, though one could imagine

ipython --profile=amuse

instead you will want to import this module (see example below) in your python code and go from there. Internally many components in AMUSE are legacy codes (C,C++,Fortran) running at fantastic speeds.

An example is shown below, and within NEMO there the script amuse_convert.py can be used to convert between different snapshot formats, as long as the format is supported by AMUSE. See also unsio(3NEMO) for another approach to such snapshot conversion.

Examples

Here is an example snippet of AMUSE python code integrating a Plummer sphere in nbody units and writing the resulting snapshot as a table:

NBODY = 128
TIME = 10
FILENAME = ’p.txt’

from amuse.units import nbody_system
from amuse.ic.plummer import new_plummer_model
from amuse.community.bhtree import Bhtree
from amuse.io import write_set_to_file,read_set_from_file

stars = new_plummer_model(NBODY)
gravity = Bhtree()

eps = 0.05 | nbody_system.length
tstop = 10 | nbody_system.time

gravity.parameters.opening_angle = 0.75
gravity.parameters.epsilon_squared = eps * eps
gravity.parameters.dt_dia = 1.0 | nbody_system.time
gravity.parameters.timestep = 0.015625 | nbody_system.time

stars_in_gravity = gravity.particles.add_particles(stars)
gravity.evolve_model(tstop)
write_set_to_file(stars_in_gravity, FILENAME, format=’txt’)

This table has mass, radius, velocity and position, one star per row. Notice velocity comes before position! Thus the following NEMO command will convert it to a standard snapshot(5NEMO) file:

nbody=$(tabcols p.txt | wc -l)
tabcols p.txt | tabtos - p.snap block1=mass,skip,vx,vy,vz,x,y,z nbody=$nbody

Bugs

The follow round trip exercise on the txt format causes an error:

fmt=txt amuse_convert.py -o junk1 -O $fmt -n 100 amuse_convert.py -i junk1 -I $fmt -o junk2 -O $fmt amuse.io.base.IoException: IO exception: Number of values on line ’0.01 0.0 -0.319149817818 0.911387278048 0.00131274766207 -1.22528821614 -0.310636170602 0.0257190619401’ is 8, expected 0

formats like csv, amuse-txt, tsf, dyn all seem to work.

Install

Within NEMO the command

mknemo amuse

will get you started on the install. Note there is a user release that does not need NEMO, which can be a set of pip install. A developer release is recommended with NEMO, the start of which will likely look as follows:

cd $NEMO/local/amuse
pip install -e .
make bhtree.code

The AMUSE bhtree code should be the same as the original program bhtree(1NEMO) in NEMO, allowing for a closer comparison.

Snapshot

As described in the help (-h) of amuse_convert.py, the following formats are supported by AMUSE:
amuse        HDF5 file
amuse-txt    text files with AMUSE header format
csv        comma separated files
dyn        Starlab binary structured file
gadget        Gadget binary data file
hdf5        HDF5 file
nemo        NEMO binary structured file
starlab        Starlab binary structured file
tsf        NEMO binary structured file
txt        text file containing a table of values separated by a predefined
vts        text file containing a table of values separated by a predefined character
vtu        text file containing a table of values separated by a predefined character

Files


$NEMO/src/scripts/mknemo.d/amuse - example install script (can be run via
mknemo)
$NEMO/local/amuse - root of source code after install
$NEMO/src/scripts/python/amuse_convert.py - also copied to $NEMOBIN during
install

Ads

@ads 2013A&A...557A..84P @ads 2013CoPhC.184..456P

See Also

nemo(1NEMO) , zeno(1NEMO) , starlab(1NEMO) , bhtree(1NEMO)


https://www.amusecode.org/

History


25-may-2025    man page and amuse_convert.py written (MODEST25-SPZ)    PJT


Table of Contents