Ejemplo n.º 1
0
    def _BuildRibs(self, ChordFactor, ScaleFactor):
        """Generates Ribs surface along the wingspan, given the general,
        nondimensional parameters of the object (variations of chord length,
        dihedral, etc.) and the two scaling factors.

        Parameters
        ----------
        ChordFactor - float
            Factor againt which the standard shape is scaled in the chordwise
            direction
        ScaleFactor - float
            Factor againt which the standard shape is scaled in the world
            coordinates

        Returns
        -------
        Ribs : TopoDS_Shape
            The generated Ribs surface
        """
        SectionsRibs = []
        RibsFace = []

        Step = (self.SegmentNoLoft) / (self.NoRibs - 1)
        LEPointsR = self._GenerateLeadingEdge()
        Eps = np.linspace(0, 1, self.SegmentNoLoft + 1)
        SectionsRibs = [
            self.AirfoilFunct(Eps[i], LEPointsR[i], self.ChordFunct,
                              ChordFactor, self.DihedralFunct,
                              self.TwistFunct).Curve
            for i in xrange(0, self.SegmentNoLoft + 1, Step)
        ]

        LESpar, TESpar, MIDSpar, StringerUp, StringerDown, PointsUp, PointsDown = self._BuildSpars(
            self.ChordFactor, self.ScaleFactor)

        # RIBS generated from segments
        for i in range(0, self.NoRibs):
            for ii in range(0, self.NoStiffners - 1):
                SegUp = GC_MakeSegment(
                    PointsUp[ii + i * self.NoStiffners * (Step)],
                    PointsUp[ii + i * self.NoStiffners * (Step) + 1]).Value()
                SegDown = GC_MakeSegment(
                    PointsDown[ii + i * self.NoStiffners * (Step) + 1],
                    PointsDown[ii + i * self.NoStiffners * (Step)]).Value()
                SegSide1 = GC_MakeSegment(
                    PointsDown[ii + i * self.NoStiffners * (Step)],
                    PointsUp[ii + i * self.NoStiffners * (Step)]).Value()
                SegSide2 = GC_MakeSegment(
                    PointsUp[ii + i * self.NoStiffners * (Step) + 1],
                    PointsDown[ii + i * self.NoStiffners * (Step) +
                               1]).Value()
                EdgeSegUp = act.make_edge(SegUp)
                EdgeSegDown = act.make_edge(SegDown)
                EdgeSide1 = act.make_edge(SegSide1)
                EdgeSide2 = act.make_edge(SegSide2)
                WireRib = act.make_wire(
                    [EdgeSide1, EdgeSegUp, EdgeSide2, EdgeSegDown])
                FaceRibi = act.make_face(WireRib)
                if self.ScaleFactor != 1:
                    Origin = gp_Pnt(0., 0., 0.)
                    FaceRib = act.scale_uniformal(FaceRibi, Origin,
                                                  self.ScaleFactor)
                    RibsFace.append(FaceRib)

        return SectionsRibs, RibsFace
