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

This commit is contained in:
sjplimp 2013-04-23 20:35:26 +00:00
parent 3dadc962c0
commit 8492c4149e
8 changed files with 88 additions and 6 deletions

View File

@ -153,6 +153,7 @@ class Pair : protected Pointers {
virtual void write_restart_settings(FILE *) {}
virtual void read_restart_settings(FILE *) {}
virtual void write_data(FILE *) {}
virtual void write_data_all(FILE *) {}
virtual int pack_comm(int, int *, double *, int, int *) {return 0;}
virtual void unpack_comm(int, int, double *) {}

View File

@ -34,7 +34,10 @@ using namespace MathConst;
/* ---------------------------------------------------------------------- */
PairCoulWolf::PairCoulWolf(LAMMPS *lmp) : Pair(lmp) {}
PairCoulWolf::PairCoulWolf(LAMMPS *lmp) : Pair(lmp)
{
writedata = 0;
}
/* ---------------------------------------------------------------------- */

View File

@ -690,6 +690,17 @@ void PairLJCut::write_data(FILE *fp)
fprintf(fp,"%d %g %g\n",i,epsilon[i][i],sigma[i][i]);
}
/* ----------------------------------------------------------------------
proc 0 writes all pairs to data file
------------------------------------------------------------------------- */
void PairLJCut::write_data_all(FILE *fp)
{
for (int i = 1; i <= atom->ntypes; i++)
for (int j = i; j <= atom->ntypes; j++)
fprintf(fp,"%d %d %g %g %g\n",i,j,epsilon[i][i],sigma[i][i],cut[i][j]);
}
/* ---------------------------------------------------------------------- */
double PairLJCut::single(int i, int j, int itype, int jtype, double rsq,

View File

@ -39,6 +39,7 @@ class PairLJCut : public Pair {
void write_restart_settings(FILE *);
void read_restart_settings(FILE *);
void write_data(FILE *);
void write_data_all(FILE *);
double single(int, int, int, int, double, double, double, double &);
void *extract(const char *, int &);

View File

@ -47,7 +47,7 @@ using namespace LAMMPS_NS;
#define MAXBODY 20 // max # of lines in one body, also in Atom class
// customize for new sections
#define NSECTIONS 24 // change when add to header::section_keywords
#define NSECTIONS 25 // change when add to header::section_keywords
/* ---------------------------------------------------------------------- */
@ -255,6 +255,10 @@ void ReadData::command(int narg, char **arg)
if (force->pair == NULL)
error->all(FLERR,"Must define pair_style before Pair Coeffs");
paircoeffs();
} else if (strcmp(keyword,"PairIJ Coeffs") == 0) {
if (force->pair == NULL)
error->all(FLERR,"Must define pair_style before PairIJ Coeffs");
pairIJcoeffs();
} else if (strcmp(keyword,"Bond Coeffs") == 0) {
if (atom->avec->bonds_allow == 0)
error->all(FLERR,"Invalid data file section: Bond Coeffs");
@ -387,7 +391,7 @@ void ReadData::header(int flag)
const char *section_keywords[NSECTIONS] =
{"Atoms","Velocities","Ellipsoids","Lines","Triangles","Bodies",
"Bonds","Angles","Dihedrals","Impropers",
"Masses","Pair Coeffs","Bond Coeffs","Angle Coeffs",
"Masses","Pair Coeffs","PairIJ Coeffs","Bond Coeffs","Angle Coeffs",
"Dihedral Coeffs","Improper Coeffs",
"BondBond Coeffs","BondAngle Coeffs","MiddleBondTorsion Coeffs",
"EndBondTorsion Coeffs","AngleTorsion Coeffs",
@ -1062,6 +1066,40 @@ void ReadData::paircoeffs()
/* ---------------------------------------------------------------------- */
void ReadData::pairIJcoeffs()
{
int i,j,m;
char *buf = new char[atom->ntypes*(atom->ntypes+1)/2 * MAXLINE];
char *original = buf;
if (me == 0) {
char *eof;
m = 0;
for (i = 0; i < atom->ntypes; i++)
for (j = i; j < atom->ntypes; j++) {
eof = fgets(&buf[m],MAXLINE,fp);
if (eof == NULL) error->one(FLERR,"Unexpected end of data file");
m += strlen(&buf[m]);
if (buf[m-1] != '\n') strcpy(&buf[m++],"\n");
buf[m-1] = '\0';
}
}
MPI_Bcast(&m,1,MPI_INT,0,world);
MPI_Bcast(buf,m,MPI_CHAR,0,world);
for (i = 0; i < atom->ntypes; i++)
for (j = i; j < atom->ntypes; j++) {
m = strlen(buf) + 1;
parse_coeffs(buf,NULL,0);
force->pair->coeff(narg,arg);
buf += m;
}
delete [] original;
}
/* ---------------------------------------------------------------------- */
void ReadData::bondcoeffs()
{
int i,m;
@ -1305,6 +1343,10 @@ void ReadData::scan(int &bond_per_atom, int &angle_per_atom,
if (force->pair == NULL)
error->one(FLERR,"Must define pair_style before Pair Coeffs");
skip_lines(atom->ntypes);
} else if (strcmp(keyword,"PairIJ Coeffs") == 0) {
if (force->pair == NULL)
error->one(FLERR,"Must define pair_style before Pair Coeffs");
skip_lines(atom->ntypes*(atom->ntypes+1)/2);
} else if (strcmp(keyword,"Bond Coeffs") == 0) {
if (atom->avec->bonds_allow == 0)
error->one(FLERR,"Invalid data file section: Bond Coeffs");

View File

@ -72,6 +72,7 @@ class ReadData : protected Pointers {
void mass();
void paircoeffs();
void pairIJcoeffs();
void bondcoeffs();
void anglecoeffs(int);
void dihedralcoeffs(int);

View File

@ -37,6 +37,7 @@
using namespace LAMMPS_NS;
enum{IGNORE,WARN,ERROR}; // same as thermo.cpp
enum{II,IJ};
/* ---------------------------------------------------------------------- */
@ -54,7 +55,8 @@ void WriteData::command(int narg, char **arg)
{
if (domain->box_exist == 0)
error->all(FLERR,"Write_data command before simulation box is defined");
if (narg != 1) error->all(FLERR,"Illegal write_data command");
if (narg < 1) error->all(FLERR,"Illegal write_data command");
// if filename contains a "*", replace with current timestep
@ -67,6 +69,21 @@ void WriteData::command(int narg, char **arg)
sprintf(file,"%s" BIGINT_FORMAT "%s",arg[0],update->ntimestep,ptr+1);
} else strcpy(file,arg[0]);
// read optional args
pairflag = II;
int iarg = 1;
while (iarg < narg) {
if (strcmp(arg[iarg],"pair") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal write_data command");
if (strcmp(arg[iarg+1],"ii") == 0) pairflag = II;
else if (strcmp(arg[iarg+1],"ij") == 0) pairflag = IJ;
else error->all(FLERR,"Illegal write_data command");
iarg += 2;
} else error->all(FLERR,"Illegal write_data command");
}
// init entire system since comm->exchange is done
// comm::init needs neighbor::init needs pair::init needs kspace::init, etc
@ -224,8 +241,13 @@ void WriteData::type_arrays()
void WriteData::force_fields()
{
if (force->pair && force->pair->writedata) {
fprintf(fp,"\nPair Coeffs\n\n");
force->pair->write_data(fp);
if (pairflag == II) {
fprintf(fp,"\nPair Coeffs\n\n");
force->pair->write_data(fp);
} else if (pairflag == IJ) {
fprintf(fp,"\nPairIJ Coeffs\n\n");
force->pair->write_data_all(fp);
}
}
if (atom->avec->bonds_allow && force->bond && force->bond->writedata) {
fprintf(fp,"\nBond Coeffs\n\n");

View File

@ -33,6 +33,7 @@ class WriteData : protected Pointers {
private:
int me,nprocs;
int pairflag;
FILE *fp;
bigint nbonds_local,nbonds;
bigint nangles_local,nangles;