Skip to content

Commit

Permalink
Add support for loading constant lattice data (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefsmeets authored Oct 19, 2023
1 parent deee2a8 commit ebf919f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/gemdat/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def __init__(
n_parts : int, optional
Number of parts to divide transitions into for statistics
"""
if not trajectory.constant_lattice:
raise ValueError(
'Trajectory must have constant lattice for site analysis.')

self.n_parts = n_parts

self.floating_specie = floating_specie
Expand Down
6 changes: 5 additions & 1 deletion src/gemdat/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def from_vasprun(
cls,
xml_file: str | Path,
cache: Optional[str | Path] = None,
constant_lattice: bool = True,
**kwargs,
) -> Trajectory:
"""Load data from a `vasprun.xml`.
Expand All @@ -167,6 +168,9 @@ def from_vasprun(
Path to vasprun.xml
cache : Optional[Path], optional
Path to cache data for vasprun.xml
constant_lattice : bool
Whether the lattice changes during the simulation,
such as in an NPT MD simulation.
**kwargs : dict
Optional arguments passed to [pymatgen.io.vasp.outputs.Vasprun][]
Expand Down Expand Up @@ -203,7 +207,7 @@ def from_vasprun(

obj = cls.from_structures(
run.structures,
constant_lattice=True,
constant_lattice=constant_lattice,
time_step=run.parameters['POTIM'] * 1e-15,
metadata=metadata,
)
Expand Down

0 comments on commit ebf919f

Please sign in to comment.