1#!/usr/bin/env python 2 3from Siesta.Interface import Atom, Crystal 4from Siesta.calculator import SiestaCalculator 5 6import urllib 7import os, shutil 8 9URLbase = "http://fisica.ehu.es/ag/siesta-psffiles/" 10 11atoms = Crystal([Atom('H', (0.757,0.586,0.)), 12 Atom('H', (-0.757,0.586,0.),magmom=1), 13 Atom('O', (0, 0, 0),magmom=1)], 14 cell=(6.0, 6.0, 6.0), periodic=1) 15 16# create a work subdirectory 17orig_dir = os.getcwd() 18dir = "ase_work" 19if os.path.isdir(dir): # does dir exist? 20 shutil.rmtree(dir) # yes, remove old directory 21os.mkdir(dir) # make dir directory 22os.chdir(dir) # move to dir 23 24urllib.urlretrieve(URLbase + "H.psf", "H.psf") 25urllib.urlretrieve(URLbase + "O.psf", "O.psf") 26 27b = SiestaCalculator(executable="$HOME/bin/siesta-2.4-optim") 28 29b.SetOption("DM.Tolerance","0.005") 30atoms.SetCalculator(b) 31 32energy = atoms.GetPotentialEnergy() 33forces = atoms.GetCartesianForces() 34stress = atoms.GetStress() 35 36print "The energy is: ", energy 37print "Forces ", forces 38print "Stress ", stress 39stress = atoms.GetStress() 40print "Stress ", stress 41 42os.chdir(orig_dir) 43