reactord.mix package¶
Module contents¶
Mixture module.
- class reactord.mix.AbstractMix(substance_list: List[Substance], phase_nature: str, viscosity_mixing_rule: str)[source]¶
Bases:
objectMixture objects abstract class.
- Parameters:
metaclass (AbstractMix) – Mixture objects interface.
phase_nature (str) – Liquid or gas.
substance_list (List[Substance]) – List of substances.
viscosity_mixing_rule (str) – Viscosity mixing rule method. Options available: “linear”, “grunberg_nissan”, “herning_zipperer”.
- names¶
Names of the mixture’s substances.
- Type:
NDArray[str]
- molecular_weights¶
The molecular weights of the mixture’s substances. [g/mol]
- Type:
NDArray[np.float64]
- normal_boiling_points¶
The normal boiling points of the mixture’s substances. [K]
- Type:
NDArray[np.float64]
- normal_melting_points¶
The normal melting points of the mixture’s substances. [K]
- Type:
NDArray[np.float64]
- critical_temperatures¶
The critical temperatures of the mixture’s substances. [K].
- Type:
NDArray[np.float64]
- critical_pressures¶
The critical pressures of the mixture’s substances. [Pa]
- Type:
NDArray[np.float64]
- acentric_factors¶
The acentric factors of the mixture’s substances.
- Type:
NDArray[np.float64]
- formation_enthalpies¶
Standard state molar enthalpies of formation of the mixture’s substances. [J/mol]
- Type:
NDArray[np.float64]
- formation_enthalpies_ig¶
Ideal-gas molar enthalpies of formation of the mixture’s substances. [J/mol]
- Type:
NDArray[np.float64]
- phase_nature: str = 'gas'¶
- viscosity_mixing_rule: str = 'linear'¶
- mole_fractions(moles: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]¶
Calculate the mole fractions of the mixture’s substances.
Multiple mixture compositions can be specified by a moles matrix. Each column of the matrix represents each mixture and each row represent each substance’s mole fraction.
\[z_i = \frac {n_i} {\sum_{i=0}^{N} n_i}\]\(z_i\): mole fraction of the mix’s \(i\)-th substance.\(n_i\): moles of the mix’s \(i\)-th substance.\(N\): total number of substances in the mixture.- Parameters:
moles (Union[float, NDArray[np.float64]]) – Mole fractions of each substance specified in the same order as the mix’s substances order.
- Returns:
The array of the molar fractions of the mix’s substances. Each column of the matrix represents each mixture and each row represent each substance’s mole fraction.
- Return type:
Union[float, NDArray[np.float64]]
- mix_molecular_weight(mole_fractions: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]¶
Calculate the molecular weight of the mixture.
Multiple mixture compositions can be specified by a mole_fractions matrix. Each column of the matrix represents each mixture and each row represent each substance’s mole fraction. In this case, the return is a 1D array with the molecular weight of each mix.
\[M_{mix} = \sum_{i=0}^{N} M_i z_i\]\(M_{mix}\): molecular weight of the mixture.\(N\): total number of substances in the mixture.\(M_i\): molecular weight of the mix’s \(i\)-th substance.\(z_i\): mole fraction of the mix’s \(i\)-th substance.- Parameters:
mole_fractions (Union[float, NDArray[np.float64]]) – Mole fractions of each substance specified in the same order as the mix’s substances order.
- Returns:
The molecular weight of the mixture. [kg/kmol]
- Return type:
Union[float, NDArray[np.float64]]
Requires¶
molecular_weight defined on each mix’s Substance.
- molar_density(mole_fractions: float | ndarray[Any, dtype[float64]], temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]¶
Calculate the mixture’s molar density.
Multiple mixture compositions can be specified by a mole_fractions matrix. Each column of the matrix represents each mixture and each row represent each substance’s mole fraction. Also with temperature and pressure vectors following de NumPy broadcasting rules.
\[\rho_{mix} = \frac {1} {v_{(\vec{z}, T, P)}}\]\(\rho_{mix}\): mix’s molar density.\(v\): mix’s molar volume.\(T\): temperature.\(P\): pressure.\(\vec{z}\): substances’ mole fractions.- Parameters:
mole_fractions (Union[float, NDArray[np.float64]]) – Mole fractions of each substance specified in the same order as the mix’s substances order.
temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]
pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]
- Returns:
Mixture’s molar density. [mol/m3]
- Return type:
Union[float, NDArray[np.float64]]
- mass_density(mole_fractions: float | ndarray[Any, dtype[float64]], temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]¶
Calculate the mixture’s mass density.
Multiple mixture compositions can be specified by a mole_fractions matrix. Each column of the matrix represents each mixture and each row represent each substance’s mole fraction. Also with temperature and pressure vectors following de NumPy broadcasting rules.
\[\rho_{mix}^{mass} = \rho_{mix}^{mol} M_{mix}\]\(\rho_{mix}^{mass}\): mix’s masic density.\(\rho_{mix}^{mol}\): mix’s molar density.\(M_{mix}\): molecular weight of the mixture.- Parameters:
mole_fractions (Union[float, NDArray[np.float64]]) – Mole fractions of each substance specified in the same order as the mix’s substances order.
temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]
pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]
- Returns:
Mixture’s mass density. [kg/m3]
- Return type:
Union[float, NDArray[np.float64]]
Requires¶
molecular_weight defined on each mix’s Substance.
- mix_viscosity(mole_fractions: ndarray[Any, dtype[ScalarType]], temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]¶
Evaluate the viscosity of the mixture with the chosen mixing rule.
Multiple mixture compositions can be specified by a moles matrix. Each column of the matrix represents each mixture and each row represents each substance’s mole fractions. Also with temperature and pressure vectors following de NumPy broadcasting rules.
- Parameters:
mole_fractions (NDArray) – Mole fractions of each substance specified in the same order as the mix’s substances order.
temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]
pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]
- Returns:
Mixture’s viscosity. [Pa s]
- Return type:
Union[float, NDArray[np.float64]]
- partial_pressures(mole_fractions: ndarray[Any, dtype[ScalarType]], temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]¶
Calculate the partial pressures of the mixture’s substances.
Multiple mixture compositions can be specified by a mole_fractions matrix. Each column of the matrix represents each mixture and each row represent each substance’s mole fraction. Also with temperature and pressure vectors following de NumPy broadcasting rules.
\[P_i = P z_i\]\(P_i\): partial pressure of the \(i\)-th mix’s substance.\(P\): total system’s pressure.\(z_i\): mole fraction of the mix’s \(i\)-th substance.- Parameters:
mole_fractions (NDArray) – Mole fractions of each substance specified in the same order as the mix’s substances order.
temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]
pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]
- Returns:
An array that contains the partial pressures of mix’s substances. Each column of the matrix represents each mixture and each row represent each substance’s partial pressure. [Pa]
- Return type:
Union[float, NDArray[np.float64]]
- concentrations(mole_fractions: ndarray[Any, dtype[ScalarType]], temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]¶
Concentrations of the mixture’s substances.
Multiple mixture compositions can be specified by a moles matrix. Each column of the matrix represents each mixture and each row represents each substance’s mole fractions. Also with temperature and pressure vectors following de NumPy broadcasting rules.
\[C_i = z_i \rho_{mix}\]\(C_i\): concentration of the mix’s \(i\)-th substance.\(z_i\): mole fraction of the mix’s \(i\)-th substance.\(\rho_{mix}\): mix’s molar density.- Parameters:
mole_fractions (NDArray) – Mole fractions of each substance specified in the same order as the mix’s substances order.
temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]
pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]
- Returns:
An array that contains the concentrations of the mixture’s substances. [mol/m³]
- Return type:
Union[float, NDArray[np.float64]]
- abstract volume(mole_fractions: ndarray[Any, dtype[ScalarType]], temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]¶
Return the molar volume of the mixture.
Multiple mixture compositions can be specified by a moles matrix. Each column of the matrix represents each mixture and each row represents each substance’s mole fractions. Also with temperature and pressure vectors following de NumPy broadcasting rules.
- Parameters:
mole_fractions (NDArray) – Mole fractions of each substance specified in the same order as the mix’s substances order.
temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]
pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]
- Returns:
Mixture’s molar volume. [m³/mol]
- Return type:
Union[float, NDArray[np.float64]]
- Raises:
NotImplementedError – Abstract method not implemented.
- abstract mix_heat_capacity(mole_fractions: ndarray[Any, dtype[ScalarType]], temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]¶
Calculate the mixture’s heat capacity.
Multiple mixture compositions can be specified by a moles matrix. Each column of the matrix represents each mixture and each row represents each substance’s mole fractions. Also with temperature and pressure vectors following de NumPy broadcasting rules.
- Parameters:
mole_fractions (NDArray) – Mole fractions of each substance specified in the same order as the mix’s substances order.
temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]
pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]
- Returns:
Mixture’s heat capacity. [J/mol]
- Return type:
Union[float, NDArray[np.float64]]
- Raises:
NotImplementedError – Abstract method not implemented.
- abstract formation_enthalpies_correction(temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]¶
Calculate the correction term for the formation enthalpy.
Method that calculates the correction term for the formation enthalpies of the pure substances from 298.15 K and 101325 Pa to the given temperature and pressure. Multiple temperatures and pressures may be specified following de NumPy broadcasting rules.
- Parameters:
temperature (Union[float, NDArray[np.float64]]) – Temperature at which formation enthalpies are to be calculated. [K]
pressure (Union[float, NDArray[np.float64]]) – Pressure at which formation enthalpies are to be calculated. [Pa]
- Returns:
Formation enthalpies correction for each mix’s substance. [J/mol/K]
- Return type:
Union[float, NDArray[np.float64]]
- Raises:
NotImplementedError – Abstract method not implemented.
- abstract get_formation_enthalpies() float | ndarray[Any, dtype[float64]][source]¶
Calculate the formation enthalpy of the mixture’s substances.
- Returns:
Formation enthalpies of the mixture’s substances. [J/mol]
- Return type:
Union[float, NDArray[np.float64]]
- Raises:
NotImplementedError – Abstract method not implemented.
- class reactord.mix.IdealGas(substance_list: List[Substance], viscosity_mixing_rule: str = 'herning_zipperer')[source]¶
Bases:
AbstractMixIdealGas object class.
This class should be used when the mixture is considered an ideal gas.
- Parameters:
substance_list (list[Substance]) – list of substance objects
viscosity_mixing_rule (str, optional) – Viscosity mixing rule method. Options available: “linear”, “grunberg_nissan”, “herning_zipperer”., by default “herning_zipperer”
- phase_nature¶
gas.
- Type:
str
- viscosity_mixing_rule¶
Viscosity mixing rule method.
- Type:
str
- volume(mole_fractions: ndarray, temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float[source]¶
Return the molar volume of the mixture.
Multiple mixture compositions can be specified by a moles matrix. Each column of the matrix represents each mixture and each row represents each substance’s mole fractions. Also with temperature and pressure vectors following de NumPy broadcasting rules.
\[v = \frac {R T} {P}\]\(v\): mix’s molar volume.\(R\): Ideal gas constant = 8.31446261815324 \(\frac {m^3 Pa} {K mol}\)\(T\): temperature.\(P\): pressure.- Parameters:
mole_fractions (NDArray[np.float64]) – mole fractions of each substance specified in the same order as the mix’s substances order.
temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]
pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]
- Returns:
Mixture’s molar volume. [m³/mol]
- Return type:
Union[float, NDArray[np.float64]]
- mix_heat_capacity(mole_fractions: ndarray, temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float[source]¶
Calculate the mixture’s heat capacity [J/mol].
Multiple mixture compositions can be specified by a moles matrix. Each column of the matrix represents each mixture and each row represents each substance’s mole fractions. Also with temperature and pressure vectors following de NumPy broadcasting rules.
\[C_{p_{mix}} = \sum_{i=0}^{N} z_i C_{p_i}\]\(C_{p_{mix}}\): mix’s heat capacity.\(N\): total number of substances in the mixture.\(C_{p_i}\): ideal gas heat capacity of the mix’s \(i\)-th substance.\(z_i\): mole fraction of the mix’s \(i\)-th substance.- Parameters:
mole_fractions (np.ndarray [float]) – mole fractions of each substance specified in the same order as the mix’s substances order.
temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]
pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]
- Returns:
Union[float, NDArray[np.float64]] – Mixture’s heat capacity. [J/mol]
Requires
——– – heat_capacity_gas defined on each mix’s Substance.
- formation_enthalpies_correction(temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]])[source]¶
Calculate the correction term for the formation enthalpy.
Method that calculates the correction term for the formation enthalpies of the pure substances from 298.15 K and 101325 Pa to the given temperature and pressure.
\[ \begin{align}\begin{aligned}\Delta H_{f T_{(g)}} = \Delta H_{f 298.15_{(g)}}^0 + \sum_{i=0}^{N} \int_{298.15}^{T} v_i C_{p_i} dT\\CT = \sum_{i=0}^{N} \int_{298.15}^{T} v_i C_{p_i} dT\end{aligned}\end{align} \]\(\Delta H_{f T_{(g)}}\): reaction enthalpy.\(\Delta H_{f 298.15_{(g)}}^0\): ideal gas standard reaction enthalpy.\(N\): total number of substances in the mixture.\(C_{p_i}\): ideal gas heat capacity of the mix’s \(i\)-th substance.\(z_i\): mole fraction of the mix’s \(i\)-th substance.\(v_i\): stoichiometric coefficient of the mix’s \(i\)-th substance.\(CT\): correction term.- Parameters:
temperature (Union[float, NDArray[np.float64]]) – Temperature at which formation enthalpies are to be calculated. [K]
pressure (Union[float, NDArray[np.float64]]) – Pressure at which formation enthalpies are to be calculated. [Pa]
- Returns:
Formation enthalpies of each substance (J/mol/K)
- Return type:
Union[float, NDArray[np.float64]]
- get_formation_enthalpies()[source]¶
Return the ideal gas formation enthalpies in an ordered ndarray.
Method that read the ideal gas formation enthalpies of the mix class and returns them in an ordered ndarray.
- Returns:
Ideal gas formation enthalpies of each substance [J/mol/K]
- Return type:
Union[float, NDArray[np.float64]]
- class reactord.mix.IdealSolution(substance_list: List[Substance], viscosity_mixing_rule: str = 'grunberg_nissan')[source]¶
Bases:
AbstractMixIdealSolution object class.
This class should be used when the mixture is considered an ideal solution.
- Parameters:
substance_list (list [float]) – list of substance objects
viscosity_mixing_rule (str, optional) – Viscosity mixing rule method. Options available: “linear”, “grunberg_nissan”, “herning_zipperer”., by default “grunberg_nissan”
- phase_nature¶
liquid.
- Type:
str
- viscosity_mixing_rule¶
Viscosity mixing rule method.
- Type:
str
- volume(mole_fractions: List[float], temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float[source]¶
Return the molar volume of the mixture.
Multiple mixture compositions can be specified by a moles matrix. Each column of the matrix represents each mixture and each row represents each substance’s mole fractions. Also with temperature and pressure vectors following de NumPy broadcasting rules.
\[v = \sum z_i {v_i}_{(T,P)}\]\(v\): mix’s molar volume.\(z_i\): mole fraction of the mix’s \(i\)-th substance.\({v_i}_{(T,P)\): liquid molar volume of the mix’s \(i\)-th substance.\(T\): temperature.\(P\): pressure.- Parameters:
mole_fractions (np.Union[float, NDArray[np.float64]]) – mole fractions of each substance specified in the same order as the mix’s substances order.
temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]
pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]
- Returns:
Mixture’s molar volume. [m³/mol]
- Return type:
float
Requires¶
volume_liquid defined on each mix’s Substance.
- mix_heat_capacity(mole_fractions: List[float], temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]])[source]¶
Calculate the mixture’s heat capacity [J/mol].
Multiple mixture compositions can be specified by a moles matrix. Each column of the matrix represents each mixture and each row represents each substance’s mole fractions. Also with temperature and pressure vectors following de NumPy broadcasting rules.
\[C_{p_{mix}} = \sum_{i=0}^{N} z_i C_{p_i}\]\(C_{p_{mix}}\): mix’s heat capacity.\(N\): total number of substances in the mixture.\(C_{p_i}\): ideal gas heat capacity of the mix’s \(i\)-th substance.\(z_i\): mole fraction of the mix’s \(i\)-th substance.- Parameters:
mole_fractions (np.Union[float, NDArray[np.float64]]) – mole fractions of each substance specified in the same order as the mix’s substances order.
temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]
pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]
- Returns:
Mixture’s heat capacity. [J/mol]
- Return type:
float
Requires¶
heat_capacity_liquid defined on each mix’s Substance.
- formation_enthalpies_correction(temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]])[source]¶
Calculate the correction term for the formation enthalpy.
Method that calculates the correction term for the formation enthalpies of the pure substances from 298.15 K and 101325 Pa to the given temperature and pressure using Kirchhoff’s equation. If the substance is a solid at a temperature > 298.15 K, this method also takes it into account.
- Parameters:
temperature (Union[float, NDArray[np.float64]]) – Temperature at which formation enthalpies are to be calculated. [K]
pressure (Union[float, NDArray[np.float64]]) – Pressure at which formation enthalpies are to be calculated. [Pa]
- Returns:
correction_enthalpies – Formation enthalpies correction for each substance (J/mol/K)
- Return type:
Union[float, NDArray[np.float64]]