本文整理汇总了Python中amuse.community.sse.interface.SSE.update_time_steps方法的典型用法代码示例。如果您正苦于以下问题:Python SSE.update_time_steps方法的具体用法?Python SSE.update_time_steps怎么用?Python SSE.update_time_steps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类amuse.community.sse.interface.SSE
的用法示例。
在下文中一共展示了SSE.update_time_steps方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test1
# 需要导入模块: from amuse.community.sse.interface import SSE [as 别名]
# 或者: from amuse.community.sse.interface.SSE import update_time_steps [as 别名]
def test1(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)
from_sse_to_model = sse.particles.new_channel_to(stars)
from_sse_to_model.copy()
previous_type = star.stellar_type
results = []
t0 = 0 | units.Myr
current_time = t0
while current_time < (125 | units.Myr):
sse.update_time_steps()
current_time = current_time + sse.particles[0].time_step
sse.evolve_model(current_time)
from_sse_to_model.copy()
if not star.stellar_type == previous_type:
results.append((star.age, star.mass, star.stellar_type))
previous_type = star.stellar_type
self.assertEqual(len(results), 6)
times = (
104.0 | units.Myr,
104.4 | units.Myr,
104.7 | units.Myr,
120.1 | units.Myr,
120.9 | units.Myr,
121.5 | units.Myr
)
for result, expected in zip(results, times):
self.assertAlmostEqual(result[0].value_in(units.Myr), expected.value_in(units.Myr), 1)
masses = (
5.000 | units.MSun,
5.000 | units.MSun,
4.998 | units.MSun,
4.932 | units.MSun,
4.895 | units.MSun,
0.997 | units.MSun
)
for result, expected in zip(results, masses):
self.assertAlmostEqual(result[1].value_in(units.MSun), expected.value_in(units.MSun), 3)
types = (
"Hertzsprung Gap",
"First Giant Branch",
"Core Helium Burning",
"First Asymptotic Giant Branch",
"Second Asymptotic Giant Branch",
"Carbon/Oxygen White Dwarf",
)
for result, expected in zip(results, types):
self.assertEquals(str(result[2]), expected)
sse.stop()