예제 #1
0
 def Extract(self, jobdir):
     from pylada.vasp import MassExtract
     extract = MassExtract(jobdir)
     success={}
     for name in self.names:
         success[name]=MassExtract(jobdir+'/'+name).success
     success=all(success.values())
     extract.success=success
     return extract
예제 #2
0
 def Extract(self, jobdir):
     extract = MassExtract(jobdir)
     success = {}
     for name in self.names:
         #import pdb; pdb.set_trace()
         success[name] = Extract(jobdir + '/' + name).success
     success = all(success.values())
     extract.success = success
     return extract
예제 #3
0
 def Extract(self, jobdir):
     extract = MassExtract(jobdir)
     success = {}
     last = self.names[-1]
     lasts = [last, os.path.join('bottom', last), os.path.join('top', last)]
     folders = self.names[self.to_run:] + [
         os.path.join('bottom', x) for x in self.names
     ] + [os.path.join('top', x) for x in self.names]
     for name in folders:
         #import pdb; pdb.set_trace()
         success[name] = Extract(jobdir + '/' + name).success
     success = all(success.values())
     extract.success = success
     return extract
예제 #4
0
  def __init__(self, path=None, epsilon = 1e0, pa_maxdiff=0.5, Extractor=None, **kwargs):
    """ Initializes an enthalpy function. """
    from pylada.vasp import MassExtract
    super(PointDefectMassExtractor, self).__init__(**kwargs)

    self.Extractor = Extractor
    """ Class for extracting data from a single defect. """
    if self.Extractor is None: self.Extractor = PointDefectExtractor
    self.massextract = MassExtract(path, unix_re=False, excludes=[".*relax_*"])
    """ Mass extraction object from which all results are pulled. """
    self.host = self._get_host()
    """ Result of host calculations. """

    # must be last. Can't use porperty setter.
    self._epsilon = epsilon
    self._pa_maxdiff = pa_maxdiff
예제 #5
0
class PointDefectMassExtractorImpl(AbstractMassExtract):
  """ Enthalpy for a series of defects for a given material and lattice. """
  def __init__(self, path=None, epsilon = 1e0, pa_maxdiff=0.5, Extractor=None, **kwargs):
    """ Initializes an enthalpy function. """
    from pylada.vasp import MassExtract
    super(PointDefectMassExtractor, self).__init__(**kwargs)

    self.Extractor = Extractor
    """ Class for extracting data from a single defect. """
    if self.Extractor is None: self.Extractor = PointDefectExtractor
    self.massextract = MassExtract(path, unix_re=False, excludes=[".*relax_*"])
    """ Mass extraction object from which all results are pulled. """
    self.host = self._get_host()
    """ Result of host calculations. """

    # must be last. Can't use porperty setter.
    self._epsilon = epsilon
    self._pa_maxdiff = pa_maxdiff


  @property 
  def epsilon(self): 
    """ Dimensionless dielectric constant. """
    return self._epsilon
  @epsilon.setter
  def epsilon(self, value):
    self._epsilon = value 
    for v in self.itervalues(): v.epsilon = self._epsilon

  @property 
  def pa_maxdiff(self): 
    """ Dimensionless dielectric constant. """
    return self._pa_maxdiff
  @pa_maxdiff.setter
  def pa_maxdiff(self, value):
    self._pa_maxdiff = value 
    for v in self.itervalues(): v.pa_maxdiff = self._pa_maxdiff


  @property
  def rootdir(self): 
    """ Path to the root-directory containing the poin-defects. """
    return self.massextract.rootdir
  @rootdir.setter
  def rootdir(self, value): self.massextract.rootdir = value
    
  def _get_host(self):
    """ Returns extraction object towards the host. """
    from operator import itemgetter
    host = self.massextract.copy(excludes=[".*PointDefects"])
    host.excludes.extend(self.massextract.excludes)
    lowest = sorted(host.total_energies.iteritems(), key=itemgetter(1))[0][0]
    host = [u for u in host[lowest].itervalues()]
    assert len(host) == 1
    return host[0]


  def __iter_alljobs__(self):
    """ Walks through point-defects only. """
    for child in self.massextract["PointDefects"].children:
      # looks for site_n
      if len(child["site_\d+"].jobs) != 0:
        assert len(child["site_\d+"].jobs) == len(child.jobs),\
               RuntimeError("Don't understand directory structure of {0}.".format(child.view))
        for site in child.children: # should site specific defects.
          result = self.Extractor(site, self.epsilon, self.host, self.pa_maxdiff)
          # checks this is a point-defect.
          if result.is_interstitial or result.is_vacancy or result.is_substitution:
            yield site.view, result
      else:
        result = self.Extractor(child, host=self.host, pa_maxdiff=self.pa_maxdiff,\
                                epsilon = self.epsilon)
        # checks if this is a valid point-defect.
        if result.is_interstitial or result.is_vacancy or result.is_substitution:
          yield child.view, result

  def ordered_items(self):
    """ Returns items ordered by substitution, vacancy, and interstitial. """
    from operator import itemgetter
    interstitials = (u for u in self.iteritems() if u[1].is_interstitial)
    substitution  = (u for u in self.iteritems() if u[1].is_substitution)
    vacancy       = (u for u in self.iteritems() if u[1].is_vacancy)
    result = sorted(substitution, key = itemgetter(0)) 
    result.extend(sorted(vacancy, key = itemgetter(0)))
    result.extend(sorted(interstitials, key = itemgetter(0)))
    return result
  def ordered_keys(self):
    """ Returns keys ordered by substitution, vacancy, and interstitial. """
    return [u[0] for u in self.ordered_items()]
  def ordered_values(self):
    """ Returns values ordered by substitution, vacancy, and interstitial. """
    return [u[1] for u in self.ordered_items()]

  def __str__(self): 
    """ Prints out all energies and corrections. """
    return "".join( str(value) for value in self.ordered_values() )