Simplify Pair COMB3

This commit is contained in:
Richard Berger 2020-06-04 16:29:15 -04:00
parent 8689b31bca
commit 7ab65c05da
No known key found for this signature in database
GPG Key ID: A9E83994E0BA0CAB
1 changed files with 24 additions and 83 deletions

View File

@ -312,84 +312,45 @@ double PairComb3::init_one(int i, int j)
void PairComb3::read_lib() void PairComb3::read_lib()
{ {
const unsigned int MAXLIB = 1024;
int i,j,k,l,m; int i,j,k,l,m;
int ii,jj,kk,ll,mm,iii; int ii,jj,kk,ll,mm,iii;
char s[MAXLIB];
// open library file on proc 0 // open library file on proc 0
if (comm->me == 0) { if (comm->me == 0) {
const char filename[] = "lib.comb3";
FILE *fp = force->open_potential(filename);
if (fp == NULL) error->one(FLERR,"Cannot open COMB3 lib.comb3 file");
try { try {
// read and store at the same time PotentialFileReader reader(lmp, "lib.comb3", "COMB3");
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); reader.next_dvector(6, ccutoff);
reader.next_dvector(7, ch_a);
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
ValueTokenizer values(s, " \t\n\r\f");
ccutoff[0] = values.next_double();
ccutoff[1] = values.next_double();
ccutoff[2] = values.next_double();
ccutoff[3] = values.next_double();
ccutoff[4] = values.next_double();
ccutoff[5] = values.next_double();
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
values = ValueTokenizer(s, " \t\n\r\f");
ch_a[0] = values.next_double();
ch_a[1] = values.next_double();
ch_a[2] = values.next_double();
ch_a[3] = values.next_double();
ch_a[4] = values.next_double();
ch_a[5] = values.next_double();
ch_a[6] = values.next_double();
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error);
values = ValueTokenizer(s, " \t\n\r\f");
ValueTokenizer values = reader.next_values(3);
nsplpcn = values.next_int(); nsplpcn = values.next_int();
nsplrad = values.next_int(); nsplrad = values.next_int();
nspltor = values.next_int(); nspltor = values.next_int();
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); values = reader.next_values(3);
values = ValueTokenizer(s, " \t\n\r\f");
maxx = values.next_int(); maxx = values.next_int();
maxy = values.next_int(); maxy = values.next_int();
maxz = values.next_int(); maxz = values.next_int();
utils::sfgets(FLERR,s,MAXLIB,fp,filename,error); values = reader.next_values(3);
values = ValueTokenizer(s, " \t\n\r\f");
maxxc = values.next_int(); maxxc = values.next_int();
maxyc = values.next_int(); maxyc = values.next_int();
maxconj = values.next_int(); maxconj = values.next_int();
for (l = 0; l < nsplpcn; l++) { for (l = 0; l < nsplpcn; l++) {
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); values = reader.next_values(3);
values = ValueTokenizer(s, " \t\n\r\f");
values.skip(1); values.skip(1);
maxxcn[l] = values.next_int(); maxxcn[l] = values.next_int();
vmaxxcn[l] = values.next_double(); vmaxxcn[l] = values.next_double();
dvmaxxcn[l] = values.next_double(); dvmaxxcn[l] = values.next_double();
} }
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); ntab = reader.next_int();
values = ValueTokenizer(s, " \t\n\r\f");
ntab = values.next_int();
for (i = 0; i < (ntab + 1); i++){ for (i = 0; i < (ntab + 1); i++){
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); values = reader.next_values(4);
values = ValueTokenizer(s, " \t\n\r\f");
values.skip(1); values.skip(1);
pang[i] = values.next_double(); pang[i] = values.next_double();
dpang[i] = values.next_double(); dpang[i] = values.next_double();
ddpang[i] = values.next_double(); ddpang[i] = values.next_double();
@ -399,8 +360,7 @@ void PairComb3::read_lib()
for (i = 0; i < (maxx + 1); i++) for (i = 0; i < (maxx + 1); i++)
for (j = 0; j < (maxy + 1); j++) for (j = 0; j < (maxy + 1); j++)
for (k = 0; k < (maxz + 1); k++) { for (k = 0; k < (maxz + 1); k++) {
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); values = reader.next_values(8);
values = ValueTokenizer(s, " \t\n\r\f");
ll = values.next_int() - 1; ll = values.next_int() - 1;
ii = values.next_int(); ii = values.next_int();
@ -416,8 +376,7 @@ void PairComb3::read_lib()
for (i = 0; i < maxx; i++) for (i = 0; i < maxx; i++)
for (j = 0; j < maxy; j++) for (j = 0; j < maxy; j++)
for (k = 0; k < maxz; k++) { for (k = 0; k < maxz; k++) {
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); values = reader.next_values(4);
values = ValueTokenizer(s, " \t\n\r\f");
ll = values.next_int()-1; ll = values.next_int()-1;
ii = values.next_int(); ii = values.next_int();
@ -425,13 +384,8 @@ void PairComb3::read_lib()
kk = values.next_int(); kk = values.next_int();
for(iii = 0; iii < 2; iii++) { for(iii = 0; iii < 2; iii++) {
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); mm = iii*32;
values = ValueTokenizer(s, " \t\n\r\f"); reader.next_dvector(32, &pcn_cubs[ll][ii][jj][kk][mm]);
for(m = 0; m < 32 ; m++) {
mm = iii*32 + m;
pcn_cubs[ll][ii][jj][kk][mm] = values.next_double();
}
} }
} }
@ -439,8 +393,7 @@ void PairComb3::read_lib()
for (i = 0; i < (maxxc + 1); i++) for (i = 0; i < (maxxc + 1); i++)
for (j = 0; j < (maxyc + 1); j++) for (j = 0; j < (maxyc + 1); j++)
for (k = 0; k < maxconj; k++) { for (k = 0; k < maxconj; k++) {
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); values = reader.next_values(8);
values = ValueTokenizer(s, " \t\n\r\f");
ll = values.next_int() - 1; ll = values.next_int() - 1;
ii = values.next_int(); ii = values.next_int();
@ -456,8 +409,7 @@ void PairComb3::read_lib()
for (i = 0; i < maxxc; i++) for (i = 0; i < maxxc; i++)
for (j = 0; j < maxyc; j++) for (j = 0; j < maxyc; j++)
for (k = 0; k < (maxconj - 1); k++) { for (k = 0; k < (maxconj - 1); k++) {
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); values = reader.next_values(4);
values = ValueTokenizer(s, " \t\n\r\f");
ll = values.next_int() - 1; ll = values.next_int() - 1;
ii = values.next_int(); ii = values.next_int();
@ -465,13 +417,8 @@ void PairComb3::read_lib()
kk = values.next_int() - 1; kk = values.next_int() - 1;
for (iii = 0; iii < 2; iii++) { for (iii = 0; iii < 2; iii++) {
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); mm = iii * 32;
values = ValueTokenizer(s, " \t\n\r\f"); reader.next_dvector(32, &rad_spl[ll][ii][jj][kk][mm]);
for(m = 0; m < 32 ; m++){
mm = iii * 32 + m;
rad_spl[ll][ii][jj][kk][mm] = values.next_double();
}
} }
} }
@ -479,8 +426,7 @@ void PairComb3::read_lib()
for (i=0; i<maxxc+1; i++) for (i=0; i<maxxc+1; i++)
for (j=0; j<maxyc+1; j++) for (j=0; j<maxyc+1; j++)
for (k=0; k<maxconj; k++) { for (k=0; k<maxconj; k++) {
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); values = reader.next_values(8);
values = ValueTokenizer(s, " \t\n\r\f");
ll = values.next_int() - 1; ll = values.next_int() - 1;
ii = values.next_int(); ii = values.next_int();
@ -496,26 +442,21 @@ void PairComb3::read_lib()
for (i=0; i<maxxc; i++) for (i=0; i<maxxc; i++)
for (j=0; j<maxyc; j++) for (j=0; j<maxyc; j++)
for (k=0; k<maxconj-1; k++) { for (k=0; k<maxconj-1; k++) {
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); values = reader.next_values(4);
values = ValueTokenizer(s, " \t\n\r\f");
ll = values.next_int() - 1; ll = values.next_int() - 1;
ii = values.next_int(); ii = values.next_int();
jj = values.next_int(); jj = values.next_int();
kk = values.next_int() - 1; kk = values.next_int() - 1;
for(iii=0; iii<2; iii++) { for(iii=0; iii<2; iii++) {
utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); mm=iii*32;
values = ValueTokenizer(s, " \t\n\r\f"); reader.next_dvector(32, &tor_spl[ll][ii][jj][kk][mm]);
for (m = 0; m < 32 ; m++){
mm=iii*32+m;
tor_spl[ll][ii][jj][kk][mm] = values.next_double();
}
} }
} }
fclose(fp);
} catch (FileReaderException & fre) {
error->one(FLERR, fre.what());
} catch (TokenizerException & e) { } catch (TokenizerException & e) {
fclose(fp);
error->one(FLERR, e.what()); error->one(FLERR, e.what());
} }
} }