Ejemplo n.º 1
0
    def test8(self):
        instance = HermiteInterface()
        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)
Ejemplo n.º 2
0
 def test3(self):
     hermite = HermiteInterface()
     self.assertEqual(0, hermite.set_eps2(0.101))
     self.assertEqual([0.101, 0], list(hermite.get_eps2().values()))
     self.assertEqual(0, hermite.set_eps2(0.2))
     self.assertEqual([0.2, 0], list(hermite.get_eps2().values()))
     hermite.cleanup_code()
     hermite.stop()