forked from lijiext/lammps
git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8179 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
parent
b02227547d
commit
d1419c4c9c
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ class FixTempBerendsen : public Fix {
|
|||
int which;
|
||||
double t_start,t_stop,t_period,t_target;
|
||||
double energy;
|
||||
int tstyle,tvar;
|
||||
char *tstr;
|
||||
|
||||
char *id_temp;
|
||||
class Compute *temperature;
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "domain.h"
|
||||
#include "region.h"
|
||||
#include "comm.h"
|
||||
#include "input.h"
|
||||
#include "variable.h"
|
||||
#include "modify.h"
|
||||
#include "compute.h"
|
||||
#include "error.h"
|
||||
|
@ -30,6 +32,7 @@ using namespace LAMMPS_NS;
|
|||
using namespace FixConst;
|
||||
|
||||
enum{NOBIAS,BIAS};
|
||||
enum{CONSTANT,EQUAL};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
|
@ -45,8 +48,18 @@ FixTempRescale::FixTempRescale(LAMMPS *lmp, int narg, char **arg) :
|
|||
global_freq = nevery;
|
||||
extscalar = 1;
|
||||
|
||||
t_start = atof(arg[4]);
|
||||
t_target = t_start;
|
||||
tstr = NULL;
|
||||
if (strstr(arg[4],"v_") == arg[4]) {
|
||||
int n = strlen(&arg[4][2]) + 1;
|
||||
tstr = new char[n];
|
||||
strcpy(tstr,&arg[4][2]);
|
||||
tstyle = EQUAL;
|
||||
} else {
|
||||
t_start = atof(arg[4]);
|
||||
t_target = t_start;
|
||||
tstyle = CONSTANT;
|
||||
}
|
||||
|
||||
t_stop = atof(arg[5]);
|
||||
t_window = atof(arg[6]);
|
||||
fraction = atof(arg[7]);
|
||||
|
@ -74,6 +87,8 @@ FixTempRescale::FixTempRescale(LAMMPS *lmp, int narg, char **arg) :
|
|||
|
||||
FixTempRescale::~FixTempRescale()
|
||||
{
|
||||
delete [] tstr;
|
||||
|
||||
// delete temperature if fix created it
|
||||
|
||||
if (tflag) modify->delete_compute(id_temp);
|
||||
|
@ -94,6 +109,16 @@ int FixTempRescale::setmask()
|
|||
|
||||
void FixTempRescale::init()
|
||||
{
|
||||
// check variable
|
||||
|
||||
if (tstr) {
|
||||
tvar = input->variable->find(tstr);
|
||||
if (tvar < 0)
|
||||
error->all(FLERR,"Variable name for fix temp/rescale does not exist");
|
||||
if (input->variable->equalstyle(tvar)) tstyle = EQUAL;
|
||||
else error->all(FLERR,"Variable for fix temp/rescale is invalid style");
|
||||
}
|
||||
|
||||
int icompute = modify->find_compute(id_temp);
|
||||
if (icompute < 0)
|
||||
error->all(FLERR,"Temperature ID for fix temp/rescale does not exist");
|
||||
|
@ -113,7 +138,20 @@ void FixTempRescale::end_of_step()
|
|||
|
||||
double delta = update->ntimestep - update->beginstep;
|
||||
delta /= update->endstep - update->beginstep;
|
||||
t_target = t_start + delta * (t_stop-t_start);
|
||||
|
||||
// set current t_target and t_sqrt
|
||||
// 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/rescale variable returned negative temperature");
|
||||
modify->addstep_compute(update->ntimestep + nevery);
|
||||
}
|
||||
|
||||
// rescale velocity of appropriate atoms if outside window
|
||||
// for BIAS:
|
||||
|
@ -150,7 +188,6 @@ void FixTempRescale::end_of_step()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,7 +212,8 @@ int FixTempRescale::modify_param(int narg, char **arg)
|
|||
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;
|
||||
|
@ -209,4 +247,3 @@ void *FixTempRescale::extract(const char *str, int &dim)
|
|||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ class FixTempRescale : public Fix {
|
|||
int which;
|
||||
double t_start,t_stop,t_window,t_target;
|
||||
double fraction,energy,efactor;
|
||||
int tstyle,tvar;
|
||||
char *tstr;
|
||||
|
||||
char *id_temp;
|
||||
class Compute *temperature;
|
||||
|
|
Loading…
Reference in New Issue