print('# ------------ in the time-mesh circle ------------ #')
    print('i = ', i)
    print('# -------------------------------------------------- #')
    # NN = int(1./h_space[i]) + 1
    NN = 128
    print('    In new looping, NN = ', NN)
    mesh = MF.boxmesh2d(box, nx=NN, ny=NN, meshtype='tri')
    if time_scheme == 1:
        ch = FEM_CH_NS_Var_addXi_Model2d(pde, mesh, p, dt_space[i])
        uh_l2err, uh_h1err, vel_l2err, vel_h1err, ph_l2err = ch.CH_NS_addXi_Solver_T1stOrder(
        )
    else:
        raise ValueError("There has no other time-scheme")

    Ndof[i] = ch.number_of_global_dofs()
    errorMatrix[0, i] = uh_l2err
    errorMatrix[1, i] = uh_h1err
    errorMatrix[2, i] = vel_l2err
    errorMatrix[3, i] = vel_h1err
    errorMatrix[4, i] = ph_l2err

# --- get the convergence rate --- #
print('# ------------ the error-table ------------ #')
show_error_table(dt_space, errorType, errorMatrix, table_scheme='dt')

# # plot the rate
# showmultirate(plt, 0, Ndof, errorMatrix, errorType)
# plt.show()

print('# ------------ end of the file ------------ #')
    )
    print('# ------------ in the time-mesh circle ------------ #')
    print('i = ', i)
    print('# -------------------------------------------------- #')
    NN = int(
        (box[1] - box[0]) / h_space[i])  # TODO: NN = int(1./h_space[i]) ??
    mesh = MF.boxmesh2d(box, nx=NN, ny=NN, meshtype='tri')
    ch = FEM_CH_NS_VarCoeff_Model2d(pde, mesh, p, dt_space)
    if time_scheme == 1:
        uh_l2err, uh_h1err, vel_l2err, vel_h1err, ph_l2err = ch.CH_NS_Solver_T1stOrder(
        )
    else:
        raise ValueError("There has no other time-scheme")

    Ndof[i] = ch.number_of_global_dofs()
    errorMatrix[0, i] = uh_l2err
    errorMatrix[1, i] = uh_h1err
    errorMatrix[2, i] = vel_l2err
    errorMatrix[3, i] = vel_h1err
    errorMatrix[4, i] = ph_l2err

# --- get the convergence rate --- #
print('# ------------ the error-table ------------ #')
show_error_table(Ndof, errorType, errorMatrix, table_scheme='h')

# # plot the rate
# showmultirate(plt, 0, Ndof, errorMatrix, errorType)
# plt.show()

print('# ------------ end of the file ------------ #')
# # error settings
# errorType = ['$|| u - u_h||_0$', '$||\\nabla u - \\nabla u_h||_0$', '|| p - p_h ||_0']
errorType = ['$|| u - u_h||_0$', '$||\\nabla u - \\nabla u_h||_0$']
errorMatrix = np.zeros((len(errorType), maxit), dtype=np.float)

Ndof = np.zeros(maxit, dtype=np.int)  # the array to store the number of dofs

# --- start for-loop --- #
for i in range(maxit):
    print('# ------------ in the space-mesh circle ------------ #')
    print('i = ', i)
    print('# -------------------------------------------------- #')
    ch = FEMCahnHilliardModel2d(pde, mesh, p, dt)
    l2err, h1err = ch.CH_Solver_T1stOrder()
    # l2err, h1err = ch.CH_Solver_T2ndOrder()
    Ndof[i] = ch.space.number_of_global_dofs()  # get the number of dofs
    errorMatrix[0, i] = l2err  # get the velocity L2 error
    errorMatrix[1, i] = h1err  # get the velocity L2 error
    if i < maxit - 1:
        mesh.uniform_refine()

# --- get the convergence rate --- #
print('# ------------ the error-table ------------ #')
show_error_table(Ndof, errorType, errorMatrix)

# # plot the rate
# showmultirate(plt, 0, Ndof, errorMatrix, errorType)
# plt.show()

print('# ------------ end of the file ------------ #')
示例#4
0
print('dt_space = ', dt_space)
print('domain box = ', box)
print('the initial-mesh subdivision = ', NN)
print('# #')

# # error settings
# errorType = ['$|| u - u_h||_0$', '$||\\nabla u - \\nabla u_h||_0$', '|| p - p_h ||_0']
errorType = ['$|| u - u_h||_0$', '$||\\nabla u - \\nabla u_h||_0$']
errorMatrix = np.zeros((len(errorType), maxit), dtype=np.float)

# --- start for-loop --- #
for i in range(N_T):
    print('# ------------ in the time-mesh circle ------------ #')
    print('i = ', i)
    print('# -------------------------------------------------- #\n')
    ch = FEMCahnHilliardModel2d(pde, mesh, p, dt_space[i])
    l2err, h1err = ch.CH_Solver_T1stOrder()
    # l2err, h1err = ch.CH_Solver_T2ndOrder()
    errorMatrix[0, i] = l2err  # get the velocity L2 error
    errorMatrix[1, i] = h1err  # get the velocity L2 error

# --- get the convergence rate --- #
print('# ------------ the error-table ------------ #')
show_error_table(dt_space, errorType, errorMatrix)

# # plot the rate
# showmultirate(plt, 0, Ndof, errorMatrix, errorType)
# plt.show()

print('# ------------ end of the file ------------ #')