コード例 #1
0
ファイル: shitty.py プロジェクト: foobarmontoya/Shitty
sun = vparticle(m_sun, [0., 0., 0.], [0., 0., 0.], 50. * r_sun, color.yellow)
earth = vparticle(m_earth, [AU, 0., 0.], [0., v_earth, 0.], r_sun, color.blue)
mercury = vparticle(m_mercury, [d_mercury, 0., 0.], [0., v_mercury, 0.], .382 * r_sun, color.red)
venus = vparticle(m_venus, [d_venus, 0., 0.], [0., v_venus, 0.], .949 * r_sun, color.orange)
mars = vparticle(m_mars, [d_mars, 0., 0.], [0., v_mars, 0.], .532 * r_sun, color.red)
jupiter = vparticle(m_jupiter, [d_jupiter, 0., 0.], [0., v_jupiter, 0.], 11.19 * r_sun, color.orange)
saturn = vparticle(m_saturn, [d_saturn, 0., 0.], [0., v_saturn, 0.], 9.26 * r_sun, color.yellow)
uranus = vparticle(m_uranus, [d_uranus, 0., 0.], [0., v_uranus, 0.], 4.01 * r_sun, color.green)
neptune = vparticle(m_neptune, [d_neptune, 0., 0.], [0., v_neptune, 0.], 3.88 * r_sun, color.blue)

# Setup the camera
scene.range = 1.5 * AU
scene.forward = (AU, -.3 * AU, -.5 * AU)

# Can't see it anyway 
# moon = vparticle(m_moon, [AU + d_moon, 0., 0.], [0., v_earth + v_moon, 0.], 10. * r_moon, color.white)

shitty = nbody_gravity(1000)
shitty.time_step = 43200 # .5 Day
shitty.add_particle(sun)
shitty.add_particle(earth)
shitty.add_particle(mercury)
shitty.add_particle(venus)
shitty.add_particle(mars)
shitty.add_particle(jupiter)
shitty.add_particle(saturn)
shitty.add_particle(uranus)
shitty.add_particle(neptune)
shitty.go()
コード例 #2
0
ファイル: cold_collapse.py プロジェクト: foobarmontoya/Shitty
# Simulation parameters
num_stars = 5e2
star_mass = m_sun
# Draw each star as a curve so we don't have to waste so much time on lighting tiny spheres
star_radius = 0.
cluster_radius = 100 * pc
random.seed(12345)

scene.range = 1.5 * cluster_radius
cluster_mass = num_stars * star_mass
cluster_density = cluster_mass / (4. / 3. * pi * cluster_radius**3)
# Crossing time of the cluster when it's virialized (roughly).
cluster_timescale = cluster_radius**1.5 / sqrt(constants.G * cluster_mass)

# 1000 timesteps, 1 parsec of softening distance
cold_collapse = nbody_gravity(100, pc)
cold_collapse.time_step = (.01 * cluster_timescale)

# Populate our box with stars
total_mass = 0.0
while(total_mass < cluster_mass):
    if( random.random() * star_mass / pc**3 < cluster_density ):
        total_mass += star_mass
        # distribute the particles in a sphere of radius rand_radius
        rand_radius = cluster_radius * random.random()
        rand_phi = 2. * pi * random.random()
        rand_theta = pi * random.random()
        rand_position = rand_radius * array([sin(rand_theta) * cos(rand_phi), sin(rand_theta) * sin(rand_phi), cos(rand_theta)])
        rand_star = vparticle(star_mass, rand_position, [0., 0., 0.], star_radius, color.white)
        # Add the star to the simulation
        cold_collapse.add_particle(rand_star)