pymatgen.analysis.reaction_calculator module
This module provides classes that define a chemical reaction.
- class BalancedReaction(reactants_coeffs, products_coeffs)[source]
Bases:
MSONable
An object representing a complete chemical reaction.
Reactants and products to be specified as dict of {Composition: coeff}.
- Parameters:
({Composition (products_coeffs) – float}): Reactants as dict of {Composition: amt}.
({Composition – float}): Products as dict of {Composition: amt}.
- calculate_energy(energies)[source]
Calculates the energy of the reaction.
- Parameters:
({Composition (energies) – float}): Energy for each composition. E.g ., {comp1: energy1, comp2: energy2}.
- Returns:
reaction energy as a float.
- classmethod from_dict(d)[source]
- Parameters:
d (dict) – from as_dict()
- Returns:
A BalancedReaction object.
- static from_string(rxn_string)[source]
Generates a balanced reaction from a string. The reaction must already be balanced.
- Parameters:
rxn_string – The reaction string. For example, “4 Li + O2-> 2Li2O”
- Returns:
BalancedReaction
- get_el_amount(element)[source]
Returns the amount of the element in the reaction.
- Parameters:
element (Element/Species) – Element in the reaction
- Returns:
Amount of that element in the reaction.
- normalize_to(comp, factor=1)[source]
Normalizes the reaction to one of the compositions. By default, normalizes such that the composition given has a coefficient of 1. Another factor can be specified.
- Parameters:
comp (Composition) – Composition to normalize to
factor (float) – Factor to normalize to. Defaults to 1.
- normalize_to_element(element, factor=1)[source]
Normalizes the reaction to one of the elements. By default, normalizes such that the amount of the element is 1. Another factor can be specified.
- Parameters:
element (Element/Species) – Element to normalize to.
factor (float) – Factor to normalize to. Defaults to 1.
- property normalized_repr[source]
A normalized representation of the reaction. All factors are converted to lowest common factors.
- class ComputedReaction(reactant_entries, product_entries)[source]
Bases:
Reaction
Convenience class to generate a reaction from ComputedEntry objects, with some additional attributes, such as a reaction energy based on computed energies.
- Parameters:
reactant_entries ([ComputedEntry]) – List of reactant_entries.
product_entries ([ComputedEntry]) – List of product_entries.
- property all_entries[source]
Equivalent of all_comp but returns entries, in the same order as the coefficients.
- class Reaction(reactants, products)[source]
Bases:
BalancedReaction
A more flexible class representing a Reaction. The reaction amounts will be automatically balanced. Reactants and products can swap sides so that all coefficients are positive, however this class will find the solution with the minimum number of swaps and coefficients of 0. Normalizes so that the FIRST product (or products, if underdetermined) has a coefficient of one.
Reactants and products to be specified as list of pymatgen.core.structure.Composition. e.g., [comp1, comp2]
- Parameters:
reactants ([Composition]) – List of reactants.
products ([Composition]) – List of products.