Exemplo n.º 1
0
def homog_GaNi_full_potential(Agani, Aga, pars):

    N = Agani.N  # double grid number
    dim = N.__len__()

    F = DFT(name='FN', inverse=False, N=N)  # discrete Fourier transform (DFT)
    iF = DFT(name='FiN', inverse=True, N=N)  # inverse DFT

    P = get_preconditioner(N, pars)

    E = np.zeros(dim)
    E[0] = 1  # macroscopic load
    EN = Tensor(name='EN', N=N, shape=(dim, ),
                Fourier=False)  # constant trig. pol.
    EN.set_mean(E)

    def DFAFGfun(X):
        assert (X.Fourier)
        FAX = F(Agani * iF(grad(X)))
        return -div(FAX)

    B = div(F(Agani(EN)))
    x0 = Tensor(N=N, shape=(),
                Fourier=True)  # initial approximation to solvers

    PDFAFGPfun = lambda Fx: P * DFAFGfun(P * Fx)
    PB = P * B
    tic = Timer(name='CG (potential)')
    iPU, info = linear_solver(solver='CG',
                              Afun=PDFAFGPfun,
                              B=PB,
                              x0=x0,
                              par=pars.solver,
                              callback=None)
    tic.measure()
    print(('iterations of CG={}'.format(info['kit'])))
    print(('norm of residuum={}'.format(info['norm_res'])))

    Fu = P * iPU
    if Aga is None:  # GaNi homogenised properties
        print('!!!!! homogenised properties are GaNi only !!!!!')
        XEN = iF(grad(Fu)) + EN
        AH = Agani(XEN) * XEN
    else:
        Nbar = 2 * np.array(N) - 1
        iF2 = DFT(name='FiN', inverse=True, N=Nbar)  # inverse DFT
        XEN = iF2(grad(Fu).project(Nbar)) + EN.project(Nbar)
        AH = Aga(XEN) * XEN

    return Struct(AH=AH, Fu=Fu, info=info, time=tic.vals[0][0], pars=pars)
Exemplo n.º 2
0
Fourier coefficients of phi
Fphi = FN*phi = FN(phi) =""")
Fphi = FN*phi
print(Fphi)
print("Fphi.val =")
print(Fphi.val)

print("""
In order to create a plot of this polynomial, it is
evaluated on a fine grid sizing
M = 16*N =""")
M = 16*N
print(M)

print("phi_fine = phi.project(M) =")
phi_fine = phi.project(M)
print(phi_fine)
print("""The procedure is provided by VecTri.enlarge(M) function, which consists of
a calculation of Fourier coefficients, putting zeros to Fourier coefficients
with high frequencies, and inverse FFT that evaluates the polynomial on
a fine grid.
""")


print("""In order to plot this polynomial, we also set a size of a cell
Y =""")
Y = np.ones(d) # size of a cell
print(Y)
print(""" and evaluate the coordinates of grid points, which are stored in
numpy.ndarray of following shape:
coord.shape =""")
Exemplo n.º 3
0
Fourier coefficients of phi
Fphi = FN*phi = FN(phi) =""")
Fphi = FN * phi
print(Fphi)
print("Fphi.val =")
print(Fphi.val)

print("""
In order to create a plot of this polynomial, it is
evaluated on a fine grid sizing
M = 16*N =""")
M = 16 * N
print(M)

print("phi_fine = phi.project(M) =")
phi_fine = phi.project(M)
print(phi_fine)
print(
    """The procedure is provided by VecTri.enlarge(M) function, which consists of
a calculation of Fourier coefficients, putting zeros to Fourier coefficients
with high frequencies, and inverse FFT that evaluates the polynomial on
a fine grid.
""")

print("""In order to plot this polynomial, we also set a size of a cell
Y =""")
Y = np.ones(d)  # size of a cell
print(Y)
print(""" and evaluate the coordinates of grid points, which are stored in
numpy.ndarray of following shape:
coord.shape =""")