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


Python Huayno.evolve_model方法代码示例

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


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

示例1: test3

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

        instance = Huayno(convert_nbody)
        instance.initialize_code()
        instance.parameters.epsilon_squared = 0.00001 | units.AU**2
        
        stars = datamodel.Stars(2)
        star1 = stars[0]
        star2 = stars[1]

        star1.mass = units.MSun(1.0)
        star1.position = units.AU(numpy.array((-1.0,0.0,0.0)))
        star1.velocity = units.AUd(numpy.array((0.0,0.0,0.0)))
        star1.radius = units.RSun(1.0)

        star2.mass = units.MSun(1.0)
        star2.position = units.AU(numpy.array((1.0,0.0,0.0)))
        star2.velocity = units.AUd(numpy.array((0.0,0.0,0.0)))
        star2.radius = units.RSun(100.0)
        
        instance.particles.add_particles(stars)
    
        for x in range(1,2000,10):
            instance.evolve_model(x | units.day)
            instance.particles.copy_values_of_all_attributes_to(stars)
            stars.savepoint()
开发者ID:mherkazandjian,项目名称:amuse,代码行数:29,代码来源:test_huayno.py

示例2: test13

# 需要导入模块: from amuse.community.huayno.interface import Huayno [as 别名]
# 或者: from amuse.community.huayno.interface.Huayno import evolve_model [as 别名]
 def test13(self):
     particles = plummer.new_plummer_model(31)
    
     instance = Huayno(number_of_workers=1)#, debugger="xterm")
     instance.initialize_code()
     instance.parameters.epsilon_squared = 0.01 | nbody_system.length ** 2
     instance.particles.add_particles(particles)
     
     instance.evolve_model(0.1 | nbody_system.time)
     instance.synchronize_model()
     expected_positions = instance.particles.position
     instance.stop()
开发者ID:mherkazandjian,项目名称:amuse,代码行数:14,代码来源:test_huayno.py

示例3: binary_with_planet_run

# 需要导入模块: from amuse.community.huayno.interface import Huayno [as 别名]
# 或者: from amuse.community.huayno.interface.Huayno import evolve_model [as 别名]
def binary_with_planet_run(m1=1.|units.MSun, m2=1.| units.MSun, m_planet=1|units.MJupiter,
                           r1=None, r2=None, r_planet=None, ecc_binary=0, P_binary=20 | units.day,
                           ecc_planet=0., P_planet=1.| units.yr, pangle_planet=0., a_planet=None,
                           tend=100. | units.yr,hostname=''):

    dEcrit=1.e-6

    three=binary_with_planet(m1=m1,m2=m2,m_planet=m_planet,r1=r1,r2=r2,r_planet=r_planet,
             ecc_binary=ecc_binary,P_binary=P_binary,
             ecc_planet=ecc_planet,a_planet=a_planet,pangle_planet=pangle_planet)
    
    convert=nbody_system.nbody_to_si(1|units.MSun,1|units.AU)
    code=Huayno(convert,hostname=hostname)
    
    code.parameters.inttype_parameter=code.inttypes.SHARED10
    code.parameters.timestep_parameter=.2
    code.parameters.timestep=100. | units.day
        
    dt=10000. | units.day
    
    code.particles.add_particles(three)

    E0=code.potential_energy+code.kinetic_energy
    a0,eps0,pangle0=elements( three.total_mass(),
          code.particles.x[2],
          code.particles.y[2],
          code.particles.z[2],
          code.particles.vx[2],
          code.particles.vy[2],
          code.particles.vz[2] )

    t=0. | units.day
    result="stable"
    while(t < tend-dt/2):
        t=t+dt
        code.evolve_model(t)
        E=code.potential_energy+code.kinetic_energy    
        dE=abs(((E-E0)/E0))
        a,eps,pangle=elements( three.total_mass(),
          code.particles.x[2],
          code.particles.y[2],
          code.particles.z[2],
          code.particles.vx[2],
          code.particles.vy[2],
          code.particles.vz[2] )
        if dE > dEcrit or a<0.5*a0 or a>2.*a0:
          result="unstable"
          if dE > dEcrit:
            result="failed"
          break
    code.stop()
    return result,t,dE,a.in_(units.AU),eps,pangle
开发者ID:Ingwar,项目名称:amuse,代码行数:54,代码来源:bin_planet.py

示例4: test14

