Skip to content
Snippets Groups Projects
Commit 3c41295e authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

change implementation to be consistent with pair_coeff and remain backward compatible

parent 8b944e06
No related branches found
No related tags found
No related merge requests found
...@@ -10,22 +10,20 @@ compute pair command :h3 ...@@ -10,22 +10,20 @@ compute pair command :h3
[Syntax:] [Syntax:]
compute ID group-ID pair pstyle keyword value :pre compute ID group-ID pair pstyle \[nstyle\] \[evalue\] :pre
ID, group-ID are documented in "compute"_compute.html command :ulb,l ID, group-ID are documented in "compute"_compute.html command :ulb,l
pair = style name of this compute command :l pair = style name of this compute command :l
pstyle = style name of a pair style that calculates additional values :l pstyle = style name of a pair style that calculates additional values :l
zero or more keyword/value pairs may be appended :l nsub = {n}-instance of a substyle, if a pair style is used multiple times in a hybrid style :l
keyword = {evalue} or {nsub} {evalue} = {epair} or {evdwl} or {ecoul} or blank (optional) :l
{evalue} arg = {epair} or {evdwl} or {ecoul}
{nsub} n = use the {n}-th instance of a sub-style in a pair_style hybrid or hybrid/overlay command :pre
:ule :ule
[Examples:] [Examples:]
compute 1 all pair gauss compute 1 all pair gauss
compute 1 all pair lj/cut/coul/cut evalue ecoul compute 1 all pair lj/cut/coul/cut ecoul
compute 1 all pair tersoff nsub 2 compute 1 all pair tersoff 2 epair
compute 1 all pair reax :pre compute 1 all pair reax :pre
[Description:] [Description:]
...@@ -39,15 +37,10 @@ NOTE: The group specified for this command is [ignored]. ...@@ -39,15 +37,10 @@ NOTE: The group specified for this command is [ignored].
The specified {pstyle} must be a pair style used in your simulation The specified {pstyle} must be a pair style used in your simulation
either by itself or as a sub-style in a "pair_style hybrid or either by itself or as a sub-style in a "pair_style hybrid or
hybrid/overlay"_pair_hybrid.html command. If the sub-style is hybrid/overlay"_pair_hybrid.html command. If the sub-style is
used more than once, an additional keyword {nsub} has to be used more than once, an additional number {nsub} has to be specified
specified in order to choose which instance of the sub-style will in order to choose which instance of the sub-style will be used by
be used by the compute. the compute. Not specifying the number in this case will cause the
compute to fail.
NOTE: The {nsub} keyword should be used only if the sub-style occurs
multiple times. Its value must be an integer from 1 to M, where M is
the number of times the sub-style is listed in the "pair_style hybrid
or hybrid/overlay"_pair_hybrid.html" command. If the pair style is
used only once, {nsub} must remain zero.
The {evalue} setting is optional. All The {evalue} setting is optional. All
pair styles tally a potential energy {epair} which may be broken into pair styles tally a potential energy {epair} which may be broken into
...@@ -55,7 +48,7 @@ two parts: {evdwl} and {ecoul} such that {epair} = {evdwl} + {ecoul}. ...@@ -55,7 +48,7 @@ two parts: {evdwl} and {ecoul} such that {epair} = {evdwl} + {ecoul}.
If the pair style calculates Coulombic interactions, their energy will If the pair style calculates Coulombic interactions, their energy will
be tallied in {ecoul}. Everything else (whether it is a Lennard-Jones be tallied in {ecoul}. Everything else (whether it is a Lennard-Jones
style van der Waals interaction or not) is tallied in {evdwl}. If style van der Waals interaction or not) is tallied in {evdwl}. If
{evalue} is specified as {epair}, then {epair} is stored {evalue} is blank or specified as {epair}, then {epair} is stored
as a global scalar by this compute. This is useful when using as a global scalar by this compute. This is useful when using
"pair_style hybrid"_pair_hybrid.html if you want to know the portion "pair_style hybrid"_pair_hybrid.html if you want to know the portion
of the total energy contributed by one sub-style. If {evalue} is of the total energy contributed by one sub-style. If {evalue} is
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <mpi.h> #include <mpi.h>
#include <cstring> #include <cstring>
#include <cctype>
#include "compute_pair.h" #include "compute_pair.h"
#include "update.h" #include "update.h"
#include "force.h" #include "force.h"
...@@ -43,23 +44,24 @@ ComputePair::ComputePair(LAMMPS *lmp, int narg, char **arg) : ...@@ -43,23 +44,24 @@ ComputePair::ComputePair(LAMMPS *lmp, int narg, char **arg) :
int iarg = 4; int iarg = 4;
nsub = 0; nsub = 0;
evalue = NPAIR;
if (narg > iarg) {
if (isdigit(arg[iarg][0])) {
nsub = force->inumeric(FLERR,arg[iarg]);
++iarg;
if (nsub <= 0)
error->all(FLERR,"Illegal compute pair command");
}
}
while (iarg < narg) { if (narg > iarg) {
if (strcmp(arg[iarg],"evalue") == 0) { if (strcmp(arg[iarg],"epair") == 0) evalue = EPAIR;
if (iarg+2 > narg) error->all(FLERR,"Illegal compute pair command"); else if (strcmp(arg[iarg],"evdwl") == 0) evalue = EVDWL;
if (strcmp(arg[iarg+1],"epair") == 0) evalue = EPAIR; else if (strcmp(arg[iarg],"ecoul") == 0) evalue = ECOUL;
else if (strcmp(arg[iarg+1],"evdwl") == 0) evalue = EVDWL; else error->all(FLERR, "Illegal compute pair command");
else if (strcmp(arg[iarg+1],"ecoul") == 0) evalue = ECOUL; ++iarg;
else error->all(FLERR, "Unrecognized energy type");
iarg += 2;
} else if (strcmp(arg[iarg],"nsub") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal compute pair command");
nsub = force->inumeric(FLERR,arg[iarg+1]);
iarg += 2;
} else error->all(FLERR,"Illegal compute pair command");
} }
// check if pair style with and without suffix exists // check if pair style with and without suffix exists
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment