Ejemplo n.º 1
0
from paraBEM.vtk_export import VtkWriter
import numpy as np
from paraBEM.utils import check_path

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")
Ejemplo n.º 2
0
rhs = np.zeros([2])

#    |    |
# col|+  +|
#    |    |
# x -1    1
# T  0    1
# R  1    1
# l    1
#   panel1: temp-formulation
T1 = 0
T2 = 1
R1 = 0
R2 = 0
l = 1
mat[0, 0] = source_2_0(pan1.center, pan1)
mat[0, 1] = source_2_0(pan1.center, pan2)
mat[0, 0] -= doublet_2_0(pan1.center, pan1) * l * R1
mat[0, 1] -= doublet_2_0(pan1.center, pan2) * l * R2
rhs[0] += T1

#   panel3: temp-formulation
mat[1, 0] = source_2_0(pan2.center, pan1)
mat[1, 1] = source_2_0(pan2.center, pan2)
mat[1, 0] -= doublet_2_0(pan2.center, pan1) * l * R1
mat[1, 1] -= doublet_2_0(pan2.center, pan2) * l * R2
rhs[1] += T2

sol = np.linalg.solve(mat, rhs)
print(mat)
print(rhs)
Ejemplo n.º 3
0
import numpy

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",
Ejemplo n.º 4
0
]

points = [paraBEM.PanelVector2(*point) for point in points]
panels = [
    [1, 0], [2, 1], [3, 2], [0, 3],
    [4, 5], [5, 6], [6, 7], [7, 4]
]
panels = [paraBEM.Panel2([points[i] for i in panel]) for panel in panels]

T_boundary = [0, 0, 0, 0, 1, 1, 1, 1]
mat = np.zeros([8, 8])
rhs = np.zeros([8])
for i, panel_i in enumerate(panels):
    rhs[i] = T_boundary[i]
    for j, panel_j in enumerate(panels):
        mat[i, j] = - source_2_0(panel_i.center, panel_j)
        mat[i, j] += doublet_2_0(panel_i.center, panel_j) * R

sol = np.linalg.solve(mat, rhs)


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]
Ejemplo n.º 5
0
R = 1

points = [[-2, -2], [2, -2], [2, 2], [-2, 2], [-1, -1], [1, -1], [1, 1],
          [-1, 1]]

points = [paraBEM.PanelVector2(*point) for point in points]
panels = [[1, 0], [2, 1], [3, 2], [0, 3], [4, 5], [5, 6], [6, 7], [7, 4]]
panels = [paraBEM.Panel2([points[i] for i in panel]) for panel in panels]

T_boundary = [0, 0, 0, 0, 1, 1, 1, 1]
mat = np.zeros([8, 8])
rhs = np.zeros([8])
for i, panel_i in enumerate(panels):
    rhs[i] = T_boundary[i]
    for j, panel_j in enumerate(panels):
        mat[i, j] = -source_2_0(panel_i.center, panel_j)
        mat[i, j] += doublet_2_0(panel_i.center, panel_j) * R

sol = np.linalg.solve(mat, rhs)

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
Ejemplo n.º 6
0
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")
Ejemplo n.º 7
0
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot as plt
import numpy as np

import paraBEM
from paraBEM.pan2d import doublet_2_0, source_2_0, doublet_2_0_v
from paraBEM.utils import check_path

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)
Ejemplo n.º 8
0
mat = np.zeros([3, 3])
rhs = np.zeros([3])
panels = [pan1, pan2, pan3]

#    |   |   |
# col|+ +|  +|
#    |   |   |
# x -1   0   1
# T  0   ?   1
# l    1   2
#   panel1: temp-formulation
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])