Exemple #1
0
def planetplot():
    sun, planets = new_solar_system_for_mercury()
    timerange = units.day(numpy.arange(0, 120 * 365.25, 12))

    instance = MercuryWayWard()
    instance.initialize_code()
    instance.central_particle.add_particles(sun)
    instance.orbiters.add_particles(planets)
    instance.commit_particles()

    channels = instance.orbiters.new_channel_to(planets)

    for time in timerange:
        err = instance.evolve_model(time)
        channels.copy()
        planets.savepoint(time)

    instance.stop()

    for planet in planets:
        t, x = planet.get_timeline_of_attribute_as_vector("x")
        t, y = planet.get_timeline_of_attribute_as_vector("y")
        plot(x, y,'.')

    native_plot.show()
Exemple #2
0
def planetplot():
    sun, planets = new_solar_system_for_mercury()
    timerange = units.day(numpy.arange(0, 120 * 365.25, 12))

    instance = MercuryWayWard()
    instance.initialize_code()
    instance.central_particle.add_particles(sun)
    instance.orbiters.add_particles(planets)
    instance.commit_particles()

    channels = instance.orbiters.new_channel_to(planets)

    for time in timerange:
        err = instance.evolve_model(time)
        channels.copy()
        planets.savepoint(time)

    instance.stop()

    for planet in planets:
        t, x = planet.get_timeline_of_attribute_as_vector("x")
        t, y = planet.get_timeline_of_attribute_as_vector("y")
        plot(x, y, '.')

    native_plot.show()
Exemple #3
0
def plottillagb():
    sse = SSEWithMassEvolve()
    sse.commit_parameters()
    sun, planets = Solarsystem.new_solarsystem()
    sse.particles.add_particles(sun)
    sse.commit_particles()
    channel = sse.particles.new_channel_to(sun)
    channel.copy()

    massrange = units.MSun(numpy.arange(1, 0.8, -0.001))
    print massrange
    masses = [] | units.MSun

    timerange = [] | units.Myr

    for mass in massrange:
        #sse.evolve_model(time)
        sse.evolve_mass(mass)
        timerange.append(sse.evolve_mass(mass))
        channel.copy()
        masses.append(sse.particles[0].mass)
        #print time.value_in(units.yr), sse.particles[0].mass.value_in(units.MSun)

    sse.stop()
    plot(massrange, timerange, '.')
    native_plot.show()
def planetplot():
    sun, planets = new_solar_system_for_mercury()

    initial = 12.2138 | units.Gyr
    final = 12.3300 | units.Gyr
    step = 10000.0 | units.yr

    timerange = VectorQuantity.arange(initial, final, step)
    gd = MercuryWayWard()
    gd.initialize_code()
    #gd.stopping_conditions.timeout_detection.disable()
    gd.central_particle.add_particles(sun)
    gd.orbiters.add_particles(planets)
    gd.commit_particles()

    se = SSE()
    #se.initialize_code()
    se.commit_parameters()
    se.particles.add_particles(sun)
    se.commit_particles()
    channelp = gd.orbiters.new_channel_to(planets)
    channels = se.particles.new_channel_to(sun)

    for time in timerange:
        err = gd.evolve_model(time - initial)
        channelp.copy()
        #planets.savepoint(time)
        err = se.evolve_model(time)
        channels.copy()
        gd.central_particle.mass = sun.mass
        print sun[0].mass.value_in(units.MSun), time.value_in(
            units.Myr), planets[4].x.value_in(units.AU), planets[4].y.value_in(
                units.AU), planets[4].z.value_in(units.AU)

    gd.stop()
    se.stop()

    for planet in planets:
        t, x = planet.get_timeline_of_attribute_as_vector("x")
        t, y = planet.get_timeline_of_attribute_as_vector("y")
        plot(x, y, '.')
        native_plot.gca().set_aspect('equal')

    native_plot.show()
Exemple #5
0
def planetplot():
    sun, planets = new_solar_system_for_mercury()

    initial = 12.2138 | units.Gyr
    final  =  12.3300 | units.Gyr
    step = 10000.0 | units.yr

    timerange = VectorQuantity.arange(initial, final, step)
    gd = MercuryWayWard()
    gd.initialize_code()
    #gd.stopping_conditions.timeout_detection.disable()
    gd.central_particle.add_particles(sun)
    gd.orbiters.add_particles(planets)
    gd.commit_particles()
    
    se = SSE()
    #se.initialize_code()
    se.commit_parameters()
    se.particles.add_particles(sun)
    se.commit_particles()
    channelp = gd.orbiters.new_channel_to(planets)
    channels = se.particles.new_channel_to(sun)

    for time in timerange:
        err = gd.evolve_model(time-initial)
        channelp.copy()
        #planets.savepoint(time)
        err = se.evolve_model(time)
        channels.copy()
        gd.central_particle.mass = sun.mass
        print sun[0].mass.value_in(units.MSun), time.value_in(units.Myr), planets[4].x.value_in(units.AU),  planets[4].y.value_in(units.AU),planets[4].z.value_in(units.AU)

    gd.stop()
    se.stop()

    for planet in planets:
        t, x = planet.get_timeline_of_attribute_as_vector("x")
        t, y = planet.get_timeline_of_attribute_as_vector("y")
        plot(x, y,'.')
        native_plot.gca().set_aspect('equal')

    native_plot.show()
