Skip to content

Commit 4f2576e

Browse files
author
Han Wang
committed
fix bug of minimal model devi when a proc has 0 local atom
1 parent 75bddf9 commit 4f2576e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

source/lmp/pair_nnp.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <iostream>
22
#include <iomanip>
3+
#include <limits>
34
#include "atom.h"
45
#include "domain.h"
56
#include "comm.h"
@@ -86,7 +87,7 @@ ana_st (double & max,
8687
const vector<double> & vec,
8788
const int & nloc)
8889
{
89-
if (vec.size() == 0) return;
90+
if (nloc == 0) return;
9091
max = vec[0];
9192
min = vec[0];
9293
sum = vec[0];
@@ -438,7 +439,7 @@ void PairNNP::compute(int eflag, int vflag)
438439
std_f.resize(std_f_.size());
439440
for (int dd = 0; dd < std_f_.size(); ++dd) std_f[dd] = std_f_[dd];
440441
#endif
441-
double min = 0, max = 0, avg = 0;
442+
double min = numeric_limits<double>::max(), max = 0, avg = 0;
442443
ana_st(max, min, avg, std_f, nlocal);
443444
int all_nlocal = 0;
444445
MPI_Reduce (&nlocal, &all_nlocal, 1, MPI_INT, MPI_SUM, 0, world);
@@ -460,7 +461,8 @@ void PairNNP::compute(int eflag, int vflag)
460461
std_e.resize(std_e_.size());
461462
for (int dd = 0; dd < std_e_.size(); ++dd) std_e[dd] = std_e_[dd];
462463
#endif
463-
min = max = avg = 0;
464+
max = avg = 0;
465+
min = numeric_limits<double>::max();
464466
ana_st(max, min, avg, std_e, nlocal);
465467
double all_e_min = 0, all_e_max = 0, all_e_avg = 0;
466468
MPI_Reduce (&min, &all_e_min, 1, MPI_DOUBLE, MPI_MIN, 0, world);

0 commit comments

Comments
 (0)