Input format

Two formats are accepted. The format is chosen by the file extension.

Text format (.txt)

This is the original Celestial Rhapsody format. It is still supported:

[Global]
G = 1.0
dt = 0.01
final_time = 5

[Planet]
name = P1
mass = 1.0
x_0 = 0.8083106230
y_0 = 0.0
vx_0 = 0.0
vy_0 = 0.9901979166

[Planet]
name = P2
...

Warning

The values are read in order, not by name. Keep the lines in exactly this order: G, dt, final_time and then name, mass, x_0, y_0, vx_0, vy_0 for every planet. The first line must be [Global]. The text format is 2D only and has no softening option.

Units

The code uses no fixed units. Just be consistent. Two common choices:

  • Dimensionless: G = 1, masses and distances of order 1.

  • Astronomical: distances in AU, time in years, masses in solar masses. Then \(G = 4\pi^2 \approx 39.478\) and the Earth moves at \(2\pi\) AU/yr. See examples/inner_solar_system.json.

Choosing dt

dt should be much smaller than the shortest orbital period in the system, about 1/500 of it is a good start. Then look at the energy drift printed by nbody run. If it is larger than about 1e-3, halve dt.

Checking a file

nbody check my_system.json

Errors say what is wrong, for example:

error: invalid input: Body 1 is missing: velocity