From 4900c3d0c07b5f3287c223acf3d540b803572ad2 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Mon, 21 Dec 2009 21:21:22 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@3598 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/XTC/dump_xtc.cpp | 10 +++++----- src/compute_com_molecule.cpp | 2 +- src/compute_gyration_molecule.cpp | 2 +- src/compute_msd.cpp | 27 ++++++++------------------- src/compute_msd_molecule.cpp | 2 +- src/compute_property_atom.cpp | 2 +- src/compute_property_local.cpp | 2 +- src/dump_atom.cpp | 22 +++++++++++----------- src/dump_cfg.cpp | 8 ++++---- src/dump_custom.cpp | 14 +++++++------- src/dump_dcd.cpp | 10 +++++----- src/dump_local.cpp | 6 +++--- src/dump_xyz.cpp | 14 +++++++------- src/style.h | 2 ++ 14 files changed, 57 insertions(+), 66 deletions(-) diff --git a/src/XTC/dump_xtc.cpp b/src/XTC/dump_xtc.cpp index 54e987fd53..b0269e6945 100644 --- a/src/XTC/dump_xtc.cpp +++ b/src/XTC/dump_xtc.cpp @@ -229,18 +229,18 @@ int DumpXTC::pack() /* ---------------------------------------------------------------------- */ -void DumpXTC::write_data(int n, double *buf) +void DumpXTC::write_data(int n, double *mybuf) { float *xyz; int j,tag; int m = 0; for (int i = 0; i < n; i++) { - tag = static_cast (buf[m]) - 1; + tag = static_cast (mybuf[m]) - 1; j = 3*tag; - coords[j++] = buf[m+1]; - coords[j++] = buf[m+2]; - coords[j] = buf[m+3]; + coords[j++] = mybuf[m+1]; + coords[j++] = mybuf[m+2]; + coords[j] = mybuf[m+3]; m += size_one; } diff --git a/src/compute_com_molecule.cpp b/src/compute_com_molecule.cpp index cf22a1cd95..3323692469 100644 --- a/src/compute_com_molecule.cpp +++ b/src/compute_com_molecule.cpp @@ -150,7 +150,7 @@ void ComputeCOMMolecule::compute_array() double ComputeCOMMolecule::memory_usage() { double bytes = 2*nmolecules * sizeof(double); - if (molmap) bytes += nmolecules * sizeof(int); + if (molmap) bytes += (idhi-idlo+1) * sizeof(int); bytes += 2*nmolecules*3 * sizeof(double); return bytes; } diff --git a/src/compute_gyration_molecule.cpp b/src/compute_gyration_molecule.cpp index 8bf135aac4..e5dfee9966 100644 --- a/src/compute_gyration_molecule.cpp +++ b/src/compute_gyration_molecule.cpp @@ -180,7 +180,7 @@ void ComputeGyrationMolecule::compute_vector() double ComputeGyrationMolecule::memory_usage() { double bytes = 4*nmolecules * sizeof(double); - if (molmap) bytes += nmolecules * sizeof(int); + if (molmap) bytes += (idhi-idlo+1) * sizeof(int); bytes += 2*nmolecules*3 * sizeof(double); return bytes; } diff --git a/src/compute_msd.cpp b/src/compute_msd.cpp index 22b04cbc4d..f3bab0445b 100644 --- a/src/compute_msd.cpp +++ b/src/compute_msd.cpp @@ -118,6 +118,7 @@ void ComputeMSD::compute_vector() double cm[3]; if (comflag) group->xcm(igroup,masstotal,cm); + else cm[0] = cm[1] = cm[2] = 0.0; // dx,dy,dz = displacement of atom from original position // original unwrapped position is stored by fix @@ -148,15 +149,9 @@ void ComputeMSD::compute_vector() xbox = (image[i] & 1023) - 512; ybox = (image[i] >> 10 & 1023) - 512; zbox = (image[i] >> 20) - 512; - if (comflag) { - dx = x[i][0] + xbox*xprd - cm[0] - xoriginal[i][0]; - dy = x[i][1] + ybox*yprd - cm[1] - xoriginal[i][1]; - dz = x[i][2] + zbox*zprd - cm[2] - xoriginal[i][2]; - } else { - dx = x[i][0] + xbox*xprd - xoriginal[i][0]; - dy = x[i][1] + ybox*yprd - xoriginal[i][1]; - dz = x[i][2] + zbox*zprd - xoriginal[i][2]; - } + dx = x[i][0] + xbox*xprd - cm[0] - xoriginal[i][0]; + dy = x[i][1] + ybox*yprd - cm[1] - xoriginal[i][1]; + dz = x[i][2] + zbox*zprd - cm[2] - xoriginal[i][2]; msd[0] += dx*dx; msd[1] += dy*dy; msd[2] += dz*dz; @@ -169,16 +164,10 @@ void ComputeMSD::compute_vector() xbox = (image[i] & 1023) - 512; ybox = (image[i] >> 10 & 1023) - 512; zbox = (image[i] >> 20) - 512; - if (comflag) { - dx = x[i][0] + h[0]*xbox + h[5]*ybox + h[4]*zbox - - cm[0] - xoriginal[i][0]; - dy = x[i][1] + h[1]*ybox + h[3]*zbox - cm[1] - xoriginal[i][1]; - dz = x[i][2] + h[2]*zbox - cm[2] - xoriginal[i][2]; - } else { - dx = x[i][0] + h[0]*xbox + h[5]*ybox + h[4]*zbox - xoriginal[i][0]; - dy = x[i][1] + h[1]*ybox + h[3]*zbox - xoriginal[i][1]; - dz = x[i][2] + h[2]*zbox - xoriginal[i][2]; - } + dx = x[i][0] + h[0]*xbox + h[5]*ybox + h[4]*zbox - + cm[0] - xoriginal[i][0]; + dy = x[i][1] + h[1]*ybox + h[3]*zbox - cm[1] - xoriginal[i][1]; + dz = x[i][2] + h[2]*zbox - cm[2] - xoriginal[i][2]; msd[0] += dx*dx; msd[1] += dy*dy; msd[2] += dz*dz; diff --git a/src/compute_msd_molecule.cpp b/src/compute_msd_molecule.cpp index b80cd0a0c6..ca9f099ff1 100644 --- a/src/compute_msd_molecule.cpp +++ b/src/compute_msd_molecule.cpp @@ -183,7 +183,7 @@ void ComputeMSDMolecule::compute_array() double ComputeMSDMolecule::memory_usage() { double bytes = 2*nmolecules * sizeof(double); - if (molmap) bytes += nmolecules * sizeof(int); + if (molmap) bytes += (idhi-idlo+1) * sizeof(int); bytes += 2*nmolecules*3 * sizeof(double); bytes += nmolecules*4 * sizeof(double); return bytes; diff --git a/src/compute_property_atom.cpp b/src/compute_property_atom.cpp index 5c42103a46..a8d44fd3a6 100644 --- a/src/compute_property_atom.cpp +++ b/src/compute_property_atom.cpp @@ -249,7 +249,7 @@ void ComputePropertyAtom::compute_peratom() buf = vector; (this->*pack_choice[0])(0); } else { - if (array) buf = array[0]; + if (array) buf = &array[0][0]; for (int n = 0; n < nvalues; n++) (this->*pack_choice[n])(n); } diff --git a/src/compute_property_local.cpp b/src/compute_property_local.cpp index 7b99a2b44e..191f849104 100644 --- a/src/compute_property_local.cpp +++ b/src/compute_property_local.cpp @@ -216,7 +216,7 @@ void ComputePropertyLocal::compute_local() buf = vector; (this->*pack_choice[0])(0); } else { - if (array) buf = array[0]; + if (array) buf = &array[0][0]; for (int n = 0; n < nvalues; n++) (this->*pack_choice[n])(n); } diff --git a/src/dump_atom.cpp b/src/dump_atom.cpp index 8635546ef3..85a1701ccb 100644 --- a/src/dump_atom.cpp +++ b/src/dump_atom.cpp @@ -153,9 +153,9 @@ int DumpAtom::pack() /* ---------------------------------------------------------------------- */ -void DumpAtom::write_data(int n, double *buf) +void DumpAtom::write_data(int n, double *mybuf) { - (this->*write_choice)(n,buf); + (this->*write_choice)(n,mybuf); } /* ---------------------------------------------------------------------- */ @@ -397,36 +397,36 @@ int DumpAtom::pack_noscale_noimage() /* ---------------------------------------------------------------------- */ -void DumpAtom::write_binary(int n, double *buf) +void DumpAtom::write_binary(int n, double *mybuf) { n *= size_one; fwrite(&n,sizeof(int),1,fp); - fwrite(buf,sizeof(double),n,fp); + fwrite(mybuf,sizeof(double),n,fp); } /* ---------------------------------------------------------------------- */ -void DumpAtom::write_image(int n, double *buf) +void DumpAtom::write_image(int n, double *mybuf) { int m = 0; for (int i = 0; i < n; i++) { fprintf(fp,format, - static_cast (buf[m]), static_cast (buf[m+1]), - buf[m+2],buf[m+3],buf[m+4], static_cast (buf[m+5]), - static_cast (buf[m+6]), static_cast (buf[m+7])); + static_cast (mybuf[m]), static_cast (mybuf[m+1]), + mybuf[m+2],mybuf[m+3],mybuf[m+4], static_cast (mybuf[m+5]), + static_cast (mybuf[m+6]), static_cast (mybuf[m+7])); m += size_one; } } /* ---------------------------------------------------------------------- */ -void DumpAtom::write_noimage(int n, double *buf) +void DumpAtom::write_noimage(int n, double *mybuf) { int m = 0; for (int i = 0; i < n; i++) { fprintf(fp,format, - static_cast (buf[m]), static_cast (buf[m+1]), - buf[m+2],buf[m+3],buf[m+4]); + static_cast (mybuf[m]), static_cast (mybuf[m+1]), + mybuf[m+2],mybuf[m+3],mybuf[m+4]); m += size_one; } } diff --git a/src/dump_cfg.cpp b/src/dump_cfg.cpp index 881068f409..ac17fc3d56 100755 --- a/src/dump_cfg.cpp +++ b/src/dump_cfg.cpp @@ -229,7 +229,7 @@ void DumpCFG::write_header(int n) write head of block (mass & element name) only if has atoms of the type ------------------------------------------------------------------------- */ -void DumpCFG::write_data(int n, double *buf) +void DumpCFG::write_data(int n, double *mybuf) { int i,j,m,itype; int tag_i,index; @@ -241,7 +241,7 @@ void DumpCFG::write_data(int n, double *buf) if (sort_flag == 0) { for (i = 0, m = 0; i < n; i++) { for (j = 0; j < size_one; j++) - rbuf[nlines][j] = buf[m++]; + rbuf[nlines][j] = mybuf[m++]; nlines++; } @@ -282,7 +282,7 @@ void DumpCFG::write_data(int n, double *buf) // to this index for (i = 0, m = 0; i < n; i++) { - tag_i = static_cast(buf[m]); + tag_i = static_cast(mybuf[m]); for (j = 0; j < nchosen; j++) { if (tag_i == tags[j]) { index = j; @@ -290,7 +290,7 @@ void DumpCFG::write_data(int n, double *buf) } } for (j = 0; j < size_one; j++) - rbuf[index][j] = buf[m++]; + rbuf[index][j] = mybuf[m++]; } // write data lines in rbuf to file after transfer is done diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index ff1fa108eb..c95bbfc195 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -751,31 +751,31 @@ int DumpCustom::pack() /* ---------------------------------------------------------------------- */ -void DumpCustom::write_data(int n, double *buf) +void DumpCustom::write_data(int n, double *mybuf) { - (this->*write_choice)(n,buf); + (this->*write_choice)(n,mybuf); } /* ---------------------------------------------------------------------- */ -void DumpCustom::write_binary(int n, double *buf) +void DumpCustom::write_binary(int n, double *mybuf) { n *= size_one; fwrite(&n,sizeof(int),1,fp); - fwrite(buf,sizeof(double),n,fp); + fwrite(mybuf,sizeof(double),n,fp); } /* ---------------------------------------------------------------------- */ -void DumpCustom::write_text(int n, double *buf) +void DumpCustom::write_text(int n, double *mybuf) { int i,j; int m = 0; for (i = 0; i < n; i++) { for (j = 0; j < size_one; j++) { - if (vtype[j] == INT) fprintf(fp,vformat[j],static_cast (buf[m])); - else fprintf(fp,vformat[j],buf[m]); + if (vtype[j] == INT) fprintf(fp,vformat[j],static_cast (mybuf[m])); + else fprintf(fp,vformat[j],mybuf[m]); m++; } fprintf(fp,"\n"); diff --git a/src/dump_dcd.cpp b/src/dump_dcd.cpp index cdd2a82c31..e0fa74e219 100644 --- a/src/dump_dcd.cpp +++ b/src/dump_dcd.cpp @@ -233,17 +233,17 @@ int DumpDCD::pack() /* ---------------------------------------------------------------------- */ -void DumpDCD::write_data(int n, double *buf) +void DumpDCD::write_data(int n, double *mybuf) { // spread buf atom coords into global arrays int tag; int m = 0; for (int i = 0; i < n; i++) { - tag = static_cast (buf[m]) - 1; - xf[tag] = buf[m+1]; - yf[tag] = buf[m+2]; - zf[tag] = buf[m+3]; + tag = static_cast (mybuf[m]) - 1; + xf[tag] = mybuf[m+1]; + yf[tag] = mybuf[m+2]; + zf[tag] = mybuf[m+3]; m += size_one; } diff --git a/src/dump_local.cpp b/src/dump_local.cpp index 4e4c94e7ef..bda5c599af 100644 --- a/src/dump_local.cpp +++ b/src/dump_local.cpp @@ -245,15 +245,15 @@ int DumpLocal::pack() /* ---------------------------------------------------------------------- */ -void DumpLocal::write_data(int n, double *buf) +void DumpLocal::write_data(int n, double *mybuf) { int i,j; int m = 0; for (i = 0; i < n; i++) { for (j = 0; j < size_one; j++) { - if (vtype[j] == INT) fprintf(fp,vformat[j],static_cast (buf[m])); - else fprintf(fp,vformat[j],buf[m]); + if (vtype[j] == INT) fprintf(fp,vformat[j],static_cast (mybuf[m])); + else fprintf(fp,vformat[j],mybuf[m]); m++; } fprintf(fp,"\n"); diff --git a/src/dump_xyz.cpp b/src/dump_xyz.cpp index 5aaca3c396..c91061a008 100644 --- a/src/dump_xyz.cpp +++ b/src/dump_xyz.cpp @@ -155,7 +155,7 @@ int DumpXYZ::pack() /* ---------------------------------------------------------------------- */ -void DumpXYZ::write_data(int n, double *buf) +void DumpXYZ::write_data(int n, double *mybuf) { // for group = all, spread buf atom coords into global arrays // if last chunk of atoms in this snapshot, write global arrays to file @@ -165,12 +165,12 @@ void DumpXYZ::write_data(int n, double *buf) int m = 0; for (int i = 0; i < n; i++) { - tag = static_cast (buf[m]) - 1; - types[tag] = static_cast (buf[m+1]); + tag = static_cast (mybuf[m]) - 1; + types[tag] = static_cast (mybuf[m+1]); j = 3*tag; - coords[j++] = buf[m+2]; - coords[j++] = buf[m+3]; - coords[j] = buf[m+4]; + coords[j++] = mybuf[m+2]; + coords[j++] = mybuf[m+3]; + coords[j] = mybuf[m+4]; m += size_one; } @@ -186,7 +186,7 @@ void DumpXYZ::write_data(int n, double *buf) int m = 0; for (int i = 0; i < n; i++) { fprintf(fp,format, - static_cast (buf[m+1]),buf[m+2],buf[m+3],buf[m+4]); + static_cast (mybuf[m+1]),mybuf[m+2],mybuf[m+3],mybuf[m+4]); m += size_one; } } diff --git a/src/style.h b/src/style.h index 5c4e7f7e27..397c56ebcd 100644 --- a/src/style.h +++ b/src/style.h @@ -103,6 +103,7 @@ CommandStyle(write_restart,WriteRestart) #include "compute_erotate_sphere.h" #include "compute_property_atom.h" #include "compute_property_local.h" +#include "compute_property_molecule.h" #include "compute_stress_atom.h" #include "compute_temp.h" #include "compute_temp_com.h" @@ -142,6 +143,7 @@ ComputeStyle(reduce/region,ComputeReduceRegion) ComputeStyle(erotate/sphere,ComputeERotateSphere) ComputeStyle(property/atom,ComputePropertyAtom) ComputeStyle(property/local,ComputePropertyLocal) +ComputeStyle(property/molecule,ComputePropertyMolecule) ComputeStyle(stress/atom,ComputeStressAtom) ComputeStyle(temp,ComputeTemp) ComputeStyle(temp/com,ComputeTempCOM)