示例#1
0
    def slowtest5(self):
        print "Test convert_SPH_to_stellar_model result in EVtwin"
        stellar_evolution = EVtwin()
        stellar_evolution.parameters.verbosity = True
        stellar_evolution.particles.add_particle(
            Particle(mass=1.0 | units.MSun))  # reference particle
        stellar_evolution.evolve_model(100.0 | units.Myr)

        model = convert_SPH_to_stellar_model(
            self.new_particles())  # model is from center to surface
        stellar_evolution.new_particle_from_model(model, 0.0 | units.Myr)
        print stellar_evolution.particles
        self.assertAlmostEqual(stellar_evolution.particles.age,
                               [100.0, 0.0] | units.Myr, 1)
        stellar_evolution.evolve_model(200.0 | units.Myr)
        print stellar_evolution.particles
        self.assertAlmostEqual(stellar_evolution.particles.age,
                               [200.0, 100.0] | units.Myr, 1)
        self.assertAlmostRelativeEqual(
            stellar_evolution.particles[0].temperature,
            stellar_evolution.particles[1].temperature, 2)
        self.assertAlmostRelativeEqual(
            stellar_evolution.particles[0].luminosity,
            stellar_evolution.particles[1].luminosity, 2)
        stellar_evolution.stop()
示例#2
0
    def test11(self):
        print "Test for importing new stellar models"
        instance = EVtwin()
#~        instance.parameters.import_model_entropy_force = 1.0
#~        instance.parameters.import_model_entropy_accuracy = 1.0e-1
        instance.parameters.verbosity = True
        instance.particles.add_particles(Particles(mass = [0.8] | units.MSun))
        instance.evolve_model()

        instance.new_particle_from_model(instance.particles[0].get_internal_structure())
        # The above line is equivalent with:
        #copy = Particles(1)
        #copy.internal_structure = instance.particles[0].get_internal_structure()
        #instance.particles.add_particles(copy)

        number_of_zones = instance.particles[0].get_number_of_zones()
        self.assertEqual(len(instance.particles), 2)
        self.assertEqual(instance.particles[1].get_number_of_zones(), number_of_zones)
        self.assertIsOfOrder(instance.particles[1].get_radius_profile()[-1],          1.0 | units.RSun)
        self.assertIsOfOrder(instance.particles[1].get_temperature_profile()[0],  1.0e7 | units.K)
        self.assertIsOfOrder(instance.particles[1].get_pressure_profile()[0],      1.0e17 | units.barye)

        instance.evolve_model(keep_synchronous = False)
        self.assertAlmostRelativeEqual(
            instance.particles[0].temperature, instance.particles[1].temperature, 2)
        self.assertAlmostRelativeEqual(
            instance.particles[0].luminosity, instance.particles[1].luminosity, 2)
        instance.stop()
示例#3
0
 def slowtest5(self):
     print "Test convert_SPH_to_stellar_model result in EVtwin"
     stellar_evolution = EVtwin()
     stellar_evolution.parameters.verbosity = True
     stellar_evolution.particles.add_particle(Particle(mass=1.0|units.MSun)) # reference particle
     stellar_evolution.evolve_model(100.0|units.Myr)
     
     model = convert_SPH_to_stellar_model(self.new_particles()) # model is from center to surface
     stellar_evolution.new_particle_from_model(model, 0.0|units.Myr)
     print stellar_evolution.particles
     self.assertAlmostEqual(stellar_evolution.particles.age, [100.0, 0.0] | units.Myr, 1)
     stellar_evolution.evolve_model(200.0|units.Myr)
     print stellar_evolution.particles
     self.assertAlmostEqual(stellar_evolution.particles.age, [200.0, 100.0] | units.Myr, 1)
     self.assertAlmostRelativeEqual(stellar_evolution.particles[0].temperature, 
         stellar_evolution.particles[1].temperature, 2)
     self.assertAlmostRelativeEqual(stellar_evolution.particles[0].luminosity, 
         stellar_evolution.particles[1].luminosity, 2)
     stellar_evolution.stop()
示例#4
0
    def xslowtest11(self):
        print "Test 11: Continue the stellar evolution of a 'merger product' - WIP"
        instance = EVtwin()
        instance.initialize_code()
        instance.commit_parameters()

        instance.parameters.min_timestep_stop_condition = 1.0 | units.s

        stars = Particles(3)
        stars.mass = [1.0, 2.0, 1.0] | units.MSun
        instance.particles.add_particles(stars)
        instance.commit_particles()
        instance.evolve_model(1.0 | units.Myr)
        stellar_models = instance.native_stars.get_internal_structure()

        self.assertEqual(len(stellar_models), 3)
        self.assertEqual(len(stellar_models[0]), 199)
        self.assertEqual(len(stellar_models[1]), 199)
        self.assertAlmostEqual(stellar_models[0].mass[198], 1.0 | units.MSun, 2)
        self.assertAlmostEqual(stellar_models[1].mass[198], 2.0 | units.MSun, 2)
        self.assertAlmostEqual(stellar_models[0].mass[0], 0.0 | units.MSun, 2)

        instance.new_particle_from_model(stellar_models[0], instance.particles[0].age)
        self.assertEqual(len(instance.particles), 4)
        self.assertEqual(len(instance.imported_stars), 1)
        imported_stellar_model = instance.imported_stars[0].get_internal_structure()
        self.assertEqual(len(imported_stellar_model), 199)
        self.assertAlmostEqual(imported_stellar_model.mass[198], 1.0 | units.MSun, 2)
        self.assertAlmostEqual(imported_stellar_model.mass[0], 0.0 | units.MSun, 2)
        self.assertAlmostRelativeEqual(imported_stellar_model.X_H, stellar_models[0].X_H, 5)
        self.assertAlmostRelativeEqual(imported_stellar_model.X_He, stellar_models[0].X_He, 5)
        self.assertAlmostRelativeEqual(imported_stellar_model.mass, stellar_models[0].mass, 2)
        self.assertAlmostRelativeEqual(imported_stellar_model.radius[1:], stellar_models[0].radius[1:], 2)
#        instance.evolve_model(2.0 | units.Myr)
        print instance.particles
        instance.stop()
        del instance