[lammps-users] Bug reports about the patch of 28 Apr 2009 version - region-based command, variable id equal vcm(group, dim, region)

Hi,

I’ve been using LAMMPS for one years. It is obviously a good package for MD simulation.

As I updated lammps with the patch of 28 Apr 2009 version, when I specified the following lines in the input file as follows

region r1 cylinder z 30.0 30.0 1.0 INF INF units box
variable vt1 equal vcm(oxygen,z,r1)

and, in order to get the details during running I inserted three lines in the variable.cpp file,

else if (strcmp(word,“vcm”) == 0) {
atom->check_mass();
double vcm[3];
if (narg == 2) {
printf("%s\n",“2”);
double masstotal = group->mass(igroup);
group->vcm(igroup,masstotal,vcm);
} else if (narg == 3) {
printf("%s\n",arg1); // inserted by myself
printf("%s\n",arg2); // inserted by myself
printf("%s\n",arg3); // inserted by myself
int iregion = region_function(arg3);
double masstotal = group->mass(igroup,iregion);
group->vcm(igroup,masstotal,vcm,iregion);
} else error->all(“Invalid group function in variable formula”);

I got the output like this

oxygen
z
z

which is supposed to be

oxygen
z
r1

And the error message in the log file,

ERROR: Invalid region in group function in variable formula

It seems that the ’ variable id equal vcm(group,dim,region) ’
command reads or uses the wrong arg, is it a bug? As this function was just added on 28 Apr 2009.
If so, could anybody tell me how to fix it?
Thank you very much for your help!

Just posted a 6May09 patch for this. Change this
line:
     arg3 = new char[n];
     strcpy(arg3,ptr1+1);
to this:
     arg3 = new char[n];
     strcpy(arg3,ptr2+1);

Thanks,
Steve