git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8179 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -18,6 +18,8 @@
|
||||
#include "atom.h"
|
||||
#include "force.h"
|
||||
#include "comm.h"
|
||||
#include "input.h"
|
||||
#include "variable.h"
|
||||
#include "group.h"
|
||||
#include "update.h"
|
||||
#include "modify.h"
|
||||
@ -28,6 +30,7 @@ using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
enum{NOBIAS,BIAS};
|
||||
enum{CONSTANT,EQUAL};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -43,14 +46,25 @@ FixTempBerendsen::FixTempBerendsen(LAMMPS *lmp, int narg, char **arg) :
|
||||
global_freq = nevery;
|
||||
extscalar = 1;
|
||||
|
||||
t_start = atof(arg[3]);
|
||||
t_target = t_start;
|
||||
tstr = NULL;
|
||||
if (strstr(arg[3],"v_") == arg[3]) {
|
||||
int n = strlen(&arg[3][2]) + 1;
|
||||
tstr = new char[n];
|
||||
strcpy(tstr,&arg[3][2]);
|
||||
tstyle = EQUAL;
|
||||
} else {
|
||||
t_start = atof(arg[3]);
|
||||
t_target = t_start;
|
||||
tstyle = CONSTANT;
|
||||
}
|
||||
|
||||
t_stop = atof(arg[4]);
|
||||
t_period = atof(arg[5]);
|
||||
|
||||
// error checks
|
||||
|
||||
if (t_period <= 0.0) error->all(FLERR,"Fix temp/berendsen period must be > 0.0");
|
||||
if (t_period <= 0.0)
|
||||
error->all(FLERR,"Fix temp/berendsen period must be > 0.0");
|
||||
|
||||
// create a new compute temp style
|
||||
// id = fix-ID + temp, compute group = fix group
|
||||
@ -75,6 +89,8 @@ FixTempBerendsen::FixTempBerendsen(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
FixTempBerendsen::~FixTempBerendsen()
|
||||
{
|
||||
delete [] tstr;
|
||||
|
||||
// delete temperature if fix created it
|
||||
|
||||
if (tflag) modify->delete_compute(id_temp);
|
||||
@ -95,6 +111,16 @@ int FixTempBerendsen::setmask()
|
||||
|
||||
void FixTempBerendsen::init()
|
||||
{
|
||||
// check variable
|
||||
|
||||
if (tstr) {
|
||||
tvar = input->variable->find(tstr);
|
||||
if (tvar < 0)
|
||||
error->all(FLERR,"Variable name for fix temp/berendsen does not exist");
|
||||
if (input->variable->equalstyle(tvar)) tstyle = EQUAL;
|
||||
else error->all(FLERR,"Variable for fix temp/berendsen is invalid style");
|
||||
}
|
||||
|
||||
int icompute = modify->find_compute(id_temp);
|
||||
if (icompute < 0)
|
||||
error->all(FLERR,"Temperature ID for fix temp/berendsen does not exist");
|
||||
@ -110,11 +136,25 @@ void FixTempBerendsen::end_of_step()
|
||||
{
|
||||
double t_current = temperature->compute_scalar();
|
||||
if (t_current == 0.0)
|
||||
error->all(FLERR,"Computed temperature for fix temp/berendsen cannot be 0.0");
|
||||
error->all(FLERR,
|
||||
"Computed temperature for fix temp/berendsen cannot be 0.0");
|
||||
|
||||
double delta = update->ntimestep - update->beginstep;
|
||||
delta /= update->endstep - update->beginstep;
|
||||
t_target = t_start + delta * (t_stop-t_start);
|
||||
|
||||
// set current t_target
|
||||
// if variable temp, evaluate variable, wrap with clear/add
|
||||
|
||||
if (tstyle == CONSTANT)
|
||||
t_target = t_start + delta * (t_stop-t_start);
|
||||
else {
|
||||
modify->clearstep_compute();
|
||||
t_target = input->variable->compute_equal(tvar);
|
||||
if (t_target < 0.0)
|
||||
error->one(FLERR,
|
||||
"Fix temp/berendsen variable returned negative temperature");
|
||||
modify->addstep_compute(update->ntimestep + nevery);
|
||||
}
|
||||
|
||||
// rescale velocities by lamda
|
||||
// for BIAS:
|
||||
@ -166,11 +206,13 @@ int FixTempBerendsen::modify_param(int narg, char **arg)
|
||||
strcpy(id_temp,arg[1]);
|
||||
|
||||
int icompute = modify->find_compute(id_temp);
|
||||
if (icompute < 0) error->all(FLERR,"Could not find fix_modify temperature ID");
|
||||
if (icompute < 0)
|
||||
error->all(FLERR,"Could not find fix_modify temperature ID");
|
||||
temperature = modify->compute[icompute];
|
||||
|
||||
if (temperature->tempflag == 0)
|
||||
error->all(FLERR,"Fix_modify temperature ID does not compute temperature");
|
||||
error->all(FLERR,
|
||||
"Fix_modify temperature ID does not compute temperature");
|
||||
if (temperature->igroup != igroup && comm->me == 0)
|
||||
error->warning(FLERR,"Group for fix_modify temp != fix group");
|
||||
return 2;
|
||||
@ -204,4 +246,3 @@ void *FixTempBerendsen::extract(const char *str, int &dim)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user