def add_comets(star, m_comets, n_comets, q_min, a_min, a_max, seed): #bodies.position -= star.position #bodies.velocity -= star.velocity cloud_xyz = generate_initial_oort_cloud(star.mass, n_comets, q_min, a_min, a_max, seed) masses = new_salpeter_mass_distribution(n_comets, 0.1 | units.MSun, 100 | units.MSun) masses = m_comets * masses / masses.sum() print("total mass in comets: M=", masses.sum().in_(units.MEarth)) comets = Particles(n_comets) comets.mass = masses comets.name = "comet" comets.host = star comets.x = cloud_xyz[:, 2] | units.au comets.y = cloud_xyz[:, 3] | units.au comets.z = cloud_xyz[:, 4] | units.au comets.vx = cloud_xyz[:, 5] | 2 * numpy.pi * units.au / units.yr comets.vy = cloud_xyz[:, 6] | 2 * numpy.pi * units.au / units.yr comets.vz = cloud_xyz[:, 7] | 2 * numpy.pi * units.au / units.yr comets.position += star.position comets.velocity += star.velocity return comets
def construct_particle_set_from_orbital_elements(name, mass, a, ecc, inc, Ma, Aop, LoAn, Mparent=1 | units.MSun): print("length:", len(a), len(ecc), len(inc), len(Ma), len(Aop), len(LoAn), len(name)) p = Particles(len(a)) print(name) p.name = name p.type = "asteroid" p.host = "Sun" p.mass = mass from orbital_elements_to_cartesian import orbital_elements_to_pos_and_vel from orbital_elements_to_cartesian import orbital_period from amuse.ext.orbital_elements import new_binary_from_orbital_elements for i in range(len(p)): Ta = True_anomaly_from_mean_anomaly(numpy.rad2deg(Ma[i]), ecc[i]) b = new_binary_from_orbital_elements(Mparent, p[i].mass, a[i], ecc[i], Ta, inc[i], LoAn[i], Aop[i], G=constants.G) p[i].position = b[1].position - b[0].position p[i].velocity = b[1].velocity - b[0].velocity rho = 2.0 | units.g / units.cm**3 p.radius = (p.mass / rho)**(1. / 3.) return p