Exemple #6
0
def testsse():
    sse = SSEWithMassEvolve()
    sse.commit_parameters()
    sun, planets = new_solar_system_for_mercury()
    sse.particles.add_particles(sun)
    sse.commit_particles()
    channel = sse.particles.new_channel_to(sun)
    channel.copy()

    massrange = units.MSun(numpy.arange(1, 0.8, -0.001))
    masses = [] | units.MSun
    timerange = [] | units.Myr

    for mass in massrange:
        sse.evolve_mass(mass)
        t, m = sse.evolve_mass(mass)
        timerange.append(t)
        channel.copy()
        masses.append(sse.particles[0].mass)

    sse.stop()
    plot(massrange, timerange, '.')
    native_plot.show()
Exemple #7
0
def testsse():
    sse = SSEWithMassEvolve()
    sse.commit_parameters()
    sun, planets = new_solar_system_for_mercury()
    sse.particles.add_particles(sun)
    sse.commit_particles()
    channel = sse.particles.new_channel_to(sun)
    channel.copy()
    
    massrange = units.MSun(numpy.arange(1, 0.8 ,-0.001))
    masses = []|units.MSun
    timerange = [] | units.Myr

    for mass in massrange:
        sse.evolve_mass(mass)
        t,m = sse.evolve_mass(mass)
        timerange.append(t)
        channel.copy()
        masses.append(sse.particles[0].mass)
        
    sse.stop()
    plot(massrange, timerange,'.')
    native_plot.show()
Exemple #8
0
    instance.commit_particles()

    channelp = instance.particles.new_channel_to(particles)
    
    start = 0 |units.yr
    end = 150 | units.yr
    step = 10|units.day

    timerange = VectorQuantity.arange(start, end, step)

    masses = []|units.MSun

    for i, time in enumerate(timerange):
        instance.evolve_model(time)
        channelp.copy()
        particles.savepoint(time)
        if (i % 220 == 0):
            instance.particles[0].mass = simulate_massloss(time)
        masses.append(instance.particles[0].mass)
 
    instance.stop()

    particle = particles[1]

    t, pos = particle.get_timeline_of_attribute_as_vector("position")
    distances = pos.lengths().as_quantity_in(units.AU)

    plot(timerange, distances , timerange, masses)

    native_plot.show()
Exemple #9
0
    instance.particles.add_particles(particles)

    channelp = instance.particles.new_channel_to(particles)
    
    start = 0 |units.yr
    end = 150 | units.yr
    step = 10|units.day

    timerange = VectorQuantity.arange(start, end, step)

    masses = []|units.MSun

    for i, time in enumerate(timerange):
        instance.evolve_model(time)
        channelp.copy()
        particles.savepoint(time)
        if (i % 220 == 0):
            instance.particles[0].mass = simulate_massloss(time)
        masses.append(instance.particles[0].mass)
 
    instance.stop()

    particle = particles[1]

    t, pos = particle.get_timeline_of_attribute_as_vector("position")
    distances = pos.lengths().as_quantity_in(units.AU)

    plot(timerange, distances , timerange, masses)

    native_plot.show()
"""
Creates a number of plots using the AMUSE unit aware plot functions.
"""
from amuse.lab import *
from amuse.plot import *
import numpy as np

if __name__ == "__main__":

    #latex_support()

    x = np.pi / 20.0 * (range(-10, 10) | units.m)
    y1 = units.MSun.new_quantity(np.sin(x.number))
    y2 = units.MSun.new_quantity(x.number)
    native_plot.subplot(2, 2, 1)
    plot(x, y2, label='model')
    scatter(x, y1, label='data')
    xlabel('x')
    ylabel('mass [$M_\odot$]')  #overrides auto unit!
    native_plot.legend(loc=2)

    x = range(50) | units.Myr
    y1 = quantities.new_quantity(np.sin(np.arange(0, 1.5, 0.03)),
                                 1e50 * units.erg)
    y2 = -(1e43 | units.J) - y1
    native_plot.subplot(2, 2, 2)
    plot(x, y1, label='$E_\mathrm{kin}$')
    plot(x, y2, label='$E_\mathrm{pot}$')
    xlabel('t')
    ylabel('E')
    native_plot.legend()
Exemple #11
0
"""
Creates a number of plots using the AMUSE unit aware plot functions.
"""
from amuse.lab import *
from amuse.plot import *
import numpy as np

if __name__ == "__main__":

    #latex_support()

    x = np.pi/20.0 * (range(-10,10) | units.m)
    y1 = units.MSun.new_quantity(np.sin(x.number))
    y2 = units.MSun.new_quantity(x.number)
    native_plot.subplot(2,2,1)
    plot(x, y2, label='model')
    scatter(x, y1, label='data')
    xlabel('x')
    ylabel('mass [$M_\odot$]')#overrides auto unit!
    native_plot.legend(loc=2)

    x = range(50) | units.Myr
    y1 = quantities.new_quantity(np.sin(np.arange(0,1.5,0.03)), 1e50*units.erg)
    y2 = -(1e43 | units.J) - y1
    native_plot.subplot(2,2,2)
    plot(x, y1, label='$E_\mathrm{kin}$')
    plot(x, y2, label='$E_\mathrm{pot}$')
    xlabel('t')
    ylabel('E')
    native_plot.legend()
Exemple #12
0
def plotdata(planets):
    for planet in planets:
        t, x = planet.get_timeline_of_attribute_as_vector("x")
        t, y = planet.get_timeline_of_attribute_as_vector("y")
        plot(x, y, '.')
    native_plot.show()