Ejemplo n.º 2
0
    def _BuildPanels(self, ChordFactor, ScaleFactor):

        LESpar, TESpar, MIDSpar, StringerUp, StringerDown, PointsUp, PointsDown = self._BuildSpars(
            self.ChordFactor, self.ScaleFactor)
        PanelUp = []
        PanelDown = []

        cont = 1
        for ii in range(0, len(PointsUp) - self.NoStiffners - 1):
            if cont == self.NoStiffners:
                cont = 0
            else:
                cont = cont

                # Panel from segments
                SegH1 = GC_MakeSegment(
                    PointsUp[ii], PointsUp[ii + self.NoStiffners]).Value()
                SegH2 = GC_MakeSegment(PointsUp[ii + 1],
                                       PointsUp[ii + self.NoStiffners +
                                                1]).Value()
                SegV1 = GC_MakeSegment(PointsUp[ii], PointsUp[ii + 1]).Value()
                SegV2 = GC_MakeSegment(PointsUp[ii + self.NoStiffners],
                                       PointsUp[ii + self.NoStiffners +
                                                1]).Value()
                EdgeHUp1 = act.make_edge(SegH1)
                EdgeHUp2 = act.make_edge(SegH2)
                EdgeVUp1 = act.make_edge(SegV1)
                EdgeVUp2 = act.make_edge(SegV2)
                WirePanelUp = act.make_wire(
                    [EdgeHUp1, EdgeVUp1, EdgeHUp2, EdgeVUp2])
                PanelUpi = act.make_face(WirePanelUp)
                # In this way the pannel will be ordered in alternance between upper and lower surface
                SegH1 = GC_MakeSegment(
                    PointsDown[ii], PointsDown[ii + self.NoStiffners]).Value()
                SegH2 = GC_MakeSegment(PointsDown[ii + 1],
                                       PointsDown[ii + self.NoStiffners +
                                                  1]).Value()
                SegV1 = GC_MakeSegment(PointsDown[ii],
                                       PointsDown[ii + 1]).Value()
                SegV2 = GC_MakeSegment(PointsDown[ii + self.NoStiffners],
                                       PointsDown[ii + self.NoStiffners +
                                                  1]).Value()
                EdgeHUp1 = act.make_edge(SegH1)
                EdgeHUp2 = act.make_edge(SegH2)
                EdgeVUp1 = act.make_edge(SegV1)
                EdgeVUp2 = act.make_edge(SegV2)
                WirePanelDown = act.make_wire(
                    [EdgeHUp1, EdgeVUp1, EdgeHUp2, EdgeVUp2])
                PanelDowni = act.make_face(WirePanelDown)

                if self.ScaleFactor != 1:
                    Origin = gp_Pnt(0., 0., 0.)
                    PanelUpi = act.scale_uniformal(PanelUpi, Origin,
                                                   self.ScaleFactor)
                    PanelDowni = act.scale_uniformal(PanelDowni, Origin,
                                                     self.ScaleFactor)

                PanelUp.append(PanelUpi)
                PanelDown.append(PanelDowni)
            cont = cont + 1

        return PanelUp, PanelDown
