/atomistic-skills:ml-cluster-expansionfrom Atomistic Skills
Builds and refines a Cluster Expansion model for disordered materials using an iterative workflow with MCP tools, MLIP labeling, and Monte Carlo sampling.
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.
[!NOTE] Steps written
server.toolare MCP tool calls:smol.train_cluster_expansionis thetrain_cluster_expansiontool of thesmolserver (mcp__smol__train_cluster_expansion, ormcp__plugin_atomistic-skills_smol__train_cluster_expansionwhen installed as a plugin). Without a connected server, run the same tools from the shell. Tools named in one command share a process, so a model loaded byload_modelstays loaded:${CLAUDE_SKILL_DIR}/../../venv/run cpu python -m src.mcp_server.cli smol train_cluster_expansion key=value run_monte_carlo key=value ${CLAUDE_SKILL_DIR}/../../venv/run mlip python -m src.mcp_server.cli mace load_model key=value relax_structure key=value
To automatically build and refine a Cluster Expansion (CE) model for a disordered material system using an Agent-driven iterative workflow that leverages MCP tools for efficient training, sampling, and labeling.
smol.train_cluster_expansion.smol.run_monte_carlo to explore configuration space.Use prepare_disordered.py to handle symmetry refinement and disorder creation. It is highly recommended to save the primordial structure as a JSON file to preserve exact occupancy and species information, avoiding "unrecognized species" errors during matching.
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/prepare_disordered.py \
input_structure.cif \
Li \
0.5 \
-o primordial.cif
Generate an initial set of structures using systematic enumeration and D-optimality via the MCP tool. It is recommended to generate around 1000 structures to ensure high coverage of the configuration space.
# MCP Tool: smol.sample_ordered_structures
result = smol.sample_ordered_structures(
disordered_structure="primordial.cif",
cutoffs={2: 5.0, 3: 4.0},
num_structures=1000,
target_num_sites=32,
output_dir="./ce_project/iter_0/to_label"
)
[!NOTE] Training Workflow: You can perform a Simple Training by only using the initially
sample_ordered_structuresset. This is often sufficient for basic property predictions. For high-accuracy ground-state exploration, you should continue with the Active Learning loop (MC sampling and iterative refinement).
[!TIP] This tool works for arbitrary disorder, including multi-element alloys (e.g., Co-Ni-Cr) and multi-sublattice systems (e.g., (Li-Na)(Cl-Br)).
Use the appropriate MLIP MCP tool to relax the structures.
[!IMPORTANT] Fixed Cell: Always set
relax_cell=Falseduring MLIP relaxation for cluster expansion training. The cluster expansion model is built on a fixed lattice. Fixed Lattice: Ensure the supercell matrix used for enumeration/sampling matches your expectation.
Example (MACE):
mace.load_model(model_name="MACE-OMAT-0-small", device="cuda")
mace.relax_structure(
structure_data="./ce_project/iter_0/to_label",
fmax=0.02,
relax_cell=False,
output_dir="./ce_project/iter_0/results"
)
The smol.train_cluster_expansion tool can directly accept the directory containing relaxation results (from Step 3). It will automatically find and aggregate the training data.
result = smol.train_cluster_expansion(
disordered_structure="primordial.cif",
training_data="ce_project/iter_0/results",
cutoffs={2: 5.0, 3: 4.0},
ce_file="ce_project/cluster_expansion.json"
)
[!NOTE] Training Workflow: You can perform a Simple Training by only using the initially
sample_ordered_structuresset. This is often sufficient for basic property predictions. For high-accuracy ground-state exploration, you should continue with the Active Learning loop (MC sampling and iterative refinement).
In some scenarios, you may have pre-computed feature matrices and energies (e.g., from literature or external workflows). You can directly fit these without building a ClusterSubspace first, using the smol.fit_feature_matrix tool. This is also how you can utilize advanced techniques like Sparse Group Lasso (SGL).
# MCP Tool: smol.fit_feature_matrix
result = smol.fit_feature_matrix(
feature_matrix_path="fm.npy",
energies_path="e.npy",
groups_path="groups.npy", # Required for sgl
fit_method="sgl", # 'ls', 'lasso', 'ridge', or 'sgl'
alpha=0.002,
lambda_mixing=0.5,
test_size=0.2
)
[!TIP] Sparse Group Lasso (SGL) is highly recommended for complex, high-component systems as it naturally selects important cluster groups while maintaining sparsity. It requires a
groups.npyfile that assigns each feature column to a cluster orbit group.
mc_result = smol.run_monte_carlo(
supercell_matrix=[[2,0,0], [0,2,0], [0,0,2]],
temperature=2000,
steps=100000,
ce_file="./ce_project/cluster_expansion.json",
trajectory_file="./ce_project/iter_1/mc_trajectory.h5"
)
Extract structures from the trajectory. The skill script handles dimension squeeze for single-sample trajectories.
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/extract_mc_structures.py \
--trajectory_file ./ce_project/iter_1/mc_trajectory.h5 \
--cluster_expansion ./ce_project/cluster_expansion.json \
--output_dir ./ce_project/iter_1/to_label \
--num_structures 20 \
--strategy random
[!IMPORTANT] Loop Back: After extracting these new candidate structures, go back to Step 3 to relax and label them. Then, add these new results to your training set and repeat Step 4 to refine your Cluster Expansion.
[!IMPORTANT] Use Total Energy (Extensive Property) Training structures should include the total energy for the entire supercell (not per-atom energy). Smol automatically normalizes energies by the primitive cell size during training via
get_property_vector('energy', normalize=True).
Example: For a 32-atom supercell with total DFT energy of -160.0 eV:
{"structure": {...}, "energy": -160.0}{"structure": {...}, "energy": -5.0} (per-atom)Formation Energy: If you want to train on formation energies instead of total energies, calculate the formation energy for each structure first, then provide it as the total (extensive) energy value. Smol will still normalize by primitive cell size.
.cif for primordial structures. Ensure partial occupancies are correctly defined.sc_matrix explicitly in the training data JSON.relax_cell=False to maintain the cluster expansion mapping.Author: Bowen Deng Contact: GitHub @learningmatter-mit
examples/AgPd_DFT_CE/README.md (opens in a new tab)examples/CuAg_CE/README.md (opens in a new tab)examples/CuAg_CE/cluster_expansion.json (opens in a new tab)examples/pdptag_ternary_surface/README.md (opens in a new tab)examples/pdptag_ternary_surface/analyze_mc.py (opens in a new tab)examples/pdptag_ternary_surface/mc_trajectory_final.cif (opens in a new tab)examples/pdptag_ternary_surface/mc_trajectory_initial.cif (opens in a new tab)examples/pdptag_ternary_surface/parse_atat.py (opens in a new tab)examples/pdptag_ternary_surface/parse_primordial.py (opens in a new tab)examples/pdptag_ternary_surface/primordial.cif (opens in a new tab)scripts/extract_mc_structures.py (opens in a new tab)scripts/prepare_disordered.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
133 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.npx claudepluginhub learningmatter-mit/atomisticskills --plugin atomistic-skillsOther plugins' skills for the same job