bond/react: remember reaction counts

allow restart files to restore cumutative reaction counts
This commit is contained in:
jrgissing 2019-09-01 23:31:31 -06:00
parent 86c21264b9
commit 50af20d194
3 changed files with 56 additions and 4 deletions

View File

@ -392,10 +392,11 @@ local command.
[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 "binary restart Cumulative reaction counts for each reaction are written to "binary
files"_restart.html, aside from internally-created per-atom restart files"_restart.html. These values are associated with the
properties. None of the "fix_modify"_fix_modify.html options are reaction name (react-ID). Additionally, internally-created per-atom
relevant to this fix. properties are stored to allow for smooth restarts. None of the
"fix_modify"_fix_modify.html options are relevant to this fix.
This fix computes one statistic for each {react} argument that it This fix computes one statistic for each {react} argument that it
stores in a global vector, of length 'number of react arguments', that stores in a global vector, of length 'number of react arguments', that

View File

@ -87,6 +87,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
MPI_Comm_size(world,&nprocs); MPI_Comm_size(world,&nprocs);
newton_bond = force->newton_bond; newton_bond = force->newton_bond;
restart_global = 1;
attempted_rxn = 0; attempted_rxn = 0;
force_reneighbor = 1; force_reneighbor = 1;
next_reneighbor = -1; next_reneighbor = -1;
@ -388,6 +389,10 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
id_fix3 = NULL; id_fix3 = NULL;
statted_id = NULL; statted_id = NULL;
custom_exclude_flag = 0; custom_exclude_flag = 0;
// used to store restart info
set = new Set[nreacts];
memset(set,0,nreacts*sizeof(Set));
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -471,6 +476,7 @@ FixBondReact::~FixBondReact()
delete [] statted_id; delete [] statted_id;
delete [] guess_branch; delete [] guess_branch;
delete [] pioneer_count; delete [] pioneer_count;
delete [] set;
if (group) { if (group) {
char **newarg; char **newarg;
@ -3100,6 +3106,42 @@ void FixBondReact::unpack_reverse_comm(int n, int *list, double *buf)
} }
} }
/* ----------------------------------------------------------------------
write Set data to restart file
------------------------------------------------------------------------- */
void FixBondReact::write_restart(FILE *fp)
{
set[0].nreacts = nreacts;
for (int i = 0; i < nreacts; i++) {
set[i].reaction_count_total = reaction_count_total[i];
int n = strlen(rxn_name[i]) + 1;
strncpy(set[i].rxn_name,rxn_name[i],n);
}
if (me == 0) {
int size = nreacts*sizeof(Set);
fwrite(&size,sizeof(int),1,fp);
fwrite(set,sizeof(Set),nreacts,fp);
}
}
/* ----------------------------------------------------------------------
use selected state info from restart file to restart the Fix
------------------------------------------------------------------------- */
void FixBondReact::restart(char *buf)
{
Set *set_restart = (Set *) buf;
for (int i = 0; i < set_restart[0].nreacts; i++) {
for (int j = 0; j < nreacts; j++) {
if (strcmp(set_restart[i].rxn_name,rxn_name[j]) == 0) {
reaction_count_total[j] = set_restart[i].reaction_count_total;
}
}
}
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
memory usage of local atom-based arrays memory usage of local atom-based arrays
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */

View File

@ -170,6 +170,15 @@ class FixBondReact : public Fix {
void unlimit_bond(); void unlimit_bond();
void limit_bond(int); void limit_bond(int);
void dedup_mega_gloves(int); //dedup global mega_glove void dedup_mega_gloves(int); //dedup global mega_glove
virtual void write_restart(FILE *);
virtual void restart(char *buf);
struct Set {
int nreacts;
char rxn_name[256];
int reaction_count_total;
};
Set *set;
// DEBUG // DEBUG