Updating restart2data.cpp to reflect new GPU pair styles --- all changes courtesy of Axel.

git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5292 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
pscrozi 2010-11-23 21:28:42 +00:00
parent 04de31551c
commit 8ba792f112
1 changed files with 111 additions and 56 deletions

View File

@ -5,7 +5,7 @@
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
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.
@ -51,7 +51,7 @@ enum{VERSION,UNITS,NTIMESTEP,DIMENSION,NPROCS,PROCGRID_0,PROCGRID_1,PROCGRID_2,
enum{MASS,SHAPE,DIPOLE};
enum{PAIR,BOND,ANGLE,DIHEDRAL,IMPROPER};
static const char * const cg_type_list[] =
static const char * const cg_type_list[] =
{"none", "lj9_6", "lj12_4", "lj12_6"};
// ---------------------------------------------------------------------
@ -191,7 +191,7 @@ class Data {
int *angle_atom1,*angle_atom2,*angle_atom3;
int *dihedral_atom1,*dihedral_atom2,*dihedral_atom3,*dihedral_atom4;
int *improper_atom1,*improper_atom2,*improper_atom3,*improper_atom4;
// functions
Data();
@ -345,7 +345,7 @@ int main (int argc, char **argv)
double *buf = NULL;
int n,m;
int maxbuf = 0;
data.iatoms = data.ibonds = data.iangles =
data.iatoms = data.ibonds = data.iangles =
data.idihedrals = data.iimpropers = 0;
for (int iproc = 0; iproc < data.nprocs; iproc++) {
@ -410,7 +410,7 @@ int main (int argc, char **argv)
fclose(fp);
fclose(fp2);
}
return 0;
}
@ -420,7 +420,7 @@ int main (int argc, char **argv)
void header(FILE *fp, Data &data)
{
char *version = "10 Sept 2010";
char *version = "23 Nov 2010";
data.triclinic = 0;
@ -462,7 +462,7 @@ void header(FILE *fp, Data &data)
// set sub-styles to 1 to N
else if (flag == ATOM_STYLE) {
data.style_angle = data.style_atomic = data.style_bond =
data.style_angle = data.style_atomic = data.style_bond =
data.style_charge = data.style_dipole = data.style_dpd =
data.style_ellipsoid = data.style_full = data.style_granular =
data.style_hybrid = data.style_molecular = data.style_peri = 0;
@ -887,7 +887,7 @@ int atom_dipole(double *buf, Data &data, int iatoms)
data.mux[iatoms] = buf[m++];
data.muy[iatoms] = buf[m++];
data.muz[iatoms] = buf[m++];
return m;
}
@ -929,7 +929,7 @@ int atom_ellipsoid(double *buf, Data &data, int iatoms)
data.angmomx[iatoms] = buf[m++];
data.angmomy[iatoms] = buf[m++];
data.angmomz[iatoms] = buf[m++];
return m;
}
@ -1018,7 +1018,7 @@ int atom_full(double *buf, Data &data, int iatoms)
data.idihedrals++;
}
}
n = static_cast<int> (buf[m++]);
for (int k = 0; k < n; k++) {
type = static_cast<int> (buf[m++]);
@ -1418,7 +1418,7 @@ void pair(FILE *fp, Data &data, char *style, int flag)
}
}
}
} else if ((strcmp(style,"coul/cut") == 0) ||
(strcmp(style,"coul/debye") == 0) ||
(strcmp(style,"coul/long") == 0)) {
@ -1523,6 +1523,39 @@ void pair(FILE *fp, Data &data, char *style, int flag)
}
}
} else if ((strcmp(style,"dpd/tstat") == 0) {
double tstart = read_double(fp);
double tstop = read_double(fp);
double cut_global = read_double(fp);
int seed = read_int(fp);
int mix_flag = read_int(fp);
if (!flag) return;
data.pair_dpd_a0 = new double[data.ntypes+1];
data.pair_dpd_gamma = new double[data.ntypes+1];
for (i = 1; i <= data.ntypes; i++)
for (j = i; j <= data.ntypes; j++) {
itmp = read_int(fp);
if (i == j && itmp == 0) {
printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j);
exit(1);
}
if (itmp) {
if (i == j) {
data.pair_dpd_a0[i] = read_double(fp);
data.pair_dpd_gamma[i] = read_double(fp);
double cut = read_double(fp);
} else {
double dpd_a0 = read_double(fp);
double dpd_gamma = read_double(fp);
double cut = read_double(fp);
}
}
}
} else if (strcmp(style,"eam") == 0) {
} else if (strcmp(style,"eam/opt") == 0) {
} else if (strcmp(style,"eam/alloy") == 0) {
@ -1584,7 +1617,7 @@ void pair(FILE *fp, Data &data, char *style, int flag)
data.pair_gb_epsb[i] = pow(data.pair_gb_epsb[i],-mu);
data.pair_gb_epsc[i] = pow(data.pair_gb_epsc[i],-mu);
}
for (j = i; j <= data.ntypes; j++) {
itmp = read_int(fp);
if (i == j && itmp == 0) {
@ -1724,19 +1757,25 @@ void pair(FILE *fp, Data &data, char *style, int flag)
}
} else if ((strcmp(style,"lj/cut") == 0) ||
(strcmp(style,"lj/cut/gpu") == 0) ||
(strcmp(style,"lj/cut/opt") == 0) ||
(strcmp(style,"lj/cut/coul/cut") == 0) ||
(strcmp(style,"lj/cut/coul/cut/gpu") == 0) ||
(strcmp(style,"lj/cut/coul/debye") == 0) ||
(strcmp(style,"lj/cut/coul/long") == 0) ||
(strcmp(style,"lj/cut/coul/long/gpu") == 0) ||
(strcmp(style,"lj/cut/coul/long/tip4p") == 0) ||
(strcmp(style,"lj/coul") == 0)) {
if ((strcmp(style,"lj/cut") == 0) || (strcmp(style,"lj/cut/opt") == 0)) {
if ((strcmp(style,"lj/cut") == 0) ||
(strcmp(style,"lj/cut/gpu") == 0) ||
(strcmp(style,"lj/cut/opt") == 0)) {
m = 0;
double cut_lj_global = read_double(fp);
int offset_flag = read_int(fp);
int mix_flag = read_int(fp);
} else if (strcmp(style,"lj/cut/coul/cut") == 0) {
} else if ((strcmp(style,"lj/cut/coul/cut") == 0) ||
(strcmp(style,"lj/cut/coul/cut/gpu") == 0)) {
m = 1;
double cut_lj_global = read_double(fp);
double cut_lj_coul = read_double(fp);
@ -1749,7 +1788,8 @@ void pair(FILE *fp, Data &data, char *style, int flag)
double kappa = read_double(fp);
int offset_flag = read_int(fp);
int mix_flag = read_int(fp);
} else if (strcmp(style,"lj/cut/coul/long") == 0) {
} else if ((strcmp(style,"lj/cut/coul/long") == 0) ||
(strcmp(style,"lj/cut/coul/long/gpu") == 0)) {
m = 0;
double cut_lj_global = read_double(fp);
double cut_lj_coul = read_double(fp);
@ -2027,8 +2067,10 @@ void pair(FILE *fp, Data &data, char *style, int flag)
}
} else if ((strcmp(style,"cg/cmm") == 0) ||
(strcmp(style,"cg/cmm/gpu") == 0) ||
(strcmp(style,"cg/cmm/coul/cut") == 0) ||
(strcmp(style,"cg/cmm/coul/long") == 0) ) {
(strcmp(style,"cg/cmm/coul/long") == 0) ||
(strcmp(style,"cg/cmm/coul/long/gpu") == 0)) {
m = 0;
data.cut_lj_global = read_double(fp);
data.cut_coul_global = read_double(fp);
@ -2045,14 +2087,15 @@ void pair(FILE *fp, Data &data, char *style, int flag)
data.pair_cg_sigma = new double*[numtyp];
data.pair_cut_lj = new double*[numtyp];
if ((strcmp(style,"cg/cmm/coul/cut") == 0) ||
(strcmp(style,"cg/cmm/coul/long") == 0) ) {
(strcmp(style,"cg/cmm/coul/long") == 0) ||
(strcmp(style,"cg/cmm/coul/long/gpu") == 0)) {
data.pair_cut_coul = new double*[numtyp];
m=1;
} else {
data.pair_cut_coul = NULL;
m=0;
}
for (i = 1; i <= data.ntypes; i++) {
data.pair_cg_cmm_type[i] = new int[numtyp];
data.pair_setflag[i] = new int[numtyp];
@ -2060,13 +2103,14 @@ void pair(FILE *fp, Data &data, char *style, int flag)
data.pair_cg_sigma[i] = new double[numtyp];
data.pair_cut_lj[i] = new double[numtyp];
if ((strcmp(style,"cg/cmm/coul/cut") == 0) ||
(strcmp(style,"cg/cmm/coul/long") == 0) ) {
(strcmp(style,"cg/cmm/coul/long") == 0) ||
(strcmp(style,"cg/cmm/coul/long/gpu") == 0)) {
data.pair_cut_coul[i] = new double[numtyp];
}
for (j = i; j <= data.ntypes; j++) {
itmp = read_int(fp);
data.pair_setflag[i][j] = itmp;
data.pair_setflag[i][j] = itmp;
if (i == j && itmp == 0) {
printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j);
exit(1);
@ -2080,7 +2124,7 @@ void pair(FILE *fp, Data &data, char *style, int flag)
data.pair_cut_lj[i][j] = read_double(fp);
data.pair_cut_coul[i][j] = read_double(fp);
}
}
}
}
}
@ -2219,7 +2263,7 @@ void angle(FILE *fp, Data &data)
data.angle_cg_cmm_sigma = new double[data.nangletypes+1];
double *angle_cg_cmm_rcut = new double[data.nangletypes+1];
data.angle_cg_cmm_type = new int[data.nangletypes+1];
fread(&data.angle_harmonic_k[1],sizeof(double),data.nangletypes,fp);
fread(&data.angle_harmonic_theta0[1],sizeof(double),data.nangletypes,fp);
fread(&data.angle_cg_cmm_epsilon[1],sizeof(double),data.nangletypes,fp);
@ -2609,7 +2653,7 @@ void Data::write(FILE *fp, FILE *fp2)
{
fprintf(fp,"LAMMPS data file from restart file: timestep = %d, procs = %d\n",
ntimestep,nprocs);
fprintf(fp,"\n");
fprintf(fp,"%d atoms\n",natoms);
@ -2627,7 +2671,7 @@ void Data::write(FILE *fp, FILE *fp2)
if (nimpropertypes) fprintf(fp,"%d improper types\n",nimpropertypes);
fprintf(fp,"\n");
fprintf(fp,"%-1.16e %-1.16e xlo xhi\n",xlo,xhi);
fprintf(fp,"%-1.16e %-1.16e ylo yhi\n",ylo,yhi);
fprintf(fp,"%-1.16e %-1.16e zlo zhi\n",zlo,zhi);
@ -2680,7 +2724,7 @@ void Data::write(FILE *fp, FILE *fp2)
// pair coeffs to data file
if (pair_style && fp2 == NULL) {
if ((strcmp(pair_style,"none") != 0) &&
if ((strcmp(pair_style,"none") != 0) &&
(strcmp(pair_style,"airebo") != 0) &&
(strcmp(pair_style,"coul/cut") != 0) &&
(strcmp(pair_style,"coul/debye") != 0) &&
@ -2706,21 +2750,21 @@ void Data::write(FILE *fp, FILE *fp2)
(strcmp(pair_style,"hybrid") != 0) &&
(strcmp(pair_style,"hybrid/overlay") != 0))
fprintf(fp,"\nPair Coeffs\n\n");
if (strcmp(pair_style,"born/coul/long") == 0) {
for (int i = 1; i <= ntypes; i++)
fprintf(fp,"%d %g %g %g %g %g\n",i,
pair_born_A[i],pair_born_rho[i],pair_born_sigma[i],
pair_born_C[i],pair_born_D[i]);
} else if ((strcmp(pair_style,"buck") == 0) ||
} else if ((strcmp(pair_style,"buck") == 0) ||
(strcmp(pair_style,"buck/coul/cut") == 0) ||
(strcmp(pair_style,"buck/coul/long") == 0) ||
(strcmp(pair_style,"buck/long") == 0)) {
for (int i = 1; i <= ntypes; i++)
fprintf(fp,"%d %g %g %g\n",i,
pair_buck_A[i],pair_buck_rho[i],pair_buck_C[i]);
} else if (strcmp(pair_style,"colloid") == 0) {
for (int i = 1; i <= ntypes; i++)
fprintf(fp,"%d %g %g %g %g\n",i,
@ -2731,13 +2775,19 @@ void Data::write(FILE *fp, FILE *fp2)
for (int i = 1; i <= ntypes; i++)
fprintf(fp,"%d %g %g\n",i,
pair_dipole_epsilon[i],pair_dipole_sigma[i]);
} else if (strcmp(pair_style,"dpd") == 0) {
for (int i = 1; i <= ntypes; i++)
fprintf(fp,"%d %g %g\n",i,
pair_dpd_a0[i],pair_dpd_gamma[i]);
} else if (strcmp(pair_style,"gayberne") == 0) {
} else if ((strcmp(pair_style,"dpd/tstat") == 0) {
for (int i = 1; i <= ntypes; i++)
fprintf(fp,"%d %g\n",i,
pair_dpd_gamma[i]);
} else if ((strcmp(pair_style,"gayberne") == 0) ||
(strcmp(pair_style,"gayberne/gpu") == 0)) {
for (int i = 1; i <= ntypes; i++)
fprintf(fp,"%d %g %g %g %g %g %g %g %g\n",i,
pair_gb_epsilon[i],pair_gb_sigma[i],
@ -2752,19 +2802,22 @@ void Data::write(FILE *fp, FILE *fp2)
fprintf(fp,"%d %g %g %g %g\n",i,
pair_charmm_epsilon[i],pair_charmm_sigma[i],
pair_charmm_eps14[i],pair_charmm_sigma14[i]);
} else if ((strcmp(pair_style,"lj/class2") == 0) ||
} else if ((strcmp(pair_style,"lj/class2") == 0) ||
(strcmp(pair_style,"lj/class2/coul/cut") == 0) ||
(strcmp(pair_style,"lj/class2/coul/long") == 0)) {
for (int i = 1; i <= ntypes; i++)
fprintf(fp,"%d %g %g\n",i,
pair_class2_epsilon[i],pair_class2_sigma[i]);
} else if ((strcmp(pair_style,"lj/cut") == 0) ||
} else if ((strcmp(pair_style,"lj/cut") == 0) ||
(strcmp(pair_style,"lj/cut/gpu") == 0) ||
(strcmp(pair_style,"lj/cut/opt") == 0) ||
(strcmp(pair_style,"lj/cut/coul/cut") == 0) ||
(strcmp(pair_style,"lj/cut/coul/cut/gpu") == 0) ||
(strcmp(pair_style,"lj/cut/coul/debye") == 0) ||
(strcmp(pair_style,"lj/cut/coul/long") == 0) ||
(strcmp(pair_style,"lj/cut/coul/long/gpu") == 0) ||
(strcmp(pair_style,"lj/cut/coul/long/tip4p") == 0) ||
(strcmp(pair_style,"lj/coul") == 0)) {
for (int i = 1; i <= ntypes; i++)
@ -2787,24 +2840,24 @@ void Data::write(FILE *fp, FILE *fp2)
for (int i = 1; i <= ntypes; i++)
fprintf(fp,"%d %g %g\n",i,
pair_ljsmooth_epsilon[i],pair_ljsmooth_sigma[i]);
} else if ((strcmp(pair_style,"morse") == 0) ||
(strcmp(pair_style,"morse/opt") == 0)) {
for (int i = 1; i <= ntypes; i++)
fprintf(fp,"%d %g %g %g\n",i,
pair_morse_d0[i],pair_morse_alpha[i],pair_morse_r0[i]);
} else if (strcmp(pair_style,"soft") == 0) {
for (int i = 1; i <= ntypes; i++)
fprintf(fp,"%d %g\n",i,
pair_soft_A[i]);
} else if (strcmp(pair_style,"yukawa") == 0) {
for (int i = 1; i <= ntypes; i++)
fprintf(fp,"%d %g\n",i,
pair_yukawa_A[i]);
} else if ((strcmp(pair_style,"cg/cmm") == 0) ||
} else if ((strcmp(pair_style,"cg/cmm") == 0) ||
(strcmp(pair_style,"cg/cmm/coul/cut") == 0) ||
(strcmp(pair_style,"cg/cmm/coul/long") == 0)) {
printf("ERROR: Cannot write pair_style %s to data file\n",
@ -2817,9 +2870,11 @@ void Data::write(FILE *fp, FILE *fp2)
// only supported styles = cg/cmm
if (pair_style && fp2) {
if ((strcmp(pair_style,"cg/cmm") == 0) ||
if ((strcmp(pair_style,"cg/cmm") == 0) ||
(strcmp(pair_style,"cg/cmm/gpu") == 0) ||
(strcmp(pair_style,"cg/cmm/coul/cut") == 0) ||
(strcmp(pair_style,"cg/cmm/coul/long") == 0)) {
(strcmp(pair_style,"cg/cmm/coul/long") == 0) ||
(strcmp(pair_style,"cg/cmm/coul/long/gpu") == 0)) {
for (int i = 1; i <= ntypes; i++) {
for (int j = i; j <= ntypes; j++) {
fprintf(fp2,"pair_coeff %d %d %s %g %g\n",i,j,
@ -2838,7 +2893,7 @@ void Data::write(FILE *fp, FILE *fp2)
// bond coeffs to data file
if (bond_style && fp2 == NULL) {
if ((strcmp(bond_style,"none") != 0) &&
if ((strcmp(bond_style,"none") != 0) &&
(strcmp(bond_style,"table") != 0) &&
(strcmp(bond_style,"hybrid") != 0))
fprintf(fp,"\nBond Coeffs\n\n");
@ -2907,11 +2962,11 @@ void Data::write(FILE *fp, FILE *fp2)
if (angle_style && fp2 == NULL) {
double PI = 3.1415926; // convert back to degrees
if ((strcmp(angle_style,"none") != 0) &&
if ((strcmp(angle_style,"none") != 0) &&
(strcmp(angle_style,"table") != 0) &&
(strcmp(angle_style,"hybrid") != 0))
fprintf(fp,"\nAngle Coeffs\n\n");
if (strcmp(angle_style,"charmm") == 0) {
for (int i = 1; i <= nangletypes; i++)
fprintf(fp,"%d %g %g %g %g\n",i,
@ -2921,15 +2976,15 @@ void Data::write(FILE *fp, FILE *fp2)
} else if (strcmp(angle_style,"class2") == 0) {
for (int i = 1; i <= nangletypes; i++)
fprintf(fp,"%d %g %g %g %g\n",i,
angle_class2_theta0[i]/PI*180.0,angle_class2_k2[i],
angle_class2_theta0[i]/PI*180.0,angle_class2_k2[i],
angle_class2_k3[i],angle_class2_k4[i]);
fprintf(fp,"\nBondBond Coeffs\n\n");
for (int i = 1; i <= nangletypes; i++)
fprintf(fp,"%d %g %g %g\n",i,
angle_class2_bb_k[i],
angle_class2_bb_r1[i],angle_class2_bb_r2[i]);
fprintf(fp,"\nBondAngle Coeffs\n\n");
for (int i = 1; i <= nangletypes; i++)
fprintf(fp,"%d %g %g %g %g\n",i,
@ -2939,19 +2994,19 @@ void Data::write(FILE *fp, FILE *fp2)
} else if (strcmp(angle_style,"cosine") == 0) {
for (int i = 1; i <= nangletypes; i++)
fprintf(fp,"%d %g\n",i,angle_cosine_k[i]);
} else if ((strcmp(angle_style,"cosine/squared") == 0) ||
(strcmp(angle_style,"cosine/delta") == 0)) {
for (int i = 1; i <= nangletypes; i++)
fprintf(fp,"%d %g %g\n",i,
angle_cosine_squared_k[i],
angle_cosine_squared_theta0[i]/PI*180.0);
} else if (strcmp(angle_style,"harmonic") == 0) {
for (int i = 1; i <= nangletypes; i++)
fprintf(fp,"%d %g %g\n",i,
angle_harmonic_k[i],angle_harmonic_theta0[i]/PI*180.0);
} else if (strcmp(angle_style,"cg/cmm") == 0) {
for (int i = 1; i <= nangletypes; i++)
fprintf(fp,"%d %g %g %s %g %g\n",i,
@ -2973,19 +3028,19 @@ void Data::write(FILE *fp, FILE *fp2)
fprintf(fp2,"angle_coeffs %d %g %g\n",i,
angle_cosine_squared_k[i],
angle_cosine_squared_theta0[i]/PI*180.0);
} else if (strcmp(angle_style,"harmonic") == 0) {
for (int i = 1; i <= nangletypes; i++)
fprintf(fp2,"angle_coeffs %d %g %g\n",i,
angle_harmonic_k[i],angle_harmonic_theta0[i]/PI*180.0);
} else if (strcmp(angle_style,"cg/cmm") == 0) {
for (int i = 1; i <= nangletypes; i++)
fprintf(fp2,"angle_coeffs %d %g %g %s %g %g\n",i,
angle_harmonic_k[i],angle_harmonic_theta0[i]/PI*180.0,
cg_type_list[angle_cg_cmm_type[i]],angle_cg_cmm_epsilon[i],
angle_cg_cmm_sigma[i]);
} else {
printf("ERROR: Cannot write angle_style %s to input file\n",
angle_style);
@ -2996,7 +3051,7 @@ void Data::write(FILE *fp, FILE *fp2)
if (dihedral_style) {
double PI = 3.1415926; // convert back to degrees
if ((strcmp(dihedral_style,"none") != 0) &&
if ((strcmp(dihedral_style,"none") != 0) &&
(strcmp(dihedral_style,"table") != 0) &&
(strcmp(dihedral_style,"hybrid") != 0))
fprintf(fp,"\nDihedral Coeffs\n\n");
@ -3063,7 +3118,7 @@ void Data::write(FILE *fp, FILE *fp2)
dihedral_harmonic_sign[i]);
} else if (strcmp(dihedral_style,"helix") == 0) {
for (int i = 1; i <= ndihedraltypes; i++)
for (int i = 1; i <= ndihedraltypes; i++)
fprintf(fp,"%d %g %g %g\n",i,dihedral_helix_aphi[i],
dihedral_helix_bphi[i],dihedral_helix_cphi[i]);
@ -3085,7 +3140,7 @@ void Data::write(FILE *fp, FILE *fp2)
if (improper_style) {
double PI = 3.1415926; // convert back to degrees
if ((strcmp(improper_style,"none") != 0) &&
if ((strcmp(improper_style,"none") != 0) &&
(strcmp(improper_style,"hybrid") != 0))
fprintf(fp,"\nImproper Coeffs\n\n");