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

@ -119,7 +119,11 @@ thermal degrees of freedom, and the bias is added back in.
**Restart, fix_modify, output, run start/stop, minimize info:** **Restart, fix_modify, output, run start/stop, minimize info:**
No information about this fix is written to :doc:`binary restart files <restart>`. This fix writes the cumulative global energy change to
:doc:`binary restart files <restart>`. See the
:doc:`read_restart <read_restart>` command for info on how to
re-specify a fix in an input script that reads a restart file,
so that the fix continues in an uninterrupted fashion.
The :doc:`fix_modify <fix_modify>` *temp* option is supported by this The :doc:`fix_modify <fix_modify>` *temp* option is supported by this
fix. You can use it to assign a temperature :doc:`compute <compute>` fix. You can use it to assign a temperature :doc:`compute <compute>`

View File

@ -43,6 +43,7 @@ FixTempBerendsen::FixTempBerendsen(LAMMPS *lmp, int narg, char **arg) :
// Berendsen thermostat should be applied every step // Berendsen thermostat should be applied every step
restart_global = 1;
dynamic_group_allow = 1; dynamic_group_allow = 1;
nevery = 1; nevery = 1;
scalar_flag = 1; scalar_flag = 1;
@ -241,6 +242,34 @@ double FixTempBerendsen::compute_scalar()
return energy; 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 extract thermostat properties
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */

View File

@ -34,6 +34,8 @@ class FixTempBerendsen : public Fix {
int modify_param(int, char **); int modify_param(int, char **);
void reset_target(double); void reset_target(double);
double compute_scalar(); double compute_scalar();
void write_restart(FILE *);
void restart(char *buf);
virtual void *extract(const char *, int &); virtual void *extract(const char *, int &);
private: private: