Unverified Commit 62a501eb authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

store cumulative energy change in restart file

parent e94d1c55
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -119,7 +119,11 @@ thermal degrees of freedom, and the bias is added back in.

**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
fix.  You can use it to assign a temperature :doc:`compute <compute>`
+29 −0
Original line number Diff line number Diff line
@@ -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
------------------------------------------------------------------------- */
+2 −0
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ class FixTempBerendsen : public Fix {
  int modify_param(int, char **);
  void reset_target(double);
  double compute_scalar();
  void write_restart(FILE *);
  void restart(char *buf);
  virtual void *extract(const char *, int &);

 private: