Siesta 2: Molecular Dynamics — ASE documentation

### Navigation

- index
- modules |
- Tutorials »
- Exercises »

# Siesta 2: Molecular Dynamics

This exercise is intended to illustrate a Molecular Dynamics run with the SIESTA calculator. The system is a Si(001) surface, in the 2x1 reconstruction with asymmetric dimers. The simulation cell contains two dimers. An H2 molecule approaches the surface, above one of the dimers, and dissociates, ending up with a H atom bonded to each of the Si atoms in the dimer (and thus leading to a symmetric dimer). You can get the `xyz` file with the initial geometry doc/exercises/siesta2/geom.xyz.

    from ase.io import read
    from ase.constraints import FixAtoms
    from ase.calculators.siesta import Siesta
    from ase.md import VelocityVerlet
    from ase import units

    # Read in the geometry from a xyz file, set the cell, boundary conditions and center
    atoms = read('geom.xyz')
    atoms.set_cell([7.66348,7.66348,7.66348*2])
    atoms.set_pbc((1,1,1))
    atoms.center()

    # Set initial velocities for hydrogen atoms along the z-direction
    p = atoms.get_momenta()
    p[0,2]= -1.5
    p[1,2]= -1.5
    atoms.set_momenta(p)

    # Keep some atoms fixed during the simulation
    atoms.set_constraint(FixAtoms(indices=range(18, 38)))

    # Set the calculator and attach it to the system
    calc = Siesta('si001+h2',basis='SZ',xc='PBE',meshcutoff=50*units.Ry)
    calc.set_fdf('PAO.EnergyShift', 0.25 * units.eV)
    calc.set_fdf('PAO.SplitNorm', 0.15)
    atoms.set_calculator(calc)

    # Set the VelocityVerlet algorithm and run it
    dyn = VelocityVerlet(atoms,dt=1.0 * units.fs,trajectory='si001+h2.traj')
    dyn.run(steps=100)

Note that both H atoms are given an initial velocity towards the surface through the lines:

    p = atoms.get_momenta()
    p[0,2]= -1.5
    p[1,2]= -1.5
    atoms.set_momenta(p)

Run the program, and check the results. You can visualize the dynamics using the trajectory file with the help of the ASE `gui`. For example you can visualize the behaviour of the potential and total energies during the dynamics by doing:

    $ ase-gui -b si001+h2.traj -g i,e,e+ekin

The -b option turns on plotting of bonds between the atoms. Check that the total energy is a conserved quantity in this microcanonical simulation.

You can also use VMD to visualize the trajectory. To do this, you need a `.xyz` file that you can write using ase-gui:

    $ ase-gui si001+h2.traj -o si.xyz -r 2,2,1

Then simply open the file using VMD:

    $ vmd si.xyz

and set Graphics/Representations from the main menu in order to get a nice picture.

You can also try to repeat the simulation with a different `dynamics`. For instance you can model a canonical ensemble with the Langevin dynamics, which couples the system to a heat bath:

    dyn = Langevin(atoms, 1 * fs, kB * 300, 0.002, trajectory=traj)

### Navigation

- index
- modules |
- Tutorials »
- Exercises »