diff --git a/src/compute_gyration.cpp b/src/compute_gyration.cpp new file mode 100644 index 0000000000..de2ebf8f1b --- /dev/null +++ b/src/compute_gyration.cpp @@ -0,0 +1,49 @@ +/* ---------------------------------------------------------------------- + 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 "compute_gyration.h" +#include "update.h" +#include "group.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +ComputeGyration::ComputeGyration(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg) +{ + if (narg != 3) error->all("Illegal compute gyration command"); + + scalar_flag = 1; + extscalar = 0; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeGyration::init() +{ + masstotal = group->mass(igroup); +} + +/* ---------------------------------------------------------------------- */ + +double ComputeGyration::compute_scalar() +{ + invoked_scalar = update->ntimestep; + + double xcm[3]; + group->xcm(igroup,masstotal,xcm); + scalar = group->gyration(igroup,masstotal,xcm); + return scalar; +} diff --git a/src/compute_gyration.h b/src/compute_gyration.h new file mode 100644 index 0000000000..899b42b4a3 --- /dev/null +++ b/src/compute_gyration.h @@ -0,0 +1,34 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#ifndef COMPUTE_GYRATION_H +#define COMPUTE_GYRATION_H + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputeGyration : public Compute { + public: + ComputeGyration(class LAMMPS *, int, char **); + ~ComputeGyration() {} + void init(); + double compute_scalar(); + + private: + double masstotal; +}; + +} + +#endif diff --git a/src/style.h b/src/style.h index e869920a85..d6dd6003aa 100644 --- a/src/style.h +++ b/src/style.h @@ -82,6 +82,7 @@ CommandStyle(write_restart,WriteRestart) #include "compute_coord_atom.h" #include "compute_displace_atom.h" #include "compute_group_group.h" +#include "compute_gyration.h" #include "compute_heat_flux.h" #include "compute_ke.h" #include "compute_ke_atom.h" @@ -110,6 +111,7 @@ ComputeStyle(com,ComputeCOM) ComputeStyle(coord/atom,ComputeCoordAtom) ComputeStyle(displace/atom,ComputeDisplaceAtom) ComputeStyle(group/group,ComputeGroupGroup) +ComputeStyle(gyration,ComputeGyration) ComputeStyle(heat/flux,ComputeHeatFlux) ComputeStyle(ke,ComputeKE) ComputeStyle(ke/atom,ComputeKEAtom)