git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@1034 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp 2007-10-12 17:34:53 +00:00
parent 913dca7a2d
commit a1b082b37d
4 changed files with 60 additions and 0 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;