def afunc(var,data=None): rcs, rcp = var[0], var[1] f=open("base.fdf","w") f.write("%block PAO.Basis\n Ga 2\n") f.write(" 0 1\n") f.write("%10.5f\n1.0\n" % (rcs,) ) f.write("1 1\n") f.write("%10.5f\n1.0\n" % (rcp,) ) f.write("%endblock PAO.Basis\n") f.close() atoms = ListOfAtoms([Atom('Ga', (0.0,0.0,0.0),magmom=0), Atom('Ga', (2.0,0.0,0.0),magmom=0)]) a = Siesta(executable="/Users/ag/bin/siesta-xlf") a.SetOption("%include","base.fdf") energy = a.run(atoms) print rcs, rcp, energy return -energy
def afunc(var, data=None): rcs, rcp = var[0], var[1] f = open("base.fdf", "w") f.write("%block PAO.Basis\n Ga 2\n") f.write(" 0 1\n") f.write("%10.5f\n1.0\n" % (rcs, )) f.write("1 1\n") f.write("%10.5f\n1.0\n" % (rcp, )) f.write("%endblock PAO.Basis\n") f.close() atoms = ListOfAtoms([ Atom('Ga', (0.0, 0.0, 0.0), magmom=0), Atom('Ga', (2.0, 0.0, 0.0), magmom=0) ]) a = Siesta(executable="/Users/ag/bin/siesta-xlf") a.SetOption("%include", "base.fdf") energy = a.run(atoms) print rcs, rcp, energy return -energy
from Siesta.siesta import Siesta import urllib import os, shutil URLbase = "http://fisica.ehu.es/ag/siesta-psffiles/" atoms = Crystal([Atom('H', (0.757,0.586,0.),label="H_test"), Atom('H', (-0.757,0.586,0.),magmom=1), Atom('O', (0, 0, 0),magmom=1)]) # cell=(4, 4, 4), periodic=1) # create a work subdirectory orig_dir = os.getcwd() dir = "h2o_work" if os.path.isdir(dir): # does dir exist? shutil.rmtree(dir) # yes, remove old directory os.mkdir(dir) # make dir directory os.chdir(dir) # move to dir urllib.urlretrieve(URLbase + "H.psf", "H.psf") urllib.urlretrieve(URLbase + "H.psf", "H_test.psf") urllib.urlretrieve(URLbase + "O.psf", "O.psf") a = Siesta(executable="$HOME/bin/siesta-2.4-optim") energy = a.run(atoms,out="OUT") print "The energy is: ", energy os.chdir(orig_dir)
# create a work subdirectory orig_dir = os.getcwd() dir = "bond_work" if os.path.isdir(dir): # does dir exist? shutil.rmtree(dir) # yes, remove old directory os.mkdir(dir) # make dir directory os.chdir(dir) # move to dir URLbase = "http://fisica.ehu.es/ag/siesta-psffiles/" urllib.urlretrieve(URLbase + "H.psf", "H.psf") urllib.urlretrieve(URLbase + "O.psf", "O.psf") for i in range(len(bonds)): d = bonds[i] print i, d atoms = ListOfAtoms( [Atom('H', (d*math.cos(theta),d*math.sin(theta),0.0),magmom=1), Atom('H', (-d*math.cos(theta),d*math.sin(theta),0.0),magmom=1), Atom('O', (0, 0, 0),magmom=1) ]) # cell=(4, 4, 4), periodic=1) energy[i] = a.run(atoms) # Run Siesta and get the (free)energy # # Plot # p.add(biggles.Curve(bonds[:],energy[:])) p.show() os.chdir(orig_dir)
# create a work subdirectory orig_dir = os.getcwd() dir = "bond_work" if os.path.isdir(dir): # does dir exist? shutil.rmtree(dir) # yes, remove old directory os.mkdir(dir) # make dir directory os.chdir(dir) # move to dir URLbase = "http://fisica.ehu.es/ag/siesta-psffiles/" urllib.urlretrieve(URLbase + "H.psf", "H.psf") urllib.urlretrieve(URLbase + "O.psf", "O.psf") for i in range(len(bonds)): d = bonds[i] print i, d atoms = ListOfAtoms([ Atom('H', (d * math.cos(theta), d * math.sin(theta), 0.0), magmom=1), Atom('H', (-d * math.cos(theta), d * math.sin(theta), 0.0), magmom=1), Atom('O', (0, 0, 0), magmom=1) ]) # cell=(4, 4, 4), periodic=1) energy[i] = a.run(atoms) # Run Siesta and get the (free)energy # # Plot # p.add(biggles.Curve(bonds[:], energy[:])) p.show() os.chdir(orig_dir)