From b9a9bebd37e21692d8c732e47a2910794f9c3244 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Thu, 20 Feb 2020 12:48:44 -0700 Subject: [PATCH 01/18] delay change_box error check on per-atom restart data existing --- doc/src/change_box.rst | 40 ++++++++++++++++++++++++++++------------ src/change_box.cpp | 22 +++++++++++++++++++--- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/doc/src/change_box.rst b/doc/src/change_box.rst index 02f06ac681..f481658849 100644 --- a/doc/src/change_box.rst +++ b/doc/src/change_box.rst @@ -147,24 +147,40 @@ new owning processors. .. note:: - The simulation box size/shape can be changed by arbitrarily - large amounts by this command. This is not a problem, except that the + The simulation box size/shape can be changed by arbitrarily large + amounts by this command. This is not a problem, except that the mapping of processors to the simulation box is not changed from its initial 3d configuration; see the :doc:`processors ` command. Thus, if the box size/shape changes dramatically, the - mapping of processors to the simulation box may not end up as optimal - as the initial mapping attempted to be. + mapping of processors to the simulation box may not end up as + optimal as the initial mapping attempted to be. You may wish to + re-balance the atoms by using the :doc:`balance ` command + if that is the case. .. note:: - Because the keywords used in this command are applied one at a - time to the simulation box and the atoms in it, care must be taken - with triclinic cells to avoid exceeding the limits on skew after each - transformation in the sequence. If skew is exceeded before the final - transformation this can be avoided by changing the order of the - sequence, or breaking the transformation into two or more smaller - transformations. For more information on the allowed limits for box - skew see the discussion on triclinic boxes on :doc:`Howto triclinic ` doc page. + You cannot use this command after reading a restart file (and + before a run is performed) if the restart file stored per-atom + information from a fix and any of the specified keywords change the + box size or shape or boundary conditions. This is because atoms + may be moved to new processors and the restart info will not + migrate with them. LAMMPS will generate an error if this could + happen. Only the *ortho* and *triclinic* keywords do not trigger + this error. One solution is to perform a "run 0" command before + using the change_box command. This clears the per-atom restart + data, whether it has been re-assigned to a new fix or not. + +.. note:: + + Because the keywords used in this command are applied one at a time + to the simulation box and the atoms in it, care must be taken with + triclinic cells to avoid exceeding the limits on skew after each + transformation in the sequence. If skew is exceeded before the + final transformation this can be avoided by changing the order of + the sequence, or breaking the transformation into two or more + smaller transformations. For more information on the allowed + limits for box skew see the discussion on triclinic boxes on + :doc:`Howto triclinic ` doc page. ---------- diff --git a/src/change_box.cpp b/src/change_box.cpp index 98119fb3bf..7ae49ca776 100644 --- a/src/change_box.cpp +++ b/src/change_box.cpp @@ -46,9 +46,6 @@ void ChangeBox::command(int narg, char **arg) if (domain->box_exist == 0) error->all(FLERR,"Change_box command before simulation box is defined"); if (narg < 2) error->all(FLERR,"Illegal change_box command"); - if (modify->nfix_restart_peratom) - error->all(FLERR,"Cannot change_box after " - "reading restart file with per-atom info"); if (comm->me == 0 && screen) fprintf(screen,"Changing box ...\n"); @@ -174,6 +171,21 @@ void ChangeBox::command(int narg, char **arg) if (nops == 0) error->all(FLERR,"Illegal change_box command"); + // move_atoms = 1 if need to move atoms to new procs after box changes + // anything other than ORTHO or TRICLINIC may cause atom movement + + int move_atoms = 0; + for (int m = 0; m < nops; m++) { + if (ops[m].style != ORTHO || ops[m].style != TRICLINIC) move_atoms = 1; + } + + // error if moving atoms and there is stored per-atom restart state + // disallowed b/c restart per-atom fix info will not move with atoms + + if (move_atoms && modify->nfix_restart_peratom) + error->all(FLERR,"Change_box parameter not allowed after " + "reading restart file with per-atom info"); + // read options from end of input line options(narg-iarg,&arg[iarg]); @@ -350,6 +362,10 @@ void ChangeBox::command(int narg, char **arg) if (domain->triclinic) domain->lamda2x(atom->nlocal); } + // done if don't need to move atoms + + if (!move_atoms) return; + // move atoms back inside simulation box and to new processors // use remap() instead of pbc() // in case box moved a long distance relative to atoms From 0f00bb1ca6c08c3d5fcc14857f2a629fd9c8292d Mon Sep 17 00:00:00 2001 From: david-castillo Date: Mon, 23 Mar 2020 16:48:08 +0100 Subject: [PATCH 02/18] Added new argument r0stop to fix restrain bond Added new fix restrain lowerbound harmonic --- doc/src/fix_restrain.rst | 33 +++++++++- src/fix_restrain.cpp | 133 ++++++++++++++++++++++++++++++++++++--- src/fix_restrain.h | 4 +- 3 files changed, 160 insertions(+), 10 deletions(-) diff --git a/doc/src/fix_restrain.rst b/doc/src/fix_restrain.rst index 3965cee04d..9b9beaa5ac 100644 --- a/doc/src/fix_restrain.rst +++ b/doc/src/fix_restrain.rst @@ -17,10 +17,18 @@ Syntax .. parsed-literal:: - *bond* args = atom1 atom2 Kstart Kstop r0 + *bond* args = atom1 atom2 Kstart Kstop r0start r0stop atom1,atom2 = IDs of 2 atoms in bond Kstart,Kstop = restraint coefficients at start/end of run (energy units) - r0 = equilibrium bond distance (distance units) + r0start = equilibrium bond distance at start of run (distance units) + r0stop = equilibrium bond distance at end of run (distance units). If not + specified it's assumed to be equal to r0start + *lbond* args = atom1 atom2 Kstart Kstop r0start r0stop + atom1,atom2 = IDs of 2 atoms in bond + Kstart,Kstop = restraint coefficients at start/end of run (energy units) + r0start = equilibrium bond distance at start of run (distance units) + r0stop = equilibrium bond distance at end of run (distance units). If not + specified it's assumed to be equal to r0start *angle* args = atom1 atom2 atom3 Kstart Kstop theta0 atom1,atom2,atom3 = IDs of 3 atoms in angle, atom2 = middle atom Kstart,Kstop = restraint coefficients at start/end of run (energy units) @@ -38,6 +46,7 @@ Examples .. code-block:: LAMMPS fix holdem all restrain bond 45 48 2000.0 2000.0 2.75 + fix holdem all restrain lbond 45 48 2000.0 2000.0 2.75 fix holdem all restrain dihedral 1 2 3 4 2000.0 2000.0 120.0 fix holdem all restrain bond 45 48 2000.0 2000.0 2.75 dihedral 1 2 3 4 2000.0 2000.0 120.0 fix texas_holdem all restrain dihedral 1 2 3 4 0.0 2000.0 120.0 dihedral 1 2 3 5 0.0 2000.0 -120.0 dihedral 1 2 3 6 0.0 2000.0 0.0 @@ -141,6 +150,26 @@ is included in :math:`K`. ---------- +The *lbond* keyword applies a lowerbound bond restraint to the specified atoms +using the same functional form used by the :doc:`bond_style harmonic ` command if the distance between +the atoms is smaller than the equilibrium bond distance and 0 otherwise. The potential associated with +the restraint is + +.. math:: + + E = K (r - r_0)^2 if r < r_0 + E = 0 if r >= r_0 + +with the following coefficients: + +* :math:`K` (energy/distance\^2) +* :math:`r_0` (distance) + +:math:`K` and :math:`r_0` are specified with the fix. Note that the usual 1/2 factor +is included in :math:`K`. + +---------- + The *angle* keyword applies an angle restraint to the specified atoms using the same functional form used by the :doc:`angle_style harmonic ` command. The potential associated with the restraint is diff --git a/src/fix_restrain.cpp b/src/fix_restrain.cpp index 5a0d4fb662..5f65d7069b 100644 --- a/src/fix_restrain.cpp +++ b/src/fix_restrain.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -enum{BOND,ANGLE,DIHEDRAL}; +enum{BOND,LBOUND,ANGLE,DIHEDRAL}; #define TOLERANCE 0.05 #define SMALL 0.001 @@ -45,7 +45,7 @@ enum{BOND,ANGLE,DIHEDRAL}; FixRestrain::FixRestrain(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), rstyle(NULL), mult(NULL), ids(NULL), kstart(NULL), kstop(NULL), target(NULL), - cos_target(NULL), sin_target(NULL) + deqstart(NULL), deqstop(NULL), cos_target(NULL), sin_target(NULL) { if (narg < 4) error->all(FLERR,"Illegal fix restrain command"); @@ -72,6 +72,8 @@ FixRestrain::FixRestrain(LAMMPS *lmp, int narg, char **arg) : memory->grow(kstart,maxrestrain,"restrain:kstart"); memory->grow(kstop,maxrestrain,"restrain:kstop"); memory->grow(target,maxrestrain,"restrain:target"); + memory->grow(deqstart,maxrestrain,"restrain:deqstart"); + memory->grow(deqstop,maxrestrain,"restrain:deqstop"); memory->grow(cos_target,maxrestrain,"restrain:cos_target"); memory->grow(sin_target,maxrestrain,"restrain:sin_target"); } @@ -83,8 +85,29 @@ FixRestrain::FixRestrain(LAMMPS *lmp, int narg, char **arg) : ids[nrestrain][1] = force->inumeric(FLERR,arg[iarg+2]); kstart[nrestrain] = force->numeric(FLERR,arg[iarg+3]); kstop[nrestrain] = force->numeric(FLERR,arg[iarg+4]); - target[nrestrain] = force->numeric(FLERR,arg[iarg+5]); - iarg += 6; + deqstart[nrestrain] = force->numeric(FLERR,arg[iarg+5]); + if (iarg+6 == narg) { + deqstop[nrestrain] = force->numeric(FLERR,arg[iarg+5]); + iarg += 6; + } else { + deqstop[nrestrain] = force->numeric(FLERR,arg[iarg+6]); + iarg += 7; + } + } else if (strcmp(arg[iarg],"lbound") == 0) { + if (iarg+6 > narg) error->all(FLERR,"Illegal fix restrain command"); + rstyle[nrestrain] = LBOUND; + ids[nrestrain][0] = force->inumeric(FLERR,arg[iarg+1]); + ids[nrestrain][1] = force->inumeric(FLERR,arg[iarg+2]); + kstart[nrestrain] = force->numeric(FLERR,arg[iarg+3]); + kstop[nrestrain] = force->numeric(FLERR,arg[iarg+4]); + deqstart[nrestrain] = force->numeric(FLERR,arg[iarg+5]); + if (iarg+6 == narg) { + deqstop[nrestrain] = force->numeric(FLERR,arg[iarg+5]); + iarg += 6; + } else { + deqstop[nrestrain] = force->numeric(FLERR,arg[iarg+6]); + iarg += 7; + } } else if (strcmp(arg[iarg],"angle") == 0) { if (iarg+7 > narg) error->all(FLERR,"Illegal fix restrain command"); rstyle[nrestrain] = ANGLE; @@ -139,6 +162,8 @@ FixRestrain::~FixRestrain() memory->destroy(kstart); memory->destroy(kstop); memory->destroy(target); + memory->destroy(deqstart); + memory->destroy(deqstop); memory->destroy(cos_target); memory->destroy(sin_target); } @@ -192,11 +217,13 @@ void FixRestrain::post_force(int /*vflag*/) energy = 0.0; ebond = 0.0; + elbound = 0.0; eangle = 0.0; edihed = 0.0; for (int m = 0; m < nrestrain; m++) if (rstyle[m] == BOND) restrain_bond(m); + else if (rstyle[m] == LBOUND) restrain_lbound(m); else if (rstyle[m] == ANGLE) restrain_angle(m); else if (rstyle[m] == DIHEDRAL) restrain_dihedral(m); } @@ -233,6 +260,7 @@ void FixRestrain::restrain_bond(int m) double delta = update->ntimestep - update->beginstep; if (delta != 0.0) delta /= update->endstep - update->beginstep; double k = kstart[m] + delta * (kstop[m] - kstart[m]); + double deq = deqstart[m] + delta * (deqstop[m] - deqstart[m]); i1 = atom->map(ids[m][0]); i2 = atom->map(ids[m][1]); @@ -269,7 +297,7 @@ void FixRestrain::restrain_bond(int m) rsq = delx*delx + dely*dely + delz*delz; r = sqrt(rsq); - dr = r - target[m]; + dr = r - deq; rk = k * dr; // force & energy @@ -277,7 +305,7 @@ void FixRestrain::restrain_bond(int m) if (r > 0.0) fbond = -2.0*rk/r; else fbond = 0.0; - ebond += rk*dr; + ebond += rk*dr; energy += rk*dr; // apply force to each of 2 atoms @@ -295,6 +323,94 @@ void FixRestrain::restrain_bond(int m) } } +/* ---------------------------------------------------------------------- + apply harmonic lower-bound bond restraints +---------------------------------------------------------------------- */ + +void FixRestrain::restrain_lbound(int m) +{ + int i1,i2; + double delx,dely,delz,fbond; + double rsq,r,dr,rk; + + double **x = atom->x; + double **f = atom->f; + int nlocal = atom->nlocal; + int newton_bond = force->newton_bond; + + double delta = update->ntimestep - update->beginstep; + if (delta != 0.0) delta /= update->endstep - update->beginstep; + double k = kstart[m] + delta * (kstop[m] - kstart[m]); + double deq = deqstart[m] + delta * (deqstop[m] - deqstart[m]); + + i1 = atom->map(ids[m][0]); + i2 = atom->map(ids[m][1]); + + // newton_bond on: only processor owning i2 computes restraint + // newton_bond off: only processors owning either of i1,i2 computes restraint + + if (newton_bond) { + if (i2 == -1 || i2 >= nlocal) return; + if (i1 == -1) { + char str[128]; + sprintf(str, + "Restrain atoms %d %d missing on proc %d at step " BIGINT_FORMAT, + ids[m][0],ids[m][1], + comm->me,update->ntimestep); + error->one(FLERR,str); + } + } else { + if ((i1 == -1 || i1 >= nlocal) && (i2 == -1 || i2 >= nlocal)) return; + if (i1 == -1 || i2 == -1) { + char str[128]; + sprintf(str, + "Restrain atoms %d %d missing on proc %d at step " BIGINT_FORMAT, + ids[m][0],ids[m][1], + comm->me,update->ntimestep); + error->one(FLERR,str); + } + } + + delx = x[i1][0] - x[i2][0]; + dely = x[i1][1] - x[i2][1]; + delz = x[i1][2] - x[i2][2]; + domain->minimum_image(delx,dely,delz); + + rsq = delx*delx + dely*dely + delz*delz; + r = sqrt(rsq); + dr = r - deq; + rk = k * dr; + + // force & energy + + if (dr < 0) { + if (r > 0.0) fbond = -2.0*rk/r; + else fbond = 0.0; + + elbound += rk*dr; + energy += rk*dr; + } else { + fbond = 0.0; + + elbound += 0.0; + energy += 0.0; + } + + // apply force to each of 2 atoms + + if (newton_bond || i1 < nlocal) { + f[i1][0] += delx*fbond; + f[i1][1] += dely*fbond; + f[i1][2] += delz*fbond; + } + + if (newton_bond || i2 < nlocal) { + f[i2][0] -= delx*fbond; + f[i2][1] -= dely*fbond; + f[i2][2] -= delz*fbond; + } +} + /* ---------------------------------------------------------------------- apply harmonic angle restraints ---------------------------------------------------------------------- */ @@ -655,9 +771,12 @@ double FixRestrain::compute_vector(int n) MPI_Allreduce(&ebond,&ebond_all,1,MPI_DOUBLE,MPI_SUM,world); return ebond_all; } else if (n == 1) { + MPI_Allreduce(&elbound,&elbound_all,1,MPI_DOUBLE,MPI_SUM,world); + return elbound_all; + } else if (n == 3) { MPI_Allreduce(&eangle,&eangle_all,1,MPI_DOUBLE,MPI_SUM,world); return eangle_all; - } else if (n == 2) { + } else if (n == 4) { MPI_Allreduce(&edihed,&edihed_all,1,MPI_DOUBLE,MPI_SUM,world); return edihed_all; } else { diff --git a/src/fix_restrain.h b/src/fix_restrain.h index 4572905d46..3497b7daf5 100644 --- a/src/fix_restrain.h +++ b/src/fix_restrain.h @@ -44,14 +44,16 @@ class FixRestrain : public Fix { int *rstyle; int *mult; int **ids; - double *kstart,*kstop,*target; + double *kstart,*kstop,*deqstart,*deqstop,*target; double *cos_target,*sin_target; double energy,energy_all; double ebond,ebond_all; + double elbound,elbound_all; double eangle,eangle_all; double edihed,edihed_all; void restrain_bond(int); + void restrain_lbound(int); void restrain_angle(int); void restrain_dihedral(int); }; From 6209479797e29df62dd17476127e30a64d73d08f Mon Sep 17 00:00:00 2001 From: david-castillo Date: Mon, 23 Mar 2020 17:57:58 +0100 Subject: [PATCH 03/18] Removed some tabs Changed mathjax for multiline formula --- doc/src/fix_restrain.rst | 9 ++++++--- src/fix_restrain.cpp | 16 ++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/doc/src/fix_restrain.rst b/doc/src/fix_restrain.rst index 9b9beaa5ac..110b26680d 100644 --- a/doc/src/fix_restrain.rst +++ b/doc/src/fix_restrain.rst @@ -150,16 +150,19 @@ is included in :math:`K`. ---------- -The *lbond* keyword applies a lowerbound bond restraint to the specified atoms +The *lbond* keyword applies a lower bound bond restraint to the specified atoms using the same functional form used by the :doc:`bond_style harmonic ` command if the distance between the atoms is smaller than the equilibrium bond distance and 0 otherwise. The potential associated with the restraint is .. math:: - E = K (r - r_0)^2 if r < r_0 - E = 0 if r >= r_0 + E = K (r - r_0)^2 ,if\;r < r_0 +.. math:: + + E = 0 \qquad\quad\quad ,if\;r \ge r_0 + with the following coefficients: * :math:`K` (energy/distance\^2) diff --git a/src/fix_restrain.cpp b/src/fix_restrain.cpp index 5f65d7069b..a6793a36be 100644 --- a/src/fix_restrain.cpp +++ b/src/fix_restrain.cpp @@ -87,11 +87,11 @@ FixRestrain::FixRestrain(LAMMPS *lmp, int narg, char **arg) : kstop[nrestrain] = force->numeric(FLERR,arg[iarg+4]); deqstart[nrestrain] = force->numeric(FLERR,arg[iarg+5]); if (iarg+6 == narg) { - deqstop[nrestrain] = force->numeric(FLERR,arg[iarg+5]); - iarg += 6; + deqstop[nrestrain] = force->numeric(FLERR,arg[iarg+5]); + iarg += 6; } else { - deqstop[nrestrain] = force->numeric(FLERR,arg[iarg+6]); - iarg += 7; + deqstop[nrestrain] = force->numeric(FLERR,arg[iarg+6]); + iarg += 7; } } else if (strcmp(arg[iarg],"lbound") == 0) { if (iarg+6 > narg) error->all(FLERR,"Illegal fix restrain command"); @@ -102,11 +102,11 @@ FixRestrain::FixRestrain(LAMMPS *lmp, int narg, char **arg) : kstop[nrestrain] = force->numeric(FLERR,arg[iarg+4]); deqstart[nrestrain] = force->numeric(FLERR,arg[iarg+5]); if (iarg+6 == narg) { - deqstop[nrestrain] = force->numeric(FLERR,arg[iarg+5]); - iarg += 6; + deqstop[nrestrain] = force->numeric(FLERR,arg[iarg+5]); + iarg += 6; } else { - deqstop[nrestrain] = force->numeric(FLERR,arg[iarg+6]); - iarg += 7; + deqstop[nrestrain] = force->numeric(FLERR,arg[iarg+6]); + iarg += 7; } } else if (strcmp(arg[iarg],"angle") == 0) { if (iarg+7 > narg) error->all(FLERR,"Illegal fix restrain command"); From 732ae97083291845e2d59a18e0fe61c75403c4b2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 13 Apr 2020 20:50:45 -0400 Subject: [PATCH 04/18] update version string for next patch release --- doc/lammps.1 | 2 +- src/version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/lammps.1 b/doc/lammps.1 index d2851603c6..fd228f892f 100644 --- a/doc/lammps.1 +++ b/doc/lammps.1 @@ -1,4 +1,4 @@ -.TH LAMMPS "19 March 2020" "2020-03-19" +.TH LAMMPS "15 April 2020" "2020-04-15" .SH NAME .B LAMMPS \- Molecular Dynamics Simulator. diff --git a/src/version.h b/src/version.h index 774a0a4b96..65a0ca8e7d 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define LAMMPS_VERSION "19 Mar 2020" +#define LAMMPS_VERSION "15 Apr 2020" From be1f3073847b94575a63a6e8efb6fa5f2457ee2c Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Tue, 14 Apr 2020 16:57:04 -0400 Subject: [PATCH 05/18] Add defines to build Lepton with MSVC and traditional make --- lib/colvars/Makefile.common | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/colvars/Makefile.common b/lib/colvars/Makefile.common index 0482cff74a..2f2e2beffb 100644 --- a/lib/colvars/Makefile.common +++ b/lib/colvars/Makefile.common @@ -61,7 +61,7 @@ ifeq ($(COLVARS_LEPTON),no) LEPTON_INCFLAGS = COLVARS_OBJS = $(COLVARS_SRCS:.cpp=.o) else -LEPTON_INCFLAGS = -Ilepton/include -DLEPTON +LEPTON_INCFLAGS = -Ilepton/include -DLEPTON -DLEPTON_USE_STATIC_LIBRARIES COLVARS_OBJS = $(COLVARS_SRCS:.cpp=.o) $(LEPTON_SRCS:.cpp=.o) endif @@ -82,4 +82,20 @@ Makefile.deps: $(COLVARS_SRCS) done include Makefile.deps + +# Exceptions to pattern rule above for Lepton objects + +lepton/src/CompiledExpression.o: lepton/src/CompiledExpression.cpp + $(CXX) $(CXXFLAGS) -Ilepton/include -DLEPTON_BUILDING_STATIC_LIBRARY -c -o $@ $< +lepton/src/ExpressionProgram.o: lepton/src/ExpressionProgram.cpp + $(CXX) $(CXXFLAGS) -Ilepton/include -DLEPTON_BUILDING_STATIC_LIBRARY -c -o $@ $< +lepton/src/ExpressionTreeNode.o: lepton/src/ExpressionTreeNode.cpp + $(CXX) $(CXXFLAGS) -Ilepton/include -DLEPTON_BUILDING_STATIC_LIBRARY -c -o $@ $< +lepton/src/Operation.o: lepton/src/Operation.cpp + $(CXX) $(CXXFLAGS) -Ilepton/include -DLEPTON_BUILDING_STATIC_LIBRARY -c -o $@ $< +lepton/src/ParsedExpression.o: lepton/src/ParsedExpression.cpp + $(CXX) $(CXXFLAGS) -Ilepton/include -DLEPTON_BUILDING_STATIC_LIBRARY -c -o $@ $< +lepton/src/Parser.o: lepton/src/Parser.cpp + $(CXX) $(CXXFLAGS) -Ilepton/include -DLEPTON_BUILDING_STATIC_LIBRARY -c -o $@ $< + include Makefile.lepton.deps # Hand-generated From 250e3892f821211402379eb3148d7bc5df0a1cca Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Tue, 14 Apr 2020 17:07:14 -0400 Subject: [PATCH 06/18] Add defines to build Lepton with MSVC and CMake --- cmake/Modules/Packages/USER-COLVARS.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/Modules/Packages/USER-COLVARS.cmake b/cmake/Modules/Packages/USER-COLVARS.cmake index 281b497dea..31e64e3790 100644 --- a/cmake/Modules/Packages/USER-COLVARS.cmake +++ b/cmake/Modules/Packages/USER-COLVARS.cmake @@ -12,6 +12,8 @@ if(COLVARS_LEPTON) if(NOT BUILD_SHARED_LIBS) install(TARGETS lepton EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() + # Change the define below to LEPTON_BUILDING_SHARED_LIBRARY when linking Lepton as a DLL with MSVC + target_compile_definitions(lepton PRIVATE -DLEPTON_BUILDING_STATIC_LIBRARY) set_target_properties(lepton PROPERTIES OUTPUT_NAME lammps_lepton${LAMMPS_MACHINE}) target_include_directories(lepton PRIVATE ${LEPTON_DIR}/include) endif() @@ -27,6 +29,8 @@ target_link_libraries(lammps PRIVATE colvars) if(COLVARS_LEPTON) target_link_libraries(lammps PRIVATE lepton) - target_compile_options(colvars PRIVATE -DLEPTON) + target_compile_definitions(colvars PRIVATE -DLEPTON) + # Disable the line below when linking Lepton as a DLL with MSVC + target_compile_definitions(colvars PRIVATE -DLEPTON_USE_STATIC_LIBRARIES) target_include_directories(colvars PUBLIC ${LEPTON_DIR}/include) endif() From 48c136b78430d1976ec4fdc3302b644cf6fdfccf Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 14 Apr 2020 21:37:34 -0400 Subject: [PATCH 07/18] fix whitespace issue --- src/KOKKOS/min_kokkos.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KOKKOS/min_kokkos.cpp b/src/KOKKOS/min_kokkos.cpp index 30b362dc51..e5f22411f6 100644 --- a/src/KOKKOS/min_kokkos.cpp +++ b/src/KOKKOS/min_kokkos.cpp @@ -636,7 +636,7 @@ double MinKokkos::fnorm_inf() double MinKokkos::fnorm_max() { - + double local_norm_max = 0.0; { // local variables for lambda capture From b718db385dbc82e2e5d2787b498116e883a032a5 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Tue, 14 Apr 2020 17:36:44 -0500 Subject: [PATCH 08/18] Add support for "internal" kim_match_pairs command --- src/KIM/kim_interactions.cpp | 84 +++++++++++++++++++++++++++++++++++- src/KIM/kim_interactions.h | 2 + 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/src/KIM/kim_interactions.cpp b/src/KIM/kim_interactions.cpp index 7dbe523033..cc891f098f 100644 --- a/src/KIM/kim_interactions.cpp +++ b/src/KIM/kim_interactions.cpp @@ -15,6 +15,7 @@ Contributing authors: Axel Kohlmeyer (Temple U), Ryan S. Elliott (UMN) Ellad B. Tadmor (UMN) + Ronald Miller (Carleton U) ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- @@ -57,8 +58,10 @@ #include "kim_interactions.h" #include +#include #include #include +#include #include "error.h" #include "atom.h" #include "comm.h" @@ -80,6 +83,8 @@ extern "C" { using namespace LAMMPS_NS; +#define MAXLINE 1024 + /* ---------------------------------------------------------------------- */ void KimInteractions::command(int narg, char **arg) @@ -223,8 +228,16 @@ void KimInteractions::do_setup(int narg, char **arg) for (int j=0; j < sim_lines; ++j) { KIM_SimulatorModel_GetSimulatorFieldLine( simulatorModel,sim_model_idx,j,&sim_value); - input->one(sim_value); - } + char strbuf[MAXLINE]; + char * strword; + strcpy(strbuf,sim_value); + strword = strtok(strbuf," \t"); + if (0==strcmp(strword,"kim_match_pairs")) { + kim_match_pairs(sim_value); + } else { + input->one(sim_value); + } + } } } @@ -263,6 +276,73 @@ void KimInteractions::do_setup(int narg, char **arg) /* ---------------------------------------------------------------------- */ +void KimInteractions::kim_match_pairs(char const *const input_line) const +{ + char strbuf[MAXLINE]; + strcpy(strbuf,input_line); + char *cmd, *filename; + cmd = strtok(strbuf," \t"); + filename = strtok(NULL," \t"); + + FILE *fp; + fp = fopen(filename,"r"); + if (fp == NULL) { + error->one(FLERR,"Parameter file not found"); + } + + std::vector species; + for (int i = 0; i < atom->ntypes; ++i) + { + char *str; + str = strtok(NULL," \t"); + if (str == NULL) + error->one(FLERR,"Incorrect args for pair_species_coeff command"); + species.push_back(str); + } + + char line[MAXLINE],*ptr; + int n, eof = 0; + + while (1) { + if (comm->me == 0) { + ptr = fgets(line,MAXLINE,fp); + if (ptr == NULL) { + eof = 1; + fclose(fp); + } else n = strlen(line) + 1; + } + MPI_Bcast(&eof,1,MPI_INT,0,world); + if (eof) break; + MPI_Bcast(&n,1,MPI_INT,0,world); + MPI_Bcast(line,n,MPI_CHAR,0,world); + + char *species1, *species2, *the_rest; + ptr = line; + species1 = strtok(ptr," \t"); + species2 = strtok(NULL," \t"); + the_rest = strtok(NULL,"\n"); + + for (int type_a = 0; type_a < atom->ntypes; ++type_a) { + for (int type_b = type_a; type_b < atom->ntypes; ++type_b) { + if(((strcmp(species[type_a],species1) == 0) && + (strcmp(species[type_b],species2) == 0)) + || + ((strcmp(species[type_b],species1) == 0) && + (strcmp(species[type_a],species2) == 0)) + ) { + char pair_command[MAXLINE]; + sprintf(pair_command,"pair_coeff %i %i %s",type_a+1,type_b+1, + the_rest); + input->one(pair_command); + } + } + } + } + fclose(fp); +} + +/* ---------------------------------------------------------------------- */ + int KimInteractions::species_to_atomic_no(std::string const species) const { if (species == "H") return 1; diff --git a/src/KIM/kim_interactions.h b/src/KIM/kim_interactions.h index 8172004d53..d22205249f 100644 --- a/src/KIM/kim_interactions.h +++ b/src/KIM/kim_interactions.h @@ -15,6 +15,7 @@ Contributing authors: Axel Kohlmeyer (Temple U), Ryan S. Elliott (UMN) Ellad B. Tadmor (UMN) + Ronald Miller (Carleton U) ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- @@ -76,6 +77,7 @@ class KimInteractions : protected Pointers { private: void do_setup(int, char **); int species_to_atomic_no(std::string const species) const; + void kim_match_pairs(char const *const input_line) const; void kim_interactions_log_delimiter(std::string const begin_end) const; }; From 1cee0cf50e583658002c6330ba54d96af5e01592 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Wed, 15 Apr 2020 09:51:36 -0500 Subject: [PATCH 09/18] Changes and Comments in response to Axel's suggestions --- src/KIM/kim_interactions.cpp | 17 ++++++++++++++--- src/KIM/kim_interactions.h | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/KIM/kim_interactions.cpp b/src/KIM/kim_interactions.cpp index cc891f098f..0964ba6531 100644 --- a/src/KIM/kim_interactions.cpp +++ b/src/KIM/kim_interactions.cpp @@ -232,8 +232,19 @@ void KimInteractions::do_setup(int narg, char **arg) char * strword; strcpy(strbuf,sim_value); strword = strtok(strbuf," \t"); - if (0==strcmp(strword,"kim_match_pairs")) { - kim_match_pairs(sim_value); + if (0==strcmp(strword,"KIM_MATCH_PAIRS")) { + // Notes regarding the KIM_MATCH_PAIRS command + // * This is an INTERNAL command. + // * It is intended for use only by KIM Simulator Models. + // * It is not possible to use this command outside of the context + // of the kim_interactions command and KIM Simulator Models. + // * The command performs a transformation from symbolic + // string-based atom types to lammps numeric atom types for + // the pair_coeff settings. + // * The command is not documented fully as it is expected to be + // temporary. Eventually it should be replaced by a more + // comprehensive symbolic types support in lammps. + KIM_MATCH_PAIRS(sim_value); } else { input->one(sim_value); } @@ -276,7 +287,7 @@ void KimInteractions::do_setup(int narg, char **arg) /* ---------------------------------------------------------------------- */ -void KimInteractions::kim_match_pairs(char const *const input_line) const +void KimInteractions::KIM_MATCH_PAIRS(char const *const input_line) const { char strbuf[MAXLINE]; strcpy(strbuf,input_line); diff --git a/src/KIM/kim_interactions.h b/src/KIM/kim_interactions.h index d22205249f..f92e58ca48 100644 --- a/src/KIM/kim_interactions.h +++ b/src/KIM/kim_interactions.h @@ -77,7 +77,7 @@ class KimInteractions : protected Pointers { private: void do_setup(int, char **); int species_to_atomic_no(std::string const species) const; - void kim_match_pairs(char const *const input_line) const; + void KIM_MATCH_PAIRS(char const *const input_line) const; void kim_interactions_log_delimiter(std::string const begin_end) const; }; From e94576ecd8f66c8cd693c032ebb6d4e80af267ff Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 15 Apr 2020 11:21:25 -0400 Subject: [PATCH 10/18] update documentation as requested --- doc/src/fix_restrain.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/src/fix_restrain.rst b/doc/src/fix_restrain.rst index 110b26680d..44f5e7585d 100644 --- a/doc/src/fix_restrain.rst +++ b/doc/src/fix_restrain.rst @@ -17,12 +17,12 @@ Syntax .. parsed-literal:: - *bond* args = atom1 atom2 Kstart Kstop r0start r0stop + *bond* args = atom1 atom2 Kstart Kstop r0start (r0stop) atom1,atom2 = IDs of 2 atoms in bond Kstart,Kstop = restraint coefficients at start/end of run (energy units) r0start = equilibrium bond distance at start of run (distance units) - r0stop = equilibrium bond distance at end of run (distance units). If not - specified it's assumed to be equal to r0start + r0stop = equilibrium bond distance at end of run (optional) (distance units). If not + specified it is assumed to be equal to r0start *lbond* args = atom1 atom2 Kstart Kstop r0start r0stop atom1,atom2 = IDs of 2 atoms in bond Kstart,Kstop = restraint coefficients at start/end of run (energy units) From 0796a7032e4856e276b91923f8bc4422333b66e9 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 15 Apr 2020 11:22:48 -0400 Subject: [PATCH 11/18] same doc change for "lbond" option --- doc/src/fix_restrain.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/src/fix_restrain.rst b/doc/src/fix_restrain.rst index 44f5e7585d..692336bec6 100644 --- a/doc/src/fix_restrain.rst +++ b/doc/src/fix_restrain.rst @@ -23,12 +23,12 @@ Syntax r0start = equilibrium bond distance at start of run (distance units) r0stop = equilibrium bond distance at end of run (optional) (distance units). If not specified it is assumed to be equal to r0start - *lbond* args = atom1 atom2 Kstart Kstop r0start r0stop + *lbond* args = atom1 atom2 Kstart Kstop r0start (r0stop) atom1,atom2 = IDs of 2 atoms in bond Kstart,Kstop = restraint coefficients at start/end of run (energy units) r0start = equilibrium bond distance at start of run (distance units) - r0stop = equilibrium bond distance at end of run (distance units). If not - specified it's assumed to be equal to r0start + r0stop = equilibrium bond distance at end of run (optional) (distance units). If not + specified it is assumed to be equal to r0start *angle* args = atom1 atom2 atom3 Kstart Kstop theta0 atom1,atom2,atom3 = IDs of 3 atoms in angle, atom2 = middle atom Kstart,Kstop = restraint coefficients at start/end of run (energy units) From 529e905816a75d0563f38e2d073ea42fc47cb717 Mon Sep 17 00:00:00 2001 From: "Ryan S. Elliott" Date: Wed, 15 Apr 2020 10:29:55 -0500 Subject: [PATCH 12/18] Fixup error message --- src/KIM/kim_interactions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KIM/kim_interactions.cpp b/src/KIM/kim_interactions.cpp index 0964ba6531..55d89766b5 100644 --- a/src/KIM/kim_interactions.cpp +++ b/src/KIM/kim_interactions.cpp @@ -307,7 +307,7 @@ void KimInteractions::KIM_MATCH_PAIRS(char const *const input_line) const char *str; str = strtok(NULL," \t"); if (str == NULL) - error->one(FLERR,"Incorrect args for pair_species_coeff command"); + error->one(FLERR,"Incorrect args for KIM_MATCH_PAIRS command"); species.push_back(str); } From 45aa6bd3b831d2c090ed33735593531638fd397c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 15 Apr 2020 14:22:29 -0400 Subject: [PATCH 13/18] add @giacomofiorin as code owner for USER-COLVARS.cmake --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a4fc5b7b4f..a2ab1d4407 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -119,6 +119,7 @@ tools/emacs/* @HaoZeke # cmake cmake/* @junghans @rbberger +cmake/Modules/Packages/USER-COLVARS.cmake @junghans @rbberger @giacomofiorin # python python/* @rbberger From adf9602ae3b6f81c4fbf87696a318e128772cd2f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 15 Apr 2020 14:26:37 -0400 Subject: [PATCH 14/18] whitespace fix --- src/KOKKOS/min_kokkos.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KOKKOS/min_kokkos.cpp b/src/KOKKOS/min_kokkos.cpp index 30b362dc51..e5f22411f6 100644 --- a/src/KOKKOS/min_kokkos.cpp +++ b/src/KOKKOS/min_kokkos.cpp @@ -636,7 +636,7 @@ double MinKokkos::fnorm_inf() double MinKokkos::fnorm_max() { - + double local_norm_max = 0.0; { // local variables for lambda capture From c5f6b5c6873795d742d637cf6cd6eabfe8b5fe05 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 15 Apr 2020 14:29:37 -0400 Subject: [PATCH 15/18] one more whitespace fix --- src/fix_restrain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fix_restrain.cpp b/src/fix_restrain.cpp index a6793a36be..f1032c1bc1 100644 --- a/src/fix_restrain.cpp +++ b/src/fix_restrain.cpp @@ -382,11 +382,11 @@ void FixRestrain::restrain_lbound(int m) rk = k * dr; // force & energy - + if (dr < 0) { if (r > 0.0) fbond = -2.0*rk/r; else fbond = 0.0; - + elbound += rk*dr; energy += rk*dr; } else { From ca64c461ff03801bce2c5184bae79ca17509db71 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 16 Apr 2020 08:19:50 -0600 Subject: [PATCH 16/18] Remove unnecessary error check in USER-DPD fix rx --- src/USER-DPD/fix_rx.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/USER-DPD/fix_rx.cpp b/src/USER-DPD/fix_rx.cpp index 46fb17cbfd..6367b32e9d 100644 --- a/src/USER-DPD/fix_rx.cpp +++ b/src/USER-DPD/fix_rx.cpp @@ -256,10 +256,6 @@ void FixRX::post_constructor() int nUniqueSpecies = 0; bool match; - for (int i = 0; i < modify->nfix; i++) - if (utils::strmatch(modify->fix[i]->style,"^property/atom") == 0) - error->all(FLERR,"fix rx cannot be combined with fix property/atom"); - char **tmpspecies = new char*[maxspecies]; int tmpmaxstrlen = 0; for(int jj=0; jj < maxspecies; jj++) From 19ac94e9a38d9625a352cb30616221022076544a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 16 Apr 2020 13:15:41 -0400 Subject: [PATCH 17/18] remove @timmattox as a code owner of USER-DPD --- .github/CODEOWNERS | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a2ab1d4407..d44b3dfb4d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -22,7 +22,6 @@ src/SPIN/* @julient31 src/USER-CGDNA/* @ohenrich src/USER-CGSDK/* @akohlmey src/USER-COLVARS/* @giacomofiorin -src/USER-DPD/* @timattox src/USER-INTEL/* @wmbrownintel src/USER-MANIFOLD/* @Pakketeretet2 src/USER-MEAMC/* @martok From b3c7c1f93cba39c12edbaea132c63e29bc20e77e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 16 Apr 2020 15:13:21 -0400 Subject: [PATCH 18/18] utils.h is not used anymore --- src/USER-DPD/fix_rx.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/USER-DPD/fix_rx.cpp b/src/USER-DPD/fix_rx.cpp index 6367b32e9d..3d870cc902 100644 --- a/src/USER-DPD/fix_rx.cpp +++ b/src/USER-DPD/fix_rx.cpp @@ -31,7 +31,6 @@ #include "neigh_request.h" #include "math_special.h" #include "pair_dpd_fdt_energy.h" -#include "utils.h" #include // std::vector<> #include // std::max