Ejemplo n.º 1
0
def ReadStruct(filename,species_map):
    """Return "Crystal" object read from Siesta STRUCT-file.
       species_map is a dictionary mapping the species index to 
       atomic symbols. For example:

          species_map = { "1" : "Mg",
                          "2" : "C" ,
                          "3" : "O" }

	In a forthcoming version this information could be obtained
        directly from the atomic number in the .STRUCT_{IN,OUT} file.

     """
    f = open(filename)
#
#   First read unit cell
#
    cell = []
    for i in range(3):
      vector = f.readline()
      x, y, z = vector.split()
      cell.append([ float(x), float(y), float(z) ])
#
#   Now the atoms
#
#   Robust code to allow for broken lines. 
#   Accumulate all the data in a big list...

    natoms = int(f.readline())
    strings = []
    while 1:
       line = f.readline()
       if not line: break
       strings = strings + line.split()

#   ... and extract the information for each atom in turn
#
    crystal = Crystal([])
    pos = 0
    for a in range(natoms):
        sublist = strings[pos:pos+5]
        spindex, z , x, y, z = sublist
        symbol = species_map[spindex]
        crystal.append(Atom(symbol, [float(x), float(y), float(z)]))
        pos = pos + 5

    crystal.SetUnitCell(cell)

    return crystal
Ejemplo n.º 2
0
def ReadStruct(filename, species_map):
    """Return "Crystal" object read from Siesta STRUCT-file.
       species_map is a dictionary mapping the species index to 
       atomic symbols. For example:

          species_map = { "1" : "Mg",
                          "2" : "C" ,
                          "3" : "O" }

	In a forthcoming version this information could be obtained
        directly from the atomic number in the .STRUCT_{IN,OUT} file.

     """
    f = open(filename)
    #
    #   First read unit cell
    #
    cell = []
    for i in range(3):
        vector = f.readline()
        x, y, z = vector.split()
        cell.append([float(x), float(y), float(z)])
#
#   Now the atoms
#
#   Robust code to allow for broken lines.
#   Accumulate all the data in a big list...

    natoms = int(f.readline())
    strings = []
    while 1:
        line = f.readline()
        if not line: break
        strings = strings + line.split()

#   ... and extract the information for each atom in turn
#
    crystal = Crystal([])
    pos = 0
    for a in range(natoms):
        sublist = strings[pos:pos + 5]
        spindex, z, x, y, z = sublist
        symbol = species_map[spindex]
        crystal.append(Atom(symbol, [float(x), float(y), float(z)]))
        pos = pos + 5

    crystal.SetUnitCell(cell)

    return crystal
Ejemplo n.º 3
0
#!/usr/bin/env python

from Siesta.Interface import  Atom, Crystal
from Siesta.calculator import SiestaCalculator
from ASE.Dynamics.MDMin import MDMin

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=(6.0, 6.0, 6.0), periodic=1)

# create a work subdirectory
orig_dir = os.getcwd()
dir = "ase_relax_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") 

b = SiestaCalculator(executable="/Users/ag/bin/siesta-xlf")
b.SetOption("DM.Tolerance","0.001")
atoms.SetCalculator(b)
Ejemplo n.º 4
0
#!/usr/bin/env python

from Siesta.Interface import  Atom, Crystal
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
Ejemplo n.º 5
0
#!/usr/bin/env python

from Siesta.Interface import  Atom, Crystal
from Siesta.calculator import SiestaCalculator
from ASE.Dynamics.VelocityVerlet import VelocityVerlet

from RandomArray import *

import urllib 
import os, shutil 

URLbase = "http://fisica.ehu.es/ag/siesta-psffiles/"

atoms = Crystal([Atom('H', (0.757,0.586,0.),label="H_sz"),
                     Atom('H', (-0.757,0.586,0.),magmom=1),
                     Atom('O', (0, 0, 0),magmom=1)],
                     cell=(6.0, 6.0, 6.0), periodic=1)

# create a work subdirectory
orig_dir = os.getcwd()
dir = "ase_verlet_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 + "O.psf", "O.psf") 

b = SiestaCalculator(executable="/Users/ag/bin/siesta-xlf")
b.SetOption("DM.Tolerance","0.001")
Ejemplo n.º 6
0
output_file=os.path.abspath(label+".eggbox."+str(cutoff))
print "The output will be in file: ", output_file

# create a work subdirectory
orig_dir = os.getcwd()
import tempfile
workdir = tempfile.mkdtemp(prefix="eggbox.work.",dir=".")
print "Working directory: ", workdir
os.chdir(workdir) # move to dir
#
os.system("cp -p " + pseudo_file + " .")
os.system("cp -p " + basis_file + " .")
g=open(output_file,"w")

for i in range(len(disps)):
  d = i*dx/(m-1)
  # could generalize the displacement here (1,1,1), (1,0,1)...
  atoms=Crystal([Atom(symbol=symbol,label=label,position=(0,0,d))])
  atoms.SetUnitCell(cell,fix=True)
  atoms.SetBoundaryConditions(periodic=True)
  energy[i], force, stress = a.run(atoms)   # Run Siesta - get the (free)energy
  print  i, d, energy[i]
  fforce = [ float(j) for j in force[0]]
  g.write(" %10.6f %20.6f  %15.6f%15.6f%15.6f\n" % (float(d), float(energy[i]),  fforce[0], fforce[1], fforce[2] ))

#
g.close()
os.chdir(orig_dir)