Ejemplo n.º 1
0
    def test_ao_eval(self):
        from pyscf.nao.m_ao_eval_libnao import ao_eval_libnao
        from pyscf.nao.m_ao_eval import ao_eval
        """  """
        sv = nao(gto=mol)
        ra = np.array([2.0333, 0.101, 2.333])
        coords = np.array([[0.0333, 1.111, 3.333]])
        ao_vals_lib = ao_eval_libnao(sv.ao_log, ra, 0, coords)
        self.assertAlmostEqual(ao_vals_lib[0, 0], 0.021725938009701302)
        ao_vals_lib = ao_eval_libnao(sv.ao_log, ra, 1, coords)
        self.assertAlmostEqual(ao_vals_lib[1, 0], 0.0017709123325328384)

        ra = 4.0 * np.random.rand(3)
        coords = 3.0 * np.random.rand(10, 3)
        ao_vals_lib = ao_eval_libnao(sv.ao_log, ra, 0, coords)
        ao_vals_py = ao_eval(sv.ao_log, ra, 0, coords)
        for aocc1, aocc2 in zip(ao_vals_lib, ao_vals_py):
            for ao1, ao2 in zip(aocc1, aocc2):
                self.assertAlmostEqual(ao1, ao2)
Ejemplo n.º 2
0
 def test_ao_eval(self):
   from pyscf.nao.m_ao_eval_libnao import ao_eval_libnao
   from pyscf.nao.m_ao_eval import ao_eval
   """  """
   sv = nao(gto=mol)
   ra = np.array([2.0333, 0.101, 2.333])
   coords = np.array([[0.0333, 1.111, 3.333]])
   ao_vals_lib = ao_eval_libnao(sv.ao_log, ra, 0, coords)
   self.assertAlmostEqual(ao_vals_lib[0,0], 0.021725938009701302)
   ao_vals_lib = ao_eval_libnao(sv.ao_log, ra, 1, coords)
   self.assertAlmostEqual(ao_vals_lib[1,0], 0.0017709123325328384)
   
   ra = 4.0*np.random.rand(3)
   coords = 3.0*np.random.rand(10,3)
   ao_vals_lib = ao_eval_libnao(sv.ao_log, ra, 0, coords)
   ao_vals_py  = ao_eval(sv.ao_log, ra, 0, coords)
   for aocc1, aocc2 in zip(ao_vals_lib, ao_vals_py):
     for ao1, ao2 in zip(aocc1, aocc2):
       self.assertAlmostEqual(ao1, ao2)
Ejemplo n.º 3
0
#
# See above
#
def ao_eval_libnao(ao, ra, isp, coords):
  res = np.zeros((ao.sp2norbs[isp],coords.shape[0]), dtype='float64')
  ao_eval_libnao_(ao, ra, isp, coords, res)
  return res


if __name__ == '__main__':
  from pyscf.nao.m_system_vars import system_vars_c
  from pyscf.nao.m_ao_eval import ao_eval
  from pyscf.nao.m_ao_eval_libnao import ao_eval_libnao
  
  sv  = system_vars_c()
  ra = np.array([0.3, -0.5, 0.77], dtype='float64')
  #coords = np.array([[0.07716887, 2.82933578, 3.73214881]])
  coords = np.random.rand(35580,3)*5.0
  
  print('ao_val2 (reference)')
  ao_val1 = ao_eval(sv.ao_log, ra, 0, coords)

  print('ao_val2_libnao')
  ao_val2 = ao_eval_libnao(sv.ao_log, ra, 0, coords)
  
  print(np.allclose(ao_val1,ao_val2))
  for iorb,[oo1,oo2] in enumerate(zip(ao_val1,ao_val2)):
    print(iorb, abs(oo1-oo2).argmax(), abs(oo1-oo2).max(), coords[abs(oo1-oo2).argmax(),:])


Ejemplo n.º 4
0
#
# See above
#
def ao_eval_libnao(ao, ra, isp, coords):
    res = np.zeros((ao.sp2norbs[isp], coords.shape[0]), dtype='float64')
    ao_eval_libnao_(ao, ra, isp, coords, res)
    return res


if __name__ == '__main__':
    from pyscf.nao.m_system_vars import system_vars_c
    from pyscf.nao.m_ao_eval import ao_eval
    from pyscf.nao.m_ao_eval_libnao import ao_eval_libnao

    sv = system_vars_c()
    ra = np.array([0.3, -0.5, 0.77], dtype='float64')
    #coords = np.array([[0.07716887, 2.82933578, 3.73214881]])
    coords = np.random.rand(35580, 3) * 5.0

    print('ao_val2 (reference)')
    ao_val1 = ao_eval(sv.ao_log, ra, 0, coords)

    print('ao_val2_libnao')
    ao_val2 = ao_eval_libnao(sv.ao_log, ra, 0, coords)

    print(np.allclose(ao_val1, ao_val2))
    for iorb, [oo1, oo2] in enumerate(zip(ao_val1, ao_val2)):
        print(iorb,
              abs(oo1 - oo2).argmax(),
              abs(oo1 - oo2).max(), coords[abs(oo1 - oo2).argmax(), :])