Unverified Commit 92622d90 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

add restart support to fix temp/rescale, fix spring/chunk, and fix spring/rg

parent fc9f0dbc
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -50,7 +50,16 @@ atom.

**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 locations of the initial per-chunk center of mass
coordinates 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.  Since this fix depends
on an instance of :doc:`compute chunk/atom <compute_chunk_atom>`
it will check when reading the restart if the chunk still exists and
will define the same number of chunks. The restart data is only applied
when the number of chunks matches. Otherwise the center of mass
coordinates are recomputed.

The :doc:`fix_modify <fix_modify>` *energy* option is supported by this
fix to add the energy stored in all the springs to the system's potential
+14 −3
Original line number Diff line number Diff line
@@ -59,9 +59,20 @@ the time the fix is specified, and that value is used as the target.

**Restart, fix_modify, output, run start/stop, minimize info:**

No information about this fix is written to :doc:`binary restart files <restart>`.  None of the :doc:`fix_modify <fix_modify>` options
are relevant to this fix.  No global or per-atom quantities are stored
by this fix for access by various :doc:`output commands <Howto_output>`.
This fix writes the currently used reference RG (:math:`R_{G0}`) 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.

None of the :doc:`fix_modify <fix_modify>` options
are relevant to this fix.

This fix computes a global scalar which can be accessed by various
:doc:`output commands <Howto_output>`.  The scalar is the reference
radius of gyration :math:`R_{G0}` used by the fix.  energy change due to
this fix.  The scalar value calculated by this fix is "intensive".

No parameter of this fix can be used with the *start/stop* keywords of
the :doc:`run <run>` command.  This fix is not invoked during :doc:`energy minimization <minimize>`.

+7 −2
Original line number Diff line number Diff line
@@ -126,7 +126,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>`
@@ -136,7 +140,8 @@ this fix and by the compute should be the same.

The :doc:`fix_modify <fix_modify>` *energy* option is supported by this
fix to add the energy change implied by a velocity rescaling to the
system's potential energy as part of :doc:`thermodynamic output <thermo_style>`.
system's potential energy as part of :doc:`thermodynamic output
<thermo_style>`.

This fix computes a global scalar which can be accessed by various
:doc:`output commands <Howto_output>`.  The scalar is the cumulative
+54 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include <cmath>
#include <cstring>
#include "atom.h"
#include "comm.h"
#include "update.h"
#include "force.h"
#include "respa.h"
@@ -37,6 +38,7 @@ FixSpringChunk::FixSpringChunk(LAMMPS *lmp, int narg, char **arg) :
{
  if (narg != 6) error->all(FLERR,"Illegal fix spring/chunk command");

  restart_global = 1;
  scalar_flag = 1;
  global_freq = 1;
  extscalar = 1;
@@ -241,6 +243,58 @@ void FixSpringChunk::min_post_force(int vflag)
  post_force(vflag);
}

/* ----------------------------------------------------------------------
   writ number of chunks and position of original COM into restart
------------------------------------------------------------------------- */

void FixSpringChunk::write_restart(FILE *fp)
{
  double n = nchunk;

  if (comm->me == 0) {
    int size = (3*n+1) * sizeof(double);
    fwrite(&size,sizeof(int),1,fp);
    fwrite(&n,sizeof(double),1,fp);
    fwrite(&com0[0][0],3*sizeof(double),nchunk,fp);
  }
}

/* ----------------------------------------------------------------------
   use state info from restart file to restart the Fix
------------------------------------------------------------------------- */

void FixSpringChunk::restart(char *buf)
{
  double *list = (double *) buf;
  int n = list[0];

  memory->destroy(com0);
  memory->destroy(fcom);

  int icompute = modify->find_compute(idchunk);
  if (icompute < 0)
    error->all(FLERR,"Chunk/atom compute does not exist for fix spring/chunk");
  cchunk = (ComputeChunkAtom *) modify->compute[icompute];
  if (strcmp(cchunk->style,"chunk/atom") != 0)
    error->all(FLERR,"Fix spring/chunk does not use chunk/atom compute");
  nchunk = cchunk->setup_chunks();
  cchunk->compute_ichunk();
  memory->create(com0,nchunk,3,"spring/chunk:com0");
  memory->create(fcom,nchunk,3,"spring/chunk:fcom");
  printf("restart chunks:%d  computed chunks: %d\n",n,nchunk);

  if (n != nchunk) {
    if (comm->me == 0)
      error->warning(FLERR,"Number of chunks has changed. Cannot use restart");
    memory->destroy(com0);
    memory->destroy(fcom);
    nchunk = 1;
  } else {
    cchunk->lock(this,update->ntimestep,-1);
    memcpy(&com0[0][0],list+1,3*n*sizeof(double));
  }
}

/* ----------------------------------------------------------------------
   energy of stretched spring
------------------------------------------------------------------------- */
+2 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ class FixSpringChunk : public Fix {
  void post_force(int);
  void post_force_respa(int, int, int);
  void min_post_force(int);
  void write_restart(FILE *);
  void restart(char *);
  double compute_scalar();

 private:
Loading