From 6a4a7506cfb316c8e9e746a0161cf1e4571fc575 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Mon, 2 Jun 2014 16:04:35 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@12056 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/variable.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/variable.cpp b/src/variable.cpp index 9d78631229..78048a8c10 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -3482,7 +3482,7 @@ int Variable::special_function(char *word, char *contents, Tree **tree, id = positive global ID of atom, converted to local index push result onto tree or arg stack customize by adding an atom vector: - id,mass,type,mol,x,y,z,vx,vy,vz,fx,fy,fz + id,mass,type,mol,x,y,z,vx,vy,vz,fx,fy,fz,q ------------------------------------------------------------------------- */ void Variable::peratom2global(int flag, char *word, @@ -3520,7 +3520,11 @@ void Variable::peratom2global(int flag, char *word, else if (strcmp(word,"fx") == 0) mine = atom->f[index][0]; else if (strcmp(word,"fy") == 0) mine = atom->f[index][1]; else if (strcmp(word,"fz") == 0) mine = atom->f[index][2]; - + else if (strcmp(word,"q") == 0) { + if (!atom->q_flag) + error->one(FLERR,"Variable uses atom property that isn't allocated"); + mine = atom->q[index]; + } else error->one(FLERR,"Invalid atom vector in variable formula"); } else mine = vector[index*nstride]; @@ -3543,7 +3547,7 @@ void Variable::peratom2global(int flag, char *word, check if word matches an atom vector return 1 if yes, else 0 customize by adding an atom vector: - id,mass,type,mol,x,y,z,vx,vy,vz,fx,fy,fz + id,mass,type,mol,x,y,z,vx,vy,vz,fx,fy,fz,q ------------------------------------------------------------------------- */ int Variable::is_atom_vector(char *word) @@ -3561,6 +3565,7 @@ int Variable::is_atom_vector(char *word) if (strcmp(word,"fx") == 0) return 1; if (strcmp(word,"fy") == 0) return 1; if (strcmp(word,"fz") == 0) return 1; + if (strcmp(word,"q") == 0) return 1; return 0; } @@ -3569,7 +3574,7 @@ int Variable::is_atom_vector(char *word) push result onto tree word = atom vector customize by adding an atom vector: - id,mass,type,mol,x,y,z,vx,vy,vz,fx,fy,fz + id,mass,type,mol,x,y,z,vx,vy,vz,fx,fy,fz,q ------------------------------------------------------------------------- */ void Variable::atom_vector(char *word, Tree **tree, @@ -3631,6 +3636,11 @@ void Variable::atom_vector(char *word, Tree **tree, else if (strcmp(word,"fx") == 0) newtree->array = &atom->f[0][0]; else if (strcmp(word,"fy") == 0) newtree->array = &atom->f[0][1]; else if (strcmp(word,"fz") == 0) newtree->array = &atom->f[0][2]; + + else if (strcmp(word,"q") == 0) { + newtree->nstride = 1; + newtree->array = atom->q; + } } /* ----------------------------------------------------------------------