Skip to content

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-gcmc remains 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

P(N)∝zNN!e−βU(N),

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,

Pins=min[1,e−βΔUPVkBT(N+1)].

For deletion,

Pdel=min[1,e−βΔUNkBTPV].

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

Uij(r)=4ϵij[(σijr)12−(σijr)6],

with Lorentz–Berthelot mixing

σij=σi+σj2,ϵij=ϵiϵj.

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:

switchingshift_ljPotential inside the cutoff
falsefalseplain truncated U(r)
falsetrueshifted U(r) − U(r_cut), the RASPA "shifted" convention
truefalseswitched U(r) · S(r) with S tapering from 0.9 r_cut

API ​

rust
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 ​

TypeMeaning
GcmcFrameworkUnit cell plus host atoms with epsilon, sigma and optional charge
GuestModelSingle-site or multi-site guest, with optional charges
GcmcConfigTemperature, pressure points, move counts, seed, cutoff, tail correction

Output ​

TypeMeaning
GuestMoleculeCentre plus rotation matrix for a multi-site guest
AdsorptionPointPressure, fugacity, mean loading, standard error, sample count
AdsorptionIsothermTemperature, 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

Eel=12∑i≠jqiqjerfc(αrij)rij+2πV∑k≠0e−k2/(4α2)k2|S(k)|2−απ∑iqi2−π2Vα2(∑iqi)2.

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

f=ϕp,

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

Utail=16πϵ[σ129rc9−σ63rc3].

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:

rust
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 ​

GateObservableResult
Lennard-Jones minimumU(2^(1/6)σ) = -ε< 1e-9 kcal/mol
Ideal gasMean loading vs PV/(kBT)within 5 % on a 10 Å box, 1 bar, 250k moves
Peng-Robinsonphi(1 bar) and phi(50 bar) for CO2ideal limit and monotone falloff
Tail integralAnalytic correction vs numerical integral< 0.2 %
Attractive hostLoading vs empty frameworkhost ≥ empty
Ewald pairTwo opposite charges, 20 Å cellmatches direct Coulomb within 1 %
Multi-siteCO2-style three-site modeltotal charge and site count
Invalid inputNegative epsilon, zero cell volumerejected
RASPA CO2/Cu-BTC323 K, 10 bar, 160k moves, Ewald k_max=4113.67 vs 116 mol/uc (2.0 %, F116)
RASPA CO2/Cu-BTC primitive323 K, 10 bar, 40k moves, EwaldHost26.31 vs 26.12 mol/uc (0.7 %, F120)
RASPA CO2/IRMOF-1 (MOF-5)298 K, 1 bar, Ewald k_max=8 + shifted LJ5.78 vs 6.02 mol/uc (3.9 %, F131)
RASPA N2/Cu-BTC (HKUST-1)298 K, 10 bar, Ewald k_max=4 + shifted LJ5.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 ​

SurfaceEntry point
CLIsci-form gcmc '<framework-json>' '<guest-json>' '<config-json>'
WASMcompute_gcmc_isotherm(framework_json, guest_json, config_json)
Pythoncompute_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 ​

  1. Add Ewald parameter auto-tuning and convergence diagnostics.
  2. Add internal degrees of freedom for multi-site guests.
  3. Add automatic UFF/MMFF94 typing for framework atoms.
  4. Add correlation-aware block averaging.
  5. Benchmark CO2/N2 isotherms against RASPA and experiment.
  6. Add a Curie-Weiss/fugacity table path for gases without critical constants.

Released under the MIT License.