Mixture objects

Mixture objects represent the behavior of mixed Substances.

Two different mixtures are available in Reactord: * IdealGas * IdealSolution

As an example, the behavior of the IdealGas mixture will be explained.

[1]:
import numpy as np

import reactord as rd

Instantiate a mixture object

To generate a mixture, first, it is necessary to create the Substance objects that will be in the mixture. For instance:

[2]:
so2 = rd.Substance.from_thermo_database("SO2", "sulphur dioxide")
o2 = rd.Substance.from_thermo_database("O2", "oxygen")
so3 = rd.Substance.from_thermo_database("SO3", "sulphur trioxide")
co2 = rd.Substance.from_thermo_database("CO2", "carbon dioxide")

A mixture is formed by introducing the objects as a list. In this case, an instance of the IdealGas class is created, using the Herning Zipperer mixing rule for mixture’s viscosity.

[15]:
gas_mixture = rd.mix.IdealGas(
    substance_list=[so2, o2, so3, co2],
    viscosity_mixing_rule="herning_zipperer"
)

You can access the individual substances of the mixture with the attribute substances. Note that the order of the substances is the same as the order used in the instantiation of the mixture.

[4]:
gas_mixture.substances[0].name
[4]:
'SO2'

Also, you can access to arrays of the attributes of the substances of the mixture. For example, the names, molecular weights or formation enthalpies.

[5]:
print(gas_mixture.names)

print(gas_mixture.molecular_weights)

print(gas_mixture.formation_enthalpies_ig)
['SO2' 'O2' 'SO3' 'CO2']
[64.0638 31.9988 80.0632 44.0095]
[-296800.       0. -395700. -393474.]

The complete list of the mixtures’ attributes can be accessed in the API’s documentation o IdealGas and AbstractMix.

Mixture’s methods

The most basic method of a mixture is mole_fractions which allows the calculation of the mole fractions of the mixture’s substances for a given mole composition.

For example, if we have a mixture with 10 mol of \(SO_2\), 21.5 mol of \(O_2\), 14.7 mol of \(SO_3\) and 6 mol of \(CO_2\). We can calculate the mole fractions as:

[6]:
moles = np.array([10, 21.5, 14.7, 6])

gas_mixture.mole_fractions(moles)
[6]:
array([0.19157088, 0.41187739, 0.2816092 , 0.11494253])

The mole_fractions method can accept multiple composition sets by a matrix. Each column of the matrix represents each composition set and each row represents each substance’s moles.

For example, in addition to the previous mixture, you want to calculate the mole fractions of a mixture of 5 mol of \(SO_2\), 10.5 mol of \(O_2\), 9 mol of \(SO_3\) and 11 mol of \(CO_2\).

[7]:
moles = np.array([[10, 5], [21.5, 10.5], [14.7, 9], [6, 11]])

gas_mixture.mole_fractions(moles)
[7]:
array([[0.19157088, 0.14084507],
       [0.41187739, 0.29577465],
       [0.2816092 , 0.25352113],
       [0.11494253, 0.30985915]])

Moreover, mole fractions, along with temperature (in K) and pressure (in Pa), can be utilized to determine the concentrations (in mol/m³). Note that we are obtaining the concentrations of the two composition sets in a matrix, which also each column of the matrix represents each composition set and each row represents each substance’s concentration [mol/m³].

[10]:
moles = np.array([[10, 5], [21.5, 10.5], [14.7, 9], [6, 11]])

mole_fractions = gas_mixture.mole_fractions(moles)

temperature = 298.15 # K
pressure = 101_325 # Pa

gas_mixture.concentrations(mole_fractions, temperature, pressure)
[10]:
array([[ 7.83027673,  5.75690768],
       [16.83509497, 12.08950613],
       [11.51050679, 10.36243382],
       [ 4.69816604, 12.66519689]])

Also, the IdealGas class also includes methods to:

  • Calculate the molar volume (mol/m³)

  • Calculate the heat capacity (J/K)

  • Establish the standard formation enthalpies of the substances in the mixture (J/(mol.K))

The complete list of the mixtures’ methods can be accessed in the API’s documentation o IdealGas and AbstractMix.

[14]:
moles = np.array([10, 21.5, 14.7, 6])

mole_fractions = gas_mixture.mole_fractions(moles)

temperature = 298.15  # K
pressure = 101325 # Pa

print(
    "Molar volume of the mixture: ",
    gas_mixture.volume(mole_fractions, temperature, pressure),
    "m³/mol",
)
print(
    "Heat capacity: ",
    gas_mixture.mix_heat_capacity(mole_fractions, temperature, pressure),
    " J/K",
)

print(
    "Formation enthalpies: ",
    gas_mixture.get_formation_enthalpies(),
    " J/(mol.K)"
)

Molar volume of the mixture:  0.02446540369658722 m³/mol
Heat capacity:  38.36623729591365  J/K
Formation enthalpies:  [-296800.       0. -395700. -393474.]  J/(mol.K)

Custom Mixture objects

Custom mixture classes can be built by inheriting the reactord.mix.AbstracMix class.