Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ce38336
pyproject toml hacks for uv
ajjackson Aug 3, 2026
8343e73
update meson.build: flag to drop C build, include vasp.py
ajjackson Aug 3, 2026
4759aa4
VASP hdf5 modes import (AI code)
ajjackson Aug 3, 2026
6214b5d
more tests, FC loading
ajjackson Aug 3, 2026
4a4294d
Ruff fixes
ajjackson Aug 3, 2026
3d56be4
Code review
ajjackson Aug 3, 2026
0115b49
Streamline str|Path handling for readers.vasp: caller is responsible
ajjackson Aug 3, 2026
04db454
More revisions:
ajjackson Aug 3, 2026
94bed3a
Various review improvements
ajjackson Aug 4, 2026
e1c15df
flattening and refactoring FC import
ajjackson Aug 4, 2026
96ea295
Another return TypedDict, more clarifying comments
ajjackson Aug 4, 2026
c46b0e8
More meson fiddling
ajjackson Aug 4, 2026
1ca622c
Improve vasp reader test coverage
ajjackson Aug 4, 2026
97ce0bf
Refactor crystal-from-vasp testing; read input if not in results
ajjackson Aug 4, 2026
a34e5c6
Check h5 FC dimensions as expected
ajjackson Aug 4, 2026
78ae3bb
Add BornDict, rename lots of things for consistency
ajjackson Aug 4, 2026
67b6cd6
Add missing test data
ajjackson Aug 4, 2026
9b3c8c6
Linting
ajjackson Aug 4, 2026
86e26cd
Update CHANGELOG
ajjackson Aug 4, 2026
dea1daf
ruff
ajjackson Aug 5, 2026
5fcd3ba
Control tests with pytest marks
ajjackson Aug 5, 2026
6cc172e
Update tox.ini using new vasp_reader mark
ajjackson Aug 5, 2026
ce9f7a9
add missing test marker
ajjackson Aug 5, 2026
11edca3
Stricter handling of invalid POMASS data. Drop redundant group check.
ajjackson Aug 5, 2026
9b078a5
Slight improvement to error message
ajjackson Aug 5, 2026
8804872
Remove dead code
ajjackson Aug 5, 2026
b3c8f52
New test case: Al ibrion=6 without born charges
ajjackson Aug 5, 2026
4fb8228
always use input/poscar positions
ajjackson Aug 5, 2026
7bd95f3
Drop frequencies_unit arg from alternate constructors
ajjackson Aug 5, 2026
a901e0b
clearer error message
ajjackson Aug 10, 2026
0e1d684
Avoid recomputing matrix inverse
ajjackson Aug 11, 2026
034bf1f
drop duplicate pyproject block
ajjackson Aug 13, 2026
ca328e8
WIP more tests
ajjackson Aug 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@
aware this didn't cause problems *yet*, but could misbehave in
some environment.

- New features

- Added VASP HDF5 input support (`vaspout.h5`) for importing force
constants, Born effective charges, and dielectric tensors via
``ForceConstants.from_vasp``, as well as precalculated phonon mode
data via ``QpointPhononModes.from_vasp`` and
``QpointFrequencies.from_vasp``. When primitive cell data is
present, a supercell-to-primitive force constant transformation is
attempted: less data is available is available than the equivalent
phonopy scenario, which may impact reliability.

- Compatibility fixes

- The [brille] optional dependency group will no longer attempt to
Expand Down
24 changes: 23 additions & 1 deletion euphonic/force_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
)
from euphonic.qpoint_frequencies import QpointFrequencies
from euphonic.qpoint_phonon_modes import QpointPhononModes
from euphonic.readers import castep, phonopy
from euphonic.readers import castep, phonopy, vasp
from euphonic.ureg import ureg
from euphonic.util import (
_get_supercell_relative_idx,
Expand Down Expand Up @@ -1875,6 +1875,28 @@ def from_castep(cls, filename: Path | str) -> Self:
data = castep.read_interpolation_data(filename)
return cls.from_dict(data)

@classmethod
def from_vasp(cls, filename: Path | str) -> Self:
"""
Reads force constants data from a VASP HDF5 file (e.g. vaspout.h5).

Parameters
----------
filename
The path and name of the VASP HDF5 file to read

Returns
-------
forceconstants
"""
data = vasp.read_interpolation_data(Path(filename))
fc = cls.from_dict(data)
if fc.born is not None:
fc = cls.from_total_fc_with_dipole(
fc.crystal, fc.force_constants, fc.sc_matrix, fc.cell_origins,
born=fc.born, dielectric=fc.dielectric)
return fc

@classmethod
def from_phonopy(cls,
*,
Expand Down
18 changes: 17 additions & 1 deletion euphonic/qpoint_frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
_obj_to_json_file,
_process_dict,
)
from euphonic.readers import castep, phonopy
from euphonic.readers import castep, phonopy, vasp
from euphonic.spectra import Spectrum1D, Spectrum1DCollection, Spectrum2D
from euphonic.ureg import Quantity, ureg
from euphonic.util import (
Expand Down Expand Up @@ -464,3 +464,19 @@ def from_phonopy(cls,
path=path, phonon_name=phonon_name, phonon_format=phonon_format,
summary_name=summary_name, read_eigenvectors=False)
return cls.from_dict(data)

@classmethod
def from_vasp(
cls,
filename: Path | str,
) -> Self:
"""
Reads phonon frequency data from a VASP HDF5 file (e.g. vaspout.h5)

Parameters
----------
filename
The path and name of the VASP HDF5 file to read
"""
data = vasp.read_phonon_data(Path(filename))
return cls.from_dict(data)
18 changes: 17 additions & 1 deletion euphonic/qpoint_phonon_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
AdaptiveMethod,
QpointFrequencies,
)
from euphonic.readers import castep, phonopy
from euphonic.readers import castep, phonopy, vasp
from euphonic.spectra import Spectrum1DCollection
from euphonic.structure_factor import StructureFactor
from euphonic.ureg import Quantity, ureg
Expand Down Expand Up @@ -722,6 +722,22 @@ def from_phonopy(
summary_name=summary_name)
return cls.from_dict(data)

@classmethod
def from_vasp(
cls,
filename: Path | str,
) -> Self:
"""
Reads phonon mode data from a VASP HDF5 file (e.g. vaspout.h5)

Parameters
----------
filename
The path and name of the VASP HDF5 file to read
"""
data = vasp.read_phonon_data(Path(filename))
return cls.from_dict(data)


def _get_isotope_data(scattering_lengths: IsotopeDataset) -> IsotopeData:
"""Get dataset with coherent_scattering_length for coherent S(q, ω)"""
Expand Down
12 changes: 7 additions & 5 deletions euphonic/readers/phonopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
class ImportPhonopyReaderError(ModuleNotFoundError):

def __init__(self):
self.message = (
'\n\nCannot import yaml, h5py to read Phonopy files, maybe '
'they are not installed. To install the optional '
"dependencies for Euphonic's Phonopy reader, try:\n\n"
'pip install euphonic[phonopy-reader]\n')
self.message = format_error(
'Cannot import yaml and h5py to read Phonopy files.',
fix=(
'To install optional dependencies for Phonopy reader, try: '
'pip install euphonic[phonopy-reader]'
),
)

def __str__(self):
return self.message
Expand Down
Loading
Loading