示例#1
0
    def show_pressure(self):
        import paraBEM
        from paraBEM.pan2d import DirichletDoublet0Source0Case2

        # 1. get the panels from the airfoil
        self.current_airfoil.apply_splines()
        coords = self.current_airfoil.data[:-1]
        pans = []
        vertices = []
        vertices = [paraBEM.PanelVector2(*i) for i in coords]
        vertices[0].wake_vertex = True
        for i, coord in enumerate(coords):
            j = (i + 1 if (i + 1) < len(coords) else 0)
            pan = paraBEM.Panel2([vertices[i], vertices[j]])
            pans.append(pan)
        # 2. compute pressure
        case = DirichletDoublet0Source0Case2(pans)
        alpha = np.deg2rad(self.Qalpha.value())
        case.v_inf = paraBEM.Vector2(np.cos(alpha), np.sin(alpha))
        case.run()
        for pan in pans:
            p0 = pan.center
            p1 = p0 + pan.n * pan.cp * 0.03
            l = [[*p0, 0.], [*p1, 0.]]  # adding z-value
            self.pressure_sep += pp.Line(l).object
        return True
示例#2
0
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)]))
示例#3
0
from paraBEM.pan2d import doublet_2_1
import paraBEM
import numpy as np

v1 = paraBEM.PanelVector2(-1, 0)
v2 = paraBEM.PanelVector2(1, 0)
panel = paraBEM.Panel2([v2, v1])

vals = ([
    doublet_2_1(paraBEM.Vector2(x, 0), panel, True)
    for x in np.linspace(-2, 2, 20)
])
print(vals)
示例#4
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",
# -*- coding: utf-8 -*-
import numpy as np

import paraBEM
from paraBEM.airfoil import Airfoil
from paraBEM.utils import check_path
from paraBEM.vtk_export import VtkWriter
from paraBEM.pan2d import DirichletDoublet1Case2 as Case

# geometry
airfoil = Airfoil.trefftz_kutta(-0.1 + 0.0j, np.deg2rad(30))
airfoil.numpoints = 50
points = [paraBEM.PanelVector2(*i) for i in airfoil.coordinates[:-1]]
points[0].wake_vertex = True
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)
示例#6
0
from paraBEM.pan2d import DirichletDoublet1Case2 as Case
from paraBEM.utils import check_path
from paraBEM.vtk_export import VtkWriter

# geometry
numpoints = 100
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
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))
示例#7
0
import paraBEM
from paraBEM.pan2d import DirichletDoublet0Case2 as Case
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 + [x1[0]])))
示例#8
0
# 1: erstelle ein profil

dist = Distribution.from_nose_cos_distribution(numpoints, 0.2)
dist.insert_values(insert_values)
fixed = [list(dist.data).index(value) for value in insert_values]
boundary = range(len(dist))

airfoil = Profile2D.compute_trefftz(-0.1, 0.2, 100)
airfoil.x_values = dist

# 2: berechne druckverteilung (bem)
vertices = [paraBEM.PanelVector2(*point) for point in airfoil.data[:-1]]
vertices.append(vertices[0])
vertices[0].wake_vertex = True

panels = [paraBEM.Panel2(vertices[i:i + 2]) for i in range(len(vertices) - 1)]
case = bem.DirichletDoublet0Source0Case2(panels)
case.v_inf = eigen.vector2(1, 0.2)
case.run()
pressure = [
    0.01 * panel.cp * panel.l * 1.2 * 11**2 / 2 for panel in case.panels
]

# 3: mesh das profil

points = airfoil.data[:-1]
edges = np.array(range(len(points)))
edges = np.array([edges, edges + 1]).T
edges[-1, -1] = 0

info = triangle.MeshInfo()
示例#9
0
from __future__ import division
import numpy as np
import paraBEM
from paraBEM.pan2d import doublet_2_0, doublet_2_0_v, source_2_0, source_2_0_v
from paraBEM.vtk_export import VtkWriter
from paraBEM.utils import check_path

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)
示例#10
0
airfoil = Airfoil.trefftz_kutta(-0.1 + 0.00j, np.deg2rad(10))
airfoil.numpoints = 100

coordinates_1 = np.array(airfoil.coordinates[:-1])
coordinates_1 = list(map(list, coordinates_1))
pan_vectors_1 = list(map(paraBEM.PanelVector2, coordinates_1))
pan_vectors_1[0].wake_vertex = True

coordinates_2 = np.array(airfoil.coordinates[:-1]) + np.array([2.2, -0.3])
coordinates_2 = list(map(list, coordinates_2 * 0.5))
pan_vectors_2 = list(map(paraBEM.PanelVector2, coordinates_2))
pan_vectors_2[0].wake_vertex = True
panels = []
panels += [
    paraBEM.Panel2([pan_vec, pan_vectors_1[i + 1]])
    for i, pan_vec in enumerate(pan_vectors_1[:-1])
]
panels.append(paraBEM.Panel2([pan_vectors_1[-1], pan_vectors_1[0]]))

panels += [
    paraBEM.Panel2([pan_vec, pan_vectors_2[i + 1]])
    for i, pan_vec in enumerate(pan_vectors_2[:-1])
]
panels.append(paraBEM.Panel2([pan_vectors_2[-1], pan_vectors_2[0]]))
case = Case(panels)
case.v_inf = paraBEM.Vector2(1, 0.05)
case.run()

# nx = 200
# ny = 200
示例#11
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)