Quick-n-dirty binary star simulation in AMUSE

In the top level directory (where amuse.sh lives), create a file binary.py with the following contents:


 * 1) !/usr/bin/python

import sys

from amuse.legacy.phiGRAPE.muse_dynamics_mpi import *

pg = PhiGRAPE

pg.setup_module pg.add_particle(1, 1., 0.1, 1., 0., 0., 0, 0.5, 0.) pg.add_particle(2, 1., 0.1, -1., 0., 0., 0., -0.5, 0.) pg.initialize_particles(0.)

star1 = open("star1.dat", "w") star2 = open("star2.dat", "w")

for i in range(100) : pg.evolve(0.1*i, 0) t = pg.get_time star1data = pg.get_state(1) star2data = pg.get_state(2)

star1.write("%.2f %.2f %.2f %.2f\n" %               (t, star1data['x'], star1data['y'], star1data['z']) ) star2.write("%.2f %.2f %.2f %.2f\n" %               (t, star2data['x'], star2data['y'], star2data['z']) )

star1.close star2.close

Then run:

./amuse.sh binary.py

When that finishes, you will have two files, "star1.dat" and "star2.dat", which are data files with 4 columns showing (t, x, y, z) for two orbiting stars in increments of 1 "time unit"... where the time unit is whatever make sense given the mass units and distance units and the assumption that G=1.

You can look at the jolly results with gnuplot, for example:

gnuplot> plot "star1.dat" using 1:2 gnuplot> set size ratio=1 gnuplot> plot "star1.dat" using 2:3