API reference¶
The functions below are available directly from the adsorpqc package.
Overall assessment¶
adsorpqc.assess_adsorption_quality(metadata, gcmc_loading_series=None, gcmc_energy_series=None, pressure_isotherm=None, loading_isotherm=None, gas_mixture=None, isotherm_b_pressure=None, isotherm_b_loading=None, temperature_k=298.15, gcmc_molecule_series=None, energy_unit='kJ/mol')
¶
Assesses the quality, statistical stationarity, and thermodynamic consistency of adsorption simulations and isotherms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metadata
|
dict
|
Material name, framework, adsorbate, simulation engine. |
required |
gcmc_loading_series
|
ndarray
|
Raw timeseries of loading per cycle. |
None
|
gcmc_energy_series
|
ndarray
|
Raw timeseries of energy per cycle. |
None
|
pressure_isotherm
|
ndarray
|
Pressure grid. |
None
|
loading_isotherm
|
ndarray
|
Equilibrium loading values across pressures. |
None
|
temperature_k
|
float
|
Temperature in Kelvin. |
298.15
|
gcmc_molecule_series
|
ndarray
|
Number of adsorbed molecules in the simulation box per sample, aligned with gcmc_energy_series. Required for the fluctuation estimate of q_st (a loading in mol/kg would scale the result). |
None
|
energy_unit
|
(kJ / mol, K)
|
Unit of gcmc_energy_series (RASPA writes U/k_B in K). |
"kJ/mol"
|
Returns:
| Name | Type | Description |
|---|---|---|
report |
AdsorptionValidationReport
|
Complete certification report. |
Burn-in and drift¶
adsorpqc.detect_gcmc_burnin(loading_series, cycle_indices=None, step_search=10, warn_drift_pct=3.0, fail_drift_pct=8.0)
¶
Automatically detects the optimal GCMC burn-in / equilibration cutoff and verifies production stationarity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loading_series
|
ndarray
|
Array of adsorbate loadings per cycle (e.g. molecules/unit cell, mol/kg). |
required |
cycle_indices
|
ndarray
|
Cycle numbers. |
None
|
step_search
|
int
|
Step increment for candidate cutoff search. |
10
|
Returns:
| Name | Type | Description |
|---|---|---|
result |
GCMCBurninResult
|
Detailed burn-in, effective sampling, drift, and quality certification. |
adsorpqc.assess_loading_drift(production_series, warn_threshold_pct=3.0, fail_threshold_pct=8.0, z_warn=2.0, z_fail=3.0)
¶
Drift between the first and last 20% of the production phase, judged both statistically and in magnitude.
The difference of the two segment means is compared with its standard error. The segment standard errors use the scatter and the statistical inefficiency of the linearly detrended series, so that a genuine trend is not absorbed into the noise estimate and pure noise in a short or low-loading run is not mistaken for drift. A drift is reported only when it is both significant (z above z_warn / z_fail) and large relative to the mean (above the percentage thresholds).
Returns:
| Type | Description |
|---|---|
(drift_pct, mean_first_20, mean_last_20, status, message)
|
|
Isotherm models¶
adsorpqc.fit_all_isotherm_models(pressure, loading)
¶
Fits the Langmuir, dual-site Langmuir, Sips and Toth models and selects the one with the lowest AICc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pressure
|
ndarray
|
Equilibrium pressure points (bar, Pa, kPa). |
required |
loading
|
ndarray
|
Adsorbate loading values (mol/kg, mg/g, molec/uc). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
result |
dict
|
All fitted models, metrics, and identified optimal model. |
Energetics¶
adsorpqc.calculate_henry_constant(pressure, loading, n_points_linear=4, max_fraction_of_max_loading=0.15)
¶
Henry adsorption constant K_H = lim_{P->0} q/P from the low-pressure part of an isotherm.
q/P is regressed linearly on q (first-order virial / Langmuir expansion, q/P = K_H - b q + ...) using the lowest-pressure points with q below max_fraction_of_max_loading of the largest loading (at least 2, at most n_points_linear unless more points satisfy the loading criterion); K_H is the intercept. This removes the downward bias of a straight line q = K_H P through points that are already curving.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pressure
|
ndarray
|
Isotherm (any consistent units; K_H is returned in loading/pressure units). |
required |
loading
|
ndarray
|
Isotherm (any consistent units; K_H is returned in loading/pressure units). |
required |
n_points_linear
|
int
|
Minimum number of low-pressure points to use when available. |
4
|
max_fraction_of_max_loading
|
float
|
Points with q above this fraction of max(q) are excluded from the extrapolation. |
0.15
|
Returns:
| Name | Type | Description |
|---|---|---|
result |
dict
|
henry_constant, r_squared of the q/P vs q regression, n_points_used, slope_b. |
adsorpqc.calculate_isosteric_heat(energy_series=None, loading_series=None, temperature_k=298.15, energy_unit='kJ/mol')
¶
q_st from a GCMC (U, N) series; NaN when no series is available.
IAST¶
adsorpqc.calculate_iast_selectivity(isotherm_a_p, isotherm_a_q, isotherm_b_p, isotherm_b_q, gas_mole_fraction_a=0.5, gas_mole_fraction_b=0.5, total_pressure=1.0, n_bootstrap=500, model='best', random_state=42)
¶
Binary IAST selectivity S_A/B = (x_A/x_B)/(y_A/y_B) at the given total pressure and composition.
Each single-component isotherm is fitted (model: "best" = lowest AICc among Langmuir, dual-site Langmuir, Sips and Toth, or one of those names) and IAST is solved with the fitted functions. The 95% interval comes from resampling the isotherm points of each component and repeating the fit and the IAST solution (pairs bootstrap); it reflects the fit uncertainty only.
Returns:
| Type | Description |
|---|---|
dict with selectivity_a_b, ci_lower_95, ci_upper_95, x_a, loadings of both components in the
|
|
mixture, the models used, and the Henry-limit selectivity for comparison.
|
|
Parsers¶
adsorpqc.parsers.parse_isotherm_csv(filepath)
¶
Parses a CSV/TSV file containing adsorption isotherm data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str
|
Path to tabular file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
data |
dict
|
Pressure array, loading array, detected units, and column mappings. |