Skip to content

Commit 81ad848

Browse files
authored
Merge pull request #121 from obackhouse/adc2_bug_fix
Fixes bug in initialisation of ADC guess vectors
2 parents d4a9019 + 8b39a47 commit 81ad848

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

Algebraic-Diagrammatic-Construction/EE_ADC2.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ def matvec(y):
139139
d_ia -= einsum('klac,klac->a', eri[o, o, v, v], t2)[None, :] * 0.25
140140

141141
arg = np.argsort(np.absolute(diag))
142-
guess = np.eye(diag.size)[:, arg[:n_states]]
142+
guess = np.zeros((diag.size, n_states))
143+
for i in range(n_states):
144+
guess[arg[i], i] = 1.0
143145

144146
# Computes the EEs
145147
e_ee, v_ee = davidson(matvec, guess, diag, tol=tol)

Algebraic-Diagrammatic-Construction/IP_EA_ADC2.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ def ea_matvec(y):
142142
# for the Davidson algorithm, and to generate the guess vectors
143143
diag = np.concatenate([np.diag(h_hh), e_ija.ravel()])
144144
arg = np.argsort(np.absolute(diag))
145-
guess = np.eye(diag.size)[:, arg[:n_states]]
145+
guess = np.zeros((diag.size, n_states))
146+
for i in range(n_states):
147+
guess[arg[i], i] = 1.0
146148

147149
# Compute the IPs
148150
e_ip, v_ip = davidson(ip_matvec, guess, diag, tol=tol)
@@ -159,7 +161,9 @@ def ea_matvec(y):
159161
# for the Davidson algorithm, and to generate the guess vectors
160162
diag = np.concatenate([np.diag(h_pp), -e_iab.ravel()])
161163
arg = np.argsort(np.absolute(diag))
162-
guess = np.eye(diag.size)[:, arg[:n_states]]
164+
guess = np.zeros((diag.size, n_states))
165+
for i in range(n_states):
166+
guess[arg[i], i] = 1.0
163167

164168
# Compute the EAs
165169
e_ea, v_ea = davidson(ea_matvec, guess, diag, tol=tol)

Algebraic-Diagrammatic-Construction/adc_helper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def davidson(matrix, guesses, diag, maxiter=None, sort_via_abs=True, tol=1e-10,
5757
de = np.linalg.norm(theta[:k] - theta_old)
5858
if de < tol:
5959
conv = True
60+
b = np.dot(b, alpha)
6061
break
6162
else:
6263
if b.shape[1] >= (k * nvec_per_root):

0 commit comments

Comments
 (0)