From ccd6eeb8af38b6c37f9b1517835aa0a13891f729 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Fri, 4 Apr 2025 16:53:57 +0200 Subject: [PATCH 01/17] unit test --- unittest/force-styles/test_dihedral_style.cpp | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/unittest/force-styles/test_dihedral_style.cpp b/unittest/force-styles/test_dihedral_style.cpp index 5d0bd86d2b..b2f1a36346 100644 --- a/unittest/force-styles/test_dihedral_style.cpp +++ b/unittest/force-styles/test_dihedral_style.cpp @@ -746,3 +746,44 @@ TEST(DihedralStyle, numdiff) cleanup_lammps(lmp, test_config); if (!verbose) ::testing::internal::GetCapturedStdout(); } + +TEST(DihedralStyle, extract) +{ + if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP(); + + LAMMPS::argv args = {"DihedralStyle", "-log", "none", "-echo", "screen", "-nocite"}; + + if (!verbose) ::testing::internal::CaptureStdout(); + LAMMPS *lmp = nullptr; + try { + lmp = init_lammps(args, test_config, true); + } catch (std::exception &e) { + if (!verbose) ::testing::internal::GetCapturedStdout(); + FAIL() << e.what(); + } + if (!verbose) ::testing::internal::GetCapturedStdout(); + + if (!lmp) { + std::cerr << "One or more prerequisite styles are not available " + "in this LAMMPS configuration:\n"; + for (auto prerequisite : test_config.prerequisites) { + std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n"; + } + GTEST_SKIP(); + } + + auto *dihedral = lmp->force->dihedral; + void *ptr = nullptr; + int dim = 0; + for (auto extract : test_config.extract) { + ptr = dihedral->extract(extract.first.c_str(), dim); + EXPECT_NE(ptr, nullptr); + EXPECT_EQ(dim, extract.second); + } + ptr = dihedral->extract("does_not_exist", dim); + EXPECT_EQ(ptr, nullptr); + + if (!verbose) ::testing::internal::CaptureStdout(); + cleanup_lammps(lmp, test_config); + if (!verbose) ::testing::internal::GetCapturedStdout(); +} From 54d7f46151e22187cbe7716f3701dfd96dca68bb Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Fri, 4 Apr 2025 17:00:52 +0200 Subject: [PATCH 02/17] modifications in dihedral & dihedral_hybrid --- src/dihedral.cpp | 13 +++++++++++++ src/dihedral.h | 5 +++++ src/dihedral_hybrid.cpp | 8 ++++++++ src/dihedral_hybrid.h | 2 ++ 4 files changed, 28 insertions(+) diff --git a/src/dihedral.cpp b/src/dihedral.cpp index 14b59d2542..a6e66ac9cf 100644 --- a/src/dihedral.cpp +++ b/src/dihedral.cpp @@ -33,6 +33,7 @@ Dihedral::Dihedral(LAMMPS *_lmp) : Pointers(_lmp) { energy = 0.0; writedata = 0; + reinitflag = 1; allocated = 0; suffix_flag = Suffix::NONE; @@ -428,3 +429,15 @@ double Dihedral::memory_usage() bytes += (double) comm->nthreads * maxcvatom * 9 * sizeof(double); return bytes; } + +/* ----------------------------------------------------------------------- + reset all type-based dihedral params via init() +-------------------------------------------------------------------------- */ + +void Dihedral::reinit() +{ + if (!reinitflag) + error->all(FLERR, "Fix adapt interface to this dihedral style not supported"); + + init(); +} diff --git a/src/dihedral.h b/src/dihedral.h index 03a5690a49..7ca3379e44 100644 --- a/src/dihedral.h +++ b/src/dihedral.h @@ -37,6 +37,9 @@ class Dihedral : protected Pointers { // CENTROID_AVAIL = different and implemented // CENTROID_NOTAVAIL = different, not yet implemented + int reinitflag; // 0 if not compatible with fix adapt + // extract() method may still need to be added + // KOKKOS host/device flag and data masks ExecutionSpace execution_space; @@ -62,6 +65,8 @@ class Dihedral : protected Pointers { du = 0.0; du2 = 0.0; } + virtual void *extract(const char *, int &) { return nullptr; } + void reinit(); protected: int suffix_flag; // suffix compatibility flag diff --git a/src/dihedral_hybrid.cpp b/src/dihedral_hybrid.cpp index 3671391f5d..6210009170 100644 --- a/src/dihedral_hybrid.cpp +++ b/src/dihedral_hybrid.cpp @@ -326,6 +326,14 @@ void DihedralHybrid::init_style() if (styles[m]) styles[m]->init_style(); } +/* ---------------------------------------------------------------------- */ + +int DihedralHybrid::check_itype(int itype, char *substyle) +{ + if (strcmp(keywords[map[itype]], substyle) == 0) return 1; + return 0; +} + /* ---------------------------------------------------------------------- proc 0 writes to restart file ------------------------------------------------------------------------- */ diff --git a/src/dihedral_hybrid.h b/src/dihedral_hybrid.h index debc8a9d8d..4dcadcb67a 100644 --- a/src/dihedral_hybrid.h +++ b/src/dihedral_hybrid.h @@ -40,6 +40,8 @@ class DihedralHybrid : public Dihedral { void read_restart(FILE *) override; double memory_usage() override; + int check_itype(int, char *); + protected: int *map; // which style each dihedral type points to From 08795487374ea477e3a413bd26986b9bdfe7daf4 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Fri, 4 Apr 2025 17:03:58 +0200 Subject: [PATCH 03/17] change fix adapt header file --- src/fix_adapt.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/fix_adapt.h b/src/fix_adapt.h index 9f064a163e..5ed6559ef1 100644 --- a/src/fix_adapt.h +++ b/src/fix_adapt.h @@ -44,7 +44,7 @@ class FixAdapt : public Fix { private: int nadapt, resetflag, scaleflag, massflag; - int anypair, anybond, anyangle, anyimproper; + int anypair, anybond, anyangle, anydihedral, anyimproper; int nlevels_respa; char *id_fix_diam, *id_fix_chg; class FixStoreAtom *fix_diam, *fix_chg; @@ -57,9 +57,10 @@ class FixAdapt : public Fix { char *pstyle, *pparam; char *bstyle, *bparam; char *astyle, *aparam; + char *dstyle, *dparam; char *istyle, *iparam; int ilo, ihi, jlo, jhi; - int pdim, bdim, adim, idim; + int pdim, bdim, adim, ddim, idim; double *scalar, scalar_orig; double *vector, *vector_orig; double **array, **array_orig; @@ -67,6 +68,7 @@ class FixAdapt : public Fix { class Pair *pair; class Bond *bond; class Angle *angle; + class Dihedral *dihedral; class Improper *improper; }; From 3182dc26da3402463ad4aceb0e4ac506598e9dcb Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Fri, 4 Apr 2025 17:06:29 +0200 Subject: [PATCH 04/17] extract() implementation for dihedral quadratic --- src/EXTRA-MOLECULE/dihedral_quadratic.cpp | 12 ++++++++++++ src/EXTRA-MOLECULE/dihedral_quadratic.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/EXTRA-MOLECULE/dihedral_quadratic.cpp b/src/EXTRA-MOLECULE/dihedral_quadratic.cpp index 2350095f0d..e61f9eff74 100644 --- a/src/EXTRA-MOLECULE/dihedral_quadratic.cpp +++ b/src/EXTRA-MOLECULE/dihedral_quadratic.cpp @@ -435,3 +435,15 @@ void DihedralQuadratic::born_matrix(int nd, int i1, int i2, int i3, int i4, du = - 2.0 * k[type] * dphi * siinv; du2 = 2.0 * k[type] * siinv * siinv * ( 1.0 - dphi * c * siinv) ; } + +/* ---------------------------------------------------------------------- + return ptr to internal members upon request +------------------------------------------------------------------------ */ + +void *DihedralQuadratic::extract(const char *str, int &dim) +{ + dim = 1; + if (strcmp(str, "k") == 0) return (void *) k0; + if (strcmp(str, "phi0") == 0) return (void *) phi0; + return nullptr; +} diff --git a/src/EXTRA-MOLECULE/dihedral_quadratic.h b/src/EXTRA-MOLECULE/dihedral_quadratic.h index 89f6fa3b25..c584f1ae09 100644 --- a/src/EXTRA-MOLECULE/dihedral_quadratic.h +++ b/src/EXTRA-MOLECULE/dihedral_quadratic.h @@ -34,6 +34,7 @@ class DihedralQuadratic : 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 *k, *phi0; From 996faf7a94675286682273d425365369f7e44d46 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Fri, 4 Apr 2025 17:11:30 +0200 Subject: [PATCH 05/17] update documentation --- doc/src/fix_adapt.rst | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/doc/src/fix_adapt.rst b/doc/src/fix_adapt.rst index 2eec2eb457..681f9bb0af 100644 --- a/doc/src/fix_adapt.rst +++ b/doc/src/fix_adapt.rst @@ -14,7 +14,7 @@ Syntax * adapt = style name of this fix command * N = adapt simulation settings every this many timesteps * one or more attribute/arg pairs may be appended -* attribute = *pair* or *bond* or *angle* or *improper* or *kspace* or *atom* +* attribute = *pair* or *bond* or *angle* or *dihedral* or *improper* or *kspace* or *atom* .. parsed-literal:: @@ -33,6 +33,11 @@ Syntax aparam = parameter to adapt over time I = type angle to set parameter for (integer or type label) v_name = variable with name that calculates value of aparam + *dihedral* args = dstyle dparam I v_name + dstyle = dihedral style name (e.g., quadratic) + dparam = parameter to adapt over time + I = type dihedral to set parameter for (integer or type label) + v_name = variable with name that calculates value of iparam *improper* args = istyle iparam I v_name istyle = improper style name (e.g., cvff) iparam = parameter to adapt over time @@ -433,6 +438,34 @@ this fix uses to reset theta0 needs to generate values in radians. ---------- +.. versionadded:: TBD + +The *dihedral* keyword uses the specified variable to change the value of +a dihedral coefficient over time, very similar to how the *angle* keyword +operates. The only difference is that now a dihedral coefficient for a +given dihedral type is adapted. + +A wild-card asterisk can be used in place of or in conjunction with the +dihedral type argument to set the coefficients for multiple dihedral types. +This takes the form "\*" or "\*n" or "m\*" or "m\*n". If :math:`N` is +the number of dihedral types, then an asterisk with no numeric values means +all types from 1 to :math:`N`. A leading asterisk means all types from +1 to n (inclusive). A trailing asterisk means all types from m to +:math:`N` (inclusive). A middle asterisk means all types from m to n +(inclusive). + +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:`quadratic ` | k,phi0 | type dihedrals | ++---------------------------------------------------------+----------------+----------------+ + +Note that internally, phi0 is stored in radians, so the variable +this fix use to reset phi0 needs to generate values in radians. + +---------- + .. versionadded:: 2Apr2025 The *improper* keyword uses the specified variable to change the value of From d1dd05bf4e3de907401cc75f9eb38e4d53873fa1 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Fri, 4 Apr 2025 17:19:54 +0200 Subject: [PATCH 06/17] update unit test for quadratic dihedral --- unittest/force-styles/tests/dihedral-quadratic.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/unittest/force-styles/tests/dihedral-quadratic.yaml b/unittest/force-styles/tests/dihedral-quadratic.yaml index 21ddf42df0..3780ec61e4 100644 --- a/unittest/force-styles/tests/dihedral-quadratic.yaml +++ b/unittest/force-styles/tests/dihedral-quadratic.yaml @@ -17,7 +17,9 @@ dihedral_coeff: ! | 3 25 100 4 35 110 5 85 120 -extract: ! "" +extract: ! | + k 1 + phi0 1 natoms: 29 init_energy: 6216.314347066598 init_stress: ! |2- From 27ac8c0ea1f217d3788ae761faa74f7426c3fe3d Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 7 Apr 2025 09:05:42 +0200 Subject: [PATCH 07/17] 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: ! |- From 55964c123330e5143b736b9992a0832ede68713b Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 7 Apr 2025 09:11:42 +0200 Subject: [PATCH 08/17] extract() implementation for dihedral cosine squared restricted --- doc/src/fix_adapt.rst | 12 +++++++----- .../dihedral_cosine_squared_restricted.cpp | 12 ++++++++++++ .../dihedral_cosine_squared_restricted.h | 1 + .../tests/dihedral-cosine_squared_restricted.yaml | 4 +++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/doc/src/fix_adapt.rst b/doc/src/fix_adapt.rst index 2922a87b37..9dd8b0cd2f 100644 --- a/doc/src/fix_adapt.rst +++ b/doc/src/fix_adapt.rst @@ -457,11 +457,13 @@ 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 | -+---------------------------------------------------------+----------------+----------------+ ++------------------------------------------------------------------------+----------------+----------------+ +| :doc:`cosine/squared/restricted ` | k,phi0 | type dihedrals | ++------------------------------------------------------------------------+----------------+----------------+ +| :doc:`opls ` | k1,k2,k3,k4 | type dihedrals | ++------------------------------------------------------------------------+----------------+----------------+ +| :doc:`quadratic ` | k,phi0 | type dihedrals | ++------------------------------------------------------------------------+----------------+----------------+ Note that internally, phi0 is stored in radians, so the variable this fix use to reset phi0 needs to generate values in radians. diff --git a/src/EXTRA-MOLECULE/dihedral_cosine_squared_restricted.cpp b/src/EXTRA-MOLECULE/dihedral_cosine_squared_restricted.cpp index d8e34189d9..2edc87bb00 100644 --- a/src/EXTRA-MOLECULE/dihedral_cosine_squared_restricted.cpp +++ b/src/EXTRA-MOLECULE/dihedral_cosine_squared_restricted.cpp @@ -393,3 +393,15 @@ void DihedralCosineSquaredRestricted::born_matrix(int nd, int i1, int i2, int i3 du2 = 2 * k[type] * numerator / denominator; } + +/* ---------------------------------------------------------------------- + return ptr to internal members upon request + ------------------------------------------------------------------------ */ + + void *DihedralCosineSquaredRestricted::extract(const char *str, int &dim) + { + dim = 1; + if (strcmp(str, "k") == 0) return (void *) k; + if (strcmp(str, "phi0") == 0) return (void *) phi0; + return nullptr; + } diff --git a/src/EXTRA-MOLECULE/dihedral_cosine_squared_restricted.h b/src/EXTRA-MOLECULE/dihedral_cosine_squared_restricted.h index b9e2e1d9d8..f44d893cd0 100644 --- a/src/EXTRA-MOLECULE/dihedral_cosine_squared_restricted.h +++ b/src/EXTRA-MOLECULE/dihedral_cosine_squared_restricted.h @@ -34,6 +34,7 @@ class DihedralCosineSquaredRestricted : 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 *k, *phi0; diff --git a/unittest/force-styles/tests/dihedral-cosine_squared_restricted.yaml b/unittest/force-styles/tests/dihedral-cosine_squared_restricted.yaml index 0e43bc1741..12098105c5 100644 --- a/unittest/force-styles/tests/dihedral-cosine_squared_restricted.yaml +++ b/unittest/force-styles/tests/dihedral-cosine_squared_restricted.yaml @@ -16,7 +16,9 @@ dihedral_coeff: ! | 3 15.0 -10.0 4 12.0 0.0 5 11.0 45.0 -extract: ! "" +extract: ! | + k 1 + phi0 1 natoms: 29 init_energy: 10643.96352037142 init_stress: ! |2- From e956e5ccdabe36620d7698a8fcccf346ae5848ef Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 7 Apr 2025 09:24:44 +0200 Subject: [PATCH 09/17] extract() implementation for dihedral charmm and charmmfsw --- doc/src/fix_adapt.rst | 4 ++++ src/MOLECULE/dihedral_charmm.cpp | 13 +++++++++++++ src/MOLECULE/dihedral_charmm.h | 1 + src/MOLECULE/dihedral_charmmfsw.cpp | 13 +++++++++++++ src/MOLECULE/dihedral_charmmfsw.h | 1 + unittest/force-styles/tests/dihedral-charmm.yaml | 5 ++++- unittest/force-styles/tests/dihedral-charmmfsw.yaml | 5 ++++- 7 files changed, 40 insertions(+), 2 deletions(-) diff --git a/doc/src/fix_adapt.rst b/doc/src/fix_adapt.rst index 9dd8b0cd2f..3238f43f47 100644 --- a/doc/src/fix_adapt.rst +++ b/doc/src/fix_adapt.rst @@ -457,6 +457,10 @@ 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:`charmm ` | k,n,d | type dihedrals | ++------------------------------------------------------------------------+----------------+----------------+ +| :doc:`charmmfsw ` | k,n,d | type dihedrals | +------------------------------------------------------------------------+----------------+----------------+ | :doc:`cosine/squared/restricted ` | k,phi0 | type dihedrals | +------------------------------------------------------------------------+----------------+----------------+ diff --git a/src/MOLECULE/dihedral_charmm.cpp b/src/MOLECULE/dihedral_charmm.cpp index de6d59c1d4..2d8979493c 100644 --- a/src/MOLECULE/dihedral_charmm.cpp +++ b/src/MOLECULE/dihedral_charmm.cpp @@ -432,3 +432,16 @@ void DihedralCharmm::write_data(FILE *fp) for (int i = 1; i <= atom->ndihedraltypes; i++) fprintf(fp, "%d %g %d %d %g\n", i, k[i], multiplicity[i], shift[i], weight[i]); } + + /* ---------------------------------------------------------------------- + return ptr to internal members upon request + ------------------------------------------------------------------------ */ + + void *DihedralCharmm::extract(const char *str, int &dim) + { + dim = 1; + if (strcmp(str, "k") == 0) return (void *) k0; + if (strcmp(str, "n") == 0) return (void *) multiplicity; + if (strcmp(str, "d") == 0) return (void *) shift; + return nullptr; + } diff --git a/src/MOLECULE/dihedral_charmm.h b/src/MOLECULE/dihedral_charmm.h index 71e857d5f0..d9af7a56cf 100644 --- a/src/MOLECULE/dihedral_charmm.h +++ b/src/MOLECULE/dihedral_charmm.h @@ -34,6 +34,7 @@ class DihedralCharmm : public Dihedral { void write_restart(FILE *) override; void read_restart(FILE *) override; void write_data(FILE *) override; + void *extract(const char *, int &) override; protected: double *k, *weight, *cos_shift, *sin_shift; diff --git a/src/MOLECULE/dihedral_charmmfsw.cpp b/src/MOLECULE/dihedral_charmmfsw.cpp index a46fb8680c..1b249ea9e8 100644 --- a/src/MOLECULE/dihedral_charmmfsw.cpp +++ b/src/MOLECULE/dihedral_charmmfsw.cpp @@ -475,3 +475,16 @@ void DihedralCharmmfsw::write_data(FILE *fp) for (int i = 1; i <= atom->ndihedraltypes; i++) fprintf(fp, "%d %g %d %d %g\n", i, k[i], multiplicity[i], shift[i], weight[i]); } + + /* ---------------------------------------------------------------------- + return ptr to internal members upon request + ------------------------------------------------------------------------ */ + + void *DihedralCharmmfsw::extract(const char *str, int &dim) + { + dim = 1; + if (strcmp(str, "k") == 0) return (void *) k0; + if (strcmp(str, "n") == 0) return (void *) multiplicity; + if (strcmp(str, "d") == 0) return (void *) shift; + return nullptr; + } diff --git a/src/MOLECULE/dihedral_charmmfsw.h b/src/MOLECULE/dihedral_charmmfsw.h index 3930034356..660dafcd08 100644 --- a/src/MOLECULE/dihedral_charmmfsw.h +++ b/src/MOLECULE/dihedral_charmmfsw.h @@ -34,6 +34,7 @@ class DihedralCharmmfsw : public Dihedral { void write_restart(FILE *) override; void read_restart(FILE *) override; void write_data(FILE *) override; + void *extract(const char *, int &) override; protected: int implicit, weightflag, dihedflag; diff --git a/unittest/force-styles/tests/dihedral-charmm.yaml b/unittest/force-styles/tests/dihedral-charmm.yaml index cf407709b0..ebd47e2f41 100644 --- a/unittest/force-styles/tests/dihedral-charmm.yaml +++ b/unittest/force-styles/tests/dihedral-charmm.yaml @@ -19,7 +19,10 @@ dihedral_coeff: ! | 3 56.0 0 110 0.0 4 23.0 1 180 0.5 5 19.0 3 90 1.0 -extract: ! "" +extract: ! | + k 1 + n 1 + d 1 natoms: 29 init_energy: 1317.959844120986 init_stress: ! |2- diff --git a/unittest/force-styles/tests/dihedral-charmmfsw.yaml b/unittest/force-styles/tests/dihedral-charmmfsw.yaml index 6d2035acc5..3e1e32f5e3 100644 --- a/unittest/force-styles/tests/dihedral-charmmfsw.yaml +++ b/unittest/force-styles/tests/dihedral-charmmfsw.yaml @@ -19,7 +19,10 @@ dihedral_coeff: ! | 3 56.0 0 110 0.0 4 23.0 1 180 0.5 5 19.0 3 90 1.0 -extract: ! "" +extract: ! | + k 1 + n 1 + d 1 natoms: 29 init_energy: 1317.959844120986 init_stress: ! |2- From 7655a4cb84480ed971cc9cd2a54629b58339a55d Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 7 Apr 2025 09:30:44 +0200 Subject: [PATCH 10/17] 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- From e93709d34e714ed47bd3887bdab570a947cb61ac Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 7 Apr 2025 11:20:53 +0200 Subject: [PATCH 11/17] extract() implementation for dihedral helix --- doc/src/fix_adapt.rst | 2 ++ src/EXTRA-MOLECULE/dihedral_helix.cpp | 13 +++++++++++++ src/EXTRA-MOLECULE/dihedral_helix.h | 1 + unittest/force-styles/tests/dihedral-helix.yaml | 5 ++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/doc/src/fix_adapt.rst b/doc/src/fix_adapt.rst index 709a22ad6c..ed611b2c7c 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:`helix ` | a,b,c | type dihedrals | ++------------------------------------------------------------------------+----------------+----------------+ | :doc:`multi/harmonic ` | a1,a2,a3,a4,a5 | type dihedrals | +------------------------------------------------------------------------+----------------+----------------+ | :doc:`opls ` | k1,k2,k3,k4 | type dihedrals | diff --git a/src/EXTRA-MOLECULE/dihedral_helix.cpp b/src/EXTRA-MOLECULE/dihedral_helix.cpp index 4693d29cd7..55ac8ee776 100644 --- a/src/EXTRA-MOLECULE/dihedral_helix.cpp +++ b/src/EXTRA-MOLECULE/dihedral_helix.cpp @@ -430,3 +430,16 @@ void DihedralHelix::born_matrix(int nd, int i1, int i2, int i3, int i4, du2 = -(9.0*bphi[type]*cos(3.0*phi) + cphi[type]*cos(phi + MY_PI4))*siinv*siinv + (3.0*bphi[type]*sin(3.0*phi) + cphi[type]*sin(phi + MY_PI4))*c*siinv*siinv*siinv; } + +/* ---------------------------------------------------------------------- + return ptr to internal members upon request + ------------------------------------------------------------------------ */ + + void *DihedralHelix::extract(const char *str, int &dim) + { + dim = 1; + if (strcmp(str, "a") == 0) return (void *) aphi; + if (strcmp(str, "b") == 0) return (void *) bphi; + if (strcmp(str, "c") == 0) return (void *) cphi; + return nullptr; + } diff --git a/src/EXTRA-MOLECULE/dihedral_helix.h b/src/EXTRA-MOLECULE/dihedral_helix.h index 172a8c3469..be7263f900 100644 --- a/src/EXTRA-MOLECULE/dihedral_helix.h +++ b/src/EXTRA-MOLECULE/dihedral_helix.h @@ -34,6 +34,7 @@ class DihedralHelix : 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 *aphi, *bphi, *cphi; diff --git a/unittest/force-styles/tests/dihedral-helix.yaml b/unittest/force-styles/tests/dihedral-helix.yaml index e2372c8809..a6430b749b 100644 --- a/unittest/force-styles/tests/dihedral-helix.yaml +++ b/unittest/force-styles/tests/dihedral-helix.yaml @@ -16,7 +16,10 @@ dihedral_coeff: ! | 3 56 10 32 4 23 80 61 5 19 90 13 -extract: ! "" +extract: ! | + a 1 + b 1 + c 1 natoms: 29 init_energy: 4634.436545707672 init_stress: ! |- From 2b38b6d1c079dcecca320841dec2752fa4c89b26 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 7 Apr 2025 11:35:20 +0200 Subject: [PATCH 12/17] extract() implementation for dihedral class2 --- doc/src/fix_adapt.rst | 32 ++++++++++--------- src/CLASS2/dihedral_class2.cpp | 15 +++++++++ src/CLASS2/dihedral_class2.h | 1 + .../force-styles/tests/dihedral-class2.yaml | 8 ++++- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/doc/src/fix_adapt.rst b/doc/src/fix_adapt.rst index ed611b2c7c..8fb103f5c6 100644 --- a/doc/src/fix_adapt.rst +++ b/doc/src/fix_adapt.rst @@ -457,21 +457,23 @@ 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:`charmm ` | k,n,d | type dihedrals | -+------------------------------------------------------------------------+----------------+----------------+ -| :doc:`charmmfsw ` | k,n,d | type dihedrals | -+------------------------------------------------------------------------+----------------+----------------+ -| :doc:`cosine/squared/restricted ` | k,phi0 | type dihedrals | -+------------------------------------------------------------------------+----------------+----------------+ -| :doc:`helix ` | a,b,c | 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 | -+------------------------------------------------------------------------+----------------+----------------+ ++------------------------------------------------------------------------+-------------------------+----------------+ +| :doc:`charmm ` | k,n,d | type dihedrals | ++------------------------------------------------------------------------+-------------------------+----------------+ +| :doc:`charmmfsw ` | k,n,d | type dihedrals | ++------------------------------------------------------------------------+-------------------------+----------------+ +| :doc:`class2 ` | k1,k2,k3,phi1,phi2,phi3 | type dihedrals | ++------------------------------------------------------------------------+-------------------------+----------------+ +| :doc:`cosine/squared/restricted ` | k,phi0 | type dihedrals | ++------------------------------------------------------------------------+-------------------------+----------------+ +| :doc:`helix ` | a,b,c | 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 | ++------------------------------------------------------------------------+-------------------------+----------------+ Note that internally, phi0 is stored in radians, so the variable this fix use to reset phi0 needs to generate values in radians. diff --git a/src/CLASS2/dihedral_class2.cpp b/src/CLASS2/dihedral_class2.cpp index 9c4c1ad871..3ca8c52717 100644 --- a/src/CLASS2/dihedral_class2.cpp +++ b/src/CLASS2/dihedral_class2.cpp @@ -946,3 +946,18 @@ void DihedralClass2::write_data(FILE *fp) at_theta0_1[i]*180.0/MY_PI,at_theta0_2[i]*180.0/MY_PI); } +/* ---------------------------------------------------------------------- + return ptr to internal members upon request + ------------------------------------------------------------------------ */ + + void *DihedralClass2::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, "phi1") == 0) return (void *) phi1; + if (strcmp(str, "phi2") == 0) return (void *) phi2; + if (strcmp(str, "phi3") == 0) return (void *) phi3; + return nullptr; + } diff --git a/src/CLASS2/dihedral_class2.h b/src/CLASS2/dihedral_class2.h index ad42c5c3a1..d87dfb8a7b 100644 --- a/src/CLASS2/dihedral_class2.h +++ b/src/CLASS2/dihedral_class2.h @@ -33,6 +33,7 @@ class DihedralClass2 : public Dihedral { void write_restart(FILE *) override; void read_restart(FILE *) override; void write_data(FILE *) override; + void *extract(const char *, int &) override; protected: double *k1, *k2, *k3; diff --git a/unittest/force-styles/tests/dihedral-class2.yaml b/unittest/force-styles/tests/dihedral-class2.yaml index b041d4ebcb..572bc4e5d8 100644 --- a/unittest/force-styles/tests/dihedral-class2.yaml +++ b/unittest/force-styles/tests/dihedral-class2.yaml @@ -17,7 +17,13 @@ dihedral_coeff: ! | * at 75 42 31 75 42 31 120 50 * aat 75 120 160 * bb13 75 1.4 1.4 -extract: ! "" +extract: ! | + k1 1 + k2 1 + k3 1 + phi1 1 + phi2 1 + phi3 1 natoms: 29 init_energy: 3355.0074717375933 init_stress: ! |2- From 239eb64cbbff9a732178606bc88172d9ec1fa028 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 7 Apr 2025 11:58:24 +0200 Subject: [PATCH 13/17] modifications in fix adapt.cpp --- src/fix_adapt.cpp | 94 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 3 deletions(-) diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index eb7125caf7..6af96ae29e 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -19,6 +19,8 @@ #include "atom.h" #include "bond.h" #include "bond_hybrid.h" +#include "dihedral.h" +#include "dihedral_hybrid.h" #include "domain.h" #include "error.h" #include "fix_store_atom.h" @@ -43,14 +45,14 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -enum{PAIR, KSPACE, ATOM, BOND, ANGLE, IMPROPER}; +enum{PAIR, KSPACE, ATOM, BOND, ANGLE, DIHEDRAL, IMPROPER}; enum{DIAMETER, CHARGE}; /* ---------------------------------------------------------------------- */ FixAdapt::FixAdapt(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), nadapt(0), anypair(0), anybond(0), anyangle(0), - anyimproper(0), id_fix_diam(nullptr), id_fix_chg(nullptr), adapt(nullptr) + anydihedral(0), anyimproper(0), id_fix_diam(nullptr), id_fix_chg(nullptr), adapt(nullptr) { if (narg < 5) utils::missing_cmd_args(FLERR,"fix adapt", error); nevery = utils::inumeric(FLERR,arg[3],false,lmp); @@ -85,6 +87,10 @@ FixAdapt::FixAdapt(LAMMPS *lmp, int narg, char **arg) : if (iarg+5 > narg) utils::missing_cmd_args(FLERR,"fix adapt angle", error); nadapt++; iarg += 5; + } else if (strcmp(arg[iarg],"dihedral") == 0) { + if (iarg+5 > narg) utils::missing_cmd_args(FLERR,"fix adapt dihedral", error); + nadapt++; + iarg += 5; } else if (strcmp(arg[iarg],"improper") == 0) { if (iarg+5 > narg) utils::missing_cmd_args(FLERR,"fix adapt improper", error); nadapt++; @@ -155,6 +161,19 @@ FixAdapt::FixAdapt(LAMMPS *lmp, int narg, char **arg) : nadapt++; iarg += 5; + } else if (strcmp(arg[iarg],"dihedral") == 0) { + adapt[nadapt].which = DIHEDRAL; + adapt[nadapt].dihedral = nullptr; + adapt[nadapt].dstyle = utils::strdup(arg[iarg+1]); + adapt[nadapt].dparam = utils::strdup(arg[iarg+2]); + utils::bounds_typelabel(FLERR, arg[iarg+3], 1, atom->ndihedraltypes, + adapt[nadapt].ilo, adapt[nadapt].ihi, lmp, Atom::DIHEDRAL); + if (utils::strmatch(arg[iarg+4],"^v_")) { + adapt[nadapt].var = utils::strdup(arg[iarg+4]+2); + } else error->all(FLERR,"Argument #{} must be variable not {}", iarg+5, arg[iarg+4]); + nadapt++; + iarg += 5; + } else if (strcmp(arg[iarg],"improper") == 0) { adapt[nadapt].which = IMPROPER; adapt[nadapt].improper = nullptr; @@ -246,6 +265,12 @@ FixAdapt::FixAdapt(LAMMPS *lmp, int narg, char **arg) : // allocate improper style arrays: + n = atom->ndihedraltypes; + for (int m = 0; m < nadapt; ++m) + if (adapt[m].which == DIHEDRAL) memory->create(adapt[m].vector_orig,n+1,"adapt:vector_orig"); + + // allocate improper style arrays: + n = atom->nimpropertypes; for (int m = 0; m < nadapt; ++m) if (adapt[m].which == IMPROPER) memory->create(adapt[m].vector_orig,n+1,"adapt:vector_orig"); @@ -270,6 +295,10 @@ FixAdapt::~FixAdapt() delete[] adapt[m].astyle; delete[] adapt[m].aparam; memory->destroy(adapt[m].vector_orig); + } else if (adapt[m].which == DIHEDRAL) { + delete[] adapt[m].dstyle; + delete[] adapt[m].dparam; + memory->destroy(adapt[m].vector_orig); } else if (adapt[m].which == IMPROPER) { delete[] adapt[m].istyle; delete[] adapt[m].iparam; @@ -368,6 +397,7 @@ void FixAdapt::init() anypair = 0; anybond = 0; anyangle = 0; + anydihedral = 0; anyimproper = 0; for (int m = 0; m < nadapt; m++) { @@ -509,6 +539,40 @@ void FixAdapt::init() delete[] astyle; + } else if (ad->which == DIHEDRAL) { + ad->dihedral = nullptr; + anydihedral = 1; + + char *dstyle = utils::strdup(ad->dstyle); + if (lmp->suffix_enable) + ad->dihedral = force->dihedral_match(fmt::format("{}/{}",dstyle,lmp->suffix)); + + if (ad->dihedral == nullptr) ad->dihedral = force->dihedral_match(dstyle); + if (ad->dihedral == nullptr ) + error->all(FLERR,"Fix adapt dihedral style {} does not exist", dstyle); + + void *ptr = ad->dihedral->extract(ad->dparam,ad->ddim); + + if (ptr == nullptr) + error->all(FLERR,"Fix adapt dihedral style parameter {} not supported", ad->dparam); + + // for dihedral styles, use a vector + + if (ad->ddim == 1) ad->vector = (double *) ptr; + + if (utils::strmatch(force->dihedral_style,"^hybrid")) { + auto dihedral = dynamic_cast(force->dihedral); + if (dihedral) { + for (i = ad->ilo; i <= ad->ihi; i++) { + if (!dihedral->check_itype(i,dstyle)) + error->all(FLERR,"Fix adapt type dihedral range is not valid " + "for dihedral hybrid sub-style {}", dstyle); + } + } + } + + delete[] dstyle; + } else if (ad->which == IMPROPER) { ad->improper = nullptr; anyimproper = 1; @@ -569,7 +633,7 @@ void FixAdapt::init() if (restart_reset) restart_reset = 0; - // make copy of original pair/bond/angle/improper array values + // make copy of original pair/bond/angle/dihedral/improper array values for (int m = 0; m < nadapt; m++) { Adapt *ad = &adapt[m]; @@ -588,6 +652,10 @@ void FixAdapt::init() for (i = ad->ilo; i <= ad->ihi; ++i ) ad->vector_orig[i] = ad->vector[i]; + } else if (ad->which == DIHEDRAL && ad->ddim == 1) { + for (i = ad->ilo; i <= ad->ihi; ++i ) + ad->vector_orig[i] = ad->vector[i]; + } else if (ad->which == IMPROPER && ad->idim == 1) { for (i = ad->ilo; i <= ad->ihi; ++i ) ad->vector_orig[i] = ad->vector[i]; @@ -710,6 +778,18 @@ void FixAdapt::change_settings() ad->vector[i] = value; } + // set dihedral type array values: + + } else if (ad->which == DIHEDRAL) { + if (ad->ddim == 1) { + if (scaleflag) + for (i = ad->ilo; i <= ad->ihi; ++i ) + ad->vector[i] = value*ad->vector_orig[i]; + else + for (i = ad->ilo; i <= ad->ihi; ++i ) + ad->vector[i] = value; + } + // set improper type array values: } else if (ad->which == IMPROPER) { @@ -797,6 +877,7 @@ void FixAdapt::change_settings() if (anypair) force->pair->reinit(); if (anybond) force->bond->reinit(); if (anyangle) force->angle->reinit(); + if (anydihedral) force->dihedral->reinit(); if (anyimproper) force->improper->reinit(); // reset KSpace charges if charges have changed @@ -832,6 +913,12 @@ void FixAdapt::restore_settings() ad->vector[i] = ad->vector_orig[i]; } + } else if (ad->which == DIHEDRAL) { + if (ad->ddim == 1) { + for (int i = ad->ilo; i <= ad->ihi; i++) + ad->vector[i] = ad->vector_orig[i]; + } + } else if (ad->which == IMPROPER) { if (ad->idim == 1) { for (int i = ad->ilo; i <= ad->ihi; i++) @@ -878,6 +965,7 @@ void FixAdapt::restore_settings() if (anypair) force->pair->reinit(); if (anybond) force->bond->reinit(); if (anyangle) force->angle->reinit(); + if (anydihedral) force->dihedral->reinit(); if (anyimproper) force->improper->reinit(); if (chgflag && force->kspace) force->kspace->qsum_qsq(); } From d012d13c1946a4367ae5f0c8c409aea3ea418d7f Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 7 Apr 2025 20:52:55 +0200 Subject: [PATCH 14/17] fix typo in dihedral_quadratic.cpp --- src/EXTRA-MOLECULE/dihedral_quadratic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EXTRA-MOLECULE/dihedral_quadratic.cpp b/src/EXTRA-MOLECULE/dihedral_quadratic.cpp index e61f9eff74..27cf6e2ab6 100644 --- a/src/EXTRA-MOLECULE/dihedral_quadratic.cpp +++ b/src/EXTRA-MOLECULE/dihedral_quadratic.cpp @@ -443,7 +443,7 @@ void DihedralQuadratic::born_matrix(int nd, int i1, int i2, int i3, int i4, void *DihedralQuadratic::extract(const char *str, int &dim) { dim = 1; - if (strcmp(str, "k") == 0) return (void *) k0; + if (strcmp(str, "k") == 0) return (void *) k; if (strcmp(str, "phi0") == 0) return (void *) phi0; return nullptr; } From 7b0c5f3e04a964404731c4978d67f425587710d2 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 7 Apr 2025 21:07:52 +0200 Subject: [PATCH 15/17] Fix typo indihedral_charmmfsw.cpp --- src/MOLECULE/dihedral_charmmfsw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MOLECULE/dihedral_charmmfsw.cpp b/src/MOLECULE/dihedral_charmmfsw.cpp index 1b249ea9e8..2415dff8cd 100644 --- a/src/MOLECULE/dihedral_charmmfsw.cpp +++ b/src/MOLECULE/dihedral_charmmfsw.cpp @@ -483,7 +483,7 @@ void DihedralCharmmfsw::write_data(FILE *fp) void *DihedralCharmmfsw::extract(const char *str, int &dim) { dim = 1; - if (strcmp(str, "k") == 0) return (void *) k0; + if (strcmp(str, "k") == 0) return (void *) k; if (strcmp(str, "n") == 0) return (void *) multiplicity; if (strcmp(str, "d") == 0) return (void *) shift; return nullptr; From 809d5b5b93a2a0413c5e61e272ad04b842fe430f Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 7 Apr 2025 21:08:35 +0200 Subject: [PATCH 16/17] Fix typo in dihedral_charmm.cpp --- src/MOLECULE/dihedral_charmm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MOLECULE/dihedral_charmm.cpp b/src/MOLECULE/dihedral_charmm.cpp index 2d8979493c..1ec29da780 100644 --- a/src/MOLECULE/dihedral_charmm.cpp +++ b/src/MOLECULE/dihedral_charmm.cpp @@ -440,7 +440,7 @@ void DihedralCharmm::write_data(FILE *fp) void *DihedralCharmm::extract(const char *str, int &dim) { dim = 1; - if (strcmp(str, "k") == 0) return (void *) k0; + if (strcmp(str, "k") == 0) return (void *) k; if (strcmp(str, "n") == 0) return (void *) multiplicity; if (strcmp(str, "d") == 0) return (void *) shift; return nullptr; From 813e65026e78706250c347f1cd5e139cccbcba0a Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Tue, 8 Apr 2025 15:53:45 +0200 Subject: [PATCH 17/17] fixing whitespaces --- .../dihedral_cosine_squared_restricted.cpp | 18 ++++++------ src/MOLECULE/dihedral_charmm.cpp | 24 ++++++++-------- src/MOLECULE/dihedral_charmmfsw.cpp | 24 ++++++++-------- src/MOLECULE/dihedral_multi_harmonic.cpp | 28 +++++++++---------- src/MOLECULE/dihedral_opls.cpp | 24 ++++++++-------- 5 files changed, 59 insertions(+), 59 deletions(-) diff --git a/src/EXTRA-MOLECULE/dihedral_cosine_squared_restricted.cpp b/src/EXTRA-MOLECULE/dihedral_cosine_squared_restricted.cpp index 2edc87bb00..ae82a7873d 100644 --- a/src/EXTRA-MOLECULE/dihedral_cosine_squared_restricted.cpp +++ b/src/EXTRA-MOLECULE/dihedral_cosine_squared_restricted.cpp @@ -396,12 +396,12 @@ void DihedralCosineSquaredRestricted::born_matrix(int nd, int i1, int i2, int i3 /* ---------------------------------------------------------------------- return ptr to internal members upon request - ------------------------------------------------------------------------ */ - - void *DihedralCosineSquaredRestricted::extract(const char *str, int &dim) - { - dim = 1; - if (strcmp(str, "k") == 0) return (void *) k; - if (strcmp(str, "phi0") == 0) return (void *) phi0; - return nullptr; - } +------------------------------------------------------------------------ */ + +void *DihedralCosineSquaredRestricted::extract(const char *str, int &dim) +{ + dim = 1; + if (strcmp(str, "k") == 0) return (void *) k; + if (strcmp(str, "phi0") == 0) return (void *) phi0; + return nullptr; +} diff --git a/src/MOLECULE/dihedral_charmm.cpp b/src/MOLECULE/dihedral_charmm.cpp index 1ec29da780..ddce2dd66f 100644 --- a/src/MOLECULE/dihedral_charmm.cpp +++ b/src/MOLECULE/dihedral_charmm.cpp @@ -433,15 +433,15 @@ void DihedralCharmm::write_data(FILE *fp) fprintf(fp, "%d %g %d %d %g\n", i, k[i], multiplicity[i], shift[i], weight[i]); } - /* ---------------------------------------------------------------------- - return ptr to internal members upon request - ------------------------------------------------------------------------ */ - - void *DihedralCharmm::extract(const char *str, int &dim) - { - dim = 1; - if (strcmp(str, "k") == 0) return (void *) k; - if (strcmp(str, "n") == 0) return (void *) multiplicity; - if (strcmp(str, "d") == 0) return (void *) shift; - return nullptr; - } +/* ---------------------------------------------------------------------- + return ptr to internal members upon request +------------------------------------------------------------------------ */ + +void *DihedralCharmm::extract(const char *str, int &dim) +{ + dim = 1; + if (strcmp(str, "k") == 0) return (void *) k; + if (strcmp(str, "n") == 0) return (void *) multiplicity; + if (strcmp(str, "d") == 0) return (void *) shift; + return nullptr; +} diff --git a/src/MOLECULE/dihedral_charmmfsw.cpp b/src/MOLECULE/dihedral_charmmfsw.cpp index 2415dff8cd..75e4f688b1 100644 --- a/src/MOLECULE/dihedral_charmmfsw.cpp +++ b/src/MOLECULE/dihedral_charmmfsw.cpp @@ -476,15 +476,15 @@ void DihedralCharmmfsw::write_data(FILE *fp) fprintf(fp, "%d %g %d %d %g\n", i, k[i], multiplicity[i], shift[i], weight[i]); } - /* ---------------------------------------------------------------------- - return ptr to internal members upon request - ------------------------------------------------------------------------ */ - - void *DihedralCharmmfsw::extract(const char *str, int &dim) - { - dim = 1; - if (strcmp(str, "k") == 0) return (void *) k; - if (strcmp(str, "n") == 0) return (void *) multiplicity; - if (strcmp(str, "d") == 0) return (void *) shift; - return nullptr; - } +/* ---------------------------------------------------------------------- + return ptr to internal members upon request +------------------------------------------------------------------------ */ + +void *DihedralCharmmfsw::extract(const char *str, int &dim) +{ + dim = 1; + if (strcmp(str, "k") == 0) return (void *) k; + if (strcmp(str, "n") == 0) return (void *) multiplicity; + if (strcmp(str, "d") == 0) return (void *) shift; + return nullptr; +} diff --git a/src/MOLECULE/dihedral_multi_harmonic.cpp b/src/MOLECULE/dihedral_multi_harmonic.cpp index 89577fca9d..ef75c6b5e7 100644 --- a/src/MOLECULE/dihedral_multi_harmonic.cpp +++ b/src/MOLECULE/dihedral_multi_harmonic.cpp @@ -409,17 +409,17 @@ void DihedralMultiHarmonic::born_matrix(int nd, int i1, int i2, int i3, int i4, } - /* ---------------------------------------------------------------------- - 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; - } +/* ---------------------------------------------------------------------- + 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_opls.cpp b/src/MOLECULE/dihedral_opls.cpp index 0989e1d7e4..2b58f51366 100644 --- a/src/MOLECULE/dihedral_opls.cpp +++ b/src/MOLECULE/dihedral_opls.cpp @@ -433,15 +433,15 @@ void DihedralOPLS::born_matrix(int nd, int i1, int i2, int i3, int i4, double &d } /* ---------------------------------------------------------------------- - 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; - } + 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; +}