GCMC adsorption in porous materials
The first v2.x materials workflow adds grand-canonical Monte Carlo (GCMC) adsorption on a rigid periodic framework. It answers the question the existing materials module could not answer: how much gas does a framework take up at a given pressure and temperature?
Status. Implemented for rigid Lennard-Jones frameworks with optional charges, Ewald electrostatics and multi-site guests. Framework flexibility and bonded MM terms remain follow-ups. See the v2.x roadmap.
Feature. Core since 2.1.0;
alpha-gcmcremains as an empty compatibility alias.
flowchart LR
A[Framework CIF/JSON] --> B[GcmcFramework]
C[Guest model + critical constants] --> B
B --> D[GCMC move loop]
D --> E[Insertion/deletion with PR fugacity]
D --> F[Translation/rotation]
E --> G[LJ + Ewald energy]
F --> G
G --> H[Metropolis acceptance]
H --> D
D --> I[Block samples]
I --> J[Isotherm + standard error]
Grand-canonical ensemble
In the grand-canonical ensemble the number of adsorbed molecules fluctuates. The probability of a configuration with N guests is proportional to
where z is the activity, U the potential energy and β = 1/(kBT). The insertion/deletion factors use the fugacity f = φ p. When the guest carries critical constants the code evaluates the Peng–Robinson fugacity coefficient φ; otherwise φ = 1 and the ideal-gas relation zV = fV/(k_BT) is recovered.
Insertion and deletion
For insertion,
For deletion,
The implementation also supports random translations. Every move is accepted with the Metropolis rule, and the framework is kept rigid.
Energy model
The host–guest and guest–guest interactions use the Lennard-Jones potential
with Lorentz–Berthelot mixing
Periodic boundaries use the existing UnitCell::minimum_image_distance, which searches the neighbouring lattice images for skewed cells. A spherical cutoff is applied to both host–guest and guest–guest pairs.
Three Lennard-Jones cutoff conventions are available:
switching | shift_lj | Potential inside the cutoff |
|---|---|---|
false | false | plain truncated U(r) |
false | true | shifted U(r) − U(r_cut), the RASPA "shifted" convention |
true | false | switched U(r) · S(r) with S tapering from 0.9 r_cut |
API
use sci_form::gcmc::{
GcmcConfig, GcmcFramework, GuestModel, LennardJonesAtom,
};
use sci_form::compute_gcmc_isotherm;
let framework = GcmcFramework {
cell: sci_form::materials::UnitCell::cubic(20.0),
atoms: vec![LennardJonesAtom {
position: [10.0, 10.0, 10.0],
epsilon_kcal_mol: 1.0,
sigma_angstrom: 3.0,
}],
};
let guest = GuestModel {
epsilon_kcal_mol: 0.2,
sigma_angstrom: 3.0,
};
let config = GcmcConfig {
temperature_k: 298.15,
pressures_bar: vec![0.1, 1.0, 10.0],
..GcmcConfig::default()
};
let isotherm = compute_gcmc_isotherm(&framework, &guest, &config)?;
for point in isotherm.points {
println!("{:.2} bar -> {:.3} molecules/cell", point.pressure_bar, point.mean_loading);
}Input
| Type | Meaning |
|---|---|
GcmcFramework | Unit cell plus host atoms with epsilon, sigma and optional charge |
GuestModel | Single-site or multi-site guest, with optional charges |
GcmcConfig | Temperature, pressure points, move counts, seed, cutoff, tail correction |
Output
| Type | Meaning |
|---|---|
GuestMolecule | Centre plus rotation matrix for a multi-site guest |
AdsorptionPoint | Pressure, fugacity, mean loading, standard error, sample count |
AdsorptionIsotherm | Temperature, guest model, points and notes |
Loading is molecules per unit cell. Divide by the cell volume to obtain a number density, or convert to mmol/g once the framework mass is known.
Charges and Ewald
LennardJonesAtom and GuestSite carry a point charge. When GcmcConfig::electrostatics is Ewald, the total electrostatic energy is
The last term is the neutralizing background for a non-neutral cell. The reciprocal sum uses the reciprocal lattice of the existing UnitCell. The Ewald parameters are alpha_angstrom_inv, k_max and real_cutoff_angstrom.
In the Ewald path the real-space erfc(αr)/r term is optionally tapered by switching. RASPA-style shifted Lennard-Jones potentials are selected with GcmcConfig::shift_lj.
For screening runs on large frameworks, GcmcElectrostatics::Cutoff replaces the reciprocal sum by a minimum-image real-space Coulomb sum with the GCMC cutoff. It is much faster but ignores the periodic reciprocal contribution; use it for exploration, and Ewald for a production isotherm.
Fugacity and tail corrections
When GuestModel carries critical_temperature_k, critical_pressure_bar and acentric_factor, the insertion/deletion activity uses the Peng-Robinson fugacity
instead of the ideal-gas pressure. This matters for CO2 above a few bar. If the critical constants are absent the coefficient is exactly one, preserving the ideal-gas test.
The analytic Lennard-Jones tail correction is enabled by GcmcConfig::tail_correction (default true). For a pair with mixed epsilon and sigma, the energy beyond the cutoff is
Host atoms contribute with density 1/V; each guest sees N-1 other guests. The correction is a continuum approximation and does not replace a converged cutoff.
Multi-site guests
A guest can define several interaction sites:
let co2 = GuestModel {
sites: vec![
GuestSite {
offset_angstrom: [-1.16, 0.0, 0.0],
epsilon_kcal_mol: 0.2,
sigma_angstrom: 3.0,
charge: -0.35,
},
GuestSite {
offset_angstrom: [0.0, 0.0, 0.0],
epsilon_kcal_mol: 0.1,
sigma_angstrom: 2.8,
charge: 0.70,
},
GuestSite {
offset_angstrom: [1.16, 0.0, 0.0],
epsilon_kcal_mol: 0.2,
sigma_angstrom: 3.0,
charge: -0.35,
},
],
epsilon_kcal_mol: 0.0,
sigma_angstrom: 1.0,
charge: 0.0,
};Each insertion samples a random centre and rotation. Translation moves can also rotate with probability rotation_probability. Host-guest and guest-guest interactions are summed over every site pair with Lorentz-Berthelot mixing.
Validation
| Gate | Observable | Result |
|---|---|---|
| Lennard-Jones minimum | U(2^(1/6)σ) = -ε | < 1e-9 kcal/mol |
| Ideal gas | Mean loading vs PV/(kBT) | within 5 % on a 10 Å box, 1 bar, 250k moves |
| Peng-Robinson | phi(1 bar) and phi(50 bar) for CO2 | ideal limit and monotone falloff |
| Tail integral | Analytic correction vs numerical integral | < 0.2 % |
| Attractive host | Loading vs empty framework | host ≥ empty |
| Ewald pair | Two opposite charges, 20 Å cell | matches direct Coulomb within 1 % |
| Multi-site | CO2-style three-site model | total charge and site count |
| Invalid input | Negative epsilon, zero cell volume | rejected |
| RASPA CO2/Cu-BTC | 323 K, 10 bar, 160k moves, Ewald k_max=4 | 113.67 vs 116 mol/uc (2.0 %, F116) |
| RASPA CO2/Cu-BTC primitive | 323 K, 10 bar, 40k moves, EwaldHost | 26.31 vs 26.12 mol/uc (0.7 %, F120) |
| RASPA CO2/IRMOF-1 (MOF-5) | 298 K, 1 bar, Ewald k_max=8 + shifted LJ | 5.78 vs 6.02 mol/uc (3.9 %, F131) |
| RASPA N2/Cu-BTC (HKUST-1) | 298 K, 10 bar, Ewald k_max=4 + shifted LJ | 5.59 vs 5.45 mol/cell (2.5 %, F132) |
Malformed input is reported as an input error: Python raises ValueError for empty pressure grids, non-positive temperature/steps/cutoff/max-guests/sample interval, probabilities outside [0,1], non-finite framework/guest parameters and zero/negative cell volume. WASM returns {"error": "..."}.
The ideal-gas test is a statistical check of the insertion/deletion factors and of the proposal probabilities. Insertion and deletion are proposed with equal probability even when the box is empty (a deletion is a no-op) or at max_guests (an insertion is a no-op); otherwise the boundaries break detailed balance and bias the loading by a factor of two at low coverage. The test uses a 10 Å empty box at 1 bar and 250k moves (mean loading 0.025 vs ideal 0.0241). The RASPA rows use the same rigid framework geometry, point charges and Lorentz-Berthelot mixing; the IRMOF-1 row also matches RASPA's shifted Lennard-Jones convention (shift_lj = true).
Bindings
| Surface | Entry point |
|---|---|
| CLI | sci-form gcmc '<framework-json>' '<guest-json>' '<config-json>' |
| WASM | compute_gcmc_isotherm(framework_json, guest_json, config_json) |
| Python | compute_gcmc_isotherm(framework_json, guest_json, config_json) |
The CLI prints the full JSON isotherm. The JSON types are the serialized GcmcFramework, GuestModel and GcmcConfig.
Limitations
- The framework is rigid; framework flexibility, swelling and bonded MM terms are not modelled.
- Charges are fixed and no polarization is included.
- Ewald uses a neutralizing background; a non-neutral framework is allowed but the physical interpretation of the background must be documented by the user.
- Multi-site guests are rigid; internal degrees of freedom and bonded terms are not sampled.
- The isotherm uses a spherical cutoff. The analytic Lennard-Jones tail correction is enabled by default (
tail_correction = true) but remains a continuum approximation; the cutoff must still be large enough for the tested density (default 12 Å). - Ewald parameters are not auto-tuned; the user must check convergence.
- The standard error is a simple block-independent estimate. Production work should use block averaging or a correlated-time estimator.
- The framework atom parameters must be supplied explicitly. Automatic UFF typing for MOF nodes is a follow-up.
- The implementation has no Widom insertion or volume move.
Next steps
- Add Ewald parameter auto-tuning and convergence diagnostics.
- Add internal degrees of freedom for multi-site guests.
- Add automatic UFF/MMFF94 typing for framework atoms.
- Add correlation-aware block averaging.
- Benchmark CO2/N2 isotherms against RASPA and experiment.
- Add a Curie-Weiss/fugacity table path for gases without critical constants.