diff --git a/src/compute_pe.cpp b/src/compute_pe.cpp index e48b436c85..2385f1e94e 100644 --- a/src/compute_pe.cpp +++ b/src/compute_pe.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -14,30 +13,30 @@ #include "compute_pe.h" -#include -#include "atom.h" -#include "update.h" -#include "force.h" -#include "pair.h" -#include "bond.h" #include "angle.h" +#include "atom.h" +#include "atom_masks.h" +#include "bond.h" #include "dihedral.h" +#include "domain.h" +#include "error.h" +#include "force.h" #include "improper.h" #include "kspace.h" #include "modify.h" -#include "domain.h" -#include "error.h" -#include "atom_masks.h" +#include "pair.h" +#include "update.h" + +#include using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -ComputePE::ComputePE(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg) +ComputePE::ComputePE(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg) { - if (narg < 3) error->all(FLERR,"Illegal compute pe command"); - if (igroup) error->all(FLERR,"Compute pe must use group all"); + if (narg < 3) error->all(FLERR, "Illegal compute pe command"); + if (igroup) error->all(FLERR, "Compute pe must use group all"); scalar_flag = 1; extscalar = 1; @@ -56,14 +55,22 @@ ComputePE::ComputePE(LAMMPS *lmp, int narg, char **arg) : fixflag = 0; int iarg = 3; while (iarg < narg) { - if (strcmp(arg[iarg],"pair") == 0) pairflag = 1; - else if (strcmp(arg[iarg],"bond") == 0) bondflag = 1; - else if (strcmp(arg[iarg],"angle") == 0) angleflag = 1; - else if (strcmp(arg[iarg],"dihedral") == 0) dihedralflag = 1; - else if (strcmp(arg[iarg],"improper") == 0) improperflag = 1; - else if (strcmp(arg[iarg],"kspace") == 0) kspaceflag = 1; - else if (strcmp(arg[iarg],"fix") == 0) fixflag = 1; - else error->all(FLERR,"Illegal compute pe command"); + if (strcmp(arg[iarg], "pair") == 0) + pairflag = 1; + else if (strcmp(arg[iarg], "bond") == 0) + bondflag = 1; + else if (strcmp(arg[iarg], "angle") == 0) + angleflag = 1; + else if (strcmp(arg[iarg], "dihedral") == 0) + dihedralflag = 1; + else if (strcmp(arg[iarg], "improper") == 0) + improperflag = 1; + else if (strcmp(arg[iarg], "kspace") == 0) + kspaceflag = 1; + else if (strcmp(arg[iarg], "fix") == 0) + fixflag = 1; + else + error->all(FLERR, "Illegal compute pe command"); iarg++; } } @@ -78,11 +85,10 @@ double ComputePE::compute_scalar() { invoked_scalar = update->ntimestep; if (update->eflag_global != invoked_scalar) - error->all(FLERR,"Energy was not tallied on needed timestep"); + error->all(FLERR, "Energy was not tallied on needed timestep"); double one = 0.0; - if (pairflag && force->pair) - one += force->pair->eng_vdwl + force->pair->eng_coul; + if (pairflag && force->pair) one += force->pair->eng_vdwl + force->pair->eng_coul; if (atom->molecular != Atom::ATOMIC) { if (bondflag && force->bond) one += force->bond->energy; @@ -91,7 +97,7 @@ double ComputePE::compute_scalar() if (improperflag && force->improper) one += force->improper->energy; } - MPI_Allreduce(&one,&scalar,1,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&one, &scalar, 1, MPI_DOUBLE, MPI_SUM, world); if (kspaceflag && force->kspace) scalar += force->kspace->energy; @@ -100,8 +106,7 @@ double ComputePE::compute_scalar() scalar += force->pair->etail / volume; } - if (fixflag && modify->n_energy_global) - scalar += modify->energy_global(); + if (fixflag && modify->n_energy_global) scalar += modify->energy_global(); return scalar; }