Пример #1
0
 def test_ao_log_after_gpaw(self):
     """ init ao_log_c with it radial orbitals from GPAW """
     from pyscf.nao import ao_log_c
     if calc is None: return
     self.assertTrue(hasattr(calc, 'setups'))
     aos = ao_log_c().init_ao_log_gpaw(calc.setups)
     self.assertEqual(aos.nr, 1024)
Пример #2
0
    def test_prdred_eval(self):
        from pyscf.nao.m_prod_talman import prod_talman_c
        from pyscf.nao.m_ao_eval_libnao import ao_eval_libnao as ao_eval
        from pyscf.nao.m_csphar_talman_libnao import csphar_talman_libnao as csphar_jt
        from pyscf.nao.m_siesta_ion_xml import siesta_ion_xml
        from pyscf.nao import ao_log_c
        from numpy import sqrt, zeros, array

        import os

        dname = os.path.dirname(os.path.abspath(__file__))
        sp2ion = []
        sp2ion.append(siesta_ion_xml(dname + '/O.ion.xml'))

        aos = ao_log_c().init_ao_log_ion(sp2ion)
        jmx = aos.jmx
        pt = prod_talman_c(aos)

        spa, spb = 0, 0
        rav, rbv, rcv = array([0.0, 0.0, -1.0]), array([0.0, 0.0,
                                                        1.0]), zeros(3)
        coord = np.array(
            [0.4, 0.1, 0.22]
        )  # Point at which we will compute the expansion and the original product
        ylma, ylmb, ylmc = csphar_jt(coord - rav, jmx), csphar_jt(
            coord - rbv, jmx), csphar_jt(coord + rcv, pt.lbdmx)
        rcs = sqrt(sum((coord + rcv)**2))

        serr = 0.0
        merr = 0.0
        nval = 0
        for la, phia in zip(aos.sp_mu2j[spa], aos.psi_log[spa]):
            fa = pt.log_interp(phia, sqrt(sum((coord - rav)**2)))
            for lb, phib in zip(aos.sp_mu2j[spb], aos.psi_log[spb]):
                fb = pt.log_interp(phib, sqrt(sum((coord - rbv)**2)))

                jtb, clbdtb, lbdtb = pt.prdred_terms(la, lb)
                jtb, clbdtb, lbdtb, rhotb = pt.prdred_libnao(
                    phib, lb, rbv, phia, la, rav, rcv)
                rhointerp = pt.log_interp(rhotb, rcs)

                for ma in range(-la, la + 1):
                    aovala = ylma[la * (la + 1) + ma] * fa
                    for mb in range(-lb, lb + 1):
                        aovalb = ylmb[lb * (lb + 1) + mb] * fb

                        ffr, m = pt.prdred_further_scalar(
                            la, ma, lb, mb, rcv, jtb, clbdtb, lbdtb, rhointerp)
                        prdval = 0.0j
                        for j, fr in enumerate(ffr):
                            prdval = prdval + fr * ylmc[j * (j + 1) + m]

                        derr = abs(aovala * aovalb - prdval)
                        nval = nval + 1
                        serr = serr + derr
                        merr = max(merr, derr)

        self.assertTrue(merr < 1.0e-05)
        self.assertTrue(serr / nval < 1.0e-06)
