PourPy.system ============= .. py:module:: PourPy.system .. autoapi-nested-parse:: Created on Mon Jul 24 09:50:23 2023 @author: fabioenricofurcas Classes ------- .. autoapisummary:: PourPy.system.System Module Contents --------------- .. 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