From 27ac8c0ea1f217d3788ae761faa74f7426c3fe3d Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 7 Apr 2025 09:05:42 +0200 Subject: [PATCH] extract() implementation for dihedral opls --- doc/src/fix_adapt.rst | 2 ++ src/MOLECULE/dihedral_opls.cpp | 14 ++++++++++++++ src/MOLECULE/dihedral_opls.h | 1 + unittest/force-styles/tests/dihedral-opls.yaml | 6 +++++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/doc/src/fix_adapt.rst b/doc/src/fix_adapt.rst index 681f9bb0af..2922a87b37 100644 --- a/doc/src/fix_adapt.rst +++ b/doc/src/fix_adapt.rst @@ -457,6 +457,8 @@ all types from 1 to :math:`N`. A leading asterisk means all types from If :doc:`dihedral_style hybrid ` is used, *dstyle* should be a sub-style name. The dihedral styles that currently work with fix adapt are: ++---------------------------------------------------------+----------------+----------------+ +| :doc:`opls ` | k1,k2,k3,k4 | type dihedrals | +---------------------------------------------------------+----------------+----------------+ | :doc:`quadratic ` | k,phi0 | type dihedrals | +---------------------------------------------------------+----------------+----------------+ diff --git a/src/MOLECULE/dihedral_opls.cpp b/src/MOLECULE/dihedral_opls.cpp index 1ec2f869a5..0989e1d7e4 100644 --- a/src/MOLECULE/dihedral_opls.cpp +++ b/src/MOLECULE/dihedral_opls.cpp @@ -431,3 +431,17 @@ void DihedralOPLS::born_matrix(int nd, int i1, int i2, int i3, int i4, double &d 16.0 * k4[type] * si * cos(4.0 * phi) - 4.0 * k4[type] * sin(4.0 * phi)) / (si * si * si); } + +/* ---------------------------------------------------------------------- + return ptr to internal members upon request + ------------------------------------------------------------------------ */ + + void *DihedralOPLS::extract(const char *str, int &dim) + { + dim = 1; + if (strcmp(str, "k1") == 0) return (void *) k1; + if (strcmp(str, "k2") == 0) return (void *) k2; + if (strcmp(str, "k3") == 0) return (void *) k3; + if (strcmp(str, "k4") == 0) return (void *) k4; + return nullptr; + } diff --git a/src/MOLECULE/dihedral_opls.h b/src/MOLECULE/dihedral_opls.h index 82180cf323..9a483960cc 100644 --- a/src/MOLECULE/dihedral_opls.h +++ b/src/MOLECULE/dihedral_opls.h @@ -34,6 +34,7 @@ class DihedralOPLS : 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 *k1, *k2, *k3, *k4; diff --git a/unittest/force-styles/tests/dihedral-opls.yaml b/unittest/force-styles/tests/dihedral-opls.yaml index 7cf3578d1e..7a28a2d0fe 100644 --- a/unittest/force-styles/tests/dihedral-opls.yaml +++ b/unittest/force-styles/tests/dihedral-opls.yaml @@ -16,7 +16,11 @@ dihedral_coeff: ! | 3 56 10 32 84 4 23 80 61 83 5 19 90 13 15 -extract: ! "" +extract: ! | + k1 1 + k2 1 + k3 1 + k4 1 natoms: 29 init_energy: 2260.6834525285753 init_stress: ! |-