extract() implementation for dihedral cosine squared restricted

This commit is contained in:
Evangelos Voyiatzis
2025-04-07 09:11:42 +02:00
committed by GitHub
parent 27ac8c0ea1
commit 55964c1233
4 changed files with 23 additions and 6 deletions

View File

@ -457,11 +457,13 @@ all types from 1 to :math:`N`. A leading asterisk means all types from
If :doc:`dihedral_style hybrid <dihedral_hybrid>` is used, *dstyle* should be a If :doc:`dihedral_style hybrid <dihedral_hybrid>` is used, *dstyle* should be a
sub-style name. The dihedral styles that currently work with fix adapt are: 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:`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 |
+---------------------------------------------------------+----------------+----------------+ +------------------------------------------------------------------------+----------------+----------------+
Note that internally, phi0 is stored in radians, so the variable Note that internally, phi0 is stored in radians, so the variable
this fix use to reset phi0 needs to generate values in radians. this fix use to reset phi0 needs to generate values in radians.

View File

@ -393,3 +393,15 @@ void DihedralCosineSquaredRestricted::born_matrix(int nd, int i1, int i2, int i3
du2 = 2 * k[type] * numerator / denominator; 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;
}

View File

@ -34,6 +34,7 @@ class DihedralCosineSquaredRestricted : 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 *k, *phi0; double *k, *phi0;

View File

@ -16,7 +16,9 @@ dihedral_coeff: ! |
3 15.0 -10.0 3 15.0 -10.0
4 12.0 0.0 4 12.0 0.0
5 11.0 45.0 5 11.0 45.0
extract: ! "" extract: ! |
k 1
phi0 1
natoms: 29 natoms: 29
init_energy: 10643.96352037142 init_energy: 10643.96352037142
init_stress: ! |2- init_stress: ! |2-