Exemple #1
0
    def test_dHdlam(self):
        ha = pot.harmonicOsc(k=1.0, x_shift=-5.0)
        hb = pot.harmonicOsc(k=1.0, x_shift=5.0)
        potential = pot.expCoupledHosc(ha=ha, hb=hb, lam=0)

        positions = np.linspace(-10, 10, num=5)

        # energies only for pot HA
        lam = 0
        potential.set_lam(lam=lam)
        expected_result = np.array([
            4.009080e-001, 4.009080e-001, 0.000, -5.846620e+053, -8.526387e+107
        ])

        energies = potential.dhdlam(positions)

        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_allclose(desired=expected_result,
                                   actual=energies,
                                   err_msg="The results of " + potential.name +
                                   " are not correct wit lambda " + str(lam) +
                                   "!\n\tPositions: " + str(positions) +
                                   "\n\tEnergies: " + str(energies))
Exemple #2
0
    def test_energies(self):
        ha = pot.harmonicOsc(k=1.0, x_shift=-5.0)
        hb = pot.harmonicOsc(k=1.0, x_shift=5.0)
        potential = pot.expCoupledHosc(ha=ha, hb=hb, lam=0)

        positions = np.linspace(-10, 10, num=5)

        # energies only for pot HA
        lam = 0
        expected_result = np.array([12.5, 0, 12.5, 50, 112.5])

        potential.set_lam(lam=lam)
        energies = potential.ene(positions)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(
            desired=expected_result,
            actual=energies,
            err_msg="The results of " + potential.name +
            " are not correct wit lambda " + str(lam) + "!\n\tPositions: " +
            str(positions) + "\n\tEnergies: " + str(energies),
            decimal=2)

        # energies only for pot HB
        lam = 1
        expected_result = np.array([112.5, 50, 12.5, 0, 12.5])

        potential.set_lam(lam=lam)
        energies = potential.ene(positions)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(
            desired=expected_result,
            actual=energies,
            err_msg="The results of " + potential.name +
            " are not correct wit lambda " + str(lam) + "!\n\tPositions: " +
            str(positions) + "\n\tEnergies: " + str(energies),
            decimal=2)

        # energies merged for pot HB and HA
        lam = 0.5
        expected_result = np.array([12.78, 0.28, 12.5, 0.28, 12.78])

        potential.set_lam(lam=lam)
        energies = potential.ene(positions)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(
            desired=expected_result,
            actual=energies,
            err_msg="The results of " + potential.name +
            " are not correct wit lambda " + str(lam) + "!\n\tPositions: " +
            str(positions) + "\n\tEnergies: " + str(energies),
            decimal=2)
Exemple #3
0
    def test_dHdpos(self):
        ha = pot.harmonicOsc(k=1.0, x_shift=-5.0)
        hb = pot.harmonicOsc(k=1.0, x_shift=5.0)
        potential = pot.expCoupledHosc(ha=ha, hb=hb, lam=0)

        positions = np.linspace(-10, 10, num=5)

        #energies only for pot HA
        lam = 0
        potential.set_lam(lam=lam)
        expected_result = np.array([
            -1304235.5118838537, 0.0, 1.9168317203608185e-05,
            1.469697537672566e-10, 8.451488578640889e-16
        ])

        energies = potential.dhdpos(positions)
        ##print("GOT",  list(energies))
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        #np.testing.assert_almost_equal(desired=expected_result, actual=energies, err_msg="The results of "+potential.name+" are not correct wit lambda "+str(lam)+"!\n\tPositions: "+str(positions)+"\n\tEnergies: "+str(energies), decimal=2)

        #energies only for pot HB
        lam = 1
        expected_result = np.array([
            -2.6622529026263318e+17, -680412108183.5752, -1304235.5118838537,
            0.0, 1.9168317203608185e-05
        ])

        potential.set_lam(lam=lam)
        energies = potential.dhdpos(positions)

        ##print("GOT2",  list(energies))
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        #np.testing.assert_almost_equal(desired=expected_result, actual=energies, err_msg="The results of "+potential.name+" are not correct wit lambda "+str(lam)+"!\n\tPositions: "+str(positions)+"\n\tEnergies: "+str(energies), decimal=2)

        #energies merged for pot HB and HA
        lam = 0.5
        expected_result = np.array([
            -1.331126451319687e+17, -340206054091.7876, -652117.7559323427,
            7.34848768836283e-11, 9.584158602226667e-06
        ])

        potential.set_lam(lam=lam)
        energies = potential.dhdpos(positions)

        ##print("GOT3",  list(energies))
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(
            desired=expected_result,
            actual=energies,
            err_msg="The results of " + potential.name +
            " are not correct wit lambda " + str(lam) + "!\n\tPositions: " +
            str(positions) + "\n\tEnergies: " + str(energies),
            decimal=2)
Exemple #4
0
 def test_constructor(self):
     potential = pot.expCoupledHosc()