def test_dHdpos(self): fc = 1.0 alpha = 1.0 gamma = 0.0 lam = 0 potential = pot.pertHarmonicOsc(fc=fc, alpha=alpha, gamma=gamma, lam=lam) positions = np.linspace(-10, 10, num=5) #energies only for pot HA lam = 0 potential.set_lam(lam=lam) expected_result = np.array([-10, -5, 0, 5, 10]) energies = potential.dhdpos(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([-20, -10, 0, 10, 20]) potential.set_lam(lam=lam) energies = potential.dhdpos(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([-15, -7.5, 0, 7.5, 15]) potential.set_lam(lam=lam) energies = potential.dhdpos(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)
def test_constructor(self): potential = pot.pertHarmonicOsc()