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
|
Calculates a molar rate of species from specified volume and composition at the specified timesteps. |
|
Calculates a molar rate of species from specified flow and composition. |
- dgpost.transform.rates.flow_to_molar(flow, c=None, x=None, Tref=<Quantity(273.15, 'kelvin')>, pref=<Quantity(1, 'standard_atmosphere')>, output='rate')
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 dimensionlesscomp
, 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 compositioncomp
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 compositioncomp
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 (
Quantity
) – The total flow of the mixture.c (
Optional
[dict
[str
,Quantity
]]) – A dictionary containing the composition of the mixture as concentration. Cannot be supplied at the same time asx
.x (
Optional
[dict
[str
,Quantity
]]) – A dictionary containing the composition of the mixture as mole fraction. Assuming ideal gas-phase flow. Cannot be supplied at the same time asc
.Tref (
Quantity
) – Reference temperature of the flow measurement, used when composition is specified using a mol fraction. By default set to 273.15 K.pref (
Quantity
) – Reference pressure of the flow measurement, used when composition is specified using a mol fraction. By default set to 1 atm.output (
str
) – Prefix of the keys of the returned rate dictionary.
- Return type:
dict
[str
,Quantity
]
- dgpost.transform.rates.batch_to_molar(time, c, V, t0=None, output='rate')
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 (
Quantity
) – An array of timestamps at which the concentrations and volumes are measured.c (
dict
[str
,Quantity
]) – A dictionary containing concentrations of species at the specified timestamps.V (
Quantity
) – Volume of the batch at the timestamps.t0 (
Optional
[Quantity
]) – 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 (
str
) – Prefix of the columns where the calculated rate will be stored.
- Return type:
dict
[str
,Quantity
]