diff --git a/abipy/ml/extxyz_generator.py b/abipy/ml/extxyz_generator.py index 9a2a14317..650aa274d 100644 --- a/abipy/ml/extxyz_generator.py +++ b/abipy/ml/extxyz_generator.py @@ -1,4 +1,6 @@ """ +Tools to read data from output files generated by ab-initio codes +and generate extended XYZ files. """ from __future__ import annotations @@ -25,7 +27,7 @@ class ExtxyzIOWriter: """ Example: - # To find all the vasprun.xml files starting from the a top-level directory, use: + # To find all the vasprun.xml files starting from a top-level directory, use: xyz_writer = ExtxyzIOWriter.from_top(".", "vasprun.xml") print(xyz_writer) @@ -46,6 +48,20 @@ class ExtxyzIOWriter: "GSR.nc", ] + @classmethod + def from_top_vasprun(cls, top: PathLike): + """ + Find all the vasprun.xml files starting from the top-level directory top. + """ + return cls(top, "vasprun.xml") + + @classmethod + def from_top_gsr(cls, top: PathLike): + """ + Find all the GSR.nc files starting from the top-level directory top. + """ + return cls(top, "GSR.nc") + @classmethod def from_top(cls, top: PathLike, ext: str): """ @@ -79,6 +95,11 @@ def __str__(self) -> str: def write(self, xyz_filepath: PathLike, overwrite: bool = False): """ + Write data to xyz_filepath. + + Args: + xyz_filepath: Filename + overwrite: True to allow overwriting. """ if not overwrite and os.path.isfile(xyz_filepath): raise RuntimeError(f"Cannot overwrite pre-existent file: {xyz_filepath=}, use overwrite=True to allow overwriting.") @@ -89,6 +110,7 @@ def write(self, xyz_filepath: PathLike, overwrite: bool = False): def yield_atoms(self): """ + Generate ASE atoms. """ for filepath in self.filepaths: if self.ext == "vasprun.xml": diff --git a/abipy/ml/tools.py b/abipy/ml/tools.py index 11664d53f..5fa5bcb4b 100644 --- a/abipy/ml/tools.py +++ b/abipy/ml/tools.py @@ -1,4 +1,5 @@ """ +Low-level tools used in abipy.ml """ from __future__ import annotations @@ -95,5 +96,4 @@ def get_structures_labels_from_files(filepaths) -> tuple[list[Structure], dict]: #for s in structures: print(s) #for k, v in labels.items(): print(k, v) - return structures, labels - + return structures, labels \ No newline at end of file diff --git a/abipy/ppcodes/ppgen.py b/abipy/ppcodes/ppgen.py index ab3d8cf1e..cfdda4282 100644 --- a/abipy/ppcodes/ppgen.py +++ b/abipy/ppcodes/ppgen.py @@ -296,7 +296,6 @@ def check_status(self): # fr = "fully-relativistic" - class OncvGenerator(_PseudoGenerator): """ This object receives an input file for oncvpsp, a string @@ -394,4 +393,4 @@ def check_status(self): logger.warning("setting status to S_ERROR") self._status = self.S_ERROR - return self._status + return self._status \ No newline at end of file diff --git a/abipy/scripts/abiml.py b/abipy/scripts/abiml.py index fd95e502e..4abf29ada 100755 --- a/abipy/scripts/abiml.py +++ b/abipy/scripts/abiml.py @@ -15,7 +15,7 @@ from functools import wraps from time import time from abipy.core.structure import Structure -from abipy.tools.printing import print_dataframe +#from abipy.tools.printing import print_dataframe ASE_OPTIMIZERS = aseml.ase_optimizer_cls("__all__") @@ -319,8 +319,7 @@ def md(ctx, filepath, nn_name, def neb(ctx, filepaths, nn_name, nimages, relax_mode, fmax, pressure, optimizer, neb_method, climb, fix_inds, fix_symbols, - workdir, verbose - ): + workdir, verbose): """ NEB calculation with ASE and ML potential. @@ -789,4 +788,4 @@ def cwf_eos(ctx, elements, nn_names, if __name__ == "__main__": - sys.exit(main()) + sys.exit(main()) \ No newline at end of file diff --git a/abipy/scripts/abislurm.py b/abipy/scripts/abislurm.py index 455956f9e..ce5b10606 100755 --- a/abipy/scripts/abislurm.py +++ b/abipy/scripts/abislurm.py @@ -12,7 +12,7 @@ def get_epilog() -> str: - return """\ + return """\ Usage example:\n abislurm.py running => Get info on all the running jobs diff --git a/abipy/scripts/oncv.py b/abipy/scripts/oncv.py index b5c6ffa5c..00e0518d2 100755 --- a/abipy/scripts/oncv.py +++ b/abipy/scripts/oncv.py @@ -158,7 +158,7 @@ def oncv_run(options): cprint("FR calculation with input file without `_r` suffix. Will add `_r` to output files", color="yellow") elif options.rel == "from_file": - calc_type = "scalar-relativistic" + calc_type = "scalar-relativistic" if root.endswith("_r"): calc_type = "fully-relativistic" if root.endswith("_nor"): calc_type = "non-relativistic" @@ -326,7 +326,7 @@ def build(): def get_epilog() -> str: - return """\ + return """\ Usage example: oncv.py run H.in ==> Run oncvpsp input file (scalar relativistic mode). @@ -458,4 +458,4 @@ def show_examples_and_exit(err_msg=None, error_code=1): if __name__ == "__main__": - sys.exit(main()) + sys.exit(main()) \ No newline at end of file diff --git a/docs/Makefile b/docs/Makefile index c0c71e80c..465f578c2 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -66,7 +66,7 @@ html: check_dot $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html || { echo "Error: Sphinx build failed"; exit 1; } @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - open $(BUILDDIR)/html/index.html || { echo "Error: Failed to open index.html"; exit 1; } + #open $(BUILDDIR)/html/index.html || { echo "Error: Failed to open index.html"; exit 1; } dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml