Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import optimisation #287

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion abipy/dynamics/hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from monty.string import marquee, list_strings
from pymatgen.core.periodic_table import Element
from pymatgen.analysis.structure_analyzer import RelaxationAnalyzer
from pymatgen.io.vasp.outputs import Xdatcar
from abipy.tools.plotting import add_fig_kwargs, get_ax_fig_plt, get_axarray_fig_plt, set_visible, get_figs_plotly, \
get_fig_plotly, add_plotly_fig_kwargs, plotlyfigs_to_browser, push_to_chart_studio, PlotlyRowColDesc, plotly_set_lims, \
latex_greek_2unicode
Expand Down Expand Up @@ -180,6 +179,8 @@ def to_xdatcar(self, filepath=None, groupby_type=True, to_unit_cell=False, **kwa
to_unit_cell (bool): Whether to translate sites into the unit cell.
kwargs: keywords arguments passed to Xdatcar constructor.
"""
from pymatgen.io.vasp.outputs import Xdatcar

filepath = self.write_xdatcar(filepath=filepath, groupby_type=groupby_type,
to_unit_cell=to_unit_cell, overwrite=True)

Expand All @@ -201,6 +202,9 @@ def write_xdatcar(self, filepath="XDATCAR", groupby_type=True, overwrite=False,
Return:
path to Xdatcar file.
"""
# This library takes 13s to import on HPC (07/02/24) so moved to class method instead of header
from pymatgen.io.vasp.outputs import Xdatcar

if filepath is not None and os.path.exists(filepath) and not overwrite:
raise RuntimeError("Cannot overwrite pre-existing file `%s`" % filepath)

Expand Down
6 changes: 4 additions & 2 deletions abipy/electrons/lobster.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
from monty.functools import lazy_property
from pymatgen.core.periodic_table import Element
from pymatgen.electronic_structure.core import OrbitalType
from pymatgen.io.vasp.outputs import Vasprun
from pymatgen.io.vasp.inputs import Potcar
from pymatgen.io.abinit.pseudos import Pseudo
from abipy.core.func1d import Function1D
from abipy.core.mixins import BaseFile, NotebookWriter
Expand Down Expand Up @@ -1166,6 +1164,10 @@ def from_dir(cls, dirpath, dE=0.01, **kwargs):
Returns:
A LobsterInput.
"""
# These two libraries take a long time to import on HPC (07/02/24) so moved to method instead of header
from pymatgen.io.vasp.outputs import Vasprun
from pymatgen.io.vasp.inputs import Potcar

# Try to determine the code used for the calculation
dft_code = None
if os.path.isfile(os.path.join(dirpath, 'vasprun.xml')):
Expand Down
Loading