diff --git a/src/fix_external.cpp b/src/fix_external.cpp index fffc57c72c..a09dd62ffd 100644 --- a/src/fix_external.cpp +++ b/src/fix_external.cpp @@ -33,6 +33,10 @@ FixExternal::FixExternal(LAMMPS *lmp, int narg, char **arg) : { if (narg < 4) error->all(FLERR,"Illegal fix external command"); + scalar_flag = 1; + global_freq = 1; + extscalar = 1; + if (strcmp(arg[3],"pf/callback") == 0) { if (narg != 6) error->all(FLERR,"Illegal fix external command"); mode = PF_CALLBACK; @@ -55,6 +59,8 @@ FixExternal::FixExternal(LAMMPS *lmp, int narg, char **arg) : fexternal = NULL; grow_arrays(atom->nmax); atom->add_callback(0); + + user_energy = 0.0; } /* ---------------------------------------------------------------------- */ @@ -75,6 +81,7 @@ int FixExternal::setmask() int mask = 0; if (mode == PF_CALLBACK || mode == PF_ARRAY) { mask |= POST_FORCE; + mask |= THERMO_ENERGY; mask |= MIN_POST_FORCE; } return mask; @@ -138,6 +145,23 @@ void FixExternal::min_post_force(int vflag) post_force(vflag); } +/* ---------------------------------------------------------------------- */ + +void FixExternal::set_energy(double eng) +{ + user_energy = eng; +} + +/* ---------------------------------------------------------------------- + potential energy of added force + up to user to set it via set_energy() +------------------------------------------------------------------------- */ + +double FixExternal::compute_scalar() +{ + return user_energy; +} + /* ---------------------------------------------------------------------- memory usage of local atom-based array ------------------------------------------------------------------------- */ diff --git a/src/fix_external.h b/src/fix_external.h index fdd32b7712..3e38f09c42 100644 --- a/src/fix_external.h +++ b/src/fix_external.h @@ -26,6 +26,8 @@ namespace LAMMPS_NS { class FixExternal : public Fix { public: + double **fexternal; + FixExternal(class LAMMPS *, int, char **); ~FixExternal(); int setmask(); @@ -34,6 +36,9 @@ class FixExternal : public Fix { void min_setup(int); void post_force(int); void min_post_force(int); + double compute_scalar(); + + void set_energy(double eng); double memory_usage(); void grow_arrays(int); @@ -48,7 +53,7 @@ class FixExternal : public Fix { int mode,ncall,napply; FnPtr callback; void *ptr_caller; - double **fexternal; + double user_energy; }; }