本文整理汇总了Python中amuse.community.sse.interface.SSE.evolve_model方法的典型用法代码示例。如果您正苦于以下问题:Python SSE.evolve_model方法的具体用法?Python SSE.evolve_model怎么用?Python SSE.evolve_model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类amuse.community.sse.interface.SSE
的用法示例。
在下文中一共展示了SSE.evolve_model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test19
# 需要导入模块: from amuse.community.sse.interface import SSE [as 别名]
# 或者: from amuse.community.sse.interface.SSE import evolve_model [as 别名]
def test19(self):
print "SSE core_mass and CO_core_mass (high mass star)"
instance = SSE()
star = instance.particles.add_particle(Particle(mass = 30 | units.MSun))
instance.evolve_model(5.8 | units.Myr)
print star.mass, star.core_mass, star.CO_core_mass, star.stellar_type
self.assertEqual(str(star.stellar_type), "Main Sequence star")
self.assertIsOfOrder(star.mass, 30 | units.MSun)
self.assertEqual(star.core_mass, 0 | units.MSun)
self.assertEqual(star.CO_core_mass, 0 | units.MSun)
instance.evolve_model(6.0 | units.Myr)
print star.mass, star.core_mass, star.CO_core_mass, star.stellar_type
self.assertEqual(str(star.stellar_type), "Core Helium Burning")
self.assertIsOfOrder(star.mass, 30 | units.MSun)
self.assertIsOfOrder(star.core_mass, 10 | units.MSun)
self.assertEqual(star.CO_core_mass, 0 | units.MSun)
instance.evolve_model(6.5 | units.Myr)
print star.mass, star.core_mass, star.CO_core_mass, star.stellar_type
self.assertEqual(str(star.stellar_type), "Main Sequence Naked Helium star")
self.assertIsOfOrder(star.mass, 10 | units.MSun)
self.assertEqual(star.core_mass, star.mass)
self.assertEqual(star.CO_core_mass, 0 | units.MSun)
instance.evolve_model(6.65 | units.Myr)
print star.mass, star.core_mass, star.CO_core_mass, star.stellar_type
self.assertEqual(str(star.stellar_type), "Hertzsprung Gap Naked Helium star")
self.assertIsOfOrder(star.mass, 10 | units.MSun)
self.assertEqual(star.core_mass, star.mass)
self.assertAlmostEqual(star.CO_core_mass, 7.12 | units.MSun, 2)
instance.evolve_model(7.0 | units.Myr)
print star.mass, star.core_mass, star.CO_core_mass, star.stellar_type
self.assertEqual(str(star.stellar_type), "Black Hole")
self.assertIsOfOrder(star.mass, 10 | units.MSun)
self.assertEqual(star.core_mass, star.mass)
self.assertEqual(star.CO_core_mass, star.mass)
instance.stop()
示例2: plottillagb
# 需要导入模块: from amuse.community.sse.interface import SSE [as 别名]
# 或者: from amuse.community.sse.interface.SSE import evolve_model [as 别名]
def plottillagb():
sun = datamodel.Particle(
mass=1 | units.MSun,
radius=1 | units.RSun
)
sse = SSE()
sse.particles.add_particle(sun)
channel_from_se_to_memory = sse.particles.new_channel_to(sun.as_set())
channel_from_se_to_memory.copy()
masses = [] | units.MSun
timerange = numpy.arange(11500, 13500, 10) | units.Myr
for time in timerange:
sse.evolve_model(time)
channel_from_se_to_memory.copy()
masses.append(sun.mass)
print(time.as_quantity_in(units.Myr),
sun.mass.as_quantity_in(units.MSun))
sse.stop()
figure = pyplot.figure(figsize=(6, 6))
subplot = figure.add_subplot(1, 1, 1)
subplot.plot(timerange.value_in(units.Gyr),
masses.value_in(units.MSun), '.')
subplot.set_xlabel('t (Gyr)')
subplot.set_ylabel('mass (MSun)')
pyplot.show()
示例3: simulate_evolution_tracks
# 需要导入模块: from amuse.community.sse.interface import SSE [as 别名]
# 或者: from amuse.community.sse.interface.SSE import evolve_model [as 别名]
def simulate_evolution_tracks():
stellar_evolution = SSE()
star = datamodel.Particle()
star.mass = stellar_mass
star = stellar_evolution.particles.add_particle(star)
luminosity_at_time = [] | units.LSun
temperature_at_time = [] | units.K
print("Evolving a star with mass:", stellar_mass)
is_evolving = True
while is_evolving and star.age < end_time:
luminosity_at_time.append(star.luminosity)
temperature_at_time.append(star.temperature)
previous_age = star.age
# if we do not specify an end_time in the evolve_model function
# a stellar evolution code will evolve to the next
# 'natural' timestep, this will ensure all interesting physics
# is seen in the hr diagram
stellar_evolution.evolve_model()
is_evolving = (star.age != previous_age)
stellar_evolution.stop()
return temperature_at_time, luminosity_at_time
示例4: test6
# 需要导入模块: from amuse.community.sse.interface import SSE [as 别名]
# 或者: from amuse.community.sse.interface.SSE import evolve_model [as 别名]
def test6(self):
print "Test whether a set of stars evolves synchronously..."
# Create an array of stars with a range in stellar mass
masses = [.5, 1., 2., 5., 10., 30.] | units.MSun
number_of_stars = len(masses)
stars = Particles(number_of_stars)
stars.mass = masses
# Initialize stellar evolution code
instance = SSE()
instance.commit_parameters()
instance.particles.add_particles(stars)
instance.commit_particles()
from_code_to_model = instance.particles.new_channel_to(stars)
from_code_to_model.copy()
instance.evolve_model(end_time = 125 | units.Myr)
from_code_to_model.copy()
end_types = (
"deeply or fully convective low mass MS star",
"Main Sequence star",
"Main Sequence star",
"Carbon/Oxygen White Dwarf",
"Neutron Star",
"Black Hole",
)
for i in range(number_of_stars):
self.assertAlmostEquals(stars[i].age, 125.0 | units.Myr)
self.assertTrue(stars[i].mass <= masses[i])
self.assertEquals(str(stars[i].stellar_type), end_types[i])
instance.stop()
示例5: test5
# 需要导入模块: from amuse.community.sse.interface import SSE [as 别名]
# 或者: from amuse.community.sse.interface.SSE import evolve_model [as 别名]
def test5(self):
sse = SSE()
sse.commit_parameters()
stars = Particles(1)
star = stars[0]
star.mass = 35 | units.MSun
star.radius = 0.0 | units.RSun
stars.synchronize_to(sse.particles)
channel = sse.particles.new_channel_to(stars)
channel.copy_attributes(sse.particles.get_attribute_names_defined_in_store())
previous_type = star.stellar_type
results = []
dt = 1 | units.Myr
t = 0 | units.Myr
while t < 30 | units.Myr:
t += dt
sse.evolve_model(t)
self.assertTrue(sse.particles[0].mass.value_in(units.MSun) < 10.6)
sse.stop()
示例6: test21
# 需要导入模块: from amuse.community.sse.interface import SSE [as 别名]
# 或者: from amuse.community.sse.interface.SSE import evolve_model [as 别名]
def test21(self):
instance = SSE()
stars = instance.particles.add_particles(Particles(mass = 30 | units.MSun))
mass_loss_wind = stars[0].mass_loss_wind
self.assertAlmostRelativeEquals(mass_loss_wind, 1.703e-07 | units.MSun / units.yr, 3)
instance.evolve_model(1 | units.Myr)
dm = (1 | units.Myr)* mass_loss_wind
self.assertAlmostRelativeEquals(stars[0].mass, (30 | units.MSun) - dm , 3)
self.assertAlmostRelativeEquals(stars[0].mass_loss_wind, 2.053e-07 | units.MSun / units.yr, 3)
instance.stop()
示例7: test22
# 需要导入模块: from amuse.community.sse.interface import SSE [as 别名]
# 或者: from amuse.community.sse.interface.SSE import evolve_model [as 别名]
def test22(self):
instance = SSE()
stars = instance.particles.add_particles(Particles(mass = [1.0, 10.0] | units.MSun))
gyration_radius = stars.gyration_radius
self.assertTrue(numpy.all(0.0 < gyration_radius))
self.assertTrue(numpy.all(gyration_radius < 1.0))
instance.evolve_model(12.4 | units.Gyr)
self.assertTrue(stars[0].gyration_radius < gyration_radius[0])
self.assertTrue(stars[1].gyration_radius > gyration_radius[1])
instance.evolve_model(14 | units.Gyr)
self.assertTrue(numpy.all(stars.gyration_radius > gyration_radius))
instance.stop()
示例8: stellar_lifetime
# 需要导入模块: from amuse.community.sse.interface import SSE [as 别名]
# 或者: from amuse.community.sse.interface.SSE import evolve_model [as 别名]
def stellar_lifetime(mZAMS, z=0.02):
global se
if se is None:
se = SSE()
se.parameters.metallicity = z
se.particles.add_particle(Particle(mass=mZAMS))
while not stellar_remnant_state(se.particles[0]):
se.evolve_model()
t_end = se.particles[0].age
# tpe = se.particles[0].stellar_type
se.particles.remove_particle(se.particles[0])
return t_end
示例9: test12
# 需要导入模块: from amuse.community.sse.interface import SSE [as 别名]
# 或者: from amuse.community.sse.interface.SSE import evolve_model [as 别名]
def test12(self):
print "Testing adding and removing particles from stellar evolution code..."
particles = Particles(3)
particles.mass = 1.0 | units.MSun
instance = SSE()
instance.initialize_code()
instance.commit_parameters()
self.assertEquals(len(instance.particles), 0) # before creation
instance.particles.add_particles(particles[:-1])
instance.commit_particles()
instance.evolve_model(1.0 | units.Myr)
self.assertEquals(len(instance.particles), 2) # before remove
self.assertAlmostEqual(instance.particles.age, 1.0 | units.Myr)
instance.particles.remove_particle(particles[0])
self.assertEquals(len(instance.particles), 1)
instance.evolve_model(2.0 | units.Myr)
self.assertAlmostEqual(instance.particles[0].age, 2.0 | units.Myr)
instance.particles.add_particles(particles[::2])
self.assertEquals(len(instance.particles), 3) # it's back...
self.assertAlmostEqual(instance.particles[0].age, 2.0 | units.Myr)
self.assertAlmostEqual(instance.particles[1].age, 0.0 | units.Myr)
self.assertAlmostEqual(instance.particles[2].age, 0.0 | units.Myr) # ... and rejuvenated.
instance.evolve_model(3.0 | units.Myr) # The young stars keep their age offset from the old star
self.assertAlmostEqual(instance.particles.age, [3.0, 1.0, 1.0] | units.Myr)
instance.evolve_model(4.0 | units.Myr)
self.assertAlmostEqual(instance.particles.age, [4.0, 2.0, 2.0] | units.Myr)
instance.stop()
示例10: test20
# 需要导入模块: from amuse.community.sse.interface import SSE [as 别名]
# 或者: from amuse.community.sse.interface.SSE import evolve_model [as 别名]
def test20(self):
print "SSE core_mass and CO_core_mass (low mass stars)"
instance = SSE()
stars = instance.particles.add_particles(Particles(mass = [0.6, 1.0] | units.MSun))
instance.evolve_model(100 | units.Gyr)
self.assertEqual(str(stars[0].stellar_type), "Helium White Dwarf")
self.assertAlmostEqual(stars[0].mass, 0.405 | units.MSun, 2)
self.assertEqual(stars[0].core_mass, stars[0].mass)
self.assertEqual(stars[0].CO_core_mass, 0 | units.MSun)
self.assertEqual(str(stars[1].stellar_type), "Carbon/Oxygen White Dwarf")
self.assertAlmostEqual(stars[1].mass, 0.520 | units.MSun, 2)
self.assertEqual(stars[1].core_mass, stars[1].mass)
self.assertEqual(stars[1].CO_core_mass, stars[1].mass)
instance.stop()
示例11: test2
# 需要导入模块: from amuse.community.sse.interface import SSE [as 别名]
# 或者: from amuse.community.sse.interface.SSE import evolve_model [as 别名]
def test2(self):
sse = SSE()
sse.commit_parameters()
stars = Particles(1)
star = stars[0]
star.mass = 5 | units.MSun
star.radius = 0.0 | units.RSun
sse.particles.add_particles(stars)
sse.evolve_model(120.1 | units.Myr)
self.assertAlmostEqual(sse.particles[0].mass.value_in(units.MSun), 4.932, 3)
self.assertAlmostEqual(sse.particles[0].temperature.value_in(units.K), 4221., 0)
sse.stop()
示例12: test7
# 需要导入模块: from amuse.community.sse.interface import SSE [as 别名]
# 或者: from amuse.community.sse.interface.SSE import evolve_model [as 别名]
def test7(self):
print "Test: evolve particles one at a time."
print "Used to be problematic, since initial_mass of idle particle is set to zero."
stars = Particles(2)
stars.mass = 1.0 | units.MSun
for star in stars:
print star
stellar_evolution = SSE()
stellar_evolution.commit_parameters()
stellar_evolution.particles.add_particles(star.as_set())
stellar_evolution.commit_particles()
from_stellar_evolution_to_model = stellar_evolution.particles.new_channel_to(star.as_set())
stellar_evolution.evolve_model()
from_stellar_evolution_to_model.copy()
stellar_evolution.stop()
self.assertEquals(stars[0].initial_mass, stars[1].initial_mass)
self.assertEquals(stars[0].luminosity, stars[1].luminosity)
self.assertEquals(stars[0].age, stars[1].age)
print "Solved: SSE_muse_interface.f sets initial_mass to mass when necessary."
示例13: test11
# 需要导入模块: from amuse.community.sse.interface import SSE [as 别名]
# 或者: from amuse.community.sse.interface.SSE import evolve_model [as 别名]
def test11(self):
print "Test evolve_model optional arguments: end_time and keep_synchronous"
stars = Particles(3)
stars.mass = [1.0, 2.0, 3.0] | units.MSun
instance = SSE()
instance.commit_parameters()
instance.particles.add_particles(stars)
self.assertEqual(instance.particles.age, [0.0, 0.0, 0.0] | units.yr)
self.assertAlmostEqual(instance.particles.time_step, [550.1565, 58.2081, 18.8768] | units.Myr, 3)
self.assertAlmostEqual(instance.particles.radius, [0.8882494502, 1.610210385, 1.979134445] | units.RSun)
print "evolve_model without arguments: use shared timestep = min(particles.time_step)"
instance.evolve_model()
self.assertAlmostEqual(instance.particles.age, [18.8768, 18.8768, 18.8768] | units.Myr, 3)
self.assertAlmostEqual(instance.particles.time_step, [550.1565, 58.2081, 18.8768] | units.Myr, 3)
self.assertAlmostEqual(instance.model_time, 18.8768 | units.Myr, 3)
print "evolve_model with end_time: take timesteps, until end_time is reached exactly"
instance.evolve_model(100 | units.Myr)
self.assertAlmostEqual(instance.particles.age, [100.0, 100.0, 100.0] | units.Myr, 3)
self.assertAlmostEqual(instance.particles.time_step, [550.1565, 58.2081, 18.8768] | units.Myr, 3)
self.assertAlmostEqual(instance.model_time, 100.0 | units.Myr, 3)
print "evolve_model with keep_synchronous: use non-shared timestep, particle ages will typically diverge"
instance.evolve_model(keep_synchronous = False)
self.assertAlmostEqual(instance.particles.age, (100 | units.Myr) + ([550.1565, 58.2081, 18.8768] | units.Myr), 3)
self.assertAlmostEqual(instance.particles.time_step, [550.1565, 58.2081, 18.8768] | units.Myr, 3)
self.assertAlmostEqual(instance.model_time, 100.0 | units.Myr, 3) # Unchanged!
instance.stop()
示例14: test3
# 需要导入模块: from amuse.community.sse.interface import SSE [as 别名]
# 或者: from amuse.community.sse.interface.SSE import evolve_model [as 别名]
def test3(self):
sse = SSE()
sse.commit_parameters()
stars = Particles(1)
star = stars[0]
star.mass = 5 | units.MSun
star.radius = 0.0 | units.RSun
stars.synchronize_to(sse.particles)
channel = sse.particles.new_channel_to(stars)
channel.copy_attributes(sse.particles.get_attribute_names_defined_in_store())
previous_type = sse.particles.stellar_type
results = []
sse.evolve_model(121.5 | units.Myr)
channel.copy_attributes(sse.particles.get_attribute_names_defined_in_store())
self.assertAlmostEqual(star.mass.value_in(units.MSun), 0.997, 3)
sse.stop()
示例15: planetplot
# 需要导入模块: from amuse.community.sse.interface import SSE [as 别名]
# 或者: from amuse.community.sse.interface.SSE import evolve_model [as 别名]
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()