[ase-users] VASP module in ASE

Jonas Björk j.bjork at liverpool.ac.uk
Tue Sep 2 16:32:06 CEST 2008


On Tue, 2008-09-02 at 09:16 +0300, Jussi Enkovaara wrote:
> Jonas Björk wrote:
> >> Let's say I want to do 256 water molecules, and the order is
> >> HHOHHOHHOHHO ..., then I will also get a HUGE POTCAR file.  I think it
> >> would be best if the ASE Vasp interface could be intelligent and reorder
> >> things so that the POTCAR file only has two setups.
> > 
> > I agree, lets do it this way.
> 
> Hi,
> if you look how I was constructing POSCAR and POTCAR (svn revision 508) one should 
> get in the above example POTCAR with only two setups:
> 
> First I was construcytig a dictionary of atomic species, where the key is the 
> atomic symbol and value the number of this species:
> 
>          # Determine the number of atomic species
>          self.symbols = {}
>          for atom in atoms:
>              symbol = atom.get_symbol()
>              if not self.symbols.has_key(symbol):
>                  self.symbols[symbol] = 1
>              else:
>                  self.symbols[symbol] += 1
> 

I solved the problem this way now, how to get to the new from the
original ordering, vice verse, is kept in the two variable self.sort and
self.resort, respectively. 

        self.symbols = {}
        for atom in atoms:
            symbol = atom.get_symbol()
            if not self.symbols.has_key(symbol):
                self.symbols[symbol] = 1
            else:
                self.symbols[symbol] += 1
        self.sort = []
        atomtypes = atoms.get_chemical_symbols()
        for symbol in self.symbols:
            for m in range(len(atoms)):
                if atoms[m].get_symbol()==symbol:
                    self.sort.append(m)
        self.resort=range(len(self.sort))
        for n in range(len(self.resort)):
            self.resort[self.sort[n]]=n
        self.atoms_sorted=atoms[self.sort]

I attach the current updated version (working name vasp4) of the
interface.

Jonas

> 
> POTCAR can then be constructed just with loop over symbols:
> 
>          for symbol in self.symbols:
>              try:
>                  name = symbol + '_' + p['setups'][symbol]
>              except (TypeError, KeyError):
>                  name = symbol
>              name += '/POTCAR.Z'
>              found = False
>              for path in pppaths:
>                  filename = join(path, name)
>                  if isfile(filename) or islink(filename):
>                      found = True
>                      self.ppp_list.append(filename)
>                      break
>              if not found:
>                  raise RuntimeError('No pseudopotential for %s!' % symbol)
> 
> 
> After writing the unit cell information in POSCAR, the number of atomic species can 
> be written:
> 
>          for nspecies in self.symbols.values():
>              poscar.write('%i ' % nspecies)
>          poscar.write('\n')
> 
> and the actual positions:
> 
>          for symbol in self.symbols.keys():
>              mask = [asymbol == symbol for asymbol in self.all_symbols]
>              ind = npy.asarray(mask, bool)
>              for pos in self.positions[ind]:
>                  poscar.write('%.14f %.14f %.14f\n' %  tuple(pos))
> 
> I do not know if this is the optimal way, but it seemed to be working.
> 
> Best regards,
> Jussi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vasp4.py
Type: text/x-python
Size: 19511 bytes
Desc: not available
URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20080902/00efd911/attachment.py>


More information about the ase-users mailing list