#include "fix_meso_stationary.h"
#include "atom.h"
#include "force.h"
#include "update.h"
#include "error.h"
using namespace LAMMPS_NS;
using namespace FixConst;
FixMesoStationary::FixMesoStationary(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg) {
if ((atom->e_flag != 1) || (atom->rho_flag != 1))
error->all(FLERR,
"fix meso/stationary command requires atom_style with both energy and density, e.g. meso");
if (narg != 3)
error->all(FLERR,"Illegal number of arguments for fix meso/stationary command");
time_integrate = 0;
}
int FixMesoStationary::setmask() {
int mask = 0;
mask |= INITIAL_INTEGRATE;
mask |= FINAL_INTEGRATE;
return mask;
}
void FixMesoStationary::init() {
dtv = update->dt;
dtf = 0.5 * update->dt * force->ftm2v;
}
void FixMesoStationary::initial_integrate(int ) {
double *rho = atom->rho;
double *drho = atom->drho;
double *e = atom->e;
double *de = atom->de;
int *mask = atom->mask;
int nlocal = atom->nlocal;
int i;
if (igroup == atom->firstgroup)
nlocal = atom->nfirst;
for (i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
e[i] += dtf * de[i]; rho[i] += dtf * drho[i]; }
}
}
void FixMesoStationary::final_integrate() {
double *e = atom->e;
double *de = atom->de;
double *rho = atom->rho;
double *drho = atom->drho;
int *mask = atom->mask;
int nlocal = atom->nlocal;
if (igroup == atom->firstgroup)
nlocal = atom->nfirst;
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
e[i] += dtf * de[i];
rho[i] += dtf * drho[i];
}
}
}
void FixMesoStationary::reset_dt() {
dtv = update->dt;
dtf = 0.5 * update->dt * force->ftm2v;
}