Beispiel #1
0
    def test2(self):
        instance = SmallNInterface()
        instance.initialize_code()
        self.skip("index of the next particle not implemented correctly yet")
        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.assertEqual(i + 1, temp_particle['index_of_the_particle'])

        instance.delete_particle(2)

        self.assertEqual(
            2,
            instance.get_number_of_particles()['number_of_particles'])

        self.assertEqual(
            1,
            instance.get_index_of_first_particle()['index_of_the_particle'])

        self.assertEqual(
            2,
            instance.get_index_of_next_particle(1)
            ['index_of_the_next_particle'])
        self.assertEqual(0, instance.get_index_of_next_particle(1)['__result'])
        self.assertEqual(-1,
                         instance.get_index_of_next_particle(3)['__result'])
        self.assertEqual(1, instance.get_index_of_next_particle(2)['__result'])
        instance.cleanup_code()
        instance.stop()
Beispiel #2
0
 def test5(self):
     smalln = SmallNInterface()
     smalln.initialize_code()
     
     smalln.new_particle([10,20],[0,0],[0,0], [0,0], [0,0], [0,0], [0,0],[1,1])
     retrieved_state = smalln.get_state(1)
     
     self.assertEquals(10.0,  retrieved_state['mass'])
     self.assertEquals(1, retrieved_state['radius'])
 
     retrieved_state = smalln.get_state([1,2])
     self.assertEquals(20.0,  retrieved_state['mass'][1])
     self.assertEquals(smalln.get_number_of_particles()['number_of_particles'], 2)
     smalln.cleanup_code() 
     smalln.stop()
Beispiel #3
0
    def test5(self):
        smalln = SmallNInterface()
        smalln.initialize_code()

        smalln.new_particle([10, 20], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
                            [0, 0], [1, 1])
        retrieved_state = smalln.get_state(1)

        self.assertEqual(10.0, retrieved_state['mass'])
        self.assertEqual(1, retrieved_state['radius'])

        retrieved_state = smalln.get_state([1, 2])
        self.assertEqual(20.0, retrieved_state['mass'][1])
        self.assertEqual(
            smalln.get_number_of_particles()['number_of_particles'], 2)
        smalln.cleanup_code()
        smalln.stop()
Beispiel #4
0
 def test2(self):
     instance = SmallNInterface()
     instance.initialize_code()
     self.skip("index of the next particle not implemented correctly yet")
     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+1, temp_particle['index_of_the_particle'])
         
     instance.delete_particle(2)
   
     self.assertEquals(2, instance.get_number_of_particles()['number_of_particles'])
     
     self.assertEquals(1, instance.get_index_of_first_particle()['index_of_the_particle'])
     
     self.assertEquals(2, instance.get_index_of_next_particle(1)['index_of_the_next_particle'])
     self.assertEquals(0, instance.get_index_of_next_particle(1)['__result'])
     self.assertEquals(-1, instance.get_index_of_next_particle(3)['__result'])
     self.assertEquals(1, instance.get_index_of_next_particle(2)['__result'])
     instance.stop()