# 需要导入模块: from amuse.community.huayno.interface import Huayno [as 别名]
# 或者: from amuse.community.huayno.interface.Huayno import evolve_model [as 别名]
    def test14(self):
        import hashlib

        numpy.random.seed(123456)
        particles = plummer.new_plummer_model(64)
        sha=hashlib.sha1()

        class inttypes(object):
            SHARED2=1
            EXTRAPOLATE=5
            PASS_KDK=2
            PASS_DKD=7
            HOLD_KDK=3
            HOLD_DKD=8
            PPASS_DKD=9
            BRIDGE_KDK=4
            BRIDGE_DKD=10
            CC=11
            CC_KEPLER=12
            OK=13
            KEPLER=14
            SHARED4=15
            SHARED6=18
            SHARED8=19
            SHARED10=20
            SHAREDBS=21
           
            @classmethod
            def _list(cls):
                  return set([x for x in cls.__dict__.keys() if not x.startswith('_')])

        for itype in sorted(inttypes._list()):
            if itype in ("KEPLER"): continue
            instance = Huayno()
            instance.parameters.inttype_parameter=getattr(Huayno.inttypes,itype)
            instance.particles.add_particles(particles)
            instance.evolve_model(0.125 | nbody_system.time)
            part_out= instance.particles.copy()
            position = part_out.position.number
            if hasattr(position,'tobytes'):
                as_bytes = position.tobytes()
            else:
                as_bytes = numpy.copy(position.data, order='C')
            sha.update(as_bytes)
            
            instance.stop()
        
        # this result is probably dependent on system architecture hence no good for assert
        print 
        print sha.hexdigest()
        print "8e71f9441578a43af4af927943577ad2c4130e4c"
开发者ID:jorishanse,项目名称:amuse,代码行数:53,代码来源:test_huayno.py

示例5: _run_collision_with_integrator

# 需要导入模块: from amuse.community.huayno.interface import Huayno [as 别名]
# 或者: from amuse.community.huayno.interface.Huayno import evolve_model [as 别名]
 def _run_collision_with_integrator(self, inttype_parameter):
     particles = datamodel.Particles(7)
     particles.mass = 0.001 | nbody_system.mass
     particles.radius = 0.01 | nbody_system.length
     particles.x = [-101.0, -100.0, -0.5, 0.5, 100.0, 101.0, 104.0] | nbody_system.length
     particles.y = 0 | nbody_system.length
     particles.z = 0 | nbody_system.length
     particles.velocity = [[2, 0, 0], [-2, 0, 0]]*3 + [[-4, 0, 0]] | nbody_system.speed
     
     instance = Huayno()
     instance.parameters.inttype_parameter = inttype_parameter
     instance.particles.add_particles(particles)
     collisions = instance.stopping_conditions.collision_detection
     collisions.enable()
     instance.evolve_model(1.0 | nbody_system.time)
     
     self.assertTrue(collisions.is_set())
     self.assertTrue(instance.model_time < 0.5 | nbody_system.time)
     self.assertEquals(len(collisions.particles(0)), 3)
     self.assertEquals(len(collisions.particles(1)), 3)
     self.assertEquals(len(particles - collisions.particles(0) - collisions.particles(1)), 1)
     self.assertEquals(abs(collisions.particles(0).x - collisions.particles(1).x) <= 
             (collisions.particles(0).radius + collisions.particles(1).radius),
             [True, True, True])
     
     sticky_merged = datamodel.Particles(len(collisions.particles(0)))
     sticky_merged.mass = collisions.particles(0).mass + collisions.particles(1).mass
     sticky_merged.radius = collisions.particles(0).radius
     for p1, p2, merged in zip(collisions.particles(0), collisions.particles(1), sticky_merged):
         merged.position = (p1 + p2).center_of_mass()
         merged.velocity = (p1 + p2).center_of_mass_velocity()
     
     print instance.model_time
     print instance.particles
     instance.particles.remove_particles(collisions.particles(0) + collisions.particles(1))
     instance.particles.add_particles(sticky_merged)
     
     instance.evolve_model(1.0 | nbody_system.time)
     print
     print instance.model_time
     print instance.particles
     self.assertTrue(collisions.is_set())
     self.assertTrue(instance.model_time < 1.0 | nbody_system.time)
     self.assertEquals(len(collisions.particles(0)), 1)
     self.assertEquals(len(collisions.particles(1)), 1)
     self.assertEquals(len(instance.particles - collisions.particles(0) - collisions.particles(1)), 2)
     self.assertEquals(abs(collisions.particles(0).x - collisions.particles(1).x) <= 
             (collisions.particles(0).radius + collisions.particles(1).radius),
             [True])
     instance.stop()
开发者ID:mherkazandjian,项目名称:amuse,代码行数:52,代码来源:test_huayno.py

示例6: _compare_integrator_with_collision_integrator

