def _load_structure_from_dir(directory): """ Find the final geometry from a directory which contains the output of a VASP run, preferably performed within a fireworks workflow. For simple Structure objects, the full geometry can be derived from the VASP outputs. However, more complex subclasses such as Cathode and QSlab require information about the original instance. This can be retrieved from the FW.json file, if present. Args: directory: Directory of the completed VASP run. Returns: Structure: The output geometry of the calculation. Either a Structure or subclass of a Structure. """ if os.path.exists(os.path.join(directory, "FW.json")): fw = Firework.from_file(os.path.join(directory, "FW.json")) structure = _find_fw_structure(fw) if structure.__class__ == Structure: vasprun, outcar = get_vasprun_outcar(directory) return get_structure_from_prev_run(vasprun, outcar) elif issubclass(structure.__class__, QSlab): structure.update_sites(directory) return structure elif issubclass(structure.__class__, Cathode): structure.update_sites(directory) return structure else: raise ValueError else: warnings.warn("No FW.json file in the specified directory. Output geometry " "will be returned as a Structure instance, even though the " "input geometry may have been derived from a more complex " "subclass.") vasprun, outcar = get_vasprun_outcar(directory) return get_structure_from_prev_run(vasprun, outcar)