def get_occupations(self, nel, width=None, refresh=False): """ calculate occupations of each eigenvalue. the the shape of the occupation is the same as self._eigenvals. [eig_k1,eigk2,...], each eig_k is a column with the length=nbands. if nspin=2 and fix_spin, there are two fermi energies. NOTE: this conflicts with the DOS caluculation. FIXME. :param nel: number of electrons. if fix_spin, the nel is a tuple of (nel_up,nel_dn) :Returns: self._occupations (np.ndarray) index:[band,kpt,orb,spin] if nspin==2 else [band,kpt,orb] same as eigenvec """ if self._verbose: print("Calc occupation") self._nel = nel self.get_eigenvalues(refresh=refresh) #print self._kweights #print self._eigenvals occ = Occupations(nel, self._width, self._kweights, nspin=self._nspin) self._occupations = occ.occupy(self._eigenvals) self._efermi = occ.get_mu() if self._verbose: print("End Calc occupation")
def get_occupations(self, nel, width=0.2, refresh=False): """ calculate occupations of each eigenvalue. the the shape of the occupation is the same as self._eigenvals. [eig_k1,eigk2,...], each eig_k is a column with the length=nbands. if nspin=2 and fix_spin, there are two fermi energies. NOTE: this conflicts with the DOS caluculation. FIXME. :param nel: number of electrons. if fix_spin, the nel is a tuple of (nel_up,nel_dn) :Returns: self._occupations (np.ndarray) index:[band,kpt,orb,spin] if nspin==2 else [band,kpt,orb] same as eigenvec """ self._nel = nel self.get_eigenvalues(refresh=refresh) #print self._kweights #print self._eigenvals if self._nspin == 1 or not self.fix_spin: occ = Occupations(nel, width, self._kweights, nspin=self._nspin) self._occupations = occ.occupy(self._eigenvals) self._efermi = occ.get_mu() elif self._nspin == 2 and self.fix_spin: raise NotImplementedError( "current implement on fix_spin is not correct.") u"""FIXME: 这根本就不对,eig无法被直接区分为eig_up,eig_dn,不能这样处理""" nel_up, nel_dn = nel eig_up = self.eigenvals[::2] eig_dn = self.eigenvals[1::2] occ_up = Occupations(nel_up, width, self._kweights, nspin=1) occupations_up = occ_up.occupy(eig_up) efermi_up = occ_up.get_mu() occ_dn = Occupations(nel_dn, width, self._kweights, nspin=1) occupations_dn = occ_dn.occupy(eig_dn) efermi_dn = occ_dn.get_mu() self._occupations[::2] = occupations_up self._occupations[1::2] = occupations_dn self.efermi = (efermi_up, efermi_dn) return self._occupations
def get_occupations(self, nel=None, width=0.05, refresh=False): """ calculate occupations of each eigenvalue. the the shape of the occupation is the same as self._eigenvals. [eig_k1,eigk2,...], each eig_k is a column with the length=nbands. :param nel: number of electrons. :Returns: self._occupations (np.ndarray) index:[band,kpt,orb,spin] if nspin==2 else [band,kpt,orb] same as eigenvec """ if nel is not None: self._nel = nel nel = self._nel self.get_eigenvalues(refresh=refresh) #print self._kweights #print self._eigenvals if self._nspin == 1: occ = Occupations(nel, width, self._kweights, nspin=self._nspin) self._occupations = occ.occupy(self._eigenvals) self._efermi = occ.get_mu() elif self._nspin == 2: raise NotImplementedError( "current implement on fix_spin is not correct.") nel_up, nel_dn = nel eig_up = self.eigenvals[::2] eig_dn = self.eigenvals[1::2] occ_up = Occupations(nel_up, width, self._kweights, nspin=1) occupations_up = occ_up.occupy(eig_up) efermi_up = occ_up.get_mu() occ_dn = Occupations(nel_dn, width, self._kweights, nspin=1) occupations_dn = occ_dn.occupy(eig_dn) efermi_dn = occ_dn.get_mu() self._occupations[::2] = occupations_up self._occupations[1::2] = occupations_dn self.efermi = (efermi_up, efermi_dn) return self._occupations