# 需要导入模块: from amuse.community.huayno.interface import Huayno [as 别名]
# 或者: from amuse.community.huayno.interface.Huayno import evolve_model [as 别名]
 def _compare_integrator_with_collision_integrator(self, inttype_parameter1, inttype_parameter2):
     numpy.random.seed(12345)
     particles = plummer.new_plummer_model(101)
     instance = Huayno()
     instance.parameters.inttype_parameter = inttype_parameter1
     instance.particles.add_particles(particles)
     instance.evolve_model(0.2 | nbody_system.time)
     expected_position = instance.particles.position
     expected_velocity = instance.particles.velocity
     instance.reset()
     instance.parameters.inttype_parameter = inttype_parameter2
     instance.particles.add_particles(particles)
     instance.evolve_model(0.2 | nbody_system.time)
     self.assertAlmostRelativeEquals(expected_position, instance.particles.position, 8)
     self.assertAlmostRelativeEquals(expected_velocity, instance.particles.velocity, 8)
     instance.stop()
开发者ID:mherkazandjian,项目名称:amuse,代码行数:18,代码来源:test_huayno.py

示例7: orbit_evolve

# 需要导入模块: from amuse.community.huayno.interface import Huayno [as 别名]
# 或者: from amuse.community.huayno.interface.Huayno import evolve_model [as 别名]
def orbit_evolve(bodies, time_peri, eta, n_steps=100):
  converter=nbody_system.nbody_to_si(1|units.MSun,1|units.AU)
  
  gravity = Huayno(converter,channel_type="sockets")
  gravity.particles.add_particles(bodies)
  gravity.commit_particles()
  gravity.parameters.timestep_parameter = eta
  
  channel_from_gravity_to_framework = gravity.particles.new_channel_to(bodies)
  
  Etot_init = gravity.kinetic_energy + gravity.potential_energy
  Etot = Etot_init
  
  file_snap = "orbit_ini.hdf5"
  
  t_end = 2.0*abs(time_peri.value_in(units.yr)) | units.yr
  dt = t_end / float(n_steps)
  time = 0.0 | units.yr
  
  while time <= t_end:
    
    gravity.evolve_model(time)
    channel_from_gravity_to_framework.copy()
    bodies.age = time
    
    # checking energy conservation
    Ekin = gravity.kinetic_energy
    Epot = gravity.potential_energy
    Etot = Ekin + Epot
    dE = Etot_init-Etot
    
    # output centerd on the bodies[0] star
    bodies.position -= bodies[0].position
    bodies.velocity -= bodies[0].velocity
    write_set_to_file(bodies, file_snap, "hdf5")
    
    rel_r = (bodies[1].position - bodies[0].position).lengths()
    print " \t\t", time, "\t", dE/Etot_init, rel_r.in_(units.AU)
    time += dt
  
  gravity.stop()
  bodies.position -= bodies[0].position
  bodies.velocity -= bodies[0].velocity
  print bodies
  
  return
开发者ID:Sportsfan77777,项目名称:disk-transfer,代码行数:48,代码来源:orbit_ini_01.py

示例8: test29

# 需要导入模块: from amuse.community.huayno.interface import Huayno [as 别名]
# 或者: from amuse.community.huayno.interface.Huayno import evolve_model [as 别名]
 def test29(self):
     instance = Huayno()
     instance.parameters.epsilon_squared = 0.0 | nbody_system.length**2
     
     particles = datamodel.Particles(2)
     particles.position = ([0,0,0], [1,0,0] )| nbody_system.length
     particles.velocity = ([-1,0,0], [2,0,0] )| nbody_system.speed
     particles.radius = 0| nbody_system.length
     particles.mass = 0.1| nbody_system.mass
             
     instance.particles.add_particles(particles)
     instance.stopping_conditions.out_of_box_detection.enable()
     instance.parameters.stopping_conditions_out_of_box_size = 2 | nbody_system.length
     instance.parameters.stopping_conditions_out_of_box_use_center_of_mass = False
     instance.evolve_model(1 | nbody_system.time)
     self.assertTrue(instance.stopping_conditions.out_of_box_detection.is_set())
     self.assertEquals(len(instance.stopping_conditions.out_of_box_detection.particles(0)), 1)
     self.assertEquals(instance.stopping_conditions.out_of_box_detection.particles(0)[0].key, particles[1].key)
     instance.stop()
开发者ID:mherkazandjian,项目名称:amuse,代码行数:21,代码来源:test_huayno.py

示例9: test24

