Example #1
0
    def setUp(self, numpoints=100):
        self.prof1 = Profile2D.compute_naca(1223)
        self.prof2 = Profile2D.compute_naca(1223)
        for prof in [self.prof1, self.prof2]:
            naca = random.randint(1, 1399)
            # prof.compute_naca(naca=1223, numpoints=numpoints)
            prof.close()
            prof.normalize()
        self.ballooning = BallooningBezier()
        self.rib2 = Rib(self.prof1, self.ballooning, [0.0, 0.12, 0], 1.0, 20 * math.pi / 180, 2 * math.pi / 180, 0, 7.0)
        self.rib3 = Rib(
            self.prof2, self.ballooning, [0.2, 0.3, -0.1], 0.8, 30 * math.pi / 180, 5 * math.pi / 180, 0, 7.0
        )
        self.rib1 = self.rib2.copy()
        self.rib1.mirror()

        self.cell1 = Cell(self.rib1, self.rib2)
        self.cell2 = Cell(self.rib2, self.rib3)
Example #2
0
    def setUp(self, numpoints=100):
        self.prof1 = Profile2D.compute_naca(1223)
        self.prof2 = Profile2D.compute_naca(1223)
        for prof in [self.prof1, self.prof2]:
            naca = random.randint(1, 1399)
            #prof.compute_naca(naca=1223, numpoints=numpoints)
            prof.close()
            prof.normalize()
        self.ballooning = BallooningBezier()
        self.rib2 = Rib(self.prof1, self.ballooning, [0., 0.12, 0], 1.,
                        20 * math.pi / 180, 2 * math.pi / 180, 0, 7.)
        self.rib3 = Rib(self.prof2, self.ballooning, [0.2, 0.3, -0.1], 0.8,
                        30 * math.pi / 180, 5 * math.pi / 180, 0, 7.)
        self.rib1 = self.rib2.copy()
        self.rib1.mirror()

        self.cell1 = Cell(self.rib1, self.rib2)
        self.cell2 = Cell(self.rib2, self.rib3)
Example #3
0
class TestCell(unittest.TestCase):
    def setUp(self, numpoints=100):
        self.prof1 = Profile2D.compute_naca(1223)
        self.prof2 = Profile2D.compute_naca(1223)
        for prof in [self.prof1, self.prof2]:
            naca = random.randint(1, 1399)
            #prof.compute_naca(naca=1223, numpoints=numpoints)
            prof.close()
            prof.normalize()
        self.ballooning = BallooningBezier()
        self.rib2 = Rib(self.prof1, self.ballooning, [0., 0.12, 0], 1.,
                        20 * math.pi / 180, 2 * math.pi / 180, 0, 7.)
        self.rib3 = Rib(self.prof2, self.ballooning, [0.2, 0.3, -0.1], 0.8,
                        30 * math.pi / 180, 5 * math.pi / 180, 0, 7.)
        self.rib1 = self.rib2.copy()
        self.rib1.mirror()

        self.cell1 = Cell(self.rib1, self.rib2)
        self.cell2 = Cell(self.rib2, self.rib3)

    def test_show_cell(self, num=10):
        #print(self.rib1.profile_2d.x_values)
        ribs = [self.cell1.midrib(x * 1. / num) for x in range(num)]
        ribs += [self.cell2.midrib(x * 1. / num) for x in range(num)]
        Graph.Graphics([Graph.Line(x.data) for x in ribs] +
                       [Graph.Line(self.rib1.profile_3d.data)])

    def test_mirror(self):
        cell1 = self.cell2
        cell2 = self.cell2.copy()
        cell2.mirror()
        print(cell1._basic_cell.normvectors)
        print([[p, normvector] for p, normvector in zip(
            cell1.prof2.data, cell1._basic_cell.normvectors)])
        Graph.Graphics([
            Graph.Line(cell1.rib1.profile_3d.data),
            Graph.Line(cell2.rib1.profile_3d.data), Graph.Red,
            Graph.Line(cell1.prof2.data),
            Graph.Line(cell2.prof2.data), Graph.Green
        ] + [
            Graph.Line([p, p + normvector]) for p, normvector in zip(
                cell2.prof2.data, cell2.basic_cell.normvectors)
        ])
