KMatrix

class glotaran.builtin.megacomplexes.decay.k_matrix.KMatrix[source]

Bases: object

A K-Matrix represents a first order differental system.

Attributes Summary

label

ModelProperty is an extension of the property decorator.

matrix

ModelProperty is an extension of the property decorator.

Methods Summary

a_matrix

The A matrix of the KMatrix.

a_matrix_as_markdown

Returns the A Matrix as markdown formatted table.

a_matrix_general

The A matrix of the KMatrix for a general model.

a_matrix_sequential

The A matrix of the KMatrix for a sequential model.

as_dict

combine

Creates a combined matrix.

eigen

Returns the eigenvalues and eigenvectors of the k matrix.

empty

Creates an empty K-Matrix.

fill

from_dict

full

The full representation of the KMatrix as numpy array.

get_parameter_labels

involved_compartments

A list of all compartments in the Matrix.

is_sequential

Returns true in the KMatrix represents an unibranched model.

markdown

matrix_as_markdown

Returns the KMatrix as markdown formatted table.

rates

The resulting rates of the matrix.

reduced

The reduced representation of the KMatrix as numpy array.

validate

Methods Documentation

a_matrix(compartments: list[str], initial_concentration: np.ndarray) np.ndarray[source]

The A matrix of the KMatrix.

Parameters

initial_concentration – The initial concentration.

a_matrix_as_markdown(compartments: list[str], initial_concentration: np.ndarray) MarkdownStr[source]

Returns the A Matrix as markdown formatted table.

Parameters

initial_concentration – The initial concentration.

a_matrix_general(compartments: list[str], initial_concentration: np.ndarray) np.ndarray[source]

The A matrix of the KMatrix for a general model.

Parameters

initial_concentration – The initial concentration.

a_matrix_sequential(compartments: list[str]) np.ndarray[source]

The A matrix of the KMatrix for a sequential model.

Parameters

initial_concentration – The initial concentration.

as_dict() dict
combine(k_matrix: glotaran.builtin.megacomplexes.decay.k_matrix.KMatrix) glotaran.builtin.megacomplexes.decay.k_matrix.KMatrix[source]

Creates a combined matrix.

When combining k-matrices km1 and km2 (km1.combine(km2)), entries in km1 will be overwritten by corresponding entries in km2.

Parameters

k_matrix – KMatrix to combine with.

Returns

The combined KMatrix.

Return type

combined

eigen(compartments: list[str]) tuple[np.ndarray, np.ndarray][source]

Returns the eigenvalues and eigenvectors of the k matrix.

Parameters

compartments – The compartment order.

classmethod empty(label: str, compartments: list[str]) KMatrix[source]

Creates an empty K-Matrix. Useful for combining.

Parameters
  • label – Label of the K-Matrix

  • compartments – A list of all compartments in the model.

fill(model: Model, parameters: ParameterGroup) cls
classmethod from_dict(values: dict) cls
full(compartments: list[str]) np.ndarray[source]

The full representation of the KMatrix as numpy array.

Parameters

compartments – The compartment order.

get_parameter_labels() list[str]
involved_compartments() list[str][source]

A list of all compartments in the Matrix.

is_sequential(compartments: list[str], initial_concentration: np.ndarray) bool[source]

Returns true in the KMatrix represents an unibranched model.

Parameters

initial_concentration – The initial concentration.

property label: model_property.glotaran_property_type

ModelProperty is an extension of the property decorator.

It adds convenience functions for meta programming model items.

markdown(all_parameters: ParameterGroup = None, initial_parameters: ParameterGroup = None) MarkdownStr
property matrix: model_property.glotaran_property_type

ModelProperty is an extension of the property decorator.

It adds convenience functions for meta programming model items.

matrix_as_markdown(compartments: list[str] = None, fill_parameters: bool = False) MarkdownStr[source]

Returns the KMatrix as markdown formatted table.

Parameters
  • compartments – (default = None) An optional list defining the desired order of compartments.

  • fill_parameters (bool) – (default = False) If true, the entries will be filled with the actual parameter values instead of labels.

rates(compartments: list[str], initial_concentration: np.ndarray) np.ndarray[source]

The resulting rates of the matrix.

By definition, the eigenvalues of the compartmental model are negative and the rates are the negatives of the eigenvalues, thus the eigenvalues need to be multiplied with -1 to get rates with the correct sign.

Parameters
  • compartments (list[str]) – Names of compartment used to order the matrix.

  • initial_concentration (np.ndarray) – The initial concentration.

reduced(compartments: list[str]) np.ndarray[source]

The reduced representation of the KMatrix as numpy array.

Parameters

compartments – The compartment order.

validate(model: Model, parameters: ParameterGroup | None = None) list[str]