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

This commit is contained in:
sjplimp 2013-01-05 00:45:15 +00:00
parent 5ce40edc4c
commit 9934c92093
2 changed files with 35 additions and 1 deletions

View File

@ -25,11 +25,16 @@
#include "group.h" #include "group.h"
#include "force.h" #include "force.h"
#include "update.h" #include "update.h"
#include "modify.h"
#include "input.h"
#include "variable.h"
#include "error.h" #include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
enum{CONSTANT,EQUAL};
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
FixHeat::FixHeat(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) 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]); nevery = atoi(arg[3]);
if (nevery <= 0) error->all(FLERR,"Illegal fix heat command"); 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 // optional args
@ -71,6 +86,7 @@ FixHeat::FixHeat(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
FixHeat::~FixHeat() FixHeat::~FixHeat()
{ {
delete [] hstr;
delete [] idregion; delete [] idregion;
} }
@ -95,6 +111,16 @@ void FixHeat::init()
error->all(FLERR,"Region ID for fix heat does not exist"); 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 // cannot have 0 atoms in group
if (group->count(igroup) == 0) if (group->count(igroup) == 0)
@ -111,6 +137,12 @@ void FixHeat::end_of_step()
Region *region = NULL; Region *region = NULL;
if (iregion >= 0) region = domain->regions[iregion]; 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) { if (iregion < 0) {
heat = heat_input*nevery*update->dt*force->ftm2v; heat = heat_input*nevery*update->dt*force->ftm2v;
ke = group->ke(igroup)*force->ftm2v; ke = group->ke(igroup)*force->ftm2v;

View File

@ -39,6 +39,8 @@ class FixHeat : public Fix {
double masstotal; double masstotal;
double scale; double scale;
char *idregion; char *idregion;
char *hstr;
int hstyle,hvar;
}; };
} }