本文整理汇总了Python中pyscf.lib.logger.new_logger函数的典型用法代码示例。如果您正苦于以下问题:Python new_logger函数的具体用法?Python new_logger怎么用?Python new_logger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了new_logger函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: uhf_internal
def uhf_internal(mf, with_symmetry=True, verbose=None):
log = logger.new_logger(mf, verbose)
g, hop, hdiag = newton_ah.gen_g_hop_uhf(mf, mf.mo_coeff, mf.mo_occ,
with_symmetry=with_symmetry)
hdiag *= 2
def precond(dx, e, x0):
hdiagd = hdiag - e
hdiagd[abs(hdiagd)<1e-8] = 1e-8
return dx/hdiagd
def hessian_x(x): # See comments in function rhf_internal
return hop(x).real * 2
x0 = numpy.zeros_like(g)
x0[g!=0] = 1. / hdiag[g!=0]
if not with_symmetry: # allow to break point group symmetry
x0[numpy.argmin(hdiag)] = 1
e, v = lib.davidson(hessian_x, x0, precond, tol=1e-4, verbose=log)
if e < -1e-5:
log.note('UHF/UKS wavefunction has an internal instablity.')
nocca = numpy.count_nonzero(mf.mo_occ[0]> 0)
nvira = numpy.count_nonzero(mf.mo_occ[0]==0)
mo = (_rotate_mo(mf.mo_coeff[0], mf.mo_occ[0], v[:nocca*nvira]),
_rotate_mo(mf.mo_coeff[1], mf.mo_occ[1], v[nocca*nvira:]))
else:
log.note('UHF/UKS wavefunction is stable in the intenral stability analysis')
mo = mf.mo_coeff
return mo
开发者ID:chrinide,项目名称:pyscf,代码行数:27,代码来源:stability.py
示例2: casci
def casci(self, mo_coeff, ci0=None, eris=None, verbose=None, envs=None):
if eris is None:
fcasci = copy.copy(self)
fcasci.ao2mo = self.get_h2cas
else:
fcasci = _fake_h_for_fast_casci(self, mo_coeff, eris)
log = logger.new_logger(self, verbose)
e_tot, e_cas, fcivec = ucasci.kernel(fcasci, mo_coeff, ci0, log)
if envs is not None and log.verbose >= logger.INFO:
log.debug('CAS space CI energy = %.15g', e_cas)
if 'imicro' in envs: # Within CASSCF iteration
log.info('macro iter %d (%d JK %d micro), '
'UCASSCF E = %.15g dE = %.8g',
envs['imacro'], envs['njk'], envs['imicro'],
e_tot, e_tot-envs['elast'])
if 'norm_gci' in envs:
log.info(' |grad[o]|=%5.3g '
'|grad[c]|= %s |ddm|=%5.3g',
envs['norm_gorb0'],
envs['norm_gci'], envs['norm_ddm'])
else:
log.info(' |grad[o]|=%5.3g |ddm|=%5.3g',
envs['norm_gorb0'], envs['norm_ddm'])
else: # Initialization step
log.info('UCASCI E = %.15g', e_tot)
return e_tot, e_cas, fcivec
开发者ID:chrinide,项目名称:pyscf,代码行数:29,代码来源:umc1step.py
示例3: rhf_external
def rhf_external(mf, with_symmetry=True, verbose=None):
log = logger.new_logger(mf, verbose)
hop1, hdiag1, hop2, hdiag2 = _gen_hop_rhf_external(mf, with_symmetry)
def precond(dx, e, x0):
hdiagd = hdiag1 - e
hdiagd[abs(hdiagd)<1e-8] = 1e-8
return dx/hdiagd
x0 = numpy.zeros_like(hdiag1)
x0[hdiag1>1e-5] = 1. / hdiag1[hdiag1>1e-5]
if not with_symmetry: # allow to break point group symmetry
x0[numpy.argmin(hdiag1)] = 1
e1, v1 = lib.davidson(hop1, x0, precond, tol=1e-4, verbose=log)
if e1 < -1e-5:
log.note('RHF/RKS wavefunction has a real -> complex instablity')
else:
log.note('RHF/RKS wavefunction is stable in the real -> complex stability analysis')
def precond(dx, e, x0):
hdiagd = hdiag2 - e
hdiagd[abs(hdiagd)<1e-8] = 1e-8
return dx/hdiagd
x0 = v1
e3, v3 = lib.davidson(hop2, x0, precond, tol=1e-4, verbose=log)
if e3 < -1e-5:
log.note('RHF/RKS wavefunction has a RHF/RKS -> UHF/UKS instablity.')
mo = (_rotate_mo(mf.mo_coeff, mf.mo_occ, v3), mf.mo_coeff)
else:
log.note('RHF/RKS wavefunction is stable in the RHF/RKS -> UHF/UKS stability analysis')
mo = (mf.mo_coeff, mf.mo_coeff)
return mo
开发者ID:chrinide,项目名称:pyscf,代码行数:31,代码来源:stability.py
示例4: mulliken_pop
def mulliken_pop(mol, dm, s=None, verbose=logger.DEBUG):
r'''Mulliken population analysis
.. math:: M_{ij} = D_{ij} S_{ji}
Mulliken charges
.. math:: \delta_i = \sum_j M_{ij}
'''
if s is None: s = get_ovlp(mol)
log = logger.new_logger(mol, verbose)
pop = numpy.einsum('ij,ji->i', dm, s).real
log.info(' ** Mulliken pop **')
for i, s in enumerate(mol.spinor_labels()):
log.info('pop of %s %10.5f', s, pop[i])
log.note(' ** Mulliken atomic charges **')
chg = numpy.zeros(mol.natm)
for i, s in enumerate(mol.spinor_labels(fmt=None)):
chg[s[0]] += pop[i]
chg = mol.atom_charges() - chg
for ia in range(mol.natm):
symb = mol.atom_symbol(ia)
log.note('charge of %d%s = %10.5f', ia, symb, chg[ia])
return pop, chg
开发者ID:chrinide,项目名称:pyscf,代码行数:27,代码来源:dhf.py
示例5: rhf_internal
def rhf_internal(mf, verbose=None):
log = logger.new_logger(mf, verbose)
g, hop, hdiag = newton_ah.gen_g_hop_rhf(mf, mf.mo_coeff, mf.mo_occ)
def precond(dx, e, x0):
hdiagd = hdiag*2 - e
hdiagd[abs(hdiagd)<1e-8] = 1e-8
return dx/hdiagd
# The results of hop(x) corresponds to a displacement that reduces
# gradients g. It is the vir-occ block of the matrix vector product
# (Hessian*x). The occ-vir block equals to x2.T.conj(). The overall
# Hessian for internal reotation is x2 + x2.T.conj(). This is
# the reason we apply (.real * 2) below
def hessian_x(x):
return hop(x).real * 2
x0 = numpy.zeros_like(g)
x0[g!=0] = 1. / hdiag[g!=0]
e, v = lib.davidson(hessian_x, x0, precond, tol=1e-4, verbose=log)
if e < -1e-5:
log.log('KRHF/KRKS wavefunction has an internal instablity')
mo = _rotate_mo(mf.mo_coeff, mf.mo_occ, v)
else:
log.log('KRHF/KRKS wavefunction is stable in the intenral stability analysis')
mo = mf.mo_coeff
return mo
开发者ID:chrinide,项目名称:pyscf,代码行数:25,代码来源:stability.py
示例6: gen_hop
def gen_hop(hobj, mo_energy=None, mo_coeff=None, mo_occ=None, verbose=None):
log = logger.new_logger(hobj, verbose)
mol = hobj.mol
mf = hobj.base
if mo_energy is None: mo_energy = mf.mo_energy
if mo_occ is None: mo_occ = mf.mo_occ
if mo_coeff is None: mo_coeff = mf.mo_coeff
natm = mol.natm
nao, nmo = mo_coeff.shape
mocc = mo_coeff[:,mo_occ>0]
nocc = mocc.shape[1]
atmlst = range(natm)
max_memory = max(2000, hobj.max_memory - lib.current_memory()[0])
de2 = hobj.partial_hess_elec(mo_energy, mo_coeff, mo_occ, atmlst,
max_memory, log)
de2 += hobj.hess_nuc()
# Compute H1 integrals and store in hobj.chkfile
hobj.make_h1(mo_coeff, mo_occ, hobj.chkfile, atmlst, log)
aoslices = mol.aoslice_by_atom()
s1a = -mol.intor('int1e_ipovlp', comp=3)
fvind = gen_vind(mf, mo_coeff, mo_occ)
def h_op(x):
x = x.reshape(natm,3)
hx = numpy.einsum('abxy,ax->by', de2, x)
h1ao = 0
s1ao = 0
for ia in range(natm):
shl0, shl1, p0, p1 = aoslices[ia]
h1ao_i = lib.chkfile.load(hobj.chkfile, 'scf_f1ao/%d' % ia)
h1ao += numpy.einsum('x,xij->ij', x[ia], h1ao_i)
s1ao_i = numpy.zeros((3,nao,nao))
s1ao_i[:,p0:p1] += s1a[:,p0:p1]
s1ao_i[:,:,p0:p1] += s1a[:,p0:p1].transpose(0,2,1)
s1ao += numpy.einsum('x,xij->ij', x[ia], s1ao_i)
s1vo = reduce(numpy.dot, (mo_coeff.T, s1ao, mocc))
h1vo = reduce(numpy.dot, (mo_coeff.T, h1ao, mocc))
mo1, mo_e1 = cphf.solve(fvind, mo_energy, mo_occ, h1vo, s1vo)
mo1 = numpy.dot(mo_coeff, mo1)
mo_e1 = mo_e1.reshape(nocc,nocc)
dm1 = numpy.einsum('pi,qi->pq', mo1, mocc)
dme1 = numpy.einsum('pi,qi,i->pq', mo1, mocc, mo_energy[mo_occ>0])
dme1 = dme1 + dme1.T + reduce(numpy.dot, (mocc, mo_e1.T, mocc.T))
for ja in range(natm):
q0, q1 = aoslices[ja][2:]
h1ao = lib.chkfile.load(hobj.chkfile, 'scf_f1ao/%s'%ja)
hx[ja] += numpy.einsum('xpq,pq->x', h1ao, dm1) * 4
hx[ja] -= numpy.einsum('xpq,pq->x', s1a[:,q0:q1], dme1[q0:q1]) * 2
hx[ja] -= numpy.einsum('xpq,qp->x', s1a[:,q0:q1], dme1[:,q0:q1]) * 2
return hx.ravel()
hdiag = numpy.einsum('aaxx->ax', de2).ravel()
return h_op, hdiag
开发者ID:chrinide,项目名称:pyscf,代码行数:60,代码来源:rhf.py
示例7: ghf_stability
def ghf_stability(mf, verbose=None):
log = logger.new_logger(mf, verbose)
with_symmetry = True
g, hop, hdiag = newton_ah.gen_g_hop_ghf(mf, mf.mo_coeff, mf.mo_occ,
with_symmetry=with_symmetry)
hdiag *= 2
def precond(dx, e, x0):
hdiagd = hdiag - e
hdiagd[abs(hdiagd)<1e-8] = 1e-8
return dx/hdiagd
def hessian_x(x): # See comments in function rhf_internal
return hop(x).real * 2
x0 = numpy.zeros_like(g)
x0[g!=0] = 1. / hdiag[g!=0]
if not with_symmetry: # allow to break point group symmetry
x0[numpy.argmin(hdiag)] = 1
e, v = lib.davidson(hessian_x, x0, precond, tol=1e-4, verbose=log)
if e < -1e-5:
log.note('GHF wavefunction has an internal instablity')
mo = _rotate_mo(mf.mo_coeff, mf.mo_occ, v)
else:
log.note('GHF wavefunction is stable in the intenral stability analysis')
mo = mf.mo_coeff
return mo
开发者ID:chrinide,项目名称:pyscf,代码行数:25,代码来源:stability.py
示例8: mulliken_pop
def mulliken_pop(mol, dm, s=None, verbose=logger.DEBUG):
'''Mulliken population analysis
'''
if s is None: s = hf.get_ovlp(mol)
log = logger.new_logger(mol, verbose)
if isinstance(dm, numpy.ndarray) and dm.ndim == 2:
dm = numpy.array((dm*.5, dm*.5))
pop_a = numpy.einsum('ij,ji->i', dm[0], s).real
pop_b = numpy.einsum('ij,ji->i', dm[1], s).real
log.info(' ** Mulliken pop alpha | beta **')
for i, s in enumerate(mol.ao_labels()):
log.info('pop of %s %10.5f | %-10.5f',
s, pop_a[i], pop_b[i])
log.info('In total %10.5f | %-10.5f', sum(pop_a), sum(pop_b))
log.note(' ** Mulliken atomic charges ( Nelec_alpha | Nelec_beta ) **')
nelec_a = numpy.zeros(mol.natm)
nelec_b = numpy.zeros(mol.natm)
for i, s in enumerate(mol.ao_labels(fmt=None)):
nelec_a[s[0]] += pop_a[i]
nelec_b[s[0]] += pop_b[i]
chg = mol.atom_charges() - (nelec_a + nelec_b)
for ia in range(mol.natm):
symb = mol.atom_symbol(ia)
log.note('charge of %d%s = %10.5f ( %10.5f %10.5f )',
ia, symb, chg[ia], nelec_a[ia], nelec_b[ia])
return (pop_a,pop_b), chg
开发者ID:sunqm,项目名称:pyscf,代码行数:28,代码来源:uhf.py
示例9: rhf_internal
def rhf_internal(mf, verbose=None):
log = logger.new_logger(mf, verbose)
mol = mf.mol
mo_coeff = mf.mo_coeff
mo_energy = mf.mo_energy
mo_occ = mf.mo_occ
nmo = mo_coeff.shape[1]
nocc = numpy.count_nonzero(mo_occ)
nvir = nmo - nocc
eri_mo = ao2mo.full(mol, mo_coeff)
eri_mo = ao2mo.restore(1, eri_mo, nmo)
eai = lib.direct_sum('a-i->ai', mo_energy[nocc:], mo_energy[:nocc])
# A
h = numpy.einsum('ckld->kcld', eri_mo[nocc:,:nocc,:nocc,nocc:]) * 2
h-= numpy.einsum('cdlk->kcld', eri_mo[nocc:,nocc:,:nocc,:nocc])
for a in range(nvir):
for i in range(nocc):
h[i,a,i,a] += eai[a,i]
# B
h+= numpy.einsum('ckdl->kcld', eri_mo[nocc:,:nocc,nocc:,:nocc]) * 2
h-= numpy.einsum('cldk->kcld', eri_mo[nocc:,:nocc,nocc:,:nocc])
nov = nocc * nvir
e = scipy.linalg.eigh(h.reshape(nov,nov))[0]
log.debug('rhf_internal: lowest eigs = %s', e[e<=max(e[0],1e-5)])
if e[0] < -1e-5:
log.log('RHF wavefunction has an internal instablity')
else:
log.log('RHF wavefunction is stable in the intenral stablity analysis')
开发者ID:chrinide,项目名称:pyscf,代码行数:30,代码来源:stability_slow.py
示例10: get_jk
def get_jk(self, mol=None, dm=None, hermi=1):
if mol is None: mol = self.mol
if dm is None: dm = self.make_rdm1()
t0 = (time.clock(), time.time())
log = logger.new_logger(self)
if self.direct_scf and self.opt[0] is None:
self.opt = self.init_direct_scf(mol)
opt_llll, opt_ssll, opt_ssss, opt_gaunt = self.opt
vj, vk = get_jk_coulomb(mol, dm, hermi, self._coulomb_now,
opt_llll, opt_ssll, opt_ssss, log)
if self.with_breit:
if 'SSSS' in self._coulomb_now.upper():
vj1, vk1 = _call_veff_gaunt_breit(mol, dm, hermi, opt_gaunt, True)
log.debug('Add Breit term')
vj += vj1
vk += vk1
elif self.with_gaunt and 'SS' in self._coulomb_now.upper():
log.debug('Add Gaunt term')
vj1, vk1 = _call_veff_gaunt_breit(mol, dm, hermi, opt_gaunt, False)
vj += vj1
vk += vk1
log.timer('vj and vk', *t0)
return vj, vk
开发者ID:chrinide,项目名称:pyscf,代码行数:26,代码来源:dhf.py
示例11: get_jk_coulomb
def get_jk_coulomb(mol, dm, hermi=1, coulomb_allow='SSSS',
opt_llll=None, opt_ssll=None, opt_ssss=None, verbose=None):
log = logger.new_logger(mol, verbose)
if coulomb_allow.upper() == 'LLLL':
log.debug('Coulomb integral: (LL|LL)')
j1, k1 = _call_veff_llll(mol, dm, hermi, opt_llll)
n2c = j1.shape[1]
vj = numpy.zeros_like(dm)
vk = numpy.zeros_like(dm)
vj[...,:n2c,:n2c] = j1
vk[...,:n2c,:n2c] = k1
elif coulomb_allow.upper() == 'SSLL' \
or coulomb_allow.upper() == 'LLSS':
log.debug('Coulomb integral: (LL|LL) + (SS|LL)')
vj, vk = _call_veff_ssll(mol, dm, hermi, opt_ssll)
j1, k1 = _call_veff_llll(mol, dm, hermi, opt_llll)
n2c = j1.shape[1]
vj[...,:n2c,:n2c] += j1
vk[...,:n2c,:n2c] += k1
else: # coulomb_allow == 'SSSS'
log.debug('Coulomb integral: (LL|LL) + (SS|LL) + (SS|SS)')
vj, vk = _call_veff_ssll(mol, dm, hermi, opt_ssll)
j1, k1 = _call_veff_llll(mol, dm, hermi, opt_llll)
n2c = j1.shape[1]
vj[...,:n2c,:n2c] += j1
vk[...,:n2c,:n2c] += k1
j1, k1 = _call_veff_ssss(mol, dm, hermi, opt_ssss)
vj[...,n2c:,n2c:] += j1
vk[...,n2c:,n2c:] += k1
return vj, vk
开发者ID:chrinide,项目名称:pyscf,代码行数:30,代码来源:dhf.py
示例12: polarizability_with_freq
def polarizability_with_freq(polobj, freq=None):
from pyscf.prop.nmr import rhf as rhf_nmr
log = logger.new_logger(polobj)
mf = polobj._scf
mol = mf.mol
mo_energy = mf.mo_energy
mo_coeff = mf.mo_coeff
mo_occ = mf.mo_occ
occidx = mo_occ > 0
orbo = mo_coeff[:, occidx]
orbv = mo_coeff[:,~occidx]
charges = mol.atom_charges()
coords = mol.atom_coords()
charge_center = numpy.einsum('i,ix->x', charges, coords) / charges.sum()
with mol.with_common_orig(charge_center):
int_r = mol.intor_symmetric('int1e_r', comp=3)
h1 = lib.einsum('xpq,pi,qj->xij', int_r, orbv.conj(), orbo)
mo1 = cphf_with_freq(mf, mo_energy, mo_occ, h1, freq,
polobj.max_cycle_cphf, polobj.conv_tol, verbose=log)[0]
e2 = numpy.einsum('xpi,ypi->xy', h1, mo1[0])
e2 += numpy.einsum('xpi,ypi->xy', h1, mo1[1])
# *-1 from the definition of dipole moment. *2 for double occupancy
e2 *= -2
log.debug('Polarizability tensor with freq %s', freq)
log.debug('%s', e2)
return e2
开发者ID:chrinide,项目名称:pyscf,代码行数:30,代码来源:rhf.py
示例13: kernel
def kernel(self, h1, h2, norb, nelec, ci0=None, verbose=0, **kwargs):
# Note self.orbsym is initialized lazily in mc1step_symm.kernel function
log = logger.new_logger(self, verbose)
es = []
cs = []
for solver, c0 in loop_solver(fcisolvers, ci0):
e, c = solver.kernel(h1, h2, norb, get_nelec(solver, nelec), c0,
orbsym=self.orbsym, verbose=log, **kwargs)
if solver.nroots == 1:
es.append(e)
cs.append(c)
else:
es.extend(e)
cs.extend(c)
e_states[0] = es
if log.verbose >= logger.DEBUG:
if has_spin_square:
ss, multip = collect(solver.spin_square(c0, norb, get_nelec(solver, nelec))
for solver, c0 in loop_civecs(fcisolvers, cs))
for i, ei in enumerate(es):
log.debug('state %d E = %.15g S^2 = %.7f', i, ei, ss[i])
else:
for i, ei in enumerate(es):
log.debug('state %d E = %.15g', i, ei)
return numpy.einsum('i,i', numpy.array(es), weights), cs
开发者ID:chrinide,项目名称:pyscf,代码行数:26,代码来源:addons.py
示例14: kernel
def kernel(casci, mo_coeff=None, ci0=None, verbose=logger.NOTE):
'''CASCI solver
'''
if mo_coeff is None: mo_coeff = casci.mo_coeff
log = logger.new_logger(casci, verbose)
t0 = (time.clock(), time.time())
log.debug('Start CASCI')
ncas = casci.ncas
nelecas = casci.nelecas
# 2e
eri_cas = casci.get_h2eff(mo_coeff)
t1 = log.timer('integral transformation to CAS space', *t0)
# 1e
h1eff, energy_core = casci.get_h1eff(mo_coeff)
log.debug('core energy = %.15g', energy_core)
t1 = log.timer('effective h1e in CAS space', *t1)
if h1eff.shape[0] != ncas:
raise RuntimeError('Active space size error. nmo=%d ncore=%d ncas=%d' %
(mo_coeff.shape[1], casci.ncore, ncas))
# FCI
max_memory = max(400, casci.max_memory-lib.current_memory()[0])
e_tot, fcivec = casci.fcisolver.kernel(h1eff, eri_cas, ncas, nelecas,
ci0=ci0, verbose=log,
max_memory=max_memory,
ecore=energy_core)
t1 = log.timer('FCI solver', *t1)
e_cas = e_tot - energy_core
return e_tot, e_cas, fcivec
开发者ID:chrinide,项目名称:pyscf,代码行数:34,代码来源:casci.py
示例15: dump_flags
def dump_flags(self, verbose=None):
log = logger.new_logger(self, verbose)
log.info('')
log.info('******** CASCI flags ********')
ncore = self.ncore
ncas = self.ncas
nvir = self.mo_coeff.shape[1] - ncore - ncas
log.info('CAS (%de+%de, %do), ncore = %d, nvir = %d', \
self.nelecas[0], self.nelecas[1], ncas, ncore, nvir)
assert(self.ncas > 0)
log.info('natorb = %s', self.natorb)
log.info('canonicalization = %s', self.canonicalization)
log.info('sorting_mo_energy = %s', self.sorting_mo_energy)
log.info('max_memory %d (MB)', self.max_memory)
if getattr(self.fcisolver, 'dump_flags', None):
self.fcisolver.dump_flags(log.verbose)
if self.mo_coeff is None:
log.error('Orbitals for CASCI are not specified. The relevant SCF '
'object may not be initialized.')
if (getattr(self._scf, 'with_solvent', None) and
not getattr(self, 'with_solvent', None)):
log.warn('''Solvent model %s was found in SCF object.
It is not applied to the CASSCF object. The CASSCF result is not affected by the SCF solvent model.
To enable the solvent model for CASSCF, a decoration to CASSCF object as below needs be called
from pyscf import solvent
mc = mcscf.CASSCF(...)
mc = solvent.ddCOSMO(mc)
''',
self._scf.with_solvent.__class__)
return self
开发者ID:chrinide,项目名称:pyscf,代码行数:31,代码来源:casci.py
示例16: casci
def casci(self, mo_coeff, ci0=None, eris=None, verbose=None, envs=None):
log = logger.new_logger(self, verbose)
log.debug('Running CASCI with solvent. Note the total energy '
'has duplicated contributions from solvent.')
# In oldCAS.casci function, dE was computed based on the total
# energy without removing the duplicated solvent contributions.
# However, envs['elast'] is the last total energy with correct
# solvent effects. Hack envs['elast'] to make oldCAS.casci print
# the correct energy difference.
envs['elast'] = self._e_tot_without_solvent
e_tot, e_cas, fcivec = oldCAS.casci(self, mo_coeff, ci0, eris,
verbose, envs)
self._e_tot_without_solvent = e_tot
log.debug('Computing corrections to the total energy.')
dm = self.make_rdm1(ci=fcivec, ao_repr=True)
with_solvent = self.with_solvent
if with_solvent.epcm is not None:
edup = numpy.einsum('ij,ji->', with_solvent.vpcm, dm)
ediel = with_solvent.epcm
e_tot = e_tot - edup + ediel
log.info('Removing duplication %.15g, '
'adding E_diel = %.15g to total energy:\n'
' E(CASSCF+solvent) = %.15g', edup, ediel, e_tot)
# Update solvent effects for next iteration if needed
if not with_solvent.frozen:
with_solvent.epcm, with_solvent.vpcm = with_solvent.kernel(dm)
return e_tot, e_cas, fcivec
开发者ID:chrinide,项目名称:pyscf,代码行数:32,代码来源:ddcosmo.py
示例17: kernel
def kernel(casci, mo_coeff=None, ci0=None, verbose=logger.NOTE):
'''UHF-CASCI solver
'''
if mo_coeff is None: mo_coeff = casci.mo_coeff
log = logger.new_logger(casci, verbose)
t0 = (time.clock(), time.time())
log.debug('Start uhf-based CASCI')
ncas = casci.ncas
nelecas = casci.nelecas
ncore = casci.ncore
mo_core, mo_cas, mo_vir = extract_orbs(mo_coeff, ncas, nelecas, ncore)
# 1e
h1eff, energy_core = casci.h1e_for_cas(mo_coeff)
log.debug('core energy = %.15g', energy_core)
t1 = log.timer('effective h1e in CAS space', *t0)
# 2e
eri_cas = casci.get_h2eff(mo_cas)
t1 = log.timer('integral transformation to CAS space', *t1)
# FCI
max_memory = max(400, casci.max_memory-lib.current_memory()[0])
e_tot, fcivec = casci.fcisolver.kernel(h1eff, eri_cas, ncas, nelecas,
ci0=ci0, verbose=log,
max_memory=max_memory,
ecore=energy_core)
t1 = log.timer('FCI solver', *t1)
e_cas = e_tot - energy_core
return e_tot, e_cas, fcivec
开发者ID:chrinide,项目名称:pyscf,代码行数:32,代码来源:ucasci.py
示例18: make_fcdip
def make_fcdip(hfcobj, dm0, hfc_nuc=None, verbose=None):
'''The contribution of Fermi-contact term and dipole-dipole interactions'''
log = logger.new_logger(hfcobj, verbose)
mol = hfcobj.mol
if hfc_nuc is None:
hfc_nuc = range(mol.natm)
if isinstance(dm0, numpy.ndarray) and dm0.ndim == 2: # RHF DM
return numpy.zeros((3,3))
dma, dmb = dm0
spindm = dma - dmb
effspin = mol.spin * .5
e_gyro = .5 * nist.G_ELECTRON
nuc_mag = .5 * (nist.E_MASS/nist.PROTON_MASS) # e*hbar/2m
au2MHz = nist.HARTREE2J / nist.PLANCK * 1e-6
fac = nist.ALPHA**2 / 2 / effspin * e_gyro * au2MHz
hfc = []
for i, atm_id in enumerate(hfc_nuc):
nuc_gyro = get_nuc_g_factor(mol.atom_symbol(atm_id)) * nuc_mag
h1 = _get_integrals_fcdip(mol, atm_id)
fcsd = numpy.einsum('xyij,ji->xy', h1, spindm)
h1fc = _get_integrals_fc(mol, atm_id)
fc = numpy.einsum('ij,ji', h1fc, spindm)
sd = fcsd + numpy.eye(3) * fc
log.info('FC of atom %d %s (in MHz)', atm_id, fac * nuc_gyro * fc)
if hfcobj.verbose >= logger.INFO:
_write(hfcobj, align(fac*nuc_gyro*sd)[0], 'SD of atom %d (in MHz)' % atm_id)
hfc.append(fac * nuc_gyro * fcsd)
return numpy.asarray(hfc)
开发者ID:chrinide,项目名称:pyscf,代码行数:34,代码来源:uhf.py
示例19: analyze
def analyze(mf, verbose=logger.DEBUG, **kwargs):
from pyscf.tools import dump_mat
log = logger.new_logger(mf, verbose)
mo_energy = mf.mo_energy
mo_occ = mf.mo_occ
mo_coeff = mf.mo_coeff
log.info('**** MO energy ****')
for i in range(len(mo_energy)):
if mo_occ[i] > 0:
log.info('occupied MO #%d energy= %.15g occ= %g', \
i+1, mo_energy[i], mo_occ[i])
else:
log.info('virtual MO #%d energy= %.15g occ= %g', \
i+1, mo_energy[i], mo_occ[i])
mol = mf.mol
if mf.verbose >= logger.DEBUG1:
log.debug(' ** MO coefficients of large component of postive state (real part) **')
label = mol.spinor_labels()
n2c = mo_coeff.shape[0] // 2
dump_mat.dump_rec(mf.stdout, mo_coeff[n2c:,:n2c].real, label, start=1)
dm = mf.make_rdm1(mo_coeff, mo_occ)
pop_chg = mf.mulliken_pop(mol, dm, mf.get_ovlp(), log)
dip = mf.dip_moment(mol, dm, verbose=log)
return pop_chg, dip
开发者ID:chrinide,项目名称:pyscf,代码行数:25,代码来源:dhf.py
示例20: mulliken_meta
def mulliken_meta(cell, dm_ao_kpts, verbose=logger.DEBUG,
pre_orth_method=PRE_ORTH_METHOD, s=None):
'''A modified Mulliken population analysis, based on meta-Lowdin AOs.
Note this function only computes the Mulliken population for the gamma
point density matrix.
'''
from pyscf.lo import orth
if s is None:
s = khf.get_ovlp(cell)
log = logger.new_logger(cell, verbose)
log.note('Analyze output for *gamma point*.')
log.info(' To include the contributions from k-points, transform to a '
'supercell then run the population analysis on the supercell\n'
' from pyscf.pbc.tools import k2gamma\n'
' k2gamma.k2gamma(mf).mulliken_meta()')
log.note("KUHF mulliken_meta")
dm_ao_gamma = dm_ao_kpts[:,0,:,:].real
s_gamma = s[0,:,:].real
c = orth.restore_ao_character(cell, pre_orth_method)
orth_coeff = orth.orth_ao(cell, 'meta_lowdin', pre_orth_ao=c, s=s_gamma)
c_inv = np.dot(orth_coeff.T, s_gamma)
dm_a = reduce(np.dot, (c_inv, dm_ao_gamma[0], c_inv.T.conj()))
dm_b = reduce(np.dot, (c_inv, dm_ao_gamma[1], c_inv.T.conj()))
log.note(' ** Mulliken pop alpha/beta on meta-lowdin orthogonal AOs **')
return mol_uhf.mulliken_pop(cell, (dm_a,dm_b), np.eye(orth_coeff.shape[0]), log)
开发者ID:chrinide,项目名称:pyscf,代码行数:27,代码来源:kuhf.py
注:本文中的pyscf.lib.logger.new_logger函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论