From 822d0936b5ad4402708d3b7ffde154cba1701765 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 31 May 2013 16:34:55 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@9998 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/compute_msd.cpp | 1 - src/compute_msd.h | 6 +-- src/compute_msd_nongauss.cpp | 102 +++++++++++++++++++++++++++++++++++ src/compute_msd_nongauss.h | 51 ++++++++++++++++++ 4 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 src/compute_msd_nongauss.cpp create mode 100644 src/compute_msd_nongauss.h diff --git a/src/compute_msd.cpp b/src/compute_msd.cpp index 05fa21e091..15df99d9d9 100644 --- a/src/compute_msd.cpp +++ b/src/compute_msd.cpp @@ -18,7 +18,6 @@ #include "group.h" #include "domain.h" #include "modify.h" -#include "fix.h" #include "fix_store.h" #include "error.h" diff --git a/src/compute_msd.h b/src/compute_msd.h index 54c044a7c2..6889fecd55 100644 --- a/src/compute_msd.h +++ b/src/compute_msd.h @@ -27,11 +27,11 @@ namespace LAMMPS_NS { class ComputeMSD : public Compute { public: ComputeMSD(class LAMMPS *, int, char **); - ~ComputeMSD(); + virtual ~ComputeMSD(); void init(); - void compute_vector(); + virtual void compute_vector(); - private: + protected: int comflag,nmsd; double masstotal; char *id_fix; diff --git a/src/compute_msd_nongauss.cpp b/src/compute_msd_nongauss.cpp new file mode 100644 index 0000000000..64c9b1c002 --- /dev/null +++ b/src/compute_msd_nongauss.cpp @@ -0,0 +1,102 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#include "string.h" +#include "compute_msd_nongauss.h" +#include "atom.h" +#include "update.h" +#include "group.h" +#include "domain.h" +#include "fix_store.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +ComputeMSDNonGauss::ComputeMSDNonGauss(LAMMPS *lmp, int narg, char **arg) : + ComputeMSD(lmp, narg, arg) +{ + size_vector = 3; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeMSDNonGauss::compute_vector() +{ + invoked_vector = update->ntimestep; + + // cm = current center of mass + + 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 + // relative to center of mass if comflag is set + // for triclinic, need to unwrap current atom coord via h matrix + + double **xoriginal = fix->astore; + + double **x = atom->x; + int *mask = atom->mask; + tagint *image = atom->image; + int nlocal = atom->nlocal; + + double *h = domain->h; + double xprd = domain->xprd; + double yprd = domain->yprd; + double zprd = domain->zprd; + + double dx,dy,dz; + int xbox,ybox,zbox; + + double msd[2]; + msd[0] = msd[1] = 0.0; + + if (domain->triclinic == 0) { + for (int i = 0; i < nlocal; i++) + if (mask[i] & groupbit) { + xbox = (image[i] & IMGMASK) - IMGMAX; + ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX; + zbox = (image[i] >> IMG2BITS) - IMGMAX; + 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 + dy*dy + dz*dz; + msd[1] += (dx*dx + dy*dy + dz*dz)*(dx*dx + dy*dy + dz*dz); + } + + } else { + for (int i = 0; i < nlocal; i++) + if (mask[i] & groupbit) { + xbox = (image[i] & IMGMASK) - IMGMAX; + ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX; + zbox = (image[i] >> IMG2BITS) - IMGMAX; + 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 + dy*dy + dz*dz; + msd[1] += (dx*dx + dy*dy + dz*dz)*(dx*dx + dy*dy + dz*dz); + } + } + + MPI_Allreduce(msd,vector,2,MPI_DOUBLE,MPI_SUM,world); + if (nmsd) { + vector[0] /= nmsd; + vector[1] /= nmsd; + vector[2] = (3*vector[1])/(5*vector[0]*vector[0]) - 1; + } +} diff --git a/src/compute_msd_nongauss.h b/src/compute_msd_nongauss.h new file mode 100644 index 0000000000..86bb653c56 --- /dev/null +++ b/src/compute_msd_nongauss.h @@ -0,0 +1,51 @@ +/* ---------------------------------------------------------------------- + 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 COMPUTE_CLASS + +ComputeStyle(msd/nongauss,ComputeMSDNonGauss) + +#else + +#ifndef LMP_COMPUTE_MSD_NONGAUSS_H +#define LMP_COMPUTE_MSD_NONGAUSS_H + +#include "compute_msd.h" + +namespace LAMMPS_NS { + +class ComputeMSDNonGauss : public ComputeMSD { + public: + ComputeMSDNonGauss(class LAMMPS *, int, char **); + ~ComputeMSDNonGauss() {} + void compute_vector(); +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: Could not find compute msd fix ID + +Self-explanatory. + +*/