# `pycgtool.functionalforms`¶

Utilities for describing the functional forms of bonded potentials being calculated.

The links above list the bonded potentials available for use in GROMACS force fields. These can be implemented as functional forms in PyCGTOOL by subclassing `FunctionalForm`.

## Module Contents¶

### Classes¶

 `FunctionalForm` Parent class of any functional form used in Boltzmann Inversion to convert variance to a force constant. `Harmonic` Simple harmonic potential. `CosHarmonic` Cosine based angle potential. `MartiniDefaultLength` Dummy functional form which returns a fixed force constant. `MartiniDefaultAngle` Dummy functional form which returns a fixed force constant. `MartiniDefaultDihedral` Dummy functional form which returns a fixed force constant.

### Functions¶

 `get_functional_forms`() → enum.Enum Get enum of known functional forms.
`pycgtool.functionalforms.``get_functional_forms`()enum.Enum[source]

Get enum of known functional forms.

class `pycgtool.functionalforms.``FunctionalForm`(mean_func: Callable = np.nanmean, variance_func: Callable = np.nanvar)[source]

Parent class of any functional form used in Boltzmann Inversion to convert variance to a force constant.

`eqm`(self, values: Iterable[float], temp: float)float[source]

Calculate equilibrium value.

May be overridden by functional forms.

Parameters
• values – Measured internal coordinate values from which to calculate equilibrium value

• temp – Temperature of simulation

Returns

Calculated equilibrium value

abstract `fconst`(self, values: Iterable[float], temp: float)float[source]

Calculate force constant. Abstract static method to be defined by all functional forms.

Parameters
• values – Measured internal coordinate values from which to calculate force constant

• temp – Temperature of simulation

Returns

Calculated force constant

abstract `gromacs_type_ids`(self)Tuple[int]

Return tuple of GROMACS potential type ids when used as length, angle, dihedral.

Return tuple[int]

Tuple of GROMACS potential type ids

classmethod `gromacs_type_id_by_natoms`(cls, natoms: int)int[source]

Return the GROMACS potential type id for this functional form when used with natoms.

Parameters

natoms (int) – Number of atoms in bond

Return int

GROMACS potential type id

class `pycgtool.functionalforms.``Harmonic`(mean_func: Callable = np.nanmean, variance_func: Callable = np.nanvar)[source]

Bases: `FunctionalForm`

Simple harmonic potential.

`gromacs_type_ids` = [1, 1, 1]
`fconst`(self, values: Iterable[float], temp: float)float[source]

Calculate force constant. Abstract static method to be defined by all functional forms.

Parameters
• values – Measured internal coordinate values from which to calculate force constant

• temp – Temperature of simulation

Returns

Calculated force constant

class `pycgtool.functionalforms.``CosHarmonic`(mean_func: Callable = np.nanmean, variance_func: Callable = np.nanvar)[source]

Bases: `FunctionalForm`

Cosine based angle potential.

Uses the transformation in eqn 20 of the above source.

`gromacs_type_ids` = [None, 2, None]
`fconst`(self, values: Iterable[float], temp: float)float[source]

Calculate force constant. Abstract static method to be defined by all functional forms.

Parameters
• values – Measured internal coordinate values from which to calculate force constant

• temp – Temperature of simulation

Returns

Calculated force constant

class `pycgtool.functionalforms.``MartiniDefaultLength`(mean_func: Callable = np.nanmean, variance_func: Callable = np.nanvar)[source]

Bases: `FunctionalForm`

Dummy functional form which returns a fixed force constant.

`gromacs_type_ids` = [1, None, None]
`fconst`(self, values: Iterable[float], temp: float)float[source]

Calculate force constant. Abstract static method to be defined by all functional forms.

Parameters
• values – Measured internal coordinate values from which to calculate force constant

• temp – Temperature of simulation

Returns

Calculated force constant

class `pycgtool.functionalforms.``MartiniDefaultAngle`(mean_func: Callable = np.nanmean, variance_func: Callable = np.nanvar)[source]

Bases: `FunctionalForm`

Dummy functional form which returns a fixed force constant.

`gromacs_type_ids` = [None, 2, None]
`fconst`(self, values: Iterable[float], temp: float)float[source]

Calculate force constant. Abstract static method to be defined by all functional forms.

Parameters
• values – Measured internal coordinate values from which to calculate force constant

• temp – Temperature of simulation

Returns

Calculated force constant

class `pycgtool.functionalforms.``MartiniDefaultDihedral`(mean_func: Callable = np.nanmean, variance_func: Callable = np.nanvar)[source]

Bases: `FunctionalForm`

Dummy functional form which returns a fixed force constant.

`gromacs_type_ids` = [None, None, 1]
`fconst`(self, values: Iterable[float], temp: float)float[source]

Calculate force constant. Abstract static method to be defined by all functional forms.

Parameters
• values – Measured internal coordinate values from which to calculate force constant

• temp – Temperature of simulation

Returns

Calculated force constant