示例#1
0
文件: test_fdps.py 项目: rieder/amuse
    def test2(self):
        instance = FDPSInterface()
        instance.initialize_code()

        instance.commit_parameters()
        for i in [0, 1, 2]:
            temp_particle = instance.new_particle(mass = i, radius = 1.0, x = 0.0, y = 0.0, z = 0.0, vx = 0.0, vy = 0.0, vz = 0.0)
            self.assertEquals(i, temp_particle['index_of_the_particle'])
        
        instance.commit_particles()
        self.assertEquals(0, instance.get_index_of_first_particle()['index_of_the_particle'])
        self.assertEquals(1, instance.get_index_of_next_particle(0)['index_of_the_next_particle']) 
        self.assertEquals(2, instance.get_index_of_next_particle(1)['index_of_the_next_particle'])
            
        instance.delete_particle(0)
      
        self.assertEquals(2, instance.get_number_of_particles()['number_of_particles'])
        
        #the deletion moves all next particles one id down, so 2 is copied to 1, and 1 to 0
        self.assertEquals(1, instance.get_index_of_first_particle()['index_of_the_particle'])
        
        self.assertEquals(1, instance.get_index_of_next_particle(2)['__result'])

        instance.cleanup_code()
        instance.stop()
示例#2
0
文件: test_fdps.py 项目: rieder/amuse
    def test5(self):
        interface = FDPSInterface()
        interface.initialize_code()
        
        interface.commit_parameters()
        interface.new_particle([10,20],[0,0],[0,0], [0,0], [0,0], [0,0], [0,0],[1,1])
        interface.commit_particles()
        retrieved_state = interface.get_state(0)
        
        self.assertEquals(10.0,  retrieved_state['mass'])
        self.assertEquals(1, retrieved_state['radius'])

        retrieved_state = interface.get_state([0,1])
        self.assertEquals(20.0,  retrieved_state['mass'][1])
        self.assertEquals(interface.get_number_of_particles()['number_of_particles'], 2)
        interface.cleanup_code()
        interface.stop()