API Referenceο
Module: radigen3.oxidation.py
Core module for radical oxidation modeling within the Generative Simulation Initiative.
This kernel supports the generative construction, parameterization, and simulation of oxidation reaction networks in chemically diverse mixtures, such as edible oils, FAMEs, fuels, and polymers. The oxidation model is built from chemical species annotated with reactive functions and product maps. Radical propagation, decomposition, and termination pathways are handled automatically, including temperature effects and diffusion-limited corrections.
- Features:
Auto-generation of all relevant reaction species and products from labile H donors.
Rule-based reaction network construction with automatic cross-reaction inference.
Temperature-dependent Arrhenius and Smoluchowski kinetics.
Support for hydroperoxide decomposition equilibrium (free vs. cage).
Stoichiometric matrix generation and fast vectorized ODE solving.
Oxygen dissolution modeled as a transport-limited source term.
Support for hundreds of reactions and species from text prompts.
Support arbitrary lumped species.
- LLM compatibility:
This module is designed to be a kernel for Large Language Models (LLMs) that can reason about and manipulate chemical mixtures and reaction systems from natural language. The full system is composable, traceable, and extensible.
Key References: [2] Touffet M., Vitrac O. (2025), βTemperature-dependent kinetics of unsaturated fatty acid methyl esters:
Modeling autoxidation mechanismsβ, Food Chemistry, 481, 143952. https://doi.org/10.1016/j.foodchem.2025.143952
- [1] Touffet M., Smith P., Vitrac O. (2023), βA comprehensive two-scale model for predicting the oxidizability
of fatty acid methyl ester mixturesβ, Food Research International, 173(1), 113289. https://doi.org/10.1016/j.foodres.2023.113289
### π§© Overview of Core Classes +βββββββ+βββββββββββββββββββββ+ | Class | Purpose | +=====================+===============================================================+ | species | Represents chemical species (radicals, peroxides, stable) | +βββββββ+βββββββββββββββββββββ+ | reaction | Canonical reaction with fingerprint and type inference | +βββββββ+βββββββββββββββββββββ+ | reactionRateDB | Registry of rate constants (kβ, Eβ) searchable by fingerprint | +βββββββ+βββββββββββββββββββββ+ | mixture | Encodes physical/chemical system: species, V, A, T, kOβ, pOβ | +βββββββ+βββββββββββββββββββββ+ | mixtureKinetics | Numerical integrator for the chemical system (solve_ivp) | +βββββββ+βββββββββββββββββββββ+ | lumped | Group of species for aggregate observables | +βββββββ+βββββββββββββββββββββ+ | TKO2cycle | Dynamic temperature and kOβ definition for advanced scenarios | +βββββββ+βββββββββββββββββββββ+
Author: Olivier Vitrac β olivier.vitrac@gmail.com Revision: 2025-05-13
- class radigen3.oxidation.H2O(**kwargs)ο
Bases:
species
Water class (stable)
- allylic = 0ο
- classAliases = ['H2O']ο
- className = 'water'ο
- defaultName = 'H2O'ο
- defaultRoot = ''ο
- freevalence = 0ο
- freevalenceHolder = Noneο
- interpretation = 'stable water'ο
- oxidationState = 0ο
- product = Noneο
- reactWith = Noneο
- reactiveFunction = 'None'ο
- suffix = 'H2O'ο
- class radigen3.oxidation.PrintableFigure(figsize=None, dpi=None, *, facecolor=None, edgecolor=None, linewidth=0.0, frameon=None, subplotpars=None, tight_layout=None, constrained_layout=None, layout=None, **kwargs)ο
Bases:
Figure
Custom Figure class with show and print methods.
- print(filename='', destinationfolder='/home/olivi/maxime/radigen/docs_sphinx/source', overwrite=True, dpi={'pdf': 300, 'png': 150})ο
- print_pdf(filename='', destinationfolder='/home/olivi/maxime/radigen/docs_sphinx/source', overwrite=False, dpi=300)ο
- print_png(filename='', destinationfolder='/home/olivi/maxime/radigen/docs_sphinx/source', overwrite=False, dpi=300)ο
- set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, canvas=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, constrained_layout=<UNSET>, constrained_layout_pads=<UNSET>, dpi=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, figheight=<UNSET>, figwidth=<UNSET>, frameon=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, layout_engine=<UNSET>, linewidth=<UNSET>, mouseover=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, rasterized=<UNSET>, size_inches=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, tight_layout=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, zorder=<UNSET>)ο
Set multiple properties at once.
Supported properties are
- Properties:
agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: float or None animated: bool canvas: FigureCanvas clip_box: ~matplotlib.transforms.BboxBase or None clip_on: bool clip_path: Patch or (Path, Transform) or None constrained_layout: unknown constrained_layout_pads: unknown dpi: float edgecolor: :mpltype:`color` facecolor: :mpltype:`color` figheight: float figure: unknown figwidth: float frameon: bool gid: str in_layout: bool label: object layout_engine: {βconstrainedβ, βcompressedβ, βtightβ, βnoneβ, .LayoutEngine, None} linewidth: number mouseover: bool path_effects: list of .AbstractPathEffect picker: None or bool or float or callable rasterized: bool size_inches: (float, float) or float sketch_params: (scale: float, length: float, randomness: float) snap: bool or None tight_layout: unknown transform: ~matplotlib.transforms.Transform url: str visible: bool zorder: float
- show(display_mode=None)ο
Show figure based on the environment: - In Jupyter: Uses display(fig) - In scripts or GUI mode: Uses plt.show()
- class radigen3.oxidation.TKO2cycle(times, T_values, kO2_values)ο
Bases:
object
Class to define temperature (T) and oxygenation (kO2) cycles over time.
- Supports:
Constant values
Linear ramps between two values
Multiple steps combined using +
- Each cycle defines:
T(t): temperature in Celsius
kO2(t): oxygen mass transfer coefficient [m/s]
Example
cycle = TKO2cycle.constant(60, 1e-5, duration=2*3600) + TKO2cycle.ramp(60, 80, 1e-5, 2e-5, duration=1*3600)
- property Tο
T(t) interpolant at t as an anonymous function
- classmethod constant(T, kO2, duration)ο
generate an holding step for T and kO2
- property kO2ο
kO2(t) interpolation at t as an anonymous function
- classmethod ramp(T, kO2, duration)ο
generate a ramp from pair values of T and kO2
- radigen3.oxidation.custom_plt_figure(*args, **kwargs)ο
Ensure all figures use PrintableFigure.
- radigen3.oxidation.custom_plt_subplots(*args, **kwargs)ο
Ensure plt.subplots() returns a PrintableFigure.
- class radigen3.oxidation.diAllylicC(**kwargs)ο
Bases:
species
Alkyl radical (Cβ’) on diallylic site
- allylic = 2ο
- classAliases = ['C2', 'R2', 'L2', 'P2']ο
- className = 'alkyl radical on diallylic site'ο
- defaultName = 'L2β’'ο
- defaultRoot = 'L2'ο
- freevalence = 1ο
- freevalenceHolder = 'C'ο
- interpretation = 'O2 addition'ο
- oxidationState = 0ο
- product = ['diAllylicCOO', 'terminationPolymers', 'terminationPolymers']ο
- reactWith = ['β’OOβ’', 'Cβ’', 'COOβ’']ο
- reactiveFunction = 'Cβ’'ο
- suffix = 'β’'ο
- class radigen3.oxidation.diAllylicCH(**kwargs)ο
Bases:
species
Aliphatic (CH) on diallylic site
- allylic = 2ο
- classAliases = ['C2H', 'R2H', 'L2H', 'P2H']ο
- className = 'aliphatic with diallylic C-H'ο
- defaultName = 'L2H'ο
- defaultRoot = 'L2'ο
- freevalence = 0ο
- freevalenceHolder = Noneο
- interpretation = 'labile H abstraction'ο
- oxidationState = -0.5ο
- product = ['diAllylicC']ο
- reactWith = ['HOβ’', 'COβ’', 'COOβ’']ο
- reactiveFunction = 'CH'ο
- suffix = 'H'ο
- class radigen3.oxidation.diAllylicCHO(**kwargs)ο
Bases:
species
Aldehyde (CHO) on diallylic site (stable)
- allylic = 2ο
- classAliases = ['C2=O', 'R2=O', 'L2=O', 'P2=O']ο
- className = 'aldehyde on diallylic site'ο
- defaultName = 'L2HO'ο
- defaultRoot = 'L2'ο
- freevalence = 0ο
- freevalenceHolder = Noneο
- interpretation = 'stable aldehyde'ο
- oxidationState = 2ο
- product = Noneο
- reactWith = Noneο
- reactiveFunction = 'CHO'ο
- suffix = '=O'ο
- class radigen3.oxidation.diAllylicCO(**kwargs)ο
Bases:
species
Alkoxyl radical (COβ’) on diallylic site
- allylic = 2ο
- classAliases = ['C2O', 'R2O', 'L2O', 'P2O']ο
- className = 'alkoxyl radical on diallylic site'ο
- defaultName = 'L2Oβ’'ο
- defaultRoot = 'L2'ο
- freevalence = 1ο
- freevalenceHolder = 'O'ο
- interpretation = 'beta-scission or reduction to alcohol'ο
- oxidationState = -1ο
- product = ['diAllylicCeqO', 'diAllylicCOH']ο
- reactWith = [None, 'CH']ο
- reactiveFunction = 'COβ’'ο
- suffix = 'Oβ’'ο
- class radigen3.oxidation.diAllylicCOH(*, root=None, name='', shortname='', concentration=0.0, index=None, _alias_used=None)ο
Bases:
species
Alcohol (COH) on dioallylic site (stable)
- allylic = 2ο
- classAliases = ['C1OH', 'R1OH', 'L1OH', 'P1OH']ο
- className = 'alcohol on diallylic site'ο
- defaultName = 'L2OH'ο
- defaultRoot = 'L2'ο
- freevalence = 0ο
- freevalenceHolder = Noneο
- interpretation = 'stable alcohol'ο
- oxidationState = 0ο
- product = Noneο
- reactWith = Noneο
- reactiveFunction = 'COH'ο
- suffix = 'OH'ο
- class radigen3.oxidation.diAllylicCOO(**kwargs)ο
Bases:
species
Hydroperoxyl radical (COOβ’) on diallylic site
- allylic = 2ο
- classAliases = ['C2OO', 'R2OO', 'L2OO', 'P2O']ο
- className = 'hydroperoxyl radical on diallylic site'ο
- defaultName = 'L2OOβ’'ο
- defaultRoot = 'L2'ο
- freevalence = 1ο
- freevalenceHolder = 'O'ο
- interpretation = 'H abstraction termination'ο
- oxidationState = 0ο
- product = ['diAllylicCOOH', 'terminationPolymers', 'terminationPolymers']ο
- reactWith = ['CH', 'COOβ’', 'Cβ’']ο
- reactiveFunction = 'COOβ’'ο
- suffix = 'OOβ’'ο
- class radigen3.oxidation.diAllylicCOOH(**kwargs)ο
Bases:
species
Hydroperoxide (COOH) on diallylic site
- allylic = 2ο
- classAliases = ['C2OOH', 'R2OOH', 'L2OOH', 'P2OOH']ο
- className = 'hydroperoxide on diallylic site'ο
- defaultName = 'L2OOH'ο
- defaultRoot = 'L2'ο
- freevalence = 0ο
- freevalenceHolder = Noneο
- interpretation = 'monomolecular or bimolecular decomposition'ο
- oxidationState = -1ο
- product = [{'diAllylicCO', 'peroxyl'}, ('diAllylicCO', 'diAllylicCOO')]ο
- reactWith = [None, 'COOH']ο
- reactiveFunction = 'COOH'ο
- suffix = 'OOH'ο
- class radigen3.oxidation.diAllylicCeqO(**kwargs)ο
Bases:
species
Ketone (C=O) on diallylic site (stable)
- allylic = 2ο
- classAliases = ['C2=O', 'R2=O', 'L2=O', 'P2=O']ο
- className = 'ketone on diallylic site'ο
- defaultName = 'L2=O'ο
- defaultRoot = 'L2'ο
- freevalence = 0ο
- freevalenceHolder = Noneο
- interpretation = 'stable ketone'ο
- oxidationState = 1ο
- product = Noneο
- reactWith = Noneο
- reactiveFunction = 'C=O'ο
- suffix = '=O'ο
- radigen3.oxidation.is_valid_figure(fig)ο
Checks if fig is a valid and open Matplotlib figure.
Parameters: - fig: object to check
Returns: - bool: True if fig is a valid, open Matplotlib figure.
- radigen3.oxidation.kttt3 = <L3β’ + L3β’ -> L3-polymer + L3-polymer> reaction rate constantsο
- Entries from Table 1 in
Maxime Touffet, Olivier Vitrac, Temperature-dependent kinetics of unsaturated fatty acid methyl esters: Modeling autoxidation mechanisms, Food Chemistry, 481, 2025, 143952 https://doi.org/10.1016/j.foodchem.2025.143952
Note that the values defined here are automatically registered at instantiation
- class radigen3.oxidation.lumped(species_list, color=None, linestyle='-')ο
Bases:
species
Lumped species class representing the aggregate behavior of multiple individual species.
This class is used to group species that are chemically or functionally equivalent in a given context (e.g., radicals with similar reactivity, isomers, or chain-length variants).
The lumped object behaves like a single species whose concentration is the sum of its components. It inherits from the species base class but overrides key attributes.
- Parameters:
species_list (list[species]) β list of species instances being lumped.
color (str or [RGB] values) β color to apply for plotting (default=None for automatic assignment).
linestyle (str, default="-") β Linestyle used in plots.
- indexο
Lumped species are not indexed in the mixture.
- Type:
None
- concentrationο
Total concentration of included species.
- Type:
float
- shortnameο
Default shorthand label (βLMβ).
- Type:
str
- rootο
No root is assigned.
- Type:
None
- reactiveFunctionο
No reactive function is assigned.
- Type:
None
- freevalenceο
No freevalence is assigned.
- Type:
None
- _colorο
color to apply for plotting.
- _linestyleο
Linestyle used in plots.
- Type:
str, default=β-β
- _lumpedο
True for lumped species.
- Type:
True
- Usage Example:
>>> LOOH1 = species.create("L1OOH", concentration=0.1) >>> LOOH2 = species.create("L2OOH", concentration=0.2) >>> LOOH3 = species.create("L3OOH", concentration=0.3) >>> LOOH = lumped([LOOH1, LOOH2, LOOH3]) >>> print(LOOH.name) lump_L1OOH_L2OOH_L3OOH >>> print(LOOH.concentration) 0.6
Notes
Lumped species are useful for reducing model complexity or matching experimental resolution.
They can be passed to plotting, integration, or export functions just like other species.
Operations on lumped species do not propagate changes back to the individual species.
See also
species.__or__: Supports the | operator for combining species.
- class radigen3.oxidation.mixture(name='mixture', description='', A=0.45, V=0.003, pO2=21000.0, M=0.28246, rho0=883, rho_T0=25, rho_beta=0.00063, kO2=1e-05, Aunits='mΒ²', Vunits='mΒ³', pO2units='Pa', Munits='kgΒ·mβ»ΒΉ', rhounits='kgΒ·mβ»Β³', Tunits='Β°C', betaunits='Kβ»ΒΉ', kO2units='mΒ·sβ»ΒΉ')ο
Bases:
object
Container class for chemical species and reactions involved in oxidation mechanisms.
The mixture class represents a chemical system composed of individual species objects, along with their physical properties, reaction relationships, and dynamic behaviors. It supports prompt-driven population of reactive species, combinatorial generation of reactions, and parameterization from a curated reaction rate database.
This class also encodes physical parameters relevant to kinetic modeling, including density, molar mass, volume, area, oxygen pressure, and diffusion properties.
It is the entry point for model creation in the oxidation kernel, and is tightly coupled with the mixtureKinetics class, which provides numerical integration of the reaction network.
- nameο
Name of the mixture.
- Type:
str
- descriptionο
Optional description.
- Type:
str
- Aο
Interfacial area for mass transfer [mΒ²].
- Type:
float
- Vο
Volume of the reacting domain [mΒ³].
- Type:
float
- pO2ο
Partial pressure of oxygen [Pa].
- Type:
float
- Mο
Molar mass of the mixture [kg/mol].
- Type:
float
- rho0ο
Reference density [kg/mΒ³] at rho_T0 Β°C.
- Type:
float
- rho_T0ο
Reference temperature for density [Β°C].
- Type:
float
- rho_betaο
Thermal expansion coefficient [1/K].
- Type:
float
- kO2ο
Oxygen mass transfer coefficient [m/s].
- Type:
float
- Internals:
_substances (list): List of all species in the mixture. _reactions (dict): Indexed dictionary of all reactions. _reaction_hashes (set): Set of reaction fingerprints for uniqueness. _reaction_counter (int): Tracks reaction indices for auto-numbering.
- Properties:
listReactiveFunctions (list): lists unique reactive functions held by species in the mixture. listProductsBySubstance (dict): lists the products it can form for each substance listProducts (list): lists the unique names of all product species that can be formed listFormattedProductsBySubstance (dict): lists the named products it can form for each each substance listFormattedProducts (list): lists the unique named products that can be formed in the mixture species (list): lists species names substances (list(species)): lists species objects reactions (list(reactions)): lists reactions objects reactionScheme (str): Reaction scheme as a string
- Key Methods:
- add(clsname, name=β¦, **kwargs) β species
Add a species to the mixture by class or alias name.
- addProducts() β int
Recursively add all valid product species inferred from reactive pairs.
- addReactions() β int
Combinatorially create all valid reactions among species in the mixture.
- populateReactionRates() β int
Assign rate constants using registered reaction rate data.
- buildStoichiometryMatrix(sparse=False) β (S, species_list, reactions_list)
Build the full stoichiometric matrix (dense or sparse).
- stoichiometryDataFrame(sparse=False) β pd.DataFrame
Return a human-readable DataFrame version of the stoichiometry.
- getReactionByFingerprint(fingerprint: str) β reaction
Look up a reaction using its string representation.
- getSpeciesByReactiveFunction(func: str) β list[species]
Return species that match a given reactive function (e.g., βCOOHβ).
- get_lumped_by_function(function: str) β lumped
Return a lumped object for all species with the given reactive function.
- get_lumped_by_pattern(pattern: str, attr=βnameβ) β lumped
Return a lumped object for species matching a regex pattern on a given attribute.
- lumped_hydroperoxides() β lumped
Return a lumped species for all hydroperoxides (reactiveFunction = βCOOHβ).
- lumped_alcohols() β lumped
Return a lumped species for all alcohols (reactiveFunction = βCOHβ).
- lumped_aldehydes() β lumped
Return a lumped species for all aldehydes (reactiveFunction = βCHOβ).
- lumped_ketones() β lumped
Return a lumped species for all ketones (reactiveFunction = βC=Oβ).
- lumped_radicals_on_C() β lumped
Return a lumped species for all radicals centered on carbon atoms.
- lumped_radicals_on_O() β lumped
Return a lumped species for all radicals centered on oxygen atoms.
- lumped_polar_compounds() β lumped
Return a lumped species for polar compounds (any compound with at least one oxygen).
- lumped_polymers() β lumped
Return a lumped species for all termination polymers (reactiveFunction = β-polymerβ).
- copy() β mixture
Return a copy of a mixture.
- mix1 + mix2 β mixture
Operator β+β combine mixtures and dilute them accordingly
- Usage Example:
oil = mixture() oil.add(βL1Hβ, concentration=3000) oil.add(βL1OOHβ, concentration=100) oil.add(βO2β, concentration=10) oil.addProducts() oil.addReactions() oil.populateReactionRates() S, species_list, rxn_list = oil.buildStoichiometryMatrix() df = oil.stoichiometryDataFrame()
Notes
Products are named by combining the reagent root and the suffix of the product class.
Cross-reactions are inferred automatically but do not get their own parameter sets.
This class does not perform any kinetic simulation β see mixtureKinetics for that.
All parameters are expressed in SI units, unless otherwise noted.
See also
mixtureKinetics: For kinetic integration and modeling.
species: For base and derived chemical species.
reaction: For handling A (+B) β C (+D) logic.
reactionRateDB: To define and register kinetic data.
Part of the Generative Simulation Initiative β olivier.vitrac@gmail.com
- add(clsname, *, name=None, **kwargs)ο
Add a new species to the mixture using a class name or alias.
- Parameters:
clsname (str) β Alias or registered species class name.
name (str, optional) β Name to assign to the species instance. Defaults to the classβs defaultName.
**kwargs β Additional keyword arguments for the species constructor, including e.g. concentration, root, shortname.
- Returns:
The created and registered species object.
- Return type:
- addProducts()ο
Recursively adds all potential product species (with zero concentration) derived from reactions under current reactive conditions.
- Each product species is created with:
name = reagent.root + target_class.suffix
- Returns:
Number of new species added to the mixture.
- Return type:
int
- addReaction(A, B, C, D=None)ο
- addReactions(allow_self_reaction=True)ο
Generates all valid reactions based on current species.
This method uses the rule: - C = A.listProducts[B.reactiveFunction] - D = B.listProducts[A.reactiveFunction]
Products are looked up in the current mixture via their inferred names: root + suffix (from species registry).
- Returns:
number of reactions added
- Return type:
int
- buildStoichiometryMatrix(sparse=False)ο
Constructs the stoichiometric matrix S of the mixtureβs reaction network.
Rows: species (ordered by .index) Columns: reactions (ordered by .index)
Reactants A,B β -1 (increment, bimolecular β -2 with A=B) Products C,D β +1 (increment, except if polymerization β +0.5)
- Parameters:
sparse (bool) β If True, returns a scipy.sparse CSR matrix.
- Returns:
Stoichiometry matrix (dense ndarray or sparse CSR) species_list (list): Ordered list of species reactions_list (list): Ordered list of reactions
- Return type:
S
- copy()ο
Returns a deep copy (clone) of the current mixture instance.
This method ensures that all species, reactions, and internal structures are duplicated without shared references. Modifying the clone will not affect the original mixture.
- Returns:
A fully independent clone of the original mixture.
- Return type:
- getReactionByFingerprint(fingerprint)ο
Retrieves the reaction object matching a given fingerprint string.
- Parameters:
fingerprint (str) β A string representation of the reaction, e.g., βL1OOH -> L1HOβ’ + L1Oβ’β
- Returns:
The matching reaction object, or None if not found.
- Return type:
reaction or None
- getSpeciesByReactiveFunction(reactiveFunction)ο
Retrieves a list of species matching a given reactiveFunction.
- Parameters:
reactiveFunction (str) β A string representation of the reactive function, e.g., βL1OOHβ
- Returns:
An empty list is returned if the reactive function is not found.
- Return type:
list of species
- get_lumped_by_function(function, color=None, linestyle='-')ο
Returns a lumped object for all species with a given reactive function.
- get_lumped_by_pattern(pattern, attr='name', color=None, linestyle='-')ο
Returns a lumped object for species whose attribute (default βnameβ) matches a regex.
- property listFormattedProductsο
Lists the unique named products that can be formed in the mixture using root + suffix logic (e.g., L1Oβ’ instead of monoAllylicCO).
- Returns:
Sorted list of formatted product names.
- Return type:
list[str]
- property listFormattedProductsBySubstanceο
For each species in the mixture, lists the named products it can form (filtered by the reactive functions currently present in the mixture), using root + class suffix logic.
- Returns:
{species_name: {reactWith: formatted_product_name}}
- Return type:
dict[str, dict[str, str]]
- property listProductsο
Lists the unique names of all product species that can be formed by the species in the mixture under current reactive conditions.
- Returns:
Sorted list of unique product class names.
- Return type:
list[str]
- property listProductsBySubstanceο
For each species in the mixture, lists the products it can form (filtered by the reactive functions currently present in the mixture).
- Returns:
{species_name: {reactWith: product}}
- Return type:
dict[str, dict[str, str]]
- property listReactiveFunctionsο
Returns a sorted list of unique reactive functions held by species in the mixture.
- Returns:
List of unique reactiveFunction values.
- Return type:
list[str]
- lumped_alcohols(color='Indigo', linestyle='-')ο
Returns a lumped species containing all aldehydes (COH).
- lumped_aldehydes(color='DarkViolet', linestyle='-')ο
Returns a lumped species containing all aldehydes (CHO).
- lumped_hydroperoxides(color='Magenta', linestyle='-')ο
Returns a lumped species containing all hydroperoxides (COOH).
- lumped_ketones(color='DarkSlateBlue', linestyle='-')ο
Returns a lumped species containing all aldehydes (CHO).
- lumped_polar_compounds()ο
Returns a lumped species including compounds with at least one oxygen (based on reactiveFunction/suffix).
- lumped_polymers(color='DarkSlateGray', linestyle='-')ο
Returns a lumped species containing all polymer termination products.
- lumped_radicals_on_C(color='DarkGreen', linestyle=':')ο
Returns a lumped species with radicals centered on carbon atoms.
- lumped_radicals_on_O(color='Olive', linestyle='-.')ο
Returns a lumped species with radicals centered on oxygen atoms.
- populateReactionRates()ο
Updates reaction rate constants (k0, Ea, T0) from the reactionRateDB based on reaction fingerprints.
If a matching fingerprint is found, the reactionβs parameters are updated. If not, the default values are retained.
- Returns:
Number of reactions updated.
- Return type:
int
- property reactionSchemeο
Returns reaction scheme as a string
- property reactionsο
Returns defined reactions in the mixture as a list
- refresh_indices()ο
Refresh indices of compounds in the mixture. Ensures self._indexmap is contiguous and updates .index attributes.
- property speciesο
Return the list of substances in the mixture
- stoichiometryDataFrame(sparse=False)ο
Converts the stoichiometry matrix into a human-readable DataFrame.
- Parameters:
sparse (bool) β If True, builds sparse stoichiometry matrix.
- Returns:
Species Γ Reactions stoichiometry.
- Return type:
pd.DataFrame
- property substancesο
Retuns list of substances as a list
- class radigen3.oxidation.mixtureKinetics(mixture, name=None)ο
Bases:
object
Solver class for time-resolved oxidation kinetics in reactive mixtures.
This class constructs and integrates the differential system for species concentrations:
dC/dt = S Β· R(C, T) + source_terms(C, T)
- where:
C: vector of concentrations [mol/mΒ³]
S: stoichiometric matrix
R: reaction rate vector
T: temperature (can be time-dependent)
source_terms includes mass transport (e.g., O2β influx)
- Key Features:
Handles monomolecular and bimolecular mechanisms
Automatically applies Arrhenius/Smoluchowski hybrid kinetics
Models ROOH β ROβ’ + HOβ’ with cage/free equilibrium
Tracks oxygen flux using Henryβs law and film model
Solves stiff ODE systems using scipy.integrate.solve_ivp
Supports arbitrary T(t) and kOβ(t) using a TKO2cycle object
Can merge multiple simulations via the β+β operator
- Lumped Species Support:
- Lumped groups of species can be registered via:
model.register_lumped(βLOOHβ, mix.lumped_hydroperoxides())
Registered lumped species can be plotted, tracked, and exported as if they were named species.
- Plotting:
Colors and line styles are automatically detected from _color and _linestyle attributes.
Lumped species are rendered with thicker lines and a ββ β symbol in legends.
Annotations show the curve maximum for each species if enabled.
- Dynamic Simulation Support:
By passing a TKO2cycle object to solve(cycle=β¦), the solver will use time-varying temperature and oxygen transfer coefficients.
- solve(tspan, T, C0, ..., cycle=None)ο
Integrate the ODE system over time.
- plot(species=None, ...)ο
Plot time-concentration profiles, including lumped groups.
- results_as_dataframe(species=None)ο
Export results as a DataFrame.
- get_interpolator()ο
Returns interpolator for concentrations at arbitrary time points.
- get_C0(), set_C(C=None)ο
Retrieve or update species concentrations.
- register_lumped(name, lumped_obj)ο
Register a lumped species group.
- get_lumped_concentration(name)ο
Return total concentration over a lumped group.
- copy()ο
Return a deep copy of the entire model and simulation state.
- __add__(other)ο
Concatenate two compatible simulations for continuous kinetics.
- Static Methods:
- parse_time_unit(tspan, unit)
Convert time input (e.g., (10, βdaysβ)) to seconds with canonical unit tracking.
- nameο
Title of the model (e.g., βoxidation of oilβ)
- Type:
str
- species_listο
List of species in simulation
- Type:
list
- reactions_listο
List of reactions used
- Type:
list
- n_speciesο
Number of species
- Type:
int
- n_reactionsο
Number of reactions
- Type:
int
- _resultsο
Output from solve()
- Type:
SimpleNamespace
Example
oil = mixture() oil.add(βL1Hβ, concentration=3000) oil.add(βL1OOHβ, concentration=100) oil.add(βO2β, concentration=10) oil.addProducts(); oil.addReactions(); oil.populateReactionRates()
model = mixtureKinetics(oil) model.solve((5, βdaysβ), T=60) model.plot([βL1Hβ, βhydroperoxidesβ])
df = model.results_as_dataframe() print(df.head())
- KcagefreeROOH(T, C)ο
Returns the equilibrium constant between cage and free hydroperoxides at T
- cageROOH(T, C, CROOH)ο
Returns the free conentration of hydroperoxides of type COOH at T
- copy()ο
Returns a deep copy (clone) of the current mixture instance.
This method ensures that all species, reactions, and internal structures are duplicated without shared references. Modifying the clone will not affect the original mixture.
- Returns:
A fully independent clone of the original mixture.
- Return type:
- freeROOH(T, C, CROOH)ο
Returns the free conentration of hydroperoxides of type COOH at T
- get_C0()ο
Returns the initial concentration vector C0 from species in the mixture.
- get_R(T, C)ο
Computes the vector of reaction rates R at temperature T and concentrations C.
- Parameters:
T (float) β Temperature in Β°C.
C (array) β Current concentrations of all species.
- Returns:
Reaction rate vector.
- Return type:
R (np.ndarray)
- get_dCdt(T, C)ο
Computes the time derivative of species concentrations:
dC/dt = S Β· R(T, C) + source_vector
Includes source term for O2 transport.
- get_dCdt_dynamic(Tfunc, kO2func)ο
Computes the time derivative of species concentrations under dynamic T(t) and kO2(t) conditions
dC/dt = S Β· R(T(t), C) + source_vector(t)
- get_interpolator()ο
Returns an interpolator object to estimate concentrations at arbitrary times.
- Returns:
Function interp(t) that returns concentrations at time t (in seconds).
- Return type:
interp (callable)
- get_lumped_concentration(name)ο
Return the concentration (cumulated) of a registered lumped species.
- molarVolume(T)ο
Estimate molar volume (mΒ³/mol) of the mixture :param T: Temperature in Β°C. :type T: float
- Returns:
Molar volume in mΒ³/mol
- Return type:
float
- oxygen_solubility(T)ο
Returns oxygen solubility in mol/(mΒ³Β·Pa) using Arai et al. (1989) constants. Valid for FAMEs over a wide T range.
- Parameters:
T (float) β Temperature in Β°C.
- Returns:
Solubility S_O2 in mol/(mΒ³Β·Pa)
- Return type:
float
- static parse_time_unit(tspan, unit='s')ο
Convert a time span with units to seconds, return also the canonical unit and inverse scale.
- Parameters:
tspan (float or tuple) β time duration (e.g., 3600 or (10.0, βdβ))
unit (str, optional) β time unit if not using tuple form.
- Returns:
Time span converted to seconds. canonical_unit (str): Canonical form (βsβ, βminβ, βhoursβ, βdaysβ, βweeksβ, βmonthsβ, βyearsβ). inverse_scale (float): Scaling factor to convert seconds back to canonical unit.
- Return type:
time_in_seconds (float)
- Raises:
ValueError β If the unit is unknown or invalid.
- Canonical units and definitions:
βsβ: seconds
βminβ: 60 seconds
βhoursβ: 3600 seconds
βdaysβ: 86400 seconds
βweeksβ: 7 Γ 86400
βmonthsβ: 30 Γ 86400
βyearsβ: 365 Γ 86400
- plot(species=None, ax=None, figsize=None, ncol=None, legend_loc='center left', bbox_to_anchor=(1.0, 0.5), annotate_max=True, xscale='linear', yscale='linear', **kwargs)ο
Plot the concentration profiles of selected species over time.
Species are rendered with custom colors if their _color attribute is set. Lumped species (_lumped = True) are plotted with thicker lines and shown with a β symbol in the legend. The maximum value of each curve can be labeled for clarity.
- Parameters:
species (list[str], optional) β List of species or lumped names to plot. If None, all species and registered lumped groups are shown.
ax (matplotlib.axes.Axes, optional) β Axes to draw on. If None, creates a new figure.
figsize (tuple, optional) β Size of the figure.
ncol (int, optional) β Number of columns in the legend.
legend_loc (str) β Location of the legend.
bbox_to_anchor (tuple) β Anchor position for the legend.
annotate_max (bool) β Whether to annotate the curve maximum (default: True).
xscale (str) β Scale for x-axis (βlinearβ or βlogβ). Default: βlinearβ.
yscale (str) β Scale for y-axis (βlinearβ or βlogβ). Default: βlinearβ.
- Raises:
RuntimeError β If no solution is available.
ValueError β If a species or lumped group is unrecognized.
- register_lumped(name, lumped_obj)ο
Register a lumped group under a name for plotting/dataframe output.
- results_as_dataframe(species=None)ο
Return the time evolution of species as a pandas DataFrame.
- Parameters:
species (list[str], optional) β If provided, limits the output to these species.
- Returns:
DataFrame with time and concentrations.
- Return type:
pd.DataFrame
- rho(T)ο
Temperature-dependent density model for mixture. :param T: Temperature in Β°C. :type T: float
- Returns:
density in kg/mΒ³
- Return type:
float
- set_C(C=None)ο
Updates the concentrations of species in the mixture.
If C is None, uses the last simulated concentration vector from the final time point.
- solve(tspan, T=None, C0=None, species=None, cycle=None, method='BDF', rtol=1e-06, atol=1e-07, max_order=5, **kwargs)ο
Integrate the system of ODEs dC/dt = SΒ·R(C,T) with optional oxygen source and dynamic conditions.
Supports both constant and time-dependent temperature and oxygenation profiles. When a TKO2cycle object is passed to cycle, the simulation will use the temperature and kOβ values defined by the cycle for each time point.
- Parameters:
tspan (float or tuple) β Final time tf or (t0, tf) in seconds. Can also be passed as (value, unit) tuples (e.g., (10, βdaysβ)).
T (float, optional) β Constant temperature [Β°C] if no cycle is specified.
C0 (np.ndarray, optional) β Initial concentration vector. If None, uses current species concentrations.
species (list[str], optional) β Species to include in the result. Defaults to all species.
cycle (TKO2cycle, optional) β Time-dependent temperature and oxygenation cycle object.
method (str) β Integration method (e.g., βBDFβ, βLSODAβ). βBDFβ recommended if the concentrations in radicals are initially 0
rtol (float) β Relative tolerance.
atol (float) β Absolute tolerance.
max_order (int) β Maximum solver order (for implicit methods).
**kwargs β Additional arguments passed to scipy.integrate.solve_ivp.
- Returns:
t (np.ndarray): Time points [unit-scaled].
y (np.ndarray): Concentrations at each time step.
tunit (str): Original time unit (e.g., βdaysβ).
tscale (float): Scale factor applied to time for output.
concunits (str): Concentration units (βmol/mΒ³β).
species (list[str]): Names of tracked species.
success (bool): Whether the integration succeeded.
message (str): Solver status message.
solver (str): Solver method used.
cycle (TKO2cycle or None): Applied cycle, if any.
isCycle (bool): True if dynamic conditions were used.
- Return type:
types.SimpleNamespace
- sourceO2(T, concO2)ο
Oxygen transport model
- temporary_kO2(new_kO2)ο
Temporarily override current kO2 value
- totalROOH(C)ο
Returns the total concentration in hydroperoxides
- class radigen3.oxidation.monoAllylicC(**kwargs)ο
Bases:
species
Alkyl radical (Cβ’) on monoallylic site
- allylic = 1ο
- classAliases = ['C1', 'R1', 'L1', 'P1']ο
- className = 'alkyl radical on monoallylic site'ο
- defaultName = 'L1β’'ο
- defaultRoot = 'L1'ο
- freevalence = 1ο
- freevalenceHolder = 'C'ο
- interpretation = 'O2 addition'ο
- oxidationState = 0ο
- product = ['monoAllylicCOO', 'terminationPolymers', 'terminationPolymers']ο
- reactWith = ['β’OOβ’', 'Cβ’', 'COOβ’']ο
- reactiveFunction = 'Cβ’'ο
- suffix = 'β’'ο
- class radigen3.oxidation.monoAllylicCH(**kwargs)ο
Bases:
species
Aliphatic (CH) on monoallylic site
- allylic = 1ο
- classAliases = ['C1H', 'R1H', 'L1H', 'P1H']ο
- className = 'aliphatic with monoallylic C-H'ο
- defaultName = 'L1H'ο
- defaultRoot = 'L1'ο
- freevalence = 0ο
- freevalenceHolder = Noneο
- interpretation = 'labile H abstraction'ο
- oxidationState = -1ο
- product = ['monoAllylicC']ο
- reactWith = ['HOβ’', 'COβ’', 'COOβ’']ο
- reactiveFunction = 'CH'ο
- suffix = 'H'ο
- class radigen3.oxidation.monoAllylicCHO(**kwargs)ο
Bases:
species
Aldehyde (CHO) on monoallylic site (stable)
- allylic = 1ο
- classAliases = ['C1=O', 'R1=O', 'L1=O', 'P1=O']ο
- className = 'aldehyde on monoallylic site'ο
- defaultName = 'L1HO'ο
- defaultRoot = 'L1'ο
- freevalence = 0ο
- freevalenceHolder = Noneο
- interpretation = 'stable aldehyde'ο
- oxidationState = 2ο
- product = Noneο
- reactWith = Noneο
- reactiveFunction = 'CHO'ο
- suffix = '=O'ο
- class radigen3.oxidation.monoAllylicCO(**kwargs)ο
Bases:
species
Alkoxyl radical (COβ’) on monoallylic site
- allylic = 1ο
- classAliases = ['C1O', 'R1O', 'L1O', 'P1O']ο
- className = 'alkoxyl radical on monoallylic site'ο
- defaultName = 'L1Oβ’'ο
- defaultRoot = 'L1'ο
- freevalence = 1ο
- freevalenceHolder = 'O'ο
- interpretation = 'beta-scission or reduction to alcohol'ο
- oxidationState = -1ο
- product = ['monoAllylicCeqO', 'monoAllylicCOH']ο
- reactWith = [None, 'CH']ο
- reactiveFunction = 'COβ’'ο
- suffix = 'Oβ’'ο
- class radigen3.oxidation.monoAllylicCOH(**kwargs)ο
Bases:
species
Alcohol (COH) on monoallylic site (stable)
- allylic = 1ο
- classAliases = ['C1OH', 'R1OH', 'L1OH', 'P1OH']ο
- className = 'alcohol on monoallylic site'ο
- defaultName = 'L1OH'ο
- defaultRoot = 'L1'ο
- freevalence = 0ο
- freevalenceHolder = Noneο
- interpretation = 'stable alcohol'ο
- oxidationState = 0ο
- product = Noneο
- reactWith = Noneο
- reactiveFunction = 'COH'ο
- suffix = 'OH'ο
- class radigen3.oxidation.monoAllylicCOO(**kwargs)ο
Bases:
species
Hydroperoxyl radical (COOβ’) on monoallylic site
- allylic = 1ο
- classAliases = ['C1OO', 'R1OO', 'L1OO', 'P1OO']ο
- className = 'hydroperoxyl radical on monoallylic site'ο
- defaultName = 'L1OOβ’'ο
- defaultRoot = 'L1'ο
- freevalence = 1ο
- freevalenceHolder = 'O'ο
- interpretation = 'H abstraction termination'ο
- oxidationState = 0ο
- product = ['monoAllylicCOOH', 'terminationPolymers', 'terminationPolymers']ο
- reactWith = ['CH', 'COOβ’', 'Cβ’']ο
- reactiveFunction = 'COOβ’'ο
- suffix = 'OOβ’'ο
- class radigen3.oxidation.monoAllylicCOOH(**kwargs)ο
Bases:
species
Hydroperoxide (COOH) on monoallylic site
- allylic = 1ο
- classAliases = ['C1OOH', 'R1OOH', 'L1OOH', 'P1OOH']ο
- className = 'hydroperoxide on monoallylic site'ο
- defaultName = 'L1OOH'ο
- defaultRoot = 'L1'ο
- freevalence = 0ο
- freevalenceHolder = Noneο
- interpretation = 'monomolecular or bimolecular decomposition'ο
- oxidationState = -1ο
- product = [{'monoAllylicCO', 'peroxyl'}, ('monoAllylicCO', 'monoAllylicCOO')]ο
- reactWith = [None, 'COOH']ο
- reactiveFunction = 'COOH'ο
- suffix = 'OOH'ο
- class radigen3.oxidation.monoAllylicCeqO(**kwargs)ο
Bases:
species
Ketone (C=O) on monoallylic site (stable)
- allylic = 1ο
- classAliases = ['C1=O', 'R1=O', 'L1=O', 'P1=O']ο
- className = 'ketone on monoallylic site'ο
- defaultName = 'L1=O'ο
- defaultRoot = 'L1'ο
- freevalence = 0ο
- freevalenceHolder = Noneο
- interpretation = 'stable ketone'ο
- oxidationState = 1ο
- product = Noneο
- reactWith = Noneο
- reactiveFunction = 'C=O'ο
- suffix = '=O'ο
- class radigen3.oxidation.oxygen(**kwargs)ο
Bases:
species
Dioxygen (β’OOβ’)
- allylic = 0ο
- classAliases = ['O2']ο
- className = 'dioxygen (triplet state)'ο
- defaultName = 'oxygen'ο
- defaultRoot = ''ο
- freevalence = 2ο
- freevalenceHolder = 'O'ο
- interpretation = 'O2 is fixed'ο
- oxidationState = 0ο
- product = ['-']ο
- reactWith = ['Cβ’']ο
- reactiveFunction = 'β’OOβ’'ο
- suffix = 'O2'ο
- class radigen3.oxidation.peroxyl(**kwargs)ο
Bases:
species
Peroxyl radical (HOβ’) class
- allylic = 0ο
- classAliases = ['OH']ο
- className = 'peroxyl radical'ο
- defaultName = 'HOβ’'ο
- defaultRoot = ''ο
- freevalence = 1ο
- freevalenceHolder = 'O'ο
- interpretation = 'labile H abstraction'ο
- oxidationState = 0ο
- product = ['H2O']ο
- reactWith = ['CH']ο
- reactiveFunction = 'HOβ’'ο
- suffix = 'HOβ’'ο
- radigen3.oxidation.print_figure(fig, filename='', destinationfolder='/home/olivi/maxime/radigen/docs_sphinx/source', overwrite=False, dpi={'pdf': 300, 'png': 150})ο
Save the figure in both PDF and PNG formats.
Parameters: - fig: Matplotlib figure object to be saved. - filename: str, base filename (auto-generated if empty). - destinationfolder: str, folder to save the files. - overwrite: bool, overwrite existing files. - dpi: int, resolution (default=300).
- radigen3.oxidation.print_pdf(fig, filename='', destinationfolder='/home/olivi/maxime/radigen/docs_sphinx/source', overwrite=False, dpi=300)ο
Save a given figure as a PDF.
Parameters: - fig: Matplotlib figure object to be saved. - filename: str, PDF filename (auto-generated if empty). - destinationfolder: str, folder to save the file. - overwrite: bool, overwrite existing file. - dpi: int, resolution (default=300).
- radigen3.oxidation.print_png(fig, filename='', destinationfolder='/home/olivi/maxime/radigen/docs_sphinx/source', overwrite=False, dpi=300)ο
Save a given figure as a PNG.
Parameters: - fig: Matplotlib figure object to be saved. - filename: str, PNG filename (auto-generated if empty). - destinationfolder: str, folder to save the file. - overwrite: bool, overwrite existing file. - dpi: int, resolution (default=300).
- class radigen3.oxidation.reaction(*, A, C, B=None, D=None, index=None, k0=1.0, Ea=45000.0, T0=25.0, Tunits='Β°C', kunits='mΒ³/molΒ·s', Eaunits='J/mol', diffusionLimited=False, ratio_rgh=0.77, eta0=0.0019, eta_Ea=17000.0, eta_T0=80, etaunits='PaΒ·s', model='default', Tdefault=40, phi=2.0)ο
Bases:
object
Represents a chemical reaction of the form A (+ B) β C (+ D).
This class handles the logical structure and parameterization of elementary reactions in radical oxidation mechanisms. It supports Arrhenius and Smoluchowski rate models, diffusion-limited corrections, and fingerprinting for unique identification and cross-term inference.
It distinguishes between monomolecular and bimolecular reactions, between self- and cross-reactions, and supports equilibrium treatment for specific classes (e.g. hydroperoxides).
- A, B
Reactants; B can be None (monomolecular reaction).
- Type:
- C, D
Products; D can be None.
- Type:
- indexο
Reaction index within the mixture.
- Type:
int
- k0ο
Pre-exponential rate constant at T0.
- Type:
float
- Eaο
Activation energy [J/mol].
- Type:
float
- T0ο
Reference temperature [Β°C].
- Type:
float
- kunits, Eaunits, Tunits
Units for k0, Ea, T0.
- Type:
str
- diffusionLimitedο
Whether reaction is diffusion-limited.
- Type:
bool
- ratio_rghο
Ratio of gyration to hydrodynamic radii.
- Type:
float
- eta0, eta_Ea, eta_T0, etaunits
Viscosity model parameters.
- modelο
String describing the rate model origin.
- Type:
str
- phiο
Multiplicative factor for cross-reactions.
- Type:
float
- inheritο
Self-reactions from which a cross-reaction inherits its rate.
- Type:
tuple
- Properties:
ismonomolecular (bool): True if only A is defined. isbimolecular (bool): True if both A and B are defined. isselfroot (bool): True if A and B share the same root. iscrossroot (bool): True if A and B differ by root. isdecompositionROOH (bool): True if hydroperoxide decomposition. iscagedecompositionROOH (bool): True if bimolecular hydroperoxide cage decomposition.
- k(T)ο
Return rate constant (includes cross-term inference).
- kArrhenius(T)ο
Arrhenius-only rate constant.
- kSmoluchowski(T)ο
Smoluchowski diffusion rate.
- viscosity(T)ο
Temperature-dependent viscosity.
- fingerprint()ο
Human-readable identifier (e.g. βA + B -> C + Dβ).
- crossfingerprints()ο
Tuple of fingerprints for each self-reaction of a cross-term.
- __str__, __repr__
Human-readable and detailed representations.
- Static Methods:
hash_reagents(A, B): Hash based on reactants. hash_reagents_products(A, B, C, D): Hash including products. order_reagents(A, B, C, D): Canonical ordering of inputs.
Notes
Reactions are ordered to ensure uniqueness (e.g., oxidant = B if ranks differ).
Rate constants are inferred from registered reactionRateDB entries.
Cross-reactions use a geometric mean of inherited rate constants.
See also
species: for chemical participant definitions.
mixture: for reaction network generation and storage.
reactionRateDB: for assigning kinetic constants.
- property crossfingerprintsο
Returns the human-readable fingerprints for cross-reactions
- property fingerprintο
Returns the human-readable fingerprint of a reaction
- static hash_reagents(A, B=None)ο
Returns a hash based on reagent identities.
- static hash_reagents_products(A, B=None, C=None, D=None)ο
Returns a hash based on reagent and product identities.
- property isbimolecularο
Returns True if the reaction is bimolecular
- property iscagedecompositionROOHο
Returns True if the reaction involves a bimolecular cage decomposition of hydroperoxides
- property iscrossrootο
Returns True if the reaction is monomolecular or involves different roots (e.g., L1OOH+L2OOH)
- property isdecompositionROOHο
Returns True is the reaction involves the decomposition of hydroperoxides
- property ismonomolecularο
Returns True if the reaction is monomolecular
- property ispolymerizationο
Returns True if the reaction involves a polymerization
- property isselfrootο
Returns True if the reaction is bimolecular and involves same roots (e.g., L1OOH+L1OOH)
- k(T=None)ο
Returns a function k(T) giving the Arrhenius rate constant at temperature T (Β°C).
- kArrhenius(T=None)ο
Returns the Arrhenian reaction rate
- kSmoluchowski(T=None)ο
Returns the Smoluchowski reaction rate
- static order_reagents(A, B, C=None, D=None)ο
Orders A + B -> C + D for reaction consistency (B is the oxidizer) Note that the products C and D must match A and B
Rules: - If A is None and B is not, swap. - If both are defined and A._redoxRank > B._redoxRank, swap.
- Returns:
(A, B) in canonical order
- Return type:
tuple
- viscosity(T=None)ο
Returns the dynamic viscosity
- class radigen3.oxidation.reactionRateDB(*, fingerprint, T0, k0, k0_CI=None, Ea, Ea_CI=None, Tunits='Β°C', kunits='mΒ³Β·molβ»ΒΉΒ·sβ»ΒΉ', Eaunits='JΒ·molβ»ΒΉ', source='', diffusionLimited=False, ratio_rgh=0.77, eta0=0.0019, eta_Ea=17000.0, eta_T0=80, etaunits='PaΒ·s', phi=2.0)ο
Bases:
object
Database and container class for reaction rate constants.
This class enables registration, storage, and retrieval of kinetic parameters associated with elementary reactions involved in radical oxidation mechanisms. It is designed to support both monomolecular and bimolecular reactions, including Arrhenius parameters, solvent-dependent viscosity corrections, and diffusion limits.
Each entry corresponds to a uniquely defined reaction fingerprint (e.g., βL1OOH -> L1Oβ’ + HOβ’β) and may include confidence intervals, diffusion-limited behavior, and Smoluchowski model parameters.
=== Attributes === Class Attributes:
_registry (dict): Maps canonical fingerprints to lists of registered entries. _fingerprint_substitutions (list): List of (pattern, replacement) regex pairs
used to transform fingerprints queried via .get() or .get_latest().
- Instance Attributes:
fingerprint (str): Reaction descriptor in canonical form. T0 (float): Reference temperature [Β°C]. Tunits (str): Units of T0. k0 (float): Pre-exponential factor (Arrhenius rate at T0). k0_CI (float or None): Confidence interval on k0. kunits (str): Units of k0 (e.g., βmΒ³Β·molβ»ΒΉΒ·sβ»ΒΉβ). Ea (float): Activation energy [J/mol]. Ea_CI (float or None): Confidence interval on Ea. Eaunits (str): Units of activation energy. source (str): Source or reference for the entry (e.g., literature citation). diffusionLimited (bool): Whether rate is capped by diffusion. ratio_rgh (float): Radius-of-gyration to hydrodynamic-radius ratio. eta0 (float): Reference viscosity [PaΒ·s]. eta_Ea (float): Activation energy for viscosity [J/mol]. eta_T0 (float): Reference temperature for viscosity model [Β°C]. etaunits (str): Units for viscosity. phi (float): Scaling factor used for cross-reaction inference.
=== Methods === Instance:
__init__: Creates and registers a new rate constant entry. __iter__: Iterator over main fields. __str__, __repr__: Human-readable and detailed representations.
- Class:
get(fingerprint): Return all entries matching the given fingerprint or a substituted one. get_latest(fingerprint): Return the latest entry registered for a (possibly substituted) fingerprint. to_dataframe(): Export the full database to a pandas DataFrame. register_fingerprint_substitution(pattern, replacement): Register a regex substitution to transform
a queried fingerprint into a canonical one, allowing lookup under different naming schemes.
=== Fingerprint Substitution === If a reaction fingerprint is not found in the registry, a set of regex-based substitutions is applied in sequence to find alternative forms (e.g., βL1Hβ β βR1Hβ). This enables the reuse of reaction rate constants across different naming conventions.
Example
reactionRateDB.register_fingerprint_substitution(rβL([123])β, rβR1β)
# Register using R-prefixed names reactionRateDB(fingerprint=βR1H + R1Oβ’ -> R1β’ + R1OHβ, β¦)
# Lookup via L-prefixed form will succeed: reactionRateDB.get_latest(βL1H + L1Oβ’ -> L1β’ + L1OHβ)
Notes
Only the first matching substitution is applied.
Substitution is used only for lookup; registered fingerprints remain unchanged.
- === Usage Example ===
- reactionRateDB(
fingerprint=βL1OOH -> L1Oβ’ + HOβ’β, T0=140, k0=2.11e-4, Ea=74.8e3, source=βTouffet et al. 2023β
)
See also
reaction: Uses this class to populate kinetic parameters.
mixture.populateReactionRates(): Assigns values to all reactions in a mixture.
- classmethod get(fingerprint)ο
Returns all entries matching the fingerprint or its substituted variant.
- classmethod get_latest(fingerprint)ο
Returns the last entry added for a fingerprint (with substitution if needed).
- classmethod register_fingerprint_substitution(pattern: str, replacement: str)ο
Register a regex-based substitution rule to rewrite reaction fingerprints. The first rule that matches will be used.
Example
pattern = rβL([123])β # matches L1, L2, L3 replacement = rβRβ # replaces with R1, R2, R3
- classmethod to_dataframe()ο
- class radigen3.oxidation.species(*, root=None, name='', shortname='', concentration=0.0, index=None, _alias_used=None)ο
Bases:
object
Base class for chemical species involved in radical oxidation.
This class supports structural and kinetic representation of organic species, including radicals, hydroperoxides, oxygen, alcohols, aldehydes, and stable products. Derived classes should specify suffix, aliases, reactive functions, and redox ranks.
- nameο
Long name.
- Type:
str
- shortnameο
Abbreviation or label.
- Type:
str
- rootο
Identifier used to group related species.
- Type:
str
- concentrationο
Current concentration in mol/mΒ³.
- Type:
float
- indexο
Index in the mixture (set automatically).
- Type:
int
- Class Attributes:
_registry (dict): Mapping from names and aliases to subclasses.
- Core Properties:
isradical (bool): True if species has nonzero free valence. ishydroperoxide (bool): True if reactiveFunction is βCOOHβ. isreactive (bool): True if species has a defined reaction partner/product. islumped (bool): True if species is a lumped group of species. listProducts (dict): Maps reactive functions β product class names. formattedProducts (dict): Maps reactive functions β formatted product names (root + suffix).
- Behavior:
__or__(other): Lump two species (returns a lumped object). __add__(other): Placeholder for defining reaction A + B. __iter__(): Iterator over main attributes. __repr__(), __str__(): Print-friendly formatting.
- Class Methods:
register(cls): Decorator to register subclasses (with aliases). create(name, **kwargs): Factory method to instantiate from alias or class name.
Notes
reactiveFunction, reactWith, and product must be defined in subclasses.
reactWith may be a list of functional groups or None (monomolecular).
Products can be a string, tuple (ordered), or set (unordered).
Naming conventions follow: name = root + suffix (e.g., L1OOβ’ from root L1 + suffix OOβ’).
Example
@species.register class monoAllylicCH(species):
suffix = βHβ reactiveFunction = βCHβ reactWith = [βCOOβ’β, βCOβ’β] product = [βmonoAllylicCβ] defaultRoot = βL1β defaultName = βL1Hβ
See also
mixture: For managing collections of species.
reaction: For defining A + B β C + D.
lumped: For combining species into pseudo-compounds.
- static create(name, **kwargs)ο
Factory method to create a species by name or alias.
- Parameters:
name (str) β Name or alias of the species.
**kwargs β Passed to the constructor of the target class.
- Returns:
An instance of the requested class.
- Return type:
- Raises:
ValueError β If no class matches the name or alias.
- property formattedProductsο
Returns a dictionary mapping reaction types to formatted product names using root + suffix (e.g., βL1OOβ’β instead of βmonoAllylicCOOβ).
- Keys:
βselfβ β product of monomolecular decomposition <functional_group> β product from bimolecular reaction
- Returns:
Maps reaction type to formatted name(s)
- Return type:
dict[str, str or list[str]]
- property isbimolecularο
Returns True if the species reacts with another reactant (reactWith is not None). If reactWith is a list, returns a list of bools for each reactant type. Returns False if not reactive.
- property ishydroperoxideο
True if reactiveFunction is βCOOHβ, interpreted as a hydroperoxide.
- property islumpedο
True if this species is a lumped group of multiple species.
- property ismonomolecularο
Returns True if the species reacts without a partner (reactWith is None). If reactWith is a list, returns a list of bools for each reactant type. Returns False if not reactive.
- property isradicalο
True if species has free valence (i.e., is a radical).
- property isradical_onCο
True if radical center is on carbon.
- property isradical_onOο
True if radical center is on oxygen.
- property isreactiveο
True if the species leads to at least one product.
- property listProductsο
Returns a dictionary mapping the type of reaction to the corresponding product.
- Keys:
βselfβ β product of monomolecular decomposition (i.e., if None is in reactWith) <functional_group> β product when reacting with that function (from reactWith)
- Returns:
Maps reaction type to product name.
- Return type:
dict[str, str or None]
- classmethod register(derived_cls)ο
Class decorator to register a derived species class.
Adds both the class name and any class-defined aliases to the registry.
- Parameters:
derived_cls (type) β The class to register.
- Returns:
The same class, unmodified.
- Return type:
type
- class radigen3.oxidation.terminationPolymers(*, root=None, name='', shortname='', concentration=0.0, index=None, _alias_used=None)ο
Bases:
species
Generic stable polymer termination product
- allylic = Noneο
- classAliases = ['polymer']ο
- className = 'stable polymer termination product'ο
- defaultName = 'termination product (polymer)'ο
- defaultRoot = 'polymer'ο
- freevalence = 0ο
- freevalenceHolder = Noneο
- interpretation = 'stable termination products (polymers)'ο
- oxidationState = 0ο
- product = Noneο
- reactWith = Noneο
- reactiveFunction = '-polymer'ο
- suffix = '-polymer'ο
- class radigen3.oxidation.triAllylicC(**kwargs)ο
Bases:
species
Alkyl radical (Cβ’) on triallylic site
- allylic = 3ο
- classAliases = ['C3', 'R3', 'L3', 'P3']ο
- className = 'alkyl radical on triallylic site'ο
- defaultName = 'L3β’'ο
- defaultRoot = 'L3'ο
- freevalence = 1ο
- freevalenceHolder = 'C'ο
- interpretation = 'O2 addition'ο
- oxidationState = 0ο
- product = ['triAllylicCOO', 'terminationPolymers', 'terminationPolymers']ο
- reactWith = ['β’OOβ’', 'Cβ’', 'COOβ’']ο
- reactiveFunction = 'Cβ’'ο
- suffix = 'β’'ο
- class radigen3.oxidation.triAllylicCH(**kwargs)ο
Bases:
species
Aliphatic (CH) on triallylic site
- allylic = 3ο
- classAliases = ['C3H', 'R3H', 'L3H', 'P3H']ο
- className = 'aliphatic with triallylic C-H'ο
- defaultName = 'L3H'ο
- defaultRoot = 'L3'ο
- freevalence = 0ο
- freevalenceHolder = Noneο
- interpretation = 'labile H abstraction'ο
- oxidationState = 0ο
- product = ['triAllylicC']ο
- reactWith = ['HOβ’', 'COβ’', 'COOβ’']ο
- reactiveFunction = 'CH'ο
- suffix = 'H'ο
- class radigen3.oxidation.triAllylicCHO(**kwargs)ο
Bases:
species
Aldehyde (CHO) on triallylic site (stable)
- allylic = 3ο
- classAliases = ['C3=O', 'R3=O', 'L3=O', 'P3=O']ο
- className = 'aldehyde on triallylic site'ο
- defaultName = 'L3HO'ο
- defaultRoot = 'L3'ο
- freevalence = 0ο
- freevalenceHolder = Noneο
- interpretation = 'stable aldehyde'ο
- oxidationState = 2ο
- product = Noneο
- reactWith = Noneο
- reactiveFunction = 'CHO'ο
- suffix = '=O'ο
- class radigen3.oxidation.triAllylicCO(**kwargs)ο
Bases:
species
Alkoxyl radical (COβ’) on triallylic site
- allylic = 3ο
- classAliases = ['C3O', 'R3O', 'L3O', 'P3O']ο
- className = 'alkoxyl radical on triallylic site'ο
- defaultName = 'L3Oβ’'ο
- defaultRoot = 'L3'ο
- freevalence = 1ο
- freevalenceHolder = 'O'ο
- interpretation = 'beta-scission or reduction to alcohol'ο
- oxidationState = -1ο
- product = ['triAllylicCeqO', 'triAllylicCOH']ο
- reactWith = [None, 'CH']ο
- reactiveFunction = 'COβ’'ο
- suffix = 'Oβ’'ο
- class radigen3.oxidation.triAllylicCOH(**kwargs)ο
Bases:
species
Alcohol (COH) on trioallylic site (stable)
- allylic = 3ο
- classAliases = ['C1OH', 'R1OH', 'L1OH', 'P1OH']ο
- className = 'alcohol on triallylic site'ο
- defaultName = 'L3OH'ο
- defaultRoot = 'L3'ο
- freevalence = 0ο
- freevalenceHolder = Noneο
- interpretation = 'stable alcohol'ο
- oxidationState = 0ο
- product = Noneο
- reactWith = Noneο
- reactiveFunction = 'COH'ο
- suffix = 'OH'ο
- class radigen3.oxidation.triAllylicCOO(**kwargs)ο
Bases:
species
Hydroperoxyl radical (COOβ’) on triallylic site
- allylic = 3ο
- classAliases = ['C3OO', 'R3OO', 'L3OO', 'P3OO']ο
- className = 'hydroperoxyl radical on triallylic site'ο
- defaultName = 'L3OOβ’'ο
- defaultRoot = 'L3'ο
- freevalence = 1ο
- freevalenceHolder = 'O'ο
- interpretation = 'H abstraction termination'ο
- oxidationState = 0ο
- product = ['triAllylicCOOH', 'terminationPolymers', 'terminationPolymers']ο
- reactWith = ['CH', 'COOβ’', 'Cβ’']ο
- reactiveFunction = 'COOβ’'ο
- suffix = 'OOβ’'ο
- class radigen3.oxidation.triAllylicCOOH(**kwargs)ο
Bases:
species
Hydroperoxide (COOH) on triallylic site
- allylic = 3ο
- classAliases = ['C3OOH', 'R3OOH', 'L3OOH', 'P3OOH']ο
- className = 'hydroperoxide on diallylic site'ο
- defaultName = 'L3OOH'ο
- defaultRoot = 'L3'ο
- freevalence = 0ο
- freevalenceHolder = Noneο
- interpretation = 'monomolecular or bimolecular decomposition'ο
- oxidationState = -1ο
- product = [{'peroxyl', 'triAllylicCO'}, ('triAllylicCO', 'triAllylicCOO')]ο
- reactWith = [None, 'COOH']ο
- reactiveFunction = 'COOH'ο
- suffix = 'OOH'ο
- class radigen3.oxidation.triAllylicCeqO(**kwargs)ο
Bases:
species
Ketone (C=O) on triallylic site (stable)
- allylic = 3ο
- classAliases = ['C3=O', 'R3=O', 'L3=O', 'P3=O']ο
- className = 'ketone on triallylic site'ο
- defaultName = 'L3=O'ο
- defaultRoot = 'L3'ο
- freevalence = 0ο
- freevalenceHolder = Noneο
- interpretation = 'stable ketone'ο
- oxidationState = 1ο
- product = Noneο
- reactWith = Noneο
- reactiveFunction = 'C=O'ο
- suffix = '=O'ο