Calculations
Real Adsorbed Solution Theory (RAST)
RAST calculation module.
- pyrast.calculations.rast.rast(partial_pressures, isotherms, activity_coefficient: ActivityCoefficient, *, verbose: bool = False, warningoff: bool = False, adsorbed_mole_fraction_guess=None, phi_guess: float = 1.0, solver_options: dict | None = None)[source]
Performs forward RAST calculation to predict mixture adsorption.
The RAST calculation is performed by solving for the adsorbed phase mole fractions and spreading pressure that satisfy the RAST equations. The root finding is started from an initial guess of the pure component loadings at the given partial pressures. The RAST equations are solved in an unconstrained space using softmax and softplus transformations to ensure valid mole fractions and spreading pressures. The final loadings of each component are calculated from the solved mole fractions and spreading pressure.
See documentation on activity coefficient models to understand how to use activity coefficients in RAST calculations.
- Parameters:
partial_pressures (list or np.ndarray) – list of partial pressures of each component in the gas phase. Length must match number of isotherms.
isotherms (list of analytical or interpolator isotherms) – list of isotherm objects for each component. Length must match length of partial_pressures.
activity_coefficient (ActivityCoefficient) – Fitted ActivityCoefficient model for the binary mixture.
verbose (bool, optional) – If True, prints detailed information about the RAST calculation.
warningoff (bool, optional) – If True, suppresses warnings about extrapolation of isotherm data.
adsorbed_mole_fraction_guess (list or np.ndarray, optional) – Initial guess for adsorbed phase mole fractions. Length must match number of components. If not provided, defaults to pure-component loadings at the given partial pressures.
phi_guess (float, optional) – Initial guess for spreading pressure. Default is 1.0. This is used in the root finding for the RAST equations and can be adjusted if the default guess does not lead to convergence.
solver_options (dict, optional) – Dictionary of options to pass to scipy.optimize.root for solving the RAST equations. This will override the default options used by pyRAST. All options accepted by scipy.optimize.root are valid here.
- Returns:
Loadings of each component in the adsorbed phase.
- Return type:
np.ndarray
- Raises:
ValueError – If number of isotherms does not match length of partial_pressures, if more or less than 2 isotherms are provided, if solved adsorbed mole fractions are not in [0,1].
RuntimeError – If root finding for adsorbed phase mole fractions fails to converge.
- pyrast.calculations.rast.reverse_rast(adsorbed_mole_fractions, total_pressure, isotherms, activity_coefficient: ActivityCoefficient, *, verbose: bool = False, warningoff: bool = False, gas_mole_fraction_guess=None, phi_guess: float = 1.0, solver_options: dict | None = None)[source]
Performs reverse RAST calculation to predict gas phase of adsorbed solution.
The RAST calculation is performed by solving for the gas phase mole fractions and spreading pressure that satisfy the RAST equations. The root finding is started from an initial guess of the desired adsorbed mole fractions. The RAST equations are solved in an unconstrained space using softmax and softplus transformations to ensure valid mole fractions and spreading pressures. The final loadings of each component are calculated from the solved mole fractions and spreading pressure.
See documentation on activity coefficient models to understand how to use activity coefficients in RAST calculations.
- Parameters:
adsorbed_mole_fractions (list or np.ndarray) – list of adsorbed mole fractions of each component in the adsorbed phase. Length must match number of isotherms.
total_pressure (float) – Total pressure of the gas phase.
isotherms (list of analytical or interpolator isotherms) – list of isotherm objects for each component. Length must match length of partial_pressures.
activity_coefficient (ActivityCoefficient) – Fitted ActivityCoefficient model for the binary mixture.
verbose (bool, optional) – If True, prints detailed information about the RAST calculation.
warningoff (bool, optional) – If True, suppresses warnings about extrapolation of isotherm data.
gas_mole_fraction_guess (list or np.ndarray, optional) – Initial guess for gas phase mole fractions. Length must match number of components. If not provided, defaults to the adsorbed mole fractions.
phi_guess (float, optional) – Initial guess for spreading pressure. Default is 1.0. This is used in the root finding for the RAST equations and can be adjusted if the default guess does not lead to convergence.
solver_options (dict, optional) – Dictionary of options to pass to scipy.optimize.root for solving the RAST equations. This will override the default options used by pyRAST. All options accepted by scipy.optimize.root are valid here.
- Returns:
(np.ndarray of gas phase mole fractions, np.ndarray of loadings)
- Return type:
tuple
- Raises:
ValueError – If more or less than 2 isotherms are provided, if length of adsorbed molefractions does not match number of isotherms, if adsorbed mole fractions do not sum to 1.0, if solved gas phase mole fractions are not in [0,1].
RuntimeError – If root finding for gas phase mole fractions fails to converge.
Ideal Adsorbed Solution Theory (IAST)
IAST calculation module.
- pyrast.calculations.iast.iast(partial_pressures, isotherms, *, verbose: bool = False, warningoff: bool = False, adsorbed_mole_fraction_guess=None, solver_options: dict | None = None)[source]
Performs forward IAST calculation to predict mixture adsorption.
The IAST calculation is performed by solving for the adsorbed phase mole fractions that satisfy the IAST equations. The root finding is started from an initial guess of the pure component loadings at the given partial pressures. The IAST equations are solved in an unconstrained space using the softmax transformation to ensure valid mole fractions. The final loadings of each component are calculated from the solved mole fractions.
- Parameters:
partial_pressures (list or np.ndarray) – list of partial pressures of each component in the gas phase. Length must match number of isotherms.
isotherms (list of analytical or interpolator isotherms) – list of isotherm objects for each component. Length must match length of partial_pressures.
verbose (bool, optional) – If True, prints detailed information about the IAST calculation.
warningoff (bool, optional) – If True, suppresses warnings about extrapolation of isotherm data.
adsorbed_mole_fraction_guess (list or np.ndarray, optional) – Initial guess for adsorbed phase mole fractions. Length must match number of components. If not provided, defaults to pure-component loadings at the given partial pressures.
solver_options (dict, optional) – Dictionary of options to pass to scipy.optimize.root for solving the IAST equations. This will override the default options used by pyRAST. All options accepted by scipy.optimize.root are valid here.
- Returns:
Loadings of each component in the adsorbed phase.
- Return type:
np.ndarray
- Raises:
ValueError – If number of isotherms does not match length of partial_pressures, if less than 2 isotherms are provided, if solved adsorbed mole fractions are not in [0,1].
RuntimeError – If root finding for adsorbed phase mole fractions fails to converge.
- pyrast.calculations.iast.reverse_iast(adsorbed_mole_fractions, total_pressure, isotherms, *, verbose: bool = False, warningoff: bool = False, gas_mole_fraction_guess=None, solver_options: dict | None = None)[source]
Performs reverse IAST calculation to predict gas phase of adsorbed solution.
The IAST calculation is performed by solving for the gas phase mole fractions that satisfy the IAST equations. The root finding is started from an initial guess of the desired adsorbed mole fractions. The IAST equations are solved in an unconstrained space using the softmax transformation to ensure valid mole fractions. The final loadings of each component are calculated from the solved mole fractions.
- Parameters:
adsorbed_mole_fractions (list or np.ndarray) – list of adsorbed mole fractions of each component in the adsorbed phase. Length must match number of isotherms.
total_pressure (float) – Total pressure of the gas phase.
isotherms (list of analytical or interpolator isotherms) – list of isotherm objects for each component. Length must match length of partial_pressures.
verbose (bool, optional) – If True, prints detailed information about the IAST calculation.
warningoff (bool, optional) – If True, suppresses warnings about extrapolation of isotherm data.
gas_mole_fraction_guess (list or np.ndarray, optional) – Initial guess for gas phase mole fractions. Length must match number of components. If not provided, defaults to the adsorbed mole fractions.
solver_options (dict, optional) – Dictionary of options to pass to scipy.optimize.root for solving the IAST equations. This will override the default options used by pyRAST. All options accepted by scipy.optimize.root are valid here.
- Returns:
(np.ndarray of gas phase mole fractions, np.ndarray of loadings)
- Return type:
tuple
- Raises:
ValueError – If less than 2 isotherms are provided, if length of adsorbed mole fractions does not match number of isotherms, if adsorbed mole fractions do not sum to 1.0, if solved gas phase mole fractions are not in [0,1].
RuntimeError – If root finding for gas phase mole fractions fails to converge.