コード例 #1
0
ファイル: test_phigrape.py プロジェクト: mherkazandjian/amuse
 def xtest8(self):
     instance = PhiGRAPEInterface(**default_test_options)
     instance.initialize_code()
     instance.set_eps2(0.0**2)
     instance.set_eta(0.01,0.02)
     instance.new_particle( 
         [0.01,0.01],
         [10.,-10.],
         [0.0,0.0],
         [0.0,0.0],
         [-5.0,5.0],
         [0.0,0.0],
         [0.0,0.0],
         [0.1,0.1])
     instance.commit_particles() 
     #HAS NO RESULT...
     result = instance.evolve_model(3.14159)  
     
     tnow=instance.get_time()['time']
     print "after evolve(pi), tnow = %f" %  (tnow)
     #self.assertEqual( id1, 1)
     """
     instance.evolve(instance.get_time(),1)
     id2=instance.find_colliding_secondary(id1)
     self.assertEqual( id2, 2)
     self.assertAlmostEqual( tnow, 2.,2)
     state1 = instance.get_state(id1)
     state2 = instance.get_state(id2)
     self.assertTrue( abs(state1['x'] - state2['x'])<0.2)
     """
     instance.cleanup_code()
     instance.stop()
コード例 #2
0
 def xtest8(self):
     instance = PhiGRAPEInterface(**default_test_options)
     instance.initialize_code()
     instance.set_eps2(0.0**2)
     instance.set_eta(0.01,0.02)
     instance.new_particle( 
         [0.01,0.01],
         [10.,-10.],
         [0.0,0.0],
         [0.0,0.0],
         [-5.0,5.0],
         [0.0,0.0],
         [0.0,0.0],
         [0.1,0.1])
     instance.commit_particles() 
     #HAS NO RESULT...
     result = instance.evolve_model(3.14159)  
     
     tnow=instance.get_time()['time']
     print "after evolve(pi), tnow = %f" %  (tnow)
     #self.assertEqual( id1, 1)
     """
     instance.evolve(instance.get_time(),1)
     id2=instance.find_colliding_secondary(id1)
     self.assertEqual( id2, 2)
     self.assertAlmostEqual( tnow, 2.,2)
     state1 = instance.get_state(id1)
     state2 = instance.get_state(id2)
     self.assertTrue( abs(state1['x'] - state2['x'])<0.2)
     """
     instance.cleanup_code()
     instance.stop()
コード例 #3
0
ファイル: test_phigrape.py プロジェクト: mherkazandjian/amuse
    def test7(self):
        instance = PhiGRAPEInterface(**default_test_options)#(debugger="xterm")
        instance.initialize_code()
        
        instance.set_eps2(0.0**2)
        instance.set_eta(0.01,0.02)
        instance.commit_parameters()

        instance.new_particle( 
            [1.0,1.0,1.0],
            [1.0,0.0,-1.0],
            [0.0,0.0,0.0],
            [0.0,0.0,0.0],
            [0.0,1.0,0.0],
            [0.0,0.0,0.0],
            [0.0,0.0,0.0] )
        instance.recommit_particles()
        Ep=instance.get_potential_energy()['potential_energy']
        Ek=instance.get_kinetic_energy()['kinetic_energy']
        self.assertEqual( Ek, 0.5)
        self.assertEqual( Ep, -2.5)    
        instance.delete_particle(2)
        instance.recommit_particles()
        n=instance.get_number_of_particles()['number_of_particles']
        Ep=instance.get_potential_energy()['potential_energy']
        Ek=instance.get_kinetic_energy()['kinetic_energy']
    
        self.assertEqual( n, 2)
        self.assertEqual( Ek, 0.)
        self.assertEqual( Ep, -0.5)    
    
        instance.cleanup_code()
        instance.stop()
コード例 #4
0
    def test7(self):
        instance = PhiGRAPEInterface(**default_test_options)#(debugger="xterm")
        instance.initialize_code()
        
        instance.set_eps2(0.0**2)
        instance.set_eta(0.01,0.02)
        instance.commit_parameters()

        instance.new_particle( 
            [1.0,1.0,1.0],
            [1.0,0.0,-1.0],
            [0.0,0.0,0.0],
            [0.0,0.0,0.0],
            [0.0,1.0,0.0],
            [0.0,0.0,0.0],
            [0.0,0.0,0.0] )
        instance.recommit_particles()
        Ep=instance.get_potential_energy()['potential_energy']
        Ek=instance.get_kinetic_energy()['kinetic_energy']
        self.assertEqual( Ek, 0.5)
        self.assertEqual( Ep, -2.5)    
        instance.delete_particle(2)
        instance.recommit_particles()
        n=instance.get_number_of_particles()['number_of_particles']
        Ep=instance.get_potential_energy()['potential_energy']
        Ek=instance.get_kinetic_energy()['kinetic_energy']
    
        self.assertEqual( n, 2)
        self.assertEqual( Ek, 0.)
        self.assertEqual( Ep, -0.5)    
    
        instance.cleanup_code()
        instance.stop()
コード例 #5
0
ファイル: test_phigrape.py プロジェクト: mherkazandjian/amuse
 def test1(self):
     instance = PhiGRAPEInterface(**default_test_options)
     instance.initialize_code()
     instance.new_particle(11.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0)
     retrieved_state = instance.get_state(1)
     self.assertEquals(11.0,  retrieved_state['mass'])
     self.assertEquals(2.0, retrieved_state['radius'])
     self.assertEquals(instance.get_number_of_particles()['number_of_particles'], 1)
     instance.cleanup_code()
     instance.stop()
コード例 #6
0
 def test1(self):
     instance = PhiGRAPEInterface(**default_test_options)
     instance.initialize_code()
     instance.new_particle(11.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0)
     retrieved_state = instance.get_state(1)
     self.assertEquals(11.0,  retrieved_state['mass'])
     self.assertEquals(2.0, retrieved_state['radius'])
     self.assertEquals(instance.get_number_of_particles()['number_of_particles'], 1)
     instance.cleanup_code()
     instance.stop()
コード例 #7
0
ファイル: test_phigrape.py プロジェクト: mherkazandjian/amuse
 def test5(self):
     instance = PhiGRAPEInterface(**default_test_options)
     instance.initialize_code()
     n = 4000
     ids = [i for i in range(1,n)]
     values = [1.0 * i for i in range(1,n)]
     instance.new_particle(
           values
         , values
         , values
         , values
         , values
         , values
         , values)
     retrieved_state = instance.get_state(3999)
     self.assertEquals(3999.0,  retrieved_state['mass'])
     instance.cleanup_code()
     instance.stop()
コード例 #8
0
 def test5(self):
     instance = PhiGRAPEInterface(**default_test_options)
     instance.initialize_code()
     n = 4000
     ids = [i for i in range(1,n)]
     values = [1.0 * i for i in range(1,n)]
     instance.new_particle(
           values
         , values
         , values
         , values
         , values
         , values
         , values)
     retrieved_state = instance.get_state(3999)
     self.assertEquals(3999.0,  retrieved_state['mass'])
     instance.cleanup_code()
     instance.stop()
コード例 #9
0
ファイル: test_phigrape.py プロジェクト: mherkazandjian/amuse
 def test3(self):
     instance = PhiGRAPEInterface(**default_test_options)
     instance.initialize_code()
     
     instance.new_particle([11.0,12.0,13.0,14.0]
         , [2.1,3.1,4.1,5.1]
         , [2.2,3.2,4.2,5.2]
         , [2.3,3.3,4.3,5.3]
         , [2.4,3.4,4.4,5.4]
         , [2.5,3.5,4.5,5.5]
         , [2.6,3.6,4.6,5.6]
         , [2.0,3.0,4.0,5.0])
     retrieved_state = instance.get_state(1)
     self.assertEquals(11.0,  retrieved_state['mass'])
     retrieved_state = instance.get_state([2,3,4])
     self.assertEquals(12.0,  retrieved_state['mass'][0])
     self.assertEquals(instance.get_number_of_particles()['number_of_particles'], 4)
     instance.cleanup_code()
     instance.stop()
