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.linCoupledHosc(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([100, 50, 0, -50, -100]) 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_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_energies(self): ha = pot.harmonicOsc(k=1.0, x_shift=-5.0) hb = pot.harmonicOsc(k=1.0, x_shift=5.0) potential = pot.linCoupledHosc(ha=ha, hb=hb, lam=0) positions = np.linspace(-10, 10, num=5) # energies only for pot HA lam1 = 0 expected_result1 = np.array([12.5, 0, 12.5, 50, 112.5]) potential.set_lam(lam=lam1) energies = potential.ene(positions) #print(energies) self.assertEqual( type(expected_result1), type(energies), msg= "returnType of potential was not correct! it should be an np.array" ) np.testing.assert_almost_equal( desired=expected_result1, actual=energies, err_msg="The results of " + potential.name + " are not correct wit lambda " + str(lam1) + "!\n\tPositions: " + str(positions) + "\n\tEnergies: " + str(energies), decimal=2) # energies only for pot HB lam2 = 1 expected_result2 = np.array([112.5, 50, 12.5, 0, 12.5]) potential.set_lam(lam=lam2) energies = potential.ene(positions) self.assertEqual( type(expected_result2), type(energies), msg= "returnType of potential was not correct! it should be an np.array" ) np.testing.assert_almost_equal( desired=expected_result2, actual=energies, err_msg="The results of " + potential.name + " are not correct wit lambda " + str(lam2) + "!\n\tPositions: " + str(positions) + "\n\tEnergies: " + str(energies), decimal=2) # energies merged for pot HB and HA lam3 = 0.5 expected_result3 = np.array([62.5, 25, 12.5, 25, 62.5]) potential.set_lam(lam=lam3) energies = potential.ene(positions) self.assertEqual( type(expected_result3), type(energies), msg= "returnType of potential was not correct! it should be an np.array" ) np.testing.assert_almost_equal( desired=expected_result3, actual=energies, err_msg="The results of " + potential.name + " are not correct wit lambda " + str(lam3) + "!\n\tPositions: " + str(positions) + "\n\tEnergies: " + str(energies), decimal=2)
def test_constructor(self): potential = pot.linCoupledHosc()