setup issues with fix numdiff
This commit is contained in:
@ -21,8 +21,8 @@ variable errx atom fx-f_numdiff[1]
|
|||||||
variable erry atom fy-f_numdiff[2]
|
variable erry atom fy-f_numdiff[2]
|
||||||
variable errz atom fz-f_numdiff[3]
|
variable errz atom fz-f_numdiff[3]
|
||||||
|
|
||||||
|
write_dump all custom tmp.error f_numdiff[1] f_numdiff[2] f_numdiff[3]
|
||||||
|
|
||||||
dump forces all custom 200 force_error.dump v_errx v_erry v_errz
|
dump forces all custom 200 force_error.dump v_errx v_erry v_errz
|
||||||
thermo 200
|
thermo 200
|
||||||
run 2000
|
run 2000
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -71,7 +71,13 @@ FixNumDiff::FixNumDiff(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
numdiff_forces = NULL;
|
numdiff_forces = NULL;
|
||||||
temp_x = NULL;
|
temp_x = NULL;
|
||||||
temp_f = NULL;
|
temp_f = NULL;
|
||||||
array_atom = NULL;
|
|
||||||
|
// perform initial allocation of atom-based arrays
|
||||||
|
// zero numdiff_forces since dump may access it on timestep 0
|
||||||
|
// zero numdiff_forces since a variable may access it before first run
|
||||||
|
|
||||||
|
reallocate();
|
||||||
|
force_clear(numdiff_forces);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -127,6 +133,26 @@ void FixNumDiff::init()
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void FixNumDiff::setup(int vflag)
|
||||||
|
{
|
||||||
|
if (strstr(update->integrate_style,"verlet"))
|
||||||
|
post_force(vflag);
|
||||||
|
else {
|
||||||
|
((Respa *) update->integrate)->copy_flevel_f(ilevel_respa);
|
||||||
|
post_force_respa(vflag,ilevel_respa,0);
|
||||||
|
((Respa *) update->integrate)->copy_f_flevel(ilevel_respa);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void FixNumDiff::min_setup(int vflag)
|
||||||
|
{
|
||||||
|
post_force(vflag);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void FixNumDiff::post_force(int vflag)
|
void FixNumDiff::post_force(int vflag)
|
||||||
{
|
{
|
||||||
if (update->ntimestep % nevery) return;
|
if (update->ntimestep % nevery) return;
|
||||||
@ -159,16 +185,7 @@ void FixNumDiff::calculate_forces()
|
|||||||
|
|
||||||
// grow arrays if necessary
|
// grow arrays if necessary
|
||||||
|
|
||||||
if (atom->nlocal + atom->nghost > maxatom) {
|
if (atom->nlocal + atom->nghost > maxatom) reallocate();
|
||||||
memory->destroy(numdiff_forces);
|
|
||||||
memory->destroy(temp_x);
|
|
||||||
memory->destroy(temp_f);
|
|
||||||
maxatom = atom->nmax;
|
|
||||||
memory->create(numdiff_forces,maxatom,3,"numdiff:numdiff_force");
|
|
||||||
memory->create(temp_x,maxatom,3,"numdiff:temp_x");
|
|
||||||
memory->create(temp_f,maxatom,3,"numdiff:temp_f");
|
|
||||||
array_atom = numdiff_forces;
|
|
||||||
}
|
|
||||||
|
|
||||||
// store copy of current forces for owned and ghost atoms
|
// store copy of current forces for owned and ghost atoms
|
||||||
|
|
||||||
@ -304,6 +321,22 @@ void FixNumDiff::force_clear(double **forces)
|
|||||||
if (nbytes) memset(&forces[0][0],0,3*nbytes);
|
if (nbytes) memset(&forces[0][0],0,3*nbytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
reallocated local per-atoms arrays
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void FixNumDiff::reallocate()
|
||||||
|
{
|
||||||
|
memory->destroy(numdiff_forces);
|
||||||
|
memory->destroy(temp_x);
|
||||||
|
memory->destroy(temp_f);
|
||||||
|
maxatom = atom->nmax;
|
||||||
|
memory->create(numdiff_forces,maxatom,3,"numdiff:numdiff_force");
|
||||||
|
memory->create(temp_x,maxatom,3,"numdiff:temp_x");
|
||||||
|
memory->create(temp_f,maxatom,3,"numdiff:temp_f");
|
||||||
|
array_atom = numdiff_forces;
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
memory usage of local atom-based arrays
|
memory usage of local atom-based arrays
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -30,6 +30,8 @@ class FixNumDiff : public Fix {
|
|||||||
~FixNumDiff();
|
~FixNumDiff();
|
||||||
int setmask();
|
int setmask();
|
||||||
void init();
|
void init();
|
||||||
|
void setup(int);
|
||||||
|
void min_setup(int);
|
||||||
void post_force(int);
|
void post_force(int);
|
||||||
void post_force_respa(int, int, int);
|
void post_force_respa(int, int, int);
|
||||||
void min_post_force(int);
|
void min_post_force(int);
|
||||||
@ -55,6 +57,7 @@ private:
|
|||||||
void restore_atoms(int, int);
|
void restore_atoms(int, int);
|
||||||
double update_energy();
|
double update_energy();
|
||||||
void force_clear(double **);
|
void force_clear(double **);
|
||||||
|
void reallocate();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user