def Calculate(self): """Calculate everything.""" atoms = self.GetListOfAtoms() self.energy, self.stress, self.forces = Sserver.get_forces(self,atoms) self.cell = atoms.GetUnitCell() self.positions = atoms.GetCartesianPositions() self.numbers = atoms.GetAtomicNumbers() self.bc = atoms.GetBoundaryConditions()
def Initialize(self): atoms = self.GetListOfAtoms() Sserver.run(self,atoms) # Ready for action! self.ready = True
def __init__(self,executable=None): Sserver.__init__(self,executable) self.ready = False
print "using executable: ", executable # # Standard bond length (units: Angstrom) # d0 = math.sqrt(0.757**2 + 0.586**2) # Range of bond lengths around the presumed minimum bonds = num.arange(0.8*d0,1.3*d0,0.1) energy = 0.0*bonds theta=0.5*(180.-105.0)*math.pi/180. # Angle with the x axis, in radians print bonds a = Siesta(executable="siesta") # Initialize object ##a.SetOption("DM.UseSaveDM","T") # 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") # First instance to launch
atoms = Structure([ 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=executable) a.launch(atoms) energy, forces, stress = a.get_forces(atoms) print "The energy is: ", energy print forces print stress a.stop() os.chdir(orig_dir)
# create a work subdirectory orig_dir = os.getcwd() dir = "client_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_test.psf") urllib.urlretrieve(URLbase + "H.psf", "H.psf") urllib.urlretrieve(URLbase + "O.psf", "O.psf") a = Siesta(executable="/Users/ag/bin/siesta-xlf") a.run(atoms,out="OUT") blist = [ 0.4, 0.50, 0.60, 0.70, 0.80, 0.90] energies = [] forces = [] energies = [] for d in blist: atoms = Crystal([Atom('H', (d,0.586,0.),label="H_test"), Atom('H', (-d,0.586,0.),magmom=1), Atom('O', (0, 0, 0),magmom=1)], cell=(6.0, 6.0, 6.0), periodic=1) e, stress, fs = a.get_forces(atoms) energies.append(e) forces.append(fs)