Random Structure Search (AIRSS-Style)
Goal
To perform random structure searching (RSS) for a given chemical composition — the approach pioneered by AIRSS (Ab Initio Random Structure Searching, Pickard & Needs 2011). Random crystal structures are generated with sensible geometric constraints, then relaxed with an MLIP to identify low-energy candidates.
[!TIP]
This method is complementary to ionic substitution and generative models like MatterGen and DiffCSP++. RSS explores the full potential energy surface without structural bias.
Instructions
Generate random structures for the target composition:
# Env: base-agent
python .agents/skills/mat-random-structure-search/scripts/generate_random_structures.py \
--composition NaCl \
--num_structures 100 \
--output_dir random_NaCl/
The script will:
- Sample random space groups from a list of common inorganic crystal space groups
- Generate random lattice parameters consistent with each crystal system
- Place atoms at random fractional coordinates
- Filter structures for minimum interatomic distances
- Save CIF files and a
generation_manifest.json
Optional parameters:
--spacegroups 225,166,62,14 — restrict to specific space groups
--volume_min 0.6 --volume_max 1.8 — control volume randomization range
--seed 42 — set random seed for reproducibility
Relax all structures with an MLIP:
mcp_mace_relax_structure(
structure_data="random_NaCl/",
relax_cell=True,
fmax=0.02,
steps=500,
output_dir="relaxed_NaCl/"
)
Or with MatGL/FairChem — use the same MLIP consistently.
Rank by energy: The lowest-energy relaxed structures are the most promising candidates. Check for duplicate structures using pymatgen's StructureMatcher.
Validate top candidates: Compute stability (E_hull) for the best candidates to assess thermodynamic viability.
Examples
Example 1: Search for NaCl ground state
# Env: base-agent
python .agents/skills/mat-random-structure-search/scripts/generate_random_structures.py \
--composition NaCl \
--num_structures 100 \
--seed 42 \
--output_dir random_NaCl/
Expected: Rocksalt (SG 225) should emerge as the lowest-energy structure after MLIP relaxation.
Example 2: Search for Li₂ZrCl₆ polymorphs
# Env: base-agent
python .agents/skills/mat-random-structure-search/scripts/generate_random_structures.py \
--composition Li2ZrCl6 \
--num_structures 200 \
--spacegroups 12,14,62,148,166,167 \
--output_dir random_Li2ZrCl6/
Constraints
- Not a DFT method: Unlike true AIRSS, this skill uses MLIPs for relaxation. The accuracy depends on the MLIP's quality for the target chemistry.
- No symmetry enforcement: Generated structures have atoms at random positions (P1). Symmetry emerges only after relaxation.
- Volume range: The default volume range (0.6–1.8× estimated) covers most reasonable crystal packings. Extreme chemistries (e.g., heavy elements, molecular crystals) may need adjusted ranges.
- Scalability: Generation is fast (~100 structures/second), but MLIP relaxation is the bottleneck. For large-scale searches, use batch relaxation via MCP tools.
- Duplicate removal: After relaxation, use
StructureMatcher to remove duplicate structures that converge to the same minimum.
References
Author: Bowen Deng
Contact: GitHub @learningmatter-mit
1---2name: mat-random-structure-search3description: Generate random crystal structures for a given composition (AIRSS-style) and relax with MLIPs to find low-energy candidates.4---56# Random Structure Search (AIRSS-Style)78## Goal910To perform random structure searching (RSS) for a given chemical composition — the approach pioneered by AIRSS (Ab Initio Random Structure Searching, Pickard & Needs 2011). Random crystal structures are generated with sensible geometric constraints, then relaxed with an MLIP to identify low-energy candidates.1112> [!TIP]13> This method is complementary to [ionic substitution](../mat-ionic-substitution/SKILL.md) and generative models like [MatterGen](../ml-generative-mattergen/SKILL.md) and [DiffCSP++](../ml-generative-diffcsp/SKILL.md). RSS explores the full potential energy surface without structural bias.1415## Instructions16171. **Generate random structures** for the target composition:18 ```bash19 # Env: base-agent20 python .agents/skills/mat-random-structure-search/scripts/generate_random_structures.py \21 --composition NaCl \22 --num_structures 100 \23 --output_dir random_NaCl/24 ```2526 The script will:27 - Sample random space groups from a list of common inorganic crystal space groups28 - Generate random lattice parameters consistent with each crystal system29 - Place atoms at random fractional coordinates30 - Filter structures for minimum interatomic distances31 - Save CIF files and a `generation_manifest.json`3233 **Optional parameters:**34 - `--spacegroups 225,166,62,14` — restrict to specific space groups35 - `--volume_min 0.6 --volume_max 1.8` — control volume randomization range36 - `--seed 42` — set random seed for reproducibility37382. **Relax all structures** with an MLIP:39 ```bash40 mcp_mace_relax_structure(41 structure_data="random_NaCl/",42 relax_cell=True,43 fmax=0.02,44 steps=500,45 output_dir="relaxed_NaCl/"46 )47 ```4849 Or with MatGL/FairChem — use the same MLIP consistently.50513. **Rank by energy**: The lowest-energy relaxed structures are the most promising candidates. Check for duplicate structures using pymatgen's `StructureMatcher`.52534. **Validate top candidates**: Compute [stability (E_hull)](../mat-stability/SKILL.md) for the best candidates to assess thermodynamic viability.5455## Examples5657### Example 1: Search for NaCl ground state58```bash59# Env: base-agent60python .agents/skills/mat-random-structure-search/scripts/generate_random_structures.py \61 --composition NaCl \62 --num_structures 100 \63 --seed 42 \64 --output_dir random_NaCl/65```66Expected: Rocksalt (SG 225) should emerge as the lowest-energy structure after MLIP relaxation.6768### Example 2: Search for Li₂ZrCl₆ polymorphs69```bash70# Env: base-agent71python .agents/skills/mat-random-structure-search/scripts/generate_random_structures.py \72 --composition Li2ZrCl6 \73 --num_structures 200 \74 --spacegroups 12,14,62,148,166,167 \75 --output_dir random_Li2ZrCl6/76```7778## Constraints7980- **Not a DFT method**: Unlike true AIRSS, this skill uses MLIPs for relaxation. The accuracy depends on the MLIP's quality for the target chemistry.81- **No symmetry enforcement**: Generated structures have atoms at random positions (P1). Symmetry emerges only after relaxation.82- **Volume range**: The default volume range (0.6–1.8× estimated) covers most reasonable crystal packings. Extreme chemistries (e.g., heavy elements, molecular crystals) may need adjusted ranges.83- **Scalability**: Generation is fast (~100 structures/second), but MLIP relaxation is the bottleneck. For large-scale searches, use batch relaxation via MCP tools.84- **Duplicate removal**: After relaxation, use `StructureMatcher` to remove duplicate structures that converge to the same minimum.8586## References8788- Pickard, C. J., & Needs, R. J. (2011). Ab initio random structure searching. *Journal of Physics: Condensed Matter*, 23(5), 053201. [DOI: 10.1088/0953-8984/23/5/053201](https://doi.org/10.1088/0953-8984/23/5/053201)8990---9192**Author:** Bowen Deng93**Contact:** [GitHub @learningmatter-mit](https://github.com/learningmatter-mit)