Skip to content

Commit

Permalink
fix bug of minimal model devi when a proc has 0 local atom
Browse files Browse the repository at this point in the history
  • Loading branch information
Han Wang committed Oct 16, 2019
1 parent 982a991 commit d73927d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions source/lmp/pair_nnp.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <iostream>
#include <iomanip>
#include <limits>
#include "atom.h"
#include "domain.h"
#include "comm.h"
Expand Down Expand Up @@ -83,7 +84,7 @@ ana_st (double & max,
const vector<double> & vec,
const int & nloc)
{
if (vec.size() == 0) return;
if (nloc == 0) return;
max = vec[0];
min = vec[0];
sum = vec[0];
Expand Down Expand Up @@ -347,7 +348,7 @@ void PairNNP::compute(int eflag, int vflag)
std_f.resize(std_f_.size());
for (int dd = 0; dd < std_f_.size(); ++dd) std_f[dd] = std_f_[dd];
#endif
double min = 0, max = 0, avg = 0;
double min = numeric_limits<double>::max(), max = 0, avg = 0;
ana_st(max, min, avg, std_f, nlocal);
int all_nlocal = 0;
MPI_Reduce (&nlocal, &all_nlocal, 1, MPI_INT, MPI_SUM, 0, world);
Expand All @@ -369,7 +370,8 @@ void PairNNP::compute(int eflag, int vflag)
std_e.resize(std_e_.size());
for (int dd = 0; dd < std_e_.size(); ++dd) std_e[dd] = std_e_[dd];
#endif
min = max = avg = 0;
max = avg = 0;
min = numeric_limits<double>::max();
ana_st(max, min, avg, std_e, nlocal);
double all_e_min = 0, all_e_max = 0, all_e_avg = 0;
MPI_Reduce (&min, &all_e_min, 1, MPI_DOUBLE, MPI_MIN, 0, world);
Expand Down

0 comments on commit d73927d

Please sign in to comment.