Merge pull request #3753 from akohlmey/tally-compute-warn
Add warning message when the callback for a /tally compute was not run
This commit is contained in:
@ -187,16 +187,22 @@ Both the scalar and vector values calculated by this compute are
|
||||
Restrictions
|
||||
""""""""""""
|
||||
|
||||
This compute is part of the TALLY package. It is only enabled if
|
||||
LAMMPS was built with that package. See the :doc:`Build package <Build_package>` page for more info.
|
||||
This compute is part of the TALLY package. It is only enabled if LAMMPS
|
||||
was built with that package. See the :doc:`Build package
|
||||
<Build_package>` page for more info.
|
||||
|
||||
Not all pair styles can be evaluated in a pairwise mode as required by
|
||||
this compute. For example, 3-body and other many-body potentials,
|
||||
such as :doc:`Tersoff <pair_tersoff>` and
|
||||
:doc:`Stillinger-Weber <pair_sw>` cannot be used. :doc:`EAM <pair_eam>`
|
||||
potentials only include the pair potential portion of the EAM
|
||||
interaction when used by this compute, not the embedding term. Also
|
||||
bonded or Kspace interactions do not contribute to this compute.
|
||||
this compute. For example, 3-body and other many-body potentials, such
|
||||
as :doc:`Tersoff <pair_tersoff>` and :doc:`Stillinger-Weber <pair_sw>`
|
||||
cannot be used. :doc:`EAM <pair_eam>` potentials only include the pair
|
||||
potential portion of the EAM interaction when used by this compute, not
|
||||
the embedding term. Also bonded or Kspace interactions do not
|
||||
contribute to this compute.
|
||||
|
||||
These computes are not compatible with accelerated pair styles from the
|
||||
GPU, INTEL, KOKKOS, or OPENMP packages. They will either create an error
|
||||
or print a warning when required data was not tallied in the required way
|
||||
and thus the data acquisition functions from these computes not called.
|
||||
|
||||
When used with dynamic groups, a :doc:`run 0 <run>` command needs to
|
||||
be inserted in order to initialize the dynamic groups before accessing
|
||||
|
||||
@ -1562,6 +1562,7 @@ invertibility
|
||||
ionicities
|
||||
ionizable
|
||||
ionocovalent
|
||||
iOS
|
||||
iostreams
|
||||
iparam
|
||||
ipi
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#include "memory.h"
|
||||
#include "pair.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
@ -29,10 +30,11 @@ using namespace LAMMPS_NS;
|
||||
|
||||
ComputeForceTally::ComputeForceTally(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg < 4) error->all(FLERR, "Illegal compute force/tally command");
|
||||
if (narg < 4) utils::missing_cmd_args(FLERR, "compute force/tally", error);
|
||||
|
||||
igroup2 = group->find(arg[3]);
|
||||
if (igroup2 == -1) error->all(FLERR, "Could not find compute force/tally second group ID");
|
||||
if (igroup2 == -1)
|
||||
error->all(FLERR, "Could not find compute force/tally second group ID {}", arg[3]);
|
||||
groupbit2 = group->bitmask[igroup2];
|
||||
|
||||
scalar_flag = 1;
|
||||
@ -177,7 +179,10 @@ double ComputeForceTally::compute_scalar()
|
||||
{
|
||||
invoked_scalar = update->ntimestep;
|
||||
if ((did_setup != invoked_scalar) || (update->eflag_global != invoked_scalar))
|
||||
error->all(FLERR, "Energy was not tallied on needed timestep");
|
||||
error->all(FLERR, "Stress was not tallied on needed timestep");
|
||||
|
||||
if ((comm->me == 0) && !force->pair->did_tally_callback())
|
||||
error->warning(FLERR, "Stress was not tallied by pair style");
|
||||
|
||||
// sum accumulated forces across procs
|
||||
|
||||
@ -193,7 +198,10 @@ void ComputeForceTally::compute_peratom()
|
||||
{
|
||||
invoked_peratom = update->ntimestep;
|
||||
if ((did_setup != invoked_peratom) || (update->eflag_global != invoked_peratom))
|
||||
error->all(FLERR, "Energy was not tallied on needed timestep");
|
||||
error->all(FLERR, "Stress was not tallied on needed timestep");
|
||||
|
||||
if ((comm->me == 0) && !force->pair->did_tally_callback())
|
||||
error->warning(FLERR, "Stress was not tallied by pair style");
|
||||
|
||||
// collect contributions from ghost atoms
|
||||
|
||||
|
||||
@ -29,10 +29,11 @@ using namespace LAMMPS_NS;
|
||||
ComputeHeatFluxTally::ComputeHeatFluxTally(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg < 4) error->all(FLERR, "Illegal compute heat/flux/tally command");
|
||||
if (narg < 4) utils::missing_cmd_args(FLERR, "compute heat/flux/tally", error);
|
||||
|
||||
igroup2 = group->find(arg[3]);
|
||||
if (igroup2 == -1) error->all(FLERR, "Could not find compute heat/flux/tally second group ID");
|
||||
if (igroup2 == -1)
|
||||
error->all(FLERR, "Could not find compute heat/flux/tally second group ID {}", arg[3]);
|
||||
groupbit2 = group->bitmask[igroup2];
|
||||
|
||||
vector_flag = 1;
|
||||
@ -204,7 +205,10 @@ void ComputeHeatFluxTally::compute_vector()
|
||||
{
|
||||
invoked_vector = update->ntimestep;
|
||||
if ((did_setup != invoked_vector) || (update->eflag_global != invoked_vector))
|
||||
error->all(FLERR, "Energy was not tallied on needed timestep");
|
||||
error->all(FLERR, "Stress was not tallied on needed timestep");
|
||||
|
||||
if ((comm->me == 0) && !force->pair->did_tally_callback())
|
||||
error->warning(FLERR, "Stress was not tallied by pair style");
|
||||
|
||||
// collect contributions from ghost atoms
|
||||
|
||||
|
||||
@ -29,11 +29,11 @@ using namespace LAMMPS_NS;
|
||||
ComputeHeatFluxVirialTally::ComputeHeatFluxVirialTally(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg < 4) error->all(FLERR, "Illegal compute heat/flux/virial/tally command");
|
||||
if (narg < 4) utils::missing_cmd_args(FLERR, "compute heat/flux/virial/tally", error);
|
||||
|
||||
igroup2 = group->find(arg[3]);
|
||||
if (igroup2 == -1)
|
||||
error->all(FLERR, "Could not find compute heat/flux/virial/tally second group ID");
|
||||
error->all(FLERR, "Could not find compute heat/flux/virial/tally second group ID {}", arg[3]);
|
||||
groupbit2 = group->bitmask[igroup2];
|
||||
|
||||
scalar_flag = 1;
|
||||
@ -191,7 +191,10 @@ double ComputeHeatFluxVirialTally::compute_scalar()
|
||||
|
||||
invoked_scalar = update->ntimestep;
|
||||
if ((did_setup != invoked_scalar) || (update->eflag_global != invoked_scalar))
|
||||
error->all(FLERR, "Energy was not tallied on needed timestep");
|
||||
error->all(FLERR, "Stress was not tallied on needed timestep");
|
||||
|
||||
if ((comm->me == 0) && !force->pair->did_tally_callback())
|
||||
error->warning(FLERR, "Stress was not tallied by pair style");
|
||||
|
||||
// sum heat flux across procs
|
||||
double hflux = 0.0;
|
||||
@ -210,7 +213,10 @@ void ComputeHeatFluxVirialTally::compute_peratom()
|
||||
{
|
||||
invoked_peratom = update->ntimestep;
|
||||
if ((did_setup != invoked_peratom) || (update->eflag_global != invoked_peratom))
|
||||
error->all(FLERR, "Energy was not tallied on needed timestep");
|
||||
error->all(FLERR, "Stress was not tallied on needed timestep");
|
||||
|
||||
if ((comm->me == 0) && !force->pair->did_tally_callback())
|
||||
error->warning(FLERR, "Stress was not tallied by pair style");
|
||||
|
||||
// collect contributions from ghost atoms
|
||||
|
||||
|
||||
@ -27,10 +27,11 @@ using namespace LAMMPS_NS;
|
||||
|
||||
ComputePEMolTally::ComputePEMolTally(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg < 4) error->all(FLERR, "Illegal compute pe/mol/tally command");
|
||||
if (narg < 4) utils::missing_cmd_args(FLERR, "compute pe/mol/tally", error);
|
||||
|
||||
igroup2 = group->find(arg[3]);
|
||||
if (igroup2 == -1) error->all(FLERR, "Could not find compute pe/mol/tally second group ID");
|
||||
if (igroup2 == -1)
|
||||
error->all(FLERR, "Could not find compute pe/mol/tally second group ID {}", arg[3]);
|
||||
groupbit2 = group->bitmask[igroup2];
|
||||
|
||||
vector_flag = 1;
|
||||
@ -127,6 +128,9 @@ void ComputePEMolTally::compute_vector()
|
||||
if ((did_setup != invoked_vector) || (update->eflag_global != invoked_vector))
|
||||
error->all(FLERR, "Energy was not tallied on needed timestep");
|
||||
|
||||
if ((comm->me == 0) && !force->pair->did_tally_callback())
|
||||
error->warning(FLERR, "Energy was not tallied by pair style");
|
||||
|
||||
// sum accumulated energies across procs
|
||||
|
||||
MPI_Allreduce(etotal, vector, size_vector, MPI_DOUBLE, MPI_SUM, world);
|
||||
|
||||
@ -28,10 +28,10 @@ using namespace LAMMPS_NS;
|
||||
|
||||
ComputePETally::ComputePETally(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg < 4) error->all(FLERR, "Illegal compute pe/tally command");
|
||||
if (narg < 4) utils::missing_cmd_args(FLERR, "compute pe/tally", error);
|
||||
|
||||
igroup2 = group->find(arg[3]);
|
||||
if (igroup2 == -1) error->all(FLERR, "Could not find compute pe/tally second group ID");
|
||||
if (igroup2 == -1) error->all(FLERR, "Could not find compute pe/tally second group ID {}", arg[3]);
|
||||
groupbit2 = group->bitmask[igroup2];
|
||||
|
||||
scalar_flag = 1;
|
||||
@ -169,6 +169,9 @@ double ComputePETally::compute_scalar()
|
||||
if ((did_setup != invoked_scalar) || (update->eflag_global != invoked_scalar))
|
||||
error->all(FLERR, "Energy was not tallied on needed timestep");
|
||||
|
||||
if ((comm->me == 0) && !force->pair->did_tally_callback())
|
||||
error->warning(FLERR, "Energy was not tallied by pair style");
|
||||
|
||||
// sum accumulated energies across procs
|
||||
|
||||
MPI_Allreduce(etotal, vector, size_peratom_cols, MPI_DOUBLE, MPI_SUM, world);
|
||||
@ -185,6 +188,9 @@ void ComputePETally::compute_peratom()
|
||||
if ((did_setup != invoked_peratom) || (update->eflag_global != invoked_peratom))
|
||||
error->all(FLERR, "Energy was not tallied on needed timestep");
|
||||
|
||||
if ((comm->me == 0) && !force->pair->did_tally_callback())
|
||||
error->warning(FLERR, "Energy was not tallied by pair style");
|
||||
|
||||
// collect contributions from ghost atoms
|
||||
|
||||
if (force->newton_pair) {
|
||||
|
||||
@ -29,10 +29,11 @@ using namespace LAMMPS_NS;
|
||||
|
||||
ComputeStressTally::ComputeStressTally(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg < 4) error->all(FLERR, "Illegal compute stress/tally command");
|
||||
if (narg < 4) utils::missing_cmd_args(FLERR, "compute stress/tally", error);
|
||||
|
||||
igroup2 = group->find(arg[3]);
|
||||
if (igroup2 == -1) error->all(FLERR, "Could not find compute stress/tally second group ID");
|
||||
if (igroup2 == -1)
|
||||
error->all(FLERR, "Could not find compute stress/tally second group ID {}", arg[3]);
|
||||
groupbit2 = group->bitmask[igroup2];
|
||||
|
||||
scalar_flag = 1;
|
||||
@ -201,7 +202,10 @@ double ComputeStressTally::compute_scalar()
|
||||
{
|
||||
invoked_scalar = update->ntimestep;
|
||||
if ((did_setup != invoked_scalar) || (update->eflag_global != invoked_scalar))
|
||||
error->all(FLERR, "Energy was not tallied on needed timestep");
|
||||
error->all(FLERR, "Stress was not tallied on needed timestep");
|
||||
|
||||
if ((comm->me == 0) && !force->pair->did_tally_callback())
|
||||
error->warning(FLERR, "Stress was not tallied by pair style");
|
||||
|
||||
// sum accumulated forces across procs
|
||||
|
||||
@ -221,7 +225,10 @@ void ComputeStressTally::compute_peratom()
|
||||
{
|
||||
invoked_peratom = update->ntimestep;
|
||||
if ((did_setup != invoked_peratom) || (update->eflag_global != invoked_peratom))
|
||||
error->all(FLERR, "Energy was not tallied on needed timestep");
|
||||
error->all(FLERR, "Stress was not tallied on needed timestep");
|
||||
|
||||
if ((comm->me == 0) && !force->pair->did_tally_callback())
|
||||
error->warning(FLERR, "Stress was not tallied by pair style");
|
||||
|
||||
// collect contributions from ghost atoms
|
||||
|
||||
|
||||
@ -109,6 +109,7 @@ Pair::Pair(LAMMPS *lmp) :
|
||||
maxeatom = maxvatom = maxcvatom = 0;
|
||||
|
||||
num_tally_compute = 0;
|
||||
did_tally_flag = 0;
|
||||
|
||||
nelements = nparams = maxparam = 0;
|
||||
|
||||
@ -295,6 +296,9 @@ void Pair::init()
|
||||
utils::logmesg(lmp,"Generated {} of {} mixed pair_coeff terms from {} mixing rule\n",
|
||||
mixed_count, num_mixed_pairs, mixing_rule_names[mix_flag]);
|
||||
}
|
||||
|
||||
// for monitoring, if Pair::ev_tally() was called.
|
||||
did_tally_flag = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -1095,6 +1099,7 @@ void Pair::ev_tally(int i, int j, int nlocal, int newton_pair,
|
||||
}
|
||||
|
||||
if (num_tally_compute > 0) {
|
||||
did_tally_flag = 1;
|
||||
for (int k=0; k < num_tally_compute; ++k) {
|
||||
Compute *c = list_tally_compute[k];
|
||||
c->pair_tally_callback(i, j, nlocal, newton_pair,
|
||||
|
||||
@ -230,12 +230,13 @@ class Pair : protected Pointers {
|
||||
// management of callbacks to be run from ev_tally()
|
||||
|
||||
protected:
|
||||
int num_tally_compute;
|
||||
int num_tally_compute, did_tally_flag;
|
||||
class Compute **list_tally_compute;
|
||||
|
||||
public:
|
||||
virtual void add_tally_callback(class Compute *);
|
||||
virtual void del_tally_callback(class Compute *);
|
||||
bool did_tally_callback() const { return did_tally_flag != 0; }
|
||||
|
||||
protected:
|
||||
int instance_me; // which Pair class instantiation I am
|
||||
|
||||
Reference in New Issue
Block a user