forked from lijiext/lammps
git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@9239 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
parent
5ce40edc4c
commit
9934c92093
|
@ -25,11 +25,16 @@
|
|||
#include "group.h"
|
||||
#include "force.h"
|
||||
#include "update.h"
|
||||
#include "modify.h"
|
||||
#include "input.h"
|
||||
#include "variable.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
enum{CONSTANT,EQUAL};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixHeat::FixHeat(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
|
||||
|
@ -43,7 +48,17 @@ FixHeat::FixHeat(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
|
|||
nevery = atoi(arg[3]);
|
||||
if (nevery <= 0) error->all(FLERR,"Illegal fix heat command");
|
||||
|
||||
heat_input = atof(arg[4]);
|
||||
hstr = NULL;
|
||||
|
||||
if (strstr(arg[4],"v_") == arg[4]) {
|
||||
int n = strlen(&arg[4][2]) + 1;
|
||||
hstr = new char[n];
|
||||
strcpy(hstr,&arg[4][2]);
|
||||
hstyle = EQUAL;
|
||||
} else {
|
||||
heat_input = atof(arg[4]);
|
||||
hstyle = CONSTANT;
|
||||
}
|
||||
|
||||
// optional args
|
||||
|
||||
|
@ -71,6 +86,7 @@ FixHeat::FixHeat(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
|
|||
|
||||
FixHeat::~FixHeat()
|
||||
{
|
||||
delete [] hstr;
|
||||
delete [] idregion;
|
||||
}
|
||||
|
||||
|
@ -95,6 +111,16 @@ void FixHeat::init()
|
|||
error->all(FLERR,"Region ID for fix heat does not exist");
|
||||
}
|
||||
|
||||
// check variable
|
||||
|
||||
if (hstr) {
|
||||
hvar = input->variable->find(hstr);
|
||||
if (hvar < 0)
|
||||
error->all(FLERR,"Variable name for fix heat does not exist");
|
||||
if (!input->variable->equalstyle(hvar))
|
||||
error->all(FLERR,"Variable for fix heat is invalid style");
|
||||
}
|
||||
|
||||
// cannot have 0 atoms in group
|
||||
|
||||
if (group->count(igroup) == 0)
|
||||
|
@ -111,6 +137,12 @@ void FixHeat::end_of_step()
|
|||
Region *region = NULL;
|
||||
if (iregion >= 0) region = domain->regions[iregion];
|
||||
|
||||
if (hstyle == EQUAL) {
|
||||
modify->clearstep_compute();
|
||||
heat_input = input->variable->compute_equal(hvar);
|
||||
modify->addstep_compute(update->ntimestep + nevery);
|
||||
}
|
||||
|
||||
if (iregion < 0) {
|
||||
heat = heat_input*nevery*update->dt*force->ftm2v;
|
||||
ke = group->ke(igroup)*force->ftm2v;
|
||||
|
|
|
@ -39,6 +39,8 @@ class FixHeat : public Fix {
|
|||
double masstotal;
|
||||
double scale;
|
||||
char *idregion;
|
||||
char *hstr;
|
||||
int hstyle,hvar;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue