Merge pull request #2292 from akohlmey/warning-no-mixing-data-file

Print warning when writing PairCoeff section in data file may not sufficiently reproduce all pair coefficients
This commit is contained in:
Axel Kohlmeyer 2020-08-18 13:45:44 -04:00 committed by GitHub
commit d63f3d87eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 0 deletions

View File

@ -86,6 +86,7 @@ Pair::Pair(LAMMPS *lmp) : Pointers(lmp)
manybody_flag = 0; manybody_flag = 0;
offset_flag = 0; offset_flag = 0;
mix_flag = GEOMETRIC; mix_flag = GEOMETRIC;
mixed_flag = 1;
tail_flag = 0; tail_flag = 0;
etail = ptail = etail_ij = ptail_ij = 0.0; etail = ptail = etail_ij = ptail_ij = 0.0;
ncoultablebits = 12; ncoultablebits = 12;
@ -251,10 +252,12 @@ void Pair::init()
cutforce = 0.0; cutforce = 0.0;
etail = ptail = 0.0; etail = ptail = 0.0;
mixed_flag = 1;
double cut; double cut;
for (i = 1; i <= atom->ntypes; i++) for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) { for (j = i; j <= atom->ntypes; j++) {
if ((i != j) && setflag[i][j]) mixed_flag = 0;
cut = init_one(i,j); cut = init_one(i,j);
cutsq[i][j] = cutsq[j][i] = cut*cut; cutsq[i][j] = cutsq[j][i] = cut*cut;
cutforce = MAX(cutforce,cut); cutforce = MAX(cutforce,cut);

View File

@ -105,6 +105,7 @@ class Pair : protected Pointers {
int allocated; // 0/1 = whether arrays are allocated int allocated; // 0/1 = whether arrays are allocated
// public so external driver can check // public so external driver can check
int compute_flag; // 0 if skip compute() int compute_flag; // 0 if skip compute()
int mixed_flag; // 1 if all itype != jtype coeffs are from mixing
enum{GEOMETRIC,ARITHMETIC,SIXTHPOWER}; // mixing options enum{GEOMETRIC,ARITHMETIC,SIXTHPOWER}; // mixing options

View File

@ -303,6 +303,9 @@ void WriteData::force_fields()
{ {
if (force->pair && force->pair->writedata) { if (force->pair && force->pair->writedata) {
if (pairflag == II) { if (pairflag == II) {
if ((comm->me == 0) && (force->pair->mixed_flag == 0))
error->warning(FLERR,"Not all mixed pair coeffs generated from mixing. "
"Use write_data with 'pair ij' option to store all pair coeffs.");
fmt::print(fp,"\nPair Coeffs # {}\n\n", force->pair_style); fmt::print(fp,"\nPair Coeffs # {}\n\n", force->pair_style);
force->pair->write_data(fp); force->pair->write_data(fp);
} else if (pairflag == IJ) { } else if (pairflag == IJ) {