def _get_bands(self): """ Create a bands and a kpoints node from values in eigenvalue. :returns: bsnode, kpout * bsnode: BandsData containing eigenvalues from EIGENVAL and occupations from vasprun.xml * kpout: KpointsData containing kpoints from EIGENVAL, both bsnode as well as kpnode come with cell unset """ eig = self.get_file('EIGENVAL') if not eig: return {'bands': None, 'kpoints': None} _, kpoints, bands = EigParser.parse_eigenval(eig) bsnode = DataFactory('array.bands')() kpout = DataFactory('array.kpoints')() # Take the output structure if available. structure = None if 'structure' in self._output_nodes: structure = self._output_nodes['structure'] if structure is None: structure = self._calc.inp.structure bsnode.set_cell(structure.get_ase().get_cell()) kpout.set_cell(structure.get_ase().get_cell()) if self._calc.inp.kpoints.get_attrs().get('array|kpoints'): bsnode.set_kpointsdata(self._calc.inp.kpoints) if self._calc.inp.kpoints.labels: bsnode.labels = self._calc.inp.kpoints.labels else: bsnode.set_kpoints(kpoints[:, :3], weights=kpoints[:, 3], cartesian=False) bsnode.set_bands(bands, occupations=self._parsers['vasprun.xml'].occupations) kpout.set_kpoints(kpoints[:, :3], weights=kpoints[:, 3], cartesian=False) return {'bands': bsnode, 'kpoints': kpout}
def read_eigenval(self): ''' Create a bands and a kpoints node from values in eigenvalue. returns: bsnode, kpout - bsnode: BandsData containing eigenvalues from EIGENVAL and occupations from vasprun.xml - kpout: KpointsData containing kpoints from EIGENVAL, both bsnode as well as kpnode come with cell unset ''' eig = self.get_file('EIGENVAL') if not eig: self.logger.warning('EIGENVAL not found') return None, None, None header, kp, bs = EigParser.parse_eigenval(eig) bsnode = DataFactory('array.bands')() kpout = DataFactory('array.kpoints')() structure = None # get output structure if not static if self.vrp.is_md or self.vrp.is_relaxation: structure = self.read_cont() if self.vrp.is_md: # set cell from input or output structure cellst = structure else: cellst = self._calc.inp.structure bsnode.set_cell(cellst.get_ase().get_cell()) kpout.set_cell(cellst.get_ase().get_cell()) if self._calc.inp.kpoints.get_attrs().get('array|kpoints'): bsnode.set_kpointsdata(self._calc.inp.kpoints) if self._calc.inp.kpoints.labels: bsnode.labels = self._calc.inp.kpoints.labels else: bsnode.set_kpoints(kp[:, :3], weights=kp[:, 3], cartesian=False) bsnode.set_bands(bs, occupations=self.vrp.occupations) kpout.set_kpoints(kp[:, :3], weights=kp[:, 3], cartesian=False) return bsnode, kpout, structure