Commit c318361d authored by sjplimp's avatar sjplimp
Browse files

git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@2937 f3b2605a-c512-4ea7-a41b-209d697bcdaa
parent b58c43a5
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@

using namespace LAMMPS_NS;

enum{DUMMY0,INVOKED_SCALAR,INVOKED_VECTOR,DUMMMY3,INVOKED_PERATOM};

/* ---------------------------------------------------------------------- */

ComputeTempAsphere::ComputeTempAsphere(LAMMPS *lmp, int narg, char **arg) :
@@ -159,7 +161,10 @@ double ComputeTempAsphere::compute_scalar()
  invoked_scalar = update->ntimestep;

  if (tempbias) {
    if (tbias->invoked_scalar != update->ntimestep) tbias->compute_scalar();
    if (!(tbias->invoked_flag & INVOKED_SCALAR)) {
      tbias->compute_scalar();
      tbias->invoked_flag |= INVOKED_SCALAR;
    }
    tbias->remove_bias_all();
  }

@@ -216,7 +221,10 @@ void ComputeTempAsphere::compute_vector()
  invoked_vector = update->ntimestep;

  if (tempbias) {
    if (tbias->invoked_vector != update->ntimestep) tbias->compute_vector();
    if (!(tbias->invoked_flag & INVOKED_VECTOR)) {
      tbias->compute_vector();
      tbias->invoked_flag |= INVOKED_VECTOR;
    }
    tbias->remove_bias_all();
  }

+7 −2
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
  pressatomflag = peatomflag = 0;
  tempbias = 0;

  id_pre = NULL;
  timeflag = 0;
  comm_forward = comm_reverse = 0;

@@ -87,7 +86,6 @@ Compute::~Compute()
{
  delete [] id;
  delete [] style;
  delete [] id_pre;

  memory->sfree(tlist);
}
@@ -129,6 +127,13 @@ void Compute::reset_extra_dof()
  extra_dof = domain->dimension;
}

/* ---------------------------------------------------------------------- */

void Compute::reset_extra_compute(char *)
{
  error->all("Compute does not allow an extra compute to be reset");
}

/* ----------------------------------------------------------------------
   add ntimestep to list of timesteps the compute will be called on
   do not add if already in list
+3 −3
Original line number Diff line number Diff line
@@ -47,14 +47,12 @@ class Compute : protected Pointers {

  int tempbias;       // 0/1 if Compute temp includes self/extra bias

  char *id_pre;       // ID of pre-compute the Compute may store

  int timeflag;       // 1 if Compute stores list of timesteps it's called on
  int ntime;          // # of entries in time list
  int maxtime;        // max # of entries time list can hold
  int *tlist;         // time list of steps the Compute is called on

  int invoked_flag;     // 1 if invoked or accessed this step, 0 if not
  int invoked_flag;     // non-zero if invoked or accessed this step, 0 if not
  int invoked_scalar;   // last timestep on which compute_scalar() was invoked
  int invoked_vector;   // ditto for compute_vector()
  int invoked_peratom;  // ditto for compute_peratom()
@@ -86,6 +84,8 @@ class Compute : protected Pointers {
  virtual void restore_bias(int, double *) {}
  virtual void restore_bias_all() {}

  virtual void reset_extra_compute(char *);

  void addstep(int);
  int matchstep(int);
  void clearstep();
+24 −8
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@

using namespace LAMMPS_NS;

enum{DUMMY0,INVOKED_SCALAR,INVOKED_VECTOR,DUMMMY3,INVOKED_PERATOM};

/* ---------------------------------------------------------------------- */

ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) :
@@ -50,10 +52,10 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) :
  // insure it is valid for temperature computation

  int n = strlen(arg[3]) + 1;
  id_pre = new char[n];
  strcpy(id_pre,arg[3]);
  id_temp = new char[n];
  strcpy(id_temp,arg[3]);

  int icompute = modify->find_compute(id_pre);
  int icompute = modify->find_compute(id_temp);
  if (icompute < 0) error->all("Could not find compute pressure temp ID");
  if (modify->compute[icompute]->tempflag == 0)
    error->all("Compute pressure temp ID does not compute temperature");
@@ -98,6 +100,7 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) :

ComputePressure::~ComputePressure()
{
  delete [] id_temp;
  delete [] vector;
  delete [] vptr;
}
@@ -113,7 +116,7 @@ void ComputePressure::init()
  // set temperature compute, must be done in init()
  // fixes could have changed or compute_modify could have changed it

  int icompute = modify->find_compute(id_pre);
  int icompute = modify->find_compute(id_temp);
  if (icompute < 0) error->all("Could not find compute pressure temp ID");
  temperature = modify->compute[icompute];

@@ -169,9 +172,10 @@ double ComputePressure::compute_scalar()

  double t;
  if (keflag) {
    if (temperature->invoked_scalar == update->ntimestep)
      t = temperature->scalar;
    else t = temperature->compute_scalar();
    if (!(temperature->invoked_flag & INVOKED_SCALAR)) {
      t = temperature->compute_scalar();
      temperature->invoked_flag |= INVOKED_SCALAR;
    } else t = temperature->scalar;
  }

  if (dimension == 3) {
@@ -210,8 +214,10 @@ void ComputePressure::compute_vector()

  double *ke_tensor;
  if (keflag) {
    if (temperature->invoked_vector != update->ntimestep)
    if (!(temperature->invoked_flag & INVOKED_VECTOR)) {
      temperature->compute_vector();
      temperature->invoked_flag |= INVOKED_VECTOR;
    }
    ke_tensor = temperature->vector;
  }

@@ -269,3 +275,13 @@ void ComputePressure::virial_compute(int n, int ndiag)
  if (force->pair && force->pair->tail_flag)
    for (i = 0; i < ndiag; i++) virial[i] += force->pair->ptail * inv_volume;
}

/* ---------------------------------------------------------------------- */

void ComputePressure::reset_extra_compute(char *id_new)
{
  delete [] id_temp;
  int n = strlen(id_new) + 1;
  id_temp = new char[n];
  strcpy(id_temp,id_new);
}
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ class ComputePressure : public Compute {
  void init();
  double compute_scalar();
  void compute_vector();
  void reset_extra_compute(char *);

 private:
  double boltz,nktv2p,inv_volume;
@@ -32,6 +33,7 @@ class ComputePressure : public Compute {
  double **vptr;
  double *kspace_virial;
  Compute *temperature;
  char *id_temp;
  double virial[6];
  int keflag,pairflag,bondflag,angleflag,dihedralflag,improperflag;
  int fixflag,kspaceflag;
Loading