Esempio n. 1
0
 def lambda_check_overlap(self, overlap_funct=overlap_am, **kvargs):
   from pyscf.nao.m_ao_log import comp_moments
   """ Check the equality (p) = [p,ab] S^ab, i.e. scalar moments are recomputed with inversed vertex from the ao's overlap """
   me = ao_matelem_c(self.ao_log)
   sp2mom0,sp2mom1 = comp_moments(self)
   mael,mxel=[],[]
   for sp,[lab,mom0_ref] in enumerate(zip(self.sp2lambda,sp2mom0)):
     ab = overlap_funct(me,sp,np.zeros(3),sp,np.zeros(3),**kvargs)
     mom0 = einsum('lab,ab->l', lab,ab)
     mael.append((abs(mom0-mom0_ref)).sum()/mom0.size); mxel.append((abs(mom0-mom0_ref)).max())
   return mael,mxel
Esempio n. 2
0
def dipole_check(sv, prod_log, dipole_funct=dipole_ni, **kvargs):
  """ Computes the allclose(), mean absolute error and maximal error of the dipoles reproduced by the (local) vertex. """
  from pyscf.nao.m_ao_matelem import ao_matelem_c
  from pyscf.nao.m_ao_log import comp_moments
  me = ao_matelem_c(prod_log.ao_log)
  sp2mom0,sp2mom1 = comp_moments(prod_log)
  mael,mxel,acl=[],[],[]
  for atm,[sp,coord] in enumerate(zip(sv.atom2sp,sv.atom2coord)):
    dip_moms = np.einsum('j,k->jk', sp2mom0[sp],coord)+sp2mom1[sp]
    koo2dipme = np.einsum('pab,pc->cab', prod_log.sp2vertex[sp],dip_moms) 
    dipme_ref = dipole_funct(me,sp,coord,sp,coord, **kvargs)
    ac = np.allclose(dipme_ref, koo2dipme, atol=prod_log.tol_loc*10, rtol=prod_log.tol_loc)
    mae = abs(koo2dipme-dipme_ref).sum()/koo2dipme.size
    mxe = abs(koo2dipme-dipme_ref).max()
    acl.append(ac); mael.append(mae); mxel.append(mxe)
    if not ac: print('dipole check:', sp, mae, mxe, prod_log.tol_loc)
  return mael,mxel,acl
Esempio n. 3
0
def overlap_check(prod_log, overlap_funct=overlap_ni, **kvargs):
  """ Computes the allclose(), mean absolute error and maximal error of the overlap reproduced by the (local) vertex."""
  from pyscf.nao.m_ao_matelem import ao_matelem_c
  from pyscf.nao.m_ao_log import comp_moments
  me = ao_matelem_c(prod_log.rr, prod_log.pp).init_one_set(prod_log.ao_log)
  sp2mom0,sp2mom1 = comp_moments(prod_log)
  mael,mxel,acl=[],[],[]
  R0 = np.array([0.0,0.0,0.0])
  for sp,[vertex,mom0] in enumerate(zip(prod_log.sp2vertex,sp2mom0)):
    oo_ref = overlap_funct(me,sp,R0,sp,R0,**kvargs)
    oo = np.einsum('pjk,p->jk', vertex, mom0)
    ac = np.allclose(oo_ref, oo, atol=prod_log.tol_loc*10, rtol=prod_log.tol_loc)
    mae = abs(oo_ref-oo).sum()/oo.size
    mxe = abs(oo_ref-oo).max()
    acl.append(ac); mael.append(mae); mxel.append(mxe)
    if not ac: print('overlap check:', sp, mae, mxe, prod_log.tol_loc) 
  return mael,mxel,acl