Skip to content

🧬 Models

This section provides an overview of the core data models used in PyReactLab-Core, including classes for representing chemical species, reactions, and reaction networks. Each model is designed to facilitate efficient storage, manipulation, and analysis of chemical data.

⚛️ Chemical Reaction Model

pyreactlab_core.models.reaction

Reaction

Bases: BaseModel

A class representing a chemical reaction, including its analysis and properties.

Attributes

name : str The name of the reaction. reaction : str The chemical reaction equation as a string. reaction_mode_symbol : Optional[ReactionMode] The symbol used to separate reactants and products in a reaction equation. analysis : Dict[str, Any] A dictionary containing the analysis results of the reaction.

Properties

symbolic_reaction : str The symbolic representation of the balanced reaction. symbolic_unbalanced_reaction : str The symbolic representation of the unbalanced reaction. reactants_names : list[str] A list of names of the reactants in the reaction. products_names : list[str] A list of names of the products in the reaction. products : List[Dict[str, Any]] A list of dictionaries representing the products of the reaction. reactants : List[Dict[str, Any]] A list of dictionaries representing the reactants of the reaction. reaction_coefficients : Dict[str, float] A dictionary of reaction coefficients for each component. reaction_stoichiometry : Dict[str, float] A dictionary representing the stoichiometry of the reaction. reaction_stoichiometry_matrix : list[float] A list representing the stoichiometry matrix of the reaction. carbon_count : int The total number of carbon atoms in the reaction. reaction_state : str The state of the reaction (e.g., "balanced", "unbalanced"). reaction_phase : Optional[PhaseRule] The phase rule of the reaction, if applicable. state_count : Dict[str, int] A dictionary counting the states of components in the reaction. component_ids : Dict[str, int] A dictionary mapping component names to their IDs. all_components : list[str] A list of all component names involved in the reaction.

Methods

_run_existing_analysis(self) -> Reaction Validates and analyzes the reaction after initialization.

all_components: list[str] property

analysis: Dict[str, Any] = Field(default_factory=dict) class-attribute instance-attribute

carbon_count: int property

component_ids: Dict[str, int] property

name: str instance-attribute

products: List[Dict[str, Any]] property

products_names: list[str] property

reactants: List[Dict[str, Any]] property

reactants_names: list[str] property

reaction: str instance-attribute

reaction_coefficients: Dict[str, float] property

reaction_mode_symbol: Optional[ReactionMode] = Field(default=None, description='The symbol used to separate reactants and products in a reaction equation.') class-attribute instance-attribute

reaction_phase: Optional[PhaseRule] property

reaction_state: str property

reaction_stoichiometry: Dict[str, float] property

reaction_stoichiometry_matrix: list[float] property

state_count: Dict[str, int] property

symbolic_reaction: str property

symbolic_unbalanced_reaction: str property