form_b2c=False)
qfs3 = QFS_Evaluator(new_ebdyc.ebdys[0].bdy_qfs,
                     True, [
                         Singular_SLP3,
                     ],
                     Naive_SLP3,
                     on_surface=True,
                     form_b2c=False)
A1 = s1_singular(new_ebdyc.ebdys[0].bdy) - half_eye(new_ebdyc.ebdys[0].bdy)
A2 = s2_singular(new_ebdyc.ebdys[0].bdy) - half_eye(new_ebdyc.ebdys[0].bdy)
A3 = s3_singular(new_ebdyc.ebdys[0].bdy) - half_eye(new_ebdyc.ebdys[0].bdy)
A1_lu = sp.linalg.lu_factor(A1)
A2_lu = sp.linalg.lu_factor(A2)
A3_lu = sp.linalg.lu_factor(A3)
solver1 = ModifiedHelmholtzSolver(new_ebdyc,
                                  solver_type=solver_type,
                                  k=first_helmholtz_k)
solver2 = ModifiedHelmholtzSolver(new_ebdyc,
                                  solver_type=solver_type,
                                  k=second_helmholtz_k)
solver3 = ModifiedHelmholtzSolver(new_ebdyc,
                                  solver_type=solver_type,
                                  k=third_helmholtz_k)

while t < max_time - 1e-10:

    # step of the first order method to get things started
    if t == 0:
        c_new = c.copy()
        c_new_update = solver1(c_new / first_zeta, tol=1e-12, verbose=True)
        bvn = solver1.get_boundary_normal_derivatives(
Esempio n. 2
0
force_func = lambda x, y: helmholtz_k**2 * solution_func(x, y) - k**2 * np.exp(
    np.sin(k * x)) * np.sin(k * y) * (np.cos(k * x)**2 - np.sin(k * x) - 1.0)
f = force_func(grid.xg, grid.yg)
frs = [force_func(ebdy.radial_x, ebdy.radial_y) for ebdy in ebdys]
ua = solution_func(grid.xg, grid.yg)
uars = [solution_func(ebdy.radial_x, ebdy.radial_y) for ebdy in ebdys]
all_nx = np.concatenate([ebdy.bdy.normal_x for ebdy in ebdys])
all_ny = np.concatenate([ebdy.bdy.normal_y for ebdy in ebdys])
bcs2v = solution_func_n(ebdyc.all_bvx, ebdyc.all_bvy, all_nx, all_ny)
bcs2l = ebdyc.v2l(bcs2v)

################################################################################
# Setup Poisson Solver

print('Creating inhomogeneous solver')
solver = ModifiedHelmholtzSolver(ebdyc, solver_type=solver_type, k=helmholtz_k)
print('Solving inhomogeneous problem')
ue, uers = solver(f, frs, tol=1e-12, verbose=verbose)

print('Solving homogeneous problem')


# this isn't correct yet because we haven't applied boundary conditions
def two_d_split(MAT, hsplit, vsplit):
    vsplits = np.vsplit(MAT, vsplit)
    return [np.hsplit(vsplit, hsplit) for vsplit in vsplits]


Ns = [ebdy.bdy.N for ebdy in ebdyc.ebdys]
CNs = np.cumsum(Ns)
CN = CNs[:-1]
# 	for i in range(6):
# 		out += 2**(2*i)*solution_func_i(x, y, i)
# 	return out + 2**2*solution_func(x, y)
f = force_func(ebdy.grid.xg, ebdy.grid.yg) * ebdy.phys
frs = [force_func(ebdy.radial_x, ebdy.radial_y) for ebdy in ebdys]
ua = solution_func(ebdy.grid.xg, ebdy.grid.yg) * ebdy.phys
uars = [solution_func(ebdy.radial_x, ebdy.radial_y) for ebdy in ebdys]
uar = uars[0]
bcs2v = solution_func(ebdyc.all_bvx, ebdyc.all_bvy)
bcs2l = ebdyc.v2l(bcs2v)

################################################################################
# Setup Poisson Solver

# THE TWO IMPORTANT LINES
solver = ModifiedHelmholtzSolver(ebdyc, solver_type=solver_type, k=helmholtz_k)
ue, uers = solver(f, frs, tol=1e-15, verbose=verbose)

uer = uers[0]
mue = np.ma.array(ue, mask=ebdy.ext)

if False:
    fig, ax = plt.subplots()
    ax.pcolormesh(grid.xg, grid.yg, mue)
    ax.plot(ebdy.bdy.x, ebdy.bdy.y, color='black', linewidth=3)
    ax.plot(ebdy.interface.x, ebdy.interface.y, color='white', linewidth=3)

# this isn't correct yet because we haven't applied boundary conditions
A = bdy.Modified_Helmholtz_DLP_Self_Form(
    k=helmholtz_k) - 0.5 * np.eye(bdy.N) * helmholtz_k**2
bv = solver.get_boundary_values(uers)
Esempio n. 4
0
    ch = ebdy.interpolate_to_points(c - dt * scaled_nonlinearity(c),
                                    xd_all,
                                    yd_all,
                                    danger_zone=new_ebdy.in_danger_zone,
                                    gi=new_ebdy.guess_inds)
    # set the grid values
    c_new.grid_value[new_ebdyc.phys_not_in_annulus] = ch[:gp.N]
    # set the radial values
    c_new.radial_value_list[0][:] = ch[gp.N:].reshape(ebdy.radial_shape)
    # overwrite under grid under annulus by radial grid
    _ = new_ebdyc.interpolate_radial_to_grid(c_new.radial_value_list,
                                             c_new.grid_value)

    # now solve diffusion equation
    solver = ModifiedHelmholtzSolver(new_ebdyc,
                                     solver_type='spectral',
                                     k=helmholtz_k)
    c_new_update = solver(c_new / zeta, tol=1e-12, verbose=False)
    A = s_singular(new_ebdyc.ebdys[0].bdy) - half_eye(new_ebdyc.ebdys[0].bdy)
    bvn = solver.get_boundary_normal_derivatives(
        c_new_update.radial_value_list)
    tau = np.linalg.solve(A, bvn)
    qfs = QFS_Evaluator(new_ebdyc.ebdys[0].bdy_qfs,
                        True, [
                            Singular_SLP,
                        ],
                        Naive_SLP,
                        on_surface=True,
                        form_b2c=False)
    sigma = qfs([
        tau,
Esempio n. 5
0
solution_func = lambda x, y: np.exp(np.sin(k * x)) * np.sin(k * y)
force_func = lambda x, y: helmholtz_k**2 * solution_func(x, y) - k**2 * np.exp(
    np.sin(k * x)) * np.sin(k * y) * (np.cos(k * x)**2 - np.sin(k * x) - 1.0)
f = force_func(grid.xg, grid.yg)
frs = [force_func(ebdy.radial_x, ebdy.radial_y) for ebdy in ebdys]
ua = solution_func(grid.xg, grid.yg)
uars = [solution_func(ebdy.radial_x, ebdy.radial_y) for ebdy in ebdys]
bcs2v = solution_func(ebdyc.all_bvx, ebdyc.all_bvy)
bcs2l = ebdyc.v2l(bcs2v)

################################################################################
# Setup Poisson Solver

st = time.time()
solver = ModifiedHelmholtzSolver(ebdyc, solver_type=solver_type, k=helmholtz_k)
print('Time for first solver construction {:0.2f}'.format(
    (time.time() - st) * 1000))
st = time.time()
solver = ModifiedHelmholtzSolver(ebdyc,
                                 solver_type=solver_type,
                                 k=helmholtz_k,
                                 AS_list=solver.AS_list)
print('Time for second solver construction {:0.2f}'.format(
    (time.time() - st) * 1000))
st = time.time()
ue, uers = solver(f, frs, tol=1e-14, verbose=verbose, maxiter=100, restart=20)
print('Time to solve {:0.2f}'.format((time.time() - st) * 1000))


# this isn't correct yet because we haven't applied boundary conditions
Esempio n. 6
0
y_tracers = []
ts = []

new_ebdyc = ebdyc

qfs0 = QFS_Evaluator(new_ebdyc.ebdys[0].bdy_qfs,
                     True, [
                         Singular_SLP0,
                     ],
                     Naive_SLP0,
                     on_surface=True,
                     form_b2c=False)
A0 = s0_singular(new_ebdyc.ebdys[0].bdy) - half_eye(new_ebdyc.ebdys[0].bdy)
A0_lu = sp.linalg.lu_factor(A0)
solver0 = ModifiedHelmholtzSolver(new_ebdyc,
                                  solver_type=solver_type,
                                  k=zero_helmholtz_k)

qfs1 = QFS_Evaluator(new_ebdyc.ebdys[0].bdy_qfs,
                     True, [
                         Singular_SLP1,
                     ],
                     Naive_SLP1,
                     on_surface=True,
                     form_b2c=False)
A1 = s1_singular(new_ebdyc.ebdys[0].bdy) - half_eye(new_ebdyc.ebdys[0].bdy)
A1_lu = sp.linalg.lu_factor(A1)
solver1 = ModifiedHelmholtzSolver(new_ebdyc,
                                  solver_type=solver_type,
                                  k=first_helmholtz_k)