コード例 #1
0
ファイル: prism4.py プロジェクト: sofiasanz/sisl
    def __init__(self, v, center=None, origin=None):

        v = _a.asarrayd(v)
        if v.size == 1:
            self._v = np.identity(3) * v  # a "Euclidean" cube
        elif v.size == 3:
            self._v = np.diag(v.ravel())  # a "Euclidean" rectangle
        elif v.size == 9:
            self._v = v.reshape(3, 3).astype(np.float64)
        else:
            raise ValueError(
                f"{self.__class__.__name__} requires initialization with 3 vectors defining the cuboid"
            )

        if center is not None and origin is not None:
            raise ValueError(
                f"{self.__class__.__name__} only allows either origin or center argument"
            )
        elif origin is not None:
            center = self._v.sum(0) / 2 + origin

        # initialize the center
        super().__init__(center)

        # Create the reciprocal cell
        self._iv = inv(self._v)
コード例 #2
0
def test_inv1():
    np.random.seed(1204982)
    a = np.random.rand(10, 10)
    ac = a.copy()
    xs = sl.inv(a)
    x = inv(a)
    assert np.allclose(xs, x)
    assert np.allclose(a, ac)
コード例 #3
0
ファイル: prism4.py プロジェクト: silsgs/sisl
    def __init__(self, v, center=None):
        super(Cuboid, self).__init__(center)
        v = _a.asarrayd(v)
        if v.size == 1:
            self._v = np.identity(3) * v # a "Euclidean" cube
        elif v.size == 3:
            self._v = np.diag(v.ravel()) # a "Euclidean" rectangle
        elif v.size == 9:
            self._v = v.reshape(3, 3).astype(np.float64)
        else:
            raise ValueError(self.__class__.__name__ + " requires initialization with 3 vectors defining the cuboid")

        # Create the reciprocal cell
        self._iv = inv(self._v)
コード例 #4
0
ファイル: self_energy.py プロジェクト: fyalcin/sisl
                def _calc_green(k, no, tile, idx0):
                    Gf, A2 = SE(E, k, dtype=dtype, bulk=True) # A1 == Gf, because of memory usage
                    tY = M1Sk(k, dtype=dtype, format='array') # S
                    tX = M1Pk(k, dtype=dtype, format='array') # H
                    B = tY * E - tX
                    # C = _conj(tY.T) * E - _conj(tX.T)

                    tY = solve(Gf, conjugate(tY.T) * E - conjugate(tX.T), True, True)
                    Gf = inv(A2 - dot(B, tY), True)
                    tX = solve(A2, B, True, True)

                    G = empty([tile, no, tile, no], dtype=dtype)
                    G[idx0, :, idx0, :] = Gf.reshape(1, no, no)
                    for i in range(1, tile):
                        G[idx0[i:], :, idx0[:-i], :] = - dot(tX, G[i-1, :, 0, :]).reshape(1, no, no)
                        G[idx0[:-i], :, idx0[i:], :] = - dot(tY, G[0, :, i-1, :]).reshape(1, no, no)
                    return G.reshape(tile * no, -1)
コード例 #5
0
ファイル: self_energy.py プロジェクト: fyalcin/sisl
                def _calc_green(k, no, tile, idx0):
                    # Calculate left/right self-energies
                    Gf, A2 = SE(E, k, dtype=dtype, bulk=True) # A1 == Gf, because of memory usage
                    B = - M1Pk(k, dtype=dtype, format='array')
                    # C = conjugate(B.T)

                    tY = solve(Gf, conjugate(B.T), True, True)
                    Gf = inv(A2 - dot(B, tY), True)
                    tX = solve(A2, B, True, True)

                    # Since this is the pristine case, we know that
                    # G11 and G22 are the same:
                    #  G = [A1 - C.tX]^-1 == [A2 - B.tY]^-1

                    G = empty([tile, no, tile, no], dtype=dtype)
                    G[idx0, :, idx0, :] = Gf.reshape(1, no, no)
                    for i in range(1, tile):
                        G[idx0[i:], :, idx0[:-i], :] = - dot(tX, G[i-1, :, 0, :]).reshape(1, no, no)
                        G[idx0[:-i], :, idx0[i:], :] = - dot(tY, G[0, :, i-1, :]).reshape(1, no, no)
                    return G.reshape(tile * no, -1)
コード例 #6
0
ファイル: self_energy.py プロジェクト: fyalcin/sisl
    def self_energy(self, E, bulk=False, coupling=False, dtype=None):
        r""" Calculate the real-space self-energy

        The real space self-energy is calculated via:

        .. math::
            \boldsymbol\Sigma^{\mathcal{R}}(E) = \mathbf S^{\mathcal{R}} E - \mathbf H^{\mathcal{R}}
               - \sum_{\mathbf k} \mathbf G_{\mathbf k}(E)

        Parameters
        ----------
        E : float/complex
           energy to evaluate the real-space self-energy at
        bulk : bool, optional
           if true, :math:`\mathbf S^{\mathcal{R}} E - \mathbf H^{\mathcal{R}} - \boldsymbol\Sigma^\mathcal{R}`
           is returned, otherwise :math:`\boldsymbol\Sigma^\mathcal{R}` is returned
        dtype : numpy.dtype, optional
          the resulting data type, default to ``np.complex128``
        coupling: bool, optional
           if True, only the self-energy terms located on the coupling geometry (`coupling_geometry`)
           are returned
        """
        if dtype is None:
            dtype = complex128
        if E.imag == 0:
            E = E.real + 1j * self._options['eta']
        invG = inv(self.green(E, dtype=dtype), True)
        if coupling:
            orbs = self._calc['orbs']
            if bulk:
                return invG[orbs, orbs.T]
            return ((self._calc['S0'] * E - self._calc['P0']).astype(dtype, copy=False).toarray() - invG)[orbs, orbs.T]
        else:
            if bulk:
                return invG
            return (self._calc['S0'] * E - self._calc['P0']).astype(dtype, copy=False).toarray() - invG
コード例 #7
0
 def test_rcell(self, setup):
     # LAPACK inverse algorithm implicitly does
     # a transpose.
     rcell = lin.inv(setup.sc.cell) * 2. * np.pi
     assert np.allclose(rcell.T, setup.sc.rcell)
     assert np.allclose(rcell.T / (2 * np.pi), setup.sc.icell)
コード例 #8
0
ファイル: self_energy.py プロジェクト: fyalcin/sisl
 def _calc_green(k, no, tile, idx0):
     SL, SR = SE(E, k, dtype=dtype)
     return inv(M0Sk(k, dtype=dtype, format='array') * E - M0Pk(k, dtype=dtype, format='array') - SL - SR, True)