ASE Manual Release 3.6.1.2825 CAMd - CampOS Wiki
ASE Manual Release 3.6.1.2825 CAMd - CampOS Wiki
ASE Manual Release 3.6.1.2825 CAMd - CampOS Wiki
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>ASE</strong> <strong>Manual</strong>, <strong>Release</strong> 3.6.1.2828<br />
We are going to use the <strong>ASE</strong> interface to the siesta calculator, for the official SIESTA documentation see here.<br />
Part 1: Standard basis sets<br />
In the following script you will relax the structure of the H2O molecule to find its equilibrium structure.<br />
import time<br />
import numpy as np<br />
from ase import Atoms, units<br />
from ase.optimize import QuasiNewton<br />
from ase.calculators.siesta import Siesta<br />
# Set up a H2O molecule by specifying atomic positions<br />
h2o = Atoms(symbols=’H2O’,<br />
positions=[( 0.776070, 0.590459, 0.00000),<br />
(-0.776070, 0.590459, 0.00000),<br />
(0.000000, -0.007702, -0.000001)],<br />
pbc=(1,1,1))<br />
# Center the molecule in the cell with some vacuum around<br />
h2o.center(vacuum=6.0)<br />
# Select some energy-shifts for the basis orbitals<br />
e_shifts = [0.01,0.1,0.2,0.3,0.4,0.5]<br />
# Run the relaxation for each energy shift, and print out the<br />
# corresponding total energy, bond length and angle<br />
for e_s in e_shifts:<br />
starttime = time.time()<br />
calc = Siesta(’h2o’,meshcutoff=200.0 * units.Ry, mix=0.5, pulay=4)<br />
calc.set_fdf(’PAO.EnergyShift’, e_s * units.eV)<br />
calc.set_fdf(’PAO.SplitNorm’, 0.15)<br />
calc.set_fdf(’PAO.BasisSize’, ’SZ’)<br />
h2o.set_calculator(calc)<br />
# Make a -traj file named h2o_current_shift.traj:<br />
dyn = QuasiNewton(h2o, trajectory=’h2o_%s.traj’ % e_s)<br />
dyn.run(fmax=0.02) # Perform the relaxation<br />
E = h2o.get_potential_energy()<br />
print # Make the output more readable<br />
print "E_shift: %.2f" %e_s<br />
print "----------------"<br />
print "Total Energy: %.4f" % E # Print total energy<br />
d = h2o.get_distance(0,2)<br />
print "Bond length: %.4f" % d # Print bond length<br />
p = h2o.positions<br />
d1 = p[0] - p[2]<br />
d2 = p[1] - p[2]<br />
r = np.dot(d1, d2) / (np.linalg.norm(d1) * np.linalg.norm(d2))<br />
angle = np.arccos(r) / pi * 180<br />
print "Bond angle: %.4f" % angle # Print bond angle<br />
endtime = time.time()<br />
walltime = endtime - starttime<br />
print ’Wall time: %.5f’ % walltime<br />
print # Make the output more readable<br />
Run the script using three different basis sets: single-Z (SZ), double-Z (DZ) and double-Z plus polarization (DZP).<br />
Run it in different directories for each basis set, since the run will produce a large amount of output files. The<br />
bases are defined in the script through these three lines:<br />
6.4. Further reading 47