Python numpy.double() Examples
The following are 30
code examples of numpy.double().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
numpy
, or try the search function
.
Example #1
Source File: cell.py From pyscf with Apache License 2.0 | 6 votes |
def lattice_vectors(self): '''Convert the primitive lattice vectors. Return 3x3 array in which each row represents one direction of the lattice vectors (unit in Bohr) ''' if isinstance(self.a, (str, unicode)): a = self.a.replace(';',' ').replace(',',' ').replace('\n',' ') a = np.asarray([float(x) for x in a.split()]).reshape(3,3) else: a = np.asarray(self.a, dtype=np.double) if isinstance(self.unit, (str, unicode)): if self.unit.startswith(('B','b','au','AU')): return a else: return a/param.BOHR else: return a/self.unit
Example #2
Source File: test_fft.py From pyscf with Apache License 2.0 | 6 votes |
def get_vjR_kpts(cell, dm_kpts, aoR_kpts): nkpts = len(aoR_kpts) coulG = tools.get_coulG(cell) rhoR = 0 for k in range(nkpts): rhoR += 1./nkpts*numint.eval_rho(cell, aoR_kpts[k], dm_kpts[k]) rhoG = tools.fft(rhoR, cell.mesh) vG = coulG*rhoG vR = tools.ifft(vG, cell.mesh) if rhoR.dtype == np.double: vR = vR.real return vR ################################################## # # scf/hf.py end # ##################################################
Example #3
Source File: test_fft.py From pyscf with Apache License 2.0 | 6 votes |
def test_get_eri_gamma(self): odf = aft.AFTDF(cell1) ref = odf.get_eri(compact=True) df = fft.FFTDF(cell1) eri0000 = df.get_eri(compact=True) self.assertTrue(eri0000.dtype == numpy.double) self.assertTrue(np.allclose(eri0000, ref, atol=1e-9, rtol=1e-9)) self.assertAlmostEqual(finger(eri0000), 0.23714016293926865, 9) ref = odf.get_eri((kpts[0],kpts[0],kpts[0],kpts[0])) eri1111 = df.get_eri((kpts[0],kpts[0],kpts[0],kpts[0])) self.assertTrue(np.allclose(eri1111, ref, atol=1e-9, rtol=1e-9)) self.assertAlmostEqual(finger(eri1111), (1.2410388899583582-5.2370501878355006e-06j), 9) eri1111 = df.get_eri((kpts[0]+1e-8,kpts[0]+1e-8,kpts[0],kpts[0])) self.assertTrue(np.allclose(eri1111, ref, atol=1e-9, rtol=1e-9)) self.assertAlmostEqual(finger(eri1111), (1.2410388899583582-5.2370501878355006e-06j), 9)
Example #4
Source File: test_uhf.py From pyscf with Apache License 2.0 | 6 votes |
def test_init_guess_by_chkfile(self): np.random.seed(1) k = np.random.random(3) mf = pscf.KUHF(cell, [k], exxdiv='vcut_sph') mf.max_cycle = 1 mf.diis = None e1 = mf.kernel() self.assertAlmostEqual(e1, -3.4070772194665477, 9) mf1 = pscf.UHF(cell, exxdiv='vcut_sph') mf1.chkfile = mf.chkfile mf1.init_guess = 'chkfile' mf1.diis = None mf1.max_cycle = 1 e1 = mf1.kernel() self.assertAlmostEqual(e1, -3.4272925247351256, 9) self.assertTrue(mf1.mo_coeff[0].dtype == np.double)
Example #5
Source File: test_mdf.py From pyscf with Apache License 2.0 | 6 votes |
def test_get_eri_gamma_high_cost(self): odf = mdf.MDF(cell) odf.linear_dep_threshold = 1e-7 odf.auxbasis = 'weigend' odf.mesh = (11,)*3 odf.eta = 0.154728892598 eri0000 = odf.get_eri() self.assertTrue(eri0000.dtype == numpy.double) self.assertAlmostEqual(eri0000.real.sum(), 140.52553833398147, 6) self.assertAlmostEqual(finger(eri0000), -1.2234059928846319, 6) eri1111 = kmdf.get_eri((kpts[0],kpts[0],kpts[0],kpts[0])) self.assertTrue(eri1111.dtype == numpy.double) self.assertAlmostEqual(eri1111.real.sum(), 140.52553833398153, 6) self.assertAlmostEqual(eri1111.imag.sum(), 0, 7) self.assertAlmostEqual(finger(eri1111), -1.2234059928846333, 6) self.assertTrue(numpy.allclose(eri1111, eri0000)) eri4444 = kmdf.get_eri((kpts[4],kpts[4],kpts[4],kpts[4])) self.assertTrue(eri4444.dtype == numpy.complex128) self.assertAlmostEqual(eri4444.real.sum(), 259.46539833377523, 6) self.assertAlmostEqual(abs(eri4444.imag).sum(), 0.00044187056294873458, 9) self.assertAlmostEqual(finger(eri4444), 1.9705270829923354-3.6097479693720031e-07j, 6) eri0000 = ao2mo.restore(1, eri0000, cell.nao_nr()).reshape(eri4444.shape) self.assertTrue(numpy.allclose(eri0000, eri4444, atol=1e-7))
Example #6
Source File: test_hf.py From pyscf with Apache License 2.0 | 6 votes |
def test_init_guess_by_chkfile(self): numpy.random.seed(1) k = numpy.random.random(3) mf = pbchf.RHF(cell, k, exxdiv='vcut_sph') mf.max_cycle = 1 mf.diis = None e1 = mf.kernel() self.assertAlmostEqual(e1, -4.132445328608581, 9) mf1 = pbchf.RHF(cell, exxdiv='vcut_sph') mf1.chkfile = mf.chkfile mf1.init_guess = 'chkfile' mf1.diis = None mf1.max_cycle = 1 e1 = mf1.kernel() self.assertAlmostEqual(e1, -4.291854736401251, 9) self.assertTrue(mf1.mo_coeff.dtype == numpy.double)
Example #7
Source File: test_mdf.py From pyscf with Apache License 2.0 | 6 votes |
def test_get_eri_gamma_1(self): odf = mdf.MDF(cell1) odf.linear_dep_threshold = 1e-7 odf.auxbasis = df.aug_etb(cell1, 1.8) odf.mesh = [6]*3 odf.eta = 0.1 eri0000 = odf.get_eri() self.assertTrue(eri0000.dtype == numpy.double) self.assertAlmostEqual(eri0000.real.sum(), 27.271885446069433, 6) self.assertAlmostEqual(finger(eri0000), 1.0614085634080137, 6) eri1111 = kmdf1.get_eri((kpts[0],kpts[0],kpts[0],kpts[0])) self.assertTrue(eri1111.dtype == numpy.double) self.assertAlmostEqual(eri1111.real.sum(), 27.271885446069433, 6) self.assertAlmostEqual(eri1111.imag.sum(), 0, 7) self.assertAlmostEqual(finger(eri0000), 1.0614085634080137, 6) self.assertAlmostEqual(abs(eri1111-eri0000).max(), 0, 12)
Example #8
Source File: test_hf.py From pyscf with Apache License 2.0 | 6 votes |
def test_rhf_vcut_sph(self): mf = pbchf.RHF(cell, exxdiv='vcut_sph') e1 = mf.kernel() self.assertAlmostEqual(e1, -4.29190260870812, 8) self.assertTrue(mf.mo_coeff.dtype == numpy.double) mf = pscf.KRHF(cell, [[0,0,0]], exxdiv='vcut_sph') e0 = mf.kernel() self.assertTrue(numpy.allclose(e0,e1)) numpy.random.seed(1) k = numpy.random.random(3) mf = pbchf.RHF(cell, k, exxdiv='vcut_sph') e1 = mf.kernel() self.assertAlmostEqual(e1, -4.1379172088570595, 8) self.assertTrue(mf.mo_coeff.dtype == numpy.complex128) mf = pscf.KRHF(cell, k, exxdiv='vcut_sph') e0 = mf.kernel() self.assertTrue(numpy.allclose(e0,e1))
Example #9
Source File: test_rohf.py From pyscf with Apache License 2.0 | 6 votes |
def test_init_guess_by_chkfile(self): np.random.seed(1) k = np.random.random(3) mf = pscf.KROHF(cell, [k], exxdiv='vcut_sph') mf.init_guess = 'hcore' mf.max_cycle = 1 mf.diis = None e1 = mf.kernel() self.assertAlmostEqual(e1, -3.4376090968645068, 9) mf1 = pscf.ROHF(cell, exxdiv='vcut_sph') mf1.chkfile = mf.chkfile mf1.init_guess = 'chkfile' mf1.diis = None mf1.max_cycle = 1 e1 = mf1.kernel() self.assertAlmostEqual(e1, -3.4190632006601662, 9) self.assertTrue(mf1.mo_coeff[0].dtype == np.double)
Example #10
Source File: test_df.py From pyscf with Apache License 2.0 | 6 votes |
def test_get_eri_gamma(self): odf = df.DF(cell) odf.linear_dep_threshold = 1e-7 odf.auxbasis = 'weigend' odf.mesh = (6,)*3 eri0000 = odf.get_eri() self.assertTrue(eri0000.dtype == numpy.double) self.assertAlmostEqual(eri0000.real.sum(), 41.61280626625331, 9) self.assertAlmostEqual(finger(eri0000), 1.9981472468639465, 9) eri1111 = kmdf.get_eri((kpts[0],kpts[0],kpts[0],kpts[0])) self.assertTrue(eri1111.dtype == numpy.double) self.assertAlmostEqual(eri1111.real.sum(), 41.61280626625331, 9) self.assertAlmostEqual(eri1111.imag.sum(), 0, 9) self.assertAlmostEqual(finger(eri1111), 1.9981472468639465, 9) self.assertAlmostEqual(abs(eri1111-eri0000).max(), 0, 9) eri4444 = kmdf.get_eri((kpts[4],kpts[4],kpts[4],kpts[4])) self.assertTrue(eri4444.dtype == numpy.complex128) self.assertAlmostEqual(eri4444.real.sum(), 62.55120674032798, 9) self.assertAlmostEqual(abs(eri4444.imag).sum(), 0.0016507912195378644, 7) self.assertAlmostEqual(finger(eri4444), 0.6206014899350296-7.413680313987067e-05j, 8) eri0000 = ao2mo.restore(1, eri0000, cell.nao_nr()).reshape(eri4444.shape) self.assertAlmostEqual(abs(eri0000-eri4444).max(), 0, 4)
Example #11
Source File: rohf.py From pyscf with Apache License 2.0 | 6 votes |
def get_veff(self, cell=None, dm=None, dm_last=0, vhf_last=0, hermi=1, kpt=None, kpts_band=None): if cell is None: cell = self.cell if dm is None: dm = self.make_rdm1() if kpt is None: kpt = self.kpt if isinstance(dm, np.ndarray) and dm.ndim == 2: dm = np.asarray((dm*.5,dm*.5)) if getattr(dm, 'mo_coeff', None) is not None: mo_coeff = dm.mo_coeff mo_occ_a = (dm.mo_occ > 0).astype(np.double) mo_occ_b = (dm.mo_occ ==2).astype(np.double) dm = lib.tag_array(dm, mo_coeff=(mo_coeff,mo_coeff), mo_occ=(mo_occ_a,mo_occ_b)) vj, vk = self.get_jk(cell, dm, hermi, kpt, kpts_band) vhf = vj[0] + vj[1] - vk return vhf
Example #12
Source File: aft.py From pyscf with Apache License 2.0 | 6 votes |
def _fake_nuc(cell): fakenuc = copy.copy(cell) fakenuc._atm = cell._atm.copy() fakenuc._atm[:,gto.PTR_COORD] = numpy.arange(gto.PTR_ENV_START, gto.PTR_ENV_START+cell.natm*3,3) _bas = [] _env = [0]*gto.PTR_ENV_START + [cell.atom_coords().ravel()] ptr = gto.PTR_ENV_START + cell.natm * 3 half_sph_norm = .5/numpy.sqrt(numpy.pi) for ia in range(cell.natm): symb = cell.atom_symbol(ia) if symb in cell._pseudo: pp = cell._pseudo[symb] rloc, nexp, cexp = pp[1:3+1] eta = .5 / rloc**2 else: eta = 1e16 norm = half_sph_norm/gto.gaussian_int(2, eta) _env.extend([eta, norm]) _bas.append([ia, 0, 1, 1, 0, ptr, ptr+1, 0]) ptr += 2 fakenuc._bas = numpy.asarray(_bas, dtype=numpy.int32) fakenuc._env = numpy.asarray(numpy.hstack(_env), dtype=numpy.double) fakenuc.rcut = cell.rcut return fakenuc
Example #13
Source File: numint.py From pyscf with Apache License 2.0 | 6 votes |
def _format_uks_dm(dms): dma, dmb = dms if getattr(dms, 'mo_coeff', None) is not None: #TODO: test whether dm.mo_coeff matching dm mo_coeff = dms.mo_coeff mo_occ = dms.mo_occ if (isinstance(mo_coeff[0], numpy.ndarray) and mo_coeff[0].ndim < dma.ndim): # handle ROKS mo_occa = [numpy.array(occ> 0, dtype=numpy.double) for occ in mo_occ] mo_occb = [numpy.array(occ==2, dtype=numpy.double) for occ in mo_occ] dma = lib.tag_array(dma, mo_coeff=mo_coeff, mo_occ=mo_occa) dmb = lib.tag_array(dmb, mo_coeff=mo_coeff, mo_occ=mo_occb) else: dma = lib.tag_array(dma, mo_coeff=mo_coeff[0], mo_occ=mo_occ[0]) dmb = lib.tag_array(dmb, mo_coeff=mo_coeff[1], mo_occ=mo_occ[1]) return dma, dmb
Example #14
Source File: numint.py From pyscf with Apache License 2.0 | 6 votes |
def _contract_rho(bra, ket): #:rho = numpy.einsum('pi,pi->p', bra.real, ket.real) #:rho += numpy.einsum('pi,pi->p', bra.imag, ket.imag) bra = bra.T ket = ket.T nao, ngrids = bra.shape rho = numpy.empty(ngrids) if not (bra.flags.c_contiguous and ket.flags.c_contiguous): rho = numpy.einsum('ip,ip->p', bra.real, ket.real) rho += numpy.einsum('ip,ip->p', bra.imag, ket.imag) elif bra.dtype == numpy.double and ket.dtype == numpy.double: libdft.VXC_dcontract_rho(rho.ctypes.data_as(ctypes.c_void_p), bra.ctypes.data_as(ctypes.c_void_p), ket.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(nao), ctypes.c_int(ngrids)) elif bra.dtype == numpy.complex128 and ket.dtype == numpy.complex128: libdft.VXC_zcontract_rho(rho.ctypes.data_as(ctypes.c_void_p), bra.ctypes.data_as(ctypes.c_void_p), ket.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(nao), ctypes.c_int(ngrids)) else: rho = numpy.einsum('ip,ip->p', bra.real, ket.real) rho += numpy.einsum('ip,ip->p', bra.imag, ket.imag) return rho
Example #15
Source File: _vhf.py From pyscf with Apache License 2.0 | 6 votes |
def set_dm(self, dm, atm, bas, env): if self._dmcondname is not None: c_atm = numpy.asarray(atm, dtype=numpy.int32, order='C') c_bas = numpy.asarray(bas, dtype=numpy.int32, order='C') c_env = numpy.asarray(env, dtype=numpy.double, order='C') natm = ctypes.c_int(c_atm.shape[0]) nbas = ctypes.c_int(c_bas.shape[0]) if isinstance(dm, numpy.ndarray) and dm.ndim == 2: n_dm = 1 else: n_dm = len(dm) dm = numpy.asarray(dm, order='C') ao_loc = make_loc(c_bas, self._intor) fsetdm = getattr(libcvhf, self._dmcondname) fsetdm(self._this, dm.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(n_dm), ao_loc.ctypes.data_as(ctypes.c_void_p), c_atm.ctypes.data_as(ctypes.c_void_p), natm, c_bas.ctypes.data_as(ctypes.c_void_p), nbas, c_env.ctypes.data_as(ctypes.c_void_p))
Example #16
Source File: rohf.py From pyscf with Apache License 2.0 | 6 votes |
def get_veff(self, mol=None, dm=None, dm_last=0, vhf_last=0, hermi=1): if mol is None: mol = self.mol if dm is None: dm = self.make_rdm1() if isinstance(dm, numpy.ndarray) and dm.ndim == 2: dm = numpy.array((dm*.5, dm*.5)) if self._eri is not None or not self.direct_scf: if getattr(dm, 'mo_coeff', None) is not None: mo_coeff = dm.mo_coeff mo_occ_a = (dm.mo_occ > 0).astype(numpy.double) mo_occ_b = (dm.mo_occ ==2).astype(numpy.double) dm = lib.tag_array(dm, mo_coeff=(mo_coeff,mo_coeff), mo_occ=(mo_occ_a,mo_occ_b)) vj, vk = self.get_jk(mol, dm, hermi) vhf = vj[0] + vj[1] - vk else: ddm = dm - numpy.asarray(dm_last) vj, vk = self.get_jk(mol, ddm, hermi) vhf = vj[0] + vj[1] - vk vhf += numpy.asarray(vhf_last) return vhf
Example #17
Source File: moleintor.py From pyscf with Apache License 2.0 | 6 votes |
def make_cintopt(atm, bas, env, intor): intor = intor.replace('_sph','').replace('_cart','').replace('_spinor','') c_atm = numpy.asarray(atm, dtype=numpy.int32, order='C') c_bas = numpy.asarray(bas, dtype=numpy.int32, order='C') c_env = numpy.asarray(env, dtype=numpy.double, order='C') natm = c_atm.shape[0] nbas = c_bas.shape[0] cintopt = lib.c_null_ptr() # TODO: call specific ECP optimizers for each intor. if intor[:3] == 'ECP': foptinit = libcgto.ECPscalar_optimizer foptinit(ctypes.byref(cintopt), c_atm.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(natm), c_bas.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(nbas), c_env.ctypes.data_as(ctypes.c_void_p)) return ctypes.cast(cintopt, _ecpoptHandler) else: foptinit = getattr(libcgto, intor+'_optimizer') foptinit(ctypes.byref(cintopt), c_atm.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(natm), c_bas.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(nbas), c_env.ctypes.data_as(ctypes.c_void_p)) return ctypes.cast(cintopt, _cintoptHandler)
Example #18
Source File: dascmop.py From pymoo with Apache License 2.0 | 6 votes |
def __init__(self, n_obj, n_constr, difficulty, **kwargs): super().__init__(n_var=30, n_obj=n_obj, n_constr=n_constr, type_var=np.double, xl=0., xu=1., **kwargs) if isinstance(difficulty, int): self.difficulty = difficulty if not (1 <= difficulty <= len(DIFFICULTIES)): raise Exception(f"Difficulty must be 1 <= difficulty <= {len(DIFFICULTIES)}, but it is {difficulty}!") vals = DIFFICULTIES[difficulty-1] else: self.difficulty = -1 vals = difficulty self.eta, self.zeta, self.gamma = vals
Example #19
Source File: eom_uccsd.py From pyscf with Apache License 2.0 | 6 votes |
def get_init_guess(self, nroots=1, koopmans=True, diag=None): if koopmans: nocca, noccb = self.nocc nmoa, nmob = self.nmo nvira, nvirb = nmoa-nocca, nmob-noccb idx = diag[:nvira+nvirb].argsort() else: idx = diag.argsort() size = self.vector_size() dtype = getattr(diag, 'dtype', np.double) nroots = min(nroots, size) guess = [] for i in idx[:nroots]: g = np.zeros(size, dtype) g[i] = 1.0 guess.append(g) return guess
Example #20
Source File: linalg_helper.py From pyscf with Apache License 2.0 | 6 votes |
def pick_real_eigs(w, v, nroots, envs): '''This function searchs the real eigenvalues or eigenvalues with small imaginary component. ''' threshold = 1e-3 abs_imag = abs(w.imag) # Grab `nroots` number of e with small(est) imaginary components max_imag_tol = max(threshold, numpy.sort(abs_imag)[min(w.size,nroots)-1]) real_idx = numpy.where((abs_imag <= max_imag_tol))[0] nbelow_thresh = numpy.count_nonzero(abs_imag[real_idx] < threshold) if nbelow_thresh < nroots and w.size >= nroots: warnings.warn('Only %d eigenvalues (out of %3d requested roots) with imaginary part < %4.3g.\n' % (nbelow_thresh, min(w.size,nroots), threshold)) # Guess whether the matrix to diagonalize is real or complex if envs.get('dtype') == numpy.double: w, v, idx = _eigs_cmplx2real(w, v, real_idx, real_eigenvectors=True) else: w, v, idx = _eigs_cmplx2real(w, v, real_idx, real_eigenvectors=False) return w, v, idx
Example #21
Source File: eom_uccsd.py From pyscf with Apache License 2.0 | 6 votes |
def get_init_guess(self, nroots=1, koopmans=True, diag=None): if koopmans: nocca, noccb = self.nocc nmoa, nmob = self.nmo nvira, nvirb = nmoa-nocca, nmob-noccb idx = diag[:nocca*nvirb+noccb*nvira].argsort() else: idx = diag.argsort() size = self.vector_size() dtype = getattr(diag, 'dtype', np.double) nroots = min(nroots, size) guess = [] for i in idx[:nroots]: g = np.zeros(size, dtype) g[i] = 1.0 guess.append(g) return guess
Example #22
Source File: eom_rccsd.py From pyscf with Apache License 2.0 | 6 votes |
def get_init_guess(self, nroots=1, koopmans=True, diag=None): size = self.vector_size() dtype = getattr(diag, 'dtype', np.double) nroots = min(nroots, size) guess = [] if koopmans: for n in range(nroots): g = np.zeros(int(size), dtype) g[self.nocc-n-1] = 1.0 guess.append(g) else: idx = diag.argsort()[:nroots] for i in idx: g = np.zeros(int(size), dtype) g[i] = 1.0 guess.append(g) return guess
Example #23
Source File: cell.py From pyscf with Apache License 2.0 | 6 votes |
def get_uniform_grids(cell, mesh=None, **kwargs): '''Generate a uniform real-space grid consistent w/ samp thm; see MH (3.19). Args: cell : instance of :class:`Cell` Returns: coords : (ngx*ngy*ngz, 3) ndarray The real-space grid point coordinates. ''' if mesh is None: mesh = cell.mesh if 'gs' in kwargs: warnings.warn('cell.gs is deprecated. It is replaced by cell.mesh,' 'the number of PWs (=2*gs+1) along each direction.') mesh = [2*n+1 for n in kwargs['gs']] mesh = np.asarray(mesh, dtype=np.double) qv = lib.cartesian_prod([np.arange(x) for x in mesh]) a_frac = np.einsum('i,ij->ij', 1./mesh, cell.lattice_vectors()) coords = np.dot(qv, a_frac) return coords
Example #24
Source File: eom_rccsd.py From pyscf with Apache License 2.0 | 6 votes |
def get_init_guess(self, nroots=1, koopmans=True, diag=None): if koopmans: nocc = self.nocc nvir = self.nmo - nocc idx = diag[:nocc*nvir].argsort() else: idx = diag.argsort() size = self.vector_size() dtype = getattr(diag, 'dtype', np.double) nroots = min(nroots, size) guess = [] for i in idx[:nroots]: g = np.zeros(size, dtype) g[i] = 1.0 guess.append(g) return guess
Example #25
Source File: mole.py From pyscf with Apache License 2.0 | 5 votes |
def make_bas_env(basis_add, atom_id=0, ptr=0): '''Convert :attr:`Mole.basis` to the argument ``bas`` for ``libcint`` integrals ''' _bas = [] _env = [] for b in basis_add: if not b: # == [] continue angl = b[0] #if angl in [6, 7]: # print('libcint may have large error for ERI of i function') if isinstance(b[1], int): kappa = b[1] b_coeff = numpy.array(sorted(list(b[2:]), reverse=True)) else: kappa = 0 b_coeff = numpy.array(sorted(list(b[1:]), reverse=True)) es = b_coeff[:,0] cs = b_coeff[:,1:] nprim, nctr = cs.shape if NORMALIZE_GTO: cs = numpy.einsum('pi,p->pi', cs, gto_norm(angl, es)) cs = _nomalize_contracted_ao(angl, es, cs) _env.append(es) _env.append(cs.T.reshape(-1)) ptr_exp = ptr ptr_coeff = ptr_exp + nprim ptr = ptr_coeff + nprim * nctr _bas.append([atom_id, angl, nprim, nctr, kappa, ptr_exp, ptr_coeff, 0]) _env = lib.flatten(_env) # flatten nested lists return (numpy.array(_bas, numpy.int32).reshape(-1,BAS_SLOTS), numpy.array(_env, numpy.double))
Example #26
Source File: fft_ao2mo.py From pyscf with Apache License 2.0 | 5 votes |
def _contract_plain(mydf, mos, coulG, phase, max_memory): cell = mydf.cell moiT, mojT, mokT, molT = mos nmoi, nmoj, nmok, nmol = [x.shape[0] for x in mos] ngrids = moiT.shape[1] wcoulG = coulG * (cell.vol/ngrids) dtype = numpy.result_type(phase, *mos) eri = numpy.empty((nmoi*nmoj,nmok*nmol), dtype=dtype) blksize = int(min(max(nmoi,nmok), (max_memory*1e6/16 - eri.size)/2/ngrids/max(nmoj,nmol)+1)) assert blksize > 0 buf0 = numpy.empty((blksize,max(nmoj,nmol),ngrids), dtype=dtype) buf1 = numpy.ndarray((blksize,nmoj,ngrids), dtype=dtype, buffer=buf0) buf2 = numpy.ndarray((blksize,nmol,ngrids), dtype=dtype, buffer=buf0) for p0, p1 in lib.prange(0, nmoi, blksize): mo_pairs = numpy.einsum('ig,jg->ijg', moiT[p0:p1].conj()*phase, mojT, out=buf1[:p1-p0]) mo_pairs_G = tools.fft(mo_pairs.reshape(-1,ngrids), mydf.mesh) mo_pairs = None mo_pairs_G*= wcoulG v = tools.ifft(mo_pairs_G, mydf.mesh) mo_pairs_G = None v *= phase.conj() if dtype == numpy.double: v = numpy.asarray(v.real, order='C') for q0, q1 in lib.prange(0, nmok, blksize): mo_pairs = numpy.einsum('ig,jg->ijg', mokT[q0:q1].conj(), molT, out=buf2[:q1-q0]) eri[p0*nmoj:p1*nmoj,q0*nmol:q1*nmol] = lib.dot(v, mo_pairs.reshape(-1,ngrids).T) v = None return eri
Example #27
Source File: test_fft.py From pyscf with Apache License 2.0 | 5 votes |
def get_vjR(cell, dm, aoR): coulG = tools.get_coulG(cell) rhoR = numint.eval_rho(cell, aoR, dm) rhoG = tools.fft(rhoR, cell.mesh) vG = coulG*rhoG vR = tools.ifft(vG, cell.mesh) if rhoR.dtype == np.double: vR = vR.real return vR
Example #28
Source File: mole.py From pyscf with Apache License 2.0 | 5 votes |
def atom_charges(self): '''np.asarray([mol.atom_charge(i) for i in range(mol.natm)])''' z = self._atm[:,CHARGE_OF] if numpy.any(self._atm[:,NUC_MOD_OF] == NUC_FRAC_CHARGE): # Create the integer nuclear charges first then replace the MM # particles with the MM charges that saved in _env[PTR_FRAC_CHARGE] z = numpy.array(z, dtype=numpy.double) idx = self._atm[:,NUC_MOD_OF] == NUC_FRAC_CHARGE # MM fractional charges can be positive or negative z[idx] = self._env[self._atm[idx,PTR_FRAC_CHARGE]] return z
Example #29
Source File: numint.py From pyscf with Apache License 2.0 | 5 votes |
def _dot_ao_ao(mol, ao1, ao2, non0tab, shls_slice, ao_loc, hermi=0): '''return numpy.dot(ao1.T, ao2)''' ngrids, nao = ao1.shape if nao < SWITCH_SIZE: return lib.dot(ao1.T.conj(), ao2) if not ao1.flags.f_contiguous: ao1 = lib.transpose(ao1) if not ao2.flags.f_contiguous: ao2 = lib.transpose(ao2) if ao1.dtype == ao2.dtype == numpy.double: fn = libdft.VXCdot_ao_ao else: fn = libdft.VXCzdot_ao_ao ao1 = numpy.asarray(ao1, numpy.complex128) ao2 = numpy.asarray(ao2, numpy.complex128) if non0tab is None or shls_slice is None or ao_loc is None: pnon0tab = pshls_slice = pao_loc = lib.c_null_ptr() else: pnon0tab = non0tab.ctypes.data_as(ctypes.c_void_p) pshls_slice = (ctypes.c_int*2)(*shls_slice) pao_loc = ao_loc.ctypes.data_as(ctypes.c_void_p) vv = numpy.empty((nao,nao), dtype=ao1.dtype) fn(vv.ctypes.data_as(ctypes.c_void_p), ao1.ctypes.data_as(ctypes.c_void_p), ao2.ctypes.data_as(ctypes.c_void_p), ctypes.c_int(nao), ctypes.c_int(ngrids), ctypes.c_int(mol.nbas), ctypes.c_int(hermi), pnon0tab, pshls_slice, pao_loc) return vv
Example #30
Source File: eom_rccsd.py From pyscf with Apache License 2.0 | 5 votes |
def make_imds(self, eris=None): imds = _IMDS(self._cc, eris=eris) imds.make_t3p2_ea(self._cc, self.partition) return imds ######################################## # EOM-EE-CCSD ######################################## #TODO: double spin-flip EOM-EE