Skip to content

Commit 2896281

Browse files
committed
expol: clean induce
1 parent 424b5ee commit 2896281

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ BreakConstructorInitializers: BeforeComma
1010
PointerAlignment: Left
1111
AllowShortBlocksOnASingleLine: Always
1212
AllowShortFunctionsOnASingleLine: Empty
13+
AllowShortIfStatementsOnASingleLine: WithoutElse
1314

1415
MaxEmptyLinesToKeep: 1
1516
AccessModifierOffset: -3

src/acc/hippo/expol.cpp

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,12 @@ void induceMutualPcg4_acc(real (*uind)[3])
408408
const real debye = units::debye;
409409
const real pcgpeek = polpcg::pcgpeek;
410410
const int maxiter = 100; // see also subroutine induce0a in induce.f
411+
const int miniter = std::min(3, n);
411412

412413
bool done = false;
413414
int iter = 0;
414415
real eps = 100;
415-
real epsold;
416+
// real epsold;
416417

417418
while (not done) {
418419
++iter;
@@ -436,8 +437,7 @@ void induceMutualPcg4_acc(real (*uind)[3])
436437
real a;
437438
a = darray::dotThenReturn(g::q0, n, conj, vec);
438439
// a <- r M r / p T p
439-
if (a != 0)
440-
a = sum / a;
440+
if (a != 0) a = sum / a;
441441

442442
// u <- u + a p
443443
// r <- r - a T p
@@ -466,8 +466,7 @@ void induceMutualPcg4_acc(real (*uind)[3])
466466
real sum1;
467467
sum1 = darray::dotThenReturn(g::q0, n, rsd, zrsd);
468468
b = sum1 / sum;
469-
if (sum == 0)
470-
b = 0;
469+
if (sum == 0) b = 0;
471470

472471
// calculate/update p
473472
#pragma acc parallel loop independent async\
@@ -482,7 +481,7 @@ void induceMutualPcg4_acc(real (*uind)[3])
482481

483482
real epsd;
484483
epsd = darray::dotThenReturn(g::q0, n, rsd, rsd);
485-
epsold = eps;
484+
// epsold = eps;
486485
eps = epsd;
487486
eps = debye * REAL_SQRT(eps / n);
488487

@@ -495,12 +494,10 @@ void induceMutualPcg4_acc(real (*uind)[3])
495494
print(stdout, " %8d %-16.10f\n", iter, eps);
496495
}
497496

498-
if (eps < poleps)
499-
done = true;
500-
// if (eps > epsold)
501-
// done = true;
502-
if (iter >= politer)
503-
done = true;
497+
if (eps < poleps) done = true;
498+
// if (eps > epsold) done = true;
499+
if (iter < miniter) done = false;
500+
if (iter >= politer) done = true;
504501

505502
// apply a "peek" iteration to the mutual induced dipoles
506503

@@ -520,14 +517,13 @@ void induceMutualPcg4_acc(real (*uind)[3])
520517

521518
if (debug) {
522519
print(stdout,
523-
" Induced Dipoles : Iterations %4d RMS "
524-
"Residual %14.10f\n",
520+
" Induced Dipoles : Iterations %4d RMS"
521+
" Residual %14.10f\n",
525522
iter, eps);
526523
}
527524

528525
// terminate the calculation if dipoles failed to converge
529526

530-
// if (iter >= maxiter || eps > epsold) {
531527
if (iter >= maxiter) {
532528
printError();
533529
TINKER_THROW("INDUCE -- Warning, Induced Dipoles are not Converged");

0 commit comments

Comments
 (0)