Exemplo n.º 1
0
    def test4(self):
        instance = MikkolaInterface()
        instance.initialize_code()
        instance.set_lightspeed(1e4)
        instance.commit_parameters()

        index1, error = instance.new_particle(mass=1.0,
                                              radius=0,
                                              x=1.0,
                                              y=2.0,
                                              z=3.0,
                                              vx=1.1,
                                              vy=2.2,
                                              vz=3.3)
        self.assertEqual(error, 0)
        self.assertEqual(index1, 1)

        instance.commit_particles()

        error = instance.cleanup_code()
        self.assertEqual(error, 0)

        mass, error = instance.get_mass(1)
        self.assertEqual(error, -1)
        instance.commit_parameters()
        index1, error = instance.new_particle(mass=1.0,
                                              radius=0,
                                              x=1.0,
                                              y=2.0,
                                              z=3.0,
                                              vx=1.1,
                                              vy=2.2,
                                              vz=3.3)
        self.assertEqual(error, 0)
        self.assertEqual(index1, 1)
        instance.commit_particles()
        error = instance.cleanup_code()
        self.assertEqual(error, 0)
Exemplo n.º 2
0
    def test2(self):
        instance = MikkolaInterface()
        instance.initialize_code()
        instance.set_lightspeed(1e4)
        instance.commit_parameters()

        index1, error = instance.new_particle(mass=1.0,
                                              radius=0.1,
                                              x=1.0,
                                              y=2.0,
                                              z=3.0,
                                              vx=1.1,
                                              vy=2.2,
                                              vz=3.3)
        self.assertEqual(error, 0)
        index2, error = instance.new_particle(mass=0.001,
                                              radius=0.2,
                                              x=3.0,
                                              y=4.0,
                                              z=5.0,
                                              vx=3.3,
                                              vy=4.4,
                                              vz=5.5)
        self.assertEqual(error, 0)

        self.assertEqual(1, index1)
        self.assertEqual(2, index2)

        mass, error = instance.get_mass(1)
        self.assertEqual(error, 0)
        self.assertEqual(mass, 1.0)

        mass, error = instance.get_mass(2)
        self.assertEqual(error, 0)
        self.assertEqual(mass, 0.001)

        radius, error = instance.get_radius(1)
        self.assertEqual(error, 0)
        self.assertEqual(radius, 0.1)

        radius, error = instance.get_radius(2)
        self.assertEqual(error, 0)
        self.assertEqual(radius, 0.2)

        x, y, z, error = instance.get_position(1)
        self.assertEqual(error, 0)
        self.assertEqual(x, 1.0)
        self.assertEqual(y, 2.0)
        self.assertEqual(z, 3.0)

        x, y, z, error = instance.get_position(2)
        self.assertEqual(error, 0)
        self.assertEqual(x, 3.0)
        self.assertEqual(y, 4.0)
        self.assertEqual(z, 5.0)

        vx, vy, vz, error = instance.get_velocity(1)
        self.assertEqual(error, 0)
        self.assertEqual(vx, 1.1)
        self.assertEqual(vy, 2.2)
        self.assertEqual(vz, 3.3)

        instance.cleanup_code()
        instance.stop()