Example #4
0
class TestCell(unittest.TestCase):
    def setUp(self, numpoints=100):
        self.prof1 = Profile2D.compute_naca(1223)
        self.prof2 = Profile2D.compute_naca(1223)
        for prof in [self.prof1, self.prof2]:
            naca = random.randint(1, 1399)
            # prof.compute_naca(naca=1223, numpoints=numpoints)
            prof.close()
            prof.normalize()
        self.ballooning = BallooningBezier()
        self.rib2 = Rib(self.prof1, self.ballooning, [0.0, 0.12, 0], 1.0, 20 * math.pi / 180, 2 * math.pi / 180, 0, 7.0)
        self.rib3 = Rib(
            self.prof2, self.ballooning, [0.2, 0.3, -0.1], 0.8, 30 * math.pi / 180, 5 * math.pi / 180, 0, 7.0
        )
        self.rib1 = self.rib2.copy()
        self.rib1.mirror()

        self.cell1 = Cell(self.rib1, self.rib2)
        self.cell2 = Cell(self.rib2, self.rib3)

    def test_show_cell(self, num=10):
        # print(self.rib1.profile_2d.x_values)
        ribs = [self.cell1.midrib(x * 1.0 / num) for x in range(num)]
        ribs += [self.cell2.midrib(x * 1.0 / num) for x in range(num)]
        Graph.Graphics([Graph.Line(x.data) for x in ribs] + [Graph.Line(self.rib1.profile_3d.data)])

    def test_mirror(self):
        cell1 = self.cell2
        cell2 = self.cell2.copy()
        cell2.mirror()
        print(cell1._basic_cell.normvectors)
        print([[p, normvector] for p, normvector in zip(cell1.prof2.data, cell1._basic_cell.normvectors)])
        Graph.Graphics(
            [
                Graph.Line(cell1.rib1.profile_3d.data),
                Graph.Line(cell2.rib1.profile_3d.data),
                Graph.Red,
                Graph.Line(cell1.prof2.data),
                Graph.Line(cell2.prof2.data),
                Graph.Green,
            ]
            + [Graph.Line([p, p + normvector]) for p, normvector in zip(cell2.prof2.data, cell2.basic_cell.normvectors)]
        )
Example #5
0
    #MiniRib(0.2, 0.8, 1),
    MiniRib(0.5, 0.7, 1),
    #MiniRib(0.8, 0.8, 1),
]

b1 = BallooningBezier()
b2 = BallooningBezier()
b2.Amount *= 0.8

r2 = Rib(a, b1, [0, 0.12, 0], 1., 20 * math.pi / 180, 2 * math.pi / 180, 0, 7)
r1 = r2.copy()
r1.mirror()
r3 = Rib(a, b2, [0.2, 0.3, -0.1], 0.8, 30 * math.pi / 180, 5 * math.pi / 180, 0, 7)


cell1 = Cell(r1, r2, midribs)
cell1.recalc()
cell2 = Cell(r2, r3, [])
cell2.recalc()

num = 20
#ribs = [cell1.midrib(x*1./num) for x in range(num+1)]
#ribs += [cell2.midrib(x*1./num) for x in range(num+1)]
#G.Graphics3D([G.Line(r1.profile_3d.data),G.Line(r2.profile_3d.data),G.Line([[0.,0.,0.],[1.,0.,0.]]),G.Line([[0.,0.,0.],[0.,0.5,0.]])])
#Graph.Graphics3D([Graph.Line(x.data) for x in ribs])
ribs = []
for x in range(num + 1):
    ribs.append(cell1.midrib(x * 1. / num).data)
for x in range(1, num + 1):
    ribs.append(cell2.midrib(x * 1. / num).data)
ribs = numpy.concatenate(ribs)
Example #6
0
    # MiniRib(0.2, 0.8, 1),
    MiniRib(0.5, 0.7, 1),
    # MiniRib(0.8, 0.8, 1),
]

b1 = BallooningBezier()
b2 = BallooningBezier()
b2.Amount *= 0.8

r2 = Rib(a, b1, [0, 0.12, 0], 1.0, 20 * math.pi / 180, 2 * math.pi / 180, 0, 7)
r1 = r2.copy()
r1.mirror()
r3 = Rib(a, b2, [0.2, 0.3, -0.1], 0.8, 30 * math.pi / 180, 5 * math.pi / 180, 0, 7)


cell1 = Cell(r1, r2, midribs)
cell1.recalc()
cell2 = Cell(r2, r3, [])
cell2.recalc()

num = 20
# ribs = [cell1.midrib(x*1./num) for x in range(num+1)]
# ribs += [cell2.midrib(x*1./num) for x in range(num+1)]
# G.Graphics3D([G.Line(r1.profile_3d.data),G.Line(r2.profile_3d.data),G.Line([[0.,0.,0.],[1.,0.,0.]]),G.Line([[0.,0.,0.],[0.,0.5,0.]])])
# Graph.Graphics3D([Graph.Line(x.data) for x in ribs])
ribs = []
for x in range(num + 1):
    ribs.append(cell1.midrib(x * 1.0 / num).data)
for x in range(1, num + 1):
    ribs.append(cell2.midrib(x * 1.0 / num).data)
ribs = numpy.concatenate(ribs)
Example #7
0
def import_ods(filename, glider=None):
    ods = ezodf.opendoc(filename)
    sheets = ods.sheets
    # Profiles -> map xvalues
    profiles = [Profile2D(profile) for profile in transpose_columns(sheets[3])]
    xvalues = sorted(profiles, key=lambda prof: prof.numpoints)[0].x_values  # Use airfoil with maximum profilepoints
    for profile in profiles:
        profile.x_values = xvalues
        # Ballooning old : 1-8 > upper (prepend/append (0,0),(1,0)), 9-16 > lower (same + * (1,-1))
    balloonings_temp = transpose_columns(sheets[4])
    balloonings = []
    for baloon in balloonings_temp:
        upper = [[0, 0]] + baloon[:7] + [[1, 0]]
        lower = [[0, 0]] + [[i[0], -1 * i[1]] for i in baloon[8:15]] + [[1, 0]]
        balloonings.append(BallooningBezier([upper, lower]))

    # Data
    data = {}
    datasheet = sheets[-1]
    assert isinstance(datasheet, ezodf.Sheet)
    for i in range(datasheet.nrows()):
        data[datasheet.get_cell([i, 0]).value] = datasheet.get_cell([i, 1]).value
        #print(data["GLEITZAHL"])
    glider.data = data

    cells = []
    main = sheets[0]
    x = y = z = span_last = 0.
    alpha2 = 0.
    thisrib = None
    # TODO: Glide -> DATAIMPORT
    for i in range(1, main.nrows()):
        line = [main.get_cell([i, j]).value for j in range(main.ncols())]
        if not line[0]:
            #print("leere zeile:", i, main.nrows())
            break

        chord = line[1]  # Rib-Chord
        span = line[2]  # spanwise-length (flat)
        alpha1 = alpha2  # angle before the rib
        alpha2 += line[4] * numpy.pi / 180  # angle after the rib
        alpha = (span > 0) * (alpha1 + alpha2) * 0.5 + line[6] * numpy.pi / 180  # rib's angle
        x = line[3]  # x-value -> front/back (ribwise)
        y += numpy.cos(alpha1) * (span - span_last)  # y-value -> spanwise
        z -= numpy.sin(alpha1) * (span - span_last)  # z-axis -> up/down
        aoa = line[5] * numpy.pi / 180
        zrot = line[7] * numpy.pi / 180
        span_last = span

        profile = merge(line[8], profiles)
        ballooning = merge(line[9], balloonings)

        lastrib = thisrib
        thisrib = Rib(profile, ballooning, numpy.array([x, y, z]), chord, alpha, aoa, zrot, data["GLEITZAHL"])
        if i == 1 and y != 0:  # Middle-cell
            #print("midrib!", y)
            lastrib = thisrib.copy()
            lastrib.mirror()
        if lastrib:
            cell = Cell(lastrib, thisrib, [])
            cell.name = "Cell_no"+str(i)
            cells.append(cell)




    if glider:
        glider.cells = cells
        glider.close_rib()
        glider.attachment_points = read_elements(sheets[2], "AHP", AttachmentPoint)
        glider.attachment_points_lower = get_lower_aufhaengepunkte(glider.data)
        for p in glider.attachment_points:
            p.force = numpy.array([0, 0, 1])
            p.get_position(glider)

        glider.lines = tolist_lines(sheets[6], glider.attachment_points_lower, glider.attachment_points)
        glider.lines.calc_geo()
        glider.lines.calc_sag()

        return
    return cells
