mythos.energy.martini.base

Common Martini Energy Utilities.

Classes

MartiniTopology

Class representing the topology of a Martini system.

MartiniEnergyFunction

Base class for Martini energy functions.

MartiniEnergyConfiguration

Base class for Martini energy function configurations.

Functions

get_periodic(→ callable)

Return displacement function given box_size.

derive_bond_names(→ tuple[str, Ellipsis])

Derive bond names aligned with bonded_neighbors.

derive_angle_names(→ tuple[str, Ellipsis])

Derive angle names aligned with angles.

Module Contents

mythos.energy.martini.base.get_periodic(box_size: mythos.utils.types.Vector3D) callable[source]

Return displacement function given box_size.

mythos.energy.martini.base.derive_bond_names(residue_names: tuple[str, Ellipsis], atom_names: tuple[str, Ellipsis], bonded_neighbors: mythos.utils.types.Arr_N) tuple[str, Ellipsis][source]

Derive bond names aligned with bonded_neighbors.

Each name has the form RESIDUE_BEAD1_BEAD2, e.g. DMPC_GL1_GL2.

mythos.energy.martini.base.derive_angle_names(residue_names: tuple[str, Ellipsis], atom_names: tuple[str, Ellipsis], angles: mythos.utils.types.Arr_N) tuple[str, Ellipsis][source]

Derive angle names aligned with angles.

Each name has the form RESIDUE_BEAD1_BEAD2_BEAD3, e.g. DMPC_NC3_PO4_GL1.

class mythos.energy.martini.base.MartiniTopology[source]

Class representing the topology of a Martini system.

This class contains information about the atom types, bonded interactions, and angles in the system. It can be used to construct energy functions and to interpret simulation results.

atom_types

A tuple of atom type names.

atom_names

A tuple of atom names.

residue_names

A tuple of residue names.

angles

An array of shape (n_angles, 3) containing the indices of the atoms involved in each angle.

bonded_neighbors

An array of shape (n_bonds, 2) containing the indices of the bonded pairs of atoms.

atom_types: tuple[str, Ellipsis]
atom_names: tuple[str, Ellipsis]
residue_names: tuple[str, Ellipsis]
angles: mythos.utils.types.Arr_N
bonded_neighbors: mythos.utils.types.Arr_N
classmethod from_universe(universe: MDAnalysis.Universe) MartiniTopology[source]

Create a MartiniTopology from a Universe object.

classmethod from_tpr(tpr_file: pathlib.Path) MartiniTopology[source]

Create a MartiniTopology from a TPR format topology file.

property bond_names: tuple[str, Ellipsis]

Return bond names based on atom names and bonded neighbors.

property angle_names: tuple[str, Ellipsis]

Return angle names based on atom names and angles.

class mythos.energy.martini.base.MartiniEnergyFunction[source]

Bases: mythos.energy.base.BaseEnergyFunction

Base class for Martini energy functions.

atom_types: tuple[str, Ellipsis]
atom_names: tuple[str, Ellipsis]
residue_names: tuple[str, Ellipsis]
angles: mythos.utils.types.Arr_N
displacement_fn: callable
__post_init__(topology: None = None) None[source]
classmethod from_topology(topology: MartiniTopology, **kwargs) MartiniEnergyFunction[source]

Create an energy function from a MartiniTopology.

property bond_names: tuple[str, Ellipsis]

Return bond names based on atom names and bonded neighbors.

property angle_names: tuple[str, Ellipsis]

Return angle names based on atom names and angles.

class mythos.energy.martini.base.MartiniEnergyConfiguration(couplings: dict[str, list[str]] | None = None, **kwargs)[source]

Base class for Martini energy function configurations.

Given the large size and sparse inclusion of parameters in Martini models, this class implements parameters as a dictionary while supporting operations of configuration classes used in EnergyFunction.

This class also supports parameter coupling, where a single proxy parameter controls multiple underlying parameters. Couplings should be provided as a dictionary of lists, where each key is a proxy parameter name and the value is a list of target parameter names that it controls. The params field of this will be populated with the expanded parameters.

Subclasses can override __post_init__ for additional initialization logic. Parameters will be available in self.params after initialization.

couplings
reversed_couplings
params
__post_init__() None[source]

Hook for additional initialization in subclasses.

init_params() MartiniEnergyConfiguration[source]

Dependent params initialization. Default to no-op.

property opt_params: dict[str, any]

Returns the parameters to optimize.

__getitem__(key: str) any[source]
__contains__(key: str) bool[source]
__or__(other: MartiniEnergyConfiguration) MartiniEnergyConfiguration[source]

Merge two configurations, with other taking precedence.