def get_pseudotable(options): """Return PseudoTable object.""" if options.pseudos is not None: from abipy.flowtk import PseudoTable return PseudoTable.as_table(options.pseudos) try: from pseudo_dojo import OfficialTables except ImportError as exc: print( "PseudoDojo package not installed. Please install it with `pip install pseudo_dojo`" ) print( "or use `--pseudos FILE_LIST` to specify the pseudopotentials to use." ) raise exc dojo_tables = OfficialTables() if options.usepaw: raise NotImplementedError("PAW table is missing") #pseudos = dojo_tables["ONCVPSP-PBE-PDv0.2-accuracy"] else: pseudos = dojo_tables["ONCVPSP-PBE-PDv0.2-accuracy"] print("Using pseudos from PseudoDojo table", repr(pseudos)) return pseudos
def dataframe_from_pseudos(pseudos, index=None): """ Build pandas dataframe with the most important info associated to a list of pseudos or a list of objects that can be converted into pseudos. Args: pseudos: List of objects that can be converted to pseudos. index: Index of the dataframe. Return: pandas Dataframe. """ from abipy.flowtk import PseudoTable pseudos = PseudoTable.as_table(pseudos) import pandas as pd from collections import OrderedDict attname = [ "Z_val", "l_max", "l_local", "nlcc_radius", "xc", "supports_soc", "type" ] rows = [] for p in pseudos: row = OrderedDict([(k, getattr(p, k, None)) for k in attname]) row["ecut_normal"], row["pawecutdg_normal"] = None, None if p.has_hints: hint = p.hint_for_accuracy(accuracy="normal") row["ecut_normal"] = hint.ecut if hint.pawecutdg: row["pawecutdg_normal"] = hint.pawecutdg rows.append(row) return pd.DataFrame(rows, index=index, columns=list(rows[0].keys()) if rows else None)
def dataframe_from_pseudos(pseudos, index=None): """ Build pandas dataframe with the most important info associated to a list of pseudos or a list of objects that can be converted into pseudos. Args: pseudos: List of objects that can be converted to pseudos. index: Index of the dataframe. Return: pandas Dataframe. """ from abipy.flowtk import PseudoTable pseudos = PseudoTable.as_table(pseudos) import pandas as pd attname = ["Z_val", "l_max", "l_local", "nlcc_radius", "xc", "supports_soc", "type"] rows = [] for p in pseudos: row = OrderedDict([(k, getattr(p, k, None)) for k in attname]) row["ecut_normal"], row["pawecutdg_normal"] = None, None if p.has_hints: hint = p.hint_for_accuracy(accuracy="normal") row["ecut_normal"] = hint.ecut if hint.pawecutdg: row["pawecutdg_normal"] = hint.pawecutdg rows.append(row) return pd.DataFrame(rows, index=index, columns=list(rows[0].keys()) if rows else None)
def __init__(self, pseudos, pseudo_dir="", structure=None, ndtset=1, comment="", decorators=None): """ Args: pseudos: String or list of string with the name of the pseudopotential files. pseudo_dir: Name of the directory where the pseudopotential files are located. structure: file with the structure, :class:`Structure` object or dictionary with ABINIT geo variable ndtset: Number of datasets. comment: Optional string with a comment that will be placed at the beginning of the file. decorators: List of `AbinitInputDecorator` objects. """ # Dataset[0] contains the global variables common to the different datasets # Dataset[1:ndtset+1] stores the variables specific to the different datasets. self._ndtset = ndtset self._datasets = [] for i in range(ndtset+1): dt0 = None if i > 0: dt0 = self._datasets[0] self._datasets.append(Dataset(index=i, dt0=dt0)) self._datasets[0]["ndtset"] = ndtset # Setup of the pseudopotential files. if isinstance(pseudos, PseudoTable): self._pseudos = pseudos elif all(isinstance(p, Pseudo) for p in pseudos): self._pseudos = PseudoTable(pseudos) else: # String(s) pseudo_dir = os.path.abspath(pseudo_dir) pseudo_paths = [os.path.join(pseudo_dir, p) for p in list_strings(pseudos)] missing = [p for p in pseudo_paths if not os.path.exists(p)] if missing: raise self.Error("Cannot find the following pseudopotential files:\n%s" % str(missing)) self._pseudos = PseudoTable(pseudo_paths) if structure is not None: self.set_structure(structure) if comment is not None: self.set_comment(comment) self._decorators = [] if not decorators else decorators
def get_pseudotable(options): """Return PseudoTable object.""" if options.pseudos is not None: from abipy.flowtk import PseudoTable return PseudoTable.as_table(options.pseudos) try: from pseudo_dojo import OfficialTables except ImportError as exc: print("PseudoDojo package not installed. Please install it with `pip install pseudo_dojo`") print("or use `--pseudos FILE_LIST` to specify the pseudopotentials to use.") raise exc dojo_tables = OfficialTables() if options.usepaw: raise NotImplementedError("PAW table is missing") #pseudos = dojo_tables["ONCVPSP-PBE-PDv0.2-accuracy"] else: pseudos = dojo_tables["ONCVPSP-PBE-PDv0.2-accuracy"] print("Using pseudos from PseudoDojo table", repr(pseudos)) return pseudos
def pseudos(*filenames): """Returns a PseudoTable constructed from the input filenames located in tests/data/pseudos.""" pseudos = list(map(pseudo, filenames)) return PseudoTable(pseudos)
from __future__ import unicode_literals, division, print_function, absolute_import import os _root = os.path.dirname(__file__) _paths = [f for f in os.listdir(_root) if f.endswith("hgh")] # Need one pseudo for element d = {} for p in _paths: i = p.index(".") head, tail = p[:i], p[i:] d[head] = tail _paths = [k + v for k, v in d.items()] _paths = [os.path.join(_root, f) for f in _paths] del d from abipy.flowtk import PseudoTable HGH_TABLE = PseudoTable(_paths) # Add fake hints. for pseudo in HGH_TABLE: pseudo.dojo_report = {} pseudo.dojo_report["hints"] = {} for accuracy in ["low", "normal", "high"]: pseudo.dojo_report["hints"][accuracy] = {"ecut": 50} #assert pseudo.has_hints