def to_mol(self): '''Return a Mole object using the same atoms and basis functions as the Cell object. ''' mol = mole.Mole() cell_dic = [(key, getattr(self, key)) for key in mol.__dict__.keys()] mol.__dict__.update(cell_dic) return mol
def _make_fakemol(): fakemol = mole.Mole() fakemol._atm = np.zeros((1,mole.ATM_SLOTS), dtype=np.int32) fakemol._bas = np.zeros((1,mole.BAS_SLOTS), dtype=np.int32) ptr = mole.PTR_ENV_START fakemol._env = np.zeros(ptr+10) fakemol._bas[0,mole.NPRIM_OF ] = 1 fakemol._bas[0,mole.NCTR_OF ] = 1 fakemol._bas[0,mole.PTR_EXP ] = ptr+3 fakemol._bas[0,mole.PTR_COEFF] = ptr+4 return fakemol
def get_pp(cell, kpt=np.zeros(3)): '''Get the periodic pseudotential nuc-el AO matrix ''' from pyscf.pbc import tools coords = cell.get_uniform_grids() aoR = cell.pbc_eval_gto('GTOval', coords, kpt=kpt) nao = cell.nao_nr() SI = cell.get_SI() vlocG = get_vlocG(cell) vpplocG = -np.sum(SI * vlocG, axis=0) vpplocG[0] = np.sum(get_alphas(cell)) # from get_jvloc_G0 function # vpploc evaluated in real-space vpplocR = tools.ifft(vpplocG, cell.mesh).real vpploc = np.dot(aoR.T.conj(), vpplocR.reshape(-1, 1) * aoR) # vppnonloc evaluated in reciprocal space aokG = tools.fftk(np.asarray(aoR.T, order='C'), cell.mesh, np.exp(-1j * np.dot(coords, kpt))).T ngrids = len(aokG) fakemol = mole.Mole() fakemol._atm = np.zeros((1, mole.ATM_SLOTS), dtype=np.int32) fakemol._bas = np.zeros((1, mole.BAS_SLOTS), dtype=np.int32) ptr = mole.PTR_ENV_START fakemol._env = np.zeros(ptr + 10) fakemol._bas[0, mole.NPRIM_OF] = 1 fakemol._bas[0, mole.NCTR_OF] = 1 fakemol._bas[0, mole.PTR_EXP] = ptr + 3 fakemol._bas[0, mole.PTR_COEFF] = ptr + 4 Gv = np.asarray(cell.Gv + kpt) G_rad = lib.norm(Gv, axis=1) vppnl = np.zeros((nao, nao), dtype=np.complex128) for ia in range(cell.natm): symb = cell.atom_symbol(ia) if symb not in cell._pseudo: continue pp = cell._pseudo[symb] for l, proj in enumerate(pp[5:]): rl, nl, hl = proj if nl > 0: hl = np.asarray(hl) fakemol._bas[0, mole.ANG_OF] = l fakemol._env[ptr + 3] = .5 * rl**2 fakemol._env[ptr + 4] = rl**(l + 1.5) * np.pi**1.25 pYlm_part = fakemol.eval_gto('GTOval', Gv) pYlm = np.empty((nl, l * 2 + 1, ngrids)) for k in range(nl): qkl = _qli(G_rad * rl, l, k) pYlm[k] = pYlm_part.T * qkl # pYlm is real SPG_lmi = np.einsum('g,nmg->nmg', SI[ia].conj(), pYlm) SPG_lm_aoG = np.einsum('nmg,gp->nmp', SPG_lmi, aokG) tmp = np.einsum('ij,jmp->imp', hl, SPG_lm_aoG) vppnl += np.einsum('imp,imq->pq', SPG_lm_aoG.conj(), tmp) vppnl *= (1. / ngrids**2) if aoR.dtype == np.double: return vpploc.real + vppnl.real else: return vpploc + vppnl
def _proj_dmll(mol_nr, dm_nr, mol): from pyscf.scf import addons proj = addons.project_mo_nr2r(mol_nr, numpy.eye(mol_nr.nao_nr()), mol) # *.5 because alpha and beta are summed in project_mo_nr2r dm_ll = reduce(numpy.dot, (proj, dm_nr * .5, proj.T.conj())) dm_ll = (dm_ll + dhf.time_reversal_matrix(mol, dm_ll)) * .5 return dm_ll # A tag to label the derived SCF class class _X2C_SCF: pass if __name__ == '__main__': mol = mole.Mole() mol.build( verbose=0, atom=[["O", (0., 0., 0.)], [1, (0., -0.757, 0.587)], [1, (0., 0.757, 0.587)]], basis='ccpvdz-dk', ) method = hf.RHF(mol) enr = method.kernel() print('E(NR) = %.12g' % enr) method = UHF(mol) ex2c = method.kernel() print('E(X2C1E) = %.12g' % ex2c) method.with_x2c.basis = {'O': 'unc-ccpvqz', 'H': 'unc-ccpvdz'}
add_so('E%dy' % m, identity(idy0)) ip += nc * degen so = [] irrep_ids = [] irrep_names = list(sodic.keys()) for irname in irrep_names: irrep_ids.append(linearmole_irrep_symb2id(gpname, irname)) idx = numpy.argsort(irrep_ids) for i in idx: so.append(numpy.vstack(sodic[irrep_names[i]]).T) irrep_ids = [irrep_ids[i] for i in idx] return so, irrep_ids if __name__ == "__main__": h2o = mole.Mole() h2o.verbose = 0 h2o.output = None h2o.atom = [['O', ( 1., 0., 0., )], [1, ( 0., -.757, 0.587, )], [1, ( 0., 0.757, 0.587, )]]