当前位置: 首页>>代码示例>>Python>>正文


Python BHTree.eps2_for_gravity方法代码示例

本文整理汇总了Python中amuse.community.bhtree.interface.BHTree.eps2_for_gravity方法的典型用法代码示例。如果您正苦于以下问题:Python BHTree.eps2_for_gravity方法的具体用法?Python BHTree.eps2_for_gravity怎么用?Python BHTree.eps2_for_gravity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在amuse.community.bhtree.interface.BHTree的用法示例。


在下文中一共展示了BHTree.eps2_for_gravity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test2

# 需要导入模块: from amuse.community.bhtree.interface import BHTree [as 别名]
# 或者: from amuse.community.bhtree.interface.BHTree import eps2_for_gravity [as 别名]
    def test2(self):
        convert_nbody = nbody_system.nbody_to_si(1.0 | units.MSun, 149.5e6 | units.km)

        bhtree = BHTree(convert_nbody)
        bhtree.initialize_code()
        bhtree.eps2_for_gravity = 0.001
            
        bhtree_particles = self.new_system_sun_and_earth()
        bhtree.particles.add_particles(bhtree_particles)
        
        if bhtree.legacy_interface.channel_type == 'mpi':
            from mpi4py import MPI
            if not MPI.Query_thread() == MPI.THREAD_MULTIPLE:
                bhtree.stop()
                self.skip("can only test parallel with multiple thread support in mpi implementation")
            
        
        hermite = Hermite(convert_nbody)
        hermite.dt_dia = 5000
        hermite.commit_parameters()
            
        hermite_particles = self.new_system_sun_and_earth()
        hermite.particles.add_particles(hermite_particles)
        
        thread1 = threading.Thread(target = self.evolve_model_unit_day, args = (bhtree, bhtree_particles, 10))
        thread2 = threading.Thread(target = self.evolve_model_unit_day, args = (hermite, hermite_particles, 10))
        
        thread1.start()
        thread2.start()
        
        thread1.join()
        thread2.join()
        
        
        
        if HAS_MATPLOTLIB:
            figure = pyplot.figure()
            plot = figure.add_subplot(1,1,1)
            
            earth = bhtree_particles[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')
            
            earth = hermite_particles[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 = "g", 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, "parallel-earth-sun.svg")
            figure.savefig(output_file)
                    
        bhtree.stop()
        hermite.stop()
        bhtree.stop()
开发者ID:Ingwar,项目名称:amuse,代码行数:67,代码来源:test_parallel.py


注:本文中的amuse.community.bhtree.interface.BHTree.eps2_for_gravity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。