Exemplo n.º 3
0
    def test3(self):
        instance = MikkolaInterface()
        instance.initialize_code()
        instance.set_lightspeed(1e4)
        instance.commit_parameters()

        index1, error = instance.new_particle(mass=1.0,
                                              radius=0,
                                              x=1.0,
                                              y=2.0,
                                              z=3.0,
                                              vx=1.1,
                                              vy=2.2,
                                              vz=3.3)
        self.assertEqual(error, 0)
        index2, error = instance.new_particle(mass=0.001,
                                              radius=0,
                                              x=3.0,
                                              y=4.0,
                                              z=5.0,
                                              vx=3.3,
                                              vy=4.4,
                                              vz=5.5)
        self.assertEqual(error, 0)

        self.assertEqual(1, index1)
        self.assertEqual(2, index2)

        mass, error = instance.get_mass(1)
        self.assertEqual(error, 0)
        self.assertEqual(mass, 1.0)

        mass, error = instance.get_mass(2)
        self.assertEqual(error, 0)
        self.assertEqual(mass, 0.001)

        error = instance.delete_particle(1)
        mass, error = instance.get_mass(1)
        self.assertEqual(error, -1)

        index1, error = instance.new_particle(mass=2.0,
                                              radius=0,
                                              x=1.0,
                                              y=2.0,
                                              z=3.0,
                                              vx=1.1,
                                              vy=2.2,
                                              vz=3.3)
        self.assertEqual(error, 0)
        self.assertEqual(1, index1)

        mass, error = instance.get_mass(1)
        self.assertEqual(error, 0)
        self.assertEqual(mass, 2.0)

        mass, error = instance.get_mass(2)
        self.assertEqual(error, 0)
        self.assertEqual(mass, 0.001)
Exemplo n.º 4
0
    def test1(self):
        #        instance = MikkolaInterface(debugger="ddd")
        instance = MikkolaInterface()
        #instance = MikkolaInterface()
        instance.initialize_code()
        instance.set_lightspeed(1e4)
        instance.commit_parameters()

        res1 = instance.new_particle(mass=1.0,
                                     radius=0,
                                     x=0.0,
                                     y=0.0,
                                     z=0.0,
                                     vx=0.0,
                                     vy=0.0,
                                     vz=0.0)
        res2 = instance.new_particle(mass=0.001,
                                     radius=0,
                                     x=1.0,
                                     y=0.0,
                                     z=0.0,
                                     vx=0.0,
                                     vy=1.0,
                                     vz=0.0)

        self.assertEqual(1, res1['index_of_the_particle'])
        self.assertEqual(2, res2['index_of_the_particle'])

        retrieved_state1 = instance.get_state(1)
        retrieved_state2 = instance.get_state(2)

        end_time = 10.0
        instance.evolve_model(end_time)
        instance.cleanup_code()
        instance.stop()
Exemplo n.º 5
0
 def xtest0(self):
     instance = MikkolaInterface()
Exemplo n.º 6
0
    def test3(self):
        instance = MikkolaInterface()
        instance.initialize_code()
        instance.set_lightspeed(1e4)
        instance.commit_parameters()

        index1, error = instance.new_particle(mass = 1.0, radius = 0, x = 1.0, y = 2.0, z = 3.0, vx = 1.1, vy = 2.2, vz = 3.3)
        self.assertEquals(error, 0)
        index2, error = instance.new_particle(mass = 0.001, radius = 0, x = 3.0, y = 4.0, z = 5.0, vx = 3.3, vy = 4.4, vz = 5.5)
        self.assertEquals(error, 0)
        
        self.assertEquals(1, index1)
        self.assertEquals(2, index2)
        
        mass,error = instance.get_mass(1)
        self.assertEquals(error, 0)
        self.assertEquals(mass, 1.0)
                
        mass,error = instance.get_mass(2)
        self.assertEquals(error, 0)
        self.assertEquals(mass, 0.001)
        
        error  = instance.delete_particle(1)
        mass,error = instance.get_mass(1)
        self.assertEquals(error, -1)
        
        index1, error = instance.new_particle(mass = 2.0, radius = 0, x = 1.0, y = 2.0, z = 3.0, vx = 1.1, vy = 2.2, vz = 3.3)
        self.assertEquals(error, 0)
        self.assertEquals(1, index1)
        
        mass,error = instance.get_mass(1)
        self.assertEquals(error, 0)
        self.assertEquals(mass, 2.0)
                
        mass,error = instance.get_mass(2)
        self.assertEquals(error, 0)
        self.assertEquals(mass, 0.001)
