本文整理匯總了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()