extract() implementation for dihedral multi/harmonic

This commit is contained in:
Evangelos Voyiatzis
2025-04-07 09:30:44 +02:00
committed by GitHub
parent e956e5ccda
commit 7655a4cb84
4 changed files with 25 additions and 1 deletions

View File

@ -464,6 +464,8 @@ sub-style name. The dihedral styles that currently work with fix adapt are:
+------------------------------------------------------------------------+----------------+----------------+ +------------------------------------------------------------------------+----------------+----------------+
| :doc:`cosine/squared/restricted <dihedral_cosine_squared_restricted>` | k,phi0 | type dihedrals | | :doc:`cosine/squared/restricted <dihedral_cosine_squared_restricted>` | k,phi0 | type dihedrals |
+------------------------------------------------------------------------+----------------+----------------+ +------------------------------------------------------------------------+----------------+----------------+
| :doc:`multi/harmonic <dihedral_multi_harmonic>` | a1,a2,a3,a4,a5 | type dihedrals |
+------------------------------------------------------------------------+----------------+----------------+
| :doc:`opls <dihedral_opls>` | k1,k2,k3,k4 | type dihedrals | | :doc:`opls <dihedral_opls>` | k1,k2,k3,k4 | type dihedrals |
+------------------------------------------------------------------------+----------------+----------------+ +------------------------------------------------------------------------+----------------+----------------+
| :doc:`quadratic <dihedral_quadratic>` | k,phi0 | type dihedrals | | :doc:`quadratic <dihedral_quadratic>` | k,phi0 | type dihedrals |

View File

@ -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])); 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); 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;
}

View File

@ -34,6 +34,7 @@ class DihedralMultiHarmonic : public Dihedral {
void read_restart(FILE *) override; void read_restart(FILE *) override;
void write_data(FILE *) override; void write_data(FILE *) override;
void born_matrix(int, int, int, int, int, double &, double &) override; void born_matrix(int, int, int, int, int, double &, double &) override;
void *extract(const char *, int &) override;
protected: protected:
double *a1, *a2, *a3, *a4, *a5; double *a1, *a2, *a3, *a4, *a5;

View File

@ -16,7 +16,12 @@ dihedral_coeff: ! |
3 56 10 32 84 52 3 56 10 32 84 52
4 23 80 61 83 74 4 23 80 61 83 74
5 19 90 13 15 58 5 19 90 13 15 58
extract: ! "" extract: ! |
a1 1
a2 1
a3 1
a4 1
a5 1
natoms: 29 natoms: 29
init_energy: 2854.9857316566695 init_energy: 2854.9857316566695
init_stress: ! |2- init_stress: ! |2-