Esempio n. 1
0
File: system.py Progetto: cpoli/tbee
    def change_hopping_square(self, list_hop, xlims, ylims=[-1., 1.]):
        '''
        Change hopping values.

        :param list_hop: List of Dictionary (see set_hopping definition).
        :param xlims: List or Tuple. :math:`x` interval.
        :param ylims: List or Tuple. :math:`y` interval.
        '''
        error_handling.empty_hop(self.hop)
        error_handling.set_hopping(list_hop, self.nmax)
        ind = self.find_square(xlims, ylims)
        self.set_new_hopping(list_hop, ind)
Esempio n. 2
0
    def change_hopping_square(self, list_hop, xlims, ylims=[-1., 1.]):
        '''
        Change hopping values.

        :param list_hop: List of Dictionary (see set_hopping definition).
        :param xlims: List or Tuple. :math:`x` interval.
        :param ylims: List or Tuple. :math:`y` interval.
        '''
        error_handling.empty_hop(self.hop)
        error_handling.set_hopping(list_hop, self.nmax)
        ind = self.find_square(xlims, ylims)
        self.set_new_hopping(list_hop, ind)
Esempio n. 3
0
File: system.py Progetto: cpoli/tbee
    def change_hopping_ellipse(self, list_hop, rx, ry, x0=0., y0=0.):
        '''
        Change hopping values.

        :param list_hop: List of Dictionary (see set_hopping definition).
        :param rx: Positive Float. Radius along :math:`x`. 
        :param ry: Positive Float. Radius along :math:`y`.
        :param x0: Float. Default value 0. :math:`x` center. 
        :param y0: Float. Default value 0. :math:`y` center.
        '''
        error_handling.empty_hop(self.hop)
        error_handling.set_hopping(list_hop, self.nmax)
        error_handling.positive_real(rx, 'rx')
        error_handling.positive_real(ry, 'rx')
        error_handling.real_number(x0, 'x0')
        error_handling.real_number(y0, 'y0')
        ind = self.find_ellipse(rx, ry, x0, y0)
        self.set_new_hopping(list_hop, ind)
Esempio n. 4
0
    def change_hopping_ellipse(self, list_hop, rx, ry, x0=0., y0=0.):
        '''
        Change hopping values.

        :param list_hop: List of Dictionary (see set_hopping definition).
        :param rx: Positive Float. Radius along :math:`x`. 
        :param ry: Positive Float. Radius along :math:`y`.
        :param x0: Float. Default value 0. :math:`x` center. 
        :param y0: Float. Default value 0. :math:`y` center.
        '''
        error_handling.empty_hop(self.hop)
        error_handling.set_hopping(list_hop, self.nmax)
        error_handling.positive_real(rx, 'rx')
        error_handling.positive_real(ry, 'rx')
        error_handling.real_number(x0, 'x0')
        error_handling.real_number(y0, 'y0')
        ind = self.find_ellipse(rx, ry, x0, y0)
        self.set_new_hopping(list_hop, ind)
