Example #1
0
 def setUp(self):
     naca = random.randint(1, 9999)
     numpoints = random.randint(10, 200)
     self.prof = openglider.Profile2D.compute_naca(naca, numpoints)
     self.rib = Rib(
         self.prof,
         startpoint=[random.random(),
                     random.random(),
                     random.random()],
         size=random.random(),
         arcang=random.random(),
         aoa=random.random(),
         glide=random.random() * 10)
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
 def setUp(self):
     naca = random.randint(1, 9999)
     numpoints = random.randint(10,200)
     self.prof = openglider.Profile2D.compute_naca(naca, numpoints)
     self.rib = Rib(self.prof,
                    startpoint=[random.random(), random.random(), random.random()],
                    size=random.random(),
                    arcang=random.random(),
                    aoa=random.random(),
                    glide=random.random()*10)
Example #4
0
    def setup_pivy(self):
        super(AoaTool, self).setup_pivy()

        arc_angles = self.parametric_glider.get_arc_angles()
        self.aoa_diff = [
            Rib._aoa_diff(arc_angle, self.parametric_glider.glide)
            for arc_angle in arc_angles
        ]
        self.aoa_absolute_curve = pp.Line([], color='blue', width=2)

        self.task_separator.addChild(self.aoa_absolute_curve.object)
Example #5
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 #6
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 #7
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 #8
0
class TestRib(unittest.TestCase):

    def setUp(self):
        naca = random.randint(1, 9999)
        numpoints = random.randint(10,200)
        self.prof = openglider.Profile2D.compute_naca(naca, numpoints)
        self.rib = Rib(self.prof,
                       startpoint=[random.random(), random.random(), random.random()],
                       size=random.random(),
                       arcang=random.random(),
                       aoa=random.random(),
                       glide=random.random()*10)


    def test_normvectors(self):
        normvectors = self.rib.normvectors

    def test_align(self):
        first = self.rib.pos
        second = self.rib.align([0, 0, 0])
        for i in range(3):
            self.assertAlmostEqual(first[i], second[i])
Example #9
0
class TestRib(unittest.TestCase):
    def setUp(self):
        naca = random.randint(1, 9999)
        numpoints = random.randint(10, 200)
        self.prof = openglider.Profile2D.compute_naca(naca, numpoints)
        self.rib = Rib(
            self.prof,
            startpoint=[random.random(),
                        random.random(),
                        random.random()],
            size=random.random(),
            arcang=random.random(),
            aoa=random.random(),
            glide=random.random() * 10)

    def test_normvectors(self):
        normvectors = self.rib.normvectors

    def test_align(self):
        first = self.rib.pos
        second = self.rib.align([0, 0, 0])
        for i in range(3):
            self.assertAlmostEqual(first[i], second[i])
Example #10
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 #11
0
a = Profile2D()
a.importdat(os.path.dirname(os.path.abspath(__file__)) + "/testprofile.dat")
#a.Numpoints = 40

