Пример #1
0
 def cleanPath(self, path, force=False):
     if os.path.exists(path):
         if force:
             try:
                 os.remove(path)
             except OSError:
                 shutil.rmtree(path)
         else:
             qtk.prompt(path + ' exists, overwrite?')
             try:
                 os.remove(path)
             except OSError:
                 shutil.rmtree(path)
             except:
                 qtk.warning("can not remove file: " + path)
Пример #2
0
 def cleanPath(self, path, force=False):
   if os.path.exists(path):
     if force:
       try:
         os.remove(path)
       except OSError:
         shutil.rmtree(path)
     else:
       qtk.prompt(path + ' exists, overwrite?')
       try:
         os.remove(path)
       except OSError:
         shutil.rmtree(path)
       except:
         qtk.warning("can not remove file: " + path)
Пример #3
0
  def setChargeMultiplicity(self, c, m, **kwargs):
    if type(c) == int or type(c) == float:
      self.charge = c
    if type(m) == int:
      self.multiplicity = m

    if type(self.multiplicity)==int and\
       type(self.charge)==(int or float):
      if not (self.multiplicity % 2 != \
              (np.sum(self.Z) + self.charge) % 2):
        ve = np.vectorize(qtk.n2ve)
        nve = sum(ve(self.type_list)) - self.charge
        msg = "Multiplicity %d " % self.multiplicity + \
              "and %d valence electrons " % nve +\
              "\n(with charge %3.1f) " % float(self.charge) +\
              "are not compatible"
        qtk.prompt(msg + "\nsuppress warning py no_warning=True,"\
                  + " continue?")
Пример #4
0
  def setChargeMultiplicity(self, c, m, **kwargs):
    if type(c) == int or type(c) == float:
      self.charge = c
    if type(m) == int:
      self.multiplicity = m

    if type(self.multiplicity)==int and\
       type(self.charge)==(int or float):
      if not (self.multiplicity % 2 != \
              (np.sum(self.Z) + self.charge) % 2):
        ve = np.vectorize(qtk.n2ve)
        nve = sum(ve(self.type_list)) - self.charge
        msg = "Multiplicity %d " % self.multiplicity + \
              "and %d valence electrons " % nve +\
              "\n(with charge %3.1f) " % float(self.charge) +\
              "are not compatible"
        qtk.prompt(msg + "\nsuppress warning py no_warning=True,"\
                  + " continue?")
Пример #5
0
def write(self, cpmd_name, espresso_name):
    if not os.path.exists(cpmd_name):
        qtk.report("PP", "writing cpmd PP file")
        cpmd_write(self, cpmd_name)
        cpmd_exists = False
    else:
        cpmd_exists = True
        qtk.prompt('cpmd pp path:%s exist' % cpmd_name)
    if (cpmd_name == espresso_name and not cpmd_exists)\
    or not os.path.exists(espresso_name):
        qtk.report("PP", 'start converting Goedecker PP')
        conv_pp = sp.Popen("%s %s" % \
          (qtk.setting.espresso_cpmd2upf_exe, cpmd_name),
          shell=True)
        conv_pp.wait()
        if conv_pp.returncode != 0:
            qtk.warning('conversion failed...')
        else:
            os.rename(cpmd_name + '.UPF', espresso_name)
    else:
        qtk.prompt('espresso pp path:%s exist' % espresso_name)