Esempio n. 5
0
File: system.py Progetto: cpoli/tbee
    def set_hopping(self, list_hop, upper_part=True):
        '''
        Set lattice hoppings.

        :param list_hop: List of Dictionaries.
            Dictionary with keys ('n', 'ang', 'tag', 't') where:
                * 'n' Positive integer, type of hoppings:

                    * 'n': 1 for nearest neighbours.
                    * 'n': 2 for next-nearest neighbours.  
                    * 'n': 3 for next-next-nearest neighbours.  
                    * etc...

                * 'ang' value, float, angle, in deg, of the hoppings. (optional).

                    Hopping angles are given by the method *print_distances*.

                        * If :math:`ang \in[0, 180)`, fill the Hamiltonian upper part.
                        * If :math:`ang \in[-180, 0)`, fill the Hamiltonian lower part.

                * 'tag' binary string of length 2  (optional).

                    Hopping tags.

                * 't' Complex number.

                    Hopping value.

        :param upper_part: Boolean. Default value True. 
            
            * True get hoppings with (:math:`i<j`) *i.e.* fill the Hamiltonian lower part.
            * False get hoppings with (:math:`i>j`) *i.e.* fill the Hamiltonian upper part.

        Example usage::

            # fill upper part:
            sys.set_hopping([{'n': 1, t: 1.}])
            # fill lower part:
            sys.set_hopping([{'n': 1, t: 1.}], upper_part=False)
            # fill upper part: specifying the angles:
            sys.set_hopping([{'n': 1, 'ang': 0., t: 1.}, {'n': 1, 'ang': 90,  t: 2.}])
            # fill lower part:
            sys.set_hopping([{'n': 1, 'ang': -180., t: 1.}, {'n': 1, 'ang': -90,  t: 2.}], upper_part=False)
            # fill upper part: specifying the tags:
            sys.set_hopping([{'n': 1, 'tag': b'ab', t: 1.}, {'n': 1, 'tag': b'ba',  t: 2.}])
            # fill lower part:
            sys.set_hopping([{'n': 1, 'tag': b'ab', t: 1.}, {'n': 1, 'tag': b'ba',  t: 2.}], upper_part=False)
            # fill upper part: specifying the angles and tags:
            sys.set_hopping([{'n': 1, 'ang': 0., 'tag': b'ab', t: 1.}, 
                                        {'n': 1, 'ang': 0., 'tag': b'ba',  t: 2.},
                                        {'n': 1, 'ang': 90., 'tag': b'ab', t: 3.}, 
                                        {'n': 1, 'ang': 90., 'tag': b'ba',  t: 4.}])
            # fill lower part:
            sys.set_hopping([{'n': 1, 'ang': 0., 'tag': b'ab', t: 1.}, 
                                        {'n': 1, 'ang': 0., 'tag': b'ba',  t: 2.},
                                        {'n': 1, 'ang': 90., 'tag': b'ab', t: 3.}, 
                                        {'n': 1, 'ang': 90., 'tag': b'ba',  t: 4.}]), upper_part=False)

        .. note::

            A Hermitian hopping matrix can be build-up only using 
            its upper part OR only using its lower part. The full matrix is then
            automatic built by Hermitian conjugaison. 
            
            If both upper AND lower parts are used to build up the hopping matrix.
            non Hermitian conjugaison is not performed *i.e.* non-Hermitian hopping matrix
            can be built.
        '''
        error_handling.sites(self.lat.sites)
        error_handling.boolean(upper_part, 'upper_part')
        self.get_distances()
        self.nmax = len(self.dist_uni) - 1
        error_handling.set_hopping(list_hop, self.nmax)
        list_n = np.unique([dic['n'] for dic in list_hop])
        # fill, if needed self.store_hop
        self.check_sites()
        for n in list_n:
            if n not in self.store_hop:
                self.fill_store_hop(n)
        # fill self.hop
        for dic in list_hop:
            if len(dic) == 2:
                size = len(self.store_hop[dic['n']])
                if upper_part:
                    mask = (self.hop['n'] == dic['n']) & (self.hop['i'] < self.hop['j'])
                else:
                    mask = (self.hop['n'] == dic['n']) & (self.hop['i'] > self.hop['j'])
                if np.sum(mask):
                    self.hop = self.hop[np.logical_not(mask)]
                ind = np.ones(size, bool)
                hop = self.set_given_hopping(dic['n'], size, dic, ind, upper_part=upper_part)
            elif len(dic) == 3 and 'ang' in dic:
                error_handling.angle(dic['ang'], np.unique(self.store_hop[dic['n']]['ang']), upper_part)
                if dic['ang'] >= 0:
                    ang_store = dic['ang']
                else:
                    ang_store = dic['ang'] + 180.
                size = np.sum(np.isclose(ang_store, self.store_hop[dic['n']]['ang'], atol=ATOL))
                mask = (self.hop['n'] == dic['n']) & np.isclose(self.hop['ang'], dic['ang'], atol=ATOL)
                if np.sum(mask):
                    self.hop = self.hop[np.logical_not(mask)]
                ind = np.isclose(ang_store, self.store_hop[dic['n']]['ang'], atol=ATOL)
                error_handling.index(ind, dic)
                hop = self.set_given_hopping(dic['n'], size, dic, ind, upper_part=upper_part)
            elif len(dic) == 3 and 'tag' in dic:
                if upper_part:
                    tag_store = dic['tag']
                else:
                    tag_store = dic['tag'][::-1]
                size = np.sum(self.store_hop[dic['n']]['tag'] == tag_store)
                mask = (self.hop['n'] == dic['n']) & (self.hop['tag'] == dic['tag'])
                if upper_part:
                    mask = self.hop['n'] == dic['n'] & (self.hop['tag'] == dic['tag']) & (self.hop['i'] < self.hop['j'])
                else:
                    mask = self.hop['n'] == dic['n'] & (self.hop['tag'] == dic['tag']) & (self.hop['i'] > self.hop['j'])
                if np.sum(mask):
                    self.hop = self.hop[np.logical_not(mask)]
                ind = self.store_hop[dic['n']]['tag'] == tag_store
                error_handling.index(ind, dic)
                hop = self.set_given_hopping(dic['n'], size, dic, ind, upper_part=upper_part)
            else:
                error_handling.angle(dic['ang'], np.unique(self.store_hop[dic['n']]['ang']), upper_part=upper_part)
                error_handling.tag(dic['tag'], np.unique(self.store_hop[dic['n']]['tag']))
                if dic['ang'] >= 0:
                    ang_store = dic['ang']
                else:
                    ang_store = dic['ang'] + 180.
                if upper_part:
                    tag_store = dic['tag']
                else:
                    tag_store = dic['tag'][::-1]
                size = np.sum((self.store_hop[dic['n']]['tag'] == tag_store) & 
                                       (np.isclose(ang_store, self.store_hop[dic['n']]['ang'], atol=ATOL)))
                bool1 = (self.hop['n'] == dic['n']) & (self.hop['tag'] == dic['tag'])
                bool2 = np.isclose(self.hop['ang'], dic['ang'], atol=ATOL)
                mask = bool1 & bool2
                if np.sum(mask):
                    self.hop = self.hop[np.logical_not(mask)]
                ind = ((self.store_hop[dic['n']]['tag'] == tag_store) & 
                          (np.isclose(ang_store, self.store_hop[dic['n']]['ang'], atol=1)))
                error_handling.index(ind, dic)
                hop = self.set_given_hopping(dic['n'], size, dic, ind, upper_part=upper_part)
            self.hop = np.concatenate([self.hop, hop])
