forked from lijiext/lammps
bond/react: remember reaction counts
allow restart files to restore cumutative reaction counts
This commit is contained in:
parent
86c21264b9
commit
50af20d194
|
@ -392,10 +392,11 @@ local command.
|
|||
|
||||
[Restart, fix_modify, output, run start/stop, minimize info:]
|
||||
|
||||
No information about this fix is written to "binary restart
|
||||
files"_restart.html, aside from internally-created per-atom
|
||||
properties. None of the "fix_modify"_fix_modify.html options are
|
||||
relevant to this fix.
|
||||
Cumulative reaction counts for each reaction are written to "binary
|
||||
restart files"_restart.html. These values are associated with the
|
||||
reaction name (react-ID). Additionally, internally-created per-atom
|
||||
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
|
||||
stores in a global vector, of length 'number of react arguments', that
|
||||
|
|
|
@ -87,6 +87,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
|
|||
MPI_Comm_size(world,&nprocs);
|
||||
newton_bond = force->newton_bond;
|
||||
|
||||
restart_global = 1;
|
||||
attempted_rxn = 0;
|
||||
force_reneighbor = 1;
|
||||
next_reneighbor = -1;
|
||||
|
@ -388,6 +389,10 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
|
|||
id_fix3 = NULL;
|
||||
statted_id = NULL;
|
||||
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 [] guess_branch;
|
||||
delete [] pioneer_count;
|
||||
delete [] set;
|
||||
|
||||
if (group) {
|
||||
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
|
||||
------------------------------------------------------------------------- */
|
||||
|
|
|
@ -170,6 +170,15 @@ class FixBondReact : public Fix {
|
|||
void unlimit_bond();
|
||||
void limit_bond(int);
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue