extract() implementation for dihedral charmm and charmmfsw

This commit is contained in:
Evangelos Voyiatzis
2025-04-07 09:24:44 +02:00
committed by GitHub
parent 55964c1233
commit e956e5ccda
7 changed files with 40 additions and 2 deletions

View File

@ -457,6 +457,10 @@ 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
sub-style name. The dihedral styles that currently work with fix adapt are:
+------------------------------------------------------------------------+----------------+----------------+
| :doc:`charmm <dihedral_charmm>` | k,n,d | type dihedrals |
+------------------------------------------------------------------------+----------------+----------------+
| :doc:`charmmfsw <dihedral_charmm>` | k,n,d | type dihedrals |
+------------------------------------------------------------------------+----------------+----------------+
| :doc:`cosine/squared/restricted <dihedral_cosine_squared_restricted>` | k,phi0 | type dihedrals |
+------------------------------------------------------------------------+----------------+----------------+

View File

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

View File

@ -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;

View File

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

View File

@ -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;

View File

@ -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-

View File

@ -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-