예제 #1
0
 def test3(self):
     fastkick = FastKickInterface(mode=self.mode, number_of_workers=self.number_of_workers)
     fastkick.initialize_code()
     fastkick.new_particle([10,10],[-1,1],[0,0], [0,0])
     self.assertEquals(0, fastkick.commit_particles())
     self.assertEqual([-20.0, 0], fastkick.get_potential_at_point(0, 0,0,0).values())
     self.assertAlmostEqual(-10.0*math.sqrt(2.0), fastkick.get_potential_at_point(1.0, 0,0,0).values()[0], 4)
     fastkick.cleanup_code()
     fastkick.stop()
예제 #2
0
 def test1(self):
     instance = FastKickInterface(mode=self.mode, number_of_workers=self.number_of_workers)
     instance.initialize_code()
     id1, error1 = instance.new_particle(mass = 11.0, x = 0.0, y = 0.0, z = 0.0)
     id2, error2 = instance.new_particle(mass = 21.0, x = 10.0, y = 0.0, z = 0.0)
     self.assertEquals(0, id1)
     self.assertEquals(0, error1)
     self.assertEquals(1, id2)
     self.assertEquals(0, error2)
     self.assertEquals(0, instance.commit_particles())
     self.assertEquals(0, instance.cleanup_code())
     instance.stop()
예제 #3
0
 def test1(self):
     instance = FastKickInterface(mode=self.mode,
                                  number_of_workers=self.number_of_workers)
     instance.initialize_code()
     id1, error1 = instance.new_particle(mass=11.0, x=0.0, y=0.0, z=0.0)
     id2, error2 = instance.new_particle(mass=21.0, x=10.0, y=0.0, z=0.0)
     self.assertEqual(0, id1)
     self.assertEqual(0, error1)
     self.assertEqual(1, id2)
     self.assertEqual(0, error2)
     self.assertEqual(0, instance.commit_particles())
     self.assertEqual(0, instance.cleanup_code())
     instance.stop()
예제 #4
0
 def test3(self):
     fastkick = FastKickInterface(mode=self.mode,
                                  number_of_workers=self.number_of_workers)
     fastkick.initialize_code()
     fastkick.new_particle([10, 10], [-1, 1], [0, 0], [0, 0])
     self.assertEquals(0, fastkick.commit_particles())
     self.assertEqual([-20.0, 0],
                      fastkick.get_potential_at_point(0, 0, 0, 0).values())
     self.assertAlmostEqual(
         -10.0 * math.sqrt(2.0),
         fastkick.get_potential_at_point(1.0, 0, 0, 0).values()[0], 4)
     fastkick.cleanup_code()
     fastkick.stop()
예제 #5
0
    def test4(self):
        numpy.random.seed(12345)
        plummer = new_plummer_model(100)
        fastkick = FastKickInterface(mode=self.mode,
                                     number_of_workers=self.number_of_workers)
        fastkick.initialize_code()
        fastkick.new_particle([1] * 100, plummer.x.number, plummer.y.number,
                              plummer.z.number)
        self.assertEqual(0, fastkick.commit_particles())
        points = new_plummer_model(73)
        potential1, error = fastkick.get_potential_at_point([0] * 73,
                                                            points.x.number,
                                                            points.y.number,
                                                            points.z.number)
        ax1, ay1, az1, error = fastkick.get_gravity_at_point([0] * 73,
                                                             points.x.number,
                                                             points.y.number,
                                                             points.z.number)
        fastkick.cleanup_code()

        fastkick.initialize_code()
        self.assertEqual(0, fastkick.commit_particles())
        potential0, error = fastkick.get_potential_at_point([0] * 73,
                                                            points.x.number,
                                                            points.y.number,
                                                            points.z.number)
        ax0, ay0, az0, error = fastkick.get_gravity_at_point([0] * 73,
                                                             points.x.number,
                                                             points.y.number,
                                                             points.z.number)
        self.assertAlmostEqual(potential0, 0)
        self.assertAlmostEqual(ax0, 0)
        self.assertAlmostEqual(ay0, 0)
        self.assertAlmostEqual(az0, 0)
        fastkick.cleanup_code()

        fastkick.initialize_code()
        for p in plummer:
            fastkick.new_particle(1, p.x.number, p.y.number, p.z.number)
        self.assertEqual(0, fastkick.commit_particles())
        potential2, error = fastkick.get_potential_at_point([0] * 73,
                                                            points.x.number,
                                                            points.y.number,
                                                            points.z.number)
        ax2, ay2, az2, error = fastkick.get_gravity_at_point([0] * 73,
                                                             points.x.number,
                                                             points.y.number,
                                                             points.z.number)
        self.assertAlmostEqual(potential1, potential2, 4)
        self.assertAlmostEqual(ax1, ax2, 4)
        self.assertAlmostEqual(ay1, ay2, 4)
        self.assertAlmostEqual(az1, az2, 4)
        fastkick.cleanup_code()
        fastkick.stop()
예제 #6
0
 def test4(self):
     numpy.random.seed(12345)
     plummer = new_plummer_model(100)
     fastkick = FastKickInterface(mode=self.mode, number_of_workers=self.number_of_workers)
     fastkick.initialize_code()
     fastkick.new_particle([1]*100, plummer.x.number, plummer.y.number, plummer.z.number)
     self.assertEquals(0, fastkick.commit_particles())
     points = new_plummer_model(73)
     potential1, error = fastkick.get_potential_at_point([0]*73, 
         points.x.number, points.y.number, points.z.number)
     ax1, ay1, az1, error = fastkick.get_gravity_at_point([0]*73, 
         points.x.number, points.y.number, points.z.number)
     fastkick.cleanup_code()
     
     fastkick.initialize_code()
     self.assertEquals(0, fastkick.commit_particles())
     potential0, error = fastkick.get_potential_at_point([0]*73, 
         points.x.number, points.y.number, points.z.number)
     ax0, ay0, az0, error = fastkick.get_gravity_at_point([0]*73, 
         points.x.number, points.y.number, points.z.number)
     self.assertAlmostEqual(potential0, 0)
     self.assertAlmostEqual(ax0, 0)
     self.assertAlmostEqual(ay0, 0)
     self.assertAlmostEqual(az0, 0)
     fastkick.cleanup_code()
     
     fastkick.initialize_code()
     for p in plummer:
         fastkick.new_particle(1, p.x.number, p.y.number, p.z.number)
     self.assertEquals(0, fastkick.commit_particles())
     potential2, error = fastkick.get_potential_at_point([0]*73, 
         points.x.number, points.y.number, points.z.number)
     ax2, ay2, az2, error = fastkick.get_gravity_at_point([0]*73, 
         points.x.number, points.y.number, points.z.number)
     self.assertAlmostEqual(potential1, potential2, 4)
     self.assertAlmostEqual(ax1, ax2, 4)
     self.assertAlmostEqual(ay1, ay2, 4)
     self.assertAlmostEqual(az1, az2, 4)
     fastkick.cleanup_code()
     fastkick.stop()