feat(qe): Add support for ibrav > 1 in Quantum Espresso SCF parser
This PR resolves the long-standing limitation where dpdata would raise RuntimeError("ibrav > 1 not supported yet.") when parsing Quantum Espresso SCF files with Bravais lattice types other than simple cubic (ibrav=1) or free lattice (ibrav=0).
Problem
Users encountered errors when trying to load QE files with common lattice types like:
import dpdata
dataset = dpdata.LabeledSystem('./scf0.out', fmt='qe/pw/scf')
# RuntimeError: ibrav > 1 not supported yet.
This occurred for any ibrav value > 1, including commonly used types like ibrav=8 (simple orthorhombic).
Solution
Extended the get_cell() function in dpdata/qe/scf.py to support all standard Quantum Espresso lattice types (ibrav 1-14):
- ibrav=1: Simple cubic (existing support maintained)
- ibrav=2,3,-3: Face-centered, body-centered, and reverse body-centered cubic
- ibrav=4: Hexagonal and trigonal
- ibrav=6,7: Simple and body-centered tetragonal
- ibrav=8,9,-9,10,11: Various orthorhombic lattices
- ibrav=12,-12,13,-13: Monoclinic lattices
- ibrav=14: Triclinic
The implementation:
- Parses both standard parameters (a, b, c, cosab, cosac, cosbc) and alternative celldm notation
- Validates required parameters for each lattice type
- Generates correct lattice vectors according to QE specifications
- Maintains full backward compatibility with existing ibrav=0 and ibrav=1 workflows
Testing
Added comprehensive test suite covering:
- All major ibrav types with parameter validation
- Mixed parameter formats (standard + celldm)
- Error handling for missing required parameters
- Backward compatibility verification
Example usage that now works:
# Simple orthorhombic lattice (ibrav=8)
dataset = dpdata.LabeledSystem('./scf0.out', fmt='qe/pw/scf')
print(dataset.data['cells'][0]) # [[a, 0, 0], [0, b, 0], [0, 0, c]]
Fixes #408.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.