-
Notifications
You must be signed in to change notification settings - Fork 35
Description
Describe the bug
The necessary binning occurring in order to compare VASP and LOBSTER DOS's done in cohp.analyze.Analysis.get_lobster_calc_quality_summary presents an issue:
We do not check if n_bins > len(dos_lobster.energies); if this condition is True get_dos_fp (from pymatgen) returns an object with an internal shape that is commensurate with the initial object. However, if the previous conditions is False, the energy array is wrapped in another array, adding one dimension. In this case, the code will fail just after in get_dos_fp_similarity because of shape mismatch in the dot product:
File "/dss/dsshome1/07/di97zak/miniforge3/envs/mcba/lib/python3.12/site-packages/atomate2/lobster/schemas.py", line 601, in from_directory
cal_quality_dict = Analysis.get_lobster_calc_quality_summary(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/dss/dsshome1/07/di97zak/miniforge3/envs/mcba/lib/python3.12/site-packages/lobsterpy/cohp/analyze.py", line 1721, in get_lobster_calc_quality_summary
dos_vasp.get_dos_fp_similarity(fp_lobster_orb, fp_vasp_orb, metric="tanimoto"),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/dss/dsshome1/07/di97zak/miniforge3/envs/mcba/lib/python3.12/site-packages/pymatgen/electronic_structure/dos.py", line 1337, in get_dos_fp_similarity
rescale = np.linalg.norm(vec1) 2 + np.linalg.norm(vec2) 2 - np.dot(vec1, vec2)
ValueError: shapes (2,) and (256,) not aligned: 2 (dim 0) != 256 (dim 0)
To Reproduce
Run CalcQualitySummary.from_directory(".") on any LOBSTER calculation where the DOS has fewer than 256 energy points (the default n_bins value for atomate2).
Expected behavior
The code should handle DOS objects with different numbers of energy points gracefully. Ideally, it should either:
- Automatically set n_bins to min(len(dos_lobster.energies), len(dos_vasp.energies))
- Or fix the inconsistent array shapes returned by get_dos_fp