def test_energies_and_modes(self, n2_data): vib_data = VibrationsData(n2_data['atoms'], n2_data['hessian']) energies, modes = vib_data.get_energies_and_modes() assert_array_almost_equal(n2_data['ref_frequencies'], energies / units.invcm, decimal=5) assert_array_almost_equal(n2_data['ref_frequencies'], vib_data.get_energies() / units.invcm, decimal=5) assert_array_almost_equal(n2_data['ref_frequencies'], vib_data.get_frequencies(), decimal=5) assert (vib_data.get_zero_point_energy() == pytest.approx( n2_data['ref_zpe'])) assert vib_data.tabulate() == vibrations_n2_log atoms_with_forces = vib_data.show_as_force(-1, show=False) try: assert_array_almost_equal(atoms_with_forces.get_forces(), n2_data['ref_forces']) except AssertionError: # Eigenvectors may be off by a sign change, which is allowed assert_array_almost_equal(atoms_with_forces.get_forces(), -n2_data['ref_forces'])
def test_zero_mass(self, n2_data): atoms = n2_data['atoms'] atoms.set_masses([0., 1.]) vib_data = VibrationsData(atoms, n2_data['hessian']) with pytest.raises(ValueError): vib_data.get_energies_and_modes()