Exemplo n.º 1
0
    def test_vibrations_on_surface(self, testdir):
        atoms = self.n2_on_ag.copy()
        atoms.calc = EMT()
        vibs = Vibrations(atoms, indices=[-2, -1])
        vibs.run()

        freqs = vibs.get_frequencies()

        vib_data = vibs.get_vibrations()
        assert_array_almost_equal(freqs, vib_data.get_frequencies())
Exemplo n.º 2
0
    def test_consistency_with_vibrationsdata(self, testdir, n2_emt):
        atoms = n2_emt
        vib = Vibrations(atoms)
        vib.run()
        vib_data = vib.get_vibrations()

        assert_array_almost_equal(vib.get_energies(), vib_data.get_energies())

        # Compare the last mode as the others may be re-ordered by negligible
        # energy changes
        assert_array_almost_equal(vib.get_mode(5), vib_data.get_modes()[5])
Exemplo n.º 3
0
    def test_consistency_with_vibrationsdata(self, testdir, random_dimer):
        vib = Vibrations(random_dimer, delta=1e-6, nfree=4)
        vib.run()
        vib_data = vib.get_vibrations()

        assert_array_almost_equal(vib.get_energies(), vib_data.get_energies())

        for mode_index in range(3 * len(vib.atoms)):
            assert_array_almost_equal(vib.get_mode(mode_index),
                                      vib_data.get_modes()[mode_index])

        # Hessian should be close to the ForceConstantCalculator input
        assert_array_almost_equal(random_dimer.calc.D,
                                  vib_data.get_hessian_2d(),
                                  decimal=6)
Exemplo n.º 4
0
    def test_vibration_on_surface(self, testdir):
        from ase.build import fcc111, add_adsorbate
        ag_slab = fcc111('Ag', (4, 4, 2), a=2)
        n2 = Atoms('N2',
                   positions=[[0., 0., 0.], [0., np.sqrt(2),
                                             np.sqrt(2)]])
        add_adsorbate(ag_slab, n2, height=1, position='fcc')

        # Add an interaction between the N atoms
        hessian_bottom_corner = np.zeros((2, 3, 2, 3))
        hessian_bottom_corner[-1, :, -2] = [1, 1, 1]
        hessian_bottom_corner[-2, :, -1] = [1, 1, 1]

        hessian = np.zeros((34, 3, 34, 3))
        hessian[32:, :, 32:, :] = hessian_bottom_corner

        ag_slab.calc = ForceConstantCalculator(hessian.reshape(
            (34 * 3, 34 * 3)),
                                               ref=ag_slab.copy(),
                                               f0=np.zeros((34, 3)))

        # Check that Vibrations with restricted indices returns correct Hessian
        vibs = Vibrations(ag_slab, indices=[-2, -1])
        vibs.run()
        vibs.read()

        assert_array_almost_equal(vibs.get_vibrations().get_hessian(),
                                  hessian_bottom_corner)

        # These should blow up if the vectors don't match number of atoms
        vibs.summary()
        vibs.write_jmol()

        for i in range(6):
            # Frozen atoms should have zero displacement
            assert_array_almost_equal(vibs.get_mode(i)[0], [0., 0., 0.])

            # The N atoms should have finite displacement
            assert np.all(vibs.get_mode(i)[-2:, :])
Exemplo n.º 5
0
    def test_vibrations_on_surface(self, testdir):
        atoms = self.n2_on_ag.copy()
        atoms.calc = EMT()
        vibs = Vibrations(atoms, indices=[-2, -1])
        vibs.run()

        freqs = vibs.get_frequencies()
        assert len(freqs) == 6

        vib_data = vibs.get_vibrations()
        assert_array_almost_equal(freqs, vib_data.get_frequencies())

        # These should blow up if the vectors don't match number of atoms
        vibs.summary()
        vibs.write_jmol()

        for i in range(6):
            # Frozen atoms should have zero displacement
            assert_array_almost_equal(vibs.get_mode(i)[0], [0., 0., 0.])

            # At least one of the N atoms should have finite displacement
            # (It's a strange test system, the N aren't interacting.)

            assert np.any(vibs.get_mode(i)[-2:, :])