modify bond style hybrid, so it can handle bond style quartic as a sub-style

This commit is contained in:
Axel Kohlmeyer
2018-11-12 16:06:55 -05:00
parent f68d77c7af
commit 8e9d4f5bce
2 changed files with 21 additions and 1 deletions

View File

@ -33,6 +33,7 @@ BondHybrid::BondHybrid(LAMMPS *lmp) : Bond(lmp)
{
writedata = 0;
nstyles = 0;
has_quartic = -1;
}
/* ---------------------------------------------------------------------- */
@ -171,6 +172,7 @@ void BondHybrid::settings(int narg, char **arg)
delete [] styles;
for (int i = 0; i < nstyles; i++) delete [] keywords[i];
delete [] keywords;
has_quartic = -1;
}
if (allocated) {
@ -214,14 +216,26 @@ void BondHybrid::settings(int narg, char **arg)
i = 0;
while (i < narg) {
for (m = 0; m < nstyles; m++)
if (strcmp(arg[i],keywords[m]) == 0)
error->all(FLERR,"Bond style hybrid cannot use same bond style twice");
if (strcmp(arg[i],"hybrid") == 0)
error->all(FLERR,"Bond style hybrid cannot have hybrid as an argument");
if (strcmp(arg[i],"none") == 0)
error->all(FLERR,"Bond style hybrid cannot have none as an argument");
if (strcmp(arg[i],"none") == 0)
error->all(FLERR,"Bond style hybrid cannot have none as an argument");
// register index of quartic bond type,
// so that bond type 0 can be mapped to it
if (strncmp(arg[i],"quartic",7) == 0)
has_quartic = m;
styles[nstyles] = force->new_bond(arg[i],1,dummy);
force->store_style(keywords[nstyles],arg[i],0);
@ -283,6 +297,12 @@ void BondHybrid::init_style()
{
for (int m = 0; m < nstyles; m++)
if (styles[m]) styles[m]->init_style();
// bond style quartic will set broken bonds to bond type 0, so we need
// to create an entry for it in the bond type to sub-style map
if (has_quartic >= 0)
map[0] = has_quartic;
}
/* ----------------------------------------------------------------------

View File

@ -47,7 +47,7 @@ class BondHybrid : public Bond {
private:
int *map; // which style each bond type points to
int has_quartic; // which style, if any is a quartic bond style
int *nbondlist; // # of bonds in sub-style bondlists
int *maxbond; // max # of bonds sub-style lists can store
int ***bondlist; // bondlist for each sub-style