Ejemplo n.º 3
0
    def _BuildSpars(self, ChordFactor, ScaleFactor):

        LE = self._GenerateLeadingEdge()

        self.NoStiffners = self.NoStiffnersLE + self.NoStiffnersTE

        SectionsProfiles = []
        SparLEFullWing = []
        SparTEFullWing = []
        SparMIDFullWing = []

        SparLEup = []
        SparLEdown = []
        SparMIDup = []
        SparMIDdown = []
        SparTEup = []
        SparTEdown = []

        planeStiffEps = []

        PStiffUpFullWing = []
        PStiffDownFullWing = []
        StringerUpFullWing = []
        StringerDownFullWing = []

        EpsS = np.linspace(0, 1, self.SegmentNoLoft + 1)
        SectionsProfiles = [
            self.AirfoilFunct(EpsS[d], LE[d], self.ChordFunct, ChordFactor,
                              self.DihedralFunct, self.TwistFunct).Curve
            for d in xrange(self.SegmentNoLoft + 1)
        ]

        # Stringers generation
        h = 0
        cont3 = 0
        PointsUp = []
        PointsDown = []
        PointsMIDup = []
        PointsMIDdown = []

        for SecR in SectionsProfiles:
            ChordLenght = ((ChordFactor * self.ChordFunct(EpsS[h])) /
                           np.cos(np.radians(self.TwistFunct(EpsS[h]))))
            LELengthX = LE[h, 0]
            LEplanePositionX = (self.PositionLESpar * ChordLenght) * np.cos(
                self.TwistFunct(EpsS[h])) + LELengthX
            TEplanePositionX = (self.PositionTESpar * ChordLenght) * np.cos(
                self.TwistFunct(EpsS[h])) + LELengthX
            MIDplanePositionX = (self.PositionMIDSpar * ChordLenght) * np.cos(
                self.TwistFunct(EpsS[h])) + LELengthX

            planeLEi = Geom_Plane(
                gp_Pln(gp_Pnt(LEplanePositionX, 0., 0.),
                       gp_Dir(gp_Vec(gp_Pnt(0., 0., 0.), gp_Pnt(1., 0., 0.)))))
            planeMIDi = Geom_Plane(
                gp_Pln(gp_Pnt(MIDplanePositionX, 0., 0.),
                       gp_Dir(gp_Vec(gp_Pnt(0., 0., 0.), gp_Pnt(1., 0., 0.)))))
            planeTEi = Geom_Plane(
                gp_Pln(gp_Pnt(TEplanePositionX, 0., 0.),
                       gp_Dir(gp_Vec(gp_Pnt(0., 0., 0.), gp_Pnt(1., 0., 0.)))))

            #            planeLEi.Rotate(gp_OY(), -np.radians(self.TwistFunct(EpsS[h])))
            #            planeMIDi.Rotate(gp_OY(), -np.radians(self.TwistFunct(EpsS[h])))
            #            planeTEi.Rotate(gp_OY(), -np.radians(self.TwistFunct(EpsS[h])))

            SegmentStiffLE = (MIDplanePositionX -
                              LEplanePositionX) / (self.NoStiffnersLE - 1)
            SegmentStiffTE = (TEplanePositionX -
                              MIDplanePositionX) / (self.NoStiffnersTE)
            NoStiffners = self.NoStiffnersLE + self.NoStiffnersTE

            PStiffUpi = []
            PStiffDowni = []
            PosStiffiEps = LEplanePositionX

            for g in xrange(NoStiffners):

                planeStiffEps = Geom_Plane(
                    gp_Pln(
                        gp_Pnt(PosStiffiEps, 0., 0.),
                        gp_Dir(gp_Vec(gp_Pnt(0., 0., 0.), gp_Pnt(1., 0.,
                                                                 0.)))))

                StiffiEps = GeomAPI_IntCS(SecR, planeStiffEps.GetHandle())
                with act.assert_isdone(StiffiEps,
                                       'failed to calculate intersection'):
                    nb_results = StiffiEps.NbPoints()
                    if nb_results == 1:
                        return StiffiEps.Point(1)
                    #print("One point intersection")
                    elif nb_results >= 1:
                        #print("More than one intersection point")
                        PStiff = []
                        for i in range(1, nb_results + 1):
                            PStiff.append(StiffiEps.Point(i))

                    else:
                        return None
                PStiffUpi.append(PStiff[0])
                PStiffDowni.append(PStiff[nb_results - 1])
                if g <= self.NoStiffnersLE - 2:
                    PosStiffiEps = PosStiffiEps + SegmentStiffLE
                else:
                    PosStiffiEps = PosStiffiEps + SegmentStiffTE

                PointsUp.append(PStiff[0])
                PointsDown.append(PStiff[nb_results - 1])

            SparLEi = GeomAPI_IntCS(SecR, planeLEi.GetHandle())
            with act.assert_isdone(SparLEi,
                                   'failed to calculate intersection'):
                nb_results = SparLEi.NbPoints()
                #print(nb_results)
                if nb_results == 1:
                    return SparLEi.Point(1)
                #print("One point intersection")
                elif nb_results >= 1:
                    #print("More than one intersection point")
                    PLE = []
                    for i in range(1, nb_results + 1):
                        PLE.append(SparLEi.Point(i))

                else:
                    return None

            SegLE = GC_MakeSegment(PLE[0], PLE[nb_results - 1]).Value()

            SparMIDi = GeomAPI_IntCS(SecR, planeMIDi.GetHandle())
            with act.assert_isdone(SparMIDi,
                                   'failed to calculate intersection'):
                nb_results = SparMIDi.NbPoints()
                #print(nb_results)
                if nb_results == 1:
                    return SparMIDi.Point(1)
                #print("One point intersection")
                elif nb_results >= 1:
                    #print("More than one intersection point")
                    PMID = []
                    for i in range(1, nb_results + 1):
                        PMID.append(SparMIDi.Point(i))

                else:
                    return None

            SegMID = GC_MakeSegment(PMID[0], PMID[nb_results - 1]).Value()
            PointsMIDup.append(PMID[0])
            PointsMIDdown.append(PMID[nb_results - 1])

            SparTEi = GeomAPI_IntCS(SecR, planeTEi.GetHandle())
            with act.assert_isdone(SparTEi,
                                   'failed to calculate intersection'):
                nb_results = SparTEi.NbPoints()
                #print(nb_results)
                if nb_results == 1:
                    return SparTEi.Point(1)
                #print("One point intersection")
                elif nb_results >= 1:
                    #print("More than one intersection point")
                    PTE = []
                    for i in range(1, nb_results + 1):
                        PTE.append(SparTEi.Point(i))

                else:
                    return None

            SegTE = GC_MakeSegment(PTE[0], PTE[nb_results - 1]).Value()

            #print(len(SparMIDdown))
            #print(len(SparMIDup))
            #print(len(SparLEup))
            #print(len(SparLEdown))
            SparLEFullWing.append(SegLE)
            SparMIDFullWing.append(SegMID)
            SparTEFullWing.append(SegTE)
            SparLEup.append(PLE[0])
            SparLEdown.append(PLE[nb_results - 1])
            SparMIDup.append(PMID[0])
            #print(PMID[nb_results-1])
            SparMIDdown.append(PMID[nb_results - 1])
            SparTEup.append(PTE[0])
            SparTEdown.append(PTE[nb_results - 1])
            PStiffUpFullWing.append(PStiffUpi)
            PStiffDownFullWing.append(PStiffDowni)
            cont3 = cont3 + 1

            h = h + 1