Example #8
0
def import_ods(filename, glider):
    ods = ezodf.opendoc(filename)
    sheets = ods.sheets
    # Profiles -> map xvalues
    profiles = [Profile2D(profile) for profile in transpose_columns(sheets[3])]
    xvalues = sorted(profiles, key=lambda prof: prof.numpoints)[0].x_values  # Use airfoil with maximum profilepoints
    for profile in profiles:
        profile.x_values = xvalues

    # Ballooning old : 1-8 > upper (prepend/append (0,0),(1,0)), 9-16 > lower (same + * (1,-1))
    balloonings_temp = transpose_columns(sheets[4])
    balloonings = []
    for baloon in balloonings_temp:
        upper = [[0, 0]] + baloon[:7] + [[1, 0]]
        lower = [[0, 0]] + [[i[0], -1 * i[1]] for i in baloon[8:15]] + [[1, 0]]
        balloonings.append(BallooningBezier(upper, lower))

    # Data
    data = {}
    datasheet = sheets[-1]
    assert isinstance(datasheet, ezodf.Sheet)
    for i in range(datasheet.nrows()):
        data[datasheet.get_cell([i, 0]).value] = datasheet.get_cell([i, 1]).value
        #print(data["GLEITZAHL"])
    glider.data = data

    cells = []
    main = sheets[0]
    x = y = z = span_last = 0.
    alpha2 = 0.
    thisrib = None
    for i in range(1, main.nrows()):
        line = [main.get_cell([i, j]).value for j in range(main.ncols())]
        if not line[0]:
            break  # skip empty line

        chord = line[1]  # Rib-Chord
        span = line[2]  # spanwise-length (flat)
        alpha1 = alpha2  # angle before the rib
        alpha2 += line[4] * np.pi / 180  # angle after the rib
        alpha = (span > 0) * (alpha1 + alpha2) * 0.5 + line[6] * np.pi / 180  # rib's angle
        x = line[3]  # x-value -> front/back (ribwise)
        y += np.cos(alpha1) * (span - span_last)  # y-value -> spanwise
        z -= np.sin(alpha1) * (span - span_last)  # z-axis -> up/down
        aoa = line[5] * np.pi / 180
        zrot = line[7] * np.pi / 180
        span_last = span

        profile = merge(line[8], profiles)
        ballooning = merge(line[9], balloonings)

        lastrib = thisrib
        thisrib = Rib(profile, np.array([x, y, z]), chord, alpha, aoa, zrot, data["GLIDE"],
                      name="Rib ({})".format(i))
        if i == 1 and y != 0:  # Middle-cell
            #print("midrib!", y)
            lastrib = thisrib.copy()
            lastrib.mirror()
        if lastrib:
            cell = Cell(lastrib, thisrib, ballooning)
            cell.name = "Cell_no"+str(i)
            cells.append(cell)

    glider.cells = cells
    glider.close_rib()

    ######################################LINESET######################################################
    attachment_points = [AttachmentPoint(glider.ribs[args[0]], args[1], args[2]) for args in read_elements(sheets[2], "AHP", len_data=2)]
    attachment_points.sort(key=lambda element: element.name)
    attachment_points_lower = get_lower_aufhaengepunkte(glider.data)

    for p in attachment_points:
        p.force = np.array([0, 0, 10])
        p.get_position()

    glider.lineset = tolist_lines(sheets[6], attachment_points_lower, attachment_points)
    glider.lineset.recalc()

    ####################################PANELS##########################################################
    cuts = [cut+[1, glider.data["Designzugabe"]] for cut in read_elements(sheets[1], "DESIGNO")]
    cuts += [cut+[1, glider.data["Designzugabe"]] for cut in read_elements(sheets[1], "DESIGNM")]
    cuts += [cut+[2, glider.data["EKzugabe"]] for cut in read_elements(sheets[1], "EKV")]
    cuts += [cut+[2, glider.data["EKzugabe"]] for cut in read_elements(sheets[1], "EKH")]
    for i, cell in enumerate(glider.cells):  # cut = [cell_no, x_left, x_right, cut_type, amount_add]
        cuts_this = [cut for cut in cuts if cut[0] == i]
        cuts_this.sort(key=lambda cut: cut[1])
        cuts_this.sort(key=lambda cut: cut[2])
        # Insert leading-/trailing-edge
        cuts_this.insert(0, [i, -1, -1, 3, glider.data["HKzugabe"]])
        cuts_this.append([i, 1, 1, 3, glider.data["HKzugabe"]])
        cell.panels = []
        for j in range(len(cuts_this)-1):
            if cuts_this[j][3] != 2 or cuts_this[j+1][3] != 2:  # skip entry
                cell.panels.append(Panel(cuts_this[j][1:], cuts_this[j+1][1:]))
    return glider
