git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@2364 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2009-01-09 21:31:31 +00:00
parent d2dd4068b6
commit 25baa261e9
11 changed files with 259 additions and 214 deletions

View File

@ -198,7 +198,8 @@ void PPPM::init()
while (order > 0) { while (order > 0) {
if (iteration && me == 0) if (iteration && me == 0)
error->warning("Reducing PPPM order b/c stencil extends beyond neighbor processor"); error->warning("Reducing PPPM order b/c stencil extends "
"beyond neighbor processor");
iteration++; iteration++;
set_grid(); set_grid();

View File

@ -39,6 +39,7 @@ enum{ID,MOL,TYPE,MASS,X,Y,Z,XS,YS,ZS,XU,YU,ZU,IX,IY,IZ,
COMPUTE,FIX,VARIABLE}; COMPUTE,FIX,VARIABLE};
enum{LT,LE,GT,GE,EQ,NEQ}; enum{LT,LE,GT,GE,EQ,NEQ};
enum{INT,DOUBLE}; enum{INT,DOUBLE};
enum{DUMMY0,INVOKED_SCALAR,INVOKED_VECTOR,DUMMMY3,INVOKED_PERATOM};
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -267,14 +268,13 @@ int DumpCustom::count()
} }
// invoke Computes for per-atom dump quantities // invoke Computes for per-atom dump quantities
// only if not already invoked
if (ncompute) { if (ncompute) {
int ntimestep = update->ntimestep; int ntimestep = update->ntimestep;
for (i = 0; i < ncompute; i++) { for (i = 0; i < ncompute; i++)
if (compute[i]->invoked_peratom != ntimestep) if (!(compute[i]->invoked_flag & INVOKED_PERATOM)) {
compute[i]->compute_peratom(); compute[i]->compute_peratom();
compute[i]->invoked_flag = 1; compute[i]->invoked_flag |= INVOKED_PERATOM;
} }
} }

View File

