Beispiel #1
0
def plot_pressure_density_in_thermal_equilibrium(cooling_function,
                                                 heating_function,
                                                 figure_name):
    if not HAS_MATPLOTLIB:
        return
    points_per_decade = 100
    log_n_H = numpy.linspace(-2.0, 3.0, num=points_per_decade * 5 + 1)
    n_H = (units.cm**-3).new_quantity(10**log_n_H)

    logT_equi = numpy.array([
        log_equilibrium_temperature(dens,
                                    cooling_function,
                                    heating_function,
                                    logT_min=-1.0,
                                    logT_max=5.0) for dens in n_H
    ])
    T_equi = 10.0**logT_equi | units.K
    P = (n_H * T_equi).as_quantity_in(units.K * units.cm**-3)

    pyplot.figure(figsize=(12, 10))
    pyplot.gca().set_ylim([1.0e1, 1.0e6])
    loglog(n_H, P)
    xlabel('log($n_H$)')
    ylabel('log(P)')
    pyplot.savefig(figure_name)
    print "\nPlot of pressure vs. density in thermal equilibrium was saved to: ", figure_name
    pyplot.close()
Beispiel #2
0
def plot_tracks(temperatures_original, luminosities_original,
                temperatures_helium, luminosities_helium):

    x_label = "T [K]"
    y_label = "L [$L_\odot$]"
    figure = single_frame(x_label, y_label, logx=True, logy=True,
                          xsize=14, ysize=10)
    colors = get_distinct(2)
    
    loglog(temperatures_original, luminosities_original, label='progenitor',
           c=colors[0])
    loglog(temperatures_helium, luminosities_helium, label='helium star',
           c=colors[1])
    scatter(temperatures_helium[-1], luminosities_helium[-1], marker='*',
            s=400, c=colors[1])
    xlabel('Effective Temperature')
    ylabel('Luminosity')
    pyplot.xlim(1.0e5, 4000)
    pyplot.ylim(1.0,1.0e5)
    pyplot.legend(loc=4, fontsize=24)

    save_file = 'HertzsprungRussel_HeliumStar.png'
    pyplot.savefig(save_file)
    print '\nSaved figure in file', save_file,'\n'
    pyplot.show()
Beispiel #3
0
def plot_tracks(temperatures_original, luminosities_original,
                temperatures_helium, luminosities_helium):

    x_label = "T [K]"
    y_label = "L [$L_\odot$]"
    figure = single_frame(x_label, y_label, logx=True, logy=True,
                          xsize=14, ysize=10)
    colors = get_distinct(2)
    
    loglog(temperatures_original, luminosities_original, label='progenitor',
           c=colors[0])
    loglog(temperatures_helium, luminosities_helium, label='helium star',
           c=colors[1])
    scatter(temperatures_helium[-1], luminosities_helium[-1], marker='*',
            s=400, c=colors[1])
    xlabel('Effective Temperature')
    ylabel('Luminosity')
    pyplot.xlim(1.0e5, 4000)
    pyplot.ylim(1.0,1.0e5)
    pyplot.legend(loc=4, fontsize=24)

    save_file = 'HertzsprungRussel_HeliumStar.png'
    pyplot.savefig(save_file)
    print('\nSaved figure in file', save_file,'\n')
    pyplot.show()
Beispiel #4
0
def plot_track(temperature_at_time, luminosity_at_time):
    pyplot.figure(figsize=(8, 6))
    pyplot.title('Hertzsprung-Russell diagram', fontsize=12)

    loglog(temperature_at_time, luminosity_at_time)
    xlabel('Effective Temperature')
    ylabel('Luminosity')
    pyplot.xlim(pyplot.xlim()[::-1])
    pyplot.ylim(.1, 1.e4)
    pyplot.show()
Beispiel #5
0
def plot_track(temperature_at_time, luminosity_at_time):
    pyplot.figure(figsize=(8, 6))
    pyplot.title('Hertzsprung-Russell diagram', fontsize=12)

    loglog(temperature_at_time, luminosity_at_time)
    xlabel('Effective Temperature')
    ylabel('Luminosity')
    pyplot.xlim(pyplot.xlim()[::-1])
    pyplot.ylim(.1, 1.e4)
    pyplot.show()
