for atom1, [sp1, rv1, s1, f1] in enumerate( zip(sv.atom2sp, sv.atom2coord, atom2s, atom2s[1:])): for atom2, [sp2, rv2, s2, f2] in enumerate( zip(sv.atom2sp, sv.atom2coord, atom2s, atom2s[1:])): oo2f = funct(me, sp1, rv1, sp2, rv2, **kvargs) res[s1:f1, s2:f2] = oo2f[:, :] #np.savetxt("kernel_pyscf_dens.txt", res) #print("sum(kernel) = ", np.sum(abs(res))) #import sys #sys.exit() return res # # # if __name__ == '__main__': from pyscf.nao.m_comp_coulomb_den import comp_coulomb_den from pyscf.nao.m_comp_overlap_coo import comp_overlap_coo from pyscf.nao.m_system_vars import system_vars_c from pyscf.nao.m_overlap_am import overlap_am sv = system_vars_c(label='siesta') over_coo = comp_overlap_coo(sv, funct=overlap_am).toarray() over_den = comp_coulomb_den(sv, funct=overlap_am) print(np.allclose(over_coo, over_den)) # must be always true
irow,icol,data = zeros(nnz, dtype=int64),zeros(nnz, dtype=int64),zeros(nnz) # Start to construct coo matrix inz=-1 for atom1,[sp1,rv1,s1,f1] in enumerate(zip(sv.atom2sp,sv.atom2coord,atom2s,atom2s[1:])): for atom2,[sp2,rv2,s2,f2] in enumerate(zip(sv.atom2sp,sv.atom2coord,atom2s,atom2s[1:])): if (sp2rcut[sp1]+sp2rcut[sp2])**2<=sum((rv1-rv2)**2) : continue oo = funct(me,sp1,rv1,sp2,rv2,**kvargs) for o1 in range(s1,f1): for o2 in range(s2,f2): inz = inz+1 irow[inz],icol[inz],data[inz] = o1,o2,oo[o1-s1,o2-s2] norbs = atom2s[-1] return coo_matrix((data, (irow, icol)), shape=(norbs, norbs)) # # # if __name__=='__main__': from pyscf.nao.m_comp_overlap_coo import comp_overlap_coo from pyscf.nao.m_system_vars import system_vars_c from pyscf.nao.m_overlap_am import overlap_am from pyscf.nao.m_overlap_ni import overlap_ni sv = system_vars_c(label='siesta') over = comp_overlap_coo(sv, funct=overlap_ni, level=7).tocsr() diff = (sv.hsx.s4_csr-over).sum() summ = (sv.hsx.s4_csr+over).sum() print(diff/summ, diff/over.size)
res = np.zeros((norbs,norbs), dtype=dtype) for atom1,[sp1,rv1,s1,f1] in enumerate(zip(sv.atom2sp,sv.atom2coord,atom2s,atom2s[1:])): for atom2,[sp2,rv2,s2,f2] in enumerate(zip(sv.atom2sp,sv.atom2coord,atom2s,atom2s[1:])): oo2f = funct(me,sp1,rv1,sp2,rv2,**kvargs) res[s1:f1,s2:f2] = oo2f[:,:] #np.savetxt("kernel_pyscf_dens.txt", res) #print("sum(kernel) = ", np.sum(abs(res))) #import sys #sys.exit() return res # # # if __name__=='__main__': from pyscf.nao.m_comp_coulomb_den import comp_coulomb_den from pyscf.nao.m_comp_overlap_coo import comp_overlap_coo from pyscf.nao.m_system_vars import system_vars_c from pyscf.nao.m_overlap_am import overlap_am sv = system_vars_c(label='siesta') over_coo = comp_overlap_coo(sv, funct=overlap_am).toarray() over_den = comp_coulomb_den(sv, funct=overlap_am) print(np.allclose(over_coo, over_den)) # must be always true