From 7655a4cb84480ed971cc9cd2a54629b58339a55d Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 7 Apr 2025 09:30:44 +0200 Subject: [PATCH] extract() implementation for dihedral multi/harmonic --- doc/src/fix_adapt.rst | 2 ++ src/MOLECULE/dihedral_multi_harmonic.cpp | 16 ++++++++++++++++ src/MOLECULE/dihedral_multi_harmonic.h | 1 + .../tests/dihedral-multi_harmonic.yaml | 7 ++++++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/src/fix_adapt.rst b/doc/src/fix_adapt.rst index 3238f43f47..709a22ad6c 100644 --- a/doc/src/fix_adapt.rst +++ b/doc/src/fix_adapt.rst @@ -464,6 +464,8 @@ sub-style name. The dihedral styles that currently work with fix adapt are: +------------------------------------------------------------------------+----------------+----------------+ | :doc:`cosine/squared/restricted ` | k,phi0 | type dihedrals | +------------------------------------------------------------------------+----------------+----------------+ +| :doc:`multi/harmonic ` | a1,a2,a3,a4,a5 | type dihedrals | ++------------------------------------------------------------------------+----------------+----------------+ | :doc:`opls ` | k1,k2,k3,k4 | type dihedrals | +------------------------------------------------------------------------+----------------+----------------+ | :doc:`quadratic ` | k,phi0 | type dihedrals | diff --git a/src/MOLECULE/dihedral_multi_harmonic.cpp b/src/MOLECULE/dihedral_multi_harmonic.cpp index a952d1ad41..89577fca9d 100644 --- a/src/MOLECULE/dihedral_multi_harmonic.cpp +++ b/src/MOLECULE/dihedral_multi_harmonic.cpp @@ -407,3 +407,19 @@ void DihedralMultiHarmonic::born_matrix(int nd, int i1, int i2, int i3, int i4, du = a2[type] + c * (2.0 * a3[type] + c * (3.0 * a4[type] + c * 4.0 * a5[type])); du2 = 2.0 * a3[type] + 6.0 * c * (a4[type] + 2.0 * a5[type] * c); } + + + /* ---------------------------------------------------------------------- + return ptr to internal members upon request + ------------------------------------------------------------------------ */ + + void *DihedralMultiHarmonic::extract(const char *str, int &dim) + { + dim = 1; + if (strcmp(str, "a1") == 0) return (void *) a1; + if (strcmp(str, "a2") == 0) return (void *) a2; + if (strcmp(str, "a3") == 0) return (void *) a3; + if (strcmp(str, "a4") == 0) return (void *) a4; + if (strcmp(str, "a5") == 0) return (void *) a5; + return nullptr; + } diff --git a/src/MOLECULE/dihedral_multi_harmonic.h b/src/MOLECULE/dihedral_multi_harmonic.h index b1f46bd4bf..1d0ef4a573 100644 --- a/src/MOLECULE/dihedral_multi_harmonic.h +++ b/src/MOLECULE/dihedral_multi_harmonic.h @@ -34,6 +34,7 @@ class DihedralMultiHarmonic : public Dihedral { void read_restart(FILE *) override; void write_data(FILE *) override; void born_matrix(int, int, int, int, int, double &, double &) override; + void *extract(const char *, int &) override; protected: double *a1, *a2, *a3, *a4, *a5; diff --git a/unittest/force-styles/tests/dihedral-multi_harmonic.yaml b/unittest/force-styles/tests/dihedral-multi_harmonic.yaml index 567e61ad7f..dbbd054829 100644 --- a/unittest/force-styles/tests/dihedral-multi_harmonic.yaml +++ b/unittest/force-styles/tests/dihedral-multi_harmonic.yaml @@ -16,7 +16,12 @@ dihedral_coeff: ! | 3 56 10 32 84 52 4 23 80 61 83 74 5 19 90 13 15 58 -extract: ! "" +extract: ! | + a1 1 + a2 1 + a3 1 + a4 1 + a5 1 natoms: 29 init_energy: 2854.9857316566695 init_stress: ! |2-