PourPy.reaction

Created on Sun May 14 11:00:38 2023

@author: anjakorber

Classes

Reactant

Reactant class that defines an ion, compound or electron including all required thermodynamic and molecular parameters.

Constants

Convert a string or number to a floating point number, if possible.

Defaults

Reaction

Reaction class featuring all reaction-specific parameters of the (electro)chemical reactions to be included in the Pourbaix diagram.

Module Contents

class PourPy.reaction.Reactant(formula, state, dGf, dHf, Sm, elements)

Reactant class that defines an ion, compound or electron including all required thermodynamic and molecular parameters.

__str__()

Return str(self).

initialize()

Initialize additional properties of the Reactant.

Returns:

None

Return type:

None

_get_formula(formula)

Validate and returns user-input chemical formula of the reactant.

Parameters:

formula – The chemical formula to validate.

Returns:

Validated chemical formula.

_get_state(state)

Validates and returns the user-input physical state of the reactant.

Parameters:

state – The physical state to validate.

Returns:

Validated physical state.

_get_charge()

Validates and returns the user-input charge of the reactant.

Returns:

The charge of the reactant, 0 if not present.

_get_atoms(elements)

Retrieves a dictionary of atoms in the reactant.

Returns:

A dictionary containing atom symbols as keys and their counts as values.

_get_molecular_weight(elements)

Calculates the molecular weight of the reactant.

Returns:

The molecular weight of the reactant in grams per mole.

_get_super_string(x)

Converts numeric characters in the formula of the reactant to Unicode superscript characters.

Parameters:

x – The input string to convert.

Returns:

The input string with numeric characters replaced by super-script characters.

_get_sub_string(x)

Converts numeric characters in the formula of the reactant to Unicode subscript characters.

Parameters:

x – The input string to convert.

Returns:

The input string with numeric characters replaced by sub-script characters.

_get_reactant_string()

Creates a formatted string representing the reactant formula.

Returns:

Formatted string representation of the reactant, including subscripts for number of atoms and superscripts for charge.

class PourPy.reaction.Constants

Bases: float, enum.Flag

Convert a string or number to a floating point number, if possible.

GAS = 8.31446262
FARADAY = 96485.3321
STANDARD_TEMPERATURE = 298.15
STANDARD_PRESSURE = 1.0
class PourPy.reaction.Defaults

Bases: object

activity = 1.0
maximum_electrode_potential = 2.0
minimum_electrode_potenital
maximum_pH_value = 16.0
minimum_pH_value = 0.0
pressure = 1.0
temperature = 298.15
reference_electrode_abbreviation = 'SHE'
reference_potential_difference = 0.0
reference_electrodes
class PourPy.reaction.Reaction(constituents, system)

Bases: object

Reaction class featuring all reaction-specific parameters of the (electro)chemical reactions to be included in the Pourbaix diagram.

__str__()

Return the string representation of the reaction, where all reactants appear on the left hand side and all products appear on the right of the reacton arrow.

Returns:

A string representation of the reaction, e.g., ‘H2O ⇄ H2 + 0.5*O2’.

Return type:

str

initialize()

Initialize the Reaction object by calculating various reaction-specific properties.

Returns:

None

Return type:

None

_get_reaction_string()

Create the string representation of the reaction, where all reactants appear on the left hand side and all products appear on the right of the reacton arrow.

Returns the string representation of the reaction, e.g., ‘H2O ⇄ H2 + O2’.

Returns:

A string representation of the reaction.

Return type:

str

_get_echem_reaction()

Checks if the reaction is an electrochemical reaction, i.e. whether it contains electrons, and returns True if it’s electrochemical, otherwise returns False.

Returns:

True if the reaction is electrochemical, False otherwise.

Return type:

bool

_get_pH_reaction()

Checks if the reaction is a pH-dependent reaction, i.e. whether it contains protons, and returns True if it’s pH-dependent, otherwise returns False.

Returns:

True if the reaction is pH-dependent, False otherwise.

Return type:

bool

property dGr: float

Calculate the standard Gibbs free energy change of the reaction from the standard molar Gibbs free energies of all reation costituents.

Returns:

The standard Gibbs free energy change of the reaction in joules per mole.

Return type:

float

property dHr: float

Calculate the standard enthalpy change of the reaction from the standard molar enthalpies of all reation costituents.

Returns:

The standard enthalpy change of the reaction in joules per mole.

Return type:

float

property dSr: float

Calculate the standard entropy change of the reaction from the standard Gibbs free energy and enthalpy.

Returns:

The standard entropy change of the reaction in joules per mole per degrees kelvin.

Return type:

float

property K
Calculate the equilibrium constant for the reaction from its standard Gibbs free energy.
Returns:

The equilibrium constant K for the reaction.

Return type:

float

property E0
Calculate the standard electrode potential for the reaction in volts vs. SHE from its standard Gibbs gree energy.
Returns:

The standard electrode potential E0 for the electrochemical reaction in volts vs. SHE, or 0 if the reaction is not an electrochemical reaction.

Return type:

float

property nElectrons
Retrieve the number of electrons involved in the reaction.
Returns:

The number of electrons involved in the electrochemical reaction, or 0 if the reaction is not an electrochemical reaction.

Return type:

float

property nProtons
Retrieve the number of protons involved in the reaction.
Returns:

The number of protons involved in the pH-dependent reaction, or 0 if the reaction is not pH-dependent.

Return type:

float

_get_Hlimit()

Retrieve the range of H+ activities corresponding to the pH limits of the Pourbaix diagram.

Returns:

An array of H+ activities.

Return type:

numpy.ndarray

property Q: float

Calculate the reaction quotient Q for the reaction.

Returns:

The reaction quotient Q for the reaction.

Return type:

float

property rQ: float

Calculate the reduced reaction quotient rQ excluding the activity contribution of protons.

Returns:

The reduced reaction quotient rQ for the reaction.

Return type:

float

property QpH: list

Calculate reaction quotient of the reaction at different H+ activities.

Returns:

A list of reaction quotients at different H+ ion concentrations.

Return type:

list

_get_pourbaixLine()

Calculate the Pourbaix line formulated by the reaction.

Returns:

A list of coordinates defining the Pourbaix line, depending on whether the reaction is potential- and/or pH-dependent.

Return type:

list

Raises:

ValueError – If the reaction is neither potential- nor pH-dependent.

_sanity_check()

Perform a sanity check on the total charge and atom balance of all species in the reaction.

Returns:

A message indicating whether charge and atom balances are correct or if there’s a warning.

Return type:

str

_balanced_charge()

Check if the reaction is charge-balanced.

Returns:

True if the reaction’s charge is balanced, False otherwise.

Return type:

bool

_balanced_atoms()

Check if the reaction has balanced numbers of atoms of each chemical element.

Returns:

True if the reaction’s atoms are balanced, False otherwise.

Return type:

bool