/* ---------------------------------------------------------------------- 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_overdamp.h" #include "atom.h" #include "force.h" #include "update.h" #include "respa.h" #include "error.h" #include "math_extra.h" #include "domain.h" using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ FixOverdamp::FixOverdamp(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { if (narg != 3) error->all("Illegal fix nve command"); } /* ---------------------------------------------------------------------- */ int FixOverdamp::setmask() { int mask = 0; mask |= INITIAL_INTEGRATE; mask |= FINAL_INTEGRATE; mask |= INITIAL_INTEGRATE_RESPA; mask |= FINAL_INTEGRATE_RESPA; return mask; } /* ---------------------------------------------------------------------- */ void FixOverdamp::init() { dtv = update->dt; dtf = 0.5 * update->dt * force->ftm2v; dtq = 0.5 * update->dt; } /* ---------------------------------------------------------------------- allow for both per-type and per-atom mass ------------------------------------------------------------------------- */ void FixOverdamp::initial_integrate() { } /* ---------------------------------------------------------------------- */ void FixOverdamp::final_integrate() { double dtfm; // update vthermal of only atoms in NVT group // lamda = 0-1 triclinic lamda coords // vstream = streaming velocity = Hrate*lamda + Hratelo // vthermal = thermal velocity = v - vstream // vdelu = Hrate*Hinv*vthermal double **x = atom->x; double **v = atom->v; double **f = atom->f; double *mass = atom->mass; int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; double *h_rate = domain->h_rate; double *h_ratelo = domain->h_ratelo; double h_two[6],lamda[3],vstream[3],vthermal[3],vdelu[3]; MathExtra::multiply_shape_shape(h_rate,domain->h_inv,h_two); for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { domain->x2lamda(x[i],lamda); vstream[0] = h_rate[0]*lamda[0] + h_rate[5]*lamda[1] + h_rate[4]*lamda[2] + h_ratelo[0]; vstream[1] = h_rate[1]*lamda[1] + h_rate[3]*lamda[2] + h_ratelo[1]; vstream[2] = h_rate[2]*lamda[2] + h_ratelo[2]; v[i][0] = vstream[0] + f[i][0]; v[i][1] = vstream[1] + f[i][1]; v[i][2] = vstream[2] + f[i][2]; x[i][0] += dtv*v[i][0]; x[i][1] += dtv*v[i][1]; x[i][2] += dtv*v[i][2]; } } } /* ---------------------------------------------------------------------- */ void FixOverdamp::reset_dt() { dtv = update->dt; dtf = 0.5 * update->dt * force->ftm2v; dtq = 0.5 * update->dt; }