reactord.substance package

Module contents

Substance module.

class reactord.substance.Substance(name: str, molecular_weight: float | None = None, normal_boiling_point: float | None = None, normal_melting_point: float | None = None, critical_temperature: float | None = None, critical_pressure: float | None = None, acentric_factor: float | None = None, formation_enthalpy: float | None = None, formation_enthalpy_ig: float | None = None, vaporization_enthalpy: Callable | None = None, sublimation_enthalpy: Callable | None = None, volume_solid: Callable | None = None, volume_liquid: Callable | None = None, heat_capacity_solid: Callable | None = None, heat_capacity_liquid: Callable | None = None, heat_capacity_gas: Callable | None = None, thermal_conductivity_liquid: Callable | None = None, thermal_conductivity_gas: Callable | None = None, viscosity_liquid: Callable | None = None, viscosity_gas: Callable | None = None, heat_capacity_solid_dt_integral: Callable | None = None, heat_capacity_liquid_dt_integral: Callable | None = None, heat_capacity_gas_dt_integral: Callable | None = None, vectorize_functions: bool = False)[source]

Bases: Symbolic

Substance object class.

Class to define a substance object. Specific attributes definition will be required for the reactors, described in each reactor documentation. For example, an adiabatic reactor will require that substances define a heat capacity function for the substances, on the other hand, when using isothermic reactors this won’t be necessary. Substance has the from_thermo_data_base alternative construction method. Substances objects can be saved as pickle files with the method to_pickle. substances can be loaded from a pickle file with the method from_pickle.

Example:

>>> water = Substance.from_thermo_data_base('water')
>>> water.to_pickle('my_water_file')
>>> water_pickle = water.from_pickle('my_water_file)
Parameters:
  • name (str) – Name of the substance.

  • molecular_weight (float, optional) – The molecular weight of the substance [g/mol], by default None.

  • normal_boiling_point (float, optional) – The normal boiling point of the substance [K], by default None.

  • normal_melting_point (float, optional) – The normal melting point of the substance [K], by default None.

  • critical_temperature (float, optional) – The critical temperature of the substance [K], by default None.

  • critical_pressure (float, optional) – The critical pressure of the substance [Pa], by default None.

  • acentric_factor (float, optional) – The acentric factor of the substance, by default None.

  • formation_enthalpy (float, optional) – Standard state molar enthalpy of formation [J/mol], by default None.

  • formation_enthalpy_ig (float, optional) – Ideal-gas molar enthalpy of formation [J/mol], by default None.

  • vaporization_enthalpy (Callable, optional) – A function that receives a temperature and returns the vaporization enthalpy at temperature [J/mol], by default None.

  • sublimation_enthalpy (Callable, optional) – A function that receives temperature and returns the sublimation enthalpy at temperature [J/mol], by default None.

  • volume_solid (Callable, optional) – A function that receives temperature and pressure, and returns the molar volume of the solid at temperature [m³/mol], by default None.

  • volume_liquid (Callable, optional) – A function that receives temperature and pressure, and returns the molar volume of liquid at temperature and pressure [m³/mol], by default None.

  • heat_capacity_solid (Callable, optional) – A function that receives temperature and pressure, and returns the heat capacity of the solid at temperature and pressure [J/mol/K], by default None.

  • heat_capacity_liquid (Callable, optional) – A function that receives temperature and pressure, and returns the heat capacity of the liquid at temperature and pressure [J/mol/K], by default None.

  • heat_capacity_gas (Callable, optional) – A function that receives temperature and pressure, and returns the ideal gas heat capacity at temperature and pressure [J/mol/K], by default None.

  • thermal_conductivity_liquid (Callable, optional) – A function that receives temperature and pressure, and returns the thermal conductivity of the liquid at temperature and pressure [W/m/K], by default None.

  • thermal_conductivity_gas (Callable, optional) – A function that receives temperature and pressure, and returns the thermal conductivity of the gas at temperature and pressure [W/m/K], by default None.

  • viscosity_liquid (Callable, optional) – A function that receives temperature and pressure, and returns the viscosity of the liquid at temperature and pressure [Pa*s], by default None.

  • viscosity_gas (Callable, optional) – A function that receives temperature and pressure, and returns the viscosity of gas at temperature and pressure [Pa*s], by default None.

  • heat_capacity_solid_dt_integral (Callable, optional) – A function that receives temperature1, temperature2 and pressure, and returns the integral of the solid heat capacity over temperature1 and temperature2 at pressure, by default None.

  • heat_capacity_liquid_dt_integral (Callable, optional) – A function that receives temperature1, temperature2 and pressure, and returns the integral of the liquid heat capacity over temperature1 and temperature2 at pressure, by default None.

  • heat_capacity_gas_dt_integral (Callable, optional) – A function that receives temperature1, temperature2 and pressure, and returns the integral of the gas heat capacity over temperature1 and temperature2 at pressure, by default None.

  • vectorize_functions (bool, optional) – When True, numpy.vectorize() is applied to the temperature and pressure Substance Callable paramaters on Substance object init, by default False.

name

Name of the substance, by default None.

Type:

str

molecular_weight

The molecular weight of the substance [g/mol], by default None.

Type:

float

normal_boiling_point

The normal boiling point of the substance [K], by default None.

Type:

float

normal_melting_point

The normal melting point of the substance [K], by default None.

Type:

float

critical_temperature

The critical temperature of the substance [K], by default None.

Type:

float

critical_pressure

The critical pressure of the substance [Pa], by default None.

Type:

float

acentric_factor

The acentric factor of the substance, by default None.

Type:

float

formation_enthalpy

Standard state molar enthalpy of formation [J/mol], by default None.

Type:

float

formation_enthalpy_ig

Ideal-gas molar enthalpy of formation [J/mol], by default None.

Type:

float

vectorize_functions

When True, numpy.vectorize() is applied to the temperature and pressure Substance functions on Substance object init, by default False.

Type:

bool

classmethod from_thermo_database(name: str, thermo_identification: str) Substance[source]

Substance instance from Bell Caleb’s thermo library.

Method that uses Bell Caleb’s Thermo library to construct the Substance object.

Cite: Caleb Bell and Contributors (2016-2021). Thermo: Chemical properties component of Chemical Engineering Design Library (ChEDL) https://github.com/CalebBell/thermo.

Parameters:
  • name (str) – Name that will be assigned to the Substance object.

  • thermo_identification (str) – Name or CAS number of the substance that would be used to search in the Thermo library.

Returns:

Instantiated Substance object from thermo database.

Return type:

Substance

classmethod from_pickle(name_file: str) Substance[source]

Read a dill Substance file and return the Substance object.

Parameters:

name_file (str) – path/to/file.

Returns:

Substance – Substance object.

Return type:

Substance

to_pickle(name_file: str) /home/docs/checkouts/readthedocs.org/user_builds/reactord/checkouts/latest/reactord/substance/substance.py[source]

Serialize an substance object with dill library.

This method save an object substance as a file.

Parameters:

name_file (str) – Name of file to save the substance object.

Returns:

A binary file with substance predefine object.

Return type:

_file_

vaporization_enthalpy(temperature: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]

Return the vaporization enthalpy at a given temperature.

Parameters:

temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]

Returns:

Vaporization enthalpy. [J/mol]

Return type:

Union[float, NDArray[np.float64]]

sublimation_enthalpy(temperature: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]

Return the sublimation enthalpy at a given temperature.

Parameters:

temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]

Returns:

Sublimation enthalpy. [J/mol]

Return type:

Union[float, NDArray[np.float64]]

fusion_enthalpy(temperature: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]

Return the fusion enthalpy at a given temperature.

Uses the sublimation and vaporization enthalpy functions for the fusion enthalpy calculations at a given temperature, by calculating the sublimation and vaporization enthalpy difference.

Parameters:

temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]

Returns:

Fusion enthalpy. [J/mol]

Return type:

Union[float, NDArray[np.float64]]

volume_solid(temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]

Return the solid molar volume at a given temperature and pressure.

Parameters:
  • temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]

  • pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]

Returns:

Solid molar volume. [m³/mol]

Return type:

Union[float, NDArray[np.float64]]

volume_liquid(temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]

Return the liquid molar volume at a given temperature and pressure.

Parameters:
  • temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]

  • pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]

Returns:

Liquid molar volume. [m³/mol]

Return type:

Union[float, NDArray[np.float64]]

heat_capacity_solid(temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]

Return the pure solid heat capacity at a given temperature.

Parameters:
  • temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]

  • pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]

Returns:

Solid heat capacity. [J/mol/K]

Return type:

Union[float, NDArray[np.float64]]

heat_capacity_liquid(temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]

Return the pure liquid heat capacity at a given temperature.

Parameters:
  • temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]

  • pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]

Returns:

Liquid heat capacity. [J/mol/K]

Return type:

Union[float, NDArray[np.float64]]

heat_capacity_gas(temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]

Return the ideal gas heat capacity at a given temperature.

Parameters:
  • temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]

  • pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]

Returns:

Ideal gas heat capacity. [J/mol/K]

Return type:

Union[float, NDArray[np.float64]]

thermal_conductivity_liquid(temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]

Return the liquid thermal conductivity.

Parameters:
  • temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]

  • pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]

Returns:

Liquid thermal conductivity. [W/m/K]

Return type:

Union[float, NDArray[np.float64]]

thermal_conductivity_gas(temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]

Return the gas thermal conductivity.

Parameters:
  • temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]

  • pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]

Returns:

Gas thermal conductivity. [W/m/K]

Return type:

Union[float, NDArray[np.float64]]

viscosity_liquid(temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]

Return the pure liquid viscosity.

Pure liquid viscosity at a given temperature and pressure.

Parameters:
  • temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]

  • pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]

Returns:

Liquid viscosity. [Pa s]

Return type:

Union[float, NDArray[np.float64]]

viscosity_gas(temperature: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]

Return the pure gas viscosity.

Pure gas viscosity at a given temperature and pressure.

Parameters:
  • temperature (Union[float, NDArray[np.float64]]) – Temperature. [K]

  • pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]

Returns:

Gas viscosity. [Pa s]

Return type:

Union[float, NDArray[np.float64]]

heat_capacity_solid_dt_integral(temperature1: float | ndarray[Any, dtype[float64]], temperature2: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]

Return the integral of solid heat capacity.

Calculate the integral of solid heat capacity between temperature1 and temperature2

\[\int_{T_1}^{T_2} {C_{p_{solid}} (T, P)} \mathrm{d}T\]
\(T_1\): temperature1.
\(T_2\): temperature2.
\(C_{p_{solid}} (T, P)\): solid heat capacity.
Parameters:
  • temperature1 (Union[float, NDArray[np.float64]]) – Lower temperature integral bound. [K]

  • temperature2 (Union[float, NDArray[np.float64]]) – Upper temperature integral bound. [K]

  • pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]

Returns:

Integral of solid heat capacity between temperature1 and temperature2. [J/mol]

Return type:

Union[float, NDArray[np.float64]]

heat_capacity_liquid_dt_integral(temperature1: float | ndarray[Any, dtype[float64]], temperature2: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]

Return the integral of liquid heat capacity.

Calculate the definite integral of liquid heat capacity between temperature1 and temperature2

\[\int_{T_1}^{T_2} {C_{p_{liquid}} (T, P)} \mathrm{d}T\]
\(T_1\): temperature1.
\(T_2\): temperature2.
\(C_{p_{liquid}} (T, P)\): liquid heat capacity.
Parameters:
  • temperature1 (Union[float, NDArray[np.float64]]) – Lower temperature integral bound. [K]

  • temperature2 (Union[float, NDArray[np.float64]]) – Upper temperature integral bound. [K]

  • pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]

Returns:

Definite integral of liquid heat capacity between temperature1 and temperature2. [J/mol]

Return type:

Union[float, NDArray[np.float64]]

heat_capacity_gas_dt_integral(temperature1: float | ndarray[Any, dtype[float64]], temperature2: float | ndarray[Any, dtype[float64]], pressure: float | ndarray[Any, dtype[float64]]) float | ndarray[Any, dtype[float64]][source]

Return the integral of gas heat capacity.

Calculate the definite integral of gas heat capacity between temperature1 and temperature2.

\[\int_{T_1}^{T_2} {C_{p_{gas}} (T, P)} \mathrm{d}T\]
\(T_1\): temperature1.
\(T_2\): temperature2.
\(C_{p_{gas}} (T, P)\): ideal gas heat capacity.
Parameters:
  • temperature1 (Union[float, NDArray[np.float64]]) – Lower temperature integral bound. [K]

  • temperature2 (Union[float, NDArray[np.float64]]) – Upper temperature integral bound. [K]

  • pressure (Union[float, NDArray[np.float64]]) – Pressure. [Pa]

Returns:

Definite integral of gas heat capacity between temperature1 and temperature2. [J/mol]

Return type:

Union[float, NDArray[np.float64]]

class reactord.substance.Symbolic(names: str | ndarray[Any, dtype[ScalarType]], expression: Symbol | None = None, chem_equality: Equality | None = None)[source]

Bases: object

Parent class of Substance. Redefines algebraic operators.

This class is created as a parent class of Substance and redefines the __add__, __mul__, __rmul__, __gt__ and __truediv__ methods to allow the construction of chemical equations from algebraic operations with Substance objects.

Parameters:
  • names (Union[str, np.ndarray]) – Array that stores the name attribute of the substances that participates in a chemical equation.

  • expression (Symbol, optional) – Full chemical expression as a SymPy symbol, by default None.

  • chem_equality (Equality, optional) – Full chemical expression as a SymPy Equality, by default None.

Raises:

TypeError – “Substance’s name must be a string.”

reactord.substance.thermo_substance_constructor(substance: Substance, name: str, thermo_identification: str) Substance[source]

Substance constructor from Thermo database.

The functions of the Thermo library are all exclusively temperature functions (pressure is not used).

Parameters:
  • cls (Substance) – Substance class.

  • name (str) – Name that will be assigned to the Substance object.

  • thermo_identification (str) – Name or CAS number of the substance that will be used to search in the Thermo library.

Returns:

Instantiated Substance object from thermo database.

Return type:

Substance