# 需要导入模块: from amuse.community.huayno.interface import Huayno [as 别名]
# 或者: from amuse.community.huayno.interface.Huayno import evolve_model [as 别名]
    def test24(self):
        print "test massless particles/ kepler integrator"
        N=20        
        tend=2.| units.yr
        numpy.random.seed(12345)
        conv=nbody_system.nbody_to_si(4.| units.MSun, 5.|units.AU)
        orbiters=plummer.new_plummer_model(N,conv)
        sun=datamodel.Particle(mass=1.|units.MSun)
        sun.position=[12.3,1.,-.2]|units.AU
        sun.velocity=[10,50.,-20.]|units.kms
        orbiters.mass*=0.
        
        a0,eps0=elements(sun.mass,orbiters.x,orbiters.y,orbiters.z,
                      orbiters.vx,orbiters.vy,orbiters.vz)

        orbiters.position+=sun.position
        orbiters.velocity+=sun.velocity

        pos=dict()
        for inttype in [20,14]:
          code=Huayno(conv)
          code.parameters.inttype_parameter=inttype
          code.parameters.timestep_parameter=0.1
          code.particles.add_particle(sun)
          orbiters2=code.particles.add_particles(orbiters).copy()
          orbiters2.position-=sun.position
          orbiters2.velocity-=sun.velocity
          code.evolve_model(tend)
          a,eps=elements(sun.mass,orbiters2.x,orbiters2.y,orbiters2.z,
                    orbiters2.vx,orbiters2.vy,orbiters2.vz)

          da=abs((a-a0)/a0)
          deps=abs(eps-eps0)/eps0

          dev=numpy.where(da > 1.e-12)[0]
          self.assertEqual( len(dev),0)
          dev=numpy.where(deps > 1.e-12)[0]
          self.assertEqual( len(dev),0)
          pos[inttype]=[orbiters2.x.value_in(units.AU),orbiters2.y.value_in(units.AU),orbiters2.z.value_in(units.AU)]
        self.assertAlmostEqual(pos[20][0],pos[14][0],12)
        self.assertAlmostEqual(pos[20][1],pos[14][1],12)
        self.assertAlmostEqual(pos[20][2],pos[14][2],12)
开发者ID:mherkazandjian,项目名称:amuse,代码行数:44,代码来源:test_huayno.py

示例10: test1

# 需要导入模块: from amuse.community.huayno.interface import Huayno [as 别名]
# 或者: from amuse.community.huayno.interface.Huayno import evolve_model [as 别名]
 def test1(self):
     convert_nbody = nbody_system.nbody_to_si(1.0 | units.MSun, 149.5e6 | units.km)
 
     huayno = Huayno(convert_nbody)
     huayno.initialize_code()
     huayno.parameters.epsilon_squared = 0.0 | units.AU**2
     
     stars = self.new_system_of_sun_and_earth()
     earth = stars[1]
     
     huayno.particles.add_particles(stars)
     
     huayno.evolve_model(365.0 | units.day)
     huayno.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.assertAlmostEqual(position_at_start, position_after_full_rotation, 6)
     
     huayno.evolve_model(365.0 + (365.0 / 2) | units.day)
     
     huayno.particles.copy_values_of_all_attributes_to(stars)
     position_after_half_a_rotation = earth.position.value_in(units.AU)[0]
     self.assertAlmostEqual(-position_at_start, position_after_half_a_rotation, 2)
             
     huayno.evolve_model(365.0 + (365.0 / 2) + (365.0 / 4)  | units.day)
     
     huayno.particles.copy_values_of_all_attributes_to(stars)
     position_after_half_a_rotation = earth.position.value_in(units.AU)[1]
     self.assertAlmostEqual(-position_at_start, position_after_half_a_rotation, 3)
     
     huayno.cleanup_code()
     
     huayno.stop()
开发者ID:mherkazandjian,项目名称:amuse,代码行数:36,代码来源:test_huayno.py

示例11: test2

# 需要导入模块: from amuse.community.huayno.interface import Huayno [as 别名]
# 或者: from amuse.community.huayno.interface.Huayno import evolve_model [as 别名]
 def test2(self):
     convert_nbody = nbody_system.nbody_to_si(1.0 | units.MSun, 149.5e6 | units.km)
 
     instance = Huayno(convert_nbody)
     instance.initialize_code()
     instance.parameters.epsilon_squared = 0.0 | units.AU**2
     
     stars = self.new_system_of_sun_and_earth()
     earth = stars[1]
     instance.particles.add_particles(stars)
 
     for x in range(1,2000,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, "huayno-earth-sun2.svg")
         figure.savefig(output_file)
           
     instance.cleanup_code()
     del instance
开发者ID:mherkazandjian,项目名称:amuse,代码行数:40,代码来源:test_huayno.py

示例12: test27

# 需要导入模块: from amuse.community.huayno.interface import Huayno [as 别名]
# 或者: from amuse.community.huayno.interface.Huayno import evolve_model [as 别名]
    def test27(self):
        particles = plummer.new_plummer_model(31)

        tend=0.25| nbody_system.time

        instance = Huayno()
        instance.particles.add_particles(particles)        
        instance.evolve_model(tend)
        expected_positions = instance.particles.position
        self.assertEqual(instance.model_time, tend)
        instance.stop()
        
        particles2=particles.copy()
        particles2.velocity*=-1

        instance = Huayno()
        instance.particles.add_particles(particles2)        
        instance.evolve_model(-tend)
        positions = instance.particles.position
        self.assertEqual(instance.model_time, -tend)
        instance.stop()

        self.assertAlmostEqual(positions,expected_positions)
开发者ID:mherkazandjian,项目名称:amuse,代码行数:25,代码来源:test_huayno.py

示例13: test15

# 需要导入模块: from amuse.community.huayno.interface import Huayno [as 别名]
# 或者: from amuse.community.huayno.interface.Huayno import evolve_model [as 别名]
 def test15(self):
     particles = plummer.new_plummer_model(512)
     expected_positions = None
     for mode in ["cpu", "openmp", "opencl"]:
         try:
             instance = Huayno(mode=mode, number_of_workers=1)#, debugger="xterm")
         except:
             print "Running huayno with mode=", mode, " was unsuccessful."
             continue
         else:
             print "Running huayno with mode=", mode, "... "
             
         instance.initialize_code()
         instance.parameters.epsilon_squared = 0.01 | nbody_system.length ** 2
         instance.particles.add_particles(particles)
         
         instance.evolve_model(0.2 | nbody_system.time)
         instance.synchronize_model()
         if expected_positions is None:
             expected_positions = instance.particles.position
         else:
             self.assertAlmostRelativeEquals(expected_positions, instance.particles.position, 8)
         instance.stop()
开发者ID:mherkazandjian,项目名称:amuse,代码行数:25,代码来源:test_huayno.py

示例14: test25

# 需要导入模块: from amuse.community.huayno.interface import Huayno [as 别名]
# 或者: from amuse.community.huayno.interface.Huayno import evolve_model [as 别名]
    def test25(self):
        print "test massless particles/ kepler integrator, smoothed"
        N=10        
        tend=20.| units.yr
        numpy.random.seed(12345)
        conv=nbody_system.nbody_to_si(4.| units.MSun, 5.|units.AU)
        orbiters=plummer.new_plummer_model(N,conv)
        sun=datamodel.Particle(mass=1.|units.MSun)
        sun.position=[0,0,0]|units.AU
        sun.velocity=[0,0,0]|units.kms
        orbiters.mass*=0.
        eps=(5. | units.AU)

        e0=energy(sun.mass,eps,orbiters)
        l0=angular_momentum(orbiters)
        
        pos=dict()
        for inttype in [20,14]:
          code=Huayno(conv)
          code.parameters.inttype_parameter=inttype
          code.parameters.timestep_parameter=0.1
          code.parameters.epsilon_squared=eps**2
          code.particles.add_particle(sun)
          orbiters2=code.particles.add_particles(orbiters)
          code.evolve_model(tend)

          e1=energy(sun.mass,eps,orbiters2)
          l1=angular_momentum(orbiters2)
          de,dl=abs((e1-e0)/e0).max(),abs((l1-l0)/l1).max()
          self.assertTrue( numpy.all(de< 1.e-8))
          self.assertTrue( numpy.all(dl< 1.e-8))

          pos[inttype]=[orbiters2.x.value_in(units.AU),orbiters2.y.value_in(units.AU),orbiters2.z.value_in(units.AU)]
        self.assertAlmostRelativeEqual(pos[20][0],pos[14][0],4) # still not clear why 4
        self.assertAlmostRelativeEqual(pos[20][1],pos[14][1],4)
        self.assertAlmostRelativeEqual(pos[20][2],pos[14][2],4)
开发者ID:mherkazandjian,项目名称:amuse,代码行数:38,代码来源:test_huayno.py

示例15: test7

# 需要导入模块: from amuse.community.huayno.interface import Huayno [as 别名]
# 或者: from amuse.community.huayno.interface.Huayno import evolve_model [as 别名]
    def test7(self):
        print "Test7: Testing effect of Huayno 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 = Huayno(convert_nbody)
            instance.initialize_code()
            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:mherkazandjian,项目名称:amuse,代码行数:38,代码来源:test_huayno.py


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