add extract() function to angle style cosine/squared

This commit is contained in:
Axel Kohlmeyer
2024-09-19 07:21:15 -04:00
parent 6f10648d5f
commit 11838801d6
4 changed files with 23 additions and 6 deletions

View File

@ -365,11 +365,13 @@ all types from 1 to :math:`N`. A leading asterisk means all types from
If :doc:`angle_style hybrid <angle_hybrid>` is used, *astyle* should be a
sub-style name. The angle styles that currently work with fix adapt are:
+------------------------------------+----------+-------------+
| :doc:`harmonic <angle_harmonic>` | k,theta0 | type angles |
+------------------------------------+----------+-------------+
| :doc:`cosine <angle_cosine>` | k | type angles |
+------------------------------------+----------+-------------+
+-----------------------------------------------+----------+-------------+
| :doc:`harmonic <angle_harmonic>` | k,theta0 | type angles |
+-----------------------------------------------+----------+-------------+
| :doc:`cosine <angle_cosine>` | k | type angles |
+-----------------------------------------------+----------+-------------+
| :doc:`cosine/squared <angle_cosine_squared>` | k,theta0 | type angles |
+-----------------------------------------------+----------+-------------+
Note that internally, theta0 is stored in radians, so the variable
this fix uses to reset theta0 needs to generate values in radians.

View File

@ -291,3 +291,15 @@ void AngleCosineSquared::born_matrix(int type, int i1, int i2, int i3, double &d
du2 = 2 * k[type];
du = du2 * dcostheta;
}
/* ----------------------------------------------------------------------
return ptr to internal members upon request
------------------------------------------------------------------------ */
void *AngleCosineSquared::extract(const char *str, int &dim)
{
dim = 1;
if (strcmp(str, "k") == 0) return (void *) k;
if (strcmp(str, "theta0") == 0) return (void *) theta0;
return nullptr;
}

View File

@ -36,6 +36,7 @@ class AngleCosineSquared : public Angle {
void write_data(FILE *) override;
double single(int, int, int, int) override;
void born_matrix(int type, int i1, int i2, int i3, double &du, double &du2) override;
void *extract(const char *, int &) override;
protected:
double *k, *theta0;

View File

@ -16,7 +16,9 @@ angle_coeff: ! |
3 50.0 120.0
4 100.0 108.5
equilibrium: 4 1.9216075064457567 1.9373154697137058 2.0943951023931953 1.8936822384138476
extract: ! ""
extract: |
k 1
theta0 1
natoms: 29
init_energy: 36.01162448576962
init_stress: ! |2-