molgri.molecules.transitions
Combine a ParsedTrajectory and a FullGrid to generate a MSM or SqRA model.
In this module, the two methods of evaluating transitions between states - the MSM and the SqRA approach - are implemented.
Classes
|
Markov state model (MSM) works on simulation trajectories by discretising the accessed space and counting transitions between states in the time span of tau. |
|
As opposed to MSM, this object works with a pseudo-trajectory that evaluates energy at each grid point and with geometric parameters of position space division. |
|
This class takes the data from ParsedTrajectory and combines it with a specific FullGrid so that each simulation step can be assigned to a cell and the occupancy of those cells evaluated. |
|
A class that contains both the MSM and SQRA models. |
- class molgri.molecules.transitions.SimulationHistogram(parsed_trajectory: ParsedTrajectory, full_grid: FullGrid)
This class takes the data from ParsedTrajectory and combines it with a specific FullGrid so that each simulation step can be assigned to a cell and the occupancy of those cells evaluated.
- __init__(parsed_trajectory: ParsedTrajectory, full_grid: FullGrid)
- get_name() str
- get_all_assignments() Tuple[ndarray[Any, dtype[ScalarType]], ndarray[Any, dtype[ScalarType]]]
For each step in the trajectory assign which cell it belongs to. Uses the default atom selection of the ParsedTrajectory object.
- Returns:
(all centers of mass within grid, all assignments to grid cells)
- class molgri.molecules.transitions.TransitionModel(sim_hist: SimulationHistogram, tau_array: ndarray[Any, dtype[ScalarType]] | None = None, use_saved: bool = False)
A class that contains both the MSM and SQRA models.
- __init__(sim_hist: SimulationHistogram, tau_array: ndarray[Any, dtype[ScalarType]] | None = None, use_saved: bool = False)
- get_name() str
- abstract get_transitions_matrix() ndarray[Any, dtype[ScalarType]]
For MSM, generate the transition matrix from simulation data. For SQRA, generate rate matrix from the point energy calculations.
- Returns:
an array of shape (num_tau, num_cells, num_cells) for MSM or (n1, num_cells, num_cells) for SQRA
- get_eigenval_eigenvec(num_eigenv: int = 15, **kwargs) Tuple[ndarray[Any, dtype[ScalarType]], ndarray[Any, dtype[ScalarType]]]
Obtain eigenvectors and eigenvalues of the transition matrices.
- Args:
num_eigenv: how many eigenvalues/vectors pairs to return (too many may give inaccurate results) **kwargs: named arguments to forward to eigs()
- Returns:
(eigenval, eigenvec) a tuple of eigenvalues and eigenvectors, first num_eigv given for all tau-s Eigenval is of shape (num_tau, num_eigenv), eigenvec of shape (num_tau, num_cells, num_eigenv)
- class molgri.molecules.transitions.MSM(sim_hist: SimulationHistogram, tau_array: ndarray[Any, dtype[ScalarType]] | None = None, use_saved: bool = False)
Markov state model (MSM) works on simulation trajectories by discretising the accessed space and counting transitions between states in the time span of tau.
- get_transitions_matrix(noncorr: bool = False) ndarray[Any, dtype[ScalarType]]
Obtain a set of transition matrices for different tau-s specified in self.tau_array.
- Args:
- noncorr: bool, should only every tau-th frame be used for MSM construction
(if False, use sliding window - much more expensive but throws away less data)
- Returns:
an array of transition matrices of shape (self.num_tau, self.num_cells, self.num_cells)
- class molgri.molecules.transitions.SQRA(sim_hist: SimulationHistogram, **kwargs)
As opposed to MSM, this object works with a pseudo-trajectory that evaluates energy at each grid point and with geometric parameters of position space division.
- __init__(sim_hist: SimulationHistogram, **kwargs)
- get_transitions_matrix(D: float = 1, energy_type: str = 'Potential') ndarray[Any, dtype[ScalarType]]
Return the rate matrix as calculated by the SqRA formula:
Q_ij = np.sqrt(pi_j/pi_i) * D * S_ij / (h_ij * V_i)
- Args:
D: diffusion constant energy_type: the keyword to pass to self.sim_hist.parsed_trajectory.get_all_energies to obtain energy information at centers of cells
- Returns:
a (1, self.num_cells, self.num_cells) array that is a rate matrix estimated with SqRA (first dimension is expanded to be compatible with the MSM model)