def pivot(self, elec=None, in_device=False, sort=False): """ Return the pivoting indices for a specific electrode Parameters ---------- elec : str or int the corresponding electrode to return the self-energy from in_device : bool, optional If ``True`` the pivoting table will be translated to the device region orbitals sort : bool, optional Whether the returned indices are sorted. Mostly useful if the self-energies are returned sorted as well. Examples -------- >>> se = tbtsencSileTBtrans(...) >>> se.pivot() [3, 4, 6, 5, 2] >>> se.pivot(sort=True) [2, 3, 4, 5, 6] >>> se.pivot(0) [2, 3] >>> se.pivot(0, in_device=True) [4, 0] >>> se.pivot(0, in_device=True, sort=True) [0, 1] >>> se.pivot(0, sort=True) [2, 3] """ if elec is None: if in_device and sort: return _a.arangei(self.no_d) pvt = self._value('pivot') - 1 if in_device: # Count number of elements that we need to subtract from each orbital subn = _a.onesi(self.no) subn[pvt] = 0 pvt -= _a.cumsumi(subn)[pvt] elif sort: pvt = np.sort(pvt) return pvt # Get electrode pivoting elements se_pvt = self._value('pivot', tree=self._elec(elec)) - 1 if sort: # Sort pivoting indices # Since we know that pvt is also sorted, then # the resulting in_device would also return sorted # indices se_pvt = np.sort(se_pvt) if in_device: pvt = self._value('pivot') - 1 if sort: pvt = np.sort(pvt) # translate to the device indices se_pvt = indices(pvt, se_pvt, 0) return se_pvt
def pivot(self, elec=None, in_device=False, sort=False): """ Return the pivoting indices for a specific electrode (in the device region) or the device Parameters ---------- elec : str or int the corresponding electrode to return the pivoting indices from in_device : bool, optional If ``True`` the pivoting table will be translated to the device region orbitals. If `sort` is also true, this would correspond to the orbitals directly translated to the geometry ``self.geometry.sub(self.a_dev)``. sort : bool, optional Whether the returned indices are sorted. Mostly useful if you want to handle the device in a non-pivoted order. Examples -------- >>> se = tbtncSileTBtrans(...) >>> se.pivot() [3, 4, 6, 5, 2] >>> se.pivot(sort=True) [2, 3, 4, 5, 6] >>> se.pivot(0) [2, 3] >>> se.pivot(0, in_device=True) [4, 0] >>> se.pivot(0, in_device=True, sort=True) [0, 1] >>> se.pivot(0, sort=True) [2, 3] See Also -------- pivot_down : for the pivot table for electrodes down-folding regions """ if elec is None: if in_device and sort: return _a.arangei(self.no_d) pvt = self._value('pivot') - 1 if in_device: # Count number of elements that we need to subtract from each orbital subn = _a.onesi(self.no) subn[pvt] = 0 pvt -= _a.cumsumi(subn)[pvt] elif sort: pvt = npsort(pvt) return pvt # Get electrode pivoting elements se_pvt = self._value('pivot', tree=self._elec(elec)) - 1 if sort: # Sort pivoting indices # Since we know that pvt is also sorted, then # the resulting in_device would also return sorted # indices se_pvt = npsort(se_pvt) if in_device: pvt = self._value('pivot') - 1 if sort: pvt = npsort(pvt) # translate to the device indices se_pvt = indices(pvt, se_pvt, 0) return se_pvt