Пример #1
0
def min_func(x):
    global count
    count += 1
    print("\niteration: " + str(count))
    _glider2d = deepcopy(glider2d)
    glider_set_controlpoint(_glider2d, x)
    glider3d = _glider2d.get_glider_3d()
    panels = paraBEM_Panels(glider3d,
                        midribs=0,
                        profile_numpoints=40,
                        symmetric=True,
                        distribution=Distribution.from_nose_cos_distribution(40, 0.2),
                        num_average=0)
    case = Case(panels[1], panels[2])
    case.farfield = 5
    case.drag_calc = "trefftz"
    case.A_ref = 23

    case.create_wake(length=10000, count=5)
    case.v_inf = paraBEM.Vector3(8, 0, 1)
    case.trefftz_cut_pos = case.v_inf * 50
    alpha = v_inf_deg_range3(case.v_inf, 5, 9, 20)
    polars = case.polars(alpha)
    vtk_writer = CaseToVTK(case, "results/vtk_opt", suffix=str(count))
    vtk_writer.write_panels(data_type="point")
    cL = []
    cD = []
    for i in polars.values:
        cL.append(i.cL)
        cD.append(i.cD)
    return np.interp(0.6, cL, cD)
Пример #2
0
 def create_potential_table(self):
     if not self.paraBEM:
         self.QWarning = QtGui.QLabel("no panel_method installed")
         self.layout.addWidget(self.QWarning)
     else:
         self._vertices, self._panels, self._trailing_edges = paraBEM_Panels(
             self.ParametricGlider.get_glider_3d(),
             midribs=0,
             profile_numpoints=50,
             num_average=4,
             distribution=Distribution.from_nose_cos_distribution(0.2),
             symmetric=True
             )
         case = self.pan3d.DirichletDoublet0Source0Case3(self._panels, self._trailing_edges)
         case.A_ref = self.ParametricGlider.shape.area
         case.mom_ref_point = self.paraBEM.Vector3(1.25, 0, -6)
         case.v_inf = self.paraBEM.Vector(self.ParametricGlider.v_inf)
         case.drag_calc = "trefftz"
         case.farfield = 5
         case.create_wake(10000000, 20)
         pols = case.polars(self.paraBEM_utils.v_inf_deg_range3(case.v_inf, 2, 15, 20))
         self.cL = []
         self.cDi = []
         self.cPi = []
         self.alpha = []
         for i in pols.values:
             self.alpha.append(i.alpha)
             self.cL.append(i.cL)
             self.cDi.append(i.cD)
             self.cPi.append(i.cP)
         self.alpha = np.array(self.alpha)
         self.cL = np.array(self.cL)
         self.cDi = np.array(self.cDi)
         self.cPi = np.array(self.cPi)
Пример #3
0
 def create_potential_table(self):
     if not self.paraBEM:
         self.QWarning = QtGui.QLabel('no panel_method installed')
         self.layout.addWidget(self.QWarning)
     else:
         self._vertices, self._panels, self._trailing_edges = paraBEM_Panels(
             self.parametric_glider.get_glider_3d(),
             midribs=0,
             profile_numpoints=50,
             num_average=4,
             distribution=Distribution.from_nose_cos_distribution(0.2),
             symmetric=True)
         case = self.pan3d.DirichletDoublet0Source0Case3(
             self._panels, self._trailing_edges)
         case.A_ref = self.parametric_glider.shape.area
         case.mom_ref_point = self.paraBEM.Vector3(1.25, 0, -6)
         case.v_inf = self.paraBEM.Vector(self.parametric_glider.v_inf)
         case.drag_calc = 'trefftz'
         case.farfield = 5
         case.create_wake(10000000, 20)
         pols = case.polars(
             self.paraBEM_utils.v_inf_deg_range3(case.v_inf, 2, 15, 20))
         self.cL = []
         self.cDi = []
         self.cPi = []
         self.alpha = []
         for i in pols.values:
             self.alpha.append(i.alpha)
             self.cL.append(i.cL)
             self.cDi.append(i.cD)
             self.cPi.append(i.cP)
         self.alpha = np.array(self.alpha)
         self.cL = np.array(self.cL)
         self.cDi = np.array(self.cDi)
         self.cPi = np.array(self.cPi)
