Exemple #1
0
 def test_pdos(self, n2_data):
     vib_data = VibrationsData(n2_data['atoms'], n2_data['hessian'])
     with pytest.warns(np.ComplexWarning):
         pdos = vib_data.get_pdos()
     assert_array_almost_equal(pdos[0].get_energies(),
                               vib_data.get_energies())
     assert_array_almost_equal(pdos[1].get_energies(),
                               vib_data.get_energies())
     assert sum(pdos[0].get_weights()) == pytest.approx(3.0)
Exemple #2
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'])
Exemple #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() == ('\n'.join(
            VibrationsData._tabulate_from_energies(vib_data.get_energies())) +
                                       '\n')
Exemple #4
0
 def test_new_mass(self, n2_data):
     vib_data = VibrationsData(n2_data['atoms'], n2_data['hessian'])
     original_masses = vib_data.get_atoms().get_masses()
     new_masses = original_masses * 3
     new_vib_data = vib_data.with_new_masses(new_masses)
     assert_array_almost_equal(new_vib_data.get_atoms().get_masses(),
                               new_masses)
     assert_array_almost_equal(vib_data.get_energies() / np.sqrt(3),
                               new_vib_data.get_energies())
Exemple #5
0
 def test_dos(self, n2_data):
     vib_data = VibrationsData(n2_data['atoms'], n2_data['hessian'])
     with pytest.warns(np.ComplexWarning):
         dos = vib_data.get_dos()
     assert_array_almost_equal(dos.get_energies(), vib_data.get_energies())