def get_bands_node(self): bnode = DataFactory('array.bands')() bdat, bkp, bgnu = self.get_bands_plot() if not (bdat and bkp): return None with open(bkp) as bk: self.line(bk) # contains num kpoints kp = re.split(self.empty_line, bk.read()) kp = filter(None, kp) kp = map(self.splitlines, kp) kp = filter(None, kp[0]) kp = np.array(kp) bnode.set_kpoints(kp[:, :3], weights=kp[:, 3]) with open(bdat) as bd: data = re.split(self.empty_line, bd.read()) data = filter(None, data) data = map(self.splitlines, data) data = np.array(data) bnode.set_bands(data[:, :, 1].transpose()) kppath = self._calc.inp.settings.get_dict().get('kpoint_path') kpl = [[kpp[0], kpp[1:4]] for kpp in kppath] kpl.append([kppath[-1][4], kppath[-1][5:8]]) counter = {i[0]: 0 for i in kpl} kplab = [] for kpi in kpl: ci = counter[kpi[0]] idx = self._find_special_kpoint(kp[:, :3], kpi[1], num=ci) kplab.append((idx, kpi[0])) counter[kpi[0]] += 1 bnode.labels = kplab return bnode
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