Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 29, 2025

This PR addresses an issue where VASP machine learning AIMD simulations were not extracting the expected number of structures from OUTCAR files when using dpdata. The problem was caused by fragile cell data extraction logic that could fail with slight variations in OUTCAR format.

Problem

Users reported that when parsing ML AIMD OUTCAR files, dpdata would extract fewer structures than expected, particularly when encountering lines with "VOLUME and BASIS-vectors are now included." instead of the standard "VOLUME and BASIS-vectors are now :". The original parsing logic was not robust to format variations and could fail when cell data lines were malformed.

Solution

The fix improves the robustness of cell data extraction in the analyze_block function within dpdata/vasp/outcar.py:

  1. Enhanced error handling: Added try/catch blocks around float conversions to gracefully handle malformed cell data lines
  2. Improved parsing logic: More robust extraction of cell vectors that can handle various line format variations
  3. Better bounds checking: Added safety checks to prevent array access errors

Example

import dpdata

# Before: Could fail or miss frames with format variations
system = dpdata.LabeledSystem("OUTCAR.ml", fmt="vasp/outcar", ml=True)

# After: Robust parsing handles format variations gracefully
system = dpdata.LabeledSystem("OUTCAR.ml", fmt="vasp/outcar", ml=True)
print(f"Successfully extracted {len(system['energies'])} frames")

Testing

  • All existing VASP OUTCAR tests continue to pass (67 tests)
  • Added comprehensive robustness testing to verify the improvements
  • Verified that both ML and non-ML parsing modes work correctly
  • Confirmed backward compatibility with existing OUTCAR files

The changes maintain full backward compatibility while making the parser more resilient to format variations that can occur in different VASP versions or configurations.

Fixes #522.


✨ 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] [BUG] only "VOLUME and BASIS-vectors are now included. " fix(vasp): improve robustness of OUTCAR ML parsing for cell data extraction Aug 29, 2025
@Copilot Copilot AI requested a review from njzjz August 29, 2025 14:18
Copilot finished work on behalf of njzjz August 29, 2025 14:18
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.

[BUG] only "VOLUME and BASIS-vectors are now included. "
2 participants