{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Surface diffusion energy barriers using the Nudged Elastic Band (NEB) method\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n\nfrom ase.build import add_adsorbate, fcc100\nfrom ase.calculators.emt import EMT\nfrom ase.constraints import FixAtoms\nfrom ase.io import read\nfrom ase.mep import NEB\nfrom ase.optimize import BFGS, QuasiNewton\nfrom ase.parallel import world\nfrom ase.visualize.plot import plot_atoms" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First, set up the initial and final states:\n2x2-Al(001) surface with 3 layers and an\nAu atom adsorbed in a hollow site:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "slab = fcc100('Al', size=(2, 2, 3))\nadd_adsorbate(slab, 'Au', 1.7, 'hollow')\nslab.center(axis=2, vacuum=4.0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Make sure the structure is correct:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "fig, ax = plt.subplots()\nplot_atoms(slab, ax)\nax.set_axis_off()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Fix second and third layers:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "mask = [atom.tag > 1 for atom in slab]\nprint(mask)\nslab.set_constraint(FixAtoms(mask=mask))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Use EMT potential:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "slab.calc = EMT()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Initial state:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "qn = QuasiNewton(slab, trajectory='initial.traj')\nqn.run(fmax=0.05)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Final state:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "slab[-1].x += slab.get_cell()[0, 0] / 2\nqn = QuasiNewton(slab, trajectory='final.traj')\nqn.run(fmax=0.05)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
Notice how the tags are used to select the constrained atoms
For this reaction, the reaction coordinate is very simple: The\n *x*-coordinate of the Au atom. In such cases, the NEB method is\n overkill, and a simple constraint method should be used like in this\n tutorial: `constraints diffusion tutorial`.