store cumulative energy change in restart file

This commit is contained in:
Axel Kohlmeyer
2020-08-09 01:27:14 -04:00
parent e94d1c5537
commit 62a501ebda
3 changed files with 36 additions and 1 deletions

View File

@ -43,6 +43,7 @@ FixTempBerendsen::FixTempBerendsen(LAMMPS *lmp, int narg, char **arg) :
// Berendsen thermostat should be applied every step
restart_global = 1;
dynamic_group_allow = 1;
nevery = 1;
scalar_flag = 1;
@ -241,6 +242,34 @@ double FixTempBerendsen::compute_scalar()
return energy;
}
/* ----------------------------------------------------------------------
pack entire state of Fix into one write
------------------------------------------------------------------------- */
void FixTempBerendsen::write_restart(FILE *fp)
{
int n = 0;
double list[1];
list[n++] = energy;
if (comm->me == 0) {
int size = n * sizeof(double);
fwrite(&size,sizeof(int),1,fp);
fwrite(list,sizeof(double),n,fp);
}
}
/* ----------------------------------------------------------------------
use state info from restart file to restart the Fix
------------------------------------------------------------------------- */
void FixTempBerendsen::restart(char *buf)
{
int n = 0;
double *list = (double *) buf;
energy = list[n++];
}
/* ----------------------------------------------------------------------
extract thermostat properties
------------------------------------------------------------------------- */