git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@1034 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -36,6 +36,8 @@ FixDeposit::FixDeposit(LAMMPS *lmp, int narg, char **arg) :
|
||||
{
|
||||
if (narg < 7) error->all("Illegal fix deposit command");
|
||||
|
||||
restart_global = 1;
|
||||
|
||||
// required args
|
||||
|
||||
ninsert = atoi(arg[3]);
|
||||
@ -315,6 +317,7 @@ void FixDeposit::pre_exchange()
|
||||
}
|
||||
|
||||
// next timestep to insert
|
||||
// next_reneighbor = 0 if done
|
||||
|
||||
if (success) ninserted++;
|
||||
if (ninserted < ninsert) next_reneighbor += nfreq;
|
||||
@ -388,3 +391,40 @@ void FixDeposit::options(int narg, char **arg)
|
||||
} else error->all("Illegal fix deposit command");
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack entire state of Fix into one write
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixDeposit::write_restart(FILE *fp)
|
||||
{
|
||||
int n = 0;
|
||||
double list[4];
|
||||
list[n++] = random->state();
|
||||
list[n++] = ninserted;
|
||||
list[n++] = nfirst;
|
||||
list[n++] = next_reneighbor;
|
||||
|
||||
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 FixDeposit::restart(char *buf)
|
||||
{
|
||||
int n = 0;
|
||||
double *list = (double *) buf;
|
||||
|
||||
seed = static_cast<int> (list[n++]);
|
||||
ninserted = static_cast<int> (list[n++]);
|
||||
nfirst = static_cast<int> (list[n++]);
|
||||
next_reneighbor = static_cast<int> (list[n++]);
|
||||
|
||||
random->reset(seed);
|
||||
}
|
||||
|
||||
@ -24,6 +24,8 @@ class FixDeposit : public Fix {
|
||||
~FixDeposit();
|
||||
int setmask();
|
||||
void pre_exchange();
|
||||
void write_restart(FILE *);
|
||||
void restart(char *);
|
||||
|
||||
private:
|
||||
int ninsert,ntype,nfreq,seed;
|
||||
|
||||
@ -85,6 +85,15 @@ double RanPark::gaussian()
|
||||
return first;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void RanPark::reset(int seed_init)
|
||||
{
|
||||
if (seed_init <= 0) error->all("Invalid seed for Park random # generator");
|
||||
seed = seed_init;
|
||||
save = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
reset the seed based on atom position within box and ibase = caller seed
|
||||
combine 3 RNGs based on fractional position in box into one new seed
|
||||
@ -135,3 +144,10 @@ void RanPark::reset(int ibase, double *coord)
|
||||
uniform();
|
||||
uniform();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int RanPark::state()
|
||||
{
|
||||
return seed;
|
||||
}
|
||||
|
||||
@ -23,7 +23,9 @@ class RanPark : protected Pointers {
|
||||
RanPark(class LAMMPS *, int);
|
||||
double uniform();
|
||||
double gaussian();
|
||||
void reset(int);
|
||||
void reset(int, double *);
|
||||
int state();
|
||||
|
||||
private:
|
||||
int seed,save;
|
||||
|
||||
Reference in New Issue
Block a user