rates: determining molar rates of chemical species

Code author: Peter Kraus

Includes functions to convert mixture compositions (concentration, mol fraction) from instantaneous flow data or continuous batch data to rates (dimension of [quantity]/[time]). The flow_to_molar() function is useful for converting gas-phase or liquid flows, while batch_to_molar() can be used to determine formation rates from the concentration profile of a batch mixture.

Functions

batch_to_molar(time, c, V[, t0, output])

Calculates a molar rate of species from specified volume and composition at the specified timesteps.

flow_to_molar(flow[, c, x, Tref, pref, output])

Calculates a molar rate of species from specified flow and composition.

dgpost.transform.rates.flow_to_molar(flow: ~pint.registry.Quantity, c: dict[str, ~pint.registry.Quantity] = None, x: dict[str, ~pint.registry.Quantity] = None, Tref: ~pint.registry.Quantity = <Quantity(273.15, 'kelvin')>, pref: ~pint.registry.Quantity = <Quantity(1, 'standard_atmosphere')>, output: str = 'rate') dict[str, Quantity]

Calculates a molar rate of species from specified flow and composition. The units of the rate have to be either dimensionless (for unit-naive dataframes) or in dimensions of [substance]/[time].

Currently, three combinations of units are supported:

  • Dimensionless flow and dimensionless comp, as is the case for unit-naive dataframes. In this case, the molar flow rates of species \(r_s\) are calculated by a simple multiplication:

    \[r_s = \text{flow} \times \text{comp}_s\]
  • Volumetric flow \(\dot{V}\) and composition comp as a concentration, as is often the case in liquid flows. In this case, the molar rates of species \(r_s\) are also a simple multiplication (accounting for unit conversion):

    \[r_s = \dot{V} \times c_s\]
  • Volumetric flow \(\dot{V}\) and composition comp as a dimensionless molar fraction \(x_s\), in which case the flow is assumed to be gas-phase. In this case, the flow has to be converted to molar units using the ideal gas law:

    \[r_s = \dot{V} \times \frac{p_\text{ref}}{RT_\text{ref}} \times x_s\]

    The pressure \(p_\text{ref}\) and temperature \(T_\text{ref}\) are specifying the state at which the flow \(\dot{V}\) has been measured.

Parameters:
  • flow – The total flow of the mixture.

  • c – A dictionary containing the composition of the mixture as concentration. Cannot be supplied at the same time as x.

  • x – A dictionary containing the composition of the mixture as mole fraction. Assuming ideal gas-phase flow. Cannot be supplied at the same time as c.

  • Tref – Reference temperature of the flow measurement, used when composition is specified using a mol fraction. By default set to 273.15 K.

  • pref – Reference pressure of the flow measurement, used when composition is specified using a mol fraction. By default set to 1 atm.

  • output – Prefix of the keys of the returned rate dictionary.

dgpost.transform.rates.batch_to_molar(time: Quantity, c: dict[str, Quantity], V: Quantity, t0: Quantity = None, output: str = 'rate') dict[str, Quantity]

Calculates a molar rate of species from specified volume and composition at the specified timesteps. The units of the rate have to be either dimensionless (for unit-naive dataframes) or in dimensions of [substance]/[time].

First, the \(\delta t\) and \(\delta c(x)\) at each timestep \(n\) is calculated:

\[\delta t_n = t_n - t_{n-1} \delta c(x)_n = c(x)_n - c(x)_{n-1}\]

Then, the formation rate is calculated using the volume:

Parameters:
  • time – An array of timestamps at which the concentrations and volumes are measured.

  • c – A dictionary containing concentrations of species at the specified timestamps.

  • V – Volume of the batch at the timestamps.

  • t0 – An optional timestamp representing the initial time where all concentrations are zero. If not supplied, the calculation will use the first datapoint as reference with its rates set to zero.

  • output – Prefix of the columns where the calculated rate will be stored.