Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/amuse/ext/masc/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ def new_fixed_mass_distribution(
mass = mass[mass.cumsum() < stellar_mass]

additional_mass = [] | units.MSun
while True:
if previous_number_of_stars + len(additional_mass) > len(mass):
count_failsafe = 0
while count_failsafe > 10:
if len(mass) > number_of_stars:
break
# We don't have enough stars yet, or at least not tested this
additional_mass = initial_mass_function(
Expand All @@ -102,6 +103,7 @@ def new_fixed_mass_distribution(
mass.sum() + additional_mass.cumsum() < stellar_mass
]
mass.append(additional_mass)
count_failsafe += 1
number_of_stars = len(mass)
else:
# Give stars their mass
Expand All @@ -111,6 +113,7 @@ def new_fixed_mass_distribution(
mass_max=upper_mass_limit,
)

mass = mass.flatten()
return mass


Expand Down