/atomistic-skills:mat-grand-canonical-mcfrom Atomistic Skills
Run Grand Canonical Monte Carlo (GCMC) simulations with cluster expansion models to map composition-temperature phase diagrams via chemical potential sweeps.
Ships in Atomistic Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
To perform Grand Canonical Monte Carlo (GCMC) simulations using cluster expansion models to study composition-dependent thermodynamics and generate temperature-composition (T-x) phase diagrams. GCMC allows the system composition to vary by controlling the chemical potential ($\mu$) instead of fixing composition directly.
In the canonical ensemble (fixed N, V, T), Monte Carlo simulations explore configurational space at a fixed composition. In contrast, the grand canonical (or semigrand canonical) ensemble allows composition to fluctuate in response to specified chemical potentials. This is particularly useful for:
For binary alloys (e.g., Cu-Ag), we typically control the chemical potential difference Δμ = μ_A - μ_B by setting one species to μ = 0 and varying the other.
Start with a trained cluster expansion model. You can train one using the ml-cluster-expansion skill or use an existing model.
# Load the cluster expansion
from smol.cofe import ClusterExpansion
ce = ClusterExpansion.load("path/to/cluster_expansion.json")
print(f"Loaded CE with {len(ce.cluster_subspace)} clusters")
Use the run_gcmc_sweep.py script to perform systematic sweeps of chemical potential at different temperatures.
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/run_gcmc_sweep.py \
--ce_file cluster_expansion.json \
--supercell 3 3 3 \
--temperatures 400 600 800 1000 \
--mu_min -0.4 \
--mu_max 0.4 \
--num_mu_points 20 \
--steps 50000 \
--equilibration_steps 10000 \
--element Ag \
--output_dir gcmc_results/
Key Parameters:
--ce_file: Path to the trained cluster expansion JSON file--supercell: Supercell size (e.g., 3 3 3 for a 3×3×3 supercell)--temperatures: List of temperatures (K) to simulate--mu_min, --mu_max: Chemical potential range (eV)--num_mu_points: Number of chemical potential points to sample--steps: Number of MC steps per simulation--equilibration_steps: Initial burn-in steps (discarded)--element: Species to control (the other is set to μ=0)--output_dir: Directory to save resultsOutput:
gcmc_results/results_summary.json: Composition and energy datagcmc_results/T{temp}_mu{mu:.3f}.h5: Trajectory files (HDF5)gcmc_results/T{temp}_mu{mu:.3f}_final.cif: Final structuresUse the analysis script to visualize the results and create phase diagrams.
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/analyze_gcmc_results.py \
--results_file gcmc_results/results_summary.json \
--output_dir gcmc_results/ \
--element Ag
Output:
mu_vs_composition.png: Chemical potential vs. composition at each temperaturephase_diagram.png: Temperature-composition (T-x) phase diagramenergy_vs_mu.png: Energy per atom vs. chemical potentialUsing the pre-trained Cu-Ag cluster expansion:
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/run_gcmc_sweep.py \
--ce_file ${CLAUDE_SKILL_DIR}/../ml-cluster-expansion/examples/CuAg_CE/cluster_expansion.json \
--supercell 4 4 4 \
--temperatures 300 400 500 600 700 800 900 1000 \
--mu_min -0.3 \
--mu_max 0.3 \
--num_mu_points 15 \
--steps 30000 \
--equilibration_steps 5000 \
--element Ag \
--output_dir ${CLAUDE_SKILL_DIR}/examples/CuAg/gcmc_results/
Then analyze:
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/analyze_gcmc_results.py \
--results_file ${CLAUDE_SKILL_DIR}/examples/CuAg/gcmc_results/results_summary.json \
--output_dir ${CLAUDE_SKILL_DIR}/examples/CuAg/ \
--element Ag
cpu environment with smol, pymatgen, matplotlib, and numpy.In the semigrand canonical ensemble for a binary alloy A-B:
The probability of a configuration depends on: $$P(\sigma) \propto \exp\left[-\frac{E(\sigma) - \Delta\mu \cdot N_A}{k_B T}\right]$$
where $N_A$ is the number of A atoms in configuration $\sigma$.
At equilibrium, the composition $x_A$ (mole fraction of A) is related to Δμ through the free energy: $$\Delta\mu = \frac{\partial F}{\partial N_A}\bigg|_{T,V}$$
By sweeping Δμ, we can map out the entire compositional range and identify:
Author: Bowen Deng Contact: GitHub @learningmatter-mit
examples/AgPd/README.md (opens in a new tab)examples/AgPd/mu_vs_composition.png (opens in a new tab)examples/AgPd/phase_diagram.png (opens in a new tab)examples/CuAg/README.md (opens in a new tab)examples/CuAg/gcmc_sweep_analysis.png (opens in a new tab)scripts/analyze_gcmc_results.py (opens in a new tab)scripts/run_gcmc_sweep.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub learningmatter-mit/atomisticskills --plugin atomistic-skills133 skills in this plugin
/chem-bond-dissociationCalculate homolytic and heterolytic bond dissociation energies (BDEs) for all single bonds in a molecule using MLIPs with RDKit fragmentation./chem-conformer-searchGenerate molecular conformers with RDKit ETKDG, relax with MLIPs, and rank by energy with Boltzmann weighting./chem-db-mofQuery multiple MOF databases (QMOF via MPContribs; ARC-MOF DB7/Majumdar et al. via Materials Cloud) and download CIF structures with optional element or identifier filters./chem-db-qmofQuery the Quantum MOF (QMOF) database via Materials Project's MPContribs platform for DFT-computed properties (bandgap) and optimized crystal structures of Metal-Organic Frameworks./chem-db-spectraSearch and download experimental InfraRed (IR), Mass spectra, and UV-Vis spectra data (JCAMP-DX format) for molecules./chem-dft-orca-advanced-calculationWrite and run custom ORCA input files for advanced electronic structure methods or settings not available through the SCINE wrapper, including multi-reference methods, excited states, relativistic effects, advanced SCF, NMR/EPR, and more.Other plugins' skills for the same job