Skip to content
Snippets Groups Projects
Unverified Commit 9a0c02a8 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #1150 from mkanski/compute_pair_multiple_pstyles

Extend compute pair to handle multiple instances of a sub-style in pair style hybrid
parents 7416e113 dc6123fa
No related branches found
No related tags found
No related merge requests found
...@@ -10,17 +10,20 @@ compute pair command :h3 ...@@ -10,17 +10,20 @@ compute pair command :h3
[Syntax:] [Syntax:]
compute ID group-ID pair pstyle evalue :pre compute ID group-ID pair pstyle \[nstyle\] \[evalue\] :pre
ID, group-ID are documented in "compute"_compute.html command ID, group-ID are documented in "compute"_compute.html command :ulb,l
pair = style name of this compute command pair = style name of this compute command :l
pstyle = style name of a pair style that calculates additional values pstyle = style name of a pair style that calculates additional values :l
evalue = {epair} or {evdwl} or {ecoul} or blank (optional setting) :ul nsub = {n}-instance of a substyle, if a pair style is used multiple times in a hybrid style :l
{evalue} = {epair} or {evdwl} or {ecoul} or blank (optional) :l
:ule
[Examples:] [Examples:]
compute 1 all pair gauss compute 1 all pair gauss
compute 1 all pair lj/cut/coul/cut ecoul compute 1 all pair lj/cut/coul/cut ecoul
compute 1 all pair tersoff 2 epair
compute 1 all pair reax :pre compute 1 all pair reax :pre
[Description:] [Description:]
...@@ -33,15 +36,19 @@ NOTE: The group specified for this command is [ignored]. ...@@ -33,15 +36,19 @@ 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. hybrid/overlay"_pair_hybrid.html command. If the sub-style is
used more than once, an additional number {nsub} has to be specified
in order to choose which instance of the sub-style will be used by
the compute. Not specifying the number in this case will cause the
compute to fail.
The {evalue} setting is optional; it may be left off the command. 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
two parts: {evdwl} and {ecoul} such that {epair} = {evdwl} + {ecoul}. 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} or left out, 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
...@@ -82,4 +89,4 @@ the doc page for the pair style for details. ...@@ -82,4 +89,4 @@ the doc page for the pair style for details.
[Default:] [Default:]
The default for {evalue} is {epair}. The keyword defaults are {evalue} = {epair}, nsub = 0.
...@@ -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"
...@@ -29,7 +30,7 @@ ComputePair::ComputePair(LAMMPS *lmp, int narg, char **arg) : ...@@ -29,7 +30,7 @@ ComputePair::ComputePair(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg), Compute(lmp, narg, arg),
pstyle(NULL), pair(NULL), one(NULL) pstyle(NULL), pair(NULL), one(NULL)
{ {
if (narg < 4 || narg > 5) error->all(FLERR,"Illegal compute pair command"); if (narg < 4) error->all(FLERR,"Illegal compute pair command");
scalar_flag = 1; scalar_flag = 1;
extscalar = 1; extscalar = 1;
...@@ -41,19 +42,34 @@ ComputePair::ComputePair(LAMMPS *lmp, int narg, char **arg) : ...@@ -41,19 +42,34 @@ ComputePair::ComputePair(LAMMPS *lmp, int narg, char **arg) :
pstyle = new char[n]; pstyle = new char[n];
strcpy(pstyle,arg[3]); strcpy(pstyle,arg[3]);
if (narg == 5) { int iarg = 4;
if (strcmp(arg[4],"epair") == 0) evalue = EPAIR; nsub = 0;
if (strcmp(arg[4],"evdwl") == 0) evalue = EVDWL; evalue = EPAIR;
if (strcmp(arg[4],"ecoul") == 0) evalue = ECOUL;
} else evalue = EPAIR; 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");
}
}
if (narg > iarg) {
if (strcmp(arg[iarg],"epair") == 0) evalue = EPAIR;
else if (strcmp(arg[iarg],"evdwl") == 0) evalue = EVDWL;
else if (strcmp(arg[iarg],"ecoul") == 0) evalue = ECOUL;
else error->all(FLERR, "Illegal compute pair command");
++iarg;
}
// check if pair style with and without suffix exists // check if pair style with and without suffix exists
pair = force->pair_match(pstyle,1); pair = force->pair_match(pstyle,1,nsub);
if (!pair && lmp->suffix) { if (!pair && lmp->suffix) {
strcat(pstyle,"/"); strcat(pstyle,"/");
strcat(pstyle,lmp->suffix); strcat(pstyle,lmp->suffix);
pair = force->pair_match(pstyle,1); pair = force->pair_match(pstyle,1,nsub);
} }
if (!pair) if (!pair)
...@@ -84,7 +100,7 @@ void ComputePair::init() ...@@ -84,7 +100,7 @@ void ComputePair::init()
{ {
// recheck for pair style in case it has been deleted // recheck for pair style in case it has been deleted
pair = force->pair_match(pstyle,1); pair = force->pair_match(pstyle,1,nsub);
if (!pair) if (!pair)
error->all(FLERR,"Unrecognized pair style in compute pair command"); error->all(FLERR,"Unrecognized pair style in compute pair command");
} }
......
...@@ -33,7 +33,7 @@ class ComputePair : public Compute { ...@@ -33,7 +33,7 @@ class ComputePair : public Compute {
void compute_vector(); void compute_vector();
private: private:
int evalue,npair; int evalue,npair,nsub;
char *pstyle; char *pstyle;
class Pair *pair; class Pair *pair;
double *one; double *one;
......
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