def ext_helmholtz_convg(qbx_order, k): """ Tests external Helmholtz solution by placing monopoles inside domain """ alpha = k # CFIE parameter sp, dp, qbx_exp_slp, qbx_exp_dlp, _, _, _, _ = eval_sp_dp_QBX(qbx_order, k) xs = 0.75 ys = 1.75 test_targets = np.array([[-1, 0], [4, 0], [0, -1], [0, 4]]).T # test_targets = np.array([[-5, 0], [5, 0], [0, -5], [0, 5]]).T exact_test = sp(test_targets[0], test_targets[1], xs, ys) plotset() n_panels = np.arange(10, 60, 5) convg_err = [] for n in n_panels: domain = QuadratureInfo(n, show_bound=0) rhs = sp(domain.curve_nodes[0], domain.curve_nodes[1], xs, ys) soln = bvp(n, k, domain, alpha, qbx_exp_slp, qbx_exp_dlp, rhs) num_test = eval_target( test_targets, domain.curve_nodes, domain.curve_weights, domain.normals, soln, sp, dp, alpha, ) er = la.norm( np.abs(num_test - exact_test) / la.norm(np.abs(exact_test))) convg_err.append(er) plt.figure(1) plt.loglog(n_panels, np.array(convg_err), "-o", label="QBX" + str(qbx_order)) plt.loglog( n_panels, 5e4 * np.power(n_panels.astype(float), -qbx_order - 1), label="$N^{-5}$", ) plt.loglog(n_panels, 2e3 * np.power(n_panels.astype(float), -qbx_order), label="$N^{-4}$") title = "Helmholtz exterior problem: target evaluation convergence" plt.xlabel("Number of panels", size=25) plt.ylabel("$|u - u_e| / |u_e|$", size=25) plt.title(title, size=25) plt.legend(loc="upper right", ncol=1, frameon=True) plt.show() slope, _, _, _, _ = stats.linregress(np.log(n_panels), np.log(np.array(convg_err))) print(slope)
def main(): k = 10 alpha = k # CFIE parameter sp, dp, qbx_exp_slp, qbx_exp_dlp, _, _, _, _ = eval_sp_dp_QBX(4, k) npanels = 30 domain = QuadratureInfo(npanels, show_bound=1) xs = 0.75 ys = 1.75 tg_size = 101 x = np.linspace(-2, 5, tg_size) y = np.linspace(-2, 5, tg_size) X, Y = np.meshgrid(x, y) test_targets = np.array((X.reshape(-1), Y.reshape(-1))) rhs = sp(domain.curve_nodes[0], domain.curve_nodes[1], xs, ys) soln1 = bvp(npanels, k, domain, alpha, qbx_exp_slp, qbx_exp_dlp, rhs) num_test = eval_target( test_targets, domain.curve_nodes, domain.curve_weights, domain.normals, soln1, sp, dp, alpha, ).reshape(tg_size, -1) exact_test = sp(test_targets[0], test_targets[1], xs, ys).reshape(tg_size, -1) err = np.abs(num_test - exact_test) / np.abs(exact_test) # plt.contourf(X, Y, np.real(exact_test), cmap='magma', levels=100) v = np.linspace(-0.15, 0.15, 100, endpoint=True) plt.figure(1) plt.contourf(X, Y, np.real(num_test), v, cmap="twilight") plt.plot(xs, ys, "ro") plt.fill(domain.curve_nodes[0], domain.curve_nodes[1], "w") show_targets = np.array([[-1, 0], [4, 0], [0, -1], [0, 4]]).T plt.plot(show_targets[0], show_targets[1], "go") plt.xlabel("X", size=10) plt.ylabel("Y", size=10) plt.colorbar() plt.figure(2) plt.contourf(X, Y, np.log10(err), cmap="magma", levels=200) plt.fill(domain.curve_nodes[0], domain.curve_nodes[1], "w") plt.plot(xs, ys, "ro") plt.plot(show_targets[0], show_targets[1], "go") plt.xlabel("X", size=10) plt.ylabel("Y", size=10) plt.colorbar() plt.show()
npanels = 30 domain = QuadratureInfo(npanels, show_bound=1) som_sp, som_dp = sommerfeld(k, beta, interval, "far") imgs = Images_Integral(m, beta, img_sp, img_dp) # finding the source response and solving bvp inc = sp(domain.curve_nodes[0], domain.curve_nodes[1], xs, ys) som_rhs = som_sp(domain.curve_nodes[0], domain.curve_nodes[1], xs, ys) imag_sp_rhs, _ = imgs.eval_integral(domain.curve_nodes, (xs, ys), 0.0, 0.0) rhs = -(inc + som_rhs + imag_sp_rhs) soln1 = bvp( npanels, k, domain, alpha, qbx_exp_slp, qbx_exp_dlp, rhs, som_sp=som_sp, som_dp=som_dp, imgs=imgs, ) # evaluating at target locations tg_size = 51 x = np.linspace(-4, 4, tg_size) y = np.linspace(0, 8, tg_size) X, Y = np.meshgrid(x, y) test_targets = np.array((X.reshape(-1), Y.reshape(-1))) exact_test = (sp(test_targets[0], test_targets[1], xs, ys)).reshape(tg_size, -1) som_test = som_sp(test_targets[0], test_targets[1], xs,
from kernels import eval_sp_dp_QBX, eval_target, bvp, sommerfeld plt.gca().set_aspect("equal") xs = -3 ys = 0 k = 10 alpha = k # CFIE parameter (sp, dp, qbx_exp_slp, qbx_exp_dlp, img_sp, img_dp, _, _) = eval_sp_dp_QBX(4, k) npanels = 30 domain = QuadratureInfo(npanels, show_bound=1) # finding the source response and solving bvp inc = sp(domain.curve_nodes[0], domain.curve_nodes[1], xs, ys) rhs = -(inc) soln1 = bvp(npanels, k, domain, alpha, qbx_exp_slp, qbx_exp_dlp, rhs) # evaluating at target locations tg_size = 101 x = np.linspace(-5, 5, tg_size) y = np.linspace(-3, 7, tg_size) X, Y = np.meshgrid(x, y) test_targets = np.array((X.reshape(-1), Y.reshape(-1))) exact_test = (sp(test_targets[0], test_targets[1], xs, ys)).reshape(tg_size, -1) num_test = eval_target( test_targets, domain.curve_nodes, domain.curve_weights, domain.normals, soln1,