pymatgen.analysis.reaction_calculator module

class BalancedReaction(reactants_coeffs, products_coeffs)[source]

Bases: monty.json.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}.
TOLERANCE = 1e-06
all_comp

List of all compositions in the reaction.

as_dict()[source]
as_entry(energies)[source]

Returns a ComputedEntry representation of the reaction. :return:

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.
coeffs

Final coefficients of the calculated reaction

elements

List of elements in the reaction

classmethod from_dict(d)[source]
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_coeff(comp)[source]

Returns coefficient for a particular composition

get_el_amount(element)[source]

Returns the amount of the element in the reaction.

Parameters:element (Element/Specie) – 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/Specie) – Element to normalize to.
  • factor (float) – Factor to normalize to. Defaults to 1.
normalized_repr

A normalized representation of the reaction. All factors are converted to lowest common factors.

normalized_repr_and_factor()[source]

Normalized representation for a reaction For example, 4 Li + 2 O -> 2Li2O becomes 2 Li + O -> Li2O

products

List of products

reactants

List of reactants

class ComputedReaction(reactant_entries, product_entries)[source]

Bases: pymatgen.analysis.reaction_calculator.Reaction

Convenience class to generate a reaction from ComputedEntry objects, with some additional attributes, such as a reaction energy based on computed energies.

Parameters:
all_entries

Equivalent of all_comp but returns entries, in the same order as the coefficients.

as_dict()[source]
calculated_reaction_energy
classmethod from_dict(d)[source]
class Reaction(reactants, products)[source]

Bases: pymatgen.analysis.reaction_calculator.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. 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:
as_dict()[source]
copy()[source]

Returns a copy of the Reaction object.

classmethod from_dict(d)[source]
exception ReactionError(msg)[source]

Bases: Exception

Exception class for Reactions. Allows more information in exception messages to cover situations not covered by standard exception classes.