midribs = [
    #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])
Example #12
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
Example #13
0
a = Profile2D()
a.importdat(os.path.dirname(os.path.abspath(__file__)) + "/testprofile.dat")
# a.Numpoints = 40

midribs = [
    # 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])
Example #14
0
def excelimport(filename):
    imp = open_workbook(filename)
    ribsheet = sheettolist(
        imp.sheet_by_index(0)
    )  ### cellnr/chord/xval/yval/arcangle/aoa/z-rot/arcrot-offset/merge/baloon
    cellsheet = sheettolist(imp.sheet_by_index(1))

    ######import profiles
    profiles = profileimp(imp.sheet_by_index(3))
    xvalues = profiles[0].XValues
    for profil in profiles:
        profil.XValues = xvalues

    ######import ballooning

    def merge(factor):
        num = int(factor)
        val = factor - num
        if val > 0 and num < len(profiles):
            prof = profiles[num] * (1 - val) + profiles[num + 1] * val
        else:
            prof = profiles[num]
        return prof

    rippen = []
    arcang = 0.
    front = [0., 0., 0.]
    for i in range(1, len(ribsheet)):
        # row: num, chord, x, y, angle, aoa, z-rot, angle-offset, merge, balloonmerge
        # airfoil:
        profil = merge(ribsheet[i, 8])

        # Ballooning

        # Rib

        # Cell

        #rippen.append(Rib(profil,front,arcang,ribsheet[i,5],zrot,glide,"Rib_"+str(i)))
        # Mittelzelle -> rib.mirror, append mirrorrib, rib
        print("jo hier kommt die Aufbauarbeit")
        """
        old mathematica code:
        	aoaabs={};
            alpha2=0;
            z=0;
            x=0;
            {
            Table[
                spw=excel[[i,3]];
                y=excel[[i,4]];
                chord=excel[[i,2]];
                alpha1=alpha2;
                alpha2+=excel[[i,5]]*Pi/180;
                If[x==0,alpha=0,alpha=(alpha1+alpha2)/2];
                If[i>1,z=z-Sin[alpha1]*(spw-excel[[i-1,3]])];
                x=x+Cos[alpha1]*(spw-If[i>1,excel[[i-1,3]],0]);

                beta=ArcTan[Cos[alpha]/gleitzahl]-excel[[i,6]]*Pi/180;(*Anstellwinkel*)
                AppendTo[aoaabs,{spw,-beta*180/Pi}];
                gamma=ArcTan[Sin[alpha]/gleitzahl]*excel[[i,7]];(*faktor 0-1; winkel um profilz-achse*)
                rot1=RotationMatrix[alpha+excel[[i,8]]/180.*Pi,{0,1,0}];(*um profilxachse, +offset*)
                rot2=RotationMatrix[beta,rot1.{1,0,0}].rot1;
                rot3=RotationMatrix[gamma,rot2.{0,0,1}].rot2;
                rot=chord*rot3;
                trans={x,y,z};
                {trans,rot},{i,Length[excel]}]
        """
        ab = Rib()

        ab.profile_2d = merge(ribsheet[i, 8])
        ab.AOA = [ribsheet[i, 6], False]
        #ab.arcang=
        ab.name = "rib" + str(i + 1)
        #ab.glide
        #ab.zrot
        #ab.pos
        #ab.ReCalc()

        rippen.append(ab)
        ###bp=int(fak) fak=fak-int(fak)
        ###if fak>0 -> bneu=b[bp]*(1-fak)+bneu[bp+1]*fak else b[bp]
        ###

        Graphics[[Line(i.profile3D) for i in rippen]]

    return rippen
Example #15
0
def excelimport(filename):
    imp = open_workbook(filename)
    ribsheet = sheettolist(
        imp.sheet_by_index(0)) ### cellnr/chord/xval/yval/arcangle/aoa/z-rot/arcrot-offset/merge/baloon
    cellsheet = sheettolist(imp.sheet_by_index(1))

    ######import profiles
    profiles = profileimp(imp.sheet_by_index(3))
    xvalues = profiles[0].XValues
    for profil in profiles:
        profil.XValues = xvalues

    ######import ballooning



    def merge(factor):
        num = int(factor)
        val = factor - num
        if val > 0 and num < len(profiles):
            prof = profiles[num] * (1 - val) + profiles[num + 1] * val
        else:
            prof = profiles[num]
        return prof

    rippen = []
    arcang = 0.
    front = [0., 0., 0.]
    for i in range(1, len(ribsheet)):
        # row: num, chord, x, y, angle, aoa, z-rot, angle-offset, merge, balloonmerge
        # airfoil:
        profil = merge(ribsheet[i, 8])


        # Ballooning


        # Rib


        # Cell

        #rippen.append(Rib(profil,front,arcang,ribsheet[i,5],zrot,glide,"Rib_"+str(i)))
        # Mittelzelle -> rib.mirror, append mirrorrib, rib
        print("jo hier kommt die Aufbauarbeit")
        """
        old mathematica code:
        	aoaabs={};
            alpha2=0;
            z=0;
            x=0;
            {
            Table[
                spw=excel[[i,3]];
                y=excel[[i,4]];
                chord=excel[[i,2]];
                alpha1=alpha2;
                alpha2+=excel[[i,5]]*Pi/180;
                If[x==0,alpha=0,alpha=(alpha1+alpha2)/2];
                If[i>1,z=z-Sin[alpha1]*(spw-excel[[i-1,3]])];
                x=x+Cos[alpha1]*(spw-If[i>1,excel[[i-1,3]],0]);

                beta=ArcTan[Cos[alpha]/gleitzahl]-excel[[i,6]]*Pi/180;(*Anstellwinkel*)
                AppendTo[aoaabs,{spw,-beta*180/Pi}];
                gamma=ArcTan[Sin[alpha]/gleitzahl]*excel[[i,7]];(*faktor 0-1; winkel um profilz-achse*)
                rot1=RotationMatrix[alpha+excel[[i,8]]/180.*Pi,{0,1,0}];(*um profilxachse, +offset*)
                rot2=RotationMatrix[beta,rot1.{1,0,0}].rot1;
                rot3=RotationMatrix[gamma,rot2.{0,0,1}].rot2;
                rot=chord*rot3;
                trans={x,y,z};
                {trans,rot},{i,Length[excel]}]
        """
        ab = Rib()

        ab.profile_2d = merge(ribsheet[i, 8])
        ab.AOA = [ribsheet[i, 6], False]
        #ab.arcang=
        ab.name = "rib" + str(i + 1)
        #ab.glide
        #ab.zrot
        #ab.pos
        #ab.ReCalc()

        rippen.append(ab)
        ###bp=int(fak) fak=fak-int(fak)
        ###if fak>0 -> bneu=b[bp]*(1-fak)+bneu[bp+1]*fak else b[bp]
        ###

        Graphics[[Line(i.profile3D) for i in rippen]]

    return rippen
import openglider.airfoil
from openglider.glider.ballooning import BallooningBezier
from openglider.plots.projection import flatten_list
import openglider.plots
from openglider.glider.cell import Cell
from openglider.glider.rib import Rib
import numpy
__author__ = 'simon'

prof = openglider.airfoil.Profile2D()
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)
Example #17
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 #18
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
from openglider.glider.ballooning import BallooningBezier
from openglider.plots.projection import flatten_list
import openglider.plots
from openglider.glider.cell import Cell
from openglider.glider.rib import Rib
import numpy
__author__ = 'simon'


prof = openglider.airfoil.Profile2D()
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)