amusecode / amuse

Astrophysical Multipurpose Software Environment. This is the main repository for AMUSE
http://www.amusecode.org
Apache License 2.0
154 stars 98 forks source link

nbody6 does not keep individual masses of stars #961

Open rieder opened 1 year ago

rieder commented 1 year ago

When evolving a star cluster with a mass function with the Nbody6++ code, the masses assigned to particles change after some evolve steps. Perhaps this is related to encounters between stars?

While this remains unfixed, Nbody6++ in AMUSE should not be used for simulations with non-equal mass stars.

E.g.:

"""
AMUSE-Nbody6 script
"""
import numpy as np
from amuse.units import nbody_system, units
from amuse.ic.plummer import new_plummer_model
from amuse.ic.kroupa import new_kroupa_mass_distribution
from amuse.community.nbody6xx import Nbody6xx

np.random.seed(123)
number_of_stars = 100
mass = new_kroupa_mass_distribution(number_of_stars)
total_mass = mass.sum()
converter = nbody_system.nbody_to_si(total_mass, 0.1 | units.Myr)
particles = new_plummer_model(number_of_stars, convert_nbody=converter)
particles.mass = mass

gravity = Nbody6xx(convert_nbody=converter)
gravity.particles.add_particles(particles)

time = 0 | units.Myr
while time < 2 | units.Myr:
    gravity.evolve_model(time)
    print(gravity.model_time, gravity.particles[0].mass)
    time = time + (0.1 | units.Myr)
gravity.stop()

prints the following:

0.0 s 4.92440516115e+29 kg
6.31138519872e+12 s 4.92440516115e+29 kg
9.46707779808e+12 s 4.92440516115e+29 kg
1.26227703974e+13 s 4.92440516115e+29 kg
1.57784629968e+13 s 4.92440516115e+29 kg
1.89341555962e+13 s 4.92440516115e+29 kg
2.20898481955e+13 s 4.92440516115e+29 kg
2.46737111522e+13 s 1.2953964666e+30 kg  # <-- mass changes
2.84012333942e+13 s 1.2953964666e+30 kg
3.15569259936e+13 s 1.2953964666e+30 kg
3.4712618593e+13 s 1.2953964666e+30 kg
3.78683111923e+13 s 1.2953964666e+30 kg
4.10240037917e+13 s 1.2953964666e+30 kg
4.4179696391e+13 s 1.2953964666e+30 kg
4.73353889904e+13 s 1.2953964666e+30 kg
5.04910815898e+13 s 1.2953964666e+30 kg
5.0783942344e+13 s 4.81168215574e+30 kg  # <-- mass changes again
5.68024667885e+13 s 4.81168215574e+30 kg
5.99581593878e+13 s 4.81168215574e+30 kg
6.31138519872e+13 s 4.81168215574e+30 kg