Conversation
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified FilesNo covered modified files...
|
|
I note that coverage reporting seems to be totally broken. This isn't even a fork and it's still failing to pick up the changed files correctly 😞 |
- use format_error for hdf5 availability error - open hdf5 with context manager - no single-character variable names - tweak docstrings
- TypedDict for crystal dict output - Use h5py feature to guarantee string output (not bytes) - Fix POMASS priority order - Fix fractional coordinate rounding - Force amu/Ang units, simplifying params
In an NSW=0 calculation the positions are not a result so should be read from input. This occurs for post-processing QPOINTS runs. If there _is_ a structure in results we should use it as the stucture may have been optimised.
Don't quietly pass onto POTCAR data if INCAR data is bad.
- This introduced a nasty challenge: the final structure in results/positions can include finite displacements from Hessian calculation. Clearly we don't want that in our reference structure. For now fallback to the input structure, but that also has possible problems...
Testing suggests that ibrion=6 calculations don't actually do optimisation to update the base positions, but they do tend to leave a displaced structure in "results". So it seems safest to always use the input structure if we didn't get a primitive transformation; that also streamlines the code a bit.
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Woohoo, rebased and the new coverage reporter seems to be working 🎉 |
| # 1. Try active input/incar/POMASS | ||
| if 'input/incar/POMASS' in h5_file: | ||
| val = h5_file['input/incar/POMASS'].asstr()[()] | ||
| raw_vals = re.findall(r'[0-9.]+', str(val)) |
There was a problem hiding this comment.
Does this need casting to str again?
Also, would it be "better" to use finditer, build the list from that, then check whether the list has elements before returning?
| match = re.search( | ||
| r'POMASS\s*=\s*(?P<masses>[0-9.\s,]+)', incar_content | ||
| ) | ||
| if match: |
There was a problem hiding this comment.
| match = re.search( | |
| r'POMASS\s*=\s*(?P<masses>[0-9.\s,]+)', incar_content | |
| ) | |
| if match: | |
| if not (match := re.search( | |
| r'POMASS\s*=\s*(?P<masses>[0-9.\s,]+)', incar_content | |
| )): |
| matches = re.findall(r'POMASS\s*=\s*(?P<mass>[0-9.]+)', potcar_content) | ||
| if matches: |
There was a problem hiding this comment.
| matches = re.findall(r'POMASS\s*=\s*(?P<mass>[0-9.]+)', potcar_content) | |
| if matches: | |
| if matches := re.findall(r'POMASS\s*=\s*(?P<mass>[0-9.]+)', potcar_content): |
|
|
||
|
|
||
| def _read_cell_from_group( | ||
| h5_file: 'h5py.File', group_path: str |
There was a problem hiding this comment.
Do you need forward declaration if it's in a TYPE_CHECKING block?
Recent (relatively-speaking) versions of VASP have improved phonon calculation features and a machine-friendly .h5 file output. This makes it a lot more attractive to include some built-in support. A tricky point is that various calculation types will produce an identically-named .h5 file so a bit of intelligence is needed to identify if relevant information is available:
An IBRION=[5-8] calculation will produce a Hessian for the whole simulation cell. VASP might identify the supercell nature and use this to reduce the number of displacements, but we still get a 3Nx3N set of force constants. For now we do not look for a primitive cell in this case, and treat the system as though it is primitive. That will give correct DOS and INS simulations for a supercell calculation, but at increased cost compared with a more sophisticated scheme. (Band structures will include folding and incorrect symmetry labels.)
If QPOINTS are provided and PHON_DOS is set, VASP will do q-point interpolation and produce a dataset with defined primitive cell and sufficient data to construct QpointPhononModes. The force constants may be present, but can also be missing if the file was produced in a "post-processing" run on an existing .h5 file.
If both force constants and primitive cell are defined, we can attempt to map the force constants to primitive as we do for Phonopy. Less metadata is available so for now we naively try to solve for the supercell matrix. This might go wrong in non-trivial cases, but so do some Phonopy imports at the moment; probably they can be fixed together in future. In (fairly common) trivial diagonal supercell cases we should be fine.
https://vasp.at/wiki/Computing_the_phonon_dispersion_and_DOS
h5py is an optional dependency included in the existing phonopy-reader dependency group, so we re-use that in packaging/CI infrastructure. (phonopy-reader also includes YAML, but VASP doesn't need it.)
At the moment I've put the tests in a new vasp_reader group. But perhaps life would be simpler if they shared phonopy_reader.