Example #9
0
import tempfile
from openglider.airfoil.parametric import BezierProfile2D

from openglider.glider.cell import Cell
from openglider.glider.rib import Rib
from openglider.glider import Glider
from openglider.glider.ballooning import BallooningBezier
from openglider.graphics import Graphics3D, Polygon, Line
from openglider.glider.in_out.export_3d import export_obj

path = "/tmp/cell.obj"
# a tool to optimize a parafoil for a given cell geometry
ar = 0.1

bal = BallooningBezier()
profile = BezierProfile2D.compute_naca(2412)

rib0 = Rib(profile, [0, -ar / 2, 0], 1, 0., 0., 0., 999999.)
rib1 = Rib(profile, [0, ar / 2, 0], 1, 0., 0., 0., 999999.)
cell1 = Cell(rib0, rib1, bal)
glider = Glider([cell1])
export_obj(glider, path, midribs=40, numpoints=50, floatnum=6, copy=False)
Example #10
0
    def get_glider_3d(self, glider=None, num=50, num_profile=None):
        """returns a new glider from parametric values"""
        glider = glider or Glider()
        ribs = []

        self.rescale_curves()

        x_values = self.shape.rib_x_values
        shape_ribs = self.shape.ribs

        profile_merge_curve = self.profile_merge_curve.interpolation(num=num)
        ballooning_merge_curve = self.ballooning_merge_curve.interpolation(
            num=num)
        aoa_int = self.aoa.interpolation(num=num)
        zrot_int = self.zrot.interpolation(num=num)

        arc_pos = list(self.arc.get_arc_positions(x_values))
        rib_angles = self.arc.get_rib_angles(x_values)

        if self.num_profile is not None:
            num_profile = self.num_profile

        if num_profile is not None:
            profile_x_values = Distribution.from_cos_distribution(num_profile)
        else:
            profile_x_values = self.profiles[0].x_values

        rib_holes = self.elements.get("holes", [])
        rigids = self.elements.get("rigidfoils", [])

        cell_centers = [(p1 + p2) / 2
                        for p1, p2 in zip(x_values[:-1], x_values[1:])]
        offset_x = shape_ribs[0][0][1]
        for rib_no, pos in enumerate(x_values):
            front, back = shape_ribs[rib_no]
            arc = arc_pos[rib_no]
            startpoint = np.array([-front[1] + offset_x, arc[0], arc[1]])

            chord = abs(front[1] - back[1])
            factor = profile_merge_curve(abs(pos))
            profile = self.get_merge_profile(factor)
            profile.name = "Profile{}".format(rib_no)
            profile.x_values = profile_x_values

            this_rib_holes = [
                RibHole(ribhole["pos"], ribhole["size"])
                for ribhole in rib_holes if rib_no in ribhole["ribs"]
            ]
            this_rigid_foils = [
                RigidFoil(rigid["start"], rigid["end"], rigid["distance"])
                for rigid in rigids if rib_no in rigid["ribs"]
            ]

            ribs.append(
                Rib(profile_2d=profile,
                    startpoint=startpoint,
                    chord=chord,
                    arcang=rib_angles[rib_no],
                    glide=self.glide,
                    aoa_absolute=aoa_int(pos),
                    zrot=zrot_int(pos),
                    holes=this_rib_holes,
                    rigidfoils=this_rigid_foils,
                    name="rib{}".format(rib_no)))
            ribs[-1].aoa_relative = aoa_int(pos)

        if self.shape.has_center_cell:
            new_rib = ribs[0].copy()
            new_rib.name = "rib0"
            new_rib.mirror()
            new_rib.mirrored_rib = ribs[0]
            ribs.insert(0, new_rib)
            cell_centers.insert(0, 0.)

        glider.cells = []
        for cell_no, (rib1, rib2) in enumerate(zip(ribs[:-1], ribs[1:])):
            ballooning_factor = ballooning_merge_curve(cell_centers[cell_no])
            ballooning = self.merge_ballooning(ballooning_factor)
            cell = Cell(rib1, rib2, ballooning, name="c{}".format(cell_no + 1))

            glider.cells.append(cell)

        glider.close_rib()

        # CELL-ELEMENTS
        self.get_panels(glider)
        self.apply_diagonals(glider)

        for minirib in self.elements.get("miniribs", []):
            data = minirib.copy()
            cells = data.pop("cells")
            for cell_no in cells:
                glider.cells[cell_no].miniribs.append(MiniRib(**data))

        # RIB-ELEMENTS
        #self.apply_holes(glider)

        glider.rename_parts()

        glider.lineset = self.lineset.return_lineset(glider, self.v_inf)
        glider.lineset.glider = glider
        glider.lineset.calculate_sag = False
        for _ in range(3):
            glider.lineset.recalc()
        glider.lineset.calculate_sag = True
        glider.lineset.recalc()

        return glider
prof.importdat(os.path.dirname(os.path.abspath(__file__)) + "/testprofile.dat")

ballooning = BallooningBezier()
balloon = [ballooning(i) for i in prof.x_values]

r1 = Rib(prof, ballooning, [0., 0.12, 0], 1., 20 * math.pi / 180,
         2 * math.pi / 180, 0, 7.)
r2 = r1.copy()
r2.mirror()

left, right = flatten_list(r2.profile_3d.data, r1.profile_3d.data)
ding = [numpy.array([0, 0]), numpy.array([1., 0])]

#[numpy.array([0,0]),numpy.array([1,0])

cell = Cell(r1, r2)
left2, right2 = flattened_cell(cell)
left_out = left2.copy()
left_out.add_stuff(-0.02)
right_out = right2.copy()
right_out.add_stuff(0.02)

openglider.graphics.Graphics2D([
    openglider.graphics.Line(left.data),
    openglider.graphics.Line(right.data),
    openglider.graphics.Line(left2.data),
    openglider.graphics.Line(right2.data),
    openglider.graphics.Line(left_out.data),
    openglider.graphics.Line(right_out.data)
])