Skip to content

Commit 7514991

Browse files
Added Olsen correction for Davidson
1 parent f6a2270 commit 7514991

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

include/macis/solvers/davidson.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,21 @@ auto p_davidson(int64_t N_local, int64_t max_m, const Functor& op,
378378

379379
// Compute new vector
380380
// (D - LAM(0)*I) * W = -R ==> W = -(D - LAM(0)*I)**-1 * R
381+
double E1_denom = 0, E1_num = 0;
381382
for(auto j = 0; j < N_local; ++j) {
382383
R_local[j] = -R_local[j] / (D_local[j] - LAM[0]);
384+
E1_num += X_local[j] * R_local[j];
385+
E1_denom += X_local[j] * X_local[j] / (D_local[j] - LAM[0]);
383386
}
387+
E1_denom = allreduce(E1_denom, MPI_SUM, comm);
388+
E1_num = allreduce(E1_num, MPI_SUM, comm);
389+
const double E1 = E1_num / E1_denom;
390+
391+
for(auto j = 0; j < N_local; ++j) {
392+
R_local[j] += E1 * X_local[j] / (D_local[j] - LAM[0]);
393+
}
394+
395+
384396

385397
// Project new vector out form old vectors
386398
p_gram_schmidt(N_local, k, V_local.data(), N_local, R_local, comm);

0 commit comments

Comments
 (0)