PourPy ====== .. py:module:: PourPy Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/PourPy/common/index /autoapi/PourPy/database/index /autoapi/PourPy/parser/index /autoapi/PourPy/pourbaix/index /autoapi/PourPy/reactant/index /autoapi/PourPy/reaction/index /autoapi/PourPy/system/index Attributes ---------- .. autoapisummary:: PourPy.__author__ PourPy.__credits__ PourPy.__copyright__ PourPy.__license__ PourPy.element_list Classes ------- .. autoapisummary:: PourPy.DefaultParser PourPy.Defaults PourPy.PourbaixDiagram PourPy.State PourPy.Reactant PourPy.Reactant PourPy.Constants PourPy.Defaults PourPy.Reaction PourPy.Reaction PourPy.Reactant PourPy.Constants PourPy.State PourPy.Defaults PourPy.System PourPy.DefaultParser PourPy.Database Package Contents ---------------- .. py:data:: __author__ :value: 'Mohit Pundir' .. py:data:: __credits__ :value: 'Mohit Pundir ' .. py:data:: __copyright__ :value: '' .. py:data:: __license__ :value: 'LGPLv3' .. py:class:: DefaultParser Bases: :py:obj:`Parser` Helper class that provides a standard way to create an ABC using inheritance. .. py:method:: parse_reactions(reactions: tuple) :staticmethod: Parses several reactions given as tuple :param reactions: reactions to be parsed, each entry of a tuple is a reaction string :type reactions: tuple :return : reactions as list, each entry is a dict containing reactants :rtype : list .. py:method:: parse_reaction(reaction: str) :staticmethod: Parse a reaction from its string representation :param reaction: reaction to be parsed :type reaction: str :return : reactants as dict :rtype : dict .. py:method:: parse_species(species: tuple, elements: dict) :staticmethod: .. py:method:: parse_specie(specie: str) :staticmethod: Parse a specie and its chemical props from its string representation :param specie: specie_name,state,dGf,dHf,Sm as string :type specie: str :return : name of the specie, properties as dictionary :rtype : tuple .. py:method:: parse_elements() :staticmethod: .. py:class:: Defaults Bases: :py:obj:`object` .. py:attribute:: activity :value: 1.0 .. py:attribute:: maximum_electrode_potential :value: 2.0 .. py:attribute:: minimum_electrode_potenital :value: -2.0 .. py:attribute:: maximum_pH_value :value: 16.0 .. py:attribute:: minimum_pH_value :value: 0.0 .. py:attribute:: pressure :value: 1.0 .. py:attribute:: temperature :value: 298.15 .. py:attribute:: reference_electrode_abbreviation :value: 'SHE' .. py:attribute:: reference_potential_difference :value: 0.0 .. py:attribute:: reference_electrodes .. py:class:: PourbaixDiagram(reactive_system, line_inspection=False, HER=False, OER=False) Bases: :py:obj:`object` PourbaixDiagram class that defines and plots a Pourbaix diagram. :param reactive_system: The reactive system for which the diagram is constructed. :type reactive_system: ReactiveSystem :param HER: Hydrogen Evolution Reaction. :type HER: Reaction, optional :param OER: Oxygen Evolution Reaction. :type OER: Reaction, optional .. py:attribute:: system .. py:attribute:: inspectorMode :value: False .. py:attribute:: stable_regions .. py:method:: solve() Solve the Pourbaix diagram by computing the intersections of all Nernst equation reaction lines and the regions of stability enclosed between the lines. .. py:method:: show(backend='bokeh', plot_regions=False, labelling=True) Plots the Pourbaix diagram using the specified plotting backend. :param backend: The plotting backend to use (either 'bokeh' or 'matplotlib'). :type backend: str :raises RuntimeError: If the specified backend is invalid. .. py:method:: _get_unique_constitutents() Get a dictionary of unique constituents in the included in the reactive system. Species H+, e-, H2O(l), O2(g) and H2(g) are automatically excluded, as these species are unique constituents of the aqueous solvent bound by the HER and OER by default. :return: A dictionary of unique constituents. :rtype: dict .. py:method:: check_pH(pH_to_check) .. py:method:: _compute_intersections(unique_constituents: dict) Compute intersections between the reactions marking the stablity region of each unique constituent. :param unique_constituents: A dictionary of unique constituents. :type unique_constituents: dict .. py:method:: _compute_boundary_lines(system) :staticmethod: Compute the boundary lines that actually enclose the stability region of each unique constituent. :param system: The reactive system. :type system: ReactiveSystem .. py:method:: _construct_stability_regions() Construct stability regions on the Pourbaix diagram. This method calculates stability regions for different constituents on the Pourbaix diagram and adds corner points where the computed intersection points are on the boundary of the diagram. :return: None :rtype: None .. py:method:: _polar_angle(point, reference_point) Calculate the polar angle of a point relative to a reference intersection point. :param point: The point to calculate the angle for. :type point: tuple :param reference_point: The reference point with respect to which the angle is calculated. :type reference_point: tuple :return: The polar angle of the point relative to the reference point. :rtype: float .. py:method:: _average_values(i) .. py:method:: get_stable_phases() Get all stable phases within the created Pourbaix diagram. :return: A list of stable phases. :rtype: list .. py:method:: get_stable_phase_at(pH, potential) Get the stable phase at a specific pH, potential coordinate relative to the reference electrode. :param pH: The pH value. :type pH: float :param potential: The potential value. :type potential: float :return: The stable phase at the specified pH and potential. :rtype: str :raises: warnings.warn if the point does not exist within the calculated range. .. py:method:: _get_matplotlib_plot(plot_regions=False, labelling=True) Display the created Pourbaix diagram using Matplotlib. :return: None :rtype: None .. py:method:: _get_bokeh_plot(plot_regions=True, labelling=True) Display and return the created Pourbaix diagram using Bokeh. :return: Bokeh plot object. :rtype: Bokeh.plotting.figure .. py:class:: State(*args, **kwds) Bases: :py:obj:`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 - value lookup: >>> Color(1) - name lookup: >>> Color['RED'] Enumerations can be iterated over, and know how many members they have: >>> len(Color) 3 >>> list(Color) [, , ] Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details. .. py:attribute:: aqueous :value: 'aq' .. py:attribute:: solid :value: 's' .. py:attribute:: gaseous :value: 'g' .. py:attribute:: liquid :value: 'l' .. py:attribute:: electron :value: 'e' .. py:class:: Reactant(formula, state, dGf, dHf, Sm, elements) Reactant class that defines an ion, compound or electron including all required thermodynamic and molecular parameters. .. py:attribute:: formula .. py:attribute:: state .. py:attribute:: charge :value: 0 .. py:attribute:: atoms :value: 0 .. py:attribute:: MW :value: 0.0 .. py:attribute:: dGf .. py:attribute:: dHf .. py:attribute:: Sm .. py:method:: __str__() .. py:method:: initialize() Initialize additional properties of the Reactant. :return: None :rtype: None .. py:method:: _get_formula(formula) Validate and returns user-input chemical formula of the reactant. :param formula: The chemical formula to validate. :return: Validated chemical formula. .. py:method:: _get_state(state) Validates and returns the user-input physical state of the reactant. :param state: The physical state to validate. :return: Validated physical state. .. py:method:: _get_charge() Validates and returns the user-input charge of the reactant. :return: The charge of the reactant, 0 if not present. .. py:method:: _get_atoms(elements) Retrieves a dictionary of atoms in the reactant. :return: A dictionary containing atom symbols as keys and their counts as values. .. py:method:: _get_molecular_weight(elements) Calculates the molecular weight of the reactant. :return: The molecular weight of the reactant in grams per mole. .. py:method:: _get_super_string(x) Converts numeric characters in the formula of the reactant to Unicode superscript characters. :param x: The input string to convert. :return: The input string with numeric characters replaced by super-script characters. .. py:method:: _get_sub_string(x) Converts numeric characters in the formula of the reactant to Unicode subscript characters. :param x: The input string to convert. :return: The input string with numeric characters replaced by sub-script characters. .. py:method:: _get_reactant_string() Creates a formatted string representing the reactant formula. :return: Formatted string representation of the reactant, including subscripts for number of atoms and superscripts for charge. .. py:class:: Reactant(formula, state, dGf, dHf, Sm, elements) Reactant class that defines an ion, compound or electron including all required thermodynamic and molecular parameters. .. py:attribute:: formula .. py:attribute:: state .. py:attribute:: charge :value: 0 .. py:attribute:: atoms :value: 0 .. py:attribute:: MW :value: 0.0 .. py:attribute:: dGf .. py:attribute:: dHf .. py:attribute:: Sm .. py:method:: __str__() .. py:method:: initialize() Initialize additional properties of the Reactant. :return: None :rtype: None .. py:method:: _get_formula(formula) Validate and returns user-input chemical formula of the reactant. :param formula: The chemical formula to validate. :return: Validated chemical formula. .. py:method:: _get_state(state) Validates and returns the user-input physical state of the reactant. :param state: The physical state to validate. :return: Validated physical state. .. py:method:: _get_charge() Validates and returns the user-input charge of the reactant. :return: The charge of the reactant, 0 if not present. .. py:method:: _get_atoms(elements) Retrieves a dictionary of atoms in the reactant. :return: A dictionary containing atom symbols as keys and their counts as values. .. py:method:: _get_molecular_weight(elements) Calculates the molecular weight of the reactant. :return: The molecular weight of the reactant in grams per mole. .. py:method:: _get_super_string(x) Converts numeric characters in the formula of the reactant to Unicode superscript characters. :param x: The input string to convert. :return: The input string with numeric characters replaced by super-script characters. .. py:method:: _get_sub_string(x) Converts numeric characters in the formula of the reactant to Unicode subscript characters. :param x: The input string to convert. :return: The input string with numeric characters replaced by sub-script characters. .. py:method:: _get_reactant_string() Creates a formatted string representing the reactant formula. :return: Formatted string representation of the reactant, including subscripts for number of atoms and superscripts for charge. .. py:class:: Constants Bases: :py:obj:`float`, :py:obj:`enum.Flag` Convert a string or number to a floating point number, if possible. .. py:attribute:: GAS :value: 8.31446262 .. py:attribute:: FARADAY :value: 96485.3321 .. py:attribute:: STANDARD_TEMPERATURE :value: 298.15 .. py:attribute:: STANDARD_PRESSURE :value: 1.0 .. py:class:: Defaults Bases: :py:obj:`object` .. py:attribute:: activity :value: 1.0 .. py:attribute:: maximum_electrode_potential :value: 2.0 .. py:attribute:: minimum_electrode_potenital :value: -2.0 .. py:attribute:: maximum_pH_value :value: 16.0 .. py:attribute:: minimum_pH_value :value: 0.0 .. py:attribute:: pressure :value: 1.0 .. py:attribute:: temperature :value: 298.15 .. py:attribute:: reference_electrode_abbreviation :value: 'SHE' .. py:attribute:: reference_potential_difference :value: 0.0 .. py:attribute:: reference_electrodes .. py:class:: Reaction(constituents, system) Bases: :py:obj:`object` Reaction class featuring all reaction-specific parameters of the (electro)chemical reactions to be included in the Pourbaix diagram. .. py:attribute:: constituents .. py:attribute:: system .. py:method:: __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. :return: A string representation of the reaction, e.g., 'H2O ⇄ H2 + 0.5*O2'. :rtype: str .. py:method:: initialize() Initialize the Reaction object by calculating various reaction-specific properties. :return: None :rtype: None .. py:method:: _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'. :return: A string representation of the reaction. :rtype: str .. py:method:: _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. :return: True if the reaction is electrochemical, False otherwise. :rtype: bool .. py:method:: _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. :return: True if the reaction is pH-dependent, False otherwise. :rtype: bool .. py:property:: dGr :type: float Calculate the standard Gibbs free energy change of the reaction from the standard molar Gibbs free energies of all reation costituents. :return: The standard Gibbs free energy change of the reaction in joules per mole. :rtype: float .. py:property:: dHr :type: float Calculate the standard enthalpy change of the reaction from the standard molar enthalpies of all reation costituents. :return: The standard enthalpy change of the reaction in joules per mole. :rtype: float .. py:property:: dSr :type: float Calculate the standard entropy change of the reaction from the standard Gibbs free energy and enthalpy. :return: The standard entropy change of the reaction in joules per mole per degrees kelvin. :rtype: float .. py:property:: K Calculate the equilibrium constant for the reaction from its standard Gibbs free energy. :return: The equilibrium constant K for the reaction. :rtype: float .. py:property:: E0 Calculate the standard electrode potential for the reaction in volts vs. SHE from its standard Gibbs gree energy. :return: The standard electrode potential E0 for the electrochemical reaction in volts vs. SHE, or 0 if the reaction is not an electrochemical reaction. :rtype: float .. py:property:: nElectrons Retrieve the number of electrons involved in the reaction. :return: The number of electrons involved in the electrochemical reaction, or 0 if the reaction is not an electrochemical reaction. :rtype: float .. py:property:: nProtons Retrieve the number of protons involved in the reaction. :return: The number of protons involved in the pH-dependent reaction, or 0 if the reaction is not pH-dependent. :rtype: float .. py:method:: _get_Hlimit() Retrieve the range of H+ activities corresponding to the pH limits of the Pourbaix diagram. :return: An array of H+ activities. :rtype: numpy.ndarray .. py:property:: Q :type: float Calculate the reaction quotient Q for the reaction. :return: The reaction quotient Q for the reaction. :rtype: float .. py:property:: rQ :type: float Calculate the reduced reaction quotient rQ excluding the activity contribution of protons. :return: The reduced reaction quotient rQ for the reaction. :rtype: float .. py:property:: QpH :type: list Calculate reaction quotient of the reaction at different H+ activities. :return: A list of reaction quotients at different H+ ion concentrations. :rtype: list .. py:method:: _get_pourbaixLine() Calculate the Pourbaix line formulated by the reaction. :return: A list of coordinates defining the Pourbaix line, depending on whether the reaction is potential- and/or pH-dependent. :rtype: list :raises ValueError: If the reaction is neither potential- nor pH-dependent. .. py:method:: _sanity_check() Perform a sanity check on the total charge and atom balance of all species in the reaction. :return: A message indicating whether charge and atom balances are correct or if there's a warning. :rtype: str .. py:method:: _balanced_charge() Check if the reaction is charge-balanced. :return: True if the reaction's charge is balanced, False otherwise. :rtype: bool .. py:method:: _balanced_atoms() Check if the reaction has balanced numbers of atoms of each chemical element. :return: True if the reaction's atoms are balanced, False otherwise. :rtype: bool .. py:class:: Reaction(constituents, system) Bases: :py:obj:`object` Reaction class featuring all reaction-specific parameters of the (electro)chemical reactions to be included in the Pourbaix diagram. .. py:attribute:: constituents .. py:attribute:: system .. py:method:: __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. :return: A string representation of the reaction, e.g., 'H2O ⇄ H2 + 0.5*O2'. :rtype: str .. py:method:: initialize() Initialize the Reaction object by calculating various reaction-specific properties. :return: None :rtype: None .. py:method:: _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'. :return: A string representation of the reaction. :rtype: str .. py:method:: _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. :return: True if the reaction is electrochemical, False otherwise. :rtype: bool .. py:method:: _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. :return: True if the reaction is pH-dependent, False otherwise. :rtype: bool .. py:property:: dGr :type: float Calculate the standard Gibbs free energy change of the reaction from the standard molar Gibbs free energies of all reation costituents. :return: The standard Gibbs free energy change of the reaction in joules per mole. :rtype: float .. py:property:: dHr :type: float Calculate the standard enthalpy change of the reaction from the standard molar enthalpies of all reation costituents. :return: The standard enthalpy change of the reaction in joules per mole. :rtype: float .. py:property:: dSr :type: float Calculate the standard entropy change of the reaction from the standard Gibbs free energy and enthalpy. :return: The standard entropy change of the reaction in joules per mole per degrees kelvin. :rtype: float .. py:property:: K Calculate the equilibrium constant for the reaction from its standard Gibbs free energy. :return: The equilibrium constant K for the reaction. :rtype: float .. py:property:: E0 Calculate the standard electrode potential for the reaction in volts vs. SHE from its standard Gibbs gree energy. :return: The standard electrode potential E0 for the electrochemical reaction in volts vs. SHE, or 0 if the reaction is not an electrochemical reaction. :rtype: float .. py:property:: nElectrons Retrieve the number of electrons involved in the reaction. :return: The number of electrons involved in the electrochemical reaction, or 0 if the reaction is not an electrochemical reaction. :rtype: float .. py:property:: nProtons Retrieve the number of protons involved in the reaction. :return: The number of protons involved in the pH-dependent reaction, or 0 if the reaction is not pH-dependent. :rtype: float .. py:method:: _get_Hlimit() Retrieve the range of H+ activities corresponding to the pH limits of the Pourbaix diagram. :return: An array of H+ activities. :rtype: numpy.ndarray .. py:property:: Q :type: float Calculate the reaction quotient Q for the reaction. :return: The reaction quotient Q for the reaction. :rtype: float .. py:property:: rQ :type: float Calculate the reduced reaction quotient rQ excluding the activity contribution of protons. :return: The reduced reaction quotient rQ for the reaction. :rtype: float .. py:property:: QpH :type: list Calculate reaction quotient of the reaction at different H+ activities. :return: A list of reaction quotients at different H+ ion concentrations. :rtype: list .. py:method:: _get_pourbaixLine() Calculate the Pourbaix line formulated by the reaction. :return: A list of coordinates defining the Pourbaix line, depending on whether the reaction is potential- and/or pH-dependent. :rtype: list :raises ValueError: If the reaction is neither potential- nor pH-dependent. .. py:method:: _sanity_check() Perform a sanity check on the total charge and atom balance of all species in the reaction. :return: A message indicating whether charge and atom balances are correct or if there's a warning. :rtype: str .. py:method:: _balanced_charge() Check if the reaction is charge-balanced. :return: True if the reaction's charge is balanced, False otherwise. :rtype: bool .. py:method:: _balanced_atoms() Check if the reaction has balanced numbers of atoms of each chemical element. :return: True if the reaction's atoms are balanced, False otherwise. :rtype: bool .. py:class:: Reactant(formula, state, dGf, dHf, Sm, elements) Reactant class that defines an ion, compound or electron including all required thermodynamic and molecular parameters. .. py:attribute:: formula .. py:attribute:: state .. py:attribute:: charge :value: 0 .. py:attribute:: atoms :value: 0 .. py:attribute:: MW :value: 0.0 .. py:attribute:: dGf .. py:attribute:: dHf .. py:attribute:: Sm .. py:method:: __str__() .. py:method:: initialize() Initialize additional properties of the Reactant. :return: None :rtype: None .. py:method:: _get_formula(formula) Validate and returns user-input chemical formula of the reactant. :param formula: The chemical formula to validate. :return: Validated chemical formula. .. py:method:: _get_state(state) Validates and returns the user-input physical state of the reactant. :param state: The physical state to validate. :return: Validated physical state. .. py:method:: _get_charge() Validates and returns the user-input charge of the reactant. :return: The charge of the reactant, 0 if not present. .. py:method:: _get_atoms(elements) Retrieves a dictionary of atoms in the reactant. :return: A dictionary containing atom symbols as keys and their counts as values. .. py:method:: _get_molecular_weight(elements) Calculates the molecular weight of the reactant. :return: The molecular weight of the reactant in grams per mole. .. py:method:: _get_super_string(x) Converts numeric characters in the formula of the reactant to Unicode superscript characters. :param x: The input string to convert. :return: The input string with numeric characters replaced by super-script characters. .. py:method:: _get_sub_string(x) Converts numeric characters in the formula of the reactant to Unicode subscript characters. :param x: The input string to convert. :return: The input string with numeric characters replaced by sub-script characters. .. py:method:: _get_reactant_string() Creates a formatted string representing the reactant formula. :return: Formatted string representation of the reactant, including subscripts for number of atoms and superscripts for charge. .. py:data:: element_list :value: ['e', 'La', 'H', 'Xe', 'He', 'Li', 'Rf', 'B', 'Db', 'Fe', 'Sg', 'Bh', 'F', 'Ag', 'Mt', 'Na',... .. py:class:: Constants Bases: :py:obj:`float`, :py:obj:`enum.Flag` Convert a string or number to a floating point number, if possible. .. py:attribute:: GAS :value: 8.31446262 .. py:attribute:: FARADAY :value: 96485.3321 .. py:attribute:: STANDARD_TEMPERATURE :value: 298.15 .. py:attribute:: STANDARD_PRESSURE :value: 1.0 .. py:class:: State(*args, **kwds) Bases: :py:obj:`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 - value lookup: >>> Color(1) - name lookup: >>> Color['RED'] Enumerations can be iterated over, and know how many members they have: >>> len(Color) 3 >>> list(Color) [, , ] Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details. .. py:attribute:: aqueous :value: 'aq' .. py:attribute:: solid :value: 's' .. py:attribute:: gaseous :value: 'g' .. py:attribute:: liquid :value: 'l' .. py:attribute:: electron :value: 'e' .. py:class:: Defaults Bases: :py:obj:`object` .. py:attribute:: activity :value: 1.0 .. py:attribute:: maximum_electrode_potential :value: 2.0 .. py:attribute:: minimum_electrode_potenital :value: -2.0 .. py:attribute:: maximum_pH_value :value: 16.0 .. py:attribute:: minimum_pH_value :value: 0.0 .. py:attribute:: pressure :value: 1.0 .. py:attribute:: temperature :value: 298.15 .. py:attribute:: reference_electrode_abbreviation :value: 'SHE' .. py:attribute:: reference_potential_difference :value: 0.0 .. py:attribute:: reference_electrodes .. py:class:: System(filename=None) System class that contains all required physiochemical parameters, elements and reacion constituents nessecary to create a pourbaix diagram. .. py:attribute:: reactions :value: [] .. py:attribute:: elements .. py:property:: temperature Get the system temperature. :return: Temperature in degrees Kelvin. :rtype: float .. py:property:: pressure Get the system pressure. :return: Pressure in bar. :rtype: float .. py:property:: pHmin Get the minimum pH value of the system. :return: Minimum pH value. :rtype: float .. py:property:: pHmax Get the maximum pH value of the system. :return: Maximum pH value. :rtype: float .. py:property:: Emin Get the minimum electrode potential value of the system. :return: Minimum electrode potential value in volts vs. SHE. :rtype: float .. py:property:: Emax Get the maximum electrode potential value of the system. :return: Maximum electrode potential value in volts vs. SHE. :rtype: float .. py:property:: reference_electrode Get the reference electrode information. :return: A tuple containing the reference electrode abbreviation and potential difference. :rtype: tuple .. py:method:: set_database(database) .. py:method:: __str__() Generate a string of the System object containing all chemical reactions, its temperature and pressure. :return: String representation of the System. :rtype: str .. py:method:: initialize() Initialize all chemical reactions included in the system using its current physiochemical parameters. :return: None :rtype: None .. py:method:: write_parameters_to_file(filename) Writes a dictionary of standard system parameters and physical constants into a JSON file. :param filename: Name of the JSON file to write parameters to. :type filename: str :param R: Ideal gas constant R = 8.31446262 J/mol/K. :type R: float :param F: Faraday constant F = 96485.3321 A*s/mol. :type F: float :param T0: Standard temperature T0 = 298.15 degree Kelvin. :type T0: float :param P0: Standard pressure P0 = 1.00 bar. :type P0: float :param Reference_abbreviation: Abbreviation of the reference electrode. :type Reference_abbreviation: str :param dE: Potential difference of the reference electrode in volts vs. the standard hydrogen electrode. :type dE: float :param T: Temperature in degree Kelvin. :type T: float :param P: Pressure in bar. :type P: float :param pHmin: Minimum pH of the diagram. :type pHmin: float :param pHmax: Maximum pH of the diagram. :type pHmax: float :param Emin: Minimum potential of the diagram in volts vs. SHE. :type Emin: float :param Emax: Maximum potential of the diagram in volts vs. SHE. :type Emax: float .. py:method:: read_parameters_from_file(filename) Reads system parameters from a JSON file. :param filename: Name of the JSON file to read parameters from. :type filename: str :return: None :rtype: None .. py:property:: pHs Get the system pH range. :return: A tuple containing the minimum and maximum pH values. :rtype: tuple .. py:property:: electrode_potentials Get the electrode potential range of the system and automatically check which value is the lower one an which one corresponds to the upper limit. :return: A tuple containing the minimum and maximum electrode potentials. :rtype: tuple .. py:property:: reference_abbreviation Get the abbreviation of the reference electrode. :return: Abbreviation of the reference electrode. :rtype: str .. py:property:: deltaE Get the potential difference of the reference electrode in volts vs. the standard hydrogen electrode. :return: Potential difference in volts. :rtype: float .. py:method:: add_elements(elements: list) Adds elements to the chemical system. :param elements: List of chemical elements in the system. :type elements: list .. py:method:: add_reactions(reactions) :abstractmethod: .. py:method:: _(reactions: list) Adds reactions to the chemical system. :param reactions: List of chemical reactions in the system. :type reactions: list .. py:method:: read_reactions_from_file(filename: str) Reads the reactions from a file and adds reactions to the chemical system :param filename: filename with reactions :type filename: str .. py:method:: set_aqueous_activity(element: str, activity: float) Modifies the aqueous activity of singular elements previously defined to be included in the chemical system. :param element: Chemical element in the system. :type element: str :param activity: Chemical activity of `element`. :type activity: float .. py:method:: _get_elements(elements) Validates the user-input list of chemical elements and updates the dictionary in system_parameters.json to include a dictionary of elements together with their aqueous activities. :param elements: List of chemical elements in the system. :type elements: list :raises ValueError: Error raised if the list of elements provided contains entries that are not in `element_list` of know and supported elements. :return: Dictionary of validated elements as keys and standard aqueous activities as values. :rtype: dict .. py:method:: construct_reactions_from_reactants(reactants: dict) Validates the user-input reactants and constructs reactions from reactants from a dictionary containing the reactants and their corresponding activities. :param reactants: A dictionary of reactants (species) as keys and their corresponding activities as values. :type reactants: dict :return: A Reaction object created based on the provided reactants and activities. :rtype: Reaction :raises ValueError: If any reactant contains elements not yet added to the system. .. py:method:: _get_reactions(reactions) Validates the user-input list of chemical reactions to appear on the Pourbaix diagram. :param reactions: List of chemical reactions in the system. :type reactions: list :raises ValueError: Error raised if list entries are not in the form of a dictionary. Further error validation upon creating the reaction() object from each entry provided. :return: List of chemical reaction objects featuring the systems potential and pH limits as well as the temperature and pressure. :rtype: list .. py:method:: _set_aqueous_activity(element: str, activity: float) -> dict Validates the user-input element and corresponding chemical activity and updates the dictionary in system_parameters.json. :param element: Chemical element whose activity is modified. :type element: str :param activity: Chemical activity of the element. :type activity: float :raises ValueError: Error raised if element provided is not part of the chemical system. :return: Dictionary of elements as keys and updated standard aqueous activities as values. :rtype: dict .. py:class:: DefaultParser Bases: :py:obj:`Parser` Helper class that provides a standard way to create an ABC using inheritance. .. py:method:: parse_reactions(reactions: tuple) :staticmethod: Parses several reactions given as tuple :param reactions: reactions to be parsed, each entry of a tuple is a reaction string :type reactions: tuple :return : reactions as list, each entry is a dict containing reactants :rtype : list .. py:method:: parse_reaction(reaction: str) :staticmethod: Parse a reaction from its string representation :param reaction: reaction to be parsed :type reaction: str :return : reactants as dict :rtype : dict .. py:method:: parse_species(species: tuple, elements: dict) :staticmethod: .. py:method:: parse_specie(specie: str) :staticmethod: Parse a specie and its chemical props from its string representation :param specie: specie_name,state,dGf,dHf,Sm as string :type specie: str :return : name of the specie, properties as dictionary :rtype : tuple .. py:method:: parse_elements() :staticmethod: .. py:class:: Database(species: list, elements: dict, parser=None) Bases: :py:obj:`object` .. py:attribute:: elements .. py:attribute:: species .. py:attribute:: parser :value: None .. py:method:: __str__() .. py:method:: from_default(species: tuple) :classmethod: Create database containing species and their chemical properties from a tuple of string : param species : Species data as tuple of strings : type species : tuple .. py:method:: from_file(filename: str) :classmethod: Create database containing species and their chemical properties from a txt file : param filename : file containing species data : type filename : str .. py:method:: add_reactions(reactions: tuple) .. py:method:: associate_reactions_to_database(reactions: list)