Пример #1
0
 def get_fmo_energy(self):
     """
     get H**O, LUMO and their gap
     """
     f = self.f
     cmd1 = "awk '/^ The electronic state is/{print NR}' %s | tail -n 1" % f
     Ln1 = int(io2.cmdout2(cmd1)) + 1
     cmd2 = "awk '/^          Condensed to atoms \(all electrons\)/{print NR}' %s | tail -n 1" % f
     Ln2 = int(io2.cmdout2(cmd2)) - 1
     cmd = "sed -n '%d,%dp' %s | grep Beta" % (Ln1, Ln2, f)
     cont0 = io2.cmdout2(cmd)
     if self.isp:
         print(' ## spin polarised!')
         h**o = None
         lumo = None
     else:
         cmd = "sed -n '%d,%dp' %s | grep ' Alpha virt. eigenvalues --' | head -n 1" % (
             Ln1, Ln2, f)
         ct = io2.cmdout2(cmd)
         lumo = eval(ct.split()[-5]) * self.uo.h2e
         cmd = "sed -n '%d,%dp' %s | grep ' Alpha  occ. eigenvalues --' | tail -1" % (
             Ln1, Ln2, f)
         ct = io2.cmdout2(cmd)
         h**o = eval(ct.split()[-1]) * self.uo.h2e
     return h**o, lumo
Пример #2
0
 def get_mulliken_population(self):
     # note that the output Mulliken charge starting line may be different
     # for different versions of Gaussian, i.e., with or without `atomic` in between
     # "Mullike" and "charges:", so a "robust" regular expression is used
     cmd1 = "awk '/^ Mulliken [a-zA-Z]*\s?charges:/{print NR}' %s | tail -1" % self.f
     Ln1 = int(io2.cmdout2(cmd1)) + 2
     cmd2 = "awk '/^ Sum of Mulliken [a-zA-Z]*\s?charges =/{print NR}' %s | tail -1" % self.f
     Ln2 = int(io2.cmdout2(cmd2)) - 1
     cmd = "sed -n '%d,%dp' %s" % (Ln1, Ln2, self.f)
     cs = io2.cmdout2(cmd).split('\n')
     pops = np.array([eval(ci.split()[2]) for ci in cs])
     return pops
Пример #3
0
 def get_polarizability(self):
     cmd = "awk '/Isotropic polarizability/{print $6}' %s" % self.f
     a = None
     try:
         a = eval(io2.cmdout2(cmd))
     except:
         print(' * WARNING: no Isotropic polarizability found')
     return a
Пример #4
0
 def get_force(self):
     iou = io2.Units()
     const = iou.h2e / iou.b2a  # from hartree/bohr to eV/A
     #cmd = "grep '^\s*[XYZ][0-9]*   ' %s | awk '{print $3}'"%self.f #
     cmd1 = "awk '/^ Variable       Old X    -DE/{print NR}' %s | tail -1" % self.f
     Ln1 = int(io2.cmdout2(cmd1)) + 2
     cmd2 = "awk '/^         Item               Value     Threshold  Converged/{print NR}' %s | tail -1" % self.f
     Ln2 = int(io2.cmdout2(cmd2)) - 1
     cmd = "sed -n '%d,%dp' %s" % (Ln1, Ln2, self.f)
     #print cmd
     cs = io2.cmdout2(cmd).split('\n')
     vals = [eval(ci.split()[2]) for ci in cs]
     #print vals
     #print len(vals)
     forces = np.array(vals).reshape((self.na, 3)) * const
     #abs_forces = np.linalg.norm( forces, axis=1 )
     #self.forces = abs_forces[:, np.newaxis]
     return forces
Пример #5
0
 def get_cf_and_chg(self):
     """ cf: chemical formula
         chg: charge """
     cmdi = "grep Stoichiometry %s | tail -1" % f
     ct = io2.cmdout2(cmdi)
     info = ct.split()[-1]
     if ('(' in info) and (info[-1] == ')'):
         # charged mol
         cf, c0_ = info.split('(')  # cf: chemical formula;
         if c0_[-2] == '-':
             chg = -int(c0_[:-2])  # negatively charged
         elif c0_[-2] == '+':
             chg = int(c0_[:-2])  # positively charged
         else:
             #print 'c0_ = ', c0_, ', ct = ', ct
             #sys.exit(2)
             chg = 0  # spin-polarized case, e.g., C4H9O(2)
     else:
         chg = 0
         cf = info
     return cf, chg
Пример #6
0
 def get_dipole_moment(self):
     cmd = "grep -A1 ' Dipole moment (field-independent basis, Debye):' %s | tail -1 | awk '{print $NF}'" % self.f
     mu = eval(io2.cmdout2(cmd))
     return mu
Пример #7
0
 def get_task(self):
     task = 'e'
     if io2.cmdout2('grep -i " opt[(\s]" %s' % (self.f)):
         task = 'optg'
     return task