Esempio n. 1
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)
        ])
Esempio n. 2
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)]
        )
Esempio n. 3
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])
ribs = []
Esempio n. 4
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])
ribs = []
Esempio n. 5
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
Esempio n. 6
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
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)

openglider.graphics.Graphics2D([
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)