Skip to content

Commit

Permalink
Fixing flake8 complaints.
Browse files Browse the repository at this point in the history
  • Loading branch information
lothian committed Jul 26, 2021
1 parent 41a26f5 commit 973044d
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 22 deletions.
2 changes: 2 additions & 0 deletions pycc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from .cctriples import cctriples
from pycc.rt.rtcc import rtcc

__all__ = ['ccenergy', 'cchbar', 'cclambda', 'ccdensity', 'cctriples', 'rtcc']

# Handle versioneer
from ._version import get_versions
versions = get_versions()
Expand Down
3 changes: 1 addition & 2 deletions pycc/ccdensity.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from .density_eqs import build_Dovov, build_Doovv
import numpy as np
from opt_einsum import contract
import numpy as np


class ccdensity(object):
Expand Down Expand Up @@ -47,7 +46,7 @@ class ccdensity(object):
-------
compute_energy() :
Compute the CC energy from the density. If only onepdm is available, just compute the one-electron energy.
compute_onepdm() :
compute_onepdm() :
Compute the one-electron density for a given set of amplitudes (useful for RTCC)
"""
def __init__(self, ccwfn, cclambda, onlyone=False):
Expand Down
1 change: 0 additions & 1 deletion pycc/ccenergy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
raise Exception("This file cannot be invoked on its own.")


import psi4
import time
import numpy as np
from opt_einsum import contract
Expand Down
9 changes: 4 additions & 5 deletions pycc/cctriples.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def t_vikings(self):

return ET


# Vikings' formulation – inverted algorithm
def t_vikings_inverted(self):

o = self.ccwfn.o
v = self.ccwfn.v
no = self.ccwfn.no
Expand Down Expand Up @@ -68,7 +68,6 @@ def t_vikings_inverted(self):

return ET


# Lee and Rendell's formulation
def t_tjl(self):
o = self.ccwfn.o
Expand All @@ -90,7 +89,7 @@ def t_tjl(self):
for a in range(nv):
for b in range(nv):
for c in range(nv):
V3[a,b,c] /= (1.0 + int(a==b) + int(a==c) + int(b==c))
V3[a,b,c] /= (1.0 + int(a == b) + int(a == c) + int(b == c))

X3 = W3 * V3 # abc
X3 += W3.swapaxes(1,2) * V3.swapaxes(1,2) # acb
Expand All @@ -112,7 +111,7 @@ def t_tjl(self):
for c in range(b+1):
ET += (
(Y3[a,b,c] - 2.0 * Z3[a,b,c]) * (W3[a,b,c] + W3[b,c,a] + W3[c,a,b])
+(Z3[a,b,c] - 2.0 * Y3[a,b,c]) * (W3[a,c,b] + W3[b,a,c] + W3[c,b,a])
+ 3.0 * X3[a,b,c]) * (2.0 - (int(i==j) + int(i==k) + int(j==k)))/denom[a,b,c]
+ (Z3[a,b,c] - 2.0 * Y3[a,b,c]) * (W3[a,c,b] + W3[b,a,c] + W3[c,b,a])
+ 3.0 * X3[a,b,c]) * (2.0 - (int(i == j) + int(i == k) + int(j == k)))/denom[a,b,c]

return ET
5 changes: 2 additions & 3 deletions pycc/hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import psi4
import numpy as np

class Hamiltonian(object):

class Hamiltonian(object):

def __init__(self, ref, local=False):
self.ref = ref
Expand All @@ -17,9 +17,8 @@ def __init__(self, ref, local=False):
self.C = C

# Localize occupied MOs if requested
if (local == True):
if (local is not False):
C_occ = self.ref.Ca_subset("AO", "ACTIVE_OCC")
npC_occ = np.asarray(C_occ)
no = self.ref.doccpi()[0] - self.ref.frzcpi()[0] # assumes symmetry c1
Local = psi4.core.Localizer.build("PIPEK_MEZEY", ref.basisset(), C_occ)
Local.localize()
Expand Down
18 changes: 7 additions & 11 deletions pycc/local.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np
from opt_einsum import contract
import scipy.linalg


class Local(object):
Expand All @@ -10,7 +9,7 @@ def __init__(self, no, nv, H, cutoff):
o = slice(0, no)
v = slice(no, no+nv)

## Compute MP2 amplitudes in non-canonical MO basis
# Compute MP2 amplitudes in non-canonical MO basis
eps_occ = np.diag(H.F)[o]
eps_vir = np.diag(H.F)[v]
Dijab = eps_occ.reshape(-1,1,1,1) + eps_occ.reshape(-1,1,1) - eps_vir.reshape(-1,1) - eps_vir
Expand All @@ -21,9 +20,9 @@ def __init__(self, no, nv, H, cutoff):
emp2 = contract('ijab,ijab->', t2, H.L[o,o,v,v])
print("MP2 Iter %3d: MP2 Ecorr = %.15f dE = % .5E" % (0, emp2, -emp2))

e_conv=1e-7
r_conv=1e-7
maxiter=100
e_conv = 1e-7
r_conv = 1e-7
maxiter = 100
ediff = emp2
rmsd = 0.0
niter = 0
Expand All @@ -45,7 +44,7 @@ def __init__(self, no, nv, H, cutoff):

print("MP2 Iter %3d: MP2 Ecorr = %.15f dE = % .5E rmsd = % .5E" % (niter, emp2, ediff, rmsd))

## Build LPNOs and store transformation matrices
# Build LPNOs and store transformation matrices
print("Computing PNOs. Canonical VMO dim: %d" % (nv))
T_ij = t2.copy().reshape((no*no, nv, nv))
Tt_ij = 2.0 * T_ij - T_ij.swapaxes(1,2)
Expand All @@ -62,7 +61,7 @@ def __init__(self, no, nv, H, cutoff):

# Compute pair density
D[ij] = contract('ab,bc->ac', T_ij[ij], Tt_ij[ij].T) + contract('ab,bc->ac', T_ij[ij].T, Tt_ij[ij])
D[ij] *= 2.0/(1 + int(i==j))
D[ij] *= 2.0/(1 + int(i == j))

# Compute PNOs and truncate
occ[ij], Q_full[ij] = np.linalg.eigh(D[ij])
Expand All @@ -89,7 +88,6 @@ def __init__(self, no, nv, H, cutoff):
self.eps = eps # semicananonical LPNO energies
self.L = L # transform between LPNO and semicanonical LPNO spaces


def filter_amps(self, r1, r2):
no = self.no
nv = self.nv
Expand Down Expand Up @@ -118,7 +116,7 @@ def filter_amps(self, r1, r2):

for a in range(dim[ij]):
for b in range(dim[ij]):
Y[a,b] = Y[a,b]/(self.H.F[i,i] + self.H.F[j,j] - self.eps[ij][a] - self.eps[ij][b])
Y[a,b] = Y[a,b]/(self.H.F[i,i] + self.H.F[j,j] - self.eps[ij][a] - self.eps[ij][b])

X = self.L[ij] @ Y @ self.L[ij].T
t2[i,j] = self.Q[ij] @ X @ self.Q[ij].T
Expand All @@ -128,7 +126,6 @@ def filter_amps(self, r1, r2):
def filter_res(self, r1, r2):
no = self.no
nv = self.nv
dim = self.dim

t1 = np.zeros((no,nv)).astype('complex128')
for i in range(no):
Expand All @@ -146,4 +143,3 @@ def filter_res(self, r1, r2):
t2[i,j] = self.Q[ij] @ X @ self.Q[ij].T

return t1, t2

3 changes: 3 additions & 0 deletions pycc/triples_eqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
from opt_einsum import contract


def t3c_ijk(o, v, i, j, k, t2, ERI, F, WithDenom=True):

t3 = contract('eab,ce->abc', ERI[i,v,v,v], t2[k,j])
Expand All @@ -28,6 +29,7 @@ def t3c_ijk(o, v, i, j, k, t2, ERI, F, WithDenom=True):
else:
return t3


def t3c_abc(o, v, a, b, c, t2, ERI, F, WithDenom=True):
no = o.stop

Expand All @@ -54,6 +56,7 @@ def t3c_abc(o, v, a, b, c, t2, ERI, F, WithDenom=True):
else:
return t3


def t3d_ijk(o, v, i, j, k, t1, t2, ERI, F, WithDenom=True):
t3 = contract('ab,c->abc', ERI[i,j,v,v], t1[k])
t3 += contract('ac,b->abc', ERI[i,k,v,v], t1[j])
Expand Down

0 comments on commit 973044d

Please sign in to comment.