@ -26,6 +26,7 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
enum{X,V,F,COMPUTE,FIX,VARIABLE}; enum{X,V,F,COMPUTE,FIX,VARIABLE};
enum{DUMMY0,INVOKED_SCALAR,INVOKED_VECTOR,DUMMMY3,INVOKED_PERATOM};
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -309,8 +310,10 @@ void FixAveAtom::end_of_step()
} else if (which[m] == COMPUTE) { } else if (which[m] == COMPUTE) {
Compute *compute = modify->compute[n]; Compute *compute = modify->compute[n];
if (compute->invoked_peratom != ntimestep) compute->compute_peratom(); if (!(compute->invoked_flag & INVOKED_PERATOM)) {
compute->invoked_flag = 1; compute->compute_peratom();
compute->invoked_flag |= INVOKED_PERATOM;
}
if (j == 0) { if (j == 0) {
double *compute_scalar = compute->scalar_atom; double *compute_scalar = compute->scalar_atom;

View File

@ -36,6 +36,7 @@ enum{X,V,F,DENSITY_NUMBER,DENSITY_MASS,COMPUTE,FIX,VARIABLE};
enum{SAMPLE,ALL}; enum{SAMPLE,ALL};
enum{BOX,LATTICE,REDUCED}; enum{BOX,LATTICE,REDUCED};
enum{ONE,RUNNING,WINDOW}; enum{ONE,RUNNING,WINDOW};
enum{DUMMY0,INVOKED_SCALAR,INVOKED_VECTOR,DUMMMY3,INVOKED_PERATOM};
#define BIG 1000000000 #define BIG 1000000000
@ -622,8 +623,10 @@ void FixAveSpatial::end_of_step()
} else if (which[m] == COMPUTE) { } else if (which[m] == COMPUTE) {
Compute *compute = modify->compute[n]; Compute *compute = modify->compute[n];
if (compute->invoked_peratom != ntimestep) compute->compute_peratom(); if (!(compute->invoked_flag & INVOKED_PERATOM)) {
compute->invoked_flag = 1; compute->compute_peratom();
compute->invoked_flag |= INVOKED_PERATOM;
}
double *scalar = compute->scalar_atom; double *scalar = compute->scalar_atom;
double **vector = compute->vector_atom; double **vector = compute->vector_atom;
int jm1 = j - 1; int jm1 = j - 1;

View File

@ -31,6 +31,7 @@ using namespace LAMMPS_NS;
enum{COMPUTE,FIX,VARIABLE}; enum{COMPUTE,FIX,VARIABLE};
enum{ONE,RUNNING,WINDOW}; enum{ONE,RUNNING,WINDOW};
enum{DUMMY0,INVOKED_SCALAR,INVOKED_VECTOR,DUMMMY3,INVOKED_PERATOM};
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -351,13 +352,17 @@ void FixAveTime::end_of_step()
Compute *compute = modify->compute[m]; Compute *compute = modify->compute[m];
if (argindex[i] == 0) { if (argindex[i] == 0) {
if (compute->invoked_scalar == ntimestep) vector[i] += compute->scalar; if (!(compute->invoked_flag & INVOKED_SCALAR)) {
else vector[i] += compute->compute_scalar(); compute->compute_scalar();
compute->invoked_flag = 1; compute->invoked_flag |= INVOKED_SCALAR;
}
vector[i] += compute->compute_scalar();
} else { } else {
if (compute->invoked_vector != ntimestep) compute->compute_vector(); if (!(compute->invoked_flag & INVOKED_VECTOR)) {
compute->compute_vector();
compute->invoked_flag |= INVOKED_VECTOR;
}
vector[i] += compute->vector[argindex[i]-1]; vector[i] += compute->vector[argindex[i]-1];
compute->invoked_flag = 1;
} }
// access fix fields, guaranteed to be ready // access fix fields, guaranteed to be ready

View File

@ -684,21 +684,22 @@ int Modify::find_compute(char *id)
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
loop only over computes that store invocation times clear invoked flag of all computes
clear their invoked flag for this step called everywhere that computes are used, before computes are invoked
called before computes are invoked invoked flag used to avoid re-invoking same compute multiple times
and to flag computes that store invocation times as having been invoked
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Modify::clearstep_compute() void Modify::clearstep_compute()
{ {
for (int icompute = 0; icompute < n_timeflag; icompute++) for (int icompute = 0; icompute < ncompute; icompute++)
compute[list_timeflag[icompute]]->invoked_flag = 0; compute[list_timeflag[icompute]]->invoked_flag = 0;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
loop only over computes that store invocation times loop over computes that store invocation times
if its invoked flag set on this timestep, schedule the next invocation if its invoked flag set on this timestep, schedule next invocation
called after computes are invoked called everywhere that computes are used, after computes are invoked
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Modify::addstep_compute(int newstep) void Modify::addstep_compute(int newstep)
@ -709,8 +710,8 @@ void Modify::addstep_compute(int newstep)
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
loop over all computes loop over computes that store invocation times
schedule the next invocation for those that store invocation times schedule next invocation for all of them
called when not sure what computes will be needed on newstep called when not sure what computes will be needed on newstep
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */

View File

@ -195,7 +195,8 @@ void Run::command(int narg, char **arg)
if (postflag || nleft <= nsteps) finish.end(1); if (postflag || nleft <= nsteps) finish.end(1);
else finish.end(0); else finish.end(0);
// command string may invoke computes so wrap with clear/add // command string may invoke computes via command with variable
// so wrap with clearstep/addstep
if (commandstr) { if (commandstr) {
modify->clearstep_compute(); modify->clearstep_compute();

View File

@ -1,20 +0,0 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef PairInclude
#include "pair_meam.h"
#endif
#ifdef PairClass
PairStyle(meam,PairMEAM)
#endif

View File

@ -1,20 +0,0 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef FixInclude
#include "fix_poems.h"
#endif
#ifdef FixClass
FixStyle(poems,FixPOEMS)
#endif

View File

@ -53,6 +53,7 @@ using namespace LAMMPS_NS;
enum{IGNORE,WARN,ERROR}; // same as write_restart.cpp enum{IGNORE,WARN,ERROR}; // same as write_restart.cpp
enum{ONELINE,MULTILINE}; enum{ONELINE,MULTILINE};
enum{INT,FLOAT}; enum{INT,FLOAT};
enum{DUMMY0,INVOKED_SCALAR,INVOKED_VECTOR,DUMMMY3,INVOKED_PERATOM};
#define MAXLINE 1024 #define MAXLINE 1024
#define DELTA 8 #define DELTA 8
@ -268,15 +269,17 @@ void Thermo::compute(int flag)
// invoke Compute methods needed for thermo keywords // invoke Compute methods needed for thermo keywords
// which = 0 is global scalar, which = 1 is global vector // which = 0 is global scalar, which = 1 is global vector
for (i = 0; i < ncompute; i++) { for (i = 0; i < ncompute; i++)
if (compute_which[i] == 0) { if (compute_which[i] == 0) {
if (computes[i]->invoked_scalar != ntimestep) if (!(computes[i]->invoked_flag & INVOKED_SCALAR)) {
computes[i]->compute_scalar(); computes[i]->compute_scalar();
} else { computes[i]->invoked_flag |= INVOKED_SCALAR;
if (computes[i]->invoked_vector != ntimestep) }
computes[i]->compute_vector(); } else {
if (!(computes[i]->invoked_flag & INVOKED_VECTOR)) {
computes[i]->compute_vector();
computes[i]->invoked_flag |= INVOKED_VECTOR;
} }
computes[i]->invoked_flag = 1;
} }
// if lineflag = MULTILINE, prepend step/cpu header line // if lineflag = MULTILINE, prepend step/cpu header line
@ -826,13 +829,12 @@ void Thermo::create_compute(char *id, char *cstyle, char *extra)
int Thermo::evaluate_keyword(char *word, double *answer) int Thermo::evaluate_keyword(char *word, double *answer)
{ {
// invoke a lo-level thermo routine to compute the variable value // invoke a lo-level thermo routine to compute the variable value
// if keyword requires a compute, is error if thermo doesn't use the compute // if keyword requires a compute, error if thermo doesn't use the compute
// if in middle of run and needed compute is not current, invoke it
// if inbetween runs and needed compute is not current, error // if inbetween runs and needed compute is not current, error
// set invoked flag for pe and pressure for keywords that use them // if in middle of run and needed compute is not current, invoke it
// this insures tallying on future needed steps via clearstep/addstep
// for keywords that use pe indirectly (evdwl, ebond, etc): // for keywords that use pe indirectly (evdwl, ebond, etc):
// check if energy was tallied on this timestep and set pe->invoked_flag // check if energy was tallied on this timestep and set pe->invoked_flag
// this will trigger next timestep for energy tallying via addstep()
if (strcmp(word,"step") == 0) { if (strcmp(word,"step") == 0) {
compute_step(); compute_step();
@ -848,168 +850,196 @@ int Thermo::evaluate_keyword(char *word, double *answer)
} else if (strcmp(word,"temp") == 0) { } else if (strcmp(word,"temp") == 0) {
if (!temperature) if (!temperature)
error->all("Thermo keyword in variable requires thermo to use/init temp"); error->all("Thermo keyword in variable requires "
if (temperature->invoked_scalar != update->ntimestep) { "thermo to use/init temp");
if (update->whichflag < 0) if (update->whichflag < 0) {
error->all("Compute used in variable thermo keyword is not current"); if (temperature->invoked_scalar != update->ntimestep)
else temperature->compute_scalar(); error->all("Compute used in variable thermo keyword between runs "
"is not current");
} else if (!(temperature->invoked_flag & INVOKED_SCALAR)) {
temperature->compute_scalar();
temperature->invoked_flag |= INVOKED_SCALAR;
} }
compute_temp(); compute_temp();
} else if (strcmp(word,"press") == 0) { } else if (strcmp(word,"press") == 0) {
if (!pressure) if (!pressure)
error->all("Thermo keyword in variable requires thermo to use/init press"); error->all("Thermo keyword in variable requires "
if (pressure->invoked_scalar != update->ntimestep) { "thermo to use/init press");
if (update->whichflag < 0) if (update->whichflag < 0) {
error->all("Compute used in variable thermo keyword is not current"); if (pressure->invoked_scalar != update->ntimestep)
else pressure->compute_scalar(); error->all("Compute used in variable thermo keyword between runs "
"is not current");
} else if (!(pressure->invoked_flag & INVOKED_SCALAR)) {
pressure->compute_scalar();
pressure->invoked_flag |= INVOKED_SCALAR;
} }
pressure->invoked_flag = 1;
compute_press(); compute_press();
} else if (strcmp(word,"pe") == 0) { } else if (strcmp(word,"pe") == 0) {
if (!pe) if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe"); error->all("Thermo keyword in variable requires thermo to use/init pe");
if (pe->invoked_scalar != update->ntimestep) { if (update->whichflag < 0) {
if (update->whichflag < 0) if (pe->invoked_scalar != update->ntimestep)
error->all("Compute used in variable thermo keyword is not current"); error->all("Compute used in variable thermo keyword between runs "
else pe->compute_scalar(); "is not current");
} else if (!(pe->invoked_flag & INVOKED_SCALAR)) {
pe->compute_scalar();
pe->invoked_flag |= INVOKED_SCALAR;
} }
pe->invoked_flag = 1;
compute_pe(); compute_pe();
} else if (strcmp(word,"ke") == 0) { } else if (strcmp(word,"ke") == 0) {
if (!temperature) if (!temperature)
error->all("Thermo keyword in variable requires thermo to use/init temp"); error->all("Thermo keyword in variable requires "
if (temperature->invoked_scalar != update->ntimestep) { "thermo to use/init temp");
if (update->whichflag < 0) if (update->whichflag < 0) {
error->all("Compute used in variable thermo keyword is not current"); if (temperature->invoked_scalar != update->ntimestep)
else temperature->compute_scalar(); error->all("Compute used in variable thermo keyword between runs "
"is not current");
} else if (!(temperature->invoked_flag & INVOKED_SCALAR)) {
temperature->compute_scalar();
temperature->invoked_flag |= INVOKED_SCALAR;
} }
compute_ke(); compute_ke();
} else if (strcmp(word,"etotal") == 0) { } else if (strcmp(word,"etotal") == 0) {
if (!pe) if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe"); error->all("Thermo keyword in variable requires thermo to use/init pe");
if (pe->invoked_scalar != update->ntimestep) { if (update->whichflag < 0) {
if (update->whichflag < 0) if (pe->invoked_scalar != update->ntimestep)
error->all("Compute used in variable thermo keyword is not current"); error->all("Compute used in variable thermo keyword between runs "
else pe->compute_scalar(); "is not current");
} else if (!(pe->invoked_flag & INVOKED_SCALAR)) {
pe->compute_scalar();
pe->invoked_flag |= INVOKED_SCALAR;
} }
if (!temperature) if (!temperature)
error->all("Thermo keyword in variable requires thermo to use/init temp"); error->all("Thermo keyword in variable requires "
if (temperature->invoked_scalar != update->ntimestep) { "thermo to use/init temp");
if (update->whichflag < 0) if (update->whichflag < 0) {
error->all("Compute used in variable thermo keyword is not current"); if (temperature->invoked_scalar != update->ntimestep)
else temperature->compute_scalar(); error->all("Compute used in variable thermo keyword between runs "
"is not current");
} else if (!(temperature->invoked_flag & INVOKED_SCALAR)) {
temperature->compute_scalar();
temperature->invoked_flag |= INVOKED_SCALAR;
} }
pe->invoked_flag = 1;
compute_etotal(); compute_etotal();
} else if (strcmp(word,"enthalpy") == 0) { } else if (strcmp(word,"enthalpy") == 0) {
if (!pe) if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe"); error->all("Thermo keyword in variable requires thermo to use/init pe");
if (pe->invoked_scalar != update->ntimestep) { if (update->whichflag < 0) {
if (update->whichflag < 0) if (pe->invoked_scalar != update->ntimestep)
error->all("Compute used in variable thermo keyword is not current"); error->all("Compute used in variable thermo keyword between runs "
else pe->compute_scalar(); "is not current");
} else if (!(pe->invoked_flag & INVOKED_SCALAR)) {
pe->compute_scalar();
pe->invoked_flag |= INVOKED_SCALAR;
} }
if (!temperature) if (!temperature)
error->all("Thermo keyword in variable requires thermo to use/init temp"); error->all("Thermo keyword in variable requires "
if (temperature->invoked_scalar != update->ntimestep) { "thermo to use/init temp");
if (update->whichflag < 0) if (update->whichflag < 0) {
error->all("Compute used in variable thermo keyword is not current"); if (temperature->invoked_scalar != update->ntimestep)
else temperature->compute_scalar(); error->all("Compute used in variable thermo keyword between runs "
"is not current");
} else if (!(temperature->invoked_flag & INVOKED_SCALAR)) {
temperature->compute_scalar();
temperature->invoked_flag |= INVOKED_SCALAR;
} }
if (!pressure) if (!pressure)
error->all("Thermo keyword in variable requires thermo to use/init press"); error->all("Thermo keyword in variable requires "
if (pressure->invoked_scalar != update->ntimestep) { "thermo to use/init press");
if (update->whichflag < 0) if (update->whichflag < 0) {
error->all("Compute used in variable thermo keyword is not current"); if (pressure->invoked_scalar != update->ntimestep)
else pressure->compute_scalar(); error->all("Compute used in variable thermo keyword between runs "
"is not current");
} else if (!(pressure->invoked_flag & INVOKED_SCALAR)) {
pressure->compute_scalar();
pressure->invoked_flag |= INVOKED_SCALAR;
} }
pe->invoked_flag = 1;
pressure->invoked_flag = 1;
compute_enthalpy(); compute_enthalpy();
} else if (strcmp(word,"evdwl") == 0) { } else if (strcmp(word,"evdwl") == 0) {
if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
if (update->eflag_global != update->ntimestep) if (update->eflag_global != update->ntimestep)
error->all("Energy was not tallied on needed timestep"); error->all("Energy was not tallied on needed timestep");
pe->invoked_flag = 1; if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
pe->invoked_flag |= INVOKED_SCALAR;
compute_evdwl(); compute_evdwl();
} else if (strcmp(word,"ecoul") == 0) { } else if (strcmp(word,"ecoul") == 0) {
if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
if (update->eflag_global != update->ntimestep) if (update->eflag_global != update->ntimestep)
error->all("Energy was not tallied on needed timestep"); error->all("Energy was not tallied on needed timestep");
pe->invoked_flag = 1; if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
pe->invoked_flag |= INVOKED_SCALAR;
compute_ecoul(); compute_ecoul();
} else if (strcmp(word,"epair") == 0) { } else if (strcmp(word,"epair") == 0) {
if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
if (update->eflag_global != update->ntimestep) if (update->eflag_global != update->ntimestep)
error->all("Energy was not tallied on needed timestep"); error->all("Energy was not tallied on needed timestep");
pe->invoked_flag = 1; if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
pe->invoked_flag |= INVOKED_SCALAR;
compute_epair(); compute_epair();
} else if (strcmp(word,"ebond") == 0) { } else if (strcmp(word,"ebond") == 0) {
if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
if (update->eflag_global != update->ntimestep) if (update->eflag_global != update->ntimestep)
error->all("Energy was not tallied on needed timestep"); error->all("Energy was not tallied on needed timestep");
pe->invoked_flag = 1; if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
pe->invoked_flag |= INVOKED_SCALAR;
compute_ebond(); compute_ebond();
} else if (strcmp(word,"eangle") == 0) { } else if (strcmp(word,"eangle") == 0) {
if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
if (update->eflag_global != update->ntimestep) if (update->eflag_global != update->ntimestep)
error->all("Energy was not tallied on needed timestep"); error->all("Energy was not tallied on needed timestep");
pe->invoked_flag = 1; if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
pe->invoked_flag |= INVOKED_SCALAR;
compute_eangle(); compute_eangle();
} else if (strcmp(word,"edihed") == 0) { } else if (strcmp(word,"edihed") == 0) {
if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
if (update->eflag_global != update->ntimestep) if (update->eflag_global != update->ntimestep)
error->all("Energy was not tallied on needed timestep"); error->all("Energy was not tallied on needed timestep");
pe->invoked_flag = 1; if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
pe->invoked_flag |= INVOKED_SCALAR;
compute_edihed(); compute_edihed();
} else if (strcmp(word,"eimp") == 0) { } else if (strcmp(word,"eimp") == 0) {
if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
if (update->eflag_global != update->ntimestep) if (update->eflag_global != update->ntimestep)
error->all("Energy was not tallied on needed timestep"); error->all("Energy was not tallied on needed timestep");
pe->invoked_flag = 1; if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
pe->invoked_flag |= INVOKED_SCALAR;
compute_eimp(); compute_eimp();
} else if (strcmp(word,"emol") == 0) { } else if (strcmp(word,"emol") == 0) {
if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
if (update->eflag_global != update->ntimestep) if (update->eflag_global != update->ntimestep)
error->all("Energy was not tallied on needed timestep"); error->all("Energy was not tallied on needed timestep");
pe->invoked_flag = 1; if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
pe->invoked_flag |= INVOKED_SCALAR;
compute_emol(); compute_emol();
} else if (strcmp(word,"elong") == 0) { } else if (strcmp(word,"elong") == 0) {
if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
if (update->eflag_global != update->ntimestep) if (update->eflag_global != update->ntimestep)
error->all("Energy was not tallied on needed timestep"); error->all("Energy was not tallied on needed timestep");
pe->invoked_flag = 1; if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
pe->invoked_flag |= INVOKED_SCALAR;
compute_elong(); compute_elong();
} else if (strcmp(word,"etail") == 0) { } else if (strcmp(word,"etail") == 0) {
if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
if (update->eflag_global != update->ntimestep) if (update->eflag_global != update->ntimestep)
error->all("Energy was not tallied on needed timestep"); error->all("Energy was not tallied on needed timestep");
pe->invoked_flag = 1; if (!pe)
error->all("Thermo keyword in variable requires thermo to use/init pe");
pe->invoked_flag |= INVOKED_SCALAR;
compute_etail(); compute_etail();
} else if (strcmp(word,"vol") == 0) compute_vol(); } else if (strcmp(word,"vol") == 0) compute_vol();
@ -1030,68 +1060,86 @@ int Thermo::evaluate_keyword(char *word, double *answer)
else if (strcmp(word,"pxx") == 0) { else if (strcmp(word,"pxx") == 0) {
if (!pressure) if (!pressure)
error->all("Thermo keyword in variable requires thermo to use/init press"); error->all("Thermo keyword in variable requires "
if (pressure->invoked_vector != update->ntimestep) { "thermo to use/init press");
if (update->whichflag < 0) if (update->whichflag < 0) {
error->all("Compute used in variable thermo keyword is not current"); if (pressure->invoked_vector != update->ntimestep)
else pressure->compute_vector(); error->all("Compute used in variable thermo keyword between runs "
"is not current");
} else if (!(pressure->invoked_flag & INVOKED_VECTOR)) {
pressure->compute_vector();
pressure->invoked_flag |= INVOKED_VECTOR;
} }
pressure->invoked_flag = 1;
compute_pxx(); compute_pxx();
} else if (strcmp(word,"pyy") == 0) { } else if (strcmp(word,"pyy") == 0) {
if (!pressure) if (!pressure)
error->all("Thermo keyword in variable requires thermo to use/init press"); error->all("Thermo keyword in variable requires "
if (pressure->invoked_vector != update->ntimestep) { "thermo to use/init press");
if (update->whichflag < 0) if (update->whichflag < 0) {
error->all("Compute used in variable thermo keyword is not current"); if (pressure->invoked_vector != update->ntimestep)
else pressure->compute_vector(); error->all("Compute used in variable thermo keyword between runs "
"is not current");
} else if (!(pressure->invoked_flag & INVOKED_VECTOR)) {
pressure->compute_vector();
pressure->invoked_flag |= INVOKED_VECTOR;
} }
pressure->invoked_flag = 1;
compute_pyy(); compute_pyy();
} else if (strcmp(word,"pzz") == 0) { } else if (strcmp(word,"pzz") == 0) {
if (!pressure) if (!pressure)
error->all("Thermo keyword in variable requires thermo to use/init press"); error->all("Thermo keyword in variable requires "
if (pressure->invoked_vector != update->ntimestep) { "thermo to use/init press");
if (update->whichflag < 0) if (update->whichflag < 0) {
error->all("Compute used in variable thermo keyword is not current"); if (pressure->invoked_vector != update->ntimestep)
else pressure->compute_vector(); error->all("Compute used in variable thermo keyword between runs "
"is not current");
} else if (!(pressure->invoked_flag & INVOKED_VECTOR)) {
pressure->compute_vector();
pressure->invoked_flag |= INVOKED_VECTOR;
} }
pressure->invoked_flag = 1;
compute_pzz(); compute_pzz();
} else if (strcmp(word,"pxy") == 0) { } else if (strcmp(word,"pxy") == 0) {
if (!pressure) if (!pressure)
error->all("Thermo keyword in variable requires thermo to use/init press"); error->all("Thermo keyword in variable requires "
if (pressure->invoked_vector != update->ntimestep) { "thermo to use/init press");
if (update->whichflag < 0) if (update->whichflag < 0) {
error->all("Compute used in variable thermo keyword is not current"); if (pressure->invoked_vector != update->ntimestep)
else pressure->compute_vector(); error->all("Compute used in variable thermo keyword between runs "
"is not current");
} else if (!(pressure->invoked_flag & INVOKED_VECTOR)) {
pressure->compute_vector();
pressure->invoked_flag |= INVOKED_VECTOR;
} }
pressure->invoked_flag = 1;
compute_pxy(); compute_pxy();
} else if (strcmp(word,"pxz") == 0) { } else if (strcmp(word,"pxz") == 0) {
if (!pressure) if (!pressure)
error->all("Thermo keyword in variable requires thermo to use/init press"); error->all("Thermo keyword in variable requires "
if (pressure->invoked_vector != update->ntimestep) { "thermo to use/init press");
if (update->whichflag < 0) if (update->whichflag < 0) {
error->all("Compute used in variable thermo keyword is not current"); if (pressure->invoked_vector != update->ntimestep)
else pressure->compute_vector(); error->all("Compute used in variable thermo keyword between runs "
"is not current");
} else if (!(pressure->invoked_flag & INVOKED_VECTOR)) {
pressure->compute_vector();
pressure->invoked_flag |= INVOKED_VECTOR;
} }
pressure->invoked_flag = 1;
compute_pxz(); compute_pxz();
} else if (strcmp(word,"pyz") == 0) { } else if (strcmp(word,"pyz") == 0) {
if (!pressure) if (!pressure)
error->all("Thermo keyword in variable requires thermo to use/init press"); error->all("Thermo keyword in variable requires "
if (pressure->invoked_vector != update->ntimestep) { "thermo to use/init press");
if (update->whichflag < 0) if (update->whichflag < 0) {
error->all("Compute used in variable thermo keyword is not current"); if (pressure->invoked_vector != update->ntimestep)
else pressure->compute_vector(); error->all("Compute used in variable thermo keyword between runs "
"is not current");
} else if (!(pressure->invoked_flag & INVOKED_VECTOR)) {
pressure->compute_vector();
pressure->invoked_flag |= INVOKED_VECTOR;
} }
pressure->invoked_flag = 1;
compute_pyz(); compute_pyz();
} else return 1; } else return 1;
@ -1146,8 +1194,7 @@ void Thermo::compute_fix()
void Thermo::compute_variable() void Thermo::compute_variable()
{ {
int index = field2index[ifield]; dvalue = input->variable->compute_equal(variables[field2index[ifield]]);
dvalue = input->variable->compute_equal(variables[index]);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -37,6 +37,7 @@ using namespace LAMMPS_NS;
#define MYROUND(a) (( a-floor(a) ) >= .5) ? ceil(a) : floor(a) #define MYROUND(a) (( a-floor(a) ) >= .5) ? ceil(a) : floor(a)
enum{DUMMY0,INVOKED_SCALAR,INVOKED_VECTOR,DUMMMY3,INVOKED_PERATOM};
enum{INDEX,LOOP,EQUAL,WORLD,UNIVERSE,ULOOP,ATOM}; enum{INDEX,LOOP,EQUAL,WORLD,UNIVERSE,ULOOP,ATOM};
enum{ARG,OP}; enum{ARG,OP};
enum{DONE,ADD,SUBTRACT,MULTIPLY,DIVIDE,CARAT,UNARY, enum{DONE,ADD,SUBTRACT,MULTIPLY,DIVIDE,CARAT,UNARY,
@ -642,7 +643,6 @@ double Variable::evaluate(char *str, Tree **tree)
int icompute = modify->find_compute(id); int icompute = modify->find_compute(id);
if (icompute < 0) error->all("Invalid compute ID in variable formula"); if (icompute < 0) error->all("Invalid compute ID in variable formula");
Compute *compute = modify->compute[icompute]; Compute *compute = modify->compute[icompute];
compute->invoked_flag = 1;
delete [] id; delete [] id;
if (domain->box_exist == 0) if (domain->box_exist == 0)
@ -670,11 +670,15 @@ double Variable::evaluate(char *str, Tree **tree)
if (nbracket == 0 && compute->scalar_flag) { if (nbracket == 0 && compute->scalar_flag) {
if (compute->invoked_scalar != update->ntimestep) { if (update->whichflag < 0) {
if (update->whichflag < 0) if (compute->invoked_scalar != update->ntimestep)
error->all("Compute used in variable is not current"); error->all("Compute used in variable between runs "
else compute->compute_scalar(); "is not current");
} else if (!(compute->invoked_flag & INVOKED_SCALAR)) {
compute->compute_scalar();
compute->invoked_flag |= INVOKED_SCALAR;
} }
value1 = compute->scalar; value1 = compute->scalar;
if (tree) { if (tree) {
Tree *newtree = new Tree(); Tree *newtree = new Tree();
@ -690,11 +694,15 @@ double Variable::evaluate(char *str, Tree **tree)
if (index1 > compute->size_vector) if (index1 > compute->size_vector)
error->all("Compute vector in variable formula is too small"); error->all("Compute vector in variable formula is too small");
if (compute->invoked_vector != update->ntimestep) { if (update->whichflag < 0) {
if (update->whichflag < 0) if (compute->invoked_vector != update->ntimestep)
error->all("Compute used in variable is not current"); error->all("Compute used in variable between runs "
else compute->compute_vector(); "is not current");
} else if (!(compute->invoked_flag & INVOKED_VECTOR)) {
compute->compute_vector();
compute->invoked_flag |= INVOKED_VECTOR;
} }
value1 = compute->vector[index1-1]; value1 = compute->vector[index1-1];
if (tree) { if (tree) {
Tree *newtree = new Tree(); Tree *newtree = new Tree();
@ -711,11 +719,15 @@ double Variable::evaluate(char *str, Tree **tree)
if (tree == NULL) if (tree == NULL)
error->all("Per-atom compute in equal-style variable formula"); error->all("Per-atom compute in equal-style variable formula");
if (compute->invoked_peratom != update->ntimestep) { if (update->whichflag < 0) {
if (update->whichflag < 0) if (compute->invoked_peratom != update->ntimestep)
error->all("Compute used in variable is not current"); error->all("Compute used in variable between runs "
else compute->compute_peratom(); "is not current");
} else if (!(compute->invoked_flag & INVOKED_PERATOM)) {
compute->compute_peratom();
compute->invoked_flag |= INVOKED_PERATOM;
} }
Tree *newtree = new Tree(); Tree *newtree = new Tree();
newtree->type = ATOMARRAY; newtree->type = ATOMARRAY;
newtree->array = compute->scalar_atom; newtree->array = compute->scalar_atom;
@ -728,11 +740,15 @@ double Variable::evaluate(char *str, Tree **tree)
} else if (nbracket == 1 && index1 > 0 && } else if (nbracket == 1 && index1 > 0 &&
compute->peratom_flag && compute->size_peratom == 0) { compute->peratom_flag && compute->size_peratom == 0) {
if (compute->invoked_peratom != update->ntimestep) { if (update->whichflag < 0) {
if (update->whichflag < 0) if (compute->invoked_peratom != update->ntimestep)
error->all("Compute used in variable is not current"); error->all("Compute used in variable between runs "
else compute->compute_peratom(); "is not current");
} else if (!(compute->invoked_flag & INVOKED_PERATOM)) {
compute->compute_peratom();
compute->invoked_flag |= INVOKED_PERATOM;
} }
peratom2global(1,NULL,compute->scalar_atom,1,index1, peratom2global(1,NULL,compute->scalar_atom,1,index1,
tree,treestack,ntreestack,argstack,nargstack); tree,treestack,ntreestack,argstack,nargstack);
@ -745,11 +761,15 @@ double Variable::evaluate(char *str, Tree **tree)
error->all("Per-atom compute in equal-style variable formula"); error->all("Per-atom compute in equal-style variable formula");
if (index2 > compute->size_peratom) if (index2 > compute->size_peratom)
error->all("Compute vector in variable formula is too small"); error->all("Compute vector in variable formula is too small");
if (compute->invoked_peratom != update->ntimestep) { if (update->whichflag < 0) {
if (update->whichflag < 0) if (compute->invoked_peratom != update->ntimestep)
error->all("Compute used in variable is not current"); error->all("Compute used in variable between runs "
else compute->compute_peratom(); "is not current");
} else if (!(compute->invoked_flag & INVOKED_PERATOM)) {
compute->compute_peratom();
compute->invoked_flag |= INVOKED_PERATOM;
} }
Tree *newtree = new Tree(); Tree *newtree = new Tree();
newtree->type = ATOMARRAY; newtree->type = ATOMARRAY;
newtree->array = &compute->vector_atom[0][index2-1]; newtree->array = &compute->vector_atom[0][index2-1];
@ -764,11 +784,15 @@ double Variable::evaluate(char *str, Tree **tree)
if (index2 > compute->size_peratom) if (index2 > compute->size_peratom)
error->all("Compute vector in variable formula is too small"); error->all("Compute vector in variable formula is too small");
if (compute->invoked_peratom != update->ntimestep) { if (update->whichflag < 0) {
if (update->whichflag < 0) if (compute->invoked_peratom != update->ntimestep)
error->all("Compute used in variable is not current"); error->all("Compute used in variable between runs "
else compute->compute_peratom(); "is not current");
} else if (!(compute->invoked_flag & INVOKED_PERATOM)) {
compute->compute_peratom();
compute->invoked_flag |= INVOKED_PERATOM;
} }
peratom2global(1,NULL,&compute->vector_atom[0][index2-1], peratom2global(1,NULL,&compute->vector_atom[0][index2-1],
compute->size_peratom,index1, compute->size_peratom,index1,
tree,treestack,ntreestack,argstack,nargstack); tree,treestack,ntreestack,argstack,nargstack);