Merge remote-tracking branch 'lammps-ro/master' into lammps-icms

Resolved Conflicts:
	doc/Manual.html
	doc/Manual.txt
	doc/fix_oneway.txt
	doc/fix_temp_csvr.txt
	src/fix_move.cpp
	src/fix_nh.cpp
	src/fix_temp_csvr.cpp
	src/neigh_stencil.cpp
	src/pair.cpp
	src/pair_hybrid.cpp
	src/read_data.cpp
	tools/msi2lmp/src/msi2lmp.c
	tools/msi2lmp/src/msi2lmp.h

Signed-off-by: Axel Kohlmeyer <akohlmey@gmail.com>
This commit is contained in:
Axel Kohlmeyer
2014-03-12 17:43:22 -04:00
72 changed files with 580 additions and 326 deletions

View File

@ -23,6 +23,7 @@
#include "atom_vec_ellipsoid.h"
#include "atom_vec_line.h"
#include "atom_vec_tri.h"
#include "force.h"
#include "molecule.h"
#include "comm.h"
#include "update.h"
@ -50,48 +51,13 @@ using namespace LAMMPS_NS;
// customize for new sections
#define NSECTIONS 25 // change when add to header::section_keywords
/* ---------------------------------------------------------------------- */
// pair style suffixes to ignore
// when matching Pair Coeffs comment to currently-defined pair style
// compare two style strings and compare under consideration of possibly
// having suffixes which should be ignored (like /cuda, /gpu, /omp, /opt)
// we also need to strip off all coulomb related parts, since they do not
// affect the choice of coefficients (with very few execptions).
static const char *suffixes[] = {"/cuda","/gpu","/opt","/omp","/coul/cut",
"/coul/long","/coul/msm","/coul/dsf","/coul/debye","/coul/charmm",NULL};
static int style_match(const char *one, const char *two)
{
int i, delta, len, len1, len2;
// cannot compare empty styles
if ((one == NULL) || (two == NULL)) return 1;
len1 = strlen(one);
len2 = strlen(two);
for (i=0; suffixes[i] != NULL; ++i) {
len = strlen(suffixes[i]);
if ((delta = len1 - len) > 0)
if (strcmp(one+delta,suffixes[i]) == 0)
len1 = delta;
if ((delta = len2 - len) > 0)
if (strcmp(two+delta,suffixes[i]) == 0)
len2 = delta;
}
// if the data file has no style hint, accept it unconditionally.
// otherwise the length of the style without suffix has to match
// and the style name up to that point has to be identical, too.
if ((len1 == 0) || (len1 == len2) || (strncmp(one,two,len1) == 0))
return 1;
return 0;
}
const char *suffixes[] = {"/cuda","/gpu","/opt","/omp","/kk",
"/coul/cut","/coul/long","/coul/msm",
"/coul/dsf","/coul/debye","/coul/charmm",
NULL};
/* ---------------------------------------------------------------------- */
@ -143,13 +109,10 @@ void ReadData::command(int narg, char **arg)
{
if (narg < 1) error->all(FLERR,"Illegal read_data command");
if (domain->box_exist)
error->all(FLERR,"Cannot read_data after simulation box is defined");
if (domain->dimension == 2 && domain->zperiodic == 0)
error->all(FLERR,"Cannot run 2d simulation with nonperiodic Z dimension");
// fixes that process data file info
// optional args
addflag = mergeflag = 0;
offset[0] = offset[1] = offset[2] = 0.0;
nfix = 0;
fix_index = NULL;
fix_header = NULL;
@ -157,7 +120,20 @@ void ReadData::command(int narg, char **arg)
int iarg = 1;
while (iarg < narg) {
if (strcmp(arg[iarg],"fix") == 0) {
if (strcmp(arg[iarg],"add") == 0) {
addflag = 1;
iarg++;
} else if (strcmp(arg[iarg],"merge") == 0) {
mergeflag = 1;
iarg++;
} else if (strcmp(arg[iarg],"offset") == 0) {
if (iarg+4 > narg)
error->all(FLERR,"Illegal read_data command");
offset[0] = force->numeric(FLERR,arg[iarg+1]);
offset[1] = force->numeric(FLERR,arg[iarg+2]);
offset[2] = force->numeric(FLERR,arg[iarg+3]);
iarg += 4;
} else if (strcmp(arg[iarg],"fix") == 0) {
if (iarg+4 > narg)
error->all(FLERR,"Illegal read_data command");
memory->grow(fix_index,nfix+1,"read_data:fix_index");
@ -184,6 +160,18 @@ void ReadData::command(int narg, char **arg)
} else error->all(FLERR,"Illegal read_data command");
}
// error checks
if (domain->box_exist && !addflag && !mergeflag)
error->all(FLERR,"Cannot read_data after simulation box is defined");
if (addflag && mergeflag) error->all(FLERR,"Cannot read_data add and merge");
if (domain->dimension == 2 && offset[2] != 0.0)
error->all(FLERR,"Cannot use non-zero z offset in read_data "
"for 2d simulation");
if (domain->dimension == 2 && domain->zperiodic == 0)
error->all(FLERR,"Cannot run 2d simulation with nonperiodic Z dimension");
// perform 1-pass read if no molecular topoogy in file
// perform 2-pass read if molecular topology,
// first pass calculates max topology/atom
@ -269,7 +257,8 @@ void ReadData::command(int narg, char **arg)
atomflag = 1;
if (firstpass) {
if (me == 0 && !style_match(style,atom->atom_style))
error->warning(FLERR,"Recommended atom style in data file differs");
error->warning(FLERR,"Atom style in data file differs "
"from currently defined atom style");
atoms();
} else skip_lines(atom->natoms);
} else if (strcmp(keyword,"Velocities") == 0) {
@ -341,7 +330,8 @@ void ReadData::command(int narg, char **arg)
error->all(FLERR,"Must define pair_style before Pair Coeffs");
if (firstpass) {
if (me == 0 && !style_match(style,force->pair_style))
error->warning(FLERR,"Recommended pair style in data file differs");
error->warning(FLERR,"Pair style in data file differs "
"from currently defined pair style");
paircoeffs();
} else skip_lines(atom->ntypes);
} else if (strcmp(keyword,"PairIJ Coeffs") == 0) {
@ -349,7 +339,8 @@ void ReadData::command(int narg, char **arg)
error->all(FLERR,"Must define pair_style before PairIJ Coeffs");
if (firstpass) {
if (me == 0 && !style_match(style,force->pair_style))
error->warning(FLERR,"Recommended pair style in data file differs");
error->warning(FLERR,"Pair style in data file differs "
"from currently defined pair style");
pairIJcoeffs();
} else skip_lines(atom->ntypes*(atom->ntypes+1)/2);
} else if (strcmp(keyword,"Bond Coeffs") == 0) {
@ -359,7 +350,8 @@ void ReadData::command(int narg, char **arg)
error->all(FLERR,"Must define bond_style before Bond Coeffs");
if (firstpass) {
if (me == 0 && !style_match(style,force->bond_style))
error->warning(FLERR,"Recommended bond style in data file differs");
error->warning(FLERR,"Bond style in data file differs "
"from currently defined bond style");
bondcoeffs();
} else skip_lines(atom->nbondtypes);
} else if (strcmp(keyword,"Angle Coeffs") == 0) {
@ -369,7 +361,8 @@ void ReadData::command(int narg, char **arg)
error->all(FLERR,"Must define angle_style before Angle Coeffs");
if (firstpass) {
if (me == 0 && !style_match(style,force->angle_style))
error->warning(FLERR,"Recommended angle style in data file differs");
error->warning(FLERR,"Angle style in data file differs "
"from currently defined angle style");
anglecoeffs(0);
} else skip_lines(atom->nangletypes);
} else if (strcmp(keyword,"Dihedral Coeffs") == 0) {
@ -379,7 +372,8 @@ void ReadData::command(int narg, char **arg)
error->all(FLERR,"Must define dihedral_style before Dihedral Coeffs");
if (firstpass) {
if (me == 0 && !style_match(style,force->dihedral_style))
error->warning(FLERR,"Recommended dihedral style in data file differs");
error->warning(FLERR,"Dihedral style in data file differs "
"from currently defined dihedral style");
dihedralcoeffs(0);
} else skip_lines(atom->ndihedraltypes);
} else if (strcmp(keyword,"Improper Coeffs") == 0) {
@ -389,7 +383,8 @@ void ReadData::command(int narg, char **arg)
error->all(FLERR,"Must define improper_style before Improper Coeffs");
if (firstpass) {
if (me == 0 && !style_match(style,force->improper_style))
error->warning(FLERR,"Recommended improper style in data file differs");
error->warning(FLERR,"Improper style in data file differs "
"from currently defined improper style");
impropercoeffs(0);
} else skip_lines(atom->nimpropertypes);
@ -665,8 +660,6 @@ void ReadData::header()
if (eof == NULL) error->one(FLERR,"Unexpected end of data file");
}
// customize for new header lines
while (1) {
// read a line and bcast length if flag is set
@ -707,6 +700,7 @@ void ReadData::header()
}
// search line for header keyword and set corresponding variable
// customize for new header lines
if (strstr(line,"atoms")) {
sscanf(line,BIGINT_FORMAT,&atom->natoms);
@ -1331,7 +1325,6 @@ void ReadData::bodies(int firstpass)
void ReadData::mass()
{
int i,m;
char *next;
char *buf = new char[atom->ntypes*MAXLINE];
@ -1339,7 +1332,7 @@ void ReadData::mass()
if (eof) error->all(FLERR,"Unexpected end of data file");
char *original = buf;
for (i = 0; i < atom->ntypes; i++) {
for (int i = 0; i < atom->ntypes; i++) {
next = strchr(buf,'\n');
*next = '\0';
atom->set_mass(buf);
@ -1565,6 +1558,7 @@ void ReadData::open(char *file)
grab next keyword
read lines until one is non-blank
keyword is all text on line w/out leading & trailing white space
optional style can be appended after comment char '#'
read one additional line (assumed blank)
if any read hits EOF, set keyword to empty
if first = 1, line variable holds non-blank line that ended header
@ -1602,20 +1596,17 @@ void ReadData::parse_keyword(int first)
MPI_Bcast(&n,1,MPI_INT,0,world);
MPI_Bcast(line,n,MPI_CHAR,0,world);
// handle comments following the keyword
// truncate string and increment pointer over whitespace
// store optional "style" following comment char '#' after keyword
char *ptr;
if ((ptr = strrchr(line,'#'))) {
*ptr++ = '\0';
while (*ptr == ' ' || *ptr == '\t') ++ptr;
int stop = strlen(ptr) - 1;
while (ptr[stop] == ' ' || ptr[stop] == '\t'
|| ptr[stop] == '\n' || ptr[stop] == '\r') stop--;
ptr[stop+1] = '\0';
strcpy(style,ptr);
if ((ptr = strchr(line,'#'))) {
*ptr++ = '\0';
while (*ptr == ' ' || *ptr == '\t') ptr++;
int stop = strlen(ptr) - 1;
while (ptr[stop] == ' ' || ptr[stop] == '\t'
|| ptr[stop] == '\n' || ptr[stop] == '\r') stop--;
ptr[stop+1] = '\0';
strcpy(style,ptr);
} else style[0] = '\0';
// copy non-whitespace portion of line into keyword
@ -1671,3 +1662,30 @@ void ReadData::parse_coeffs(char *line, const char *addstr, int dupflag)
word = strtok(NULL," \t\n\r\f");
}
}
/* ----------------------------------------------------------------------
compare two style strings if they both exist
one = comment in data file section, two = currently-defined style
ignore suffixes listed in suffixes array at top of file
------------------------------------------------------------------------- */
int ReadData::style_match(const char *one, const char *two)
{
int i,delta,len,len1,len2;
if ((one == NULL) || (two == NULL)) return 1;
len1 = strlen(one);
len2 = strlen(two);
for (i = 0; suffixes[i] != NULL; i++) {
len = strlen(suffixes[i]);
if ((delta = len1 - len) > 0)
if (strcmp(one+delta,suffixes[i]) == 0) len1 = delta;
if ((delta = len2 - len) > 0)
if (strcmp(two+delta,suffixes[i]) == 0) len2 = delta;
}
if ((len1 == 0) || (len1 == len2) || (strncmp(one,two,len1) == 0)) return 1;
return 0;
}