Skip to content

Commit 9c3ca0e

Browse files
committed
update make_oort_cloud.py
1 parent dbb6d71 commit 9c3ca0e

1 file changed

Lines changed: 25 additions & 13 deletions

File tree

src/amuse/examples/make_oort_cloud.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -388,34 +388,46 @@ def new_argument_parser():
388388
return result
389389

390390

391-
def main():
392-
args = new_argument_parser().parse_args()
393-
outfile = args.outfile
394-
395-
if args.outfile is None:
396-
outfile = f"sun_and_comets_N{args.n_comets:01}.amuse"
391+
def make_oort_cloud(
392+
outfile=None,
393+
filename="starandplanets.amuse",
394+
n_comets=100,
395+
m_comets=0 | units.MEarth,
396+
seed=None,
397+
q_min=32 | units.au,
398+
a_min=3000.0 | units.au,
399+
a_max=100000.0 | units.au,
400+
m_min=0.0 | units.MSun,
401+
m_max=100.0 | units.MSun,
402+
):
403+
if outfile is None:
404+
outfile = f"sun_and_comets_N{n_comets:01}.amuse"
397405

398-
bodies = read_set_from_file(args.filename, close_file=True)
406+
bodies = read_set_from_file(filename, close_file=True)
399407
stars = bodies[bodies.type == "star"]
400-
selected_stars = stars.select(lambda m: m > args.m_min, ["mass"])
401-
selected_stars = selected_stars.select(lambda m: m <= args.m_max, ["mass"])
408+
selected_stars = stars.select(lambda m: m > m_min, ["mass"])
409+
selected_stars = selected_stars.select(lambda m: m <= m_max, ["mass"])
402410
print(f"Number of stars: {len(stars)} {len(selected_stars)}")
403411

404412
for si in selected_stars:
405-
m_comets = args.m_comets * si.mass.value_in(units.MSun)
406-
n_comets = int(args.n_comets * si.mass.value_in(units.MSun))
413+
m_comets = m_comets * si.mass.value_in(units.MSun)
414+
n_comets = int(n_comets * si.mass.value_in(units.MSun))
407415
comets = add_comets(si, m_comets, n_comets,
408-
args.q_min, args.a_min, args.a_max, args.seed)
416+
q_min, a_min, a_max, seed)
409417
bodies.add_particles(comets)
410418
bodies.move_to_center()
411419
print(bodies)
412420

413-
index = 0
414421
time = 0 | units.Myr
415422
write_set_to_file(
416423
bodies, outfile, timestamp=time, append_to_file=False,
417424
)
418425

419426

427+
def main():
428+
args = new_argument_parser().parse_args()
429+
make_oort_cloud(**args.__dict__)
430+
431+
420432
if __name__ == "__main__":
421433
main()

0 commit comments

Comments
 (0)