Beispiel #6
0
def plot_tracks(temperature1, luminosity1, temperature2, luminosity2):
    from matplotlib import pyplot
    from amuse.plot import loglog, xlabel, ylabel
    pyplot.figure(figsize = (8, 6))
    pyplot.title('Hertzsprung-Russell diagram', fontsize=12)
    loglog(temperature1, luminosity1)
    loglog(temperature2, luminosity2)
    xlabel('Effective Temperature')
    ylabel('Luminosity')
    pyplot.xlim(pyplot.xlim()[::-1])
    pyplot.show()
Beispiel #7
0
def plot_tracks(temperatures_original, luminosities_original, temperatures_helium, luminosities_helium):
    pyplot.figure(figsize = (8, 6))
    pyplot.title('Hertzsprung-Russell diagram', fontsize=12)
    
    loglog(temperatures_original, luminosities_original, label='progenitor')
    loglog(temperatures_helium, luminosities_helium, label='helium star')
    xlabel('Effective Temperature')
    ylabel('Luminosity')
    pyplot.xlim(pyplot.xlim()[::-1])
    pyplot.ylim(1.0,1.0e5)
    pyplot.legend(loc=3)
    pyplot.show()
def plot_tracks(temperatures_original, luminosities_original, temperatures_helium, luminosities_helium):
    pyplot.figure(figsize = (8, 6))
    pyplot.title('Hertzsprung-Russell diagram', fontsize=12)

    loglog(temperatures_original, luminosities_original, label='progenitor')
    loglog(temperatures_helium, luminosities_helium, label='helium star')
    xlabel('Effective Temperature')
    ylabel('Luminosity')
    pyplot.xlim(pyplot.xlim()[::-1])
    pyplot.ylim(1.0,1.0e5)
    pyplot.legend(loc=3)
    pyplot.show()
Beispiel #9
0
def plot_cooling_function(cooling_function, figure_name):
    points_per_decade = 20
    logT = numpy.linspace(1.0, 8.0, num=points_per_decade * 7 + 1)
    T = units.K.new_quantity(10**logT)

    pyplot.figure(figsize=(12, 10))
    pyplot.gca().set_ylim([1.0e-28, 1.0e-21])
    loglog(T, cooling_function(T))
    xlabel('log(T)')
    ylabel('log($\Lambda$)')
    pyplot.savefig(figure_name)
    print "\nPlot of cooling function was saved to: ", figure_name
    pyplot.close()
Beispiel #10
0
def monitor_density_profile(system, i_step, time, n_steps, memory=Memory()):
    if i_step == 0:
        memory.xlimits = (None, None)
        memory.ylimits = (None, None)
    position = system.gas_particles.position - system.gas_particles.center_of_mass()
    loglog(position.lengths_squared(), system.gas_particles.density, 'gs')
    native_plot.title("{0}: t={1}".format(i_step, time.as_quantity_in(units.yr)))
    native_plot.xlim(memory.xlimits)
    native_plot.ylim(memory.ylimits)
    native_plot.pause(0.0001)
    memory.xlimits = native_plot.gca().get_xlim()
    memory.ylimits = native_plot.gca().get_ylim()
    if i_step == n_steps-1:
        native_plot.show(block=True)
    native_plot.cla()
Beispiel #11
0
 def slowtest1(self):
     stellar_evolution = self.new_instance(MESA)
     stellar_evolution.particles.add_particles(Particles(2, mass=[1.0, 5.0]|units.MSun))
     stellar_evolution.evolve_model(10.0 | units.Myr)
     initial_separation = stellar_evolution.particles.radius.sum()
     
     sph_particles_1 = convert_stellar_model_to_SPH(
         stellar_evolution.particles[0], 
         200, 
         seed=12345
     ).gas_particles
     sph_particles_2 = convert_stellar_model_to_SPH(
         stellar_evolution.particles[1], 
         1000, 
         seed=12345
     ).gas_particles
     stellar_evolution.stop()
     
     initial_speed = 10.0 | units.km / units.s
     sph_particles_2.x  += initial_separation
     sph_particles_1.vx += initial_speed
     all_sph_particles = ParticlesSuperset([sph_particles_1, sph_particles_2])
     all_sph_particles.move_to_center()
     
     t_end = 4.0e3 | units.s
     print "Evolving to:", t_end
     n_steps = 4
     
     unit_system_converter = ConvertBetweenGenericAndSiUnits(1.0 | units.RSun, 1.0 | units.MSun, t_end)
     hydro_code = Gadget2(unit_system_converter)
     hydro_code.gas_particles.add_particles(all_sph_particles)
     
     pyplot.ion()
     for time in [i*t_end/n_steps for i in range(1, n_steps+1)]:
         hydro_code.evolve_model(time)
         pyplot.close('all')
         pyplot.figure()
         pynbody_column_density_plot(hydro_code.gas_particles, width=10|units.RSun)
         pyplot.draw()
         pyplot.figure()
         loglog(hydro_code.gas_particles.position.lengths_squared(), hydro_code.gas_particles.pressure, 'bo')
         pyplot.draw()
     
     hydro_code.stop()
     sleep(3)
     pyplot.ioff()