コード例 #10
0
 def test3(self):
     instance = PhiGRAPEInterface(**default_test_options)
     instance.initialize_code()
     
     instance.new_particle([11.0,12.0,13.0,14.0]
         , [2.1,3.1,4.1,5.1]
         , [2.2,3.2,4.2,5.2]
         , [2.3,3.3,4.3,5.3]
         , [2.4,3.4,4.4,5.4]
         , [2.5,3.5,4.5,5.5]
         , [2.6,3.6,4.6,5.6]
         , [2.0,3.0,4.0,5.0])
     retrieved_state = instance.get_state(1)
     self.assertEquals(11.0,  retrieved_state['mass'])
     retrieved_state = instance.get_state([2,3,4])
     self.assertEquals(12.0,  retrieved_state['mass'][0])
     self.assertEquals(instance.get_number_of_particles()['number_of_particles'], 4)
     instance.cleanup_code()
     instance.stop()
コード例 #11
0
ファイル: test_phigrape.py プロジェクト: mherkazandjian/amuse
 def test8(self):
     instance = PhiGRAPEInterface(**default_test_options)
     instance.initialize_code()
     instance.set_eps2(0.1**2)
     instance.commit_parameters()
     id1,errorcode = instance.new_particle(mass = 10.0, radius = 1.0, 
         x = 0.0, y = 0.0, z = 0.0, vx = 0.0, vy = 0.0, vz = 0.0)
     id2,errorcode = instance.new_particle(mass = 10.0, radius = 1.0, 
         x = 2.0, y = 0.0, z = 0.0, vx = 10.0, vy = 0.0, vz = 0.0)
     
     instance.commit_particles()
     potential, errorcode = instance.get_potential(id1)
     self.assertEquals(errorcode, 0)
     self.assertAlmostRelativeEquals(potential, -10.0 / numpy.sqrt(2.0**2 + 0.1**2), 6)
     total_potential, errorcode = instance.get_potential_energy()
     self.assertEquals(errorcode, 0)
     potentials, errorcode = instance.get_potential([id1, id2])
     instance.cleanup_code()
     instance.stop()
     self.assertEquals(errorcode, 0)
     self.assertAlmostRelativeEquals(total_potential, numpy.sum(potentials * [10.0, 10.0]) / 2.0)
コード例 #12
0
 def test8(self):
     instance = PhiGRAPEInterface(**default_test_options)
     instance.initialize_code()
     instance.set_eps2(0.1**2)
     instance.commit_parameters()
     id1,errorcode = instance.new_particle(mass = 10.0, radius = 1.0, 
         x = 0.0, y = 0.0, z = 0.0, vx = 0.0, vy = 0.0, vz = 0.0)
     id2,errorcode = instance.new_particle(mass = 10.0, radius = 1.0, 
         x = 2.0, y = 0.0, z = 0.0, vx = 10.0, vy = 0.0, vz = 0.0)
     
     instance.commit_particles()
     potential, errorcode = instance.get_potential(id1)
     self.assertEquals(errorcode, 0)
     self.assertAlmostRelativeEquals(potential, -10.0 / numpy.sqrt(2.0**2 + 0.1**2), 6)
     total_potential, errorcode = instance.get_potential_energy()
     self.assertEquals(errorcode, 0)
     potentials, errorcode = instance.get_potential([id1, id2])
     instance.cleanup_code()
     instance.stop()
     self.assertEquals(errorcode, 0)
     self.assertAlmostRelativeEquals(total_potential, numpy.sum(potentials * [10.0, 10.0]) / 2.0)