DiffCSP++ Crystal Structure Generation

SkillDev tools

Generate crystal structures with exact composition control using DiffCSP++ (space group + Wyckoff positions), or unconditionally from trained distributions.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the DiffCSP++ Crystal Structure Generation skill

What this skill tells your AI

The instructions your AI receives, as published by learningmatter-mit/atomisticskills in .agents/skills/ml-generative-diffcsp/SKILL.md and read by ahel’s review.

Goal

Generate novel crystal structures using DiffCSP++ (ICLR 2024), a diffusion model that leverages space group symmetry constraints for crystal structure prediction (CSP) and ab initio generation.

1. Prerequisites

[!IMPORTANT] GPU Required: DiffCSP++ inference is significantly faster on GPU.

  • The diffcsp-agent conda environment must be installed.
  • DiffCSP++ repo cloned to /home/bdeng/projects/DiffCSP-PP.
  • Pre-trained checkpoints downloaded to checkpoints/ directory.

2. Available Models

ModelTypeDescription
mp_cspCSPMaterials Project — composition-constrained generation
mp_genGenMaterials Project — unconditional generation
perov_cspCSPPerovskite — composition-constrained generation
perov_genGenPerovskite — unconditional generation
carbon_genGenCarbon — unconditional generation
mpts_cspCSPMPTS-52 — composition-constrained generation

3. Usage Modes

Mode 1: Single Composition via MCP Tool (Recommended)

Generate structures with exact composition using the generate_structures_with_symmetry MCP tool:

mcp_diffcsp_generate_structures_with_symmetry(
    spacegroup=58,                        # Space group number (1-230)
    wyckoff_letters="2a,2d,4g",           # Wyckoff positions (comma-separated or shorthand "adg")
    atom_types="Mn,Li,O",                 # Element per Wyckoff position
    model_name="mp_csp",                  # CSP model
    num_samples=5,                        # Number of structures to generate
    step_lr=1e-5,                         # Langevin step size
    output_dir="research/my_project"
)

Mode 2: Batch Generation from JSON File

Generate multiple structures from a JSON specification file. This is useful when you have many different compositions to generate at once.

JSON format (see examples/example.json):

[
    {"spacegroup_number": 58, "wyckoff_letters": ["2a","2d","4g"], "atom_types": ["Mn","Li","O"]},
    {"spacegroup_number": 194, "wyckoff_letters": "abff", "atom_types": ["Tm","Tm","Ni","As"]}
]

Run the batch generation script:

# Env: diffcsp-agent
python .agents/skills/ml-generative-diffcsp/scripts/batch_generate.py \
    --json_file .agents/skills/ml-generative-diffcsp/examples/example.json \
    --model mp_csp \
    --output_dir diffcsp_batch_output \
    --step_lr 1e-5

Mode 3: Ab Initio (Unconditional) Generation

Generate structures from the training distribution without specifying composition. Requires a generation model (mp_gen, perov_gen, or carbon_gen).

# Env: diffcsp-agent
python .agents/skills/ml-generative-diffcsp/scripts/unconditional_generate.py \
    --model mp_gen \
    --num_structures 100 \
    --output_dir diffcsp_gen_output \
    --step_lr 5e-6

4. Parameters

ParameterDefaultDescription
spacegroupSpace group number (1-230)
wyckoff_lettersWyckoff positions (e.g., "2a,2d,4g" or shorthand "adg")
atom_typesElement for each Wyckoff position (e.g., "Mn,Li,O")
model_namemp_cspPre-trained model name
num_samples1Number of structures per composition
step_lr1e-5Langevin dynamics step size
batch_size128Batch size for parallel generation

5. Output Files

  • structure_XXXX.cif: Generated crystal structure files (pymatgen CIF format)
  • generation_metadata.json: Generation parameters and statistics

6. Constraints

[!WARNING] Space Group Knowledge Required: You need to know the space group number and Wyckoff positions for your target composition. Use ICSD, Materials Project, or pyxtal to find these.

[!NOTE] Wyckoff Notation: Positions can be given as full labels ("2a,2d,4g") or shorthand letters ("adg"). The number prefix is the site multiplicity — it's automatically determined from the space group.

  • Environments: All scripts require the diffcsp-agent conda environment.
  • GPU: A CUDA GPU is recommended for reasonable generation speed.
  • CSP vs Gen models: CSP models require atom_types; Gen models can generate without them.

7. Workflow Integration

DiffCSP++ works well in combination with:

  • Structure relaxation: Use MLIP tools (MACE, FairChem, MatGL) to optimize generated structures
  • Stability analysis: Use mat-stability to calculate E_hull
  • Comparison: Generate structures with DiffCSP++, ADiT, and MatterGen for diversity

Author: Bowen Deng Contact: GitHub @learningmatter-mit

Signals

GitHub stars
164
Forks
24
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
ml-generative-diffcsp
Source
github.com/learningmatter-mit/atomisticskills