# Method to create spars - VIA SEGMENTS
#LE
        LoftLESparFullWing = []
        for iii in xrange(0,
                          len(PointsUp) - 2 * (self.NoStiffners - 1),
                          self.NoStiffners):
            SegUp = GC_MakeSegment(PointsUp[iii],
                                   PointsUp[iii + self.NoStiffners]).Value()
            SegDown = GC_MakeSegment(PointsDown[iii + self.NoStiffners],
                                     PointsDown[iii]).Value()
            SegSide1 = GC_MakeSegment(PointsDown[iii], PointsUp[iii]).Value()
            SegSide2 = GC_MakeSegment(PointsUp[iii + self.NoStiffners],
                                      PointsDown[iii +
                                                 self.NoStiffners]).Value()
            EdgeSegUp = act.make_edge(SegUp)
            EdgeSegDown = act.make_edge(SegDown)
            EdgeSide1 = act.make_edge(SegSide1)
            EdgeSide2 = act.make_edge(SegSide2)
            WireSparLE = act.make_wire(
                [EdgeSide1, EdgeSegUp, EdgeSide2, EdgeSegDown])
            FaceSparLEi = act.make_face(WireSparLE)

            if self.ScaleFactor != 1:
                Origin = gp_Pnt(0., 0., 0.)
                FaceSparLE = act.scale_uniformal(FaceSparLEi, Origin,
                                                 self.ScaleFactor)
                LoftLESparFullWing.append(FaceSparLE)
