def new_system_of_sun_and_earth(self): stars = datamodel.Stars(2) sun = stars[0] sun.mass = units.MSun(1.0) sun.position = units.m(numpy.array((0.0, 0.0, 0.0))) sun.velocity = units.ms(numpy.array((0.0, 0.0, 0.0))) sun.radius = units.RSun(1.0) earth = stars[1] earth.mass = units.kg(5.9736e24) earth.radius = units.km(6371) earth.position = units.km(numpy.array((149.5e6, 0.0, 0.0))) earth.velocity = units.ms(numpy.array((0.0, 29800, 0.0))) return stars
def new_system_of_sun_and_earth_and_moon(self): stars = datamodel.Stars(3) sun = stars[0] sun.mass = units.MSun(1.0) sun.position = units.m(numpy.array((0.0, 0.0, 0.0))) sun.velocity = units.ms(numpy.array((0.0, 0.0, 0.0))) sun.radius = units.RSun(1.0) earth = stars[1] earth.mass = units.kg(5.9736e24) earth.radius = units.km(6371) earth.position = units.km(numpy.array((149.5e6, 0.0, 0.0))) earth.velocity = units.ms(numpy.array((0.0, 29800, 0.0))) moon = stars[2] moon.mass = units.kg(7.3477e22) moon.radius = units.km(1737.10) moon.position = units.km(numpy.array((149.5e6 + 384399.0, 0.0, 0.0))) moon.velocity = ([0.0, 1.022, 0] | units.km / units.s) + earth.velocity return stars
def setup_solar_system(self): convert_nbody = nbody_system.nbody_to_si(1.0 | units.MSun, 149.5e6 | units.km) stars = datamodel.Stars(8) sun = stars[0] sun.mass = units.MSun(1.0) sun.position = units.AU(array((0.0,0.0,0.0))) sun.velocity = units.AUd(array((0.0,0.0,0.0))) sun.radius = units.RSun(1.0) mercury = stars[1] mercury.mass = units.kg( 3.302e23) mercury.radius = units.km(2440) mercury.position = units.AU(array((-1.812507519383936E-01, -4.238556570722329E-01, -1.858336536398257E-02))) mercury.velocity = units.AUd(array((2.028905659997442E-02, -9.482619060967475E-03, -2.636707283074494E-03))) venus = stars[2] venus.mass = units.kg(48.685e23) venus.radius = units.km(6051.8) venus.position = units.AU(array((7.174859394658725E-01, -9.118094489213757E-02, -4.286369239375957E-02))) venus.velocity = units.AUd(array((2.569149540621095E-03, 1.995467986481682E-02, 1.246915402703626E-04))) earth = stars[3] earth.mass = units.kg(5.9736e24) earth.radius = units.km(6371) earth.position = units.AU(array(( 4.152751345538410E-01, 8.988236789078493E-01, -4.821560120168533E-05))) earth.velocity = units.AUd(array(( -1.588315644843389E-02, 7.210443860976745E-03, -1.350251461569625E-07))) moon = stars[4] moon.mass = units.kg(7.35e22) moon.radius = units.km(1738) moon.position = units.AU(array(( 4.138191074397691E-01, 8.965602570292573E-01, -2.762446418149536E-04))) moon.velocity = units.AUd(array(( -1.541527312550390E-02, 6.894586206029982E-03, 1.223837010915995E-05))) mars = stars[5] mars.mass = units.kg(6.4185e23) mars.radius = units.km(3389.9) mars.position = units.AU(array(( -5.350147323170708E-01, -1.400272441929516E+00, -1.637545552747233E-02))) mars.velocity = units.AUd(array(( 1.360625065710822E-02, -3.765876077406818E-03, -4.130340644254660E-04))) jupiter = stars[6] jupiter.mass = units.kg(1898.13e24) jupiter.radius = units.km(71492) jupiter.position = units.AU(array(( 2.503092399973117E+00, -4.468134118102924E+00, -3.752173268244928E-02))) jupiter.velocity = units.AUd(array(( 6.490840561446090E-03, 4.046895067472646E-03, -1.620422227298534E-04))) saturn = stars[7] saturn.mass = units.kg(5.68319e26 ) saturn.radius = units.km(58232) saturn.position = units.AU(array(( -9.023156820924056E+00, 2.468810475231705E+00, 3.161126539154331E-01))) saturn.velocity = units.AUd(array(( -1.769097295887704E-03, -5.393257979873611E-03, 1.639859191780030E-04 ))) dist = earth.position - moon.position print "distance vector"+str(dist) print "distance %s\n" % (dot(dist,dist)**0.5).as_quantity_in(units.m)#(dist*dist).sum()**0.5 velo = moon.velocity-earth.velocity print "orb velocity %s\n" % (dot(velo,velo)**0.5).as_quantity_in(units.m/units.s) return stars