Пример #4
0
def min_func(x):
    global count
    count += 1
    print("\niteration: " + str(count))
    _glider2d = deepcopy(glider2d)
    glider_set_controlpoint(_glider2d, x)
    glider3d = _glider2d.get_glider_3d()
    panels = paraBEM_Panels(
        glider3d,
        midribs=0,
        profile_numpoints=40,
        symmetric=True,
        distribution=Distribution.from_nose_cos_distribution(40, 0.2),
        num_average=0)
    case = Case(panels[1], panels[2])
    case.farfield = 5
    case.drag_calc = "trefftz"
    case.A_ref = 23

    case.create_wake(length=10000, count=5)
    case.v_inf = paraBEM.Vector3(8, 0, 1)
    case.trefftz_cut_pos = case.v_inf * 50
    alpha = v_inf_deg_range3(case.v_inf, 5, 9, 20)
    polars = case.polars(alpha)
    vtk_writer = CaseToVTK(case, "results/vtk_opt", suffix=str(count))
    vtk_writer.write_panels(data_type="point")
    cL = []
    cD = []
    for i in polars.values:
        cL.append(i.cL)
        cD.append(i.cD)
    return np.interp(0.6, cL, cD)
Пример #5
0
 def create_panels(self, midribs=0, profile_numpoints=10, mean=False, symmetric=True):
     self._vertices, self._panels, self._trailing_edges = paraBEM_Panels(
         self.ParametricGlider.get_glider_3d(),
         midribs=midribs,
         profile_numpoints=profile_numpoints,
         num_average=mean*5,
         distribution=Distribution.from_nose_cos_distribution(0.2),
         symmetric=symmetric)
Пример #6
0
 def setUp(self):
     self.glider2d = self.import_glider_2d()
     self.glider3d = self.glider2d.get_glider_3d()
     config = {"v_inf": [10, 0, 2],
               "symmetric_case": True,
               "cell_numpoints": 5,
               "distribution": Distribution.from_nose_cos_distribution(100, 0.2)
               }
     self.glidercase = GliderPanelMethod(self.glider3d, config)
Пример #7
0
    def test_glider_mesh(self):
        dist = Distribution.from_nose_cos_distribution(30, 0.2)
        dist.add_glider_fixed_nodes(self.glider)

        self.glider.profile_x_values = dist
        m = Mesh(name="glider_mesh")
        for cell in self.glider.cells[1:-1]:
            m += cell.get_mesh(0)
        for rib in self.glider.ribs:
            m += Mesh.from_rib(rib)
        m.delete_duplicates()
        m.get_indexed()
Пример #8
0
 def create_panels(self,
                   midribs=0,
                   profile_numpoints=10,
                   mean=False,
                   symmetric=True):
     self._vertices, self._panels, self._trailing_edges = paraBEM_Panels(
         self.parametric_glider.get_glider_3d(),
         midribs=midribs,
         profile_numpoints=profile_numpoints,
         num_average=mean * 5,
         distribution=Distribution.from_nose_cos_distribution(0.2),
         symmetric=symmetric)
Пример #9
0
def create_fem_dict(par_glider):
    # not yet working

    # create a paraBEM object and compute the pressure

    # create a dict with:
    #   nodes, elements, forces, bc, joints
    vertices, panels, trailing_edges = paraBEM_Panels(
        par_glider.get_glider_3d(),
        midribs=0,
        profile_numpoints=50,
        num_average=4,
        distribution=Distribution.from_nose_cos_distribution(0.2),
        symmetric=True)
Пример #10
0
def create_fem_dict(par_glider):
    # create a paraBEM object and compute the pressure

    # create a dict with:
    #   nodes, elements, forces, bc, joints
    vertices, panels, trailing_edges = paraBEM_Panels(
        par_glider.get_glider_3d(),
        midribs=0,
        profile_numpoints=50,
        num_average=4,
        distribution=Distribution.from_nose_cos_distribution(0.2),
        symmetric=True)
    case.A_ref = par_glider.flat_area
    case.v_inf = paraBEM.Vector(glider.v_inf)
    self.case.farfield = 5
    self.case.create_wake(9999, 10)
    self.case.run()
Пример #11
0
def create_fem_dict(par_glider):
    # create a paraBEM object and compute the pressure

    # create a dict with:
    #   nodes, elements, forces, bc, joints
    vertices, panels, trailing_edges = paraBEM_Panels(
        par_glider.get_glider_3d(),
        midribs=0,
        profile_numpoints=50,
        num_average=4,
        distribution=Distribution.from_nose_cos_distribution(0.2),
        symmetric=True
        )
    case.A_ref = par_glider.flat_area
    case.v_inf = paraBEM.Vector(glider.v_inf)
    self.case.farfield = 5
    self.case.create_wake(9999, 10)
    self.case.run()