#MID
        LoftMIDSparFullWing = []
        for iii in xrange(0, self.SegmentNoLoft):
            SegUp = GC_MakeSegment(PointsMIDup[iii],
                                   PointsMIDup[iii + 1]).Value()
            SegDown = GC_MakeSegment(PointsMIDdown[iii + 1],
                                     PointsMIDdown[iii]).Value()
            SegSide1 = GC_MakeSegment(PointsMIDdown[iii],
                                      PointsMIDup[iii]).Value()
            SegSide2 = GC_MakeSegment(PointsMIDup[iii + 1],
                                      PointsMIDdown[iii + 1]).Value()
            EdgeSegUp = act.make_edge(SegUp)
            EdgeSegDown = act.make_edge(SegDown)
            EdgeSide1 = act.make_edge(SegSide1)
            EdgeSide2 = act.make_edge(SegSide2)
            WireSparMID = act.make_wire(
                [EdgeSide1, EdgeSegUp, EdgeSide2, EdgeSegDown])
            FaceSparMIDi = act.make_face(WireSparMID)

            if self.ScaleFactor != 1:
                Origin = gp_Pnt(0., 0., 0.)
                FaceSparMID = act.scale_uniformal(FaceSparMIDi, Origin,
                                                  self.ScaleFactor)
                LoftMIDSparFullWing.append(FaceSparMID)

#TE
        LoftTESparFullWing = []
        for iii in xrange(self.NoStiffners - 1,
                          len(PointsUp) - (self.NoStiffners),
                          self.NoStiffners):
            SegUp = GC_MakeSegment(PointsUp[iii],
                                   PointsUp[iii + self.NoStiffners]).Value()
            SegDown = GC_MakeSegment(PointsDown[iii + self.NoStiffners],
                                     PointsDown[iii]).Value()
            SegSide1 = GC_MakeSegment(PointsDown[iii], PointsUp[iii]).Value()
            SegSide2 = GC_MakeSegment(PointsUp[iii + self.NoStiffners],
                                      PointsDown[iii +
                                                 self.NoStiffners]).Value()
            EdgeSegUp = act.make_edge(SegUp)
            EdgeSegDown = act.make_edge(SegDown)
            EdgeSide1 = act.make_edge(SegSide1)
            EdgeSide2 = act.make_edge(SegSide2)
            WireSparTE = act.make_wire(
                [EdgeSide1, EdgeSegUp, EdgeSide2, EdgeSegDown])
            FaceSparTEi = act.make_face(WireSparTE)

            if self.ScaleFactor != 1:
                Origin = gp_Pnt(0., 0., 0.)
                FaceSparTE = act.scale_uniformal(FaceSparTEi, Origin,
                                                 self.ScaleFactor)
                LoftTESparFullWing.append(FaceSparTE)

        for g in range(self.NoStiffners):
            for gg in range(self.SegmentNoLoft):
                SegStringerUp = GC_MakeSegment(
                    PointsUp[gg * self.NoStiffners + g],
                    PointsUp[gg * self.NoStiffners + g +
                             self.NoStiffners]).Value()
                SegStringerDown = GC_MakeSegment(
                    PointsDown[gg * self.NoStiffners + g],
                    PointsDown[gg * self.NoStiffners + g +
                               self.NoStiffners]).Value()
                EdgeUp = act.make_edge(SegStringerUp)
                EdgeDown = act.make_edge(SegStringerDown)
                WireStringUp = act.make_wire(EdgeUp)
                WireStringDown = act.make_wire(EdgeDown)
                if self.ScaleFactor != 1:
                    Origin = gp_Pnt(0., 0., 0.)
                    StrUpFullWingi = act.scale_uniformal(
                        WireStringUp, Origin, self.ScaleFactor)
                    StrDownFullWingi = act.scale_uniformal(
                        WireStringDown, Origin, self.ScaleFactor)
                #print('hello')
            #print(self.ScaleFactor)
                StringerUpFullWing.append(StrUpFullWingi)
                StringerDownFullWing.append(StrDownFullWingi)

        return LoftLESparFullWing, LoftTESparFullWing, LoftMIDSparFullWing, StringerUpFullWing, StringerDownFullWing, PointsUp, PointsDown