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


Python Hermite.commit_particles方法代码示例

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


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

示例1: test15

# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import commit_particles [as 别名]
    def test15(self):
        particles = datamodel.Particles(2)
        particles.x = [0.0,10.0] | nbody_system.length
        particles.y = 0.0 | nbody_system.length
        particles.z = 0.0 | nbody_system.length
        particles.vx =  0.0 | nbody_system.speed
        particles.vy =  0.0 | nbody_system.speed
        particles.vz =  0.0 | nbody_system.speed
        particles.mass = 1.0 | nbody_system.mass

        instance = Hermite()
        instance.particles.add_particles(particles) 
        instance.commit_particles()
        self.assertEquals(instance.particles[0].radius, 0.0 | nbody_system.length)
        p = datamodel.Particle(
            x = 1.0  | nbody_system.length,
            y = 2.0 | nbody_system.length,
            z = 3.0 | nbody_system.length,
            vx = 1.0  | nbody_system.speed,
            vy = 2.0 | nbody_system.speed,
            vz = 3.0 | nbody_system.speed,
            mass = 1.0 | nbody_system.mass,
            radius = 4.0 | nbody_system.length,
        )
        instance.particles.add_particle(p) 
        self.assertEquals(instance.particles[0].radius, 0.0 | nbody_system.length)
        self.assertEquals(instance.particles[1].radius, 0.0 | nbody_system.length)
        self.assertEquals(instance.particles[2].radius, 4.0 | nbody_system.length)
        
        instance.stop()
开发者ID:Ingwar,项目名称:amuse,代码行数:32,代码来源:test_hermite.py

示例2: test18

# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import commit_particles [as 别名]
    def test18(self):
        particles = datamodel.Particles(2)
        particles.x = [0.0,1.0] | nbody_system.length
        particles.y = 0.0 | nbody_system.length
        particles.z = 0.0 | nbody_system.length
        particles.vx =  0.0 | nbody_system.speed
        particles.vy =  0.0 | nbody_system.speed
        particles.vz =  0.0 | nbody_system.speed
        particles.mass = 1.0 | nbody_system.mass

        instance = Hermite()
        instance.particles.add_particles(particles) 
        instance.commit_particles()
        self.assertEquals(instance.particles[0].radius, 0.0 | nbody_system.length)
        instance.parameters.end_time_accuracy_factor = 1.0
        instance.evolve_model(0.1 | nbody_system.time)
        self.assertAlmostRelativeEquals(instance.model_time, 0.10563767746 |nbody_system.time, 5)
        instance.parameters.end_time_accuracy_factor = -1.0
        instance.evolve_model(0.3 | nbody_system.time)
        self.assertAlmostRelativeEquals(instance.model_time, 0.266758127609 |nbody_system.time, 5)
        instance.parameters.end_time_accuracy_factor = 0.0
        instance.evolve_model(0.4 | nbody_system.time)
        self.assertAlmostRelativeEquals(instance.model_time, 0.4 |nbody_system.time, 6)
        instance.parameters.end_time_accuracy_factor = -0.5
        instance.evolve_model(0.5 | nbody_system.time)
        self.assertAlmostRelativeEquals(instance.model_time, 0.48974930698 |nbody_system.time, 6)
        instance.parameters.end_time_accuracy_factor = +0.5
        instance.evolve_model(0.6 | nbody_system.time)
        self.assertAlmostRelativeEquals(instance.model_time, 0.6042733579 |nbody_system.time, 6)
        
        instance.stop()
开发者ID:Ingwar,项目名称:amuse,代码行数:33,代码来源:test_hermite.py

示例3: test19

# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import commit_particles [as 别名]
    def test19(self):
        particles = datamodel.Particles(2)
        particles.x = [0.0,200.0] | nbody_system.length
        particles.y = 0.0 | nbody_system.length
        particles.z = 0.0 | nbody_system.length
        particles.vx =  0.0 | nbody_system.speed
        particles.vy =  0.0 | nbody_system.speed
        particles.vz =  0.0 | nbody_system.speed
        particles.mass = 1.0 | nbody_system.mass

        instance = Hermite()
        instance.particles.add_particles(particles) 
        instance.commit_particles()
        self.assertEquals(instance.particles[0].radius, 0.0 | nbody_system.length)
        instance.parameters.end_time_accuracy_factor = 0.0
        instance.evolve_model(0.1 | nbody_system.time)
        self.assertAlmostRelativeEquals(instance.model_time, 0.1 |nbody_system.time, 5)
       
        instance.stop()
开发者ID:Ingwar,项目名称:amuse,代码行数:21,代码来源:test_hermite.py

示例4: test7

# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import commit_particles [as 别名]
    def test7(self):
        print "Test7: Testing effect of Hermite parameter epsilon_squared"
        convert_nbody = nbody_system.nbody_to_si(1.0 | units.MSun, 1.0 | units.AU)
        
        particles = datamodel.Particles(2)
        sun = particles[0]
        sun.mass = 1.0 | units.MSun
        sun.position = [0.0, 0.0, 0.0] | units.AU
        sun.velocity = [0.0, 0.0, 0.0] | units.AU / units.yr
        sun.radius = 1.0 | units.RSun

        earth = particles[1]
        earth.mass = 5.9736e24 | units.kg
        earth.radius = 6371.0 | units.km
        earth.position = [0.0, 1.0, 0.0] | units.AU
        earth.velocity = [2.0*numpy.pi, -0.0001, 0.0] | units.AU / units.yr
        
        initial_direction = math.atan((earth.velocity[0]/earth.velocity[1]))
        final_direction = []
        for log_eps2 in range(-9,10,2):
            instance = Hermite(convert_nbody)
            instance.parameters.end_time_accuracy_factor = 0.0
            instance.parameters.epsilon_squared = 10.0**log_eps2 | units.AU ** 2
            instance.particles.add_particles(particles)
            instance.commit_particles()
            instance.evolve_model(0.25 | units.yr)
            final_direction.append(math.atan((instance.particles[1].velocity[0]/
                instance.particles[1].velocity[1])))
            instance.stop()
        # Small values of epsilon_squared should result in normal earth-sun dynamics: rotation of 90 degrees
        self.assertAlmostEquals(abs(final_direction[0]), abs(initial_direction+math.pi/2.0), 2)
        # Large values of epsilon_squared should result in ~ no interaction
        self.assertAlmostEquals(final_direction[-1], initial_direction, 2)
        # Outcome is most sensitive to epsilon_squared when epsilon_squared = d(earth, sun)^2
        delta = [abs(final_direction[i+1]-final_direction[i]) for i in range(len(final_direction)-1)]
        self.assertEquals(delta[len(final_direction)//2 -1], max(delta))
开发者ID:Ingwar,项目名称:amuse,代码行数:38,代码来源:test_hermite.py

示例5: new_star_code_hermite

# 需要导入模块: from amuse.community.hermite0.interface import Hermite [as 别名]
# 或者: from amuse.community.hermite0.interface.Hermite import commit_particles [as 别名]
 def new_star_code_hermite(self):
     result = Hermite(self.converter)
     result.parameters.epsilon_squared = self.star_epsilon ** 2
     result.particles.add_particles(self.new_particles_cluster())
     result.commit_particles()
     return result
开发者ID:Ingwar,项目名称:amuse,代码行数:8,代码来源:particles_and_gas_in_cluster.py


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