#include <cstdlib>
#include "fix_nh_eff.h"
#include "atom.h"
#include "atom_vec.h"
#include "error.h"
#include "domain.h"
using namespace LAMMPS_NS;
using namespace FixConst;
enum{NOBIAS,BIAS};
FixNHEff::FixNHEff(LAMMPS *lmp, int narg, char **arg) : FixNH(lmp, narg, arg)
{
if (!atom->electron_flag)
error->all(FLERR,"Fix nvt/nph/npt/eff requires atom style electron");
}
void FixNHEff::nve_v()
{
FixNH::nve_v();
double *erforce = atom->erforce;
double *ervel = atom->ervel;
double *mass = atom->mass;
int *spin = atom->spin;
double mefactor = domain->dimension/4.0;
int *type = atom->type;
int *mask = atom->mask;
int nlocal = atom->nlocal;
if (igroup == atom->firstgroup) nlocal = atom->nfirst;
double dtfm;
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
if (abs(spin[i])==1) {
dtfm = dtf / mass[type[i]];
ervel[i] = dtfm * erforce[i] / mefactor;
}
}
}
}
void FixNHEff::nve_x()
{
FixNH::nve_x();
double *eradius = atom->eradius;
double *ervel = atom->ervel;
int *spin = atom->spin;
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)
if (abs(spin[i])==1) eradius[i] += dtv * ervel[i];
}
void FixNHEff::nh_v_temp()
{
FixNH::nh_v_temp();
double *ervel = atom->ervel;
int *spin = atom->spin;
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)
if (abs(spin[i])==1) ervel[i] *= factor_eta;
}