當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。