コード例 #1
0
ファイル: lattice.py プロジェクト: Lynn-015/NJU_DMRG
    def showcell(self,bondindex=(1,2),plane=(0,1),color='r',offset=None):
        '''
        Plot the cell structure.

        bondindex:
            the bondindex-th nearest bonds are plotted. It should be a tuple.
            Default is (1,2) - the nearest, and second nearest neightbors.
        plane:
            project to the specific plane if it is a 3D structre.
            Default is (0,1) - 'x-y' plane.
        color:
            color, default is 'r' -red.
        offset:
            The offset of the sample cell.
        '''
        p1,p2=plane
        nnnbonds=self.cbonds
        if nnnbonds is None or len(nnnbonds)<=1:
            warnings.warn('Trivial [email protected], plot on-site terms only.')
            bondindex=()
        if offset is None:
            offset=[2]*self.dimension
        for nb in bondindex:
            cb=nnnbonds[nb]
            cellindex=self.l2index(append(offset,[0]))
            show_bonds(cb,start=self.sites[cellindex+cb.atom1s])
        #plot sites
        if self.vdim>1:
            p1,p2=plane
            x,y=self.sites[:,p1],self.sites[:,p2]
        else:
            x=self.sites[:,0]
            y=zeros(self.N)
        scatter(x,y,s=50,c=color,edgecolor='none',vmin=-0.5,vmax=1.5)
コード例 #2
0
ファイル: structure.py プロジェクト: Lynn-015/NJU_DMRG
    def show_bonds(self, nth=(1,), plane=(0, 1), color="r"):
        """
        Plot the structure.

        plane:
            project to the specific plane if it is a 3D structre.
            Default is (0,1) - 'x-y' plane.
        nth:
            the n-th nearest bonds are plotted. It should be a tuple.
            Default is (1,) - the nearest neightbor.
        c:
            color, default is 'r' -red.
        """
        nnnbonds = self.__nnnbonds__
        if nnnbonds is None or len(nnnbonds) <= 1:
            warnings.warn("Trivial bonds @Structure.show_bond, give up.")
            return
        for nb in nth:
            bs = nnnbonds[nb]
            show_bonds(bs, start=self.sites[bs.atom1s])