Exemple #1
0
    def test9(self):
        instance = PhiGRAPEInterface(**default_test_options)
        instance.initialize_code()
        instance.set_eps2(0)
        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=1.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.assertEqual(errorcode, 0)
        self.assertAlmostRelativeEquals(potential, -1.0 / numpy.sqrt(2.0**2),
                                        8)
        total_potential, errorcode = instance.get_potential_energy()
        potentials, errorcode = instance.get_potential([id1, id2])
        instance.cleanup_code()
        instance.stop()

        self.assertAlmostRelativeEquals(
            total_potential,
            numpy.sum(potentials * [10.0, 1.0]) / 2.0)
Exemple #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()