PourPy.reactant

Created on Sun May 14 10:57:37 2023

@author: anjakorber

Classes

State

Create a collection of name/value pairs.

Reactant

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

Module Contents

class PourPy.reactant.State(*args, **kwds)

Bases: enum.Enum

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

>>> Color.RED
<Color.RED: 1>
  • value lookup:

>>> Color(1)
<Color.RED: 1>
  • name lookup:

>>> Color['RED']
<Color.RED: 1>

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

aqueous = 'aq'
solid = 's'
gaseous = 'g'
liquid = 'l'
electron = 'e'
class PourPy.reactant.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.