report how many pair_coeff settings parameters were generated from mixing

This commit is contained in:
Axel Kohlmeyer
2021-11-19 13:43:32 -05:00
parent 229ce0a61b
commit 23d40a1d61
3 changed files with 22 additions and 10 deletions

View File

@ -41,6 +41,7 @@ using namespace LAMMPS_NS;
using namespace MathConst;
enum{NONE,RLINEAR,RSQ,BMP};
static const std::string mixing_rule_names[Pair::SIXTHPOWER+1] = {"geometric", "arithmetic", "sixthpower" };
// allocate space for static class instance variable and initialize it
@ -217,11 +218,9 @@ void Pair::init()
if (tail_flag && domain->nonperiodic && comm->me == 0)
error->warning(FLERR,"Using pair tail corrections with non-periodic system");
if (!compute_flag && tail_flag && comm->me == 0)
error->warning(FLERR,"Using pair tail corrections with "
"pair_modify compute no");
error->warning(FLERR,"Using pair tail corrections with pair_modify compute no");
if (!compute_flag && offset_flag && comm->me == 0)
error->warning(FLERR,"Using pair potential shift with "
"pair_modify compute no");
error->warning(FLERR,"Using pair potential shift with pair_modify compute no");
// for manybody potentials
// check if bonded exclusions could invalidate the neighbor list
@ -259,13 +258,18 @@ void Pair::init()
etail = ptail = 0.0;
mixed_flag = 1;
double cut;
int mixed_count = 0;
for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) {
if ((i != j) && setflag[i][j]) mixed_flag = 0;
did_mix = false;
cut = init_one(i,j);
cutsq[i][j] = cutsq[j][i] = cut*cut;
cutforce = MAX(cutforce,cut);
if (i != j) {
if (setflag[i][j]) mixed_flag = 0;
if (did_mix) ++mixed_count;
}
if (tail_flag) {
etail += etail_ij;
ptail += ptail_ij;
@ -275,6 +279,12 @@ void Pair::init()
}
}
}
if (!manybody_flag && (comm->me == 0)) {
const int num_mixed_pairs = atom->ntypes * (atom->ntypes - 1) / 2;
utils::logmesg(lmp," generated {} of {} mixed pair_coeff terms from {} mixing rule\n",
mixed_count, num_mixed_pairs, mixing_rule_names[mix_flag]);
}
}
/* ----------------------------------------------------------------------
@ -681,6 +691,7 @@ void Pair::free_disp_tables()
double Pair::mix_energy(double eps1, double eps2, double sig1, double sig2)
{
did_mix = true;
if (mix_flag == GEOMETRIC)
return sqrt(eps1*eps2);
else if (mix_flag == ARITHMETIC)
@ -688,7 +699,8 @@ double Pair::mix_energy(double eps1, double eps2, double sig1, double sig2)
else if (mix_flag == SIXTHPOWER)
return (2.0 * sqrt(eps1*eps2) *
pow(sig1,3.0) * pow(sig2,3.0) / (pow(sig1,6.0) + pow(sig2,6.0)));
else return 0.0;
else did_mix = false;
return 0.0;
}
/* ----------------------------------------------------------------------

View File

@ -110,6 +110,7 @@ class Pair : protected Pointers {
// public so external driver can check
int compute_flag; // 0 if skip compute()
int mixed_flag; // 1 if all itype != jtype coeffs are from mixing
bool did_mix; // set to true by mix_energy() to indicate that mixing was performed
enum { GEOMETRIC, ARITHMETIC, SIXTHPOWER }; // mixing options

View File

@ -706,11 +706,10 @@ double PairHybrid::init_one(int i, int j)
for (int k = 0; k < nmap[i][j]; k++) {
map[j][i][k] = map[i][j][k];
double cut = styles[map[i][j][k]]->init_one(i,j);
styles[map[i][j][k]]->cutsq[i][j] =
styles[map[i][j][k]]->cutsq[j][i] = cut*cut;
if (styles[map[i][j][k]]->did_mix) did_mix = true;
styles[map[i][j][k]]->cutsq[i][j] = styles[map[i][j][k]]->cutsq[j][i] = cut*cut;
if (styles[map[i][j][k]]->ghostneigh)
cutghost[i][j] = cutghost[j][i] =
MAX(cutghost[i][j],styles[map[i][j][k]]->cutghost[i][j]);
cutghost[i][j] = cutghost[j][i] = MAX(cutghost[i][j],styles[map[i][j][k]]->cutghost[i][j]);
if (tail_flag) {
etail_ij += styles[map[i][j][k]]->etail_ij;
ptail_ij += styles[map[i][j][k]]->ptail_ij;