Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 29, 2025

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:

  1. Parses both standard parameters (a, b, c, cosab, cosac, cosbc) and alternative celldm notation
  2. Validates required parameters for each lattice type
  3. Generates correct lattice vectors according to QE specifications
  4. 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.

@Copilot Copilot AI changed the title [WIP] ibrav > 1 not supported yet. feat(qe): Add support for ibrav > 1 in Quantum Espresso SCF parser Aug 29, 2025
@Copilot Copilot AI requested a review from njzjz August 29, 2025 14:11
Copilot finished work on behalf of njzjz August 29, 2025 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ibrav > 1 not supported yet.
2 participants