Пример #3
0
  def test_prdred_eval(self):
    from pyscf.nao.m_prod_talman import prod_talman_c
    from pyscf.nao.m_ao_eval_libnao import ao_eval_libnao as ao_eval
    from pyscf.nao.m_csphar_talman_libnao import csphar_talman_libnao as csphar_jt
    from pyscf.nao.m_siesta_ion_xml import siesta_ion_xml
    from pyscf.nao import ao_log_c
    from numpy import sqrt, zeros, array

    import os
    
    dname = os.path.dirname(os.path.abspath(__file__))
    sp2ion = []
    sp2ion.append(siesta_ion_xml(dname+'/O.ion.xml'))

    aos = ao_log_c().init_ao_log_ion(sp2ion)
    jmx = aos.jmx
    pt = prod_talman_c(aos)

    spa,spb=0,0
    rav,rbv,rcv = array([0.0,0.0,-1.0]),array([0.0,0.0,1.0]), zeros(3)
    coord = np.array([0.4, 0.1, 0.22]) # Point at which we will compute the expansion and the original product
    ylma,ylmb,ylmc = csphar_jt(coord-rav, jmx), csphar_jt(coord-rbv, jmx),csphar_jt(coord+rcv, pt.lbdmx)
    rcs = sqrt(sum((coord+rcv)**2))
 
    serr = 0.0
    merr = 0.0
    nval = 0
    for la,phia in zip(aos.sp_mu2j[spa], aos.psi_log[spa]):
      fa = pt.log_interp(phia, sqrt(sum((coord-rav)**2)))
      for lb,phib in zip(aos.sp_mu2j[spb], aos.psi_log[spb]):
        fb = pt.log_interp(phib, sqrt(sum((coord-rbv)**2)))

        jtb,clbdtb,lbdtb=pt.prdred_terms(la,lb)
        jtb,clbdtb,lbdtb,rhotb = pt.prdred_libnao(phib,lb,rbv,phia,la,rav,rcv)
        rhointerp = pt.log_interp(rhotb, rcs)
        
        for ma in range(-la,la+1):
          aovala = ylma[la*(la+1)+ma]*fa
          for mb in range(-lb,lb+1):
            aovalb = ylmb[lb*(lb+1)+mb]*fb

            ffr,m = pt.prdred_further_scalar(la,ma,lb,mb,rcv,jtb,clbdtb,lbdtb,rhointerp)
            prdval = 0.0j
            for j,fr in enumerate(ffr): prdval = prdval + fr*ylmc[j*(j+1)+m]

            derr = abs(aovala*aovalb-prdval)
            nval = nval + 1
            serr = serr + derr
            merr = max(merr, derr)

    self.assertTrue(merr<1.0e-05)
    self.assertTrue(serr/nval<1.0e-06)
Пример #4
0
 def test_ao_log_sp2ion(self):
     """ This is for initializing with SIESTA radial orbitals """
     import os
     dname = os.path.dirname(os.path.abspath(__file__))
     sp2ion = []
     sp2ion.append(siesta_ion_xml(dname + '/H.ion.xml'))
     sp2ion.append(siesta_ion_xml(dname + '/O.ion.xml'))
     ao = ao_log_c().init_ao_log_ion(sp2ion, nr=512, rmin=0.0025)
     self.assertEqual(ao.nr, 512)
     self.assertAlmostEqual(ao.rr[0], 0.0025)
     self.assertAlmostEqual(ao.rr[-1], 11.105004591662)
     self.assertAlmostEqual(ao.pp[-1], 63.271890905445957)
     self.assertAlmostEqual(ao.pp[0], 0.014244003769469984)
     self.assertEqual(len(ao.sp2nmult), 2)
     self.assertEqual(len(ao.sp_mu2j[1]), 5)
     self.assertEqual(ao.sp2charge[0], 1)
Пример #5
0
 def test_ao_log_sp2ion(self):
   """ This is for initializing with SIESTA radial orbitals """
   import os
   dname = os.path.dirname(os.path.abspath(__file__))
   sp2ion = []
   sp2ion.append(siesta_ion_xml(dname+'/H.ion.xml'))
   sp2ion.append(siesta_ion_xml(dname+'/O.ion.xml'))
   ao = ao_log_c().init_ao_log_ion(sp2ion, nr=512, rmin=0.0025)
   self.assertEqual(ao.nr, 512)
   self.assertAlmostEqual(ao.rr[0], 0.0025)
   self.assertAlmostEqual(ao.rr[-1], 11.105004591662)
   self.assertAlmostEqual(ao.pp[-1], 63.271890905445957)
   self.assertAlmostEqual(ao.pp[0], 0.014244003769469984)
   self.assertEqual(len(ao.sp2nmult), 2)
   self.assertEqual(len(ao.sp_mu2j[1]), 5)
   self.assertEqual(ao.sp2charge[0], 1)
Пример #6
0
 def test_ao_log_gto(self):
   """ This is indeed for initializing with auxiliary basis set"""
   from pyscf.nao import ao_log_c, system_vars_c
   sv = system_vars_c().init_pyscf_gto(mol)
   ao = ao_log_c().init_ao_log_gto_lm(mol, sv, sv.ao_log)
Пример #7
0
 def test_ao_log_gto(self):
     """ This is indeed for initializing with auxiliary basis set"""
     from pyscf.nao import ao_log_c, nao
     sv = nao(gto=mol)
     ao = ao_log_c().init_ao_log_gto_lm(gto=mol, nao=sv, lm=sv.ao_log)
Пример #8
0
 def test_ao_log_gto(self):
   """ This is indeed for initializing with auxiliary basis set"""
   from pyscf.nao import ao_log_c, nao
   sv = nao(gto=mol)
   ao = ao_log_c().init_ao_log_gto_lm(gto=mol, nao=sv, lm=sv.ao_log)