diff --git a/doc/src/fix_adapt.rst b/doc/src/fix_adapt.rst index 0aa0323309..1943798160 100644 --- a/doc/src/fix_adapt.rst +++ b/doc/src/fix_adapt.rst @@ -360,9 +360,8 @@ all types from 1 to :math:`N`. A leading asterisk means all types from :math:`N` (inclusive). A middle asterisk means all types from m to n (inclusive). -Currently *angle* does not support angle_style hybrid nor angle_style -hybrid/overlay as angle styles. The angle styles that currently work -with fix adapt are +If :doc:`angle_style hybrid ` is used, *astyle* should be a +sub-style name. The angle styles that currently work with fix adapt are: +------------------------------------+----------+-------------+ | :doc:`harmonic ` | k,theta0 | type angles | diff --git a/src/angle_hybrid.cpp b/src/angle_hybrid.cpp index a015882a15..1261a78176 100644 --- a/src/angle_hybrid.cpp +++ b/src/angle_hybrid.cpp @@ -320,6 +320,14 @@ void AngleHybrid::init_style() if (styles[m]) styles[m]->init_style(); } +/* ---------------------------------------------------------------------- */ + +int AngleHybrid::check_itype(int itype, char *substyle) +{ + if (strcmp(keywords[map[itype]], substyle) == 0) return 1; + return 0; +} + /* ---------------------------------------------------------------------- return an equilbrium angle length ------------------------------------------------------------------------- */ diff --git a/src/angle_hybrid.h b/src/angle_hybrid.h index a6da29245e..a84096b297 100644 --- a/src/angle_hybrid.h +++ b/src/angle_hybrid.h @@ -42,8 +42,10 @@ class AngleHybrid : public Angle { double single(int, int, int, int) override; double memory_usage() override; + int check_itype(int, char *); + protected: - int *map; // which style each angle type points to + int *map; // which style each angle type points to int *nanglelist; // # of angles in sub-style anglelists int *maxangle; // max # of angles sub-style lists can store int ***anglelist; // anglelist for each sub-style diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index 6bab704c22..c725707b29 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -15,6 +15,7 @@ #include "fix_adapt.h" #include "angle.h" +#include "angle_hybrid.h" #include "atom.h" #include "bond.h" #include "bond_hybrid.h" @@ -455,8 +456,16 @@ void FixAdapt::init() if (ad->adim == 1) ad->vector = (double *) ptr; - if (utils::strmatch(force->angle_style,"^hybrid")) - error->all(FLERR,"Fix adapt does not support angle_style hybrid"); + if (utils::strmatch(force->angle_style,"^hybrid")) { + auto angle = dynamic_cast(force->angle); + if (angle) { + for (i = ad->ilo; i <= ad->ihi; i++) { + if (!angle->check_itype(i,astyle)) + error->all(FLERR,"Fix adapt type angle range is not valid " + "for pair hybrid sub-style {}", astyle); + } + } + } delete[] astyle;