Пример #12
0
    def test_run(self):
        config = {
            "v_inf": [14, 0, 2],
            "fem_timestep": 1.e-06,
            "fem_steps": 100,
            "fem_output": 10,
            "d_velocity": 1.,
            "pressure_ramp": 100,  # steps for linear pressure ramp
            "caseType": "line_forces",
            "line_numpoints": 10,
            "line_rho": 0.00001,
            "line_elasticity": 30000,
            "rib_rho": 0.00001,
            "cell_numpoints": 0,
            "vtk_fem_output": "/tmp/Fem/testFEM",
            "symmetric_case": True,
            "line_numpoints": 2,
            "distribution": Distribution.from_nose_cos_distribution(30, 0.3)
        }

        self.glidercase = GliderFemCase(self.glider3d, config)
        self.glidercase.run()
Пример #13
0
def paraBEM_Panels(glider,
                   midribs=0,
                   profile_numpoints=None,
                   num_average=0,
                   symmetric=False,
                   distribution=None):
    """return the vertices, panels and the trailing edge of a glider, as paraBEM objects.

    midribs:           midribs of a cell spanwise. if num_average is greater then
                       0 ballooning will be disables
    profile_numpoints: coordinates of every rib, choordwise
    num_average:       steps to average a cell profile
    symmetric:         set to True if a symmetric result is expected (this will
                       reduce evaluation time)
    """
    # paraBEM is not a dependency of openglider so if problems occure here, get the module.
    import paraBEM

    if symmetric:
        glider = glider.copy()
    else:
        glider = glider.copy_complete()
        glider.close_rib(0)
    glider.close_rib()

    if profile_numpoints:
        glider.profile_x_values = Distribution.from_nose_cos_distribution(
            profile_numpoints, 0.2)

    if num_average > 0:
        glider.apply_mean_ribs(num_average)
        glider.close_rib()
        ribs = glider.return_ribs(midribs, ballooning=False)
    else:
        ribs = glider.return_ribs(midribs)
    # deleting the last vertex of every rib (no trailing edge gap)
    ribs = [rib[:-1] for rib in ribs]
    # get a numbered representation + flatten vertices
    i = 0
    vertices = []
    ribs_new = []
    panels = []
    sym_panels = []
    trailing_edge = []

    for rib in ribs:
        rib_new = []
        for vertex in rib:
            rib_new.append(i)
            vertices.append(vertex)
            i += 1
        rib_new.append(rib_new[0])
        ribs_new.append(rib_new)
    ribs = ribs_new
    panel_nr = 0
    for i, rib_i in enumerate(ribs[:-1]):
        rib_j = ribs[i + 1]
        if symmetric:
            if vertices[rib_j[0]][1] > 0.00001:
                trailing_edge.append(rib_i[0])
        else:
            trailing_edge.append(rib_i[0])
        if i == len(ribs[:-2]):
            trailing_edge.append(rib_j[0])

        for k, _ in enumerate(rib_j[:-1]):
            l = k + 1
            panel = [rib_i[k], rib_j[k], rib_j[l], rib_i[l]]
            if symmetric:
                sym = True
                add_panel = False
                for p in panel:
                    if not vertices[p][
                            1] > -0.000001:  # if one point lies on the y- side
                        sym = False  # y- is the mirrored side
                    if not vertices[p][
                            1] < 0.0001:  # if one point lies on the y+ side
                        add_panel = True
                if add_panel:
                    panels.append(panel)
                    if sym:
                        sym_panels.append(panel_nr)
                    panel_nr += 1
            else:
                panels.append(panel)

    vertices = [paraBEM.PanelVector3(*point) for point in vertices]
    panels = [
        paraBEM.Panel3([vertices[nr] for nr in panel]) for panel in panels
    ]
    trailing_edge = [vertices[nr] for nr in trailing_edge]
    for nr in sym_panels:
        panels[nr].set_symmetric()

    return vertices, panels, trailing_edge
Пример #14
0
 def profile_numpoints(self, numpoints):
     self.profile_x_values = Distribution.from_nose_cos_distribution(numpoints, 0.3)
Пример #15
0
import paraEigen as eigen
import paraBEM.pan2d as bem
import paraBEM
import paraFEM as fem

import matplotlib.tri as mtri
import matplotlib.pyplot as plt

# parameters

numpoints = 80
insert_values = [0.11, 0.27, 0.5, 0.75]

# 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)
Пример #16
0
import paraBEM.pan2d as bem
import paraBEM
import paraFEM as fem

import matplotlib.tri as mtri
import matplotlib.pyplot as plt

# parameters

numpoints = 200
insert_values = [0.09, 0.22, 0.5, 0.75]

# 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(m=-0.1+0.1j, tau=0.2, numpoints=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 = paraBEM.Vector2(1, 0.1)