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

This commit is contained in:
Axel Kohlmeyer
2020-08-20 13:46:44 -04:00
parent fc9f0dbcbc
commit 92622d9079
9 changed files with 166 additions and 6 deletions

View File

@ -19,6 +19,7 @@
#include "fix_spring_rg.h"
#include <cstring>
#include "atom.h"
#include "comm.h"
#include "update.h"
#include "group.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;
else rg0 = force->numeric(FLERR,arg[4]);
restart_global = 1;
scalar_flag = 1;
restart_global = 1;
dynamic_group_allow = 1;
respa_level_support = 1;
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);
}
/* ----------------------------------------------------------------------
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;
}