Beispiel #12
0
def monitor_density_profile(system, i_step, time, n_steps, memory=Memory()):
    if i_step == 0:
        memory.xlimits = (None, None)
        memory.ylimits = (None, None)
    position = system.gas_particles.position - system.gas_particles.center_of_mass(
    )
    loglog(position.lengths_squared(), system.gas_particles.density, 'gs')
    native_plot.title("{0}: t={1}".format(i_step,
                                          time.as_quantity_in(units.yr)))
    native_plot.xlim(memory.xlimits)
    native_plot.ylim(memory.ylimits)
    native_plot.pause(0.0001)
    memory.xlimits = native_plot.gca().get_xlim()
    memory.ylimits = native_plot.gca().get_ylim()
    if i_step == n_steps - 1:
        native_plot.show(block=True)
    native_plot.cla()
    def slowtest1(self):
        stellar_evolution = self.new_instance(MESA)
        stellar_evolution.particles.add_particles(
            Particles(2, mass=[1.0, 5.0] | units.MSun))
        stellar_evolution.evolve_model(10.0 | units.Myr)
        initial_separation = stellar_evolution.particles.radius.sum()

        sph_particles_1 = convert_stellar_model_to_SPH(
            stellar_evolution.particles[0], 200, seed=12345).gas_particles
        sph_particles_2 = convert_stellar_model_to_SPH(
            stellar_evolution.particles[1], 1000, seed=12345).gas_particles
        stellar_evolution.stop()

        initial_speed = 10.0 | units.km / units.s
        sph_particles_2.x += initial_separation
        sph_particles_1.vx += initial_speed
        all_sph_particles = ParticlesSuperset(
            [sph_particles_1, sph_particles_2])
        all_sph_particles.move_to_center()

        t_end = 4.0e3 | units.s
        print "Evolving to:", t_end
        n_steps = 4

        unit_system_converter = ConvertBetweenGenericAndSiUnits(
            1.0 | units.RSun, 1.0 | units.MSun, t_end)
        hydro_code = Gadget2(unit_system_converter)
        hydro_code.gas_particles.add_particles(all_sph_particles)

        pyplot.ion()
        for time in [i * t_end / n_steps for i in range(1, n_steps + 1)]:
            hydro_code.evolve_model(time)
            pyplot.close('all')
            pyplot.figure()
            pynbody_column_density_plot(hydro_code.gas_particles,
                                        width=10 | units.RSun)
            pyplot.draw()
            pyplot.figure()
            loglog(hydro_code.gas_particles.position.lengths_squared(),
                   hydro_code.gas_particles.pressure, 'bo')
            pyplot.draw()

        hydro_code.stop()
        sleep(3)
        pyplot.ioff()
Beispiel #14
0
def plot_cooling_vs_heating_n(n_H, cooling_function, heating_function,
                              figure_name):
    if not HAS_MATPLOTLIB:
        return
    points_per_decade = 20
    logT = numpy.linspace(1.0, 8.0, num=points_per_decade * 7 + 1)
    T = units.K.new_quantity(10**logT)
    cool = cooling_function(T)
    heat = heating_function() * numpy.ones_like(logT)

    pyplot.figure(figsize=(12, 10))
    loglog(T, heat, label="$\Gamma$")
    loglog(T, n_H * cool, label="$n_H \Lambda$")
    xlabel('log(T)')
    ylabel('log($n_H \Lambda$), log($\Gamma$)')
    pyplot.legend(loc=4)
    pyplot.savefig(figure_name)
    print "\nPlot of cooling/heating at constant density was saved to: ", figure_name
    pyplot.close()