ax1 = fig.add_subplot(131) ax1.plot(x, y) y = [] for xi in x: target1 = paraBEM.Vector3(0, xi, 0.0) target2 = paraBEM.Vector3(0, xi, 0.5) target3 = paraBEM.Vector3(0, xi, 1.0) val1 = doublet(target1, source) val2 = doublet(target2, source) val3 = doublet(target3, source) y.append([val1, val2, val3]) ax2 = fig.add_subplot(132) ax2.plot(x, y) y = [] for xi in x: target1 = paraBEM.Vector3(0., 0, xi) target2 = paraBEM.Vector3(0.5, 0, xi) target3 = paraBEM.Vector3(1.0, 0, xi) val1 = doublet(target1, source) val2 = doublet(target2, source) val3 = doublet(target3, source) y.append([val1, val2, val3]) ax3 = fig.add_subplot(133) ax3.plot(x, y) plt.savefig(check_path("results/3d/doublet.png"))
panel_infl = doublet_3_0_vsaero(target, source) point_infl = doublet_3_0_n0(target, source) y.append([panel_infl, point_infl, abs(panel_infl - point_infl)]) y = list(zip(*y)) plt.figure(figsize=(8,3)) plt.gcf().subplots_adjust(bottom=0.15) plt.ylabel("Einfluss") plt.xlabel("x") plt.plot(x, y[0], label=u"Exakte Lösung") plt.plot(x, y[1], label=u"Näherungslösung") plt.ylim(-0.1, 0.6) plt.xlim(0, None) plt.legend() plt.grid(True) plt.savefig(check_path("results/3d/far_vs_near_doublet.png")) plt.close() plt.figure(figsize=(8,3)) plt.gcf().subplots_adjust(bottom=0.15) plt.ylabel("Fehler") plt.xlabel("x") plt.yscale('log') plt.plot(x, y[2], label="Fehler durch Fernfeldmethode") plt.ylim(None, 1) plt.xlim(0, None) plt.legend() plt.grid(True) plt.savefig(check_path("results/3d/far_error_doublet.png"))
fig = plt.figure() ax1 = fig.add_subplot(131) ax1.plot(x, y) y = [] for xi in x: target1 = paraBEM.Vector3(0, xi, 0.0) target2 = paraBEM.Vector3(0, xi, 0.5) target3 = paraBEM.Vector3(0, xi, 1.0) val1 = doublet(target1, source) val2 = doublet(target2, source) val3 = doublet(target3, source) y.append([val1, val2, val3]) ax2 = fig.add_subplot(132) ax2.plot(x, y) y = [] for xi in x: target1 = paraBEM.Vector3(0., 0, xi) target2 = paraBEM.Vector3(0.5, 0, xi) target3 = paraBEM.Vector3(1.0, 0, xi) val1 = doublet(target1, source) val2 = doublet(target2, source) val3 = doublet(target3, source) y.append([val1, val2, val3]) ax3 = fig.add_subplot(133) ax3.plot(x, y) plt.savefig(check_path("results/3d/doublet_included_source.png"))
fig = plt.figure() ax1 = fig.add_subplot(131) ax1.plot(x, y) y = [] for xi in x: target1 = paraBEM.Vector3(0, xi, 0.0) target2 = paraBEM.Vector3(0, xi, 0.5) target3 = paraBEM.Vector3(0, xi, 1.0) val1 = doublet(target1, source) val2 = doublet(target2, source) val3 = doublet(target3, source) y.append([val1, val2, val3]) ax2 = fig.add_subplot(132) ax2.plot(x, y) y = [] for xi in x: target1 = paraBEM.Vector3(0., 0, xi) target2 = paraBEM.Vector3(0.5, 0, xi) target3 = paraBEM.Vector3(1.0, 0, xi) val1 = doublet(target1, source) val2 = doublet(target2, source) val3 = doublet(target3, source) y.append([val1, val2, val3]) ax3 = fig.add_subplot(133) ax3.plot(x, y) plt.savefig(check_path("results/3d/doublet.png"))
alpha_list = np.deg2rad(np.linspace(-15, 30, 30)) cl = [] cd = [] cm = [] xcp = [] for alpha in alpha_list: case = Case(a.panels) case.v_inf = paraBEM.Vector2(np.cos(alpha), np.sin(alpha)) case.mom_ref_point = paraBEM.Vector2(-0, -3) case.run() cl.append(case.cl) cd.append(case.force.dot(case.v_inf) * 10) cm.append(case.cm) # xcp.append(case.center_of_pressure.x) del (case) plt.plot(cl, alpha_list, color="black", linestyle="-", label="cl") plt.plot(cm, alpha_list, color="black", dashes=[8, 4, 2, 4, 2, 4], label="cm") # plt.plot(xcp, alpha_list, color="black", linestyle="dashed", label="x(cm=0)") plt.legend() plt.plot(*zip(*a.coordinates), marker="*") plt.grid(True) # plt.axes().set_aspect("equal", "datalim") axes = plt.gca() axes.set_xlim([-0.25, 1.25]) plt.savefig(check_path("results/2d/alpha_ca_cm_xcp_2d.png")) # plt.show()
# LiftingLine lifting_line = LiftingLine(wing) lifting_line.v_inf = paraBEM.Vector3(1, 0, 0) lifting_line.solve_for_best_gamma(1) gamma = [i.best_gamma for i in lifting_line.segments] gamma_max = max(gamma) # Plot gamma_el = lambda y: gamma_max * (1 - (y / spw * 2) ** 2) ** (1 / 2) mids = [[i.mids.x, i.mids.y, i.mids.z] for i in lifting_line.segments] x, y, z = zip(*mids) fig = plt.figure() ax1 = fig.add_subplot(3, 1, 1) ax1.plot(y, z) ax2 = fig.add_subplot(3, 1, 2) ax2.plot(y, x, marker="x") ax3 = fig.add_subplot(3, 1, 3) y_el = np.linspace(-1, 1, 400) ax3.plot([-spw / 2] + list(y) + [spw / 2], [0] + gamma + [0], marker="x") ax3.plot(y_el, list(map(gamma_el, y_el))) plt.savefig(check_path("results/2d/liftingline.png")) total = 0 for i in lifting_line.segments: total += i.lift_factor * i.best_gamma print(total)
gamma_el_2 = lambda y: gamma_max * (1 - (y / spw_proj * 2)**2)**(1 / 2) np_gamma_1 = np.vectorize(gamma_el_1) np_gamma_2 = np.vectorize(gamma_el_2) gamma_ell_1 = np_gamma_1(l) gamma_ell_2 = np_gamma_2(y) plt.figure(figsize=(10, 6)) label = (u"Hinterkante des Schirms", u"Optimale Zirkulationsverteilung nach dem Traglinien-Verfahren", u"Zirkulationsverteilung für den optimierten Schirm", u"Elliptische Zirkulation für den flach ausgebreiteten Schirm") plt.axes().set_aspect("equal", "datalim") plt.ylim([-2, 4]) plt.plot(y, z) plt.plot(y + ny * gamma * 10, z + nz * gamma * 10, color="magenta", marker="x") plt.plot(y + ny * gamma_pan * 10, z + nz * gamma_pan * 10, color="green", marker="+") plt.plot(y + ny * gamma_ell_1 * 10, z + nz * gamma_ell_1 * 10, color="black", marker="h") plt.grid(True) plt.legend(label) plt.savefig(check_path("results/vtk_opt/circulation_comparison.png"))
v2 = paraBEM.PanelVector3(0.5, -0.5, 0) v3 = paraBEM.PanelVector3(0.5, 0.5, 0) v4 = paraBEM.PanelVector3(-0.5, 0.5, 0) p = paraBEM.Panel3([v1, v2, v3, v4]) # p = paraBEM.Panel3([v1, v2, v3]) # triangle p.potential = 1. n = 50 a = numpy.linspace(-1, 1, n).tolist() b = [paraBEM.PanelVector3(i, j, k) for i in a for j in a for k in a] pot = [doublet_3_0_sphere(i, p) for i in b] vel = [doublet_3_0_vsaero_v(i, p) for i in b] writer = VtkWriter() with open(check_path("results/panel_influence.vtk"), "w") as _file: writer.structed_grid(_file, "duplet", [n, n, n]) writer.points(_file, b) writer.data(_file, pot, name="potential", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, vel, name="velocity", _type="VECTORS", data_type="POINT_DATA")
fz = [] cmy = [] xcp = [] cL = [] cD = [] case = pan3d.DirichletDoublet0Source0Case3(mesh.panels, mesh.trailing_edges) case.farfield = 5 case.create_wake(10, 30) case.v_inf = v_inf case.create_wake(length=10000, count=4) # length, count polars = case.polars(v_inf_range) p = [] alpha = [] for i in polars.values: alpha.append(np.rad2deg(i.alpha)) p.append((i.cL, i.cD, i.cP, i.cop.x, i.cop.z)) plt.figure(figsize=(10, 4)) plt.ylabel(u"alpha") plt.xlabel(u"cW, cN, cA") plt.plot(np.array(p).T[0], alpha, label=u"cA") plt.plot(np.array(p).T[1], alpha, label=u"cW_i") plt.plot(-np.array(p).T[2], alpha, label=u"- cN") plt.legend() plt.grid() plt.savefig(check_path("results/3d/cLcD.png"))
import paraBEM from paraBEM.pan2d import doublet_2_0, source_2_0, source_2_0_v from paraBEM.vtk_export import VtkWriter from paraBEM.utils import check_path a = list(map(paraBEM.PanelVector2, [[-1, -1], [-1, 1]])) b = list(map(paraBEM.PanelVector2, [[1, -1], [1, 1]])) pan_a = paraBEM.Panel2(a) pan_b = paraBEM.Panel2(b) n = 100 space = numpy.linspace(-2, 2, n) grid = [paraBEM.Vector2(x, y) for y in space for x in space] pot = [ source_2_0(v, pan_a) - source_2_0(v, pan_b) for v in grid] vel = [ source_2_0_v(v, pan_a) - source_2_0_v(v, pan_b) for v in grid] writer = VtkWriter() with open(check_path("results/parallel_flow.vtk"), "w") as _file: writer.structed_grid(_file, "doublet_2", [n, n, 1]) writer.points(_file, grid) writer.data(_file, pot, name="potential", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, vel, name="velocity", _type="VECTORS", data_type="POINT_DATA")
point_infl = src_3_0_n0(target, source) y.append([panel_infl, point_infl, abs(panel_infl - point_infl)]) y = list(zip(*y)) plt.figure(figsize=(8,3)) plt.gcf().subplots_adjust(bottom=0.15) plt.plot(x, y[0], label=u"Exakte Lösung") plt.plot(x, y[1], label=u"Näherungslösung") plt.grid(True) plt.legend() plt.ylabel("Einfluss") plt.xlabel("x") plt.ylim(-0.1, 0.6) plt.savefig(check_path("results/3d/far_vs_near_source.png")) plt.close() plt.figure(figsize=(8,3)) plt.gcf().subplots_adjust(bottom=0.15) plt.plot(x, y[2], label="Fehler durch Fernfeldmethode") plt.yscale('log') plt.grid(True) plt.legend() plt.ylim(-0.1, 0.6) plt.xlabel("x") plt.ylabel("Fehler") plt.savefig(check_path("results/3d/far_error_source.png"))
pnt1 = paraBEM.PanelVector2(-1, 0) pnt2 = paraBEM.PanelVector2(1, 0) source = paraBEM.Panel2([pnt1, pnt2]) y = np.linspace(-3, 3, 100) 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)
plt.plot(airfoil.x(num_konform), np.array(vel), label="Konforme Abbildung") label = "Dirichlet-Randbedingung konstante Dipol-Panel" plt.plot(pan_center_x, pan_vel[1], marker='+', ls=':', label=label) label = "Dirichlet-Randbedingung konstante Dipol-Quellen-panel " plt.plot(pan_center_x, pan_vel[2], marker='1', ls=':', label=label) # label = "Neumann Randbedingung konstante Dipol-Panel" # plt.plot(pan_center_x, pan_vel[0], marker='x', ls=':', label=label) # label = "Dirichlet Randbedingung linearen Dipol-panel " # plt.plot(pan_center_x, pan_vel[3], marker='1', ls=':', label=label) # plt.plot(airfoil.x(num_konform), cp) # plt.plot(pan_center_x, pan_cp, marker="x", ls='None') plt.legend() plt.axes().set_aspect("equal", "datalim") plt.xlim([-1,1]) plt.ylim([-0.5,3]) plt.xlabel('$x$', fontsize=25) plt.ylabel('$\\frac{u}{u_{\\infty}}$', fontsize=25 , rotation=0) plt.grid(True) # plt.savefig("results/2d/trefftz-kutta.png") plt.savefig(check_path("results/2d/joukowsky.png")) # plt.savefig("results/2d/vandevooren_100.png") # plt.show()
vector[0].wake_vertex = True # setting up the case case = Case(panels) case.v_inf = paraBEM.Vector2(1, 0.5) case.run() nx = 100 ny = 100 space_x = np.linspace(-2, 2, nx) space_y = np.linspace(-2, 2, ny) grid = [paraBEM.Vector2(x, y) for y in space_y for x in space_x] velocity = list(map(case.off_body_velocity, grid)) pot = list(map(case.off_body_potential, grid)) with open(check_path("results/cylinder_2d_linear/field.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "airfoil", [nx, ny, 1]) writer.points(_file, grid) writer.data(_file, velocity, name="velocity", _type="VECTORS", data_type="POINT_DATA") writer.data(_file, pot, name="pot", _type="SCALARS", data_type="POINT_DATA") with open(check_path("results/cylinder_2d_linear/shape.vtk"), "w") as _file:
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")
from paraBEM.pan2d import doublet_2_0, source_2_0, source_2_0_v from paraBEM.vtk_export import VtkWriter from paraBEM.utils import check_path a = list(map(paraBEM.PanelVector2, [[-1, -1], [-1, 1]])) b = list(map(paraBEM.PanelVector2, [[1, -1], [1, 1]])) pan_a = paraBEM.Panel2(a) pan_b = paraBEM.Panel2(b) n = 100 space = numpy.linspace(-2, 2, n) grid = [paraBEM.Vector2(x, y) for y in space for x in space] pot = [source_2_0(v, pan_a) - source_2_0(v, pan_b) for v in grid] vel = [source_2_0_v(v, pan_a) - source_2_0_v(v, pan_b) for v in grid] writer = VtkWriter() with open(check_path("results/parallel_flow.vtk"), "w") as _file: writer.structed_grid(_file, "doublet_2", [n, n, 1]) writer.points(_file, grid) writer.data(_file, pot, name="potential", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, vel, name="velocity", _type="VECTORS", data_type="POINT_DATA")
# remove all points lying inside the circle with radius r r = airfoil.radius z_grid = [z for z in z_grid if abs(z) > r] # ---------------------------------------------------------- # complex zeta-plane with mapped circle (=joukowsky airfoil) # ---------------------------------------------------------- z_to_zeta = list(map(airfoil.zeta, z_grid)) zeta_vel = list(map(zeta_velocity, z_grid)) zeta_pot = list(map(potential, z_grid)) zeta_stream = list(map(stream, z_grid)) airfoil = list(map(complex_to_3vec, airfoil.coordinates())) # ---------------------------------------------------------- with open(check_path("results/conformal_mapping/vandevooren_zeta.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "zeta_plane", [num_x, num_y, 1]) writer.points(_file, list(map(complex_to_3vec, z_to_zeta))) writer.data(_file, zeta_stream, name="stream", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, zeta_pot, name="pot", _type="SCALARS", data_type="POINT_DATA") writer.data(_file,
fig.gca().set_ylim([-5, 1]) ax1.plot(x, y) y = [] for xi in x: trg1 = paraBEM.Vector3(0, xi, 0.0) trg2 = paraBEM.Vector3(0, xi, 0.5) trg3 = paraBEM.Vector3(0, xi, 1) val1 = src_3_0_n0(trg1, source) val2 = src_3_0_n0(trg2, source) val3 = src_3_0_n0(trg3, source) y.append([val1, val2, val3]) ax2 = fig.add_subplot(132) fig.gca().set_ylim([-5, 1]) ax2.plot(x, y) y = [] for xi in x: trg1 = paraBEM.Vector3(0, 0, xi) trg2 = paraBEM.Vector3(0.5, 0, xi) trg3 = paraBEM.Vector3(1, 0, xi) val1 = src_3_0_n0(trg1, source) val2 = src_3_0_n0(trg2, source) val3 = src_3_0_n0(trg3, source) y.append([val1, val2, val3]) ax3 = fig.add_subplot(133) fig.gca().set_ylim([-5, 1]) ax3.plot(x, y) plt.savefig(check_path("results/3d/source_far.png"))
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")
panels = [paraBEM.Panel2([coord, points[i+1]]) for i, coord in enumerate(points[:-1])] panels.append(paraBEM.Panel2([points[-1], points[0]])) # panelmethode case = Case(panels) case.v_inf = paraBEM.Vector2(1, 0.3) case.run() # plt.plot(np.array(case.matrix.values).T) # # plt.show() nx = 200 ny = 200 space_x = np.linspace(-0.2, 1.5, nx) space_y = np.linspace(-0.5, 0.5, ny) grid = [paraBEM.Vector2(x, y) for y in space_y for x in space_x] velocity = list(map(case.off_body_velocity, grid)) pot = list(map(case.off_body_potential, grid)) with open(check_path("results/airfoil_2d_linear/field.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "airfoil", [nx, ny, 1]) writer.points(_file, grid) writer.data(_file, velocity, name="velocity", _type="VECTORS", data_type="POINT_DATA") writer.data(_file, pot, name="pot", _type="SCALARS", data_type="POINT_DATA") with open(check_path("results/airfoil_2d_linear/shape.vtk"), "w") as _file: writer = VtkWriter() writer.unstructed_grid(_file, "airfoil") writer.points(_file, [[i[0], i[1], 0]for i in airfoil.coordinates]) writer.lines(_file, [range(len(airfoil.coordinates))])
p = [] alpha = [] for i in polars.values: alpha.append(np.rad2deg(i.alpha)) p.append((i.cL, i.cD, i.cP, i.cop.x, i.cop.z)) plt.figure(figsize=(10, 4)) # plt.title(u"Beiwerte bei variiertem Anströmwinkel") plt.ylabel(u"$\\alpha$", rotation=0, fontsize=20) plt.xlabel(u"$c_{Wi}$, $c_N$, $c_A$", rotation=0, fontsize=20) plt.plot(np.array(p).T[0], alpha, label=u"$c_A$") plt.plot(np.array(p).T[1], alpha, label=u"$c_{Wi}$") plt.plot(-np.array(p).T[2], alpha, label=u"- $c_N$") plt.legend(fontsize=15) plt.grid() plt.savefig(check_path("results/cLcDcM.png"), bbox_inches="tight") print(case.center_of_pressure) p = [] alpha = [] for i in polars.values: alpha.append(np.rad2deg(i.alpha)) p.append((i.cL, i.cD, i.cP, i.cop.x, i.cop.z)) plt.figure(figsize=(10, 4)) # plt.title(u"Beiwerte bei variiertem Anströmwinkel") plt.ylabel(u"$\\alpha$", rotation=0, fontsize=20) plt.xlabel(u"$c_{Wi}$, $c_N$, $c_A$", rotation=0, fontsize=20) plt.plot(np.array(p).T[0], alpha, label=u"$c_A$") plt.plot(np.array(p).T[1], alpha, label=u"$c_{Wi}$") plt.plot(-np.array(p).T[2], alpha, label=u"- $c_N$")
nx = 500 ny = 500 space_x = np.linspace(-3, 7, nx) space_y = np.linspace(-2, 2, ny) vec = lambda x: paraBEM.Vector2(x[0], x[1]) vec3 = lambda x: [x[0], x[1], 0] grid = [[x, y, 0] for y in space_y for x in space_x] _grid = list(map(vec, grid)) velocity = list(map(vec3, list(map(case.off_body_velocity, _grid)))) vel1 = [(i[0]**2 + i[1]**2)**(0.5) for i in velocity] pot = list(map(case.off_body_potential, _grid)) with open(check_path("results/coordinates_not_aligned/field.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "airfoil", [nx, ny, 1]) writer.points(_file, grid) writer.data(_file, velocity, name="velocity", _type="VECTORS", data_type="POINT_DATA") writer.data(_file, pot, name="pot", _type="SCALARS", data_type="POINT_DATA") writer.data(_file,
from paraBEM.utils import check_path # geometry numpoints = 30 phi = np.linspace(0, 2 * np.pi, numpoints + 1) x = np.cos(phi)[:-1] y = np.sin(phi)[:-1] xy = np.transpose(np.array([x, y])) # mapping the geometry coordinates = [paraBEM.PanelVector2(*i) for i in xy] coordinates += [coordinates[0]] panels = [paraBEM.Panel2([vec, coordinates[i+1]]) for i, vec in enumerate(coordinates[:-1])] # setting up the case case = Case(panels) case.v_inf = paraBEM.Vector2(1, 0) case.run() # visualisation x1 = [list(i.center) for i in case.panels] x2 = [[i.center.x, i.velocity.norm()] for i in case.panels] plt.axes().set_aspect("equal", "datalim") plt.grid=True plt.plot(*zip(*x1)) plt.plot(*zip(*x2)) plt.savefig(check_path("results/2d/cylinder_cp.png")) # plt.show()
val3 = src_3_0_vsaero(target3, source) y.append([val1, val2, val3]) ax1 = fig.add_subplot(131) ax1.plot(x, y) y = [] for xi in x: target1 = paraBEM.Vector3(0, xi, 0.0) target2 = paraBEM.Vector3(0, xi, 0.5) target3 = paraBEM.Vector3(0, xi, 1) val1 = src_3_0_vsaero(target1, source) val2 = src_3_0_vsaero(target2, source) val3 = src_3_0_vsaero(target3, source) y.append([val1, val2, val3]) ax2 = fig.add_subplot(132) ax2.plot(x, y) y = [] for xi in x: target1 = paraBEM.Vector3(0, 0, xi) target2 = paraBEM.Vector3(0.5, 0, xi) target3 = paraBEM.Vector3(1, 0, xi) val1 = src_3_0_vsaero(target1, source) val2 = src_3_0_vsaero(target2, source) val3 = src_3_0_vsaero(target3, source) y.append([val1, val2, val3]) ax3 = fig.add_subplot(133) ax3.plot(x, y) plt.savefig(check_path("results/3d/source.png"))
p = [] alpha = [] for i in polars.values: alpha.append(np.rad2deg(i.alpha)) p.append((i.cL, i.cD, i.cP, i.cop.x, i.cop.z)) plt.figure(figsize=(10, 4)) # plt.title(u"Beiwerte bei variiertem Anströmwinkel") plt.ylabel(u"$\\alpha$", rotation=0, fontsize=20) plt.xlabel(u"$c_{Wi}$, $c_N$, $c_A$", rotation=0, fontsize=20) plt.plot(np.array(p).T[0], alpha, label=u"$c_A$") plt.plot(np.array(p).T[1], alpha, label=u"$c_{Wi}$") plt.plot(-np.array(p).T[2], alpha, label=u"- $c_N$") plt.legend(fontsize=15) plt.grid() plt.savefig(check_path("results/cLcDcM.png"), bbox_inches="tight") print(case.center_of_pressure) p = [] alpha = [] for i in polars.values: alpha.append(np.rad2deg(i.alpha)) p.append((i.cL, i.cD, i.cP, i.cop.x, i.cop.z)) plt.figure(figsize=(10, 4)) # plt.title(u"Beiwerte bei variiertem Anströmwinkel") plt.ylabel(u"$\\alpha$", rotation=0, fontsize=20) plt.xlabel(u"$c_{Wi}$, $c_N$, $c_A$", rotation=0, fontsize=20) plt.plot(np.array(p).T[0], alpha, label=u"$c_A$") plt.plot(np.array(p).T[1], alpha, label=u"$c_{Wi}$")
# complex zeta-plane with mapped circle (=joukowsky airfoil) # ---------------------------------------------------------- zeta_range_x = np.linspace(-3, 3, num_x) zeta_range_y = np.linspace(-3, 3, num_y) zeta_grid = [x + 1j * y for y in zeta_range_y for x in zeta_range_x] zeta_to_z = list(map(airfoil.z, zeta_grid)) zeta_vel = list(map(zeta_velocity, zeta_to_z)) zeta_pot = list(map(potential, zeta_to_z)) zeta_stream = list(map(stream, zeta_to_z)) airfoil = list(map(complex_to_3vec, airfoil.coordinates())) # ---------------------------------------------------------- with open(check_path("results/conformal_mapping/joukowsky_z.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "z_plane", [num_x, num_y, 1]) writer.points(_file, list(map(complex_to_3vec, z_grid))) writer.data(_file, z_stream, name="stream", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, z_pot, name="pot", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, z_vel, name="velocity", _type="VECTORS", data_type="POINT_DATA") with open(check_path("results/conformal_mapping/joukowsky_zeta.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "zeta_plane", [num_x, num_y, 1]) writer.points(_file, list(map(complex_to_3vec, zeta_grid))) writer.data(_file, zeta_stream, name="stream", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, zeta_pot, name="pot", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, zeta_vel, name="velocity", _type="VECTORS", data_type="POINT_DATA")
r = airfoil.radius z_grid = [z for z in z_grid if abs(z) > r] # ---------------------------------------------------------- # complex zeta-plane with mapped circle (=joukowsky airfoil) # ---------------------------------------------------------- z_to_zeta = list(map(airfoil.zeta, z_grid)) zeta_vel = list(map(zeta_velocity, z_grid)) zeta_pot = list(map(potential, z_grid)) zeta_stream = list(map(stream, z_grid)) airfoil = list(map(complex_to_3vec, airfoil.coordinates())) # ---------------------------------------------------------- with open(check_path("results/conformal_mapping/vandevooren_zeta.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "zeta_plane", [num_x, num_y, 1]) writer.points(_file, list(map(complex_to_3vec, z_to_zeta))) writer.data(_file, zeta_stream, name="stream", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, zeta_pot, name="pot", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, zeta_vel, name="velocity", _type="VECTORS", data_type="POINT_DATA") with open(check_path("results/conformal_mapping/vandevooren_airfoil.vtk"), "w") as _file: writer = VtkWriter() writer.unstructed_grid(_file, "airfoil") writer.points(_file, airfoil) writer.lines(_file, [range(len(airfoil))])
case = Case(airfoil.panels) case.v_inf = Vector2(np.cos(alpha), np.sin(alpha)) case.run() print(np.array(case.matrix.values)) nx = 300 ny = 300 space_x = np.linspace(-1, 2, nx) space_y = np.linspace(-0.2, 0.2, ny) vec = lambda x: paraBEM.Vector2(x[0], x[1]) vec3 = lambda x: [x[0], x[1], 0] grid = [paraBEM.Vector2(x, y) for y in space_y for x in space_x] velocity = list(map(vec3, map(case.off_body_velocity, grid))) vel1 = [(i[0]**2 + i[1]**2)**(0.5) for i in velocity] pot = list(map(case.off_body_potential, grid)) with open(check_path("results/neumann/field.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "airfoil", [nx, ny, 1]) writer.points(_file, grid) writer.data(_file, velocity, name="velocity", _type="VECTORS", data_type="POINT_DATA") writer.data(_file, pot, name="pot", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, vel1, name="vel", _type="SCALARS", data_type="POINT_DATA") with open(check_path("results/neumann/airfoil.vtk"), "w") as _file: writer = VtkWriter() writer.unstructed_grid(_file, "airfoil") writer.points(_file, [list(i.points[0]) + [0] for i in case.panels]) writer.lines(_file, [range(len(case.panels))])
case.v_inf = Vector2(np.cos(alpha), np.sin(alpha)) case.run() nx = 200 ny = 200 space_x = np.linspace(-1, 2, nx) space_y = np.linspace(-0.2, 0.2, ny) vec = lambda x: paraBEM.Vector2(x[0], x[1]) vec3 = lambda x: [x[0], x[1], 0] grid = [paraBEM.Vector2(x, y) for y in space_y for x in space_x] velocity = list(map(vec3, map(case.off_body_velocity, grid))) vel1 = [(i[0]**2 + i[1]**2)**(0.5) for i in velocity] pot = list(map(case.off_body_potential, grid)) with open(check_path("results/neumann/field.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "airfoil", [nx, ny, 1]) writer.points(_file, grid) writer.data(_file, velocity, name="velocity", _type="VECTORS", data_type="POINT_DATA") writer.data(_file, pot, name="pot", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, vel1, name="vel", _type="SCALARS", data_type="POINT_DATA") with open(check_path("results/neumann/airfoil.vtk"), "w") as _file: writer = VtkWriter() writer.unstructed_grid(_file, "airfoil") writer.points(_file, [list(i.points[0]) + [0] for i in case.panels]) writer.lines(_file, [range(len(case.panels))])
panel_infl = src_3_0_vsaero(target, source) point_infl = src_3_0_n0(target, source) y.append([panel_infl, point_infl, abs(panel_infl - point_infl)]) y = list(zip(*y)) plt.figure(figsize=(8, 3)) plt.gcf().subplots_adjust(bottom=0.15) plt.plot(x, y[0], label=u"Exakte Lösung") plt.plot(x, y[1], label=u"Näherungslösung") plt.grid(True) plt.legend() plt.ylabel("Einfluss") plt.xlabel("x") plt.ylim(0., 0.6) plt.savefig(check_path("results/3d/far_vs_near_source.png")) plt.close() plt.figure(figsize=(8, 3)) plt.gcf().subplots_adjust(bottom=0.15) plt.plot(x, y[2], label="Fehler durch Fernfeldmethode") plt.yscale('log') plt.grid(True) plt.legend() plt.ylim(-0.1, 0.6) plt.xlabel("x") plt.ylabel("Fehler") plt.savefig(check_path("results/3d/far_error_source.png"))
v1 = paraBEM.PanelVector3(-0.5, -0.5, 0) v2 = paraBEM.PanelVector3(0.5, -0.5, 0) v3 = paraBEM.PanelVector3(0.5, 0.5, 0) v4 = paraBEM.PanelVector3(-0.5, 0.5, 0) p = paraBEM.Panel3([v1, v2, v3, v4]) p.potential = 1. n = 50 a = numpy.linspace(-1, 1, n).tolist() b = [paraBEM.PanelVector3(i, j, k) for i in a for j in a for k in a] pot = [doublet_src_3_0_vsaero(i, p)[1] for i in b] vel = [src_3_0_vsaero_v(i, p) for i in b] writer = VtkWriter() with open(check_path("results/src_panel.vtk"), "w") as _file: writer.structed_grid(_file, "duplet", [n, n, n]) writer.points(_file, b) writer.data(_file, pot, name="potential", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, vel, name="velocity", _type="VECTORS", data_type="POINT_DATA")
case = Case(panels) case.v_inf = paraBEM.Vector2(1, 0.3) case.run() # plt.plot(np.array(case.matrix.values).T) # # plt.show() nx = 200 ny = 200 space_x = np.linspace(-0.2, 1.5, nx) space_y = np.linspace(-0.5, 0.5, ny) grid = [paraBEM.Vector2(x, y) for y in space_y for x in space_x] velocity = list(map(case.off_body_velocity, grid)) pot = list(map(case.off_body_potential, grid)) with open(check_path("results/airfoil_2d_linear/field.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "airfoil", [nx, ny, 1]) writer.points(_file, grid) writer.data(_file, velocity, name="velocity", _type="VECTORS", data_type="POINT_DATA") writer.data(_file, pot, name="pot", _type="SCALARS", data_type="POINT_DATA") with open(check_path("results/airfoil_2d_linear/shape.vtk"), "w") as _file:
numpoints = 30 phi = np.linspace(0, 2 * np.pi, numpoints + 1) x = np.cos(phi)[:-1] y = np.sin(phi)[:-1] xy = np.transpose(np.array([x, y])) # mapping the geometry coordinates = [paraBEM.PanelVector2(*i) for i in xy] coordinates += [coordinates[0]] panels = [ paraBEM.Panel2([vec, coordinates[i + 1]]) for i, vec in enumerate(coordinates[:-1]) ] # setting up the case case = Case(panels) case.v_inf = paraBEM.Vector2(1, 0) case.run() # visualisation x1 = [list(i.center) for i in case.panels] x2 = [[i.center.x, i.velocity.norm()] for i in case.panels] plt.axes().set_aspect("equal", "datalim") plt.grid = True plt.plot(*zip(*(x1 + [x1[0]]))) plt.plot(*zip(*x2)) plt.savefig(check_path("results/2d/cylinder_cp.png")) # plt.show()
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")
l = np.insert(l, 0, 0) l -= max(l) / 2 gamma_el_1 = lambda y: gamma_max * (1 - (y / spw * 2) ** 2) ** (1 / 2) gamma_el_2 = lambda y: gamma_max * (1 - (y / spw_proj * 2) ** 2) ** (1 / 2) np_gamma_1 = np.vectorize(gamma_el_1) np_gamma_2 = np.vectorize(gamma_el_2) gamma_ell_1 = np_gamma_1(l) gamma_ell_2 = np_gamma_2(y) plt.figure(figsize=(10, 6)) label = ( u"Hinterkante des Schirms", u"Optimale Zirkulationsverteilung nach dem Traglinien-Verfahren", u"Zirkulationsverteilung für den optimierten Schirm", u"Elliptische Zirkulation für den flach ausgebreiteten Schirm", ) plt.axes().set_aspect("equal", "datalim") plt.ylim([-2, 4]) plt.plot(y, z) plt.plot(y + ny * gamma * 10, z + nz * gamma * 10, color="magenta", marker="x") plt.plot(y + ny * gamma_pan * 10, z + nz * gamma_pan * 10, color="green", marker="+") plt.plot(y + ny * gamma_ell_1 * 10, z + nz * gamma_ell_1 * 10, color="black", marker="h") plt.grid(True) plt.legend(label) plt.savefig(check_path("results/vtk_opt/circulation_comparison.png"))
label=airfoil_label) plt.plot(airfoil.x(num_konform), np.array(vel), label="Konforme Abbildung") label = "Dirichlet-Randbedingung konstante Dipol-Panel" plt.plot(pan_center_x, pan_vel[1], marker='+', ls=':', label=label) label = "Dirichlet-Randbedingung konstante Dipol-Quellen-panel " plt.plot(pan_center_x, pan_vel[2], marker='1', ls=':', label=label) # label = "Neumann Randbedingung konstante Dipol-Panel" # plt.plot(pan_center_x, pan_vel[0], marker='x', ls=':', label=label) # label = "Dirichlet Randbedingung linearen Dipol-panel " # plt.plot(pan_center_x, pan_vel[3], marker='1', ls=':', label=label) # plt.plot(airfoil.x(num_konform), cp) # plt.plot(pan_center_x, pan_cp, marker="x", ls='None') plt.legend() plt.axes().set_aspect("equal", "datalim") plt.xlim([-1, 1]) plt.ylim([-0.5, 3]) plt.xlabel('$x$', fontsize=25) plt.ylabel('$\\frac{u}{u_{\\infty}}$', fontsize=25, rotation=0) plt.grid(True) # plt.savefig("results/2d/trefftz-kutta.png") plt.savefig(check_path("results/2d/joukowsky.png")) # plt.savefig("results/2d/vandevooren_100.png") # plt.show()
cD = [] for i in polars.values: cL.append(i.cL) cD.append(i.cD) return np.interp(0.6, cL, cD) y_positions = np.linspace(-6, 10, 20) cD = [min_func(i) for i in y_positions] # plt.show() plt.figure(figsize=(10, 4)) plt.plot(y_positions, cD, marker="x") plt.xlabel('y-Position der Kontrollpunkte [m]', fontsize=15) plt.ylabel('induzierter Widerstandsbeiwert $c_{Wi}$', fontsize=15) plt.grid(True) plt.savefig(check_path('results/vtk_opt/induced_drag.png'), bbox_inches='tight') # # plt.show() plt.close() plt.figure(figsize=(10, 4)) plt.plot(y_positions, 0.6 / np.array(cD), marker="x") plt.xlabel('y-Position der Kontrollpunkte [m]', fontsize=15) plt.ylabel('Gleitzahl $\\epsilon$', fontsize=15) plt.grid(True) plt.savefig(check_path('results/vtk_opt/glide.png'), bbox_inches='tight') plt.close() best_ind = list(cD).index(min(cD)) best_y = y_positions[best_ind] glider_set_controlpoint(glider2d, best_y)
ax1.legend(loc="upper left", fontsize=8) vel_f = lambda z: np.sin(np.arccos(z)) * 3 / 2 vel_n_x, vel_n_y = np.array([[i.center.x, i.velocity.norm()] for i in case.panels]).T vel_x = np.arange(-1, 1, 0.01) vel_y = list(map(vel_f, vel_x)) ax2 = fig.add_subplot(312) ax2.plot(vel_x, vel_y, c=[0, 0, 0], label="Analytisch") vel_scat = ax2.scatter(vel_n_x, vel_n_y, marker="+", label="Panelmethode") ax2.set_xlabel('x') ax2.set_ylabel('Geschwindigkeit') ax2.legend(loc="upper left", fontsize=8) cp_f = lambda z: 1 - 9. / 4. * np.sin(np.arccos(z))**2 cp_n_x, cp_n_y = np.array([[i.center.x, i.cp] for i in case.panels]).T cp_x = np.arange(-1, 1, 0.01) cp_y = list(map(cp_f, cp_x)) ax3 = fig.add_subplot(313) ax3.plot(cp_x, cp_y, c=[0, 0, 0], label="Analytisch") cp_scat = ax3.scatter(cp_n_x, cp_n_y, marker="+", label="Panelmethode") ax3.set_xlabel('x') ax3.set_ylabel('Druckbeiwert') ax3.legend(loc="upper left", fontsize=8) plt.savefig(check_path("results/3d/sphere_error.png"), bbox_inches='tight', dpi=100)
import numpy as np import paraBEM from paraBEM.pan2d import vortex_2, vortex_2_v from paraBEM.vtk_export import VtkWriter from paraBEM.utils import check_path source = paraBEM.Vector2(0, 0) direction = paraBEM.Vector2(1, 0) n = 20 a = np.linspace(-10, 10, n).tolist() b = [paraBEM.Vector2(i, j) for i in a for j in a] vel = [vortex_2_v(target, source) for target in b] pot = [vortex_2(target, source, direction) for target in b] writer = VtkWriter() with open(check_path("results/vortex_2_field.vtk"), "w") as _file: writer.structed_grid(_file, "vortex", [n, n, 1]) writer.points(_file, b) writer.data(_file, vel, name="velocity", _type="VECTORS", data_type="POINT_DATA") writer.data(_file, pot, name="potential", _type="SCALARS", data_type="POINT_DATA")
# LiftingLine lifting_line = LiftingLine(wing) lifting_line.v_inf = paraBEM.Vector3(1, 0, 0) lifting_line.solve_for_best_gamma(1) gamma = [i.best_gamma for i in lifting_line.segments] gamma_max = max(gamma) # Plot gamma_el = lambda y: gamma_max * (1 - (y / spw * 2)**2)**(1 / 2) mids = [[i.mids.x, i.mids.y, i.mids.z] for i in lifting_line.segments] x, y, z = zip(*mids) fig = plt.figure() ax1 = fig.add_subplot(3, 1, 1) ax1.plot(y, z) ax2 = fig.add_subplot(3, 1, 2) ax2.plot(y, x, marker="x") ax3 = fig.add_subplot(3, 1, 3) y_el = np.linspace(-1, 1, 400) ax3.plot([-spw/2] + list(y) + [spw/2], [0] + gamma + [0], marker="x") ax3.plot(y_el, list(map(gamma_el, y_el))) plt.savefig(check_path("results/2d/liftingline.png")) total = 0 for i in lifting_line.segments: total += i.lift_factor * i.best_gamma print(total)
target = paraBEM.PanelVector3(xi, 0., 0.1) panel_infl = doublet_3_0_vsaero(target, source) point_infl = doublet_3_0_n0(target, source) y.append([panel_infl, point_infl, abs(panel_infl - point_infl)]) y = list(zip(*y)) plt.figure(figsize=(8, 3)) plt.gcf().subplots_adjust(bottom=0.15) plt.ylabel("Einfluss") plt.xlabel("x") plt.plot(x, y[0], label=u"Exakte Lösung") plt.plot(x, y[1], label=u"Näherungslösung") plt.ylim(-0.1, 0.6) plt.xlim(0, None) plt.legend() plt.grid(True) plt.savefig(check_path("results/3d/far_vs_near_doublet.png")) plt.close() plt.figure(figsize=(8, 3)) plt.gcf().subplots_adjust(bottom=0.15) plt.ylabel("Fehler") plt.xlabel("x") plt.yscale('log') plt.plot(x, y[2], label="Fehler durch Fernfeldmethode") plt.ylim(None, 1) plt.xlim(0, None) plt.legend() plt.grid(True) plt.savefig(check_path("results/3d/far_error_doublet.png"))
ax1.set_ylabel('Potential') ax1.legend(loc="upper left", fontsize=8) vel_f = lambda z: np.sin(np.arccos(z)) * 3/2 vel_n_x, vel_n_y = np.array([[i.center.x, i.velocity.norm()] for i in case.panels]).T vel_x = np.arange(-1, 1, 0.01) vel_y = list(map(vel_f, vel_x)) ax2 = fig.add_subplot(312) ax2.plot(vel_x, vel_y, c=[0, 0, 0], label="Analytisch") vel_scat = ax2.scatter(vel_n_x, vel_n_y, marker="+", label="Panelmethode") ax2.set_xlabel('x') ax2.set_ylabel('Geschwindigkeit') ax2.legend(loc="upper left", fontsize=8) cp_f = lambda z: 1 - 9./4. * np.sin(np.arccos(z)) ** 2 cp_n_x, cp_n_y = np.array([[i.center.x, i.cp] for i in case.panels]).T cp_x = np.arange(-1, 1, 0.01) cp_y = list(map(cp_f, cp_x)) ax3 = fig.add_subplot(313) ax3.plot(cp_x, cp_y, c=[0, 0, 0], label="Analytisch") cp_scat = ax3.scatter(cp_n_x, cp_n_y, marker="+", label="Panelmethode") ax3.set_xlabel('x') ax3.set_ylabel('Druckbeiwert') ax3.legend(loc="upper left", fontsize=8) plt.savefig(check_path("results/3d/sphere_error.png"), bbox_inches='tight', dpi=100)
import paraBEM from paraBEM.pan3d import doublet_src_3_0_vsaero, src_3_0_vsaero_v from paraBEM.vtk_export import VtkWriter import numpy from paraBEM.utils import check_path v1 = paraBEM.PanelVector3(-0.5, -0.5, 0) v2 = paraBEM.PanelVector3(0.5, -0.5, 0) v3 = paraBEM.PanelVector3(0.5, 0.5, 0) v4 = paraBEM.PanelVector3(-0.5, 0.5, 0) p = paraBEM.Panel3([v1, v2, v3, v4]) p.potential = 1.0 n = 50 a = numpy.linspace(-1, 1, n).tolist() b = [paraBEM.PanelVector3(i, j, k) for i in a for j in a for k in a] pot = [doublet_src_3_0_vsaero(i, p)[1] for i in b] vel = [src_3_0_vsaero_v(i, p) for i in b] writer = VtkWriter() with open(check_path("results/src_panel.vtk"), "w") as _file: writer.structed_grid(_file, "duplet", [n, n, n]) writer.points(_file, b) writer.data(_file, pot, name="potential", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, vel, name="velocity", _type="VECTORS", data_type="POINT_DATA")
import paraBEM from paraBEM.pan3d import doublet_3_0_vsaero, doublet_3_0_vsaero_v, doublet_3_0_sphere from paraBEM.vtk_export import VtkWriter import numpy from paraBEM.utils import check_path v1 = paraBEM.PanelVector3(-0.5, -0.5, 0) v2 = paraBEM.PanelVector3(0.5, -0.5, 0) v3 = paraBEM.PanelVector3(0.5, 0.5, 0) v4 = paraBEM.PanelVector3(-0.5, 0.5, 0) p = paraBEM.Panel3([v1, v2, v3, v4]) # p = paraBEM.Panel3([v1, v2, v3]) # triangle p.potential = 1. n = 50 a = numpy.linspace(-1, 1, n).tolist() b = [paraBEM.PanelVector3(i, j, k) for i in a for j in a for k in a] pot = [doublet_3_0_sphere(i, p) for i in b] vel = [doublet_3_0_vsaero_v(i, p) for i in b] writer = VtkWriter() with open(check_path("results/panel_influence.vtk"), "w") as _file: writer.structed_grid(_file, "duplet", [n, n, n]) writer.points(_file, b) writer.data(_file, pot, name="potential", _type="SCALARS", data_type="POINT_DATA") writer.data(_file, vel, name="velocity", _type="VECTORS", data_type="POINT_DATA")
import numpy import paraBEM from paraBEM.pan3d import vortex_3_0_v from paraBEM.vtk_export import VtkWriter from paraBEM.utils import check_path v1 = paraBEM.Vector3(-1, 0, 0) v2 = paraBEM.Vector3(1, 0, 0) n = 80 a = numpy.linspace(-10, 10, n).tolist() b = [paraBEM.Vector3(i, j, k) for i in a for j in a for k in a] vel = [vortex_3_0_v(v1, v2, i) for i in b] writer = VtkWriter() with open(check_path("results/vortex_field.vtk"), "w") as _file: writer.structed_grid(_file, "vortex", [n, n, n]) writer.points(_file, b) writer.data(_file, vel, name="velocity", _type="VECTORS", data_type="POINT_DATA")
# mapping the geometry vector = [paraBEM.PanelVector2(*i) for i in xy] vector += [vector[0]] # important for calculating the gradients panels = [paraBEM.Panel2([vec, vector[i+1]]) for i, vec in enumerate(vector[:-1])] vector[0].wake_vertex = True # setting up the case case = Case(panels) case.v_inf = paraBEM.Vector2(1, 0.5) case.run() nx = 100 ny = 100 space_x = np.linspace(-2, 2, nx) space_y = np.linspace(-2, 2, ny) grid = [paraBEM.Vector2(x, y) for y in space_y for x in space_x] velocity = list(map(case.off_body_velocity, grid)) pot = list(map(case.off_body_potential, grid)) with open(check_path("results/cylinder_2d_linear/field.vtk"), "w") as _file: writer = VtkWriter() writer.structed_grid(_file, "airfoil", [nx, ny, 1]) writer.points(_file, grid) writer.data(_file, velocity, name="velocity", _type="VECTORS", data_type="POINT_DATA") writer.data(_file, pot, name="pot", _type="SCALARS", data_type="POINT_DATA") with open(check_path("results/cylinder_2d_linear/shape.vtk"), "w") as _file: writer = VtkWriter() writer.unstructed_grid(_file, "airfoil") writer.points(_file, [[i[0], i[1], 0]for i in vector]) writer.lines(_file, [range(len(vector))])