Ejemplo n.º 1
0
def get_weights_circ(r, Nbar, Y):
    """
    it evaluates integral weights,
    which are used for upper-lower bounds calculation,
    with constant circular inclusion

    Parameters
    ----------
        r - the parameter determining the size of inclusion
        Nbar - no. of points of regular grid where the weights are evaluated
        Y - the size of periodic unit cell
    Returns
    -------
        Wphi - integral weights at regular grid sizing Nbar
    """
    d = np.size(Y)
    ZN2l = Grid.get_ZNl(Nbar)
    meas_puc = np.prod(Y)
    circ = 0
    for m in np.arange(d):
        Nshape = np.ones(d)
        Nshape[m] = Nbar[m]
        Nrep = np.copy(Nbar)
        Nrep[m] = 1
        xi_p2 = np.tile(np.reshape((ZN2l[m]/Y[m])**2, Nshape), Nrep)
        circ += xi_p2
    circ = circ**0.5
    ind = tuple(np.round(Nbar/2))
    circ[ind] = 1.

    Wphi = r**2 * sp.jn(1, 2*np.pi*circ*r) / (circ*r)
    Wphi[ind] = np.pi*r**2
    Wphi = Wphi / meas_puc
    return Wphi
Ejemplo n.º 2
0
def get_weights_circ(r, Nbar, Y):
    """
    it evaluates integral weights,
    which are used for upper-lower bounds calculation,
    with constant circular inclusion

    Parameters
    ----------
        r - the parameter determining the size of inclusion
        Nbar - no. of points of regular grid where the weights are evaluated
        Y - the size of periodic unit cell
    Returns
    -------
        Wphi - integral weights at regular grid sizing Nbar
    """
    d = np.size(Y)
    ZN2l = Grid.get_ZNl(Nbar)
    meas_puc = np.prod(Y)
    circ = 0
    for m in np.arange(d):
        Nshape = np.ones(d)
        Nshape[m] = Nbar[m]
        Nrep = np.copy(Nbar)
        Nrep[m] = 1
        xi_p2 = np.tile(np.reshape((ZN2l[m] / Y[m])**2, Nshape), Nrep)
        circ += xi_p2
    circ = circ**0.5
    ind = tuple(np.round(Nbar / 2))
    circ[ind] = 1.

    Wphi = r**2 * sp.jn(1, 2 * np.pi * circ * r) / (circ * r)
    Wphi[ind] = np.pi * r**2
    Wphi = Wphi / meas_puc
    return Wphi
Ejemplo n.º 3
0
def get_shift_inclusion(N, h, Y):
    N = np.array(N, dtype=np.int32)
    Y = np.array(Y, dtype=np.float64)
    dim = N.size
    ZN = Grid.get_ZNl(N)
    SS = np.ones(N, dtype=np.complex128)
    for ii in np.arange(dim):
        Nshape = np.ones(dim)
        Nshape[ii] = N[ii]
        Nrep = N
        Nrep[ii] = 1
        SS *= np.tile(np.reshape(np.exp(-2*np.pi*1j*(h[ii]*ZN[ii]/Y[ii])),
                                 Nshape), Nrep)
    return SS
Ejemplo n.º 4
0
def get_shift_inclusion(N, h, Y):
    N = np.array(N, dtype=np.int32)
    Y = np.array(Y, dtype=np.float64)
    dim = N.size
    ZN = Grid.get_ZNl(N)
    SS = np.ones(N, dtype=np.complex128)
    for ii in np.arange(dim):
        Nshape = np.ones(dim)
        Nshape[ii] = N[ii]
        Nrep = N
        Nrep[ii] = 1
        SS *= np.tile(
            np.reshape(np.exp(-2 * np.pi * 1j * (h[ii] * ZN[ii] / Y[ii])),
                       Nshape), Nrep)
    return SS
Ejemplo n.º 5
0
    def matrix(self):
        """
        This function returns the object as a matrix of DFT or iDFT resp.
        """
        prodN = np.prod(self.N)
        proddN = self.d*prodN
        DTM = np.zeros(np.hstack([self.N, self.N]), dtype=np.complex128)
        ZNl = Grid.get_ZNl(self.N)

        if not self.inverse:
            coef = 1./np.prod(self.N)
        else:
            coef = np.prod(self.N)

        for nx in ZNl[0]:
            for ny in ZNl[1]:
                IM = np.zeros(np.array(self.N), dtype=np.float64)
                IM[nx, ny] = 1
                DTM[nx, ny, :, :] = coef*DFT.fftnc(IM, self.N)
        import numpy.matlib as npmatlib
        DTMd = npmatlib.zeros([proddN, proddN], dtype=np.complex128)
        for ii in np.arange(self.d):
            DTMd[prodN*ii:prodN**(ii+1), prodN*ii:prodN**(ii+1)] = DTM
        return DTMd