Ejemplo n.º 1
0
    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'])
Ejemplo n.º 2
0
    def test_imaginary_energies(self, n2_unstable_data):
        vib_data = VibrationsData(n2_unstable_data['atoms'],
                                  n2_unstable_data['hessian'])

        assert vib_data.tabulate() == ('\n'.join(
            VibrationsData._tabulate_from_energies(vib_data.get_energies())) +
                                       '\n')
Ejemplo n.º 3
0
 def test_imaginary_energies(self, n2_unstable_data):
     vib_data = VibrationsData(n2_unstable_data['atoms'],
                               n2_unstable_data['hessian'])
     assert vib_data.tabulate() == unstable_n2_log