v1 = paraBEM.PanelVector2(-2, 0) v2 = paraBEM.PanelVector2(2, 0) panel = paraBEM.Panel2([v1, v2]) n = 500 space = np.linspace(-5, 5, n) grid = [paraBEM.Vector2([x, y]) for y in space for x in space] dub_vals = [doublet_2_0(target, panel) for target in grid] dub_vals_lin_1 = [doublet_2_1(target, panel, True) for target in grid] dub_vals_lin_2 = [doublet_2_1(target, panel, False) for target in grid] src_vals = [source_2_0(target, panel) for target in grid] dublinv1_vals = [doublet_2_1_v(target, panel, True) for target in grid] dublinv2_vals = [doublet_2_1_v(target, panel, False) for target in grid] dubv_vals = [doublet_2_0_v(target, panel) for target in grid] srcv_vals = [source_2_0_v(target, panel) for target in grid] writer = VtkWriter() with open(check_path("results/element_2.vtk"), "w") as _file: writer.structed_grid(_file, "element_2", [n, n, 1]) writer.points(_file, grid) writer.data(_file, dub_vals, name="doublet", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, dub_vals_lin_1, name="doublet_lin_1", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, dub_vals_lin_2, name="doublet_lin_2", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, src_vals, name="source", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, dublinv1_vals, name="doublet_lin_1_v", _type="VECTORS", data_type="POINT_DATA") writer.data(_file, dublinv2_vals, name="doublet_lin_2_v", _type="VECTORS", data_type="POINT_DATA") writer.data(_file, dubv_vals, name="doublet_v", _type="VECTORS", data_type="POINT_DATA") writer.data(_file, srcv_vals, name="source_v", _type="VECTORS", data_type="POINT_DATA")
import numpy as np import paraBEM from paraBEM.pan2d import doublet_2_0, doublet_2_0_v v1 = paraBEM.PanelVector2(-1, 0) v2 = paraBEM.PanelVector2(1, 0) p = paraBEM.Panel2([v1, v2]) v = paraBEM.Vector2(0, 0) print("doublet influence on panel center:") print(doublet_2_0_v(v, p).y) print("") y = 3 pos = [[x, y] for x in np.linspace(-2, 2, 100)] _pos = map(paraBEM.Vector2, pos) vals = [doublet_2_0(i, p) for i in _pos] print("x, y, doublet_value") print("==============================\n") print(np.array([[pos[0], pos[1], vals[i]] for i, pos in enumerate(pos)]))
ny = 300 x_grid = np.linspace(-3, 3, nx) y_grid = np.linspace(-3, 3, ny) grid = [paraBEM.Vector2(x, y) for y in y_grid for x in x_grid] temp_list = [] for point in grid: t = 0 t -= doublet_2_0(point, pan1) * sol[0] * R1 * l t -= doublet_2_0(point, pan2) * sol[1] * R2 * l t += source_2_0(point, pan1) * sol[0] t += source_2_0(point, pan2) * sol[1] temp_list.append(t) q_list = [] for point in grid: q = paraBEM.Vector2(0, 0) q -= doublet_2_0_v(point, pan1) * sol[0] * R1 * l q -= doublet_2_0_v(point, pan2) * sol[1] * R2 * l q += source_2_0_v(point, pan1) * sol[0] q += source_2_0_v(point, pan2) * sol[1] q_list.append(q) writer = VtkWriter() with open(check_path("results/heat_test.vtk"), "w") as _file: writer.structed_grid(_file, "element_2", [nx, ny, 1]) writer.points(_file, grid) writer.data(_file, temp_list, name="temperature", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, q_list, name="q", _type="VECTORS", data_type="POINT_DATA")
nx = 300 ny = 300 x_grid = np.linspace(-3, 3, nx) y_grid = np.linspace(-3, 3, ny) grid = [paraBEM.Vector2(x, y) for y in y_grid for x in x_grid] t_list = [] for point in grid: t = 0 for i, panel_i in enumerate(panels): t -= source_2_0(point, panel_i) * sol[i] t += doublet_2_0(point, panel_i) * sol[i] * R t_list.append(t) q_list = [] for point in grid: q = paraBEM.Vector2(0, 0) for i, panel_i in enumerate(panels): q -= source_2_0_v(point, panel_i) * sol[i] q += doublet_2_0_v(point, panel_i) * sol[i] * R q_list.append(q) writer = VtkWriter() with open(check_path("results/heat_test.vtk"), "w") as _file: writer.structed_grid(_file, "element_2", [nx, ny, 1]) writer.points(_file, grid) writer.data(_file, t_list, name="temperature", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, q_list, name="q", _type="VECTORS", data_type="POINT_DATA")
y_grid = np.linspace(-3, 3, ny) grid = [paraBEM.Vector2(x, y) for y in y_grid for x in x_grid] t_list = [] for point in grid: t = 0 for i, panel_i in enumerate(panels): t -= source_2_0(point, panel_i) * sol[i] t += doublet_2_0(point, panel_i) * sol[i] * R t_list.append(t) q_list = [] for point in grid: q = paraBEM.Vector2(0, 0) for i, panel_i in enumerate(panels): q -= source_2_0_v(point, panel_i) * sol[i] q += doublet_2_0_v(point, panel_i) * sol[i] * R q_list.append(q) writer = VtkWriter() with open(check_path("results/heat_test.vtk"), "w") as _file: writer.structed_grid(_file, "element_2", [nx, ny, 1]) writer.points(_file, grid) writer.data(_file, t_list, name="temperature", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, q_list, name="q", _type="VECTORS",
val = [source_2_0(paraBEM.Vector2(yi, 8), source) for yi in y] plt.plot(y, val) val = [source_2_0(paraBEM.Vector2(yi, 0.01), source) for yi in y] plt.plot(y, val) val = [source_2_0(paraBEM.Vector2(yi, 0.0), source) for yi in y] plt.plot(y, val) val = [source_2_0(paraBEM.Vector2(yi, 3), source) for yi in y] plt.plot(y, val) plt.savefig(check_path("results/2d/source.png")) plt.close() y = np.linspace(-3, 3, 100) val = [doublet_2_0(paraBEM.Vector2(yi, 7), source) for yi in y] plt.plot(y, val) val = [doublet_2_0(paraBEM.Vector2(yi, 0.01), source) for yi in y] plt.plot(y, val) val = [doublet_2_0(paraBEM.Vector2(yi, 0.0), source) for yi in y] plt.plot(y, val) val = [doublet_2_0(paraBEM.Vector2(yi, 3), source) for yi in y] plt.plot(y, val) plt.savefig(check_path("results/2d/doublet.png")) plt.close() y = np.linspace(-3, 3, 100) val = [doublet_2_0_v(paraBEM.Vector2(yi, 7), source).x for yi in y] plt.plot(y, val) val = [doublet_2_0_v(paraBEM.Vector2(yi, 0.2), source).x for yi in y] plt.plot(y, val) val = [doublet_2_0_v(paraBEM.Vector2(yi, 3), source).x for yi in y] plt.savefig(check_path("results/2d/doublet_v.png"))
T1 = -10 T2 = 10 l1 = 1 l2 = 2 mat[0, 0] = source_2_0(panels[0].center, panels[0]) mat[0, 1] = source_2_0(panels[0].center, panels[1]) * (1 - l2 / l1) mat[0, 2] = source_2_0(panels[0].center, panels[2]) rhs[0] += doublet_2_0(panels[0].center, panels[0]) * T1 rhs[0] += doublet_2_0(panels[0].center, panels[2]) * T2 rhs[0] += T1 # panel2: velocity formulation mat[1, 0] = source_2_0_v(panels[1].center, panels[0]).dot(panels[1].n) mat[1, 1] = source_2_0_v(panels[1].center, panels[1]).dot(panels[1].n) * (1 - l2 / l1) - 1 mat[1, 2] = source_2_0_v(panels[1].center, panels[2]).dot(panels[1].n) rhs[1] += doublet_2_0_v(panels[1].center, panels[0]).dot(panels[1].n) * T1 rhs[1] += doublet_2_0_v(panels[1].center, panels[2]).dot(panels[1].n) * T2 # panel3: temp-formulation mat[2, 0] = source_2_0(panels[2].center, panels[0]) mat[2, 1] = source_2_0(panels[2].center, panels[1]) * (1 - l2 / l1) mat[2, 2] = source_2_0(panels[2].center, panels[2]) rhs[2] += doublet_2_0(panels[2].center, panels[0]) * T1 rhs[2] += doublet_2_0(panels[2].center, panels[2]) * T2 rhs[2] += T2 sol = np.linalg.solve(mat, rhs) print(mat) print(rhs) print(sol)