From 5028d01a487d33a4ce4198ffad2b21ff36d7bb81 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Thu, 22 Mar 2007 17:06:11 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@432 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/fix_nve_noforce.cpp | 79 +++++++++++++++++++++++++++++++++++++++++ src/fix_nve_noforce.h | 36 +++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 src/fix_nve_noforce.cpp create mode 100644 src/fix_nve_noforce.h diff --git a/src/fix_nve_noforce.cpp b/src/fix_nve_noforce.cpp new file mode 100644 index 0000000000..7e0f55b69e --- /dev/null +++ b/src/fix_nve_noforce.cpp @@ -0,0 +1,79 @@ +/* ---------------------------------------------------------------------- + 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 "stdio.h" +#include "string.h" +#include "fix_nve_noforce.h" +#include "atom.h" +#include "update.h" +#include "respa.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +FixNVENoforce::FixNVENoforce(LAMMPS *lmp, int narg, char **arg) : + Fix(lmp, narg, arg) +{ + if (narg != 3) error->all("Illegal fix nve/noforce command"); +} + +/* ---------------------------------------------------------------------- */ + +int FixNVENoforce::setmask() +{ + int mask = 0; + mask |= INITIAL_INTEGRATE; + mask |= INITIAL_INTEGRATE_RESPA; + return mask; +} + +/* ---------------------------------------------------------------------- */ + +void FixNVENoforce::init() +{ + dtv = update->dt; + + if (strcmp(update->integrate_style,"respa") == 0) + step_respa = ((Respa *) update->integrate)->step; +} + +/* ---------------------------------------------------------------------- */ + +void FixNVENoforce::initial_integrate() +{ + double **x = atom->x; + double **v = atom->v; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + x[i][0] += dtv * v[i][0]; + x[i][1] += dtv * v[i][1]; + x[i][2] += dtv * v[i][2]; + } + } +} + +/* ---------------------------------------------------------------------- */ + +void FixNVENoforce::initial_integrate_respa(int ilevel, int flag) +{ + if (flag) return; // only used by NPT,NPH + + dtv = step_respa[ilevel]; + + if (ilevel == 0) initial_integrate(); +} diff --git a/src/fix_nve_noforce.h b/src/fix_nve_noforce.h new file mode 100644 index 0000000000..b24554d5de --- /dev/null +++ b/src/fix_nve_noforce.h @@ -0,0 +1,36 @@ +/* ---------------------------------------------------------------------- + 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 FIX_NVE_NOFORCE_H +#define FIX_NVE_NOFORCE_H + +#include "fix.h" + +namespace LAMMPS_NS { + +class FixNVENoforce : public Fix { + public: + FixNVENoforce(class LAMMPS *, int, char **); + int setmask(); + void init(); + void initial_integrate(); + void initial_integrate_respa(int, int); + + private: + double dtv; + double *step_respa; +}; + +} + +#endif