git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@4475 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -75,6 +75,7 @@ Output::Output(LAMMPS *lmp) : Pointers(lmp)
|
||||
delete [] newarg;
|
||||
|
||||
thermo_every = 0;
|
||||
var_thermo = NULL;
|
||||
|
||||
ndump = 0;
|
||||
max_dump = 0;
|
||||
@ -98,6 +99,7 @@ Output::Output(LAMMPS *lmp) : Pointers(lmp)
|
||||
Output::~Output()
|
||||
{
|
||||
if (thermo) delete thermo;
|
||||
delete [] var_thermo;
|
||||
|
||||
memory->sfree(every_dump);
|
||||
memory->sfree(next_dump);
|
||||
@ -118,6 +120,15 @@ Output::~Output()
|
||||
void Output::init()
|
||||
{
|
||||
thermo->init();
|
||||
if (thermo_every) delete [] var_thermo;
|
||||
else if (var_thermo) {
|
||||
ivar_thermo = input->variable->find(var_thermo);
|
||||
if (ivar_thermo < 0)
|
||||
error->all("Variable name for thermo every does not exist");
|
||||
if (!input->variable->equalstyle(ivar_thermo))
|
||||
error->all("Variable for thermo every is invalid style");
|
||||
}
|
||||
|
||||
for (int i = 0; i < ndump; i++) dump[i]->init();
|
||||
for (int i = 0; i < ndump; i++)
|
||||
if (every_dump[i] == 0) {
|
||||
@ -207,6 +218,11 @@ void Output::setup(int flag)
|
||||
if (thermo_every) {
|
||||
next_thermo = (ntimestep/thermo_every)*thermo_every + thermo_every;
|
||||
next_thermo = MYMIN(next_thermo,update->laststep);
|
||||
} else if (var_thermo) {
|
||||
next_thermo = static_cast<int>
|
||||
(input->variable->compute_equal(ivar_thermo));
|
||||
if (next_thermo <= ntimestep)
|
||||
error->all("Thermo every variable returned a bad timestep");
|
||||
} else next_thermo = update->laststep;
|
||||
|
||||
modify->addstep_compute(next_thermo);
|
||||
@ -279,7 +295,13 @@ void Output::write(int ntimestep)
|
||||
modify->clearstep_compute();
|
||||
thermo->compute(1);
|
||||
last_thermo = ntimestep;
|
||||
next_thermo += thermo_every;
|
||||
if (thermo_every) next_thermo += thermo_every;
|
||||
else {
|
||||
next_thermo = static_cast<int>
|
||||
(input->variable->compute_equal(ivar_thermo));
|
||||
if (next_thermo <= ntimestep)
|
||||
error->all("Thermo every variable returned a bad timestep");
|
||||
}
|
||||
next_thermo = MYMIN(next_thermo,update->laststep);
|
||||
modify->addstep_compute(next_thermo);
|
||||
}
|
||||
|
||||
@ -25,6 +25,8 @@ class Output : protected Pointers {
|
||||
int next_thermo; // next timestep for thermo output
|
||||
int thermo_every; // thermo output every this many steps
|
||||
int last_thermo; // last timestep thermo was output
|
||||
char *var_thermo; // variable name for thermo frequency
|
||||
int ivar_thermo; // variable index for thermo frequency
|
||||
class Thermo *thermo; // Thermodynamic computations
|
||||
|
||||
int ndump; // # of Dumps defined
|
||||
|
||||
@ -376,7 +376,18 @@ void Thermo::modify_params(int narg, char **arg)
|
||||
|
||||
int iarg = 0;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"temp") == 0) {
|
||||
if (strcmp(arg[iarg],"every") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal thermo_modify command");
|
||||
if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) {
|
||||
delete [] output->var_thermo;
|
||||
int n = strlen(&arg[iarg+1][2]) + 1;
|
||||
output->var_thermo = new char[n];
|
||||
strcpy(output->var_thermo,&arg[iarg+1][2]);
|
||||
n = 0;
|
||||
} else error->all("Illegal thermo_modify command");
|
||||
output->thermo_every = 0;
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"temp") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal thermo_modify command");
|
||||
if (index_temp < 0) error->all("Thermo style does not use temp");
|
||||
delete [] id_compute[index_temp];
|
||||
|
||||
Reference in New Issue
Block a user