Ejemplo n.º 1
0
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")
Ejemplo n.º 2
0
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")
Ejemplo n.º 3
0
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,
                vel1,
                name="vel",
Ejemplo n.º 4
0
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")
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))])
Ejemplo n.º 6
0
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))])
Ejemplo n.º 7
0
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")
Ejemplo n.º 8
0
# 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")

with open(check_path("results/conformal_mapping/joukowsky_circle.vtk"), "w") as _file:
Ejemplo n.º 9
0
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))])

Ejemplo n.º 10
0
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")
Ejemplo n.º 11
0
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",
Ejemplo n.º 12
0
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")