update fix tmd input similar to read_data

This commit is contained in:
Axel Kohlmeyer 2019-07-19 14:00:24 -04:00
parent e72aef2a96
commit 276e3b2df1
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
1 changed files with 19 additions and 13 deletions

View File

@ -30,6 +30,7 @@
#include "force.h" #include "force.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include "utils.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -164,7 +165,7 @@ void FixTMD::init()
dtv = update->dt; dtv = update->dt;
dtf = update->dt * force->ftm2v; dtf = update->dt * force->ftm2v;
if (strstr(update->integrate_style,"respa")) if (utils::strmatch(update->integrate_style,"^respa"))
step_respa = ((Respa *) update->integrate)->step; step_respa = ((Respa *) update->integrate)->step;
} }
@ -423,21 +424,27 @@ void FixTMD::readfile(char *file)
*next = '\0'; *next = '\0';
if (firstline) { if (firstline) {
if (strstr(bufptr,"xlo xhi")) { if (utils::strmatch(bufptr,"^\\s*\\f+\\s+\\f+\\s+xlo\\s+xhi")) {
double lo,hi; double lo,hi;
sscanf(bufptr,"%lg %lg",&lo,&hi); n = sscanf(bufptr,"%lg %lg",&lo,&hi);
if (n != 2)
error->all(FLERR,"Incorrect format in TMD target file");
xprd = hi - lo; xprd = hi - lo;
bufptr = next + 1; bufptr = next + 1;
continue; continue;
} else if (strstr(bufptr,"ylo yhi")) { } else if (utils::strmatch(bufptr,"^\\s*\\f+\\s+\\f+\\s+ylo\\s+yhi")) {
double lo,hi; double lo,hi;
sscanf(bufptr,"%lg %lg",&lo,&hi); n = sscanf(bufptr,"%lg %lg",&lo,&hi);
if (n != 2)
error->all(FLERR,"Incorrect format in TMD target file");
yprd = hi - lo; yprd = hi - lo;
bufptr = next + 1; bufptr = next + 1;
continue; continue;
} else if (strstr(bufptr,"zlo zhi")) { } else if (utils::strmatch(bufptr,"^\\s*\\f+\\s+\\f+\\s+zlo\\s+zhi")) {
double lo,hi; double lo,hi;
sscanf(bufptr,"%lg %lg",&lo,&hi); n = sscanf(bufptr,"%lg %lg",&lo,&hi);
if (n != 2)
error->all(FLERR,"Incorrect format in TMD target file");
zprd = hi - lo; zprd = hi - lo;
bufptr = next + 1; bufptr = next + 1;
continue; continue;
@ -455,14 +462,13 @@ void FixTMD::readfile(char *file)
} }
if (imageflag) if (imageflag)
n = sscanf(bufptr,TAGINT_FORMAT " %lg %lg %lg %d %d %d", n = 7 - sscanf(bufptr,TAGINT_FORMAT " %lg %lg %lg %d %d %d",
&itag,&x,&y,&z,&ix,&iy,&iz); &itag,&x,&y,&z,&ix,&iy,&iz);
else else
n = sscanf(bufptr,TAGINT_FORMAT " %lg %lg %lg",&itag,&x,&y,&z); n = 4 - sscanf(bufptr,TAGINT_FORMAT " %lg %lg %lg",&itag,&x,&y,&z);
if (n < 0) { if (n != 0) {
if (me == 0) error->warning(FLERR,"Ignoring empty or incorrectly" error->all(FLERR,"Incorrectly formatted line in TMD target file");
" formatted line in target file");
bufptr = next + 1; bufptr = next + 1;
continue; continue;
} }