當前位置: 首頁>>代碼示例>>Python>>正文


Python Hermite.cleanup_code方法代碼示例

本文整理匯總了Python中amuse.community.hermite0.interface.Hermite.cleanup_code方法的典型用法代碼示例。如果您正苦於以下問題:Python Hermite.cleanup_code方法的具體用法?Python Hermite.cleanup_code怎麽用?Python Hermite.cleanup_code使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在amuse.community.hermite0.interface.Hermite的用法示例。


在下文中一共展示了Hermite.cleanup_code方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test2

# 需要導入模塊: from amuse.community.hermite0.interface import Hermite [as 別名]
# 或者: from amuse.community.hermite0.interface.Hermite import cleanup_code [as 別名]
 def test2(self):
     convert_nbody = nbody_system.nbody_to_si(1.0 | units.MSun, 149.5e6 | units.km)
 
     instance = Hermite(convert_nbody)
     instance.initialize_code()
     instance.parameters.epsilon_squared = 0.0 | units.AU**2
     instance.dt_dia = 5000
     
     stars = self.new_system_of_sun_and_earth()
     earth = stars[1]
     instance.particles.add_particles(stars)
     
     for x in range(1, 500, 10):
         instance.evolve_model(x | units.day)
         instance.particles.copy_values_of_all_attributes_to(stars)
         stars.savepoint()
     
     if HAS_MATPLOTLIB:
         figure = pyplot.figure()
         plot = figure.add_subplot(1,1,1)
         
         x_points = earth.get_timeline_of_attribute("x")
         y_points = earth.get_timeline_of_attribute("y")
         
         x_points_in_AU = map(lambda (t,x) : x.value_in(units.AU), x_points)
         y_points_in_AU = map(lambda (t,x) : x.value_in(units.AU), y_points)
         
         plot.scatter(x_points_in_AU,y_points_in_AU, color = "b", marker = 'o')
         
         plot.set_xlim(-1.5, 1.5)
         plot.set_ylim(-1.5, 1.5)
            
         
         test_results_path = self.get_path_to_results()
         output_file = os.path.join(test_results_path, "hermite-earth-sun2.svg")
         figure.savefig(output_file)
     
     
     
     instance.cleanup_code()
     instance.stop()
開發者ID:Ingwar,項目名稱:amuse,代碼行數:43,代碼來源:test_hermite.py

示例2: test10

# 需要導入模塊: from amuse.community.hermite0.interface import Hermite [as 別名]
# 或者: from amuse.community.hermite0.interface.Hermite import cleanup_code [as 別名]
 def test10(self):
     convert_nbody = nbody_system.nbody_to_si(1.0 | units.MSun, 149.5e6 | units.km)
 
     instance = Hermite(convert_nbody)
     instance.initialize_code()
     instance.parameters.epsilon_squared = 0.0 | units.AU**2
     instance.parameters.stopping_conditions_number_of_steps = 10
     self.assertEquals(instance.parameters.stopping_conditions_number_of_steps,10)
 
     stars = self.new_system_of_sun_and_earth()
     earth = stars[1]
             
     instance.particles.add_particles(stars)
     instance.stopping_conditions.number_of_steps_detection.enable()
     instance.evolve_model(365.0 | units.day)
     self.assertTrue(instance.stopping_conditions.number_of_steps_detection.is_set())
     instance.particles.copy_values_of_all_attributes_to(stars)
     
     instance.cleanup_code()
     
     instance.stop()
開發者ID:Ingwar,項目名稱:amuse,代碼行數:23,代碼來源:test_hermite.py

示例3: test20

# 需要導入模塊: from amuse.community.hermite0.interface import Hermite [as 別名]
# 或者: from amuse.community.hermite0.interface.Hermite import cleanup_code [as 別名]
 def test20(self):
     convert_nbody = nbody_system.nbody_to_si(1.0 | units.MSun, 149.5e6 | units.km)
 
     hermite = Hermite(convert_nbody)
     hermite.initialize_code()
     hermite.parameters.epsilon_squared = 0.0 | units.AU**2
     hermite.parameters.end_time_accuracy_factor = 0.0
     hermite.parameters.is_time_reversed_allowed = True
     
     stars = self.new_system_of_sun_and_earth()
     earth = stars[1]
             
     hermite.particles.add_particles(stars)
     
     hermite.evolve_model(365.0 | units.day)
     hermite.particles.copy_values_of_all_attributes_to(stars)
     
     position_at_start = earth.position.value_in(units.AU)[0]
     position_after_full_rotation = earth.position.value_in(units.AU)[0]
     self.assertAlmostRelativeEqual(position_at_start, position_after_full_rotation, 6)
     
     hermite.evolve_model(365.0 - (365.0 / 2) | units.day)
     
     hermite.particles.copy_values_of_all_attributes_to(stars)
     position_after_half_a_rotation_backward = earth.position.value_in(units.AU)[0]
     self.assertAlmostRelativeEqual(-position_at_start, position_after_half_a_rotation_backward, 4)
             
     hermite.evolve_model(365.0 | units.day)
     
     position_at_start = earth.position.value_in(units.AU)[0]
     position_after_full_rotation = earth.position.value_in(units.AU)[0]
     self.assertAlmostRelativeEqual(position_at_start, position_after_full_rotation, 6)
     
     hermite.cleanup_code()
     
     hermite.stop()
開發者ID:Ingwar,項目名稱:amuse,代碼行數:38,代碼來源:test_hermite.py


注:本文中的amuse.community.hermite0.interface.Hermite.cleanup_code方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。