本文整理汇总了Python中pyscf.lib.finger函数的典型用法代码示例。如果您正苦于以下问题:Python finger函数的具体用法?Python finger怎么用?Python finger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了finger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rand_ccsd_frozen2
def test_rand_ccsd_frozen2(self):
'''Single (eom-)ccsd iteration with random t1/t2 and full occupied frozen
at a single k-point.'''
kmf = pbcscf.addons.convert_to_ghf(rand_kmf)
# Round to make this insensitive to small changes between PySCF versions
mat_veff = kmf.get_veff().round(4)
mat_hcore = kmf.get_hcore().round(4)
kmf.get_veff = lambda *x: mat_veff
kmf.get_hcore = lambda *x: mat_hcore
frozen = [[],[0,1,2,3],[]]
rand_cc = pbcc.KGCCSD(kmf, frozen=frozen)
eris = rand_cc.ao2mo(rand_cc.mo_coeff)
eris.mo_energy = [eris.fock[k].diagonal() for k in range(rand_cc.nkpts)]
t1, t2 = rand_t1_t2(kmf, rand_cc)
# Manually zero'ing out the frozen elements of the t1/t2
# N.B. the 0'th element frozen means we are freezing the 1'th
# element in the current padding scheme
t1[1, [0,1,2,3]] = 0.0
t2[1, :, :, [0,1,2,3], :] = 0.0
t2[:, 1, :, :, [0,1,2,3]] = 0.0
Ht1, Ht2 = rand_cc.update_amps(t1, t2, eris)
self.assertAlmostEqual(finger(Ht1), (-19.2772171332-10.5977304455j), 6)
self.assertAlmostEqual(finger(Ht2), (227.434582141+298.826965082j), 6)
示例2: test_eris_contract_vvvv_t2
def test_eris_contract_vvvv_t2(self):
mol = gto.Mole()
nocca, noccb, nvira, nvirb = 5, 4, 12, 13
nvira_pair = nvira*(nvira+1)//2
nvirb_pair = nvirb*(nvirb+1)//2
numpy.random.seed(9)
t2 = numpy.random.random((nocca,noccb,nvira,nvirb))
eris = uccsd._ChemistsERIs()
eris.vvVV = numpy.random.random((nvira_pair,nvirb_pair))
eris.mol = mol
myucc.max_memory, bak = 0, myucc.max_memory
vt2 = eris._contract_vvVV_t2(myucc, t2, eris.vvVV)
myucc.max_memory = bak
self.assertAlmostEqual(lib.finger(vt2), 12.00904827896089, 11)
idxa = lib.square_mat_in_trilu_indices(nvira)
idxb = lib.square_mat_in_trilu_indices(nvirb)
vvVV = eris.vvVV[:,idxb][idxa]
ref = lib.einsum('acbd,ijcd->ijab', vvVV, t2)
self.assertAlmostEqual(abs(vt2 - ref).max(), 0, 11)
# _contract_VVVV_t2, testing complex and real mixed contraction
VVVV =(numpy.random.random((nvirb,nvirb,nvirb,nvirb)) +
numpy.random.random((nvirb,nvirb,nvirb,nvirb))*1j - (.5+.5j))
VVVV = VVVV + VVVV.transpose(1,0,3,2).conj()
VVVV = VVVV + VVVV.transpose(2,3,0,1)
eris.VVVV = VVVV
t2 = numpy.random.random((noccb,noccb,nvirb,nvirb))
t2 = t2 - t2.transpose(0,1,3,2)
t2 = t2 - t2.transpose(1,0,3,2)
myucc.max_memory, bak = 0, myucc.max_memory
vt2 = eris._contract_VVVV_t2(myucc, t2, eris.VVVV)
myucc.max_memory = bak
self.assertAlmostEqual(lib.finger(vt2), 47.903883794299404-50.501573400833429j, 11)
ref = lib.einsum('acbd,ijcd->ijab', eris.VVVV, t2)
self.assertAlmostEqual(abs(vt2 - ref).max(), 0, 11)
示例3: test_aux_e2
def test_aux_e2(self):
nao = mol.nao_nr()
naoaux = auxmol.nao_nr()
eri0 = numpy.empty((nao,nao,naoaux))
pi = 0
for i in range(mol.nbas):
pj = 0
for j in range(mol.nbas):
pk = 0
for k in range(mol.nbas, mol.nbas+auxmol.nbas):
shls = (i, j, k)
buf = gto.moleintor.getints_by_shell('int3c2e_sph',
shls, atm, bas, env)
di, dj, dk = buf.shape
eri0[pi:pi+di,pj:pj+dj,pk:pk+dk] = buf
pk += dk
pj += dj
pi += di
j3c = df.incore.aux_e2(mol, auxmol, intor='int3c2e_sph', aosym='s1')
self.assertTrue(numpy.allclose(eri0, j3c.reshape(nao,nao,naoaux)))
self.assertAlmostEqual(lib.finger(j3c), 48.11812978990752, 9)
idx = numpy.tril_indices(nao)
j3c = df.incore.aux_e2(mol, auxmol, intor='int3c2e_sph', aosym='s2ij')
self.assertTrue(numpy.allclose(eri0[idx], j3c))
self.assertAlmostEqual(lib.finger(j3c), 4.6774743051154459, 9)
示例4: test_coulG
def test_coulG(self):
numpy.random.seed(19)
kpt = numpy.random.random(3)
cell = pbcgto.Cell()
cell.unit = 'A'
cell.atom = 'C 0., 0., 0.; C 0.8917, 0.8917, 0.8917'
cell.a = numpy.array(((0. , 1.7834, 1.7834),
(1.7834, 0. , 1.7834),
(1.7834, 1.7834, 0. ),)) + numpy.random.random((3,3)).T
cell.basis = 'gth-szv'
cell.pseudo = 'gth-pade'
cell.mesh = [11,9,7]
cell.verbose = 5
cell.output = '/dev/null'
cell.build()
coulG = tools.get_coulG(cell, kpt)
self.assertAlmostEqual(lib.finger(coulG), 62.75448804333378, 9)
cell.a = numpy.eye(3)
cell.unit = 'B'
coulG = tools.get_coulG(cell, numpy.array([0, numpy.pi, 0]))
self.assertAlmostEqual(lib.finger(coulG), 4.6737453679713905, 9)
coulG = tools.get_coulG(cell, numpy.array([0, numpy.pi, 0]),
wrap_around=False)
self.assertAlmostEqual(lib.finger(coulG), 4.5757877990664744, 9)
coulG = tools.get_coulG(cell, exx='ewald')
self.assertAlmostEqual(lib.finger(coulG), 4.888843468914021, 9)
示例5: test_make_rdm1
def test_make_rdm1(self):
dm1 = mc.make_rdm1()
self.assertAlmostEqual(lib.finger(dm1), -5.0290089869374492, 5)
dm1 = mc.analyze(with_meta_lowdin=False)
self.assertAlmostEqual(lib.finger(dm1[0]), -5.7326112327013377, 5)
self.assertAlmostEqual(lib.finger(dm1[1]), 0.70360224576388797, 5)
self.assertAlmostEqual(lib.finger(dm1[0]+dm1[1]), -5.0290089869374492, 5)
示例6: test_rand_ccsd_frozen1
def test_rand_ccsd_frozen1(self):
'''Single (eom-)ccsd iteration with random t1/t2 and single frozen occupied
orbital.'''
kmf = pbcscf.addons.convert_to_ghf(rand_kmf)
# Round to make this insensitive to small changes between PySCF versions
mat_veff = kmf.get_veff().round(4)
mat_hcore = kmf.get_hcore().round(4)
kmf.get_veff = lambda *x: mat_veff
kmf.get_hcore = lambda *x: mat_hcore
frozen = [[0,],[],[]]
rand_cc = pbcc.KGCCSD(kmf, frozen=frozen)
eris = rand_cc.ao2mo(rand_cc.mo_coeff)
eris.mo_energy = [eris.fock[k].diagonal() for k in range(rand_cc.nkpts)]
t1, t2 = rand_t1_t2(kmf, rand_cc)
# Manually zero'ing out the frozen elements of the t1/t2
# N.B. the 0'th element frozen means we are freezing the 1'th
# element in the current padding scheme
t1[0, 1] = 0.0
t2[0, :, :, 1, :] = 0.0
t2[:, 0, :, :, 1] = 0.0
Ht1, Ht2 = rand_cc.update_amps(t1, t2, eris)
self.assertAlmostEqual(finger(Ht1), (-15.7950827762+31.0483053388j), 6)
self.assertAlmostEqual(finger(Ht2), (263.884192539+96.7615664563j), 6)
示例7: test_canonicalize1
def test_canonicalize1(self):
numpy.random.seed(1)
f1 = numpy.random.random(mcr.mo_coeff.shape)
u1 = numpy.linalg.svd(f1)[0]
mo1 = numpy.dot(mcr.mo_coeff, u1)
mo1 = lib.tag_array(mo1, orbsym=mcr.mo_coeff.orbsym)
mo, ci, mo_e = mcr.canonicalize(mo1)
e1 = numpy.einsum('ji,jk,ki', mo, f1, mo)
self.assertAlmostEqual(e1, 44.2658681077, 7)
self.assertAlmostEqual(lib.finger(mo_e), 5.1364166175063097, 7)
mo, ci, mo_e = mcr.canonicalize(mo1, eris=mcr.ao2mo(mcr.mo_coeff))
e1 = numpy.einsum('ji,jk,ki', mo, f1, mo)
self.assertAlmostEqual(e1, 44.2658681077, 7)
self.assertAlmostEqual(lib.finger(mo_e), 4.1206025804989173, 7)
mcr1 = copy.copy(mcr)
mcr1.frozen = 2
mo, ci, mo_e = mcr1.canonicalize(mo1)
self.assertAlmostEqual(lib.finger(mo_e), 6.6030999409178577, 7)
mcr1.frozen = [0,1]
mo, ci, mo_e = mcr1.canonicalize(mo1)
self.assertAlmostEqual(lib.finger(mo_e), 6.6030999409178577, 7)
mcr1.frozen = [1,12]
mo, ci, mo_e = mcr1.canonicalize(mo1)
self.assertAlmostEqual(lib.finger(mo_e), 5.2182584355788162, 7)
示例8: test_p
def test_p(self):
numpy.random.seed(2)
a = numpy.random.random((3,3,3))
self.assertAlmostEqual(lib.finger(cc.p('a.c', a)), -1.1768882755852079, 12)
self.assertAlmostEqual(lib.finger(cc.p('.ab', a)), -1.9344875839983993, 12)
self.assertAlmostEqual(lib.finger(cc.p('abc', a)), -0.0055534783760265282, 14)
self.assertAlmostEqual(abs(cc.p('a.a', a) - a).max(), 0, 12)
示例9: test_rand_ccsd_frozen0
def test_rand_ccsd_frozen0(self):
'''Single (eom-)ccsd iteration with random t1/t2 and lowest lying orbital
at multiple k-points frozen.'''
kmf = pbcscf.addons.convert_to_ghf(rand_kmf)
# Round to make this insensitive to small changes between PySCF versions
mat_veff = kmf.get_veff().round(4)
mat_hcore = kmf.get_hcore().round(4)
kmf.get_veff = lambda *x: mat_veff
kmf.get_hcore = lambda *x: mat_hcore
# frozen = 1
rand_cc = pbcc.KGCCSD(kmf, frozen=1)
eris = rand_cc.ao2mo(rand_cc.mo_coeff)
eris.mo_energy = [eris.fock[k].diagonal() for k in range(rand_cc.nkpts)]
t1, t2 = rand_t1_t2(kmf, rand_cc)
Ht1, Ht2 = rand_cc.update_amps(t1, t2, eris)
self.assertAlmostEqual(finger(Ht1), (12.6235870016-0.263432509044j), 6)
self.assertAlmostEqual(finger(Ht2), (94.8802678168+910.369938369j), 6)
# frozen = [[0,],[0,],[0,]], should be same as above
frozen = [[0,],[0,],[0,]]
rand_cc = pbcc.KGCCSD(kmf, frozen=frozen)
eris = rand_cc.ao2mo(rand_cc.mo_coeff)
eris.mo_energy = [eris.fock[k].diagonal() for k in range(rand_cc.nkpts)]
t1, t2 = rand_t1_t2(rand_kmf, rand_cc)
Ht1, Ht2 = rand_cc.update_amps(t1, t2, eris)
self.assertAlmostEqual(finger(Ht1), (12.6235870016-0.263432509044j), 6)
self.assertAlmostEqual(finger(Ht2), (94.8802678168+910.369938369j), 6)
示例10: test_init_guess_by_1e
def test_init_guess_by_1e(self):
dm = mf.get_init_guess(key='1e')
self.assertAlmostEqual(lib.finger(dm), 0.025922864381755062, 9)
dm = kmf.get_init_guess(key='1e')
self.assertEqual(dm.ndim, 3)
self.assertAlmostEqual(lib.finger(dm), 0.025922864381755062, 9)
示例11: test_init_guess_minao
def test_init_guess_minao(self):
mol = gto.M(
verbose = 7,
output = '/dev/null',
atom = '''
O 0 0 0
H1 0 -0.757 0.587
H2 0 0.757 0.587''',
basis = 'ccpvdz',
)
dm = scf.hf.get_init_guess(mol, key='minao')
self.assertAlmostEqual(lib.finger(dm), 2.5912875957299684, 9)
mol1 = gto.M(atom='Mo', basis='lanl2dz', ecp='lanl2dz',
verbose=7, output='/dev/null')
dm = scf.hf.get_init_guess(mol1, key='minao')
self.assertAlmostEqual(lib.finger(dm), 1.5371195992125495, 9)
self.assertAlmostEqual(numpy.einsum('ij,ji->', dm, mol1.intor('int1e_ovlp')), 14, 9)
mol1.basis = 'sto3g'
mol1.build(0, 0)
dm = scf.hf.get_init_guess(mol1, key='minao')
self.assertAlmostEqual(lib.finger(dm), 1.8936729909734513, 9)
self.assertAlmostEqual(numpy.einsum('ij,ji->', dm, mol1.intor('int1e_ovlp')), 13.4787347477, 7)
mol1.stdout.close()
示例12: test_get_veff
def test_get_veff(self):
mf = pscf.RHF(cell)
numpy.random.seed(1)
nao = cell.nao_nr()
dm = numpy.random.random((nao,nao)) + numpy.random.random((nao,nao))*1j
dm = dm + dm.conj().T
v11 = mf.get_veff(cell, dm, kpt=cell.get_abs_kpts([.25,.25,.25]))
v12 = mf.get_veff(cell, dm, kpts_band=cell.get_abs_kpts([.25,.25,.25]))
v13 = mf.get_veff(cell, dm, kpt=cell.get_abs_kpts([-1./3,1./3,.25]),
kpts_band=cell.get_abs_kpts([.25,.25,.25]))
v14 = mf.get_veff(cell, dm, kpt=cell.get_abs_kpts([-1./3,1./3,.25]),
kpts_band=cell.make_kpts([2,1,1]))
self.assertTrue(v11.dtype == numpy.complex128)
self.assertTrue(v12.dtype == numpy.complex128)
mf = pscf.UHF(cell)
v21 = mf.get_veff(cell, dm, kpt=cell.get_abs_kpts([.25,.25,.25]))
dm = [dm*.5,dm*.5]
v22 = mf.get_veff(cell, dm, kpts_band=cell.get_abs_kpts([.25,.25,.25]))
v23 = mf.get_veff(cell, dm, kpt=cell.get_abs_kpts([-1./3,1./3,.25]),
kpts_band=cell.get_abs_kpts([.25,.25,.25]))
v24 = mf.get_veff(cell, dm, kpt=cell.get_abs_kpts([-1./3,1./3,.25]),
kpts_band=cell.make_kpts([2,1,1]))
self.assertAlmostEqual(abs(v11-v21).max(), 0, 9)
self.assertAlmostEqual(abs(v12-v22).max(), 0, 9)
self.assertAlmostEqual(abs(v13-v23).max(), 0, 9)
self.assertAlmostEqual(abs(v14-v24).max(), 0, 9)
self.assertAlmostEqual(lib.finger(v11), -0.30110964334164825+0.81409418199767414j, 9)
self.assertAlmostEqual(lib.finger(v12), -2.1601376488983997-9.4070613374115908j, 9)
示例13: test_define_xc
def test_define_xc(self):
def eval_xc(xc_code, rho, spin=0, relativity=0, deriv=1, verbose=None):
# A fictitious XC functional to demonstrate the usage
rho0, dx, dy, dz = rho[:4]
gamma = (dx**2 + dy**2 + dz**2)
exc = .01 * rho0**2 + .02 * (gamma+.001)**.5
vrho = .01 * 2 * rho0
vgamma = .02 * .5 * (gamma+.001)**(-.5)
vlapl = None
vtau = None
vxc = (vrho, vgamma, vlapl, vtau)
fxc = None # 2nd order functional derivative
kxc = None # 3rd order functional derivative
return exc, vxc, fxc, kxc
mf = dft.RKS(mol)
ni = dft.libxc.define_xc(mf._numint, eval_xc, 'GGA', hyb=0.2)
numpy.random.seed(1)
rho = numpy.random.random((4,10))
exc, vxc = ni.eval_xc(None, rho, 0, deriv=1)[:2]
self.assertAlmostEqual(lib.finger(exc), 0.0012441814416833327, 9)
self.assertAlmostEqual(lib.finger(vxc[0]), 0.0065565189784811129, 9)
self.assertAlmostEqual(lib.finger(vxc[1]), 0.0049270110162854116, 9)
mf = mf.define_xc_('0.5*B3LYP+0.5*B3LYP')
exc0, vxc0 = mf._numint.eval_xc(None, rho, 0, deriv=1)[:2]
exc1, vxc1 = dft.libxc.eval_xc('0.5*B3LYP+0.5*B3LYP', rho, 0, deriv=1)[:2]
self.assertAlmostEqual(abs(exc0-exc1).max(), 0, 9)
self.assertAlmostEqual(abs(vxc0[0]-vxc1[0]).max(), 0, 9)
self.assertAlmostEqual(abs(vxc0[1]-vxc1[1]).max(), 0, 9)
self.assertRaises(ValueError, dft.libxc.define_xc, mf._numint, 0.1)
示例14: test_eris_contract_vvvv_t2
def test_eris_contract_vvvv_t2(self):
mol = gto.Mole()
nocc, nvir = 5, 12
nvir_pair = nvir*(nvir+1)//2
numpy.random.seed(9)
t2 = numpy.random.random((nocc,nocc,nvir,nvir)) - .5
t2 = t2 + t2.transpose(1,0,3,2)
eris = ccsd._ChemistsERIs()
vvvv = numpy.random.random((nvir_pair,nvir_pair)) - .5
eris.vvvv = vvvv + vvvv.T
eris.mol = mol
mycc.max_memory, bak = 0, mycc.max_memory
vt2 = eris._contract_vvvv_t2(mycc, t2, eris.vvvv)
mycc.max_memory = bak
self.assertAlmostEqual(lib.finger(vt2), -39.572579908080087, 11)
vvvv = ao2mo.restore(1, eris.vvvv, nvir)
ref = lib.einsum('acbd,ijcd->ijab', vvvv, t2)
self.assertAlmostEqual(abs(vt2 - ref).max(), 0, 11)
# _contract_s1vvvv_t2, testing complex and real mixed contraction
vvvv =(numpy.random.random((nvir,nvir,nvir,nvir)) +
numpy.random.random((nvir,nvir,nvir,nvir))*1j - (.5+.5j))
vvvv = vvvv + vvvv.transpose(1,0,3,2).conj()
vvvv = vvvv + vvvv.transpose(2,3,0,1)
eris.vvvv = vvvv
eris.mol = mol
mycc.max_memory, bak = 0, mycc.max_memory
vt2 = eris._contract_vvvv_t2(mycc, t2, eris.vvvv)
mycc.max_memory = bak
self.assertAlmostEqual(lib.finger(vt2), 23.502736435296871+113.90422480013488j, 11)
ref = lib.einsum('acbd,ijcd->ijab', eris.vvvv, t2)
self.assertAlmostEqual(abs(vt2 - ref).max(), 0, 11)
示例15: test_rand_ccsd_frozen3
def test_rand_ccsd_frozen3(self):
'''Single (eom-)ccsd iteration with random t1/t2 and single frozen virtual
orbital.'''
kconserv = kpts_helper.get_kconserv(rand_kmf.cell, rand_kmf.kpts)
kmf = pbcscf.addons.convert_to_ghf(rand_kmf)
# Round to make this insensitive to small changes between PySCF versions
mat_veff = kmf.get_veff().round(4)
mat_hcore = kmf.get_hcore().round(4)
kmf.get_veff = lambda *x: mat_veff
kmf.get_hcore = lambda *x: mat_hcore
frozen = [[],[],[5]] # freezing one virtual
rand_cc = pbcc.KGCCSD(kmf, frozen=frozen)
eris = rand_cc.ao2mo(rand_cc.mo_coeff)
eris.mo_energy = [eris.fock[k].diagonal() for k in range(rand_cc.nkpts)]
t1, t2 = rand_t1_t2(kmf, rand_cc)
# Manually zero'ing out the frozen elements of the t1/t2
t1[2, :, 0] = 0.0
for ki in range(rand_cc.nkpts):
for kj in range(rand_cc.nkpts):
for ka in range(rand_cc.nkpts):
kb = kconserv[ki, ka, kj]
if ka == 2:
t2[ki, kj, ka, :, :, 0] = 0.0
if kb == 2:
t2[ki, kj, ka, :, :, :, 0] = 0.0
Ht1, Ht2 = rand_cc.update_amps(t1, t2, eris)
self.assertAlmostEqual(finger(Ht1), (-19.6637196882-16.2773841431j), 6)
self.assertAlmostEqual(finger(Ht2), (881.655146297+1283.71020059j), 6)