add support for bond style hybrid to fix adapt

This commit is contained in:
Axel Kohlmeyer
2024-09-16 20:49:44 -04:00
parent 11365e7b2e
commit 5d40a9640d
3 changed files with 30 additions and 7 deletions

View File

@ -385,6 +385,14 @@ void BondHybrid::init_style()
else map[0] = -1;
}
/* ---------------------------------------------------------------------- */
int BondHybrid::check_itype(int itype, char *substyle)
{
if (strcmp(keywords[map[itype]], substyle) == 0) return 1;
return 0;
}
/* ----------------------------------------------------------------------
return an equilbrium bond length
------------------------------------------------------------------------- */

View File

@ -44,6 +44,8 @@ class BondHybrid : public Bond {
double single(int, double, int, int, double &) override;
double memory_usage() override;
int check_itype(int, char *);
protected:
int *map; // which style each bond type points to
int has_quartic; // which style, if any is a quartic bond style

View File

@ -17,6 +17,7 @@
#include "angle.h"
#include "atom.h"
#include "bond.h"
#include "bond_hybrid.h"
#include "domain.h"
#include "error.h"
#include "fix_store_atom.h"
@ -386,11 +387,15 @@ void FixAdapt::init()
if (utils::strmatch(force->pair_style,"^hybrid")) {
auto pair = dynamic_cast<PairHybrid *>(force->pair);
for (i = ad->ilo; i <= ad->ihi; i++)
for (j = MAX(ad->jlo,i); j <= ad->jhi; j++)
if (!pair->check_ijtype(i,j,pstyle))
error->all(FLERR,"Fix adapt type pair range is not valid "
"for pair hybrid sub-style {}", pstyle);
if (pair) {
for (i = ad->ilo; i <= ad->ihi; i++) {
for (j = MAX(ad->jlo,i); j <= ad->jhi; j++) {
if (!pair->check_ijtype(i,j,pstyle))
error->all(FLERR,"Fix adapt type pair range is not valid "
"for pair hybrid sub-style {}", pstyle);
}
}
}
}
delete[] pstyle;
@ -416,8 +421,16 @@ void FixAdapt::init()
if (ad->bdim == 1) ad->vector = (double *) ptr;
if (utils::strmatch(force->bond_style,"^hybrid"))
error->all(FLERR,"Fix adapt does not support bond_style hybrid");
if (utils::strmatch(force->bond_style,"^hybrid")) {
auto bond = dynamic_cast<BondHybrid *>(force->bond);
if (bond) {
for (i = ad->ilo; i <= ad->ihi; i++) {
if (!bond->check_itype(i,bstyle))
error->all(FLERR,"Fix adapt type bond range is not valid "
"for pair hybrid sub-style {}", bstyle);
}
}
}
delete[] bstyle;