2006-09-28 03:51:33 +08:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
2007-01-30 08:22:05 +08:00
|
|
|
http://lammps.sandia.gov, Sandia National Laboratories
|
|
|
|
Steve Plimpton, sjplimp@sandia.gov
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
|
|
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
|
|
|
certain rights in this software. This software is distributed under
|
|
|
|
the GNU General Public License.
|
|
|
|
|
|
|
|
See the README file in the top-level LAMMPS directory.
|
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#include "mpi.h"
|
|
|
|
#include "stdlib.h"
|
|
|
|
#include "string.h"
|
|
|
|
#include "thermo.h"
|
2007-01-30 08:22:05 +08:00
|
|
|
#include "atom.h"
|
2010-02-09 05:41:24 +08:00
|
|
|
#include "update.h"
|
2007-01-30 08:22:05 +08:00
|
|
|
#include "comm.h"
|
|
|
|
#include "domain.h"
|
2010-02-09 05:41:24 +08:00
|
|
|
#include "lattice.h"
|
2006-09-28 03:51:33 +08:00
|
|
|
#include "modify.h"
|
2007-01-30 08:22:05 +08:00
|
|
|
#include "fix.h"
|
|
|
|
#include "compute.h"
|
|
|
|
#include "input.h"
|
|
|
|
#include "variable.h"
|
2006-09-28 03:51:33 +08:00
|
|
|
#include "force.h"
|
|
|
|
#include "pair.h"
|
|
|
|
#include "bond.h"
|
|
|
|
#include "angle.h"
|
|
|
|
#include "dihedral.h"
|
|
|
|
#include "improper.h"
|
|
|
|
#include "kspace.h"
|
2007-10-15 23:07:04 +08:00
|
|
|
#include "output.h"
|
2006-09-28 03:51:33 +08:00
|
|
|
#include "timer.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "error.h"
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
using namespace LAMMPS_NS;
|
|
|
|
|
|
|
|
// customize a new keyword by adding to this list:
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2010-05-21 01:04:06 +08:00
|
|
|
// step, elapsed, elaplong, dt, cpu, tpcpu, spcpu
|
2010-03-04 02:40:02 +08:00
|
|
|
// atoms, temp, press, pe, ke, etotal, enthalpy
|
2007-01-30 08:22:05 +08:00
|
|
|
// evdwl, ecoul, epair, ebond, eangle, edihed, eimp, emol, elong, etail
|
2010-02-09 05:41:24 +08:00
|
|
|
// vol, lx, ly, lz, xlo, xhi, ylo, yhi, zlo, zhi, xy, xz, yz, xlat, ylat, zlat
|
2007-02-10 05:26:30 +08:00
|
|
|
// pxx, pyy, pzz, pxy, pxz, pyz
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
// customize a new thermo style by adding a DEFINE to this list
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2006-11-11 05:29:18 +08:00
|
|
|
#define ONE "step temp epair emol etotal press"
|
|
|
|
#define MULTI "etotal ke temp pe ebond eangle edihed eimp evdwl ecoul elong press"
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
enum{IGNORE,WARN,ERROR}; // same as write_restart.cpp
|
|
|
|
enum{ONELINE,MULTILINE};
|
|
|
|
enum{INT,FLOAT};
|
2009-12-10 05:12:49 +08:00
|
|
|
enum{SCALAR,VECTOR,ARRAY};
|
|
|
|
|
|
|
|
#define INVOKED_SCALAR 1
|
|
|
|
#define INVOKED_VECTOR 2
|
|
|
|
#define INVOKED_ARRAY 4
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2010-03-04 02:40:02 +08:00
|
|
|
#define MAXLINE 8192 // make this 4x longer than Input::MAXLINE
|
2008-01-03 03:24:46 +08:00
|
|
|
#define DELTA 8
|
|
|
|
|
|
|
|
#define MIN(A,B) ((A) < (B)) ? (A) : (B)
|
|
|
|
#define MAX(A,B) ((A) > (B)) ? (A) : (B)
|
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
Thermo::Thermo(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
|
2006-09-28 03:51:33 +08:00
|
|
|
{
|
|
|
|
MPI_Comm_rank(world,&me);
|
|
|
|
|
|
|
|
int n = strlen(arg[0]) + 1;
|
|
|
|
style = new char[n];
|
|
|
|
strcpy(style,arg[0]);
|
|
|
|
|
|
|
|
// set thermo_modify defaults
|
|
|
|
|
2009-04-11 07:20:41 +08:00
|
|
|
modified = 0;
|
2006-09-28 03:51:33 +08:00
|
|
|
normuserflag = 0;
|
|
|
|
lineflag = ONELINE;
|
|
|
|
lostflag = ERROR;
|
|
|
|
lostbefore = 0;
|
|
|
|
flushflag = 0;
|
|
|
|
|
|
|
|
// set style and corresponding lineflag
|
|
|
|
// custom style builds its own line of keywords
|
2007-01-30 08:22:05 +08:00
|
|
|
// customize a new thermo style by adding to if statement
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
line = new char[MAXLINE];
|
|
|
|
|
|
|
|
if (strcmp(style,"one") == 0) {
|
|
|
|
strcpy(line,ONE);
|
|
|
|
} else if (strcmp(style,"multi") == 0) {
|
|
|
|
strcpy(line,MULTI);
|
|
|
|
lineflag = MULTILINE;
|
2007-01-30 08:22:05 +08:00
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(style,"custom") == 0) {
|
|
|
|
if (narg == 1) error->all("Illegal thermo style custom command");
|
|
|
|
line[0] = '\0';
|
|
|
|
for (int iarg = 1; iarg < narg; iarg++) {
|
|
|
|
strcat(line,arg[iarg]);
|
|
|
|
strcat(line," ");
|
|
|
|
}
|
|
|
|
line[strlen(line)-1] = '\0';
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
} else error->all("Illegal thermo style command");
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2007-06-20 21:17:59 +08:00
|
|
|
// ptrs, flags, IDs for compute objects thermo may use or create
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
temperature = NULL;
|
|
|
|
pressure = NULL;
|
2007-11-03 04:25:11 +08:00
|
|
|
pe = NULL;
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2008-03-11 01:49:50 +08:00
|
|
|
index_temp = index_press_scalar = index_press_vector = index_pe = -1;
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2007-10-04 00:22:30 +08:00
|
|
|
id_temp = (char *) "thermo_temp";
|
2008-01-18 07:46:47 +08:00
|
|
|
id_press = (char *) "thermo_press";
|
2007-11-03 04:25:11 +08:00
|
|
|
id_pe = (char *) "thermo_pe";
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
// count fields in line
|
|
|
|
// allocate per-field memory
|
|
|
|
// process line of keywords
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
nfield_initial = atom->count_words(line);
|
|
|
|
allocate();
|
|
|
|
parse_fields(line);
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
// format strings
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2007-10-04 00:22:30 +08:00
|
|
|
format_multi = (char *) "---------------- Step %8d ----- "
|
|
|
|
"CPU = %11.4f (sec) ----------------";
|
|
|
|
format_int_one_def = (char *) "%8d";
|
|
|
|
format_int_multi_def = (char *) "%14d";
|
|
|
|
format_g_def = (char *) "%12.8g";
|
|
|
|
format_f_def = (char *) "%14.4f";
|
2007-01-30 08:22:05 +08:00
|
|
|
format_int_user = NULL;
|
|
|
|
format_float_user = NULL;
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
Thermo::~Thermo()
|
|
|
|
{
|
|
|
|
delete [] style;
|
|
|
|
delete [] line;
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
deallocate();
|
|
|
|
|
|
|
|
// format strings
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
delete [] format_int_user;
|
|
|
|
delete [] format_float_user;
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::init()
|
|
|
|
{
|
2007-01-30 08:22:05 +08:00
|
|
|
int i,n;
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
// set normvalue to default setting unless user has specified it
|
|
|
|
|
|
|
|
if (normuserflag) normvalue = normuser;
|
|
|
|
else if (strcmp(update->unit_style,"lj") == 0) normvalue = 1;
|
|
|
|
else normvalue = 0;
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
// add Volume field if volume changes and not style = custom
|
2006-09-28 03:51:33 +08:00
|
|
|
// this check must come after domain init, so box_change is set
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
nfield = nfield_initial;
|
2006-09-28 03:51:33 +08:00
|
|
|
if (domain->box_change && strcmp(style,"custom") != 0)
|
|
|
|
addfield("Volume",&Thermo::compute_vol,FLOAT);
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
// set format string for each field
|
2006-09-28 03:51:33 +08:00
|
|
|
// include keyword if lineflag = MULTILINE
|
|
|
|
// add '/n' every 3 values if lineflag = MULTILINE
|
|
|
|
// add trailing '/n' to last value
|
|
|
|
|
|
|
|
char *ptr;
|
|
|
|
for (i = 0; i < nfield; i++) {
|
|
|
|
format[i][0] = '\0';
|
|
|
|
if (lineflag == MULTILINE && i % 3 == 0) strcat(format[i],"\n");
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
if (format_user[i]) ptr = format_user[i];
|
|
|
|
else if (vtype[i] == INT && format_int_user) ptr = format_int_user;
|
|
|
|
else if (vtype[i] == INT && lineflag == ONELINE) ptr = format_int_one_def;
|
2007-10-17 02:08:31 +08:00
|
|
|
else if (vtype[i] == INT && lineflag == MULTILINE)
|
|
|
|
ptr = format_int_multi_def;
|
2007-01-30 08:22:05 +08:00
|
|
|
else if (vtype[i] == FLOAT && format_float_user) ptr = format_float_user;
|
|
|
|
else if (lineflag == ONELINE) ptr = format_g_def;
|
2006-09-28 03:51:33 +08:00
|
|
|
else if (lineflag == MULTILINE) ptr = format_f_def;
|
|
|
|
|
|
|
|
n = strlen(format[i]);
|
|
|
|
if (lineflag == ONELINE) sprintf(&format[i][n],"%s ",ptr);
|
|
|
|
else sprintf(&format[i][n],"%-8s = %s ",keyword[i],ptr);
|
|
|
|
|
|
|
|
if (i == nfield-1) strcat(format[i],"\n");
|
|
|
|
}
|
2007-01-30 08:22:05 +08:00
|
|
|
|
|
|
|
// find current ptr for each Compute ID
|
|
|
|
|
|
|
|
int icompute;
|
|
|
|
for (i = 0; i < ncompute; i++) {
|
|
|
|
icompute = modify->find_compute(id_compute[i]);
|
2007-06-20 21:17:59 +08:00
|
|
|
if (icompute < 0) error->all("Could not find thermo compute ID");
|
2007-01-30 08:22:05 +08:00
|
|
|
computes[i] = modify->compute[icompute];
|
|
|
|
}
|
|
|
|
|
|
|
|
// find current ptr for each Fix ID
|
2007-10-15 23:07:04 +08:00
|
|
|
// check that fix frequency is acceptable with thermo output frequency
|
2007-01-30 08:22:05 +08:00
|
|
|
|
|
|
|
int ifix;
|
|
|
|
for (i = 0; i < nfix; i++) {
|
|
|
|
ifix = modify->find_fix(id_fix[i]);
|
2007-06-20 21:17:59 +08:00
|
|
|
if (ifix < 0) error->all("Could not find thermo fix ID");
|
2007-01-30 08:22:05 +08:00
|
|
|
fixes[i] = modify->fix[ifix];
|
2009-12-05 05:03:54 +08:00
|
|
|
if (output->thermo_every % fixes[i]->global_freq)
|
2007-10-15 23:07:04 +08:00
|
|
|
error->all("Thermo and fix not computed at compatible times");
|
2007-01-30 08:22:05 +08:00
|
|
|
}
|
|
|
|
|
2008-01-03 03:24:46 +08:00
|
|
|
// find current ptr for each Variable ID
|
|
|
|
|
|
|
|
int ivariable;
|
|
|
|
for (i = 0; i < nvariable; i++) {
|
|
|
|
ivariable = input->variable->find(id_variable[i]);
|
2008-12-03 04:18:44 +08:00
|
|
|
if (ivariable < 0)
|
|
|
|
error->all("Could not find thermo custom variable name");
|
2008-01-03 03:24:46 +08:00
|
|
|
variables[i] = ivariable;
|
|
|
|
}
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
// set ptrs to keyword-specific Compute objects
|
|
|
|
|
|
|
|
if (index_temp >= 0) temperature = computes[index_temp];
|
2008-03-11 01:49:50 +08:00
|
|
|
if (index_press_scalar >= 0) pressure = computes[index_press_scalar];
|
|
|
|
if (index_press_vector >= 0) pressure = computes[index_press_vector];
|
2007-11-03 04:25:11 +08:00
|
|
|
if (index_pe >= 0) pe = computes[index_pe];
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::header()
|
|
|
|
{
|
|
|
|
if (lineflag == MULTILINE) return;
|
|
|
|
|
|
|
|
int loc = 0;
|
|
|
|
for (int i = 0; i < nfield; i++)
|
|
|
|
loc += sprintf(&line[loc],"%s ",keyword[i]);
|
|
|
|
sprintf(&line[loc],"\n");
|
|
|
|
|
|
|
|
if (me == 0) {
|
|
|
|
if (screen) fprintf(screen,line);
|
|
|
|
if (logfile) fprintf(logfile,line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute(int flag)
|
|
|
|
{
|
2007-01-30 08:22:05 +08:00
|
|
|
int i;
|
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
firststep = flag;
|
2009-01-06 06:26:08 +08:00
|
|
|
int ntimestep = update->ntimestep;
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
// check for lost atoms
|
|
|
|
// turn off normflag if natoms = 0 to avoid divide by 0
|
|
|
|
|
|
|
|
natoms = lost_check();
|
|
|
|
if (natoms == 0) normflag = 0;
|
|
|
|
else normflag = normvalue;
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
// invoke Compute methods needed for thermo keywords
|
2008-01-03 03:24:46 +08:00
|
|
|
// which = 0 is global scalar, which = 1 is global vector
|
2007-01-30 08:22:05 +08:00
|
|
|
|
2009-01-10 05:31:31 +08:00
|
|
|
for (i = 0; i < ncompute; i++)
|
2009-12-10 05:12:49 +08:00
|
|
|
if (compute_which[i] == SCALAR) {
|
2009-01-10 05:31:31 +08:00
|
|
|
if (!(computes[i]->invoked_flag & INVOKED_SCALAR)) {
|
2009-01-06 06:26:08 +08:00
|
|
|
computes[i]->compute_scalar();
|
2009-01-10 05:31:31 +08:00
|
|
|
computes[i]->invoked_flag |= INVOKED_SCALAR;
|
|
|
|
}
|
2009-12-10 05:12:49 +08:00
|
|
|
} else if (compute_which[i] == VECTOR) {
|
2009-01-10 05:31:31 +08:00
|
|
|
if (!(computes[i]->invoked_flag & INVOKED_VECTOR)) {
|
2008-01-03 03:24:46 +08:00
|
|
|
computes[i]->compute_vector();
|
2009-01-10 05:31:31 +08:00
|
|
|
computes[i]->invoked_flag |= INVOKED_VECTOR;
|
|
|
|
}
|
2009-12-10 05:12:49 +08:00
|
|
|
} else if (compute_which[i] == ARRAY) {
|
|
|
|
if (!(computes[i]->invoked_flag & INVOKED_ARRAY)) {
|
|
|
|
computes[i]->compute_array();
|
|
|
|
computes[i]->invoked_flag |= INVOKED_ARRAY;
|
|
|
|
}
|
2008-01-03 03:24:46 +08:00
|
|
|
}
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
// if lineflag = MULTILINE, prepend step/cpu header line
|
|
|
|
|
|
|
|
int loc = 0;
|
|
|
|
if (lineflag == MULTILINE) {
|
|
|
|
double cpu;
|
|
|
|
if (flag) cpu = timer->elapsed(TIME_LOOP);
|
|
|
|
else cpu = 0.0;
|
2009-01-06 06:26:08 +08:00
|
|
|
loc = sprintf(&line[loc],format_multi,ntimestep,cpu);
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// add each thermo value to line with its specific format
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
for (ifield = 0; ifield < nfield; ifield++) {
|
|
|
|
(this->*vfunc[ifield])();
|
|
|
|
if (vtype[ifield] == INT) loc += sprintf(&line[loc],format[ifield],ivalue);
|
|
|
|
else loc += sprintf(&line[loc],format[ifield],dvalue);
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
|
2007-12-11 04:49:32 +08:00
|
|
|
// kludge for RedStorm timing issue
|
2009-01-06 06:26:08 +08:00
|
|
|
// if (ntimestep == 100) return;
|
2007-12-11 04:49:32 +08:00
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
// print line to screen and logfile
|
|
|
|
|
|
|
|
if (me == 0) {
|
|
|
|
if (screen) fprintf(screen,line);
|
|
|
|
if (logfile) {
|
|
|
|
fprintf(logfile,line);
|
|
|
|
if (flushflag) fflush(logfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
check for lost atoms, return current number of atoms
|
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
double Thermo::lost_check()
|
|
|
|
{
|
2007-01-30 08:22:05 +08:00
|
|
|
// ntotal = current # of atoms
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
double ntotal;
|
2006-09-28 03:51:33 +08:00
|
|
|
double rlocal = atom->nlocal;
|
2007-01-30 08:22:05 +08:00
|
|
|
MPI_Allreduce(&rlocal,&ntotal,1,MPI_DOUBLE,MPI_SUM,world);
|
|
|
|
if (ntotal == atom->natoms) return ntotal;
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
// if not checking or already warned, just return
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
if (lostflag == IGNORE) return ntotal;
|
|
|
|
if (lostflag == WARN && lostbefore == 1) return ntotal;
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
// error message
|
|
|
|
|
|
|
|
if (lostflag == ERROR) {
|
|
|
|
char str[128];
|
|
|
|
sprintf(str,"Lost atoms: original %.15g current %.15g",
|
2007-01-30 08:22:05 +08:00
|
|
|
atom->natoms,ntotal);
|
2006-09-28 03:51:33 +08:00
|
|
|
error->all(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
// warning message
|
|
|
|
|
|
|
|
char str[128];
|
2007-01-30 08:22:05 +08:00
|
|
|
sprintf(str,"Lost atoms: original %.15g current %.15g",atom->natoms,ntotal);
|
2006-09-28 03:51:33 +08:00
|
|
|
if (me == 0) error->warning(str);
|
|
|
|
lostbefore = 1;
|
2007-01-30 08:22:05 +08:00
|
|
|
return ntotal;
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
modify thermo parameters
|
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::modify_params(int narg, char **arg)
|
|
|
|
{
|
|
|
|
if (narg == 0) error->all("Illegal thermo_modify command");
|
|
|
|
|
2009-04-11 07:20:41 +08:00
|
|
|
modified = 1;
|
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
int iarg = 0;
|
|
|
|
while (iarg < narg) {
|
|
|
|
if (strcmp(arg[iarg],"temp") == 0) {
|
|
|
|
if (iarg+2 > narg) error->all("Illegal thermo_modify command");
|
2007-01-30 08:22:05 +08:00
|
|
|
if (index_temp < 0) error->all("Thermo style does not use temp");
|
|
|
|
delete [] id_compute[index_temp];
|
2007-04-24 00:54:30 +08:00
|
|
|
int n = strlen(arg[iarg+1]) + 1;
|
2007-01-30 08:22:05 +08:00
|
|
|
id_compute[index_temp] = new char[n];
|
2007-04-24 00:54:30 +08:00
|
|
|
strcpy(id_compute[index_temp],arg[iarg+1]);
|
2007-01-30 08:22:05 +08:00
|
|
|
|
2008-03-11 01:49:50 +08:00
|
|
|
int icompute = modify->find_compute(arg[iarg+1]);
|
2009-07-03 02:01:55 +08:00
|
|
|
if (icompute < 0)
|
|
|
|
error->all("Could not find thermo_modify temperature ID");
|
2007-01-30 08:22:05 +08:00
|
|
|
temperature = modify->compute[icompute];
|
|
|
|
|
|
|
|
if (temperature->tempflag == 0)
|
2009-07-03 02:01:55 +08:00
|
|
|
error->all("Thermo_modify temperature ID does not "
|
|
|
|
"compute temperature");
|
2007-01-30 08:22:05 +08:00
|
|
|
if (temperature->igroup != 0 && comm->me == 0)
|
2006-09-28 03:51:33 +08:00
|
|
|
error->warning("Temperature for thermo pressure is not for group all");
|
2007-01-30 08:22:05 +08:00
|
|
|
|
2009-07-03 02:01:55 +08:00
|
|
|
// reset id_temp of pressure to new temperature ID
|
2008-01-18 07:46:47 +08:00
|
|
|
// either pressure currently being used by thermo or "thermo_press"
|
2007-01-30 08:22:05 +08:00
|
|
|
|
2008-03-11 01:49:50 +08:00
|
|
|
if (index_press_scalar >= 0) {
|
|
|
|
icompute = modify->find_compute(id_compute[index_press_scalar]);
|
2009-07-03 02:01:55 +08:00
|
|
|
if (icompute < 0) error->all("Pressure ID for thermo does not exist");
|
2008-03-11 01:49:50 +08:00
|
|
|
} else if (index_press_vector >= 0) {
|
|
|
|
icompute = modify->find_compute(id_compute[index_press_vector]);
|
2009-07-03 02:01:55 +08:00
|
|
|
if (icompute < 0) error->all("Pressure ID for thermo does not exist");
|
2008-01-18 07:46:47 +08:00
|
|
|
} else icompute = modify->find_compute((char *) "thermo_press");
|
2007-06-20 21:17:59 +08:00
|
|
|
|
2009-08-19 01:54:17 +08:00
|
|
|
modify->compute[icompute]->reset_extra_compute_fix(arg[iarg+1]);
|
2007-01-30 08:22:05 +08:00
|
|
|
|
|
|
|
iarg += 2;
|
|
|
|
|
2007-04-24 00:54:30 +08:00
|
|
|
} else if (strcmp(arg[iarg],"press") == 0) {
|
2007-01-30 08:22:05 +08:00
|
|
|
if (iarg+2 > narg) error->all("Illegal thermo_modify command");
|
2008-03-11 01:49:50 +08:00
|
|
|
if (index_press_scalar < 0 && index_press_vector < 0)
|
|
|
|
error->all("Thermo style does not use press");
|
|
|
|
|
|
|
|
if (index_press_scalar >= 0) {
|
|
|
|
delete [] id_compute[index_press_scalar];
|
|
|
|
int n = strlen(arg[iarg+1]) + 1;
|
|
|
|
id_compute[index_press_scalar] = new char[n];
|
|
|
|
strcpy(id_compute[index_press_scalar],arg[iarg+1]);
|
|
|
|
}
|
|
|
|
if (index_press_vector >= 0) {
|
|
|
|
delete [] id_compute[index_press_vector];
|
|
|
|
int n = strlen(arg[iarg+1]) + 1;
|
|
|
|
id_compute[index_press_vector] = new char[n];
|
|
|
|
strcpy(id_compute[index_press_vector],arg[iarg+1]);
|
|
|
|
}
|
2007-01-30 08:22:05 +08:00
|
|
|
|
2008-03-11 01:49:50 +08:00
|
|
|
int icompute = modify->find_compute(arg[iarg+1]);
|
2009-07-03 02:01:55 +08:00
|
|
|
if (icompute < 0) error->all("Could not find thermo_modify pressure ID");
|
2007-01-30 08:22:05 +08:00
|
|
|
pressure = modify->compute[icompute];
|
|
|
|
|
|
|
|
if (pressure->pressflag == 0)
|
2009-07-03 02:01:55 +08:00
|
|
|
error->all("Thermo_modify pressure ID does not compute pressure");
|
2007-01-30 08:22:05 +08:00
|
|
|
|
|
|
|
iarg += 2;
|
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(arg[iarg],"lost") == 0) {
|
|
|
|
if (iarg+2 > narg) error->all("Illegal thermo_modify command");
|
|
|
|
if (strcmp(arg[iarg+1],"ignore") == 0) lostflag = IGNORE;
|
|
|
|
else if (strcmp(arg[iarg+1],"warn") == 0) lostflag = WARN;
|
|
|
|
else if (strcmp(arg[iarg+1],"error") == 0) lostflag = ERROR;
|
|
|
|
else error->all("Illegal thermo_modify command");
|
|
|
|
iarg += 2;
|
2007-01-30 08:22:05 +08:00
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(arg[iarg],"norm") == 0) {
|
|
|
|
if (iarg+2 > narg) error->all("Illegal thermo_modify command");
|
|
|
|
normuserflag = 1;
|
|
|
|
if (strcmp(arg[iarg+1],"no") == 0) normuser = 0;
|
|
|
|
else if (strcmp(arg[iarg+1],"yes") == 0) normuser = 1;
|
|
|
|
else error->all("Illegal thermo_modify command");
|
|
|
|
iarg += 2;
|
2007-01-30 08:22:05 +08:00
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(arg[iarg],"flush") == 0) {
|
|
|
|
if (iarg+2 > narg) error->all("Illegal thermo_modify command");
|
|
|
|
if (strcmp(arg[iarg+1],"no") == 0) flushflag = 0;
|
|
|
|
else if (strcmp(arg[iarg+1],"yes") == 0) flushflag = 1;
|
|
|
|
else error->all("Illegal thermo_modify command");
|
|
|
|
iarg += 2;
|
2007-01-30 08:22:05 +08:00
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(arg[iarg],"line") == 0) {
|
|
|
|
if (iarg+2 > narg) error->all("Illegal thermo_modify command");
|
|
|
|
if (strcmp(arg[iarg+1],"one") == 0) lineflag = ONELINE;
|
|
|
|
else if (strcmp(arg[iarg+1],"multi") == 0) lineflag = MULTILINE;
|
|
|
|
else error->all("Illegal thermo_modify command");
|
|
|
|
iarg += 2;
|
2007-01-30 08:22:05 +08:00
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(arg[iarg],"format") == 0) {
|
|
|
|
if (iarg+3 > narg) error->all("Illegal thermo_modify command");
|
|
|
|
if (strcmp(arg[iarg+1],"int") == 0) {
|
2007-01-30 08:22:05 +08:00
|
|
|
if (format_int_user) delete [] format_int_user;
|
2006-09-28 03:51:33 +08:00
|
|
|
int n = strlen(arg[iarg+2]) + 1;
|
|
|
|
format_int_user = new char[n];
|
|
|
|
strcpy(format_int_user,arg[iarg+2]);
|
|
|
|
} else if (strcmp(arg[iarg+1],"float") == 0) {
|
2007-01-30 08:22:05 +08:00
|
|
|
if (format_float_user) delete [] format_float_user;
|
2006-09-28 03:51:33 +08:00
|
|
|
int n = strlen(arg[iarg+2]) + 1;
|
|
|
|
format_float_user = new char[n];
|
|
|
|
strcpy(format_float_user,arg[iarg+2]);
|
|
|
|
} else {
|
2007-04-07 02:47:09 +08:00
|
|
|
int i = atoi(arg[iarg+1]) - 1;
|
|
|
|
if (i < 0 || i >= nfield_initial)
|
2007-01-30 08:22:05 +08:00
|
|
|
error->all("Illegal thermo_modify command");
|
|
|
|
if (format_user[i]) delete [] format_user[i];
|
2006-09-28 03:51:33 +08:00
|
|
|
int n = strlen(arg[iarg+2]) + 1;
|
2007-01-30 08:22:05 +08:00
|
|
|
format_user[i] = new char[n];
|
|
|
|
strcpy(format_user[i],arg[iarg+2]);
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
iarg += 3;
|
2007-01-30 08:22:05 +08:00
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
} else error->all("Illegal thermo_modify command");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
allocate all per-field memory
|
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::allocate()
|
|
|
|
{
|
2007-04-07 02:47:09 +08:00
|
|
|
// n = specified fields + Volume field (added at run time)
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
int n = nfield_initial + 1;
|
|
|
|
|
|
|
|
keyword = new char*[n];
|
|
|
|
for (int i = 0; i < n; i++) keyword[i] = new char[32];
|
|
|
|
vfunc = new FnPtr[n];
|
|
|
|
vtype = new int[n];
|
|
|
|
|
|
|
|
format = new char*[n];
|
|
|
|
for (int i = 0; i < n; i++) format[i] = new char[32];
|
|
|
|
format_user = new char*[n];
|
|
|
|
for (int i = 0; i < n; i++) format_user[i] = NULL;
|
|
|
|
|
2008-01-03 03:24:46 +08:00
|
|
|
field2index = new int[n];
|
2009-12-10 05:12:49 +08:00
|
|
|
argindex1 = new int[n];
|
|
|
|
argindex2 = new int[n];
|
2008-01-03 03:24:46 +08:00
|
|
|
|
|
|
|
// factor of 3 is max number of computes a single field can add
|
2007-01-30 08:22:05 +08:00
|
|
|
|
|
|
|
ncompute = 0;
|
2008-01-03 03:24:46 +08:00
|
|
|
id_compute = new char*[3*n];
|
|
|
|
compute_which = new int[3*n];
|
|
|
|
computes = new Compute*[3*n];
|
2007-01-30 08:22:05 +08:00
|
|
|
|
|
|
|
nfix = 0;
|
|
|
|
id_fix = new char*[n];
|
|
|
|
fixes = new Fix*[n];
|
|
|
|
|
|
|
|
nvariable = 0;
|
|
|
|
id_variable = new char*[n];
|
2008-01-03 03:24:46 +08:00
|
|
|
variables = new int[n];
|
2007-01-30 08:22:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
deallocate all per-field memory
|
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::deallocate()
|
|
|
|
{
|
|
|
|
int n = nfield_initial + 1;
|
|
|
|
|
|
|
|
for (int i = 0; i < n; i++) delete [] keyword[i];
|
|
|
|
delete [] keyword;
|
|
|
|
delete [] vfunc;
|
|
|
|
delete [] vtype;
|
|
|
|
|
|
|
|
for (int i = 0; i < n; i++) delete [] format[i];
|
|
|
|
delete [] format;
|
|
|
|
for (int i = 0; i < n; i++) delete [] format_user[i];
|
|
|
|
delete [] format_user;
|
|
|
|
|
2008-01-03 03:24:46 +08:00
|
|
|
delete [] field2index;
|
2009-12-10 05:12:49 +08:00
|
|
|
delete [] argindex1;
|
|
|
|
delete [] argindex2;
|
2007-01-30 08:22:05 +08:00
|
|
|
|
|
|
|
for (int i = 0; i < ncompute; i++) delete [] id_compute[i];
|
2008-01-03 03:24:46 +08:00
|
|
|
delete [] id_compute;
|
|
|
|
delete [] compute_which;
|
|
|
|
delete [] computes;
|
2007-01-30 08:22:05 +08:00
|
|
|
|
|
|
|
for (int i = 0; i < nfix; i++) delete [] id_fix[i];
|
|
|
|
delete [] id_fix;
|
|
|
|
delete [] fixes;
|
|
|
|
|
|
|
|
for (int i = 0; i < nvariable; i++) delete [] id_variable[i];
|
|
|
|
delete [] id_variable;
|
2008-01-03 03:24:46 +08:00
|
|
|
delete [] variables;
|
2007-01-30 08:22:05 +08:00
|
|
|
}
|
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
parse list of thermo keywords from str
|
2007-11-03 04:25:11 +08:00
|
|
|
set compute flags (temp, press, pe, etc)
|
2006-09-28 03:51:33 +08:00
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::parse_fields(char *str)
|
|
|
|
{
|
2007-01-30 08:22:05 +08:00
|
|
|
nfield = 0;
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
// customize a new keyword by adding to if statement
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
char *word = strtok(str," \0");
|
|
|
|
while (word) {
|
2007-01-30 08:22:05 +08:00
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
if (strcmp(word,"step") == 0) {
|
|
|
|
addfield("Step",&Thermo::compute_step,INT);
|
2010-03-04 02:40:02 +08:00
|
|
|
} else if (strcmp(word,"elapsed") == 0) {
|
|
|
|
addfield("Elapsed",&Thermo::compute_elapsed,INT);
|
|
|
|
} else if (strcmp(word,"elaplong") == 0) {
|
|
|
|
addfield("Elaplong",&Thermo::compute_elapsed_long,INT);
|
2009-12-04 04:54:54 +08:00
|
|
|
} else if (strcmp(word,"dt") == 0) {
|
|
|
|
addfield("Dt",&Thermo::compute_dt,FLOAT);
|
2010-03-04 02:40:02 +08:00
|
|
|
} else if (strcmp(word,"cpu") == 0) {
|
|
|
|
addfield("CPU",&Thermo::compute_cpu,FLOAT);
|
2010-05-21 01:04:06 +08:00
|
|
|
} else if (strcmp(word,"tpcpu") == 0) {
|
|
|
|
addfield("T/CPU",&Thermo::compute_tpcpu,FLOAT);
|
|
|
|
} else if (strcmp(word,"spcpu") == 0) {
|
|
|
|
addfield("S/CPU",&Thermo::compute_spcpu,FLOAT);
|
2007-02-10 05:26:30 +08:00
|
|
|
|
2010-03-04 02:40:02 +08:00
|
|
|
} else if (strcmp(word,"atoms") == 0) {
|
|
|
|
addfield("Atoms",&Thermo::compute_atoms,INT);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"temp") == 0) {
|
|
|
|
addfield("Temp",&Thermo::compute_temp,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_temp = add_compute(id_temp,SCALAR);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"press") == 0) {
|
|
|
|
addfield("Press",&Thermo::compute_press,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_press_scalar = add_compute(id_press,SCALAR);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"pe") == 0) {
|
|
|
|
addfield("PotEng",&Thermo::compute_pe,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_pe = add_compute(id_pe,SCALAR);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"ke") == 0) {
|
|
|
|
addfield("KinEng",&Thermo::compute_ke,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_temp = add_compute(id_temp,SCALAR);
|
2006-11-11 05:29:18 +08:00
|
|
|
} else if (strcmp(word,"etotal") == 0) {
|
|
|
|
addfield("TotEng",&Thermo::compute_etotal,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_temp = add_compute(id_temp,SCALAR);
|
|
|
|
index_pe = add_compute(id_pe,SCALAR);
|
2006-12-20 00:33:08 +08:00
|
|
|
} else if (strcmp(word,"enthalpy") == 0) {
|
2007-01-30 08:22:05 +08:00
|
|
|
addfield("Enthalpy",&Thermo::compute_enthalpy,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_temp = add_compute(id_temp,SCALAR);
|
|
|
|
index_press_scalar = add_compute(id_press,SCALAR);
|
|
|
|
index_pe = add_compute(id_pe,SCALAR);
|
2007-02-10 05:26:30 +08:00
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"evdwl") == 0) {
|
|
|
|
addfield("E_vdwl",&Thermo::compute_evdwl,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_pe = add_compute(id_pe,SCALAR);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"ecoul") == 0) {
|
|
|
|
addfield("E_coul",&Thermo::compute_ecoul,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_pe = add_compute(id_pe,SCALAR);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"epair") == 0) {
|
|
|
|
addfield("E_pair",&Thermo::compute_epair,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_pe = add_compute(id_pe,SCALAR);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"ebond") == 0) {
|
|
|
|
addfield("E_bond",&Thermo::compute_ebond,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_pe = add_compute(id_pe,SCALAR);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"eangle") == 0) {
|
|
|
|
addfield("E_angle",&Thermo::compute_eangle,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_pe = add_compute(id_pe,SCALAR);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"edihed") == 0) {
|
|
|
|
addfield("E_dihed",&Thermo::compute_edihed,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_pe = add_compute(id_pe,SCALAR);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"eimp") == 0) {
|
|
|
|
addfield("E_impro",&Thermo::compute_eimp,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_pe = add_compute(id_pe,SCALAR);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"emol") == 0) {
|
|
|
|
addfield("E_mol",&Thermo::compute_emol,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_pe = add_compute(id_pe,SCALAR);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"elong") == 0) {
|
|
|
|
addfield("E_long",&Thermo::compute_elong,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_pe = add_compute(id_pe,SCALAR);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"etail") == 0) {
|
|
|
|
addfield("E_tail",&Thermo::compute_etail,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_pe = add_compute(id_pe,SCALAR);
|
2007-02-10 05:26:30 +08:00
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"vol") == 0) {
|
|
|
|
addfield("Volume",&Thermo::compute_vol,FLOAT);
|
|
|
|
} else if (strcmp(word,"lx") == 0) {
|
|
|
|
addfield("Lx",&Thermo::compute_lx,FLOAT);
|
|
|
|
} else if (strcmp(word,"ly") == 0) {
|
|
|
|
addfield("Ly",&Thermo::compute_ly,FLOAT);
|
|
|
|
} else if (strcmp(word,"lz") == 0) {
|
|
|
|
addfield("Lz",&Thermo::compute_lz,FLOAT);
|
2007-02-10 05:26:30 +08:00
|
|
|
|
|
|
|
} else if (strcmp(word,"xlo") == 0) {
|
|
|
|
addfield("Xlo",&Thermo::compute_xlo,FLOAT);
|
|
|
|
} else if (strcmp(word,"xhi") == 0) {
|
|
|
|
addfield("Xhi",&Thermo::compute_xhi,FLOAT);
|
|
|
|
} else if (strcmp(word,"ylo") == 0) {
|
|
|
|
addfield("Ylo",&Thermo::compute_ylo,FLOAT);
|
|
|
|
} else if (strcmp(word,"yhi") == 0) {
|
|
|
|
addfield("Yhi",&Thermo::compute_yhi,FLOAT);
|
|
|
|
} else if (strcmp(word,"zlo") == 0) {
|
|
|
|
addfield("Zlo",&Thermo::compute_zlo,FLOAT);
|
|
|
|
} else if (strcmp(word,"zhi") == 0) {
|
|
|
|
addfield("Zhi",&Thermo::compute_zhi,FLOAT);
|
|
|
|
|
2008-02-06 08:03:11 +08:00
|
|
|
} else if (strcmp(word,"xy") == 0) {
|
|
|
|
addfield("Xy",&Thermo::compute_xy,FLOAT);
|
|
|
|
} else if (strcmp(word,"xz") == 0) {
|
|
|
|
addfield("Xz",&Thermo::compute_xz,FLOAT);
|
|
|
|
} else if (strcmp(word,"yz") == 0) {
|
|
|
|
addfield("Yz",&Thermo::compute_yz,FLOAT);
|
|
|
|
|
2010-02-09 05:41:24 +08:00
|
|
|
} else if (strcmp(word,"xlat") == 0) {
|
|
|
|
if (domain->lattice == NULL)
|
|
|
|
error->all("Thermo keyword requires lattice be defined");
|
|
|
|
addfield("Xlat",&Thermo::compute_xlat,FLOAT);
|
|
|
|
} else if (strcmp(word,"ylat") == 0) {
|
|
|
|
if (domain->lattice == NULL)
|
|
|
|
error->all("Thermo keyword requires lattice be defined");
|
|
|
|
addfield("Ylat",&Thermo::compute_ylat,FLOAT);
|
|
|
|
} else if (strcmp(word,"zlat") == 0) {
|
|
|
|
if (domain->lattice == NULL)
|
|
|
|
error->all("Thermo keyword requires lattice be defined");
|
|
|
|
addfield("Zlat",&Thermo::compute_zlat,FLOAT);
|
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"pxx") == 0) {
|
|
|
|
addfield("Pxx",&Thermo::compute_pxx,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_press_vector = add_compute(id_press,VECTOR);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"pyy") == 0) {
|
|
|
|
addfield("Pyy",&Thermo::compute_pyy,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_press_vector = add_compute(id_press,VECTOR);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"pzz") == 0) {
|
|
|
|
addfield("Pzz",&Thermo::compute_pzz,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_press_vector = add_compute(id_press,VECTOR);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"pxy") == 0) {
|
|
|
|
addfield("Pxy",&Thermo::compute_pxy,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_press_vector = add_compute(id_press,VECTOR);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"pxz") == 0) {
|
|
|
|
addfield("Pxz",&Thermo::compute_pxz,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_press_vector = add_compute(id_press,VECTOR);
|
2006-09-28 03:51:33 +08:00
|
|
|
} else if (strcmp(word,"pyz") == 0) {
|
|
|
|
addfield("Pyz",&Thermo::compute_pyz,FLOAT);
|
2009-12-10 05:12:49 +08:00
|
|
|
index_press_vector = add_compute(id_press,VECTOR);
|
2007-02-10 05:26:30 +08:00
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
// compute value = c_ID, fix value = f_ID, variable value = v_ID
|
2009-12-10 05:12:49 +08:00
|
|
|
// count trailing [] and store int arguments
|
2007-01-30 08:22:05 +08:00
|
|
|
// copy = at most 8 chars of ID to pass to addfield
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
} else if ((strncmp(word,"c_",2) == 0) || (strncmp(word,"f_",2) == 0) ||
|
|
|
|
(strncmp(word,"v_",2) == 0)) {
|
|
|
|
|
|
|
|
int n = strlen(word);
|
|
|
|
char *id = new char[n];
|
|
|
|
strcpy(id,&word[2]);
|
2006-09-28 03:51:33 +08:00
|
|
|
char copy[9];
|
2007-01-30 08:22:05 +08:00
|
|
|
strncpy(copy,id,8);
|
2006-09-28 03:51:33 +08:00
|
|
|
copy[8] = '\0';
|
2007-01-30 08:22:05 +08:00
|
|
|
|
2009-12-10 05:12:49 +08:00
|
|
|
// parse zero or one or two trailing brackets from ID
|
|
|
|
// argindex1,argindex2 = int inside each bracket pair, 0 if no bracket
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
char *ptr = strchr(id,'[');
|
2009-12-10 05:12:49 +08:00
|
|
|
if (ptr == NULL) argindex1[nfield] = 0;
|
|
|
|
else {
|
2007-01-30 08:22:05 +08:00
|
|
|
*ptr = '\0';
|
2009-12-10 05:12:49 +08:00
|
|
|
argindex1[nfield] = input->variable->int_between_brackets(ptr);
|
|
|
|
ptr++;
|
|
|
|
if (*ptr == '[') {
|
|
|
|
argindex2[nfield] = input->variable->int_between_brackets(ptr);
|
|
|
|
ptr++;
|
|
|
|
} else argindex2[nfield] = 0;
|
|
|
|
}
|
2007-01-30 08:22:05 +08:00
|
|
|
|
|
|
|
if (word[0] == 'c') {
|
|
|
|
n = modify->find_compute(id);
|
|
|
|
if (n < 0) error->all("Could not find thermo custom compute ID");
|
2009-12-10 05:12:49 +08:00
|
|
|
if (argindex1[nfield] == 0 && modify->compute[n]->scalar_flag == 0)
|
|
|
|
error->all("Thermo compute does not compute scalar");
|
|
|
|
if (argindex1[nfield] > 0 && argindex2[nfield] == 0) {
|
|
|
|
if (modify->compute[n]->vector_flag == 0)
|
|
|
|
error->all("Thermo compute does not compute vector");
|
|
|
|
if (argindex1[nfield] > modify->compute[n]->size_vector)
|
|
|
|
error->all("Thermo compute vector is accessed out-of-range");
|
|
|
|
}
|
|
|
|
if (argindex1[nfield] > 0 && argindex2[nfield] > 0) {
|
|
|
|
if (modify->compute[n]->array_flag == 0)
|
|
|
|
error->all("Thermo compute does not compute array");
|
|
|
|
if (argindex1[nfield] > modify->compute[n]->size_array_rows ||
|
|
|
|
argindex2[nfield] > modify->compute[n]->size_array_cols)
|
|
|
|
error->all("Thermo compute array is accessed out-of-range");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argindex1[nfield] == 0)
|
|
|
|
field2index[nfield] = add_compute(id,SCALAR);
|
|
|
|
else if (argindex2[nfield] == 0)
|
|
|
|
field2index[nfield] = add_compute(id,VECTOR);
|
|
|
|
else
|
|
|
|
field2index[nfield] = add_compute(id,ARRAY);
|
2007-01-30 08:22:05 +08:00
|
|
|
addfield(copy,&Thermo::compute_compute,FLOAT);
|
|
|
|
|
|
|
|
} else if (word[0] == 'f') {
|
|
|
|
n = modify->find_fix(id);
|
|
|
|
if (n < 0) error->all("Could not find thermo custom fix ID");
|
2009-12-10 05:12:49 +08:00
|
|
|
if (argindex1[nfield] == 0 && modify->fix[n]->scalar_flag == 0)
|
|
|
|
error->all("Thermo fix does not compute scalar");
|
|
|
|
if (argindex1[nfield] > 0 && argindex2[nfield] == 0) {
|
|
|
|
if (modify->fix[n]->vector_flag == 0)
|
|
|
|
error->all("Thermo fix does not compute vector");
|
|
|
|
if (argindex1[nfield] > modify->fix[n]->size_vector)
|
|
|
|
error->all("Thermo fix vector is accessed out-of-range");
|
|
|
|
}
|
|
|
|
if (argindex1[nfield] > 0 && argindex2[nfield] > 0) {
|
|
|
|
if (modify->fix[n]->array_flag == 0)
|
|
|
|
error->all("Thermo fix does not compute array");
|
|
|
|
if (argindex1[nfield] > modify->fix[n]->size_array_rows ||
|
|
|
|
argindex2[nfield] > modify->fix[n]->size_array_cols)
|
|
|
|
error->all("Thermo fix array is accessed out-of-range");
|
|
|
|
}
|
2008-01-03 03:24:46 +08:00
|
|
|
|
|
|
|
field2index[nfield] = add_fix(id);
|
2007-01-30 08:22:05 +08:00
|
|
|
addfield(copy,&Thermo::compute_fix,FLOAT);
|
|
|
|
|
2008-01-03 03:24:46 +08:00
|
|
|
} else if (word[0] == 'v') {
|
2007-01-30 08:22:05 +08:00
|
|
|
n = input->variable->find(id);
|
2008-01-03 03:24:46 +08:00
|
|
|
if (n < 0) error->all("Could not find thermo custom variable name");
|
|
|
|
if (input->variable->equalstyle(n) == 0)
|
|
|
|
error->all("Thermo custom variable is not equal-style variable");
|
2009-12-10 05:12:49 +08:00
|
|
|
if (argindex1[nfield])
|
|
|
|
error->all("Thermo custom variable cannot be indexed");
|
2008-01-03 03:24:46 +08:00
|
|
|
|
|
|
|
field2index[nfield] = add_variable(id);
|
2007-01-30 08:22:05 +08:00
|
|
|
addfield(copy,&Thermo::compute_variable,FLOAT);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete [] id;
|
|
|
|
|
|
|
|
} else error->all("Invalid keyword in thermo_style custom command");
|
2006-09-28 03:51:33 +08:00
|
|
|
|
|
|
|
word = strtok(NULL," \0");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
2007-01-30 08:22:05 +08:00
|
|
|
add field to list of quantities to print
|
2006-09-28 03:51:33 +08:00
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
2007-10-04 00:22:30 +08:00
|
|
|
void Thermo::addfield(const char *key, FnPtr func, int typeflag)
|
2006-09-28 03:51:33 +08:00
|
|
|
{
|
|
|
|
strcpy(keyword[nfield],key);
|
|
|
|
vfunc[nfield] = func;
|
|
|
|
vtype[nfield] = typeflag;
|
|
|
|
nfield++;
|
|
|
|
}
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
add compute ID to list of Compute objects to call
|
2007-10-27 04:14:48 +08:00
|
|
|
return location of where this Compute is in list
|
2008-01-03 03:24:46 +08:00
|
|
|
if already in list with same which, do not add, just return index
|
2007-01-30 08:22:05 +08:00
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
2008-01-03 03:24:46 +08:00
|
|
|
int Thermo::add_compute(const char *id, int which)
|
2007-01-30 08:22:05 +08:00
|
|
|
{
|
|
|
|
int icompute;
|
|
|
|
for (icompute = 0; icompute < ncompute; icompute++)
|
2008-01-03 03:24:46 +08:00
|
|
|
if ((strcmp(id,id_compute[icompute]) == 0) &&
|
|
|
|
which == compute_which[icompute]) break;
|
2007-01-30 08:22:05 +08:00
|
|
|
if (icompute < ncompute) return icompute;
|
|
|
|
|
|
|
|
int n = strlen(id) + 1;
|
|
|
|
id_compute[ncompute] = new char[n];
|
|
|
|
strcpy(id_compute[ncompute],id);
|
2008-01-03 03:24:46 +08:00
|
|
|
compute_which[ncompute] = which;
|
2007-01-30 08:22:05 +08:00
|
|
|
ncompute++;
|
|
|
|
return ncompute-1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
add fix ID to list of Fix objects to call
|
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
2007-10-04 00:22:30 +08:00
|
|
|
int Thermo::add_fix(const char *id)
|
2007-01-30 08:22:05 +08:00
|
|
|
{
|
|
|
|
int n = strlen(id) + 1;
|
|
|
|
id_fix[nfix] = new char[n];
|
|
|
|
strcpy(id_fix[nfix],id);
|
|
|
|
nfix++;
|
|
|
|
return nfix-1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
add variable ID to list of Variables to evaluate
|
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
2007-10-04 00:22:30 +08:00
|
|
|
int Thermo::add_variable(const char *id)
|
2007-01-30 08:22:05 +08:00
|
|
|
{
|
|
|
|
int n = strlen(id) + 1;
|
|
|
|
id_variable[nvariable] = new char[n];
|
|
|
|
strcpy(id_variable[nvariable],id);
|
|
|
|
nvariable++;
|
|
|
|
return nvariable-1;
|
|
|
|
}
|
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
/* ----------------------------------------------------------------------
|
2009-01-06 06:26:08 +08:00
|
|
|
compute a single thermodyanmic value, word is any keyword in custom list
|
2007-11-03 04:25:11 +08:00
|
|
|
called when a variable is evaluated by Variable class
|
2007-01-30 08:22:05 +08:00
|
|
|
return value as double in answer
|
2009-01-06 06:26:08 +08:00
|
|
|
return 0 if str is recoginzed keyword, 1 if unrecognized
|
|
|
|
customize a new keyword by adding to if statement
|
2006-09-28 03:51:33 +08:00
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
int Thermo::evaluate_keyword(char *word, double *answer)
|
2006-09-28 03:51:33 +08:00
|
|
|
{
|
2009-01-06 06:26:08 +08:00
|
|
|
// invoke a lo-level thermo routine to compute the variable value
|
2009-01-10 05:31:31 +08:00
|
|
|
// if keyword requires a compute, error if thermo doesn't use the compute
|
2009-01-06 06:26:08 +08:00
|
|
|
// if inbetween runs and needed compute is not current, error
|
2009-01-10 05:31:31 +08:00
|
|
|
// if in middle of run and needed compute is not current, invoke it
|
2009-01-06 06:26:08 +08:00
|
|
|
// for keywords that use pe indirectly (evdwl, ebond, etc):
|
|
|
|
// check if energy was tallied on this timestep and set pe->invoked_flag
|
2009-01-10 05:31:31 +08:00
|
|
|
// this will trigger next timestep for energy tallying via addstep()
|
2009-01-06 06:26:08 +08:00
|
|
|
|
|
|
|
if (strcmp(word,"step") == 0) {
|
|
|
|
compute_step();
|
|
|
|
dvalue = ivalue;
|
|
|
|
|
2010-03-04 02:40:02 +08:00
|
|
|
} else if (strcmp(word,"elapsed") == 0) {
|
|
|
|
if (update->whichflag == 0)
|
|
|
|
error->all("This variable thermo keyword cannot be used between runs");
|
|
|
|
compute_elapsed();
|
2009-01-06 06:26:08 +08:00
|
|
|
dvalue = ivalue;
|
|
|
|
|
2010-03-04 02:40:02 +08:00
|
|
|
} else if (strcmp(word,"elaplong") == 0) {
|
|
|
|
if (update->whichflag == 0)
|
|
|
|
error->all("This variable thermo keyword cannot be used between runs");
|
|
|
|
compute_elapsed_long();
|
|
|
|
dvalue = ivalue;
|
|
|
|
|
|
|
|
} else if (strcmp(word,"dt") == 0) {
|
|
|
|
compute_dt();
|
|
|
|
|
2009-01-06 06:26:08 +08:00
|
|
|
} else if (strcmp(word,"cpu") == 0) {
|
2010-05-21 01:04:06 +08:00
|
|
|
if (update->whichflag == 0)
|
|
|
|
error->all("This variable thermo keyword cannot be used between runs");
|
2009-01-06 06:26:08 +08:00
|
|
|
compute_cpu();
|
|
|
|
|
2010-05-21 01:04:06 +08:00
|
|
|
} else if (strcmp(word,"tpcpu") == 0) {
|
|
|
|
if (update->whichflag == 0)
|
|
|
|
error->all("This variable thermo keyword cannot be used between runs");
|
|
|
|
compute_tpcpu();
|
|
|
|
|
|
|
|
} else if (strcmp(word,"spcpu") == 0) {
|
|
|
|
if (update->whichflag == 0)
|
|
|
|
error->all("This variable thermo keyword cannot be used between runs");
|
|
|
|
compute_spcpu();
|
|
|
|
|
2010-03-04 02:40:02 +08:00
|
|
|
} else if (strcmp(word,"atoms") == 0) {
|
|
|
|
compute_atoms();
|
|
|
|
dvalue = ivalue;
|
2009-12-04 04:54:54 +08:00
|
|
|
|
2009-01-06 06:26:08 +08:00
|
|
|
} else if (strcmp(word,"temp") == 0) {
|
2007-11-03 04:25:11 +08:00
|
|
|
if (!temperature)
|
2009-01-10 05:31:31 +08:00
|
|
|
error->all("Thermo keyword in variable requires "
|
|
|
|
"thermo to use/init temp");
|
2009-08-19 01:54:17 +08:00
|
|
|
if (update->whichflag == 0) {
|
2009-01-10 05:31:31 +08:00
|
|
|
if (temperature->invoked_scalar != update->ntimestep)
|
|
|
|
error->all("Compute used in variable thermo keyword between runs "
|
|
|
|
"is not current");
|
|
|
|
} else if (!(temperature->invoked_flag & INVOKED_SCALAR)) {
|
|
|
|
temperature->compute_scalar();
|
|
|
|
temperature->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
}
|
|
|
|
compute_temp();
|
|
|
|
|
|
|
|
} else if (strcmp(word,"press") == 0) {
|
|
|
|
if (!pressure)
|
2009-01-10 05:31:31 +08:00
|
|
|
error->all("Thermo keyword in variable requires "
|
|
|
|
"thermo to use/init press");
|
2009-08-19 01:54:17 +08:00
|
|
|
if (update->whichflag == 0) {
|
2009-01-10 05:31:31 +08:00
|
|
|
if (pressure->invoked_scalar != update->ntimestep)
|
|
|
|
error->all("Compute used in variable thermo keyword between runs "
|
|
|
|
"is not current");
|
|
|
|
} else if (!(pressure->invoked_flag & INVOKED_SCALAR)) {
|
|
|
|
pressure->compute_scalar();
|
|
|
|
pressure->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
}
|
|
|
|
compute_press();
|
|
|
|
|
|
|
|
} else if (strcmp(word,"pe") == 0) {
|
|
|
|
if (!pe)
|
|
|
|
error->all("Thermo keyword in variable requires thermo to use/init pe");
|
2009-08-19 01:54:17 +08:00
|
|
|
if (update->whichflag == 0) {
|
2009-01-10 05:31:31 +08:00
|
|
|
if (pe->invoked_scalar != update->ntimestep)
|
|
|
|
error->all("Compute used in variable thermo keyword between runs "
|
|
|
|
"is not current");
|
|
|
|
} else if (!(pe->invoked_flag & INVOKED_SCALAR)) {
|
|
|
|
pe->compute_scalar();
|
|
|
|
pe->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
}
|
|
|
|
compute_pe();
|
2007-11-03 04:25:11 +08:00
|
|
|
|
2009-01-06 06:26:08 +08:00
|
|
|
} else if (strcmp(word,"ke") == 0) {
|
|
|
|
if (!temperature)
|
2009-01-10 05:31:31 +08:00
|
|
|
error->all("Thermo keyword in variable requires "
|
|
|
|
"thermo to use/init temp");
|
2009-08-19 01:54:17 +08:00
|
|
|
if (update->whichflag == 0) {
|
2009-01-10 05:31:31 +08:00
|
|
|
if (temperature->invoked_scalar != update->ntimestep)
|
|
|
|
error->all("Compute used in variable thermo keyword between runs "
|
|
|
|
"is not current");
|
|
|
|
} else if (!(temperature->invoked_flag & INVOKED_SCALAR)) {
|
|
|
|
temperature->compute_scalar();
|
|
|
|
temperature->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
}
|
|
|
|
compute_ke();
|
|
|
|
|
|
|
|
} else if (strcmp(word,"etotal") == 0) {
|
|
|
|
if (!pe)
|
|
|
|
error->all("Thermo keyword in variable requires thermo to use/init pe");
|
2009-08-19 01:54:17 +08:00
|
|
|
if (update->whichflag == 0) {
|
2009-01-10 05:31:31 +08:00
|
|
|
if (pe->invoked_scalar != update->ntimestep)
|
|
|
|
error->all("Compute used in variable thermo keyword between runs "
|
|
|
|
"is not current");
|
|
|
|
} else if (!(pe->invoked_flag & INVOKED_SCALAR)) {
|
|
|
|
pe->compute_scalar();
|
|
|
|
pe->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
}
|
|
|
|
if (!temperature)
|
2009-01-10 05:31:31 +08:00
|
|
|
error->all("Thermo keyword in variable requires "
|
|
|
|
"thermo to use/init temp");
|
2009-08-19 01:54:17 +08:00
|
|
|
if (update->whichflag == 0) {
|
2009-01-10 05:31:31 +08:00
|
|
|
if (temperature->invoked_scalar != update->ntimestep)
|
|
|
|
error->all("Compute used in variable thermo keyword between runs "
|
|
|
|
"is not current");
|
|
|
|
} else if (!(temperature->invoked_flag & INVOKED_SCALAR)) {
|
|
|
|
temperature->compute_scalar();
|
|
|
|
temperature->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
}
|
|
|
|
compute_etotal();
|
|
|
|
|
|
|
|
} else if (strcmp(word,"enthalpy") == 0) {
|
|
|
|
if (!pe)
|
|
|
|
error->all("Thermo keyword in variable requires thermo to use/init pe");
|
2009-08-19 01:54:17 +08:00
|
|
|
if (update->whichflag == 0) {
|
2009-01-10 05:31:31 +08:00
|
|
|
if (pe->invoked_scalar != update->ntimestep)
|
|
|
|
error->all("Compute used in variable thermo keyword between runs "
|
|
|
|
"is not current");
|
|
|
|
} else if (!(pe->invoked_flag & INVOKED_SCALAR)) {
|
|
|
|
pe->compute_scalar();
|
|
|
|
pe->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
}
|
|
|
|
if (!temperature)
|
2009-01-10 05:31:31 +08:00
|
|
|
error->all("Thermo keyword in variable requires "
|
|
|
|
"thermo to use/init temp");
|
2009-08-19 01:54:17 +08:00
|
|
|
if (update->whichflag == 0) {
|
2009-01-10 05:31:31 +08:00
|
|
|
if (temperature->invoked_scalar != update->ntimestep)
|
|
|
|
error->all("Compute used in variable thermo keyword between runs "
|
|
|
|
"is not current");
|
|
|
|
} else if (!(temperature->invoked_flag & INVOKED_SCALAR)) {
|
|
|
|
temperature->compute_scalar();
|
|
|
|
temperature->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
}
|
2007-11-03 04:25:11 +08:00
|
|
|
if (!pressure)
|
2009-01-10 05:31:31 +08:00
|
|
|
error->all("Thermo keyword in variable requires "
|
|
|
|
"thermo to use/init press");
|
2009-08-19 01:54:17 +08:00
|
|
|
if (update->whichflag == 0) {
|
2009-01-10 05:31:31 +08:00
|
|
|
if (pressure->invoked_scalar != update->ntimestep)
|
|
|
|
error->all("Compute used in variable thermo keyword between runs "
|
|
|
|
"is not current");
|
|
|
|
} else if (!(pressure->invoked_flag & INVOKED_SCALAR)) {
|
|
|
|
pressure->compute_scalar();
|
|
|
|
pressure->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
}
|
|
|
|
compute_enthalpy();
|
2007-11-03 04:25:11 +08:00
|
|
|
|
2009-01-06 06:26:08 +08:00
|
|
|
} else if (strcmp(word,"evdwl") == 0) {
|
|
|
|
if (update->eflag_global != update->ntimestep)
|
|
|
|
error->all("Energy was not tallied on needed timestep");
|
2009-01-10 05:31:31 +08:00
|
|
|
if (!pe)
|
|
|
|
error->all("Thermo keyword in variable requires thermo to use/init pe");
|
|
|
|
pe->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
compute_evdwl();
|
2007-11-03 04:25:11 +08:00
|
|
|
|
2009-01-06 06:26:08 +08:00
|
|
|
} else if (strcmp(word,"ecoul") == 0) {
|
|
|
|
if (update->eflag_global != update->ntimestep)
|
|
|
|
error->all("Energy was not tallied on needed timestep");
|
2009-01-10 05:31:31 +08:00
|
|
|
if (!pe)
|
|
|
|
error->all("Thermo keyword in variable requires thermo to use/init pe");
|
|
|
|
pe->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
compute_ecoul();
|
2007-11-03 04:25:11 +08:00
|
|
|
|
2009-01-06 06:26:08 +08:00
|
|
|
} else if (strcmp(word,"epair") == 0) {
|
|
|
|
if (update->eflag_global != update->ntimestep)
|
|
|
|
error->all("Energy was not tallied on needed timestep");
|
2009-01-10 05:31:31 +08:00
|
|
|
if (!pe)
|
|
|
|
error->all("Thermo keyword in variable requires thermo to use/init pe");
|
|
|
|
pe->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
compute_epair();
|
|
|
|
|
|
|
|
} else if (strcmp(word,"ebond") == 0) {
|
|
|
|
if (update->eflag_global != update->ntimestep)
|
|
|
|
error->all("Energy was not tallied on needed timestep");
|
2009-01-10 05:31:31 +08:00
|
|
|
if (!pe)
|
|
|
|
error->all("Thermo keyword in variable requires thermo to use/init pe");
|
|
|
|
pe->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
compute_ebond();
|
2007-11-03 04:25:11 +08:00
|
|
|
|
2009-01-06 06:26:08 +08:00
|
|
|
} else if (strcmp(word,"eangle") == 0) {
|
|
|
|
if (update->eflag_global != update->ntimestep)
|
|
|
|
error->all("Energy was not tallied on needed timestep");
|
2009-01-10 05:31:31 +08:00
|
|
|
if (!pe)
|
|
|
|
error->all("Thermo keyword in variable requires thermo to use/init pe");
|
|
|
|
pe->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
compute_eangle();
|
2007-01-30 08:22:05 +08:00
|
|
|
|
2009-01-06 06:26:08 +08:00
|
|
|
} else if (strcmp(word,"edihed") == 0) {
|
|
|
|
if (update->eflag_global != update->ntimestep)
|
|
|
|
error->all("Energy was not tallied on needed timestep");
|
2009-01-10 05:31:31 +08:00
|
|
|
if (!pe)
|
|
|
|
error->all("Thermo keyword in variable requires thermo to use/init pe");
|
|
|
|
pe->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
compute_edihed();
|
2007-01-30 08:22:05 +08:00
|
|
|
|
2009-01-06 06:26:08 +08:00
|
|
|
} else if (strcmp(word,"eimp") == 0) {
|
|
|
|
if (update->eflag_global != update->ntimestep)
|
|
|
|
error->all("Energy was not tallied on needed timestep");
|
2009-01-10 05:31:31 +08:00
|
|
|
if (!pe)
|
|
|
|
error->all("Thermo keyword in variable requires thermo to use/init pe");
|
|
|
|
pe->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
compute_eimp();
|
2007-11-03 04:25:11 +08:00
|
|
|
|
2009-01-06 06:26:08 +08:00
|
|
|
} else if (strcmp(word,"emol") == 0) {
|
|
|
|
if (update->eflag_global != update->ntimestep)
|
|
|
|
error->all("Energy was not tallied on needed timestep");
|
2009-01-10 05:31:31 +08:00
|
|
|
if (!pe)
|
|
|
|
error->all("Thermo keyword in variable requires thermo to use/init pe");
|
|
|
|
pe->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
compute_emol();
|
2007-02-10 05:26:30 +08:00
|
|
|
|
2009-01-06 06:26:08 +08:00
|
|
|
} else if (strcmp(word,"elong") == 0) {
|
|
|
|
if (update->eflag_global != update->ntimestep)
|
|
|
|
error->all("Energy was not tallied on needed timestep");
|
2009-01-10 05:31:31 +08:00
|
|
|
if (!pe)
|
|
|
|
error->all("Thermo keyword in variable requires thermo to use/init pe");
|
|
|
|
pe->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
compute_elong();
|
2007-11-03 04:25:11 +08:00
|
|
|
|
2009-01-06 06:26:08 +08:00
|
|
|
} else if (strcmp(word,"etail") == 0) {
|
|
|
|
if (update->eflag_global != update->ntimestep)
|
|
|
|
error->all("Energy was not tallied on needed timestep");
|
2009-01-10 05:31:31 +08:00
|
|
|
if (!pe)
|
|
|
|
error->all("Thermo keyword in variable requires thermo to use/init pe");
|
|
|
|
pe->invoked_flag |= INVOKED_SCALAR;
|
2009-01-06 06:26:08 +08:00
|
|
|
compute_etail();
|
|
|
|
|
|
|
|
} else if (strcmp(word,"vol") == 0) compute_vol();
|
2007-01-30 08:22:05 +08:00
|
|
|
else if (strcmp(word,"lx") == 0) compute_lx();
|
|
|
|
else if (strcmp(word,"ly") == 0) compute_ly();
|
|
|
|
else if (strcmp(word,"lz") == 0) compute_lz();
|
2007-02-10 05:26:30 +08:00
|
|
|
|
|
|
|
else if (strcmp(word,"xlo") == 0) compute_xlo();
|
|
|
|
else if (strcmp(word,"xhi") == 0) compute_xhi();
|
|
|
|
else if (strcmp(word,"ylo") == 0) compute_ylo();
|
|
|
|
else if (strcmp(word,"yhi") == 0) compute_yhi();
|
|
|
|
else if (strcmp(word,"zlo") == 0) compute_zlo();
|
|
|
|
else if (strcmp(word,"zhi") == 0) compute_zhi();
|
|
|
|
|
2008-02-06 08:03:11 +08:00
|
|
|
else if (strcmp(word,"xy") == 0) compute_xy();
|
|
|
|
else if (strcmp(word,"xz") == 0) compute_xz();
|
|
|
|
else if (strcmp(word,"yz") == 0) compute_yz();
|
|
|
|
|
2010-02-09 05:41:24 +08:00
|
|
|
else if (strcmp(word,"xlat") == 0) {
|
|
|
|
if (domain->lattice == NULL)
|
|
|
|
error->all("Thermo keyword in variable requires lattice be defined");
|
|
|
|
compute_xlat();
|
|
|
|
} else if (strcmp(word,"ylat") == 0) {
|
|
|
|
if (domain->lattice == NULL)
|
|
|
|
error->all("Thermo keyword in variable requires lattice be defined");
|
|
|
|
compute_ylat();
|
|
|
|
} else if (strcmp(word,"zlat") == 0) {
|
|
|
|
if (domain->lattice == NULL)
|
|
|
|
error->all("Thermo keyword in variable requires lattice be defined");
|
|
|
|
compute_zlat();
|
|
|
|
|
|
|
|
} else if (strcmp(word,"pxx") == 0) {
|
2009-01-06 06:26:08 +08:00
|
|
|
if (!pressure)
|
2009-01-10 05:31:31 +08:00
|
|
|
error->all("Thermo keyword in variable requires "
|
|
|
|
"thermo to use/init press");
|
2009-08-19 01:54:17 +08:00
|
|
|
if (update->whichflag == 0) {
|
2009-01-10 05:31:31 +08:00
|
|
|
if (pressure->invoked_vector != update->ntimestep)
|
|
|
|
error->all("Compute used in variable thermo keyword between runs "
|
|
|
|
"is not current");
|
|
|
|
} else if (!(pressure->invoked_flag & INVOKED_VECTOR)) {
|
|
|
|
pressure->compute_vector();
|
|
|
|
pressure->invoked_flag |= INVOKED_VECTOR;
|
2009-01-06 06:26:08 +08:00
|
|
|
}
|
|
|
|
compute_pxx();
|
2007-02-10 05:26:30 +08:00
|
|
|
|
2009-01-06 06:26:08 +08:00
|
|
|
} else if (strcmp(word,"pyy") == 0) {
|
|
|
|
if (!pressure)
|
2009-01-10 05:31:31 +08:00
|
|
|
error->all("Thermo keyword in variable requires "
|
|
|
|
"thermo to use/init press");
|
2009-08-19 01:54:17 +08:00
|
|
|
if (update->whichflag == 0) {
|
2009-01-10 05:31:31 +08:00
|
|
|
if (pressure->invoked_vector != update->ntimestep)
|
|
|
|
error->all("Compute used in variable thermo keyword between runs "
|
|
|
|
"is not current");
|
|
|
|
} else if (!(pressure->invoked_flag & INVOKED_VECTOR)) {
|
|
|
|
pressure->compute_vector();
|
|
|
|
pressure->invoked_flag |= INVOKED_VECTOR;
|
2009-01-06 06:26:08 +08:00
|
|
|
}
|
|
|
|
compute_pyy();
|
2007-01-30 08:22:05 +08:00
|
|
|
|
2009-01-06 06:26:08 +08:00
|
|
|
} else if (strcmp(word,"pzz") == 0) {
|
|
|
|
if (!pressure)
|
2009-01-10 05:31:31 +08:00
|
|
|
error->all("Thermo keyword in variable requires "
|
|
|
|
"thermo to use/init press");
|
2009-08-19 01:54:17 +08:00
|
|
|
if (update->whichflag == 0) {
|
2009-01-10 05:31:31 +08:00
|
|
|
if (pressure->invoked_vector != update->ntimestep)
|
|
|
|
error->all("Compute used in variable thermo keyword between runs "
|
|
|
|
"is not current");
|
|
|
|
} else if (!(pressure->invoked_flag & INVOKED_VECTOR)) {
|
|
|
|
pressure->compute_vector();
|
|
|
|
pressure->invoked_flag |= INVOKED_VECTOR;
|
2009-01-06 06:26:08 +08:00
|
|
|
}
|
|
|
|
compute_pzz();
|
|
|
|
|
|
|
|
} else if (strcmp(word,"pxy") == 0) {
|
|
|
|
if (!pressure)
|
2009-01-10 05:31:31 +08:00
|
|
|
error->all("Thermo keyword in variable requires "
|
|
|
|
"thermo to use/init press");
|
2009-08-19 01:54:17 +08:00
|
|
|
if (update->whichflag == 0) {
|
2009-01-10 05:31:31 +08:00
|
|
|
if (pressure->invoked_vector != update->ntimestep)
|
|
|
|
error->all("Compute used in variable thermo keyword between runs "
|
|
|
|
"is not current");
|
|
|
|
} else if (!(pressure->invoked_flag & INVOKED_VECTOR)) {
|
|
|
|
pressure->compute_vector();
|
|
|
|
pressure->invoked_flag |= INVOKED_VECTOR;
|
2009-01-06 06:26:08 +08:00
|
|
|
}
|
|
|
|
compute_pxy();
|
|
|
|
|
|
|
|
} else if (strcmp(word,"pxz") == 0) {
|
|
|
|
if (!pressure)
|
2009-01-10 05:31:31 +08:00
|
|
|
error->all("Thermo keyword in variable requires "
|
|
|
|
"thermo to use/init press");
|
2009-08-19 01:54:17 +08:00
|
|
|
if (update->whichflag == 0) {
|
2009-01-10 05:31:31 +08:00
|
|
|
if (pressure->invoked_vector != update->ntimestep)
|
|
|
|
error->all("Compute used in variable thermo keyword between runs "
|
|
|
|
"is not current");
|
|
|
|
} else if (!(pressure->invoked_flag & INVOKED_VECTOR)) {
|
|
|
|
pressure->compute_vector();
|
|
|
|
pressure->invoked_flag |= INVOKED_VECTOR;
|
2009-01-06 06:26:08 +08:00
|
|
|
}
|
|
|
|
compute_pxz();
|
|
|
|
|
|
|
|
} else if (strcmp(word,"pyz") == 0) {
|
|
|
|
if (!pressure)
|
2009-01-10 05:31:31 +08:00
|
|
|
error->all("Thermo keyword in variable requires "
|
|
|
|
"thermo to use/init press");
|
2009-08-19 01:54:17 +08:00
|
|
|
if (update->whichflag == 0) {
|
2009-01-10 05:31:31 +08:00
|
|
|
if (pressure->invoked_vector != update->ntimestep)
|
|
|
|
error->all("Compute used in variable thermo keyword between runs "
|
|
|
|
"is not current");
|
|
|
|
} else if (!(pressure->invoked_flag & INVOKED_VECTOR)) {
|
|
|
|
pressure->compute_vector();
|
|
|
|
pressure->invoked_flag |= INVOKED_VECTOR;
|
2009-01-06 06:26:08 +08:00
|
|
|
}
|
|
|
|
compute_pyz();
|
|
|
|
|
|
|
|
} else return 1;
|
2007-01-30 08:22:05 +08:00
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
*answer = dvalue;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
2007-01-30 08:22:05 +08:00
|
|
|
extraction of Compute, Fix, Variable results
|
2008-01-03 03:24:46 +08:00
|
|
|
compute/fix are normalized by atoms if returning extensive value
|
|
|
|
variable value is not normalized (formula should normalize if desired)
|
2006-09-28 03:51:33 +08:00
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_compute()
|
|
|
|
{
|
2009-12-10 05:12:49 +08:00
|
|
|
int m = field2index[ifield];
|
|
|
|
Compute *compute = computes[m];
|
|
|
|
|
|
|
|
if (compute_which[m] == SCALAR) {
|
2008-01-03 03:24:46 +08:00
|
|
|
dvalue = compute->scalar;
|
|
|
|
if (normflag && compute->extscalar) dvalue /= natoms;
|
2009-12-10 05:12:49 +08:00
|
|
|
} else if (compute_which[m] == VECTOR) {
|
|
|
|
dvalue = compute->vector[argindex1[ifield]-1];
|
2008-01-03 03:24:46 +08:00
|
|
|
if (normflag) {
|
|
|
|
if (compute->extvector == 0) return;
|
|
|
|
else if (compute->extvector == 1) dvalue /= natoms;
|
2009-12-10 05:12:49 +08:00
|
|
|
else if (compute->extlist[argindex1[ifield]-1]) dvalue /= natoms;
|
2008-01-03 03:24:46 +08:00
|
|
|
}
|
2009-12-10 05:12:49 +08:00
|
|
|
} else {
|
|
|
|
dvalue = compute->array[argindex1[ifield]-1][argindex2[ifield]-1];
|
|
|
|
if (normflag && compute->extarray) dvalue /= natoms;
|
2008-01-03 03:24:46 +08:00
|
|
|
}
|
2007-01-30 08:22:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_fix()
|
2006-09-28 03:51:33 +08:00
|
|
|
{
|
2009-12-10 05:12:49 +08:00
|
|
|
int m = field2index[ifield];
|
|
|
|
Fix *fix = fixes[m];
|
|
|
|
|
|
|
|
if (argindex1[ifield] == 0) {
|
2008-01-03 03:24:46 +08:00
|
|
|
dvalue = fix->compute_scalar();
|
|
|
|
if (normflag && fix->extscalar) dvalue /= natoms;
|
2009-12-10 05:12:49 +08:00
|
|
|
} else if (argindex2[ifield] == 0) {
|
|
|
|
dvalue = fix->compute_vector(argindex1[ifield]-1);
|
2008-01-03 03:24:46 +08:00
|
|
|
if (normflag) {
|
|
|
|
if (fix->extvector == 0) return;
|
|
|
|
else if (fix->extvector == 1) dvalue /= natoms;
|
2009-12-10 05:12:49 +08:00
|
|
|
else if (fix->extlist[argindex1[ifield]-1]) dvalue /= natoms;
|
2008-01-03 03:24:46 +08:00
|
|
|
}
|
2009-12-10 05:12:49 +08:00
|
|
|
} else {
|
|
|
|
dvalue = fix->compute_array(argindex1[ifield]-1,argindex2[ifield]-1);
|
|
|
|
if (normflag && fix->extarray) dvalue /= natoms;
|
2008-01-03 03:24:46 +08:00
|
|
|
}
|
2007-01-30 08:22:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_variable()
|
|
|
|
{
|
2009-01-10 05:31:31 +08:00
|
|
|
dvalue = input->variable->compute_equal(variables[field2index[ifield]]);
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
2008-01-03 03:24:46 +08:00
|
|
|
one method for every keyword thermo can output
|
2009-01-06 06:26:08 +08:00
|
|
|
called by compute() or evaluate_keyword()
|
|
|
|
compute will have already been called
|
2006-09-28 03:51:33 +08:00
|
|
|
set ivalue/dvalue if value is integer/double
|
2007-01-30 08:22:05 +08:00
|
|
|
customize a new keyword by adding a method
|
2006-09-28 03:51:33 +08:00
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_step()
|
|
|
|
{
|
|
|
|
ivalue = update->ntimestep;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2010-03-04 02:40:02 +08:00
|
|
|
void Thermo::compute_elapsed()
|
2006-09-28 03:51:33 +08:00
|
|
|
{
|
2010-03-04 02:40:02 +08:00
|
|
|
ivalue = update->ntimestep - update->firststep;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_elapsed_long()
|
|
|
|
{
|
|
|
|
ivalue = update->ntimestep - update->beginstep;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_dt()
|
|
|
|
{
|
|
|
|
dvalue = update->dt;
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_cpu()
|
|
|
|
{
|
|
|
|
if (firststep == 0) dvalue = 0.0;
|
|
|
|
else dvalue = timer->elapsed(TIME_LOOP);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2010-05-21 01:04:06 +08:00
|
|
|
void Thermo::compute_tpcpu()
|
|
|
|
{
|
|
|
|
double new_cpu;
|
|
|
|
double new_time = update->ntimestep * update->dt;
|
|
|
|
|
|
|
|
if (firststep == 0) {
|
|
|
|
new_cpu = 0.0;
|
|
|
|
dvalue = 0.0;
|
|
|
|
} else {
|
|
|
|
new_cpu = timer->elapsed(TIME_LOOP);
|
|
|
|
double cpu_diff = new_cpu - last_tpcpu;
|
|
|
|
double time_diff = new_time - last_time;
|
|
|
|
if (time_diff > 0.0 && cpu_diff > 0.0) dvalue = time_diff/cpu_diff;
|
|
|
|
else dvalue = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
last_time = new_time;
|
|
|
|
last_tpcpu = new_cpu;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_spcpu()
|
|
|
|
{
|
|
|
|
double new_cpu;
|
|
|
|
int new_step = update->ntimestep;
|
|
|
|
|
|
|
|
if (firststep == 0) {
|
|
|
|
new_cpu = 0.0;
|
|
|
|
dvalue = 0.0;
|
|
|
|
} else {
|
|
|
|
new_cpu = timer->elapsed(TIME_LOOP);
|
|
|
|
double cpu_diff = new_cpu - last_spcpu;
|
|
|
|
int step_diff = new_step - last_step;
|
|
|
|
if (cpu_diff > 0.0) dvalue = step_diff/cpu_diff;
|
|
|
|
else dvalue = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
last_step = new_step;
|
|
|
|
last_spcpu = new_cpu;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2010-03-04 02:40:02 +08:00
|
|
|
void Thermo::compute_atoms()
|
2009-12-04 04:54:54 +08:00
|
|
|
{
|
2010-03-04 02:40:02 +08:00
|
|
|
ivalue = static_cast<int> (natoms);
|
2009-12-04 04:54:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
void Thermo::compute_temp()
|
|
|
|
{
|
2009-01-06 06:26:08 +08:00
|
|
|
dvalue = temperature->scalar;
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_press()
|
|
|
|
{
|
2009-01-06 06:26:08 +08:00
|
|
|
dvalue = pressure->scalar;
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_pe()
|
|
|
|
{
|
2009-01-06 06:26:08 +08:00
|
|
|
dvalue = pe->scalar;
|
2006-09-28 03:51:33 +08:00
|
|
|
if (normflag) dvalue /= natoms;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_ke()
|
|
|
|
{
|
2009-01-06 06:26:08 +08:00
|
|
|
dvalue = temperature->scalar;
|
2007-01-30 08:22:05 +08:00
|
|
|
dvalue *= 0.5 * temperature->dof * force->boltz;
|
2006-09-28 03:51:33 +08:00
|
|
|
if (normflag) dvalue /= natoms;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2006-11-11 05:29:18 +08:00
|
|
|
void Thermo::compute_etotal()
|
2006-09-28 03:51:33 +08:00
|
|
|
{
|
|
|
|
compute_pe();
|
2009-01-06 06:26:08 +08:00
|
|
|
double ke = temperature->scalar;
|
2007-01-30 08:22:05 +08:00
|
|
|
ke *= 0.5 * temperature->dof * force->boltz;
|
2006-09-28 03:51:33 +08:00
|
|
|
if (normflag) ke /= natoms;
|
|
|
|
dvalue += ke;
|
|
|
|
}
|
|
|
|
|
2006-12-20 00:33:08 +08:00
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_enthalpy()
|
|
|
|
{
|
|
|
|
compute_etotal();
|
|
|
|
double etmp = dvalue;
|
|
|
|
|
|
|
|
compute_vol();
|
|
|
|
double vtmp = dvalue;
|
|
|
|
if (normflag) vtmp /= natoms;
|
|
|
|
|
|
|
|
compute_press();
|
|
|
|
double ptmp = dvalue;
|
|
|
|
|
|
|
|
dvalue = etmp + ptmp*vtmp/(force->nktv2p);
|
|
|
|
}
|
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_evdwl()
|
|
|
|
{
|
|
|
|
double tmp = 0.0;
|
|
|
|
if (force->pair) tmp += force->pair->eng_vdwl;
|
|
|
|
MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world);
|
|
|
|
|
2006-10-13 06:48:04 +08:00
|
|
|
if (force->pair && force->pair->tail_flag) {
|
2006-09-28 03:51:33 +08:00
|
|
|
double volume = domain->xprd * domain->yprd * domain->zprd;
|
|
|
|
dvalue += force->pair->etail / volume;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (normflag) dvalue /= natoms;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_ecoul()
|
|
|
|
{
|
|
|
|
double tmp = 0.0;
|
|
|
|
if (force->pair) tmp += force->pair->eng_coul;
|
|
|
|
MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world);
|
|
|
|
if (normflag) dvalue /= natoms;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_epair()
|
|
|
|
{
|
|
|
|
double tmp = 0.0;
|
|
|
|
if (force->pair) tmp += force->pair->eng_vdwl + force->pair->eng_coul;
|
|
|
|
MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world);
|
|
|
|
|
|
|
|
if (force->kspace) dvalue += force->kspace->energy;
|
2006-10-13 06:48:04 +08:00
|
|
|
if (force->pair && force->pair->tail_flag) {
|
2006-09-28 03:51:33 +08:00
|
|
|
double volume = domain->xprd * domain->yprd * domain->zprd;
|
|
|
|
dvalue += force->pair->etail / volume;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (normflag) dvalue /= natoms;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_ebond()
|
|
|
|
{
|
|
|
|
if (force->bond) {
|
|
|
|
double tmp = force->bond->energy;
|
|
|
|
MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world);
|
|
|
|
if (normflag) dvalue /= natoms;
|
|
|
|
} else dvalue = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_eangle()
|
|
|
|
{
|
|
|
|
if (force->angle) {
|
|
|
|
double tmp = force->angle->energy;
|
|
|
|
MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world);
|
|
|
|
if (normflag) dvalue /= natoms;
|
|
|
|
} else dvalue = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_edihed()
|
|
|
|
{
|
|
|
|
if (force->dihedral) {
|
|
|
|
double tmp = force->dihedral->energy;
|
|
|
|
MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world);
|
|
|
|
if (normflag) dvalue /= natoms;
|
|
|
|
} else dvalue = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_eimp()
|
|
|
|
{
|
|
|
|
if (force->improper) {
|
|
|
|
double tmp = force->improper->energy;
|
|
|
|
MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world);
|
|
|
|
if (normflag) dvalue /= natoms;
|
|
|
|
} else dvalue = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_emol()
|
|
|
|
{
|
|
|
|
double tmp = 0.0;
|
|
|
|
if (atom->molecular) {
|
|
|
|
if (force->bond) tmp += force->bond->energy;
|
|
|
|
if (force->angle) tmp += force->angle->energy;
|
|
|
|
if (force->dihedral) tmp += force->dihedral->energy;
|
|
|
|
if (force->improper) tmp += force->improper->energy;
|
|
|
|
MPI_Allreduce(&tmp,&dvalue,1,MPI_DOUBLE,MPI_SUM,world);
|
|
|
|
if (normflag) dvalue /= natoms;
|
|
|
|
} else dvalue = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_elong()
|
|
|
|
{
|
|
|
|
if (force->kspace) {
|
|
|
|
dvalue = force->kspace->energy;
|
|
|
|
if (normflag) dvalue /= natoms;
|
|
|
|
} else dvalue = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_etail()
|
|
|
|
{
|
2006-10-13 06:48:04 +08:00
|
|
|
if (force->pair && force->pair->tail_flag) {
|
2006-09-28 03:51:33 +08:00
|
|
|
double volume = domain->xprd * domain->yprd * domain->zprd;
|
|
|
|
dvalue = force->pair->etail / volume;
|
|
|
|
if (normflag) dvalue /= natoms;
|
|
|
|
} else dvalue = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_vol()
|
|
|
|
{
|
2007-10-06 01:22:29 +08:00
|
|
|
if (domain->dimension == 3)
|
|
|
|
dvalue = domain->xprd * domain->yprd * domain->zprd;
|
|
|
|
else
|
|
|
|
dvalue = domain->xprd * domain->yprd;
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_lx()
|
|
|
|
{
|
|
|
|
dvalue = domain->xprd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_ly()
|
|
|
|
{
|
|
|
|
dvalue = domain->yprd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_lz()
|
|
|
|
{
|
|
|
|
dvalue = domain->zprd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
2007-02-10 05:26:30 +08:00
|
|
|
|
|
|
|
void Thermo::compute_xlo()
|
|
|
|
{
|
2007-03-16 07:38:38 +08:00
|
|
|
dvalue = domain->boxlo[0];
|
2007-02-10 05:26:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_xhi()
|
|
|
|
{
|
2007-03-16 07:38:38 +08:00
|
|
|
dvalue = domain->boxhi[0];
|
2007-02-10 05:26:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_ylo()
|
|
|
|
{
|
2007-03-16 07:38:38 +08:00
|
|
|
dvalue = domain->boxlo[1];
|
2007-02-10 05:26:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_yhi()
|
|
|
|
{
|
2007-03-16 07:38:38 +08:00
|
|
|
dvalue = domain->boxhi[1];
|
2007-02-10 05:26:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_zlo()
|
|
|
|
{
|
2007-03-16 07:38:38 +08:00
|
|
|
dvalue = domain->boxlo[2];
|
2007-02-10 05:26:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_zhi()
|
|
|
|
{
|
2007-03-16 07:38:38 +08:00
|
|
|
dvalue = domain->boxhi[2];
|
2007-02-10 05:26:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
2006-09-28 03:51:33 +08:00
|
|
|
|
2008-02-06 08:03:11 +08:00
|
|
|
void Thermo::compute_xy()
|
|
|
|
{
|
|
|
|
dvalue = domain->xy;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_xz()
|
|
|
|
{
|
|
|
|
dvalue = domain->xz;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_yz()
|
|
|
|
{
|
|
|
|
dvalue = domain->yz;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2010-02-09 05:41:24 +08:00
|
|
|
void Thermo::compute_xlat()
|
|
|
|
{
|
|
|
|
dvalue = domain->lattice->xlattice;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_ylat()
|
|
|
|
{
|
|
|
|
dvalue = domain->lattice->ylattice;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_zlat()
|
|
|
|
{
|
|
|
|
dvalue = domain->lattice->zlattice;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2006-09-28 03:51:33 +08:00
|
|
|
void Thermo::compute_pxx()
|
|
|
|
{
|
2007-01-30 08:22:05 +08:00
|
|
|
dvalue = pressure->vector[0];
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_pyy()
|
|
|
|
{
|
2007-01-30 08:22:05 +08:00
|
|
|
dvalue = pressure->vector[1];
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_pzz()
|
|
|
|
{
|
2007-01-30 08:22:05 +08:00
|
|
|
dvalue = pressure->vector[2];
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_pxy()
|
|
|
|
{
|
2007-01-30 08:22:05 +08:00
|
|
|
dvalue = pressure->vector[3];
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_pxz()
|
|
|
|
{
|
2007-01-30 08:22:05 +08:00
|
|
|
dvalue = pressure->vector[4];
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void Thermo::compute_pyz()
|
|
|
|
{
|
2007-01-30 08:22:05 +08:00
|
|
|
dvalue = pressure->vector[5];
|
2006-09-28 03:51:33 +08:00
|
|
|
}
|