| name | ggen |
| description | Generate candidate crystal structures from a chemical formula and assess their stability using ggen. Use when you need trial structures for a composition with no known experimental structure, or want stability-ranked polymorph candidates before running MD/DFT. |
ggen Skill
Crystal structure generation and stability assessment using ggen.
Validated: 2026-01-24 - API tested and working.
When to Use This Skill
Use ggen when you need to:
- Generate candidate crystal structures from a chemical formula
- Explore a chemical space (e.g., "find structures in Fe-Mn-Si")
- Assess thermodynamic stability (convex hull analysis)
- Check dynamical stability (phonon calculations)
Use Materials Project / materials-database skill when:
- You need KNOWN structures (already in databases)
- You want experimental data
ggen generates NEW candidate structures. Materials databases provide KNOWN structures.
What ggen Provides
- Structure generation - Creates crystal structures using PyXtal
- Space group exploration - Systematically tries different symmetries
- ML relaxation - Optimizes structures with ORB potentials
- Convex hull - Identifies thermodynamically stable phases
- Phonon checks - Validates dynamical stability
Installation
IMPORTANT: Install from GitHub, NOT PyPI:
pip install git+https://github.com/ourofoundation/ggen.git
WARNING: pip install ggen installs a different package (grid mesh generator).
Requires GPU for efficient relaxation.
Verification
python -c "from ggen import GGen; print('ggen:', GGen)"
Model Cache
ORB models cached in: ~/.cache/science-agent/ggen/
Showcase Demo
See: showcases/ggen-integration/workspace/demo_ggen.py
Core Concepts
ChemistryExplorer
High-level systematic exploration:
from ggen import ChemistryExplorer
explorer = ChemistryExplorer(output_dir="./runs")
result = explorer.explore(
chemical_system="Li-P-S",
max_atoms=20,
num_trials=25,
compute_phonons=False
)
GGen
Lower-level structure generation:
from ggen import GGen
ggen = GGen()
result = ggen.generate_crystal(
formula="BaTiO3",
num_trials=10,
optimize_geometry=True
)
print(f"Best: {result['final_space_group_symbol']}, E={result['best_crystal_energy']:.4f} eV")
structure = result['structure']
Common Patterns
Explore a Chemical System
from ggen import ChemistryExplorer
explorer = ChemistryExplorer(output_dir="./ggen_runs")
result = explorer.explore(
chemical_system="Li-Co-O",
max_atoms=24,
num_trials=30,
min_fraction={"Li": 0.2},
compute_phonons=True
)
print(f"Generated {result.total_structures} structures")
print(f"On-hull phases: {result.on_hull_count}")
for structure in result.stable_structures:
print(f"{structure.formula}: {structure.energy_above_hull:.3f} eV/atom")
CLI Usage
python -m ggen.scripts.explore Fe-Mn-Si --max-atoms 24 --num-trials 25
python -m ggen.scripts.phonons --system Li-P-S --e-above-hull 0.05
python -m ggen.scripts.export Li-Co-O -n 10
python -m ggen.scripts.report Li-P-S
Get Structures for Further Analysis
from ggen import ChemistryExplorer
explorer = ChemistryExplorer(output_dir="./runs")
result = explorer.explore(chemical_system="Li-P-S", max_atoms=16)
for structure in result.get_structures_near_hull(e_above_hull=0.05):
cif_path = structure.to_cif(f"{structure.formula}.cif")
Integration with Other Skills
ggen generates structures. Other skills analyze them:
ggen (structure generation)
│
├── mlip-simulation → Quick ML potential checks
├── torch-sim → High-throughput screening
├── lammps-simulation → Classical MD
├── quantum-espresso → DFT validation
└── data-analysis → Property analysis
Example Workflow
from ggen import ChemistryExplorer
explorer = ChemistryExplorer()
result = explorer.explore("Li-P-S", max_atoms=20)
candidates = result.get_structures_near_hull(e_above_hull=0.1)
from torch_sim import integrate
from torch_sim.models import MACEModel
model = MACEModel.from_pretrained("mace-mp-0-medium")
for candidate in candidates:
structure = candidate.to_pymatgen()
Key Parameters
| Parameter | Default | Description |
|---|
max_atoms | 20 | Maximum atoms per unit cell |
min_atoms | 2 | Minimum atoms per unit cell |
num_trials | 15 | Generation attempts per stoichiometry |
max_stoichiometries | 100 | Limit search space |
compute_phonons | False | Run phonon stability checks |
min_fraction | {} | Minimum element fractions |
preserve_symmetry | True | Maintain space group during relaxation |
Understanding Results
Convex Hull
- On hull (e_above_hull = 0): Thermodynamically stable
- Near hull (< 0.05 eV/atom): Potentially synthesizable
- Far from hull (> 0.1 eV/atom): Likely unstable
Dynamical Stability
- No imaginary phonons: Dynamically stable
- Imaginary modes present: Structure may distort or decompose
Limitations
- Generation is stochastic (results vary between runs)
- Default 15 trials may be insufficient for complex systems
- Phonon calculations are expensive
- ORB potentials have their own accuracy limits
Performance Tips
- Start with few trials - Increase if needed
- Skip phonons initially - Add later for promising candidates
- Use GPU - Much faster relaxation
- Constrain composition - Use
min_fraction / max_fraction
References
See Also
materials-database skill - Query known structures
mlip-simulation skill - ML potential calculations
torch-sim skill - High-throughput screening