Esempio n. 6
0
    def set_hopping(self, list_hop, upper_part=True):
        '''
        Set lattice hoppings.

        :param list_hop: List of Dictionaries.
            Dictionary with keys ('n', 'ang', 'tag', 't') where:
                * 'n' Positive integer, type of hoppings:

                    * 'n': 1 for nearest neighbours.
                    * 'n': 2 for next-nearest neighbours.  
                    * 'n': 3 for next-next-nearest neighbours.  
                    * etc...

                * 'ang' value, float, angle, in deg, of the hoppings. (optional).

                    Hopping angles are given by the method *print_distances*.

                        * If :math:`ang \in[0, 180)`, fill the Hamiltonian upper part.
                        * If :math:`ang \in[-180, 0)`, fill the Hamiltonian lower part.

                * 'tag' binary string of length 2  (optional).

                    Hopping tags.

                * 't' Complex number.

                    Hopping value.

        :param upper_part: Boolean. Default value True. 
            
            * True get hoppings with (:math:`i<j`) *i.e.* fill the Hamiltonian lower part.
            * False get hoppings with (:math:`i>j`) *i.e.* fill the Hamiltonian upper part.

        Example usage::

            # fill upper part:
            sys.set_hopping([{'n': 1, t: 1.}])
            # fill lower part:
            sys.set_hopping([{'n': 1, t: 1.}], upper_part=False)
            # fill upper part: specifying the angles:
            sys.set_hopping([{'n': 1, 'ang': 0., t: 1.}, {'n': 1, 'ang': 90,  t: 2.}])
            # fill lower part:
            sys.set_hopping([{'n': 1, 'ang': -180., t: 1.}, {'n': 1, 'ang': -90,  t: 2.}], upper_part=False)
            # fill upper part: specifying the tags:
            sys.set_hopping([{'n': 1, 'tag': b'ab', t: 1.}, {'n': 1, 'tag': b'ba',  t: 2.}])
            # fill lower part:
            sys.set_hopping([{'n': 1, 'tag': b'ab', t: 1.}, {'n': 1, 'tag': b'ba',  t: 2.}], upper_part=False)
            # fill upper part: specifying the angles and tags:
            sys.set_hopping([{'n': 1, 'ang': 0., 'tag': b'ab', t: 1.}, 
                                        {'n': 1, 'ang': 0., 'tag': b'ba',  t: 2.},
                                        {'n': 1, 'ang': 90., 'tag': b'ab', t: 3.}, 
                                        {'n': 1, 'ang': 90., 'tag': b'ba',  t: 4.}])
            # fill lower part:
            sys.set_hopping([{'n': 1, 'ang': 0., 'tag': b'ab', t: 1.}, 
                                        {'n': 1, 'ang': 0., 'tag': b'ba',  t: 2.},
                                        {'n': 1, 'ang': 90., 'tag': b'ab', t: 3.}, 
                                        {'n': 1, 'ang': 90., 'tag': b'ba',  t: 4.}]), upper_part=False)

        .. note::

            A Hermitian hopping matrix can be build-up only using 
            its upper part OR only using its lower part. The full matrix is then
            automatic built by Hermitian conjugaison. 
            
            If both upper AND lower parts are used to build up the hopping matrix.
            non Hermitian conjugaison is not performed *i.e.* non-Hermitian hopping matrix
            can be built.
        '''
        error_handling.sites(self.lat.sites)
        error_handling.boolean(upper_part, 'upper_part')
        self.get_distances()
        self.nmax = len(self.dist_uni) - 1
        error_handling.set_hopping(list_hop, self.nmax)
        list_n = np.unique([dic['n'] for dic in list_hop])
        # fill, if needed self.store_hop
        self.check_sites()
        for n in list_n:
            if n not in self.store_hop:
                self.fill_store_hop(n)
        # fill self.hop
        for dic in list_hop:
            if len(dic) == 2:
                size = len(self.store_hop[dic['n']])
                if upper_part:
                    mask = (self.hop['n']
                            == dic['n']) & (self.hop['i'] < self.hop['j'])
                else:
                    mask = (self.hop['n']
                            == dic['n']) & (self.hop['i'] > self.hop['j'])
                if np.sum(mask):
                    self.hop = self.hop[np.logical_not(mask)]
                ind = np.ones(size, bool)
                hop = self.set_given_hopping(dic['n'],
                                             size,
                                             dic,
                                             ind,
                                             upper_part=upper_part)
            elif len(dic) == 3 and 'ang' in dic:
                error_handling.angle(
                    dic['ang'], np.unique(self.store_hop[dic['n']]['ang']),
                    upper_part)
                if dic['ang'] >= 0:
                    ang_store = dic['ang']
                else:
                    ang_store = dic['ang'] + 180.
                size = np.sum(
                    np.isclose(ang_store,
                               self.store_hop[dic['n']]['ang'],
                               atol=ATOL))
                mask = (self.hop['n'] == dic['n']) & np.isclose(
                    self.hop['ang'], dic['ang'], atol=ATOL)
                if np.sum(mask):
                    self.hop = self.hop[np.logical_not(mask)]
                ind = np.isclose(ang_store,
                                 self.store_hop[dic['n']]['ang'],
                                 atol=ATOL)
                error_handling.index(ind, dic)
                hop = self.set_given_hopping(dic['n'],
                                             size,
                                             dic,
                                             ind,
                                             upper_part=upper_part)
            elif len(dic) == 3 and 'tag' in dic:
                if upper_part:
                    tag_store = dic['tag']
                else:
                    tag_store = dic['tag'][::-1]
                size = np.sum(self.store_hop[dic['n']]['tag'] == tag_store)
                mask = (self.hop['n'] == dic['n']) & (self.hop['tag']
                                                      == dic['tag'])
                if upper_part:
                    mask = self.hop['n'] == dic['n'] & (
                        self.hop['tag']
                        == dic['tag']) & (self.hop['i'] < self.hop['j'])
                else:
                    mask = self.hop['n'] == dic['n'] & (
                        self.hop['tag']
                        == dic['tag']) & (self.hop['i'] > self.hop['j'])
                if np.sum(mask):
                    self.hop = self.hop[np.logical_not(mask)]
                ind = self.store_hop[dic['n']]['tag'] == tag_store
                error_handling.index(ind, dic)
                hop = self.set_given_hopping(dic['n'],
                                             size,
                                             dic,
                                             ind,
                                             upper_part=upper_part)
            else:
                error_handling.angle(dic['ang'],
                                     np.unique(
                                         self.store_hop[dic['n']]['ang']),
                                     upper_part=upper_part)
                error_handling.tag(dic['tag'],
                                   np.unique(self.store_hop[dic['n']]['tag']))
                if dic['ang'] >= 0:
                    ang_store = dic['ang']
                else:
                    ang_store = dic['ang'] + 180.
                if upper_part:
                    tag_store = dic['tag']
                else:
                    tag_store = dic['tag'][::-1]
                size = np.sum((self.store_hop[dic['n']]['tag'] == tag_store)
                              & (np.isclose(ang_store,
                                            self.store_hop[dic['n']]['ang'],
                                            atol=ATOL)))
                bool1 = (self.hop['n'] == dic['n']) & (self.hop['tag']
                                                       == dic['tag'])
                bool2 = np.isclose(self.hop['ang'], dic['ang'], atol=ATOL)
                mask = bool1 & bool2
                if np.sum(mask):
                    self.hop = self.hop[np.logical_not(mask)]
                ind = (
                    (self.store_hop[dic['n']]['tag'] == tag_store) &
                    (np.isclose(
                        ang_store, self.store_hop[dic['n']]['ang'], atol=1)))
                error_handling.index(ind, dic)
                hop = self.set_given_hopping(dic['n'],
                                             size,
                                             dic,
                                             ind,
                                             upper_part=upper_part)
            self.hop = np.concatenate([self.hop, hop])