Exemplo n.º 7
0
    def test2(self):
        instance = MikkolaInterface()
        instance.initialize_code()
        instance.set_lightspeed(1e4)
        instance.commit_parameters()

        index1, error = instance.new_particle(mass = 1.0, radius = 0.1, x = 1.0, y = 2.0, z = 3.0, vx = 1.1, vy = 2.2, vz = 3.3)
        self.assertEquals(error, 0)
        index2, error = instance.new_particle(mass = 0.001, radius = 0.2, x = 3.0, y = 4.0, z = 5.0, vx = 3.3, vy = 4.4, vz = 5.5)
        self.assertEquals(error, 0)
        
        self.assertEquals(1, index1)
        self.assertEquals(2, index2)
        
        mass,error = instance.get_mass(1)
        self.assertEquals(error, 0)
        self.assertEquals(mass, 1.0)
                
        mass,error = instance.get_mass(2)
        self.assertEquals(error, 0)
        self.assertEquals(mass, 0.001)
        
        
        radius,error = instance.get_radius(1)
        self.assertEquals(error, 0)
        self.assertEquals(radius, 0.1)
                
        radius,error = instance.get_radius(2)
        self.assertEquals(error, 0)
        self.assertEquals(radius, 0.2)
        
        
        x,y,z,error = instance.get_position(1)
        self.assertEquals(error, 0)
        self.assertEquals(x, 1.0)
        self.assertEquals(y, 2.0)
        self.assertEquals(z, 3.0)
                
        x,y,z,error = instance.get_position(2)
        self.assertEquals(error, 0)
        self.assertEquals(x, 3.0)
        self.assertEquals(y, 4.0)
        self.assertEquals(z, 5.0)
        
        vx,vy,vz,error = instance.get_velocity(1)
        self.assertEquals(error, 0)
        self.assertEquals(vx, 1.1)
        self.assertEquals(vy, 2.2)
        self.assertEquals(vz, 3.3)
    
        instance.cleanup_code()
        instance.stop()
Exemplo n.º 8
0
    def test1(self):
#        instance = MikkolaInterface(debugger="ddd")
        instance = MikkolaInterface()
        #instance = MikkolaInterface()
        instance.initialize_code()
        instance.set_lightspeed(1e4)
        instance.commit_parameters()

        res1 = instance.new_particle(mass = 1.0, radius = 0, x = 0.0, y = 0.0, z = 0.0, vx = 0.0, vy = 0.0, vz = 0.0)
        res2 = instance.new_particle(mass = 0.001, radius = 0, x = 1.0, y = 0.0, z = 0.0, vx = 0.0, vy = 1.0, vz = 0.0)
        
        self.assertEquals(1, res1['index_of_the_particle'])
        self.assertEquals(2, res2['index_of_the_particle'])
    
        retrieved_state1 = instance.get_state(1)
        retrieved_state2 = instance.get_state(2)
    
        end_time = 10.0 
        instance.evolve_model(end_time)
        instance.cleanup_code()
        instance.stop()
Exemplo n.º 9
0
    def test4(self):
        instance = MikkolaInterface()
        instance.initialize_code()
        instance.set_lightspeed(1e4)
        instance.commit_parameters()

        index1, error = instance.new_particle(mass = 1.0, radius = 0, x = 1.0, y = 2.0, z = 3.0, vx = 1.1, vy = 2.2, vz = 3.3)
        self.assertEquals(error, 0)
        self.assertEquals(index1, 1)
        
        instance.commit_particles()
        
        error = instance.cleanup_code()
        self.assertEquals(error, 0)
        
        mass,error = instance.get_mass(1)
        self.assertEquals(error, -1)
        instance.commit_parameters()
        index1, error = instance.new_particle(mass = 1.0, radius = 0, x = 1.0, y = 2.0, z = 3.0, vx = 1.1, vy = 2.2, vz = 3.3)
        self.assertEquals(error, 0)
        self.assertEquals(index1, 1)
        instance.commit_particles()
        error = instance.cleanup_code()
        self.assertEquals(error, 0)