add restart support to fix temp/rescale, fix spring/chunk, and fix spring/rg
This commit is contained in:
@ -50,7 +50,16 @@ atom.
|
|||||||
|
|
||||||
**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 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
|
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
|
fix to add the energy stored in all the springs to the system's potential
|
||||||
|
|||||||
@ -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:**
|
**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
|
This fix writes the currently used reference RG (:math:`R_{G0}`) to
|
||||||
are relevant to this fix. No global or per-atom quantities are stored
|
:doc:`binary restart files <restart>`. See the :doc:`read_restart
|
||||||
by this fix for access by various :doc:`output commands <Howto_output>`.
|
<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
|
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>`.
|
the :doc:`run <run>` command. This fix is not invoked during :doc:`energy minimization <minimize>`.
|
||||||
|
|
||||||
|
|||||||
@ -126,7 +126,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>`
|
||||||
@ -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
|
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
|
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
|
This fix computes a global scalar which can be accessed by various
|
||||||
:doc:`output commands <Howto_output>`. The scalar is the cumulative
|
:doc:`output commands <Howto_output>`. The scalar is the cumulative
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
|
#include "comm.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
#include "force.h"
|
#include "force.h"
|
||||||
#include "respa.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");
|
if (narg != 6) error->all(FLERR,"Illegal fix spring/chunk command");
|
||||||
|
|
||||||
|
restart_global = 1;
|
||||||
scalar_flag = 1;
|
scalar_flag = 1;
|
||||||
global_freq = 1;
|
global_freq = 1;
|
||||||
extscalar = 1;
|
extscalar = 1;
|
||||||
@ -241,6 +243,58 @@ void FixSpringChunk::min_post_force(int vflag)
|
|||||||
post_force(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
|
energy of stretched spring
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -35,6 +35,8 @@ class FixSpringChunk : public Fix {
|
|||||||
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);
|
||||||
|
void write_restart(FILE *);
|
||||||
|
void restart(char *);
|
||||||
double compute_scalar();
|
double compute_scalar();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
#include "fix_spring_rg.h"
|
#include "fix_spring_rg.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
|
#include "comm.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include "respa.h"
|
#include "respa.h"
|
||||||
@ -41,6 +42,9 @@ FixSpringRG::FixSpringRG(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
if (strcmp(arg[4],"NULL") == 0) rg0_flag = 1;
|
if (strcmp(arg[4],"NULL") == 0) rg0_flag = 1;
|
||||||
else rg0 = force->numeric(FLERR,arg[4]);
|
else rg0 = force->numeric(FLERR,arg[4]);
|
||||||
|
|
||||||
|
restart_global = 1;
|
||||||
|
scalar_flag = 1;
|
||||||
|
restart_global = 1;
|
||||||
dynamic_group_allow = 1;
|
dynamic_group_allow = 1;
|
||||||
respa_level_support = 1;
|
respa_level_support = 1;
|
||||||
ilevel_respa = 0;
|
ilevel_respa = 0;
|
||||||
@ -144,3 +148,43 @@ void FixSpringRG::post_force_respa(int vflag, int ilevel, int /*iloop*/)
|
|||||||
{
|
{
|
||||||
if (ilevel == ilevel_respa) post_force(vflag);
|
if (ilevel == ilevel_respa) post_force(vflag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
pack entire state of Fix into one write
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void FixSpringRG::write_restart(FILE *fp)
|
||||||
|
{
|
||||||
|
int n = 0;
|
||||||
|
double list[1];
|
||||||
|
list[n++] = rg0;
|
||||||
|
|
||||||
|
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 FixSpringRG::restart(char *buf)
|
||||||
|
{
|
||||||
|
int n = 0;
|
||||||
|
double *list = (double *) buf;
|
||||||
|
|
||||||
|
rg0 = list[n++];
|
||||||
|
rg0_flag = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
return reference radius of gyration
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
double FixSpringRG::compute_scalar()
|
||||||
|
{
|
||||||
|
return rg0;
|
||||||
|
}
|
||||||
|
|||||||
@ -32,6 +32,9 @@ class FixSpringRG : public Fix {
|
|||||||
void setup(int);
|
void 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 write_restart(FILE *);
|
||||||
|
void restart(char *);
|
||||||
|
double compute_scalar();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int ilevel_respa,rg0_flag;
|
int ilevel_respa,rg0_flag;
|
||||||
|
|||||||
@ -44,6 +44,7 @@ FixTempRescale::FixTempRescale(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
nevery = force->inumeric(FLERR,arg[3]);
|
nevery = force->inumeric(FLERR,arg[3]);
|
||||||
if (nevery <= 0) error->all(FLERR,"Illegal fix temp/rescale command");
|
if (nevery <= 0) error->all(FLERR,"Illegal fix temp/rescale command");
|
||||||
|
|
||||||
|
restart_global = 1;
|
||||||
scalar_flag = 1;
|
scalar_flag = 1;
|
||||||
global_freq = nevery;
|
global_freq = nevery;
|
||||||
extscalar = 1;
|
extscalar = 1;
|
||||||
@ -238,6 +239,35 @@ double FixTempRescale::compute_scalar()
|
|||||||
return energy;
|
return energy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
pack entire state of Fix into one write
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void FixTempRescale::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 FixTempRescale::restart(char *buf)
|
||||||
|
{
|
||||||
|
int n = 0;
|
||||||
|
double *list = (double *) buf;
|
||||||
|
|
||||||
|
energy = list[n++];
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
extract thermostat properties
|
extract thermostat properties
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -34,6 +34,8 @@ class FixTempRescale : 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 &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
Reference in New Issue
Block a user