Ejemplo n.º 1
0
def createRudder(parentVtpCPACS, parentVtpVAMPzero, myRudder):
    """
    This is the main export method for the wings aileron
    """
    cpacsPath = "/cpacs/vehicles/aircraft/model/wings/wing[" + parentVtpVAMPzero.id + "]"
    cpacsVtp = getObjfromXpath(parentVtpCPACS, cpacsPath)
    cpacsComponentSegment = cpacsVtp.get_componentSegments().get_componentSegment()[0]

    # ===========================================================================
    # Header
    # ===========================================================================
    myName = stringBaseType(None, None, None, "rudder")
    myDescription = stringBaseType(None, None, None, "rudder from VAMPzero")
    myParentUID = stringUIDBaseType(None, None, "True", None, "vtp_Cseg")

    # ===========================================================================
    # Outer Shape
    # With the rudder this is pretty simple as it is supposed to cover
    # the same span as the VTP
    # ===========================================================================
    # the inner border eta is determined from the rooYLocation of the Rudder and the vtp span
    vtpSpan = parentVtpVAMPzero.span.getValue() / 2.0
    innerEtaLE = 0.0
    outerEtaLE = 1.0

    innerXsiLE = myRudder.cRoot.getValue() / parentVtpVAMPzero.cRoot.getValue()
    outerXsiLE = myRudder.cTip.getValue() / parentVtpVAMPzero.cTip.getValue()

    # start writing back
    myleadingEdgeShape = leadingEdgeShapeType(
        relHeightLE=doubleBaseType(valueOf_=str(0.5)),
        xsiUpperSkin=doubleBaseType(valueOf_=str(0.85)),
        xsiLowerSkin=doubleBaseType(valueOf_=str(0.85)),
    )
    innerBorder = controlSurfaceBorderTrailingEdgeType(
        etaLE=doubleBaseType(valueOf_=str(innerEtaLE)),
        xsiLE=doubleBaseType(valueOf_=str(innerXsiLE)),
        leadingEdgeShape=myleadingEdgeShape,
    )
    outerBorder = controlSurfaceBorderTrailingEdgeType(
        etaLE=doubleBaseType(valueOf_=str(outerEtaLE)),
        xsiLE=doubleBaseType(valueOf_=str(outerXsiLE)),
        leadingEdgeShape=myleadingEdgeShape,
    )

    myOuterShape = controlSurfaceOuterShapeTrailingEdgeType(innerBorder=innerBorder, outerBorder=outerBorder)

    cpacsRudder = trailingEdgeDeviceType(
        uID="rudderUID", name=myName, description=myDescription, parentUID=myParentUID, outerShape=myOuterShape
    )

    createPath(cpacsRudder, "rudder")

    if type(cpacsComponentSegment.get_controlSurfaces()) == NoneType:
        cpacsComponentSegment.set_controlSurfaces(controlSurfacesType())
    if type(cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices()) == NoneType:
        cpacsComponentSegment.get_controlSurfaces().set_trailingEdgeDevices(trailingEdgeDevicesType())

    cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices().add_trailingEdgeDevice(cpacsRudder)
Ejemplo n.º 2
0
def createStabilizer(parentHtpCPACS, parentHtpVAMPzero, myElevator):
    '''
    This is the main export method for the stabilizer, i.e. the whole htp as control surface
    '''
    cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + parentHtpVAMPzero.id + ']'
    cpacsHtp = getObjfromXpath(parentHtpCPACS, cpacsPath)
    cpacsComponentSegment = cpacsHtp.get_componentSegments(
    ).get_componentSegment()[0]

    #===========================================================================
    # Header
    #===========================================================================
    myName = stringBaseType(None, None, None, 'stabilizer')
    myDescription = stringBaseType(None, None, None,
                                   'stabilizer exported from VAMPzero')
    myParentUID = stringUIDBaseType(None, None, 'True', None,
                                    parentHtpVAMPzero.id)

    #===========================================================================
    # Outer Shape
    #===========================================================================
    innerEtaLE = 0.
    innerXsiLE = 0.
    outerEtaLE = 1.
    outerXsiLE = 0.

    # start writing back
    #myleadingEdgeShape = leadingEdgeShapeType(relHeightLE=doubleBaseType(valueOf_=str(0.5)), xsiUpperSkin=doubleBaseType(valueOf_=str(0.85)), xsiLowerSkin=doubleBaseType(valueOf_=str(0.85)))
    innerBorder = controlSurfaceBorderTrailingEdgeType(
        etaLE=doubleBaseType(valueOf_=str(innerEtaLE)),
        xsiLE=doubleBaseType(valueOf_=str(innerXsiLE)))
    outerBorder = controlSurfaceBorderTrailingEdgeType(
        etaLE=doubleBaseType(valueOf_=str(outerEtaLE)),
        xsiLE=doubleBaseType(valueOf_=str(outerXsiLE)))

    myOuterShape = controlSurfaceOuterShapeTrailingEdgeType(
        innerBorder=innerBorder, outerBorder=outerBorder)

    cpacsStabilizer = trailingEdgeDeviceType(uID='stabilizerUID',
                                             name=myName,
                                             description=myDescription,
                                             parentUID=myParentUID,
                                             outerShape=myOuterShape)

    createPath(cpacsStabilizer, 'stabilizer')

    if type(cpacsComponentSegment.get_controlSurfaces()) == NoneType:
        cpacsComponentSegment.set_controlSurfaces(controlSurfacesType())
    if type(cpacsComponentSegment.get_controlSurfaces().
            get_trailingEdgeDevices()) == NoneType:
        cpacsComponentSegment.get_controlSurfaces().set_trailingEdgeDevices(
            trailingEdgeDevicesType())

    cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices(
    ).add_trailingEdgeDevice(cpacsStabilizer)
Ejemplo n.º 3
0
def createStabilizer(parentHtpCPACS, parentHtpVAMPzero, myElevator):
    """
    This is the main export method for the stabilizer, i.e. the whole htp as control surface
    """
    cpacsPath = "/cpacs/vehicles/aircraft/model/wings/wing[" + parentHtpVAMPzero.id + "]"
    cpacsHtp = getObjfromXpath(parentHtpCPACS, cpacsPath)
    cpacsComponentSegment = cpacsHtp.get_componentSegments().get_componentSegment()[0]

    # ===========================================================================
    # Header
    # ===========================================================================
    myName = stringBaseType(None, None, None, "stabilizer")
    myDescription = stringBaseType(None, None, None, "stabilizer exported from VAMPzero")
    myParentUID = stringUIDBaseType(None, None, "True", None, parentHtpVAMPzero.id)

    # ===========================================================================
    # Outer Shape
    # ===========================================================================
    innerEtaLE = 0.0
    innerXsiLE = 0.0
    outerEtaLE = 1.0
    outerXsiLE = 0.0

    # start writing back
    # myleadingEdgeShape = leadingEdgeShapeType(relHeightLE=doubleBaseType(valueOf_=str(0.5)), xsiUpperSkin=doubleBaseType(valueOf_=str(0.85)), xsiLowerSkin=doubleBaseType(valueOf_=str(0.85)))
    innerBorder = controlSurfaceBorderTrailingEdgeType(
        etaLE=doubleBaseType(valueOf_=str(innerEtaLE)), xsiLE=doubleBaseType(valueOf_=str(innerXsiLE))
    )
    outerBorder = controlSurfaceBorderTrailingEdgeType(
        etaLE=doubleBaseType(valueOf_=str(outerEtaLE)), xsiLE=doubleBaseType(valueOf_=str(outerXsiLE))
    )

    myOuterShape = controlSurfaceOuterShapeTrailingEdgeType(innerBorder=innerBorder, outerBorder=outerBorder)

    cpacsStabilizer = trailingEdgeDeviceType(
        uID="stabilizerUID", name=myName, description=myDescription, parentUID=myParentUID, outerShape=myOuterShape
    )

    createPath(cpacsStabilizer, "stabilizer")

    if type(cpacsComponentSegment.get_controlSurfaces()) == NoneType:
        cpacsComponentSegment.set_controlSurfaces(controlSurfacesType())
    if type(cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices()) == NoneType:
        cpacsComponentSegment.get_controlSurfaces().set_trailingEdgeDevices(trailingEdgeDevicesType())

    cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices().add_trailingEdgeDevice(cpacsStabilizer)
Ejemplo n.º 4
0
def createFlapsSBW(parentWingCPACS, parentWingVAMPzero, myFlap):
    '''
    This is the main export method for the wings flaps for the strut braced wing.

    The SBW does not feature any inner flaps as no kink exists

    @todo: it is possible that the inner flap overlaps the kink area
    '''
    cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + parentWingVAMPzero.id + ']'
    cpacsWing = getObjfromXpath(parentWingCPACS, cpacsPath)
    cpacsComponentSegment = cpacsWing.get_componentSegments().get_componentSegment()[0]
    myFlaps = []

    # Initialization, i.e. fetching values throughout the code
    xsis = []
    etas = []
    for i in range(3,7):
        try:
            xsis.append(eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[i].get_xsi().valueOf_))
            etas.append(eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[i].get_eta().valueOf_))
        except IndexError:
            pass

    xsiSpar_interp = scipy.interpolate.interp1d(etas, xsis)

    yFus = parentWingVAMPzero.yFuselage.getValue()
    span = parentWingVAMPzero.span.getValue() / 2.
    etaFus = yFus / span
    etaKink = parentWingVAMPzero.etaKink.getValue()
    cRoot = parentWingVAMPzero.cRoot.getValue()
    cKink = calcChordLengthAtEta(etaKink, parentWingVAMPzero, cpacsWing)

    innerFlapArea = myFlap.refAreaInnerFlap.getValue()
    outerFlapArea = myFlap.refAreaOuterFlap.getValue()

    # OuterFlap
    sparOffset = 0.08

    # maxX is the maximum extension of the flap
    maxX = cRoot * (1. - (xsis[0] + sparOffset)) /2.
    newOuterFlapArea = innerFlapArea + outerFlapArea
    cRootOuterFlap = cRoot * (1. - (xsis[0] + sparOffset))

    # Determine the total flap span by iteration
    calcArea = 0.
    spanOuterFlap = 0.
    absSparOffset = sparOffset * cKink

    # Obtain the maxEtaValue. This is forwarded from the ailerons export routine.
    maxEta = myFlap.maxEta.getValue() - 0.02

    # the tip root length is a function of the span (as the xsi location of the spar changes)
    while abs(calcArea - newOuterFlapArea) > 0.1:
        spanOuterFlap += .01
        cTipOuterFlap = calcChordLengthAtEta(etaFus + spanOuterFlap / span, parentWingVAMPzero, cpacsWing) * (1 - xsiSpar_interp(etaFus + spanOuterFlap / span)) - absSparOffset
        oldcalcArea = calcArea
        calcArea = spanOuterFlap * (cRootOuterFlap + cTipOuterFlap) / 2.

        if calcArea < oldcalcArea:
            log.warning('VAMPzero FLAP: Outer Flap Area can not be established decreasing spar offset by 2% chord!')
            sparOffset = sparOffset - 0.02
            calcArea = 0.
            spanOuterFlap = 0.
            absSparOffset = sparOffset * cKink
            break

        if spanOuterFlap / span + etaFus > maxEta:
            log.warning('VAMPzero FLAP: Outer Flap overlaps with the aileron decreasing spar offset by 2% chord!')
            sparOffset = sparOffset - 0.02
            calcArea = 0.
            spanOuterFlap = 0.
            absSparOffset = sparOffset * cRoot
            break

    while abs(calcArea - newOuterFlapArea) > 0.1:
        spanOuterFlap += .01
        cTipOuterFlap = calcChordLengthAtEta(etaFus + spanOuterFlap / span, parentWingVAMPzero, cpacsWing) * (1 - xsiSpar_interp(etaFus + spanOuterFlap / span)) - absSparOffset
        oldcalcArea = calcArea
        calcArea = spanOuterFlap * (cRootOuterFlap + cTipOuterFlap) / 2.

        if calcArea < oldcalcArea:
            log.warning('VAMPzero FLAP: Outer Flap Area can not be established! Continuing with outerArea = %s' % str(calcArea))
            newOuterFlapArea = calcArea
            break

        if spanOuterFlap / span + etaFus + 0.06 > maxEta:
            log.warning('VAMPzero FLAP: Outer Flap overlaps with the aileron! Continuing with outerArea = %s' % str(calcArea))
            newOuterFlapArea = calcArea
            break

    # Determine the number of flaps
    # The aspect ratio of a flap should not be higher than 6.
    nOuterFlaps = spanOuterFlap ** 2. / (newOuterFlapArea * 6.)
    log.debug('VAMPzero FLAP: Exporting %s Flaps outboard of the engine for an area of %s m2.' % (str(nOuterFlaps), str(newOuterFlapArea)))

    # 1 Flap
    if nOuterFlaps <= 1.:
        # the inner border eta is located at the kink
        innerEtaLE = etaFus + 0.05
        innerXsiLE = xsis[0] + sparOffset
        # the outer border eta is determined from the span of the outer flap
        outerEtaLE = etaFus + 0.05 + spanOuterFlap / span
        outerXsiLE = 1 - (cTipOuterFlap / calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing))

        #Fowler Motion is restricted to 75% of the flap depth
        innerX = (1. - innerXsiLE) * calcChordLengthAtEta(innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = (1. - outerXsiLE) * calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        myFlaps.append(createFlap('outerFlap1', parentWingVAMPzero.id, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, maxX, appendInnerCruiseRoller=True, type='flap', innerX=innerX, outerX=outerX))

    # 2 Flaps
    elif nOuterFlaps > 1. and nOuterFlaps <= 2.:
        # the inner border eta is located at the kink
        innerEtaLE = etaFus + 0.05
        innerXsiLE = xsis[2] + sparOffset
        # the outer border eta is determined from the half span of the total outer flap
        outerEtaLE = etaFus + 0.05 + spanOuterFlap / (2*span)
        outerXsiLE = xsiSpar_interp(outerEtaLE) + absSparOffset / calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing)
        #Fowler Motion is restricted to 75% of the flap depth
        innerX = (1. - innerXsiLE) * calcChordLengthAtEta(innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = (1. - outerXsiLE) * calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        myFlaps.append(createFlap('outerFlap1', parentWingVAMPzero.id, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, maxX, type='flap', innerX=innerX, outerX=outerX))

        # new inner is the old outer
        innerEtaLE = outerEtaLE
        innerXsiLE = outerXsiLE
        # the outer border eta is determined from the full span of the total outer flap
        outerEtaLE = etaFus + 0.05 + spanOuterFlap / span
        outerXsiLE = 1 - (cTipOuterFlap / calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing))

        #Fowler Motion is restricted to 75% of the flap depth
        innerX = (1. - innerXsiLE) * calcChordLengthAtEta(innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = (1. - outerXsiLE) * calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        myFlaps.append(createFlap('outerFlap2', parentWingVAMPzero.id, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, maxX, appendInnerCruiseRoller=True, type='flap', innerX=innerX, outerX=outerX))

    # n Flaps
    elif nOuterFlaps > 2. :
        n = int(ceil(nOuterFlaps))
        # First Flap
        # the inner border eta is located at the kink
        innerEtaLE = etaFus + 0.05
        innerXsiLE = xsis[2] + sparOffset
        # the outer border eta is determined from the half span of the total outer flap
        outerEtaLE = etaFus + 0.05 + spanOuterFlap / (n*span)
        outerXsiLE = xsiSpar_interp(outerEtaLE) + absSparOffset / calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing)

        #Fowler Motion is restricted to 75% of the flap depth
        innerX = (1. - innerXsiLE) * calcChordLengthAtEta(innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = (1. - outerXsiLE) * calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        myFlaps.append(createFlap('outerFlap1', parentWingVAMPzero.id, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, maxX, type='flap', innerX=innerX, outerX=outerX))

        for i in range(2, n):
            # nth Flap
            # new inner is the old outer
            innerEtaLE = outerEtaLE
            innerXsiLE = outerXsiLE
            # the outer border eta is determined from the full span of the total outer flap
            outerEtaLE = innerEtaLE + spanOuterFlap / n / span
            outerXsiLE = xsiSpar_interp(outerEtaLE) + absSparOffset / calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing)

            #Fowler Motion is restricted to 75% of the flap depth
            innerX = (1. - innerXsiLE) * calcChordLengthAtEta(innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
            outerX = (1. - outerXsiLE) * calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
            myFlaps.append(createFlap('outerFlap' + str(i), parentWingVAMPzero.id, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, maxX, appendInnerCruiseRoller=True, type='flap', innerX=innerX, outerX=outerX))

        # Last Flap
        # new inner is the old outer
        innerEtaLE = outerEtaLE
        innerXsiLE = outerXsiLE
        # the outer border eta is determined from the full span of the total outer flap
        outerEtaLE = etaFus + 0.05 + spanOuterFlap / span
        outerXsiLE = 1 - (cTipOuterFlap / calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing))

        #Fowler Motion is restricted to 75% of the flap depth
        innerX = (1. - innerXsiLE) * calcChordLengthAtEta(innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = (1. - outerXsiLE) * calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        myFlaps.append(createFlap('outerFlap' + str(n), parentWingVAMPzero.id, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, maxX, appendInnerCruiseRoller=True, type='flap', innerX=innerX, outerX=outerX))

    # Output to Spoiler
    # as the spoiler is relying on data of the flaps some basic information is written
    # back to the the VAMPzero components
    parentWingVAMPzero.spoiler.outerEta = parameter(parent=parentWingVAMPzero.spoiler, value=outerEtaLE, unit='', status='calc', doc='The outermost eta coordinate of all flaps. This overlaps with the outer eta coordinate of the spoiler')
    spoilerChord = maxX
    parentWingVAMPzero.spoiler.chord = parameter(spoilerChord, 'm', 'calc', 'The absolute chord of the spoiler: 5% of the kink chord length + 50% of the innerFlap Chord length', parent=parentWingVAMPzero.spoiler)

    # Output to CPACS
    if type(cpacsComponentSegment.get_controlSurfaces()) == NoneType:
        cpacsComponentSegment.set_controlSurfaces(controlSurfacesType())
    if type(cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices()) == NoneType:
        cpacsComponentSegment.get_controlSurfaces().set_trailingEdgeDevices(trailingEdgeDevicesType())

    log.debug('VAMPzero SLAT: Exporting %s Flaps to CPACS.' % (str(len(myFlaps))))
    for flap in myFlaps:
        cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices().add_trailingEdgeDevice(flap)
Ejemplo n.º 5
0
def createFlapsAdvDoubleTrapezoid(parentWingCPACS, parentWingVAMPzero, myFlap):
    '''
    This is the main export method for the wings flaps
    
    @todo: it is possible that the inner flap overlaps the kink area
    '''
    cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + parentWingVAMPzero.id + ']'
    cpacsWing = getObjfromXpath(parentWingCPACS, cpacsPath)
    cpacsComponentSegment = cpacsWing.get_componentSegments().get_componentSegment()[0]
    myFlaps = []
    
    # Initialization, i.e. fetching values throughout the code
    xsiSparRoot = eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[3].get_xsi().valueOf_)
    xsiSparFuselage = eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[4].get_xsi().valueOf_)
    xsiSparKink = eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[5].get_xsi().valueOf_)
    xsiSparTip = eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[6].get_xsi().valueOf_)

    etaSparRoot = eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[3].get_eta().valueOf_)
    etaSparFuselage = eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[4].get_eta().valueOf_)
    etaSparKink = eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[5].get_eta().valueOf_)
    etaSparTip = eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[6].get_eta().valueOf_)

    xsiSpar_interp = scipy.interpolate.interp1d([etaSparRoot, etaSparFuselage, etaSparKink, etaSparTip], [xsiSparRoot, xsiSparFuselage, xsiSparKink, xsiSparTip])
    
    yFus = parentWingVAMPzero.yFuselage.getValue()
    span = parentWingVAMPzero.span.getValue() / 2.
    etaFus = yFus / span
    etaKink = parentWingVAMPzero.etaKink.getValue()
    cRoot = parentWingVAMPzero.cRoot.getValue()
    cKink = calcChordLengthAtEta(etaKink, parentWingVAMPzero, cpacsWing)
    phiLE = parentWingVAMPzero.phiLE.getValue()
    
    innerFlapArea = myFlap.refAreaInnerFlap.getValue()
    outerFlapArea = myFlap.refAreaOuterFlap.getValue()

    # InnerFlap
    # Determine the number of flaps
    # The aspect ratio of a flap should not be higher than 9.
    sparOffset = 0.08
    if phiLE > 0.:
        # if the wing is backward swept the chord of the inner flap equals the chord at kink behind the rear spar + sparOffset
        cInnerFlap = cKink * (1. - (xsiSparKink + sparOffset))
    elif phiLE < 0.:
        # if the wing is forward swept the chord of the inner flap is similar to the chord of the root section behind the spar + 20%
        cInnerFlap = cRoot * (1. - (xsiSparFuselage + 0.2))
    
    # maxX is the maximum extension of the flap
    maxX = cInnerFlap / 2.
    
    # The area of the innerFlap is determined by the chord and span 
    # The difference in the area will be substituted by the outerFlap Area
    spanInnerFlap = (etaKink - etaFus) * span
    newInnerFlapArea = cInnerFlap * spanInnerFlap
    deltaArea = innerFlapArea - newInnerFlapArea
    nInnerFlaps = spanInnerFlap ** 2. / (newInnerFlapArea * 9.)
    log.debug('VAMPzero FLAP: Exporting %s Flaps inside of the engine for an area of %s m2.' % (str(nInnerFlaps), str(innerFlapArea)))
        
    if nInnerFlaps < 1.:
        # the inner border eta is located at the intersection with the fuselage 
        innerEtaLE = etaFus
        # the inner border xsi is determined from the wing chord at the fuselage station (which equals CRoot)
        innerXsiLE = 1. - (cInnerFlap / cRoot)
        # the outer border eta is determined from the span of the inner flap
        outerEtaLE = etaKink
        # the outer xsi location is found from the avg chord and the chord length at that station
        outerXsiLE = 1. - (cInnerFlap / cKink)

        myFlaps.append(createFlap('innerFlap', parentWingVAMPzero.id, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, maxX, type='innerFlap', innerX=maxX, outerX=maxX))
    
    elif nInnerFlaps > 1. and nInnerFlaps <= 2.:
        # First Flap
        # the inner border eta is located at the intersection with the fuselage
        innerEtaLE = etaFus
        # the inner border xsi is determined from the wing chord at the fuselage station (which equals CRoot)
        innerXsiLE = 1. - (cInnerFlap / cRoot)
        # the outer border eta is determined from the span of the inner flap
        outerEtaLE = etaFus + (etaKink - etaFus) / 2.
        # the outer xsi location is found from the avg chord and the chord length at that station
        outerXsiLE = 1. - (cInnerFlap / calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing))

        myFlaps.append(createFlap('innerFlap1', parentWingVAMPzero.id, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, maxX, type='innerFlap', innerX=maxX, outerX=maxX))
        
        # Second Flap
        # new inner is old outer
        innerEtaLE = outerEtaLE
        # new outer is kink
        outerEtaLE = etaKink
        # new inner is old outer
        innerXsiLE = outerXsiLE
        # new outer is kink
        outerXsiLE = 1. - (cInnerFlap / cKink)

        myFlaps.append(createFlap('innerFlap2', parentWingVAMPzero.id, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, maxX, type='flap', innerX=maxX, outerX=maxX))

    # OuterFlap
    newOuterFlapArea = outerFlapArea + deltaArea
    cRootOuterFlap = cKink * (1. - (xsiSparKink + sparOffset))
    
    # Determine the total flap span by iteration
    calcArea = 0.
    spanOuterFlap = 0.
    absSparOffset = sparOffset * cKink
    
    # Obtain the maxEtaValue. This is forwarded from the ailerons export routine.
    maxEta = myFlap.maxEta.getValue() - 0.02
    
    # the tip root length is a function of the span (as the xsi location of the spar changes)
    while abs(calcArea - newOuterFlapArea) > 0.1:
        spanOuterFlap += .01
        cTipOuterFlap = calcChordLengthAtEta(etaKink + spanOuterFlap / span, parentWingVAMPzero, cpacsWing) * (1 - xsiSpar_interp(etaKink + spanOuterFlap / span)) - absSparOffset
        oldcalcArea = calcArea
        calcArea = spanOuterFlap * (cRootOuterFlap + cTipOuterFlap) / 2.
        
        if calcArea < oldcalcArea:
            log.warning('VAMPzero FLAP: Outer Flap Area can not be established decreasing spar offset by 2% chord!')
            sparOffset = sparOffset - 0.02
            calcArea = 0.
            spanOuterFlap = 0.
            absSparOffset = sparOffset * cKink
            break
        
        if spanOuterFlap / span + etaKink > maxEta:
            log.warning('VAMPzero FLAP: Outer Flap overlaps with the aileron decreasing spar offset by 2% chord!')
            sparOffset = sparOffset - 0.02
            calcArea = 0.
            spanOuterFlap = 0.
            absSparOffset = sparOffset * cKink
            break
            
    while abs(calcArea - newOuterFlapArea) > 0.1:
        spanOuterFlap += .01
        cTipOuterFlap = calcChordLengthAtEta(etaKink + spanOuterFlap / span, parentWingVAMPzero, cpacsWing) * (1 - xsiSpar_interp(etaKink + spanOuterFlap / span)) - absSparOffset
        oldcalcArea = calcArea
        calcArea = spanOuterFlap * (cRootOuterFlap + cTipOuterFlap) / 2.
        
        if calcArea < oldcalcArea:
            log.warning('VAMPzero FLAP: Outer Flap Area can not be established! Continuing with outerArea = %s' % str(calcArea))
            newOuterFlapArea = calcArea
            break

        if spanOuterFlap / span + etaKink > maxEta:
            log.warning('VAMPzero FLAP: Outer Flap overlaps with the aileron! Continuing with outerArea = %s' % str(calcArea))
            newOuterFlapArea = calcArea
            break
        
    # Determine the number of flaps
    # The aspect ratio of a flap should not be higher than 9. 
    nOuterFlaps = spanOuterFlap ** 2. / (newOuterFlapArea * 9.)
    log.debug('VAMPzero FLAP: Exporting %s Flaps outboard of the engine for an area of %s m2.' % (str(nOuterFlaps), str(newOuterFlapArea)))
    
    # 1 Flap
    if nOuterFlaps <= 1.:
        # the inner border eta is located at the kink 
        innerEtaLE = etaKink
        innerXsiLE = xsiSparKink + sparOffset
        # the outer border eta is determined from the span of the outer flap
        outerEtaLE = etaKink + spanOuterFlap / span
        outerXsiLE = 1 - (cTipOuterFlap / calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing))
        
        #Fowler Motion is restricted to 75% of the flap depth
        innerX = (1. - innerXsiLE) * calcChordLengthAtEta(innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = (1. - outerXsiLE) * calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        myFlaps.append(createFlap('outerFlap1', parentWingVAMPzero.id, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, maxX, appendInnerCruiseRoller=True, type='flap', innerX=innerX, outerX=outerX))
    
    # 2 Flaps
    elif nOuterFlaps > 1. and nOuterFlaps <= 2.:
        # the inner border eta is located at the kink 
        innerEtaLE = etaKink
        innerXsiLE = xsiSparKink + sparOffset
        # the outer border eta is determined from the half span of the total outer flap
        outerEtaLE = etaKink + spanOuterFlap / (2. * span)
        outerXsiLE = xsiSpar_interp(outerEtaLE) + absSparOffset / calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing)
        #Fowler Motion is restricted to 75% of the flap depth
        innerX = (1. - innerXsiLE) * calcChordLengthAtEta(innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = (1. - outerXsiLE) * calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        myFlaps.append(createFlap('outerFlap1', parentWingVAMPzero.id, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, maxX, type='flap', innerX=innerX, outerX=outerX))
        
        # new inner is the old outer 
        innerEtaLE = outerEtaLE
        innerXsiLE = outerXsiLE
        # the outer border eta is determined from the full span of the total outer flap
        outerEtaLE = etaKink + spanOuterFlap / span
        outerXsiLE = 1 - (cTipOuterFlap / calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing))

        #Fowler Motion is restricted to 75% of the flap depth
        innerX = (1. - innerXsiLE) * calcChordLengthAtEta(innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = (1. - outerXsiLE) * calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        myFlaps.append(createFlap('outerFlap2', parentWingVAMPzero.id, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, maxX, appendInnerCruiseRoller=True, type='flap', innerX=innerX, outerX=outerX))
    
    # n Flaps
    elif nOuterFlaps > 2. :
        n = int(ceil(nOuterFlaps))
        # First Flap
        # the inner border eta is located at the kink 
        innerEtaLE = etaKink
        innerXsiLE = xsiSparKink + sparOffset
        # the outer border eta is determined from the half span of the total outer flap
        outerEtaLE = etaKink + spanOuterFlap / n / span
        outerXsiLE = xsiSpar_interp(outerEtaLE) + absSparOffset / calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing)
        
        #Fowler Motion is restricted to 75% of the flap depth
        innerX = (1. - innerXsiLE) * calcChordLengthAtEta(innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = (1. - outerXsiLE) * calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        myFlaps.append(createFlap('outerFlap1', parentWingVAMPzero.id, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, maxX, type='flap', innerX=innerX, outerX=outerX))
        
        for i in range(2, n):
            # nth Flap
            # new inner is the old outer 
            innerEtaLE = outerEtaLE
            innerXsiLE = outerXsiLE
            # the outer border eta is determined from the full span of the total outer flap
            outerEtaLE = innerEtaLE + spanOuterFlap / n / span
            outerXsiLE = xsiSpar_interp(outerEtaLE) + absSparOffset / calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing)
            
            #Fowler Motion is restricted to 75% of the flap depth
            innerX = (1. - innerXsiLE) * calcChordLengthAtEta(innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
            outerX = (1. - outerXsiLE) * calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
            myFlaps.append(createFlap('outerFlap' + str(i), parentWingVAMPzero.id, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, maxX, appendInnerCruiseRoller=True, type='flap', innerX=innerX, outerX=outerX))

        # Last Flap
        # new inner is the old outer 
        innerEtaLE = outerEtaLE
        innerXsiLE = outerXsiLE
        # the outer border eta is determined from the full span of the total outer flap
        outerEtaLE = etaKink + spanOuterFlap / span
        outerXsiLE = 1 - (cTipOuterFlap / calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing))
        
        #Fowler Motion is restricted to 75% of the flap depth
        innerX = (1. - innerXsiLE) * calcChordLengthAtEta(innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = (1. - outerXsiLE) * calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        myFlaps.append(createFlap('outerFlap' + str(n), parentWingVAMPzero.id, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, maxX, appendInnerCruiseRoller=True, type='flap', innerX=innerX, outerX=outerX))

    # Output to Spoiler
    # as the spoiler is relying on data of the flaps some basic information is written 
    # back to the the VAMPzero components  
    parentWingVAMPzero.spoiler.outerEta = parameter(outerEtaLE, '', 'calc', 'The outermost eta coordinate of all flaps. This overlaps with the outer eta coordinate of the spoiler', parent=parentWingVAMPzero.spoiler)
    spoilerChord = 0.05 * cKink + 0.5 * cInnerFlap
    parentWingVAMPzero.spoiler.chord = parameter(spoilerChord, 'm', 'calc', 'The absolute chord of the spoiler: 5% of the kink chord length + 50% of the innerFlap Chord length', parent=parentWingVAMPzero.spoiler)
    
    # Output to CPACS
    if type(cpacsComponentSegment.get_controlSurfaces()) == NoneType:
        cpacsComponentSegment.set_controlSurfaces(controlSurfacesType())
    if type(cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices()) == NoneType:
        cpacsComponentSegment.get_controlSurfaces().set_trailingEdgeDevices(trailingEdgeDevicesType())
    
    log.debug('VAMPzero SLAT: Exporting %s Flaps to CPACS.' % (str(len(myFlaps))))
    for flap in myFlaps:
        cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices().add_trailingEdgeDevice(flap)
Ejemplo n.º 6
0
def createSpoilers(parentWingCPACS, parentWingVAMPzero, mySpoiler):
    '''
    This is the main export method for the wing's spoilers
    
    * It assumes a constant absolut chord for all spoilers
    * Spoiler start outboard and move inboard close behind the rearspar
    * They are rectangular
    
    '''
    cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + parentWingVAMPzero.id + ']'
    cpacsWing = getObjfromXpath(parentWingCPACS, cpacsPath)
    cpacsComponentSegment = cpacsWing.get_componentSegments().get_componentSegment()[0]
    mySpoilers = []

    #===========================================================================
    # Initialization, i.e. fetching values throughout the code
    #===========================================================================
    span = parentWingVAMPzero.span.getValue() / 2.
    etaKink = parentWingVAMPzero.etaKink.getValue()
    yFus = parentWingVAMPzero.yFuselage.getValue()
    etaFus = yFus / span
 
    spoilerArea = mySpoiler.refArea.getValue()
    spoilerChord = mySpoiler.chord.getValue()
    spoilerOuterEta = mySpoiler.outerEta.getValue()
    
    sparOffset = 0.02

    #===========================================================================
    # Rear spar locations
    #===========================================================================
    xsiSparRoot = eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[3].get_xsi().valueOf_)
    xsiSparFuselage = eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[4].get_xsi().valueOf_)
    xsiSparKink = eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[5].get_xsi().valueOf_)
    xsiSparTip = eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[6].get_xsi().valueOf_)

    etaSparRoot = eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[3].get_eta().valueOf_)
    etaSparFuselage = eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[4].get_eta().valueOf_)
    etaSparKink = eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[5].get_eta().valueOf_)
    etaSparTip = eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[6].get_eta().valueOf_)

    xsiSpar_interp = scipy.interpolate.interp1d([etaSparRoot, etaSparFuselage, etaSparKink, etaSparTip], [xsiSparRoot, xsiSparFuselage, xsiSparKink, xsiSparTip])

    
    #===========================================================================
    # Outer Spoilers 
    #===========================================================================
    outerSpan = (spoilerOuterEta - etaKink) * span
    outerArea = spoilerChord * outerSpan
    nOuterSpoiler = outerSpan ** 2 / (outerArea * 2.)
    log.debug('VAMPzero SPOILER: Exporting %s Spoiler outside of the kink for an area of %s m2.' % (str(nOuterSpoiler), str(outerArea)))


    #===========================================================================
    # 1 Spoiler
    #===========================================================================
    if nOuterSpoiler <= 1.:
        # The outer eta of the leading Edge is correspondent to the outerEta of the spoiler 
        outerEtaLE = spoilerOuterEta
        # The inner eta of the leading edge is the outer eta minus the span of the outer spoiler 
        innerEtaLE = spoilerOuterEta - outerSpan / span
        # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset
        
        spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE, innerXsiLE, parentWingVAMPzero, cpacsWing)
        deltaEta = sin(spoilerPhi) * spoilerChord
        deltaXsi = cos(spoilerPhi) * spoilerChord
        
        outerEtaTE = outerEtaLE - deltaEta / span
        outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE - deltaEta / span
        innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        # We do not want the spoiler to overlap the kink as the inner Spoilers will start here
        if innerEtaTE < etaKink:
            innerEtaTE = etaKink
            innerXsiTE = innerXsiLE + spoilerChord / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        
        mySpoilers.append(createSpoiler('OuterSpoiler1', parentWingVAMPzero.id, innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE))

    #===========================================================================
    # 2 Spoiler
    #===========================================================================
    elif nOuterSpoiler > 1. and nOuterSpoiler <= 2.:
        # The outer eta of the leading Edge is correspondent to the outerEta of the spoiler 
        outerEtaLE = spoilerOuterEta
        # The inner eta of the leading edge is the outer eta minus the span of the outer spoiler 
        innerEtaLE = spoilerOuterEta - outerSpan / span / 2.
        # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset
        
        spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE, innerXsiLE, parentWingVAMPzero, cpacsWing)
        deltaEta = sin(spoilerPhi) * spoilerChord
        deltaXsi = cos(spoilerPhi) * spoilerChord
        
        outerEtaTE = outerEtaLE - deltaEta / span
        outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE - deltaEta / span
        innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        
        mySpoilers.append(createSpoiler('OuterSpoiler2', parentWingVAMPzero.id, innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE))

        # old outer is new inner 
        outerEtaLE = innerEtaLE
        # new inner is min next to kink  
        innerEtaLE = spoilerOuterEta - outerSpan / span
        # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset
        
        spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE, innerXsiLE, parentWingVAMPzero, cpacsWing)
        deltaEta = sin(spoilerPhi) * spoilerChord
        deltaXsi = cos(spoilerPhi) * spoilerChord
        
        outerEtaTE = outerEtaLE - deltaEta / span
        outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE - deltaEta / span
        innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        # We do not want the spoiler to overlap the kink as the inner Spoilers will start here
        if innerEtaTE < etaKink:
            innerEtaTE = etaKink
            innerXsiTE = innerXsiLE + spoilerChord / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        mySpoilers.append(createSpoiler('OuterSpoiler1', parentWingVAMPzero.id, innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE))

    #===========================================================================
    # n Spoiler
    #===========================================================================
    elif nOuterSpoiler > 2.:
        n = int(ceil(nOuterSpoiler))
        # The outer eta of the leading Edge is correspondent to the outerEta of the spoiler 
        outerEtaLE = spoilerOuterEta
        # The inner eta of the leading edge is the outer eta minus the span of the outer spoiler 
        innerEtaLE = outerEtaLE - outerSpan / span / n
        # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset
        
        spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE, innerXsiLE, parentWingVAMPzero, cpacsWing)
        deltaEta = sin(spoilerPhi) * spoilerChord
        deltaXsi = cos(spoilerPhi) * spoilerChord
        
        outerEtaTE = outerEtaLE - deltaEta / span
        outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE - deltaEta / span
        innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        mySpoilers.append(createSpoiler('OuterSpoiler' + str(n), parentWingVAMPzero.id, innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE))

        for i in range(2, n):
            # old outer is new inner 
            outerEtaLE = innerEtaLE
            # new inner is min next to kink  
            innerEtaLE = outerEtaLE - outerSpan / span / n
            # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
            outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
            innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset
            
            spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE, innerXsiLE, parentWingVAMPzero, cpacsWing)
            deltaEta = sin(spoilerPhi) * spoilerChord
            deltaXsi = cos(spoilerPhi) * spoilerChord
            
            outerEtaTE = outerEtaLE - deltaEta / span
            outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)
            innerEtaTE = innerEtaLE - deltaEta / span
            innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
            mySpoilers.append(createSpoiler('OuterSpoiler' + str(n - i + 1), parentWingVAMPzero.id, innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE))
        
        # old outer is new inner 
        outerEtaLE = innerEtaLE
        # new inner is min next to kink  
        innerEtaLE = spoilerOuterEta - outerSpan / span
        # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset
        
        spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE, innerXsiLE, parentWingVAMPzero, cpacsWing)
        deltaEta = sin(spoilerPhi) * spoilerChord
        deltaXsi = cos(spoilerPhi) * spoilerChord
        
        outerEtaTE = outerEtaLE - deltaEta / span
        outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE - deltaEta / span
        innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        # We do not want the spoiler to overlap the kink as the inner Spoilers will start here
        if innerEtaTE < etaKink:
            innerEtaTE = etaKink
            innerXsiTE = innerXsiLE + spoilerChord / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        mySpoilers.append(createSpoiler('OuterSpoiler1', parentWingVAMPzero.id, innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE))

    #===============================================================================
    # Inner Spoilers 
    #===============================================================================
    deltaArea = spoilerArea - outerArea
    noExport = False
    if deltaArea <= 0.:
        log.warning('VAMPzero SPOILER: Outboard Spoiler area already exceeds the required spoiler area by: %s' % str(deltaArea))
        noExport = True

    calcArea = 0.
    maxInnerArea = (etaKink - etaFus) * span * spoilerChord
    if maxInnerArea >= deltaArea and noExport == False:
        innerSpan = 0.
        while True:
            innerSpan += .01
            oldArea = calcArea
            calcArea = innerSpan * spoilerChord
            
            # This is the break condition that should be hit normally
            if abs(deltaArea - calcArea) < 0.1:
                break
            
            if innerSpan > (etaKink - etaFus) * span:
                log.warning('VAMPzero SPOILER: The spoiler span of the inner spoiler exceeds the available span betweent fuselage and kink, continuing with calcArea = %s' % str(calcArea))
                break 
            if oldArea > calcArea:
                log.warning('VAMPzero SPOILER: Inner spoiler area apparently reached a maximum, continuing with calcArea = %s' % str(calcArea))
                break 

    elif noExport == False:
        log.warning('VAMPzero SPOILER: There is not sufficient space for the inner spoiler(s) between the kink and the fuselage!')
        spoilerChord = deltaArea / ((etaKink - etaFus) * span)
        innerSpan = (etaKink - etaFus) * span
        calcArea = deltaArea
        log.warning('VAMPzero SPOILER: The spoilerchord will be enlarged to %s!' % str(spoilerChord))
    
    if noExport == True:
        nInnerSpoiler = 0
        log.debug('VAMPzero SPOILER: Exporting %s Spoiler inside of the kink.' % (str(nInnerSpoiler)))
    else: 
        nInnerSpoiler = innerSpan ** 2 / (calcArea * 3.)
        log.debug('VAMPzero SPOILER: Exporting %s Spoiler inside of the kink for an area of %s m2.' % (str(nInnerSpoiler), str(calcArea)))
    
        

    #===========================================================================
    # 1 Spoiler
    #===========================================================================
    if nInnerSpoiler == 0:
        pass
    
    elif nInnerSpoiler <= 1:
        # The outer eta of the leading Edge to the eta of the kink
        outerEtaLE = etaKink
        # The inner eta of the leading edge is the outer eta minus the span of the inner spoiler 
        innerEtaLE = outerEtaLE - innerSpan / span
        # The outer Xsi at the leading Edge is defined by the sparLocation of the Kink
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        # The innner Xsi remains an absolute chord of the spoiler
        chordInnerSpoiler = (1-outerXsiLE) * calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing)
        innerXsiLE = 1 - chordInnerSpoiler / calcChordLengthAtEta(innerEtaLE, parentWingVAMPzero, cpacsWing)
        
        # Eta Coordinates stay constant
        # Xsi Coordinates are shifted by spoilerChord
        outerEtaTE = outerEtaLE
        outerXsiTE = outerXsiLE + spoilerChord / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE
        innerXsiTE = innerXsiLE + spoilerChord / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        mySpoilers.append(createSpoiler('InnerSpoiler1', parentWingVAMPzero.id, innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE))
    
    #===========================================================================
    # 2 Spoiler
    #===========================================================================
    elif nInnerSpoiler > 1. and nInnerSpoiler <= 2.:
        # First inner spoiler 
        # The outer eta of the leading Edge to the eta of the kink
        outerEtaLE = etaKink
        # The inner eta of the leading edge is the outer eta minus the span of the inner spoiler 
        innerEtaLE = outerEtaLE - innerSpan / span / 2.
        # The outer Xsi at the leading Edge is defined by the sparLocation of the Kink
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        # The innner Xsi remains an absolute chord of the spoiler
        chordInnerSpoiler = (1-outerXsiLE) * calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing)
        innerXsiLE = 1 - chordInnerSpoiler / calcChordLengthAtEta(innerEtaLE, parentWingVAMPzero, cpacsWing)
        
        # Eta Coordinates stay constant
        # Xsi Coordinates are shifted by spoilerChord
        outerEtaTE = outerEtaLE
        outerXsiTE = outerXsiLE + spoilerChord / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE
        innerXsiTE = innerXsiLE + spoilerChord / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        mySpoilers.append(createSpoiler('InnerSpoiler2', parentWingVAMPzero.id, innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE))
        
        # Second inner spoiler
        # old inner becomes new outer
        outerEtaLE = innerEtaLE
        # The inner eta of the leading edge is the outer eta minus the span of the inner spoiler 
        innerEtaLE = outerEtaLE - innerSpan / span / 2.
        # The outer Xsi at the leading Edge is defined by the sparLocation of the Kink
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        # The innner Xsi remains an absolute chord of the spoiler
        chordInnerSpoiler = (1-outerXsiLE) * calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing)
        innerXsiLE = 1 - chordInnerSpoiler / calcChordLengthAtEta(innerEtaLE, parentWingVAMPzero, cpacsWing)
        
        # Eta Coordinates stay constant
        # Xsi Coordinates are shifted by spoilerChord
        outerEtaTE = outerEtaLE
        outerXsiTE = outerXsiLE + spoilerChord / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE
        innerXsiTE = innerXsiLE + spoilerChord / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        mySpoilers.append(createSpoiler('InnerSpoiler1', parentWingVAMPzero.id, innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE))

    #===========================================================================
    # Output to CPACS
    #===========================================================================
    if type(cpacsComponentSegment.get_controlSurfaces()) == NoneType:
        cpacsComponentSegment.set_controlSurfaces(controlSurfacesType())
    if type(cpacsComponentSegment.get_controlSurfaces().get_spoilers()) == NoneType:
        cpacsComponentSegment.get_controlSurfaces().set_spoilers(spoilersType())
    
    log.debug('VAMPzero Spoiler: Exporting %s Spoilers to CPACS.' % (str(len(mySpoilers))))
    for spoiler in mySpoilers:
        cpacsComponentSegment.get_controlSurfaces().get_spoilers().add_spoiler(spoiler)
Ejemplo n.º 7
0
def createSlats(parentWingCPACS, parentWingVAMPzero, mySlat):
    '''
    This is the main export method for the wing's slats
    It assumes a constant absolut chord for all slats.
    At the engine position a 5% span gap is included for the slats
    Slats end 5% prior to the wing tip
    '''
    cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + parentWingVAMPzero.id + ']'
    cpacsWing = getObjfromXpath(parentWingCPACS, cpacsPath)
    cpacsComponentSegment = cpacsWing.get_componentSegments().get_componentSegment()[0]
    mySlats = []
    
    # Initialization, i.e. fetching values throughout the code
    yFus = parentWingVAMPzero.yFuselage.getValue()
    span = parentWingVAMPzero.span.getValue() / 2.
    etaFus = yFus / span

    slatArea = mySlat.refArea.getValue()

    # The absolut chord of all slats is equal it is determined by the  
    # total slat area over the remaining span
    # the remaining span is the span minus the fuselage section minus 5% around the engine
    # and 5% at the tip
    cSlat = slatArea / ((1.0 - etaFus - 0.1) * span)
    
    if cSlat > calcChordLengthAtEta(etaFus, parentWingVAMPzero, cpacsWing) * 0.075:
        log.warning('VAMPzero SLAT: The slat chord is larger than 7.5% of the wing\'s chord at the fuselage intersection.')
    # Inner Wing Slats
    # At first inner wing slats are defined. These do only extend up to the engine
    # a plus minus 2.5% span are reserved for the slats
    # Note the calculation is only valid for nEngine == 2
    # The aspect ratio of a slat should not be higher than 5.5    
    etaEngine = parentWingVAMPzero.etaEngine.getValue()
    innerSpan = span * (etaEngine - 0.025 - etaFus)
    innerArea = innerSpan * cSlat
    nInnerSlats = innerSpan ** 2. / (innerArea * 5.5)
    log.debug('VAMPzero SLAT: Exporting %s Slats inside of the engine for an area of %s m2.' % (str(nInnerSlats), str(innerArea)))

    # 1 Slat
    if nInnerSlats <= 1.:
        # the inner border eta is located at the Fuselage
        innerEtaTE = etaFus
        innerXsiTE = cSlat / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)

        # the outer border eta is determined from the span of the outer flap
        outerEtaTE = etaFus + innerSpan / span
        outerXsiTE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)

        #Slats extend 50% of their chord lenght
        innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        
        mySlats.append(createSlat('InnerSlat1', parentWingVAMPzero.id, innerEtaTE, innerXsiTE, outerEtaTE, outerXsiTE, innerX=innerX, outerX=outerX))
    
    # 2 Slats
    elif nInnerSlats > 1. and nInnerSlats < 2.:
        # the inner border eta is located at the Fuselage
        innerEtaTE = etaFus
        innerXsiTE = cSlat / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)

        # the outer border eta is determined from the span of the outer flap
        outerEtaTE = etaFus + innerSpan / 2. / span
        outerXsiTE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)

        #Slats extend 50% of their chord lenght
        innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5

        mySlats.append(createSlat('InnerSlat1', parentWingVAMPzero.id, innerEtaTE, innerXsiTE, outerEtaTE, outerXsiTE, innerX=innerX, outerX=outerX))
        
        # new inner is the old outer 
        innerEtaLE = outerEtaTE
        innerXsiLE = outerXsiTE
        # the outer border eta is determined from the full span of the total outer flap
        outerEtaLE = etaFus + innerSpan / span
        outerXsiLE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)

        #Slats extend 50% of their chord lenght
        innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5

        mySlats.append(createSlat('InnerSlat2', parentWingVAMPzero.id, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, innerX=innerX, outerX=outerX))
    else:
        log.warning('VAMPzero EXPORT: Need more inner slats')

    # Outer Wing Slats
    # Determine the number of remaining slats
    # The aspect ratio of a slat should not be higher than 5.5 
    slatArea = slatArea - innerArea
    calcArea = 0.
    spanSlat = 0.
     
    while abs(calcArea - slatArea) > 0.5:
        spanSlat += .01
        calcArea = spanSlat * cSlat

    # Determine the number of slats
    # The aspect ratio of a slats should not be higher than 5.5 
    nSlats = spanSlat ** 2. / (slatArea * 5.5)
    log.debug('VAMPzero SLAT: Exporting %s Slats outboard of the engine for an area of %s m2.' % (str(nSlats), str(slatArea)))
    
    # 1 Slat
    if nSlats <= 1.:
        # the inner border eta is located at the Fuselage
        innerEtaTE = etaEngine + 0.025
        innerXsiTE = cSlat / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)

        # the outer border eta is determined from the span of the outer flap
        outerEtaTE = innerEtaTE + spanSlat / span
        outerXsiTE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)

        #Slats extend 50% of their chord lenght
        innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5

        mySlats.append(createSlat('OuterSlat1', parentWingVAMPzero.id, innerEtaTE, innerXsiTE, outerEtaTE, outerXsiTE, innerX=innerX, outerX=outerX))
    
    # 2 Slats
    elif nSlats > 1. and nSlats < 2.:
        # the inner border eta is located at the Fuselage
        innerEtaTE = etaEngine + 0.025
        innerXsiTE = cSlat / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)

        # the outer border eta is determined from the span of the outer flap
        outerEtaTE = innerEtaTE + spanSlat / 2. / span
        outerXsiTE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)

        #Slats extend 50% of their chord lenght
        innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5

        mySlats.append(createSlat('OuterSlat1', parentWingVAMPzero.id, innerEtaTE, innerXsiTE, outerEtaTE, outerXsiTE, innerX=innerX, outerX=outerX))
        
        # new inner is the old outer 
        innerEtaTE = outerEtaTE
        innerXsiTE = outerXsiTE
        # the outer border eta is determined from the full span of the total outer flap
        outerEtaTE = innerEtaTE + spanSlat / span
        outerXsiTE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)

        #Slats extend 50% of their chord lenght
        innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5

        mySlats.append(createSlat('OuterSlat2', parentWingVAMPzero.id, innerEtaTE, innerXsiTE, outerEtaTE, outerXsiTE, innerX=innerX, outerX=outerX))
    # n Slats
    else:
        # the inner border eta is located at the Fuselage
        n = int(ceil(nSlats))
        innerEtaTE = etaEngine + 0.025
        innerXsiTE = cSlat / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        
        # First Slat
        # the outer border eta is determined from the span of the outer flap
        outerEtaTE = innerEtaTE + spanSlat / n / span
        outerXsiTE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)

        #Slats extend 50% of their chord lenght
        innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5

        mySlats.append(createSlat('OuterSlat1', parentWingVAMPzero.id, innerEtaTE, innerXsiTE, outerEtaTE, outerXsiTE, innerX=innerX, outerX=outerX))
        
        for i in range(2, n):
            # new inner is the old outer 
            innerEtaTE = outerEtaTE
            innerXsiTE = outerXsiTE
            # the outer border eta is determined from the full span of the total outer flap
            outerEtaTE = innerEtaTE + spanSlat / n / span
            outerXsiTE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)
            
            #Slats extend 50% of their chord lenght
            innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
            outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
            
            mySlats.append(createSlat('OuterSlat' + str(i), parentWingVAMPzero.id, innerEtaTE, innerXsiTE, outerEtaTE, outerXsiTE, innerX=innerX, outerX=outerX))

        # Last Slat
        # new inner is the old outer 
        innerEtaTE = outerEtaTE
        innerXsiTE = outerXsiTE
        # the outer border eta is determined from the full span of the total outer flap
        outerEtaTE = innerEtaTE + spanSlat / n / span
        outerXsiTE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)

        #Slats extend 50% of their chord lenght
        innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        
        mySlats.append(createSlat('OuterSlat' + str(n), parentWingVAMPzero.id, innerEtaTE, innerXsiTE, outerEtaTE, outerXsiTE, innerX=innerX, outerX=outerX))
    
    # Output to CPACS
    if type(cpacsComponentSegment.get_controlSurfaces()) == NoneType:
        cpacsComponentSegment.set_controlSurfaces(controlSurfacesType())
    if type(cpacsComponentSegment.get_controlSurfaces().get_leadingEdgeDevices()) == NoneType:
        cpacsComponentSegment.get_controlSurfaces().set_leadingEdgeDevices(leadingEdgeDevicesType())
    
    log.debug('VAMPzero SLAT: Exporting %s Slats to CPACS.' % (str(len(mySlats))))
    for slat in mySlats:
        cpacsComponentSegment.get_controlSurfaces().get_leadingEdgeDevices().add_leadingEdgeDevice(slat)
Ejemplo n.º 8
0
def createSpoilers(parentWingCPACS, parentWingVAMPzero, mySpoiler):
    '''
    This is the main export method for the wing's spoilers
    
    * It assumes a constant absolut chord for all spoilers
    * Spoiler start outboard and move inboard close behind the rearspar
    * They are rectangular
    
    '''
    cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + parentWingVAMPzero.id + ']'
    cpacsWing = getObjfromXpath(parentWingCPACS, cpacsPath)
    cpacsComponentSegment = cpacsWing.get_componentSegments(
    ).get_componentSegment()[0]
    mySpoilers = []

    #===========================================================================
    # Initialization, i.e. fetching values throughout the code
    #===========================================================================
    span = parentWingVAMPzero.span.getValue() / 2.
    etaKink = parentWingVAMPzero.etaKink.getValue()
    yFus = parentWingVAMPzero.yFuselage.getValue()
    etaFus = yFus / span

    spoilerArea = mySpoiler.refArea.getValue()
    spoilerChord = mySpoiler.chord.getValue()
    spoilerOuterEta = mySpoiler.outerEta.getValue()

    sparOffset = 0.02

    #===========================================================================
    # Rear spar locations
    #===========================================================================
    xsiSparRoot = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[3].get_xsi().valueOf_)
    xsiSparFuselage = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[4].get_xsi().valueOf_)
    xsiSparKink = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[5].get_xsi().valueOf_)
    xsiSparTip = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[6].get_xsi().valueOf_)

    etaSparRoot = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[3].get_eta().valueOf_)
    etaSparFuselage = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[4].get_eta().valueOf_)
    etaSparKink = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[5].get_eta().valueOf_)
    etaSparTip = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[6].get_eta().valueOf_)

    xsiSpar_interp = scipy.interpolate.interp1d(
        [etaSparRoot, etaSparFuselage, etaSparKink, etaSparTip],
        [xsiSparRoot, xsiSparFuselage, xsiSparKink, xsiSparTip])

    #===========================================================================
    # Outer Spoilers
    #===========================================================================
    outerSpan = (spoilerOuterEta - etaKink) * span
    outerArea = spoilerChord * outerSpan
    nOuterSpoiler = outerSpan**2 / (outerArea * 2.)
    log.debug(
        'VAMPzero SPOILER: Exporting %s Spoiler outside of the kink for an area of %s m2.'
        % (str(nOuterSpoiler), str(outerArea)))

    #===========================================================================
    # 1 Spoiler
    #===========================================================================
    if nOuterSpoiler <= 1.:
        # The outer eta of the leading Edge is correspondent to the outerEta of the spoiler
        outerEtaLE = spoilerOuterEta
        # The inner eta of the leading edge is the outer eta minus the span of the outer spoiler
        innerEtaLE = spoilerOuterEta - outerSpan / span
        # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset

        spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE,
                                      innerXsiLE, parentWingVAMPzero,
                                      cpacsWing)
        deltaEta = sin(spoilerPhi) * spoilerChord
        deltaXsi = cos(spoilerPhi) * spoilerChord

        outerEtaTE = outerEtaLE - deltaEta / span
        outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(
            outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE - deltaEta / span
        innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(
            innerEtaTE, parentWingVAMPzero, cpacsWing)
        # We do not want the spoiler to overlap the kink as the inner Spoilers will start here
        if innerEtaTE < etaKink:
            innerEtaTE = etaKink
            innerXsiTE = innerXsiLE + spoilerChord / calcChordLengthAtEta(
                innerEtaTE, parentWingVAMPzero, cpacsWing)

        mySpoilers.append(
            createSpoiler('OuterSpoiler1', parentWingVAMPzero.id, innerEtaLE,
                          innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE,
                          outerEtaTE, outerXsiLE, outerXsiTE))

    #===========================================================================
    # 2 Spoiler
    #===========================================================================
    elif nOuterSpoiler > 1. and nOuterSpoiler <= 2.:
        # The outer eta of the leading Edge is correspondent to the outerEta of the spoiler
        outerEtaLE = spoilerOuterEta
        # The inner eta of the leading edge is the outer eta minus the span of the outer spoiler
        innerEtaLE = spoilerOuterEta - outerSpan / span / 2.
        # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset

        spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE,
                                      innerXsiLE, parentWingVAMPzero,
                                      cpacsWing)
        deltaEta = sin(spoilerPhi) * spoilerChord
        deltaXsi = cos(spoilerPhi) * spoilerChord

        outerEtaTE = outerEtaLE - deltaEta / span
        outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(
            outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE - deltaEta / span
        innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(
            innerEtaTE, parentWingVAMPzero, cpacsWing)

        mySpoilers.append(
            createSpoiler('OuterSpoiler2', parentWingVAMPzero.id, innerEtaLE,
                          innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE,
                          outerEtaTE, outerXsiLE, outerXsiTE))

        # old outer is new inner
        outerEtaLE = innerEtaLE
        # new inner is min next to kink
        innerEtaLE = spoilerOuterEta - outerSpan / span
        # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset

        spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE,
                                      innerXsiLE, parentWingVAMPzero,
                                      cpacsWing)
        deltaEta = sin(spoilerPhi) * spoilerChord
        deltaXsi = cos(spoilerPhi) * spoilerChord

        outerEtaTE = outerEtaLE - deltaEta / span
        outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(
            outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE - deltaEta / span
        innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(
            innerEtaTE, parentWingVAMPzero, cpacsWing)
        # We do not want the spoiler to overlap the kink as the inner Spoilers will start here
        if innerEtaTE < etaKink:
            innerEtaTE = etaKink
            innerXsiTE = innerXsiLE + spoilerChord / calcChordLengthAtEta(
                innerEtaTE, parentWingVAMPzero, cpacsWing)
        mySpoilers.append(
            createSpoiler('OuterSpoiler1', parentWingVAMPzero.id, innerEtaLE,
                          innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE,
                          outerEtaTE, outerXsiLE, outerXsiTE))

    #===========================================================================
    # n Spoiler
    #===========================================================================
    elif nOuterSpoiler > 2.:
        n = int(ceil(nOuterSpoiler))
        # The outer eta of the leading Edge is correspondent to the outerEta of the spoiler
        outerEtaLE = spoilerOuterEta
        # The inner eta of the leading edge is the outer eta minus the span of the outer spoiler
        innerEtaLE = outerEtaLE - outerSpan / span / n
        # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset

        spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE,
                                      innerXsiLE, parentWingVAMPzero,
                                      cpacsWing)
        deltaEta = sin(spoilerPhi) * spoilerChord
        deltaXsi = cos(spoilerPhi) * spoilerChord

        outerEtaTE = outerEtaLE - deltaEta / span
        outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(
            outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE - deltaEta / span
        innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(
            innerEtaTE, parentWingVAMPzero, cpacsWing)
        mySpoilers.append(
            createSpoiler('OuterSpoiler' + str(n), parentWingVAMPzero.id,
                          innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE,
                          outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE))

        for i in range(2, n):
            # old outer is new inner
            outerEtaLE = innerEtaLE
            # new inner is min next to kink
            innerEtaLE = outerEtaLE - outerSpan / span / n
            # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
            outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
            innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset

            spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE,
                                          innerXsiLE, parentWingVAMPzero,
                                          cpacsWing)
            deltaEta = sin(spoilerPhi) * spoilerChord
            deltaXsi = cos(spoilerPhi) * spoilerChord

            outerEtaTE = outerEtaLE - deltaEta / span
            outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(
                outerEtaTE, parentWingVAMPzero, cpacsWing)
            innerEtaTE = innerEtaLE - deltaEta / span
            innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(
                innerEtaTE, parentWingVAMPzero, cpacsWing)
            mySpoilers.append(
                createSpoiler('OuterSpoiler' + str(n - i + 1),
                              parentWingVAMPzero.id, innerEtaLE, innerEtaTE,
                              innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE,
                              outerXsiLE, outerXsiTE))

        # old outer is new inner
        outerEtaLE = innerEtaLE
        # new inner is min next to kink
        innerEtaLE = spoilerOuterEta - outerSpan / span
        # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset

        spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE,
                                      innerXsiLE, parentWingVAMPzero,
                                      cpacsWing)
        deltaEta = sin(spoilerPhi) * spoilerChord
        deltaXsi = cos(spoilerPhi) * spoilerChord

        outerEtaTE = outerEtaLE - deltaEta / span
        outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(
            outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE - deltaEta / span
        innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(
            innerEtaTE, parentWingVAMPzero, cpacsWing)
        # We do not want the spoiler to overlap the kink as the inner Spoilers will start here
        if innerEtaTE < etaKink:
            innerEtaTE = etaKink
            innerXsiTE = innerXsiLE + spoilerChord / calcChordLengthAtEta(
                innerEtaTE, parentWingVAMPzero, cpacsWing)
        mySpoilers.append(
            createSpoiler('OuterSpoiler1', parentWingVAMPzero.id, innerEtaLE,
                          innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE,
                          outerEtaTE, outerXsiLE, outerXsiTE))

    #===============================================================================
    # Inner Spoilers
    #===============================================================================
    deltaArea = spoilerArea - outerArea
    noExport = False
    if deltaArea <= 0.:
        log.warning(
            'VAMPzero SPOILER: Outboard Spoiler area already exceeds the required spoiler area by: %s'
            % str(deltaArea))
        noExport = True

    calcArea = 0.
    maxInnerArea = (etaKink - etaFus) * span * spoilerChord
    if maxInnerArea >= deltaArea and noExport == False:
        innerSpan = 0.
        while True:
            innerSpan += .01
            oldArea = calcArea
            calcArea = innerSpan * spoilerChord

            # This is the break condition that should be hit normally
            if abs(deltaArea - calcArea) < 0.1:
                break

            if innerSpan > (etaKink - etaFus) * span:
                log.warning(
                    'VAMPzero SPOILER: The spoiler span of the inner spoiler exceeds the available span betweent fuselage and kink, continuing with calcArea = %s'
                    % str(calcArea))
                break
            if oldArea > calcArea:
                log.warning(
                    'VAMPzero SPOILER: Inner spoiler area apparently reached a maximum, continuing with calcArea = %s'
                    % str(calcArea))
                break

    elif noExport == False:
        log.warning(
            'VAMPzero SPOILER: There is not sufficient space for the inner spoiler(s) between the kink and the fuselage!'
        )
        spoilerChord = deltaArea / ((etaKink - etaFus) * span)
        innerSpan = (etaKink - etaFus) * span
        calcArea = deltaArea
        log.warning(
            'VAMPzero SPOILER: The spoilerchord will be enlarged to %s!' %
            str(spoilerChord))

    if noExport == True:
        nInnerSpoiler = 0
        log.debug(
            'VAMPzero SPOILER: Exporting %s Spoiler inside of the kink.' %
            (str(nInnerSpoiler)))
    else:
        nInnerSpoiler = innerSpan**2 / (calcArea * 3.)
        log.debug(
            'VAMPzero SPOILER: Exporting %s Spoiler inside of the kink for an area of %s m2.'
            % (str(nInnerSpoiler), str(calcArea)))

    #===========================================================================
    # 1 Spoiler
    #===========================================================================
    if nInnerSpoiler == 0:
        pass

    elif nInnerSpoiler <= 1:
        # The outer eta of the leading Edge to the eta of the kink
        outerEtaLE = etaKink
        # The inner eta of the leading edge is the outer eta minus the span of the inner spoiler
        innerEtaLE = outerEtaLE - innerSpan / span
        # The outer Xsi at the leading Edge is defined by the sparLocation of the Kink
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        # The innner Xsi remains an absolute chord of the spoiler
        chordInnerSpoiler = (1 - outerXsiLE) * calcChordLengthAtEta(
            outerEtaLE, parentWingVAMPzero, cpacsWing)
        innerXsiLE = 1 - chordInnerSpoiler / calcChordLengthAtEta(
            innerEtaLE, parentWingVAMPzero, cpacsWing)

        # Eta Coordinates stay constant
        # Xsi Coordinates are shifted by spoilerChord
        outerEtaTE = outerEtaLE
        outerXsiTE = outerXsiLE + spoilerChord / calcChordLengthAtEta(
            outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE
        innerXsiTE = innerXsiLE + spoilerChord / calcChordLengthAtEta(
            innerEtaTE, parentWingVAMPzero, cpacsWing)
        mySpoilers.append(
            createSpoiler('InnerSpoiler1', parentWingVAMPzero.id, innerEtaLE,
                          innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE,
                          outerEtaTE, outerXsiLE, outerXsiTE))

    #===========================================================================
    # 2 Spoiler
    #===========================================================================
    elif nInnerSpoiler > 1. and nInnerSpoiler <= 2.:
        # First inner spoiler
        # The outer eta of the leading Edge to the eta of the kink
        outerEtaLE = etaKink
        # The inner eta of the leading edge is the outer eta minus the span of the inner spoiler
        innerEtaLE = outerEtaLE - innerSpan / span / 2.
        # The outer Xsi at the leading Edge is defined by the sparLocation of the Kink
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        # The innner Xsi remains an absolute chord of the spoiler
        chordInnerSpoiler = (1 - outerXsiLE) * calcChordLengthAtEta(
            outerEtaLE, parentWingVAMPzero, cpacsWing)
        innerXsiLE = 1 - chordInnerSpoiler / calcChordLengthAtEta(
            innerEtaLE, parentWingVAMPzero, cpacsWing)

        # Eta Coordinates stay constant
        # Xsi Coordinates are shifted by spoilerChord
        outerEtaTE = outerEtaLE
        outerXsiTE = outerXsiLE + spoilerChord / calcChordLengthAtEta(
            outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE
        innerXsiTE = innerXsiLE + spoilerChord / calcChordLengthAtEta(
            innerEtaTE, parentWingVAMPzero, cpacsWing)
        mySpoilers.append(
            createSpoiler('InnerSpoiler2', parentWingVAMPzero.id, innerEtaLE,
                          innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE,
                          outerEtaTE, outerXsiLE, outerXsiTE))

        # Second inner spoiler
        # old inner becomes new outer
        outerEtaLE = innerEtaLE
        # The inner eta of the leading edge is the outer eta minus the span of the inner spoiler
        innerEtaLE = outerEtaLE - innerSpan / span / 2.
        # The outer Xsi at the leading Edge is defined by the sparLocation of the Kink
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        # The innner Xsi remains an absolute chord of the spoiler
        chordInnerSpoiler = (1 - outerXsiLE) * calcChordLengthAtEta(
            outerEtaLE, parentWingVAMPzero, cpacsWing)
        innerXsiLE = 1 - chordInnerSpoiler / calcChordLengthAtEta(
            innerEtaLE, parentWingVAMPzero, cpacsWing)

        # Eta Coordinates stay constant
        # Xsi Coordinates are shifted by spoilerChord
        outerEtaTE = outerEtaLE
        outerXsiTE = outerXsiLE + spoilerChord / calcChordLengthAtEta(
            outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE
        innerXsiTE = innerXsiLE + spoilerChord / calcChordLengthAtEta(
            innerEtaTE, parentWingVAMPzero, cpacsWing)
        mySpoilers.append(
            createSpoiler('InnerSpoiler1', parentWingVAMPzero.id, innerEtaLE,
                          innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE,
                          outerEtaTE, outerXsiLE, outerXsiTE))

    #===========================================================================
    # Output to CPACS
    #===========================================================================
    if type(cpacsComponentSegment.get_controlSurfaces()) == NoneType:
        cpacsComponentSegment.set_controlSurfaces(controlSurfacesType())
    if type(cpacsComponentSegment.get_controlSurfaces().get_spoilers()
            ) == NoneType:
        cpacsComponentSegment.get_controlSurfaces().set_spoilers(
            spoilersType())

    log.debug('VAMPzero Spoiler: Exporting %s Spoilers to CPACS.' %
              (str(len(mySpoilers))))
    for spoiler in mySpoilers:
        cpacsComponentSegment.get_controlSurfaces().get_spoilers().add_spoiler(
            spoiler)
Ejemplo n.º 9
0
def createElevator(parentHtpCPACS, parentHtpVAMPzero, myElevator):
    """
    This is the main export method for the htp elevator
    """
    cpacsPath = "/cpacs/vehicles/aircraft/model/wings/wing[" + parentHtpVAMPzero.id + "]"
    cpacsHtp = getObjfromXpath(parentHtpCPACS, cpacsPath)
    cpacsComponentSegment = cpacsHtp.get_componentSegments().get_componentSegment()[0]

    # ===========================================================================
    # Header
    # ===========================================================================
    myName = stringBaseType(None, None, None, "elevator")
    myDescription = stringBaseType(None, None, None, "elevator from VAMPzero")
    myParentUID = stringUIDBaseType(None, None, "True", None, parentHtpVAMPzero.id)

    # ===========================================================================
    # Outer Shape
    # ===========================================================================
    # the inner border eta is determined from the rooYLocation of the Elevator and the htp span
    htpSpan = parentHtpVAMPzero.span.getValue() / 2.0
    innerEtaLE = myElevator.rootYLocation.getValue() / htpSpan

    # the inner border xsi is determined from the Root Chord and the Chord of the Htp at the location
    phiLE = parentHtpVAMPzero.phiLE.getValue()
    phiTE = parentHtpVAMPzero.phiTE.getValue()
    x1 = tan(phiLE * rad) * htpSpan * innerEtaLE
    x2 = tan(phiTE * rad) * htpSpan * innerEtaLE
    cInnerWing = (x2 + parentHtpVAMPzero.cRoot.getValue()) - x1
    innerXsiLE = 1 - (myElevator.cRoot.getValue() / cInnerWing)

    # The outer border eta station is set to the inner eta plus the span of the elevator
    outerEtaLE = innerEtaLE + myElevator.span.getValue() / htpSpan

    # The outer border xsi is determined in the same way as the inner border xsi
    x1 = tan(phiLE * rad) * htpSpan * outerEtaLE
    x2 = tan(phiTE * rad) * htpSpan * outerEtaLE
    cOuterWing = (x2 + parentHtpVAMPzero.cRoot.getValue()) - x1
    outerXsiLE = 1 - (myElevator.cTip.getValue() / cOuterWing)

    # start writing back
    myleadingEdgeShape = leadingEdgeShapeType(
        relHeightLE=doubleBaseType(valueOf_=str(0.5)),
        xsiUpperSkin=doubleBaseType(valueOf_=str(0.85)),
        xsiLowerSkin=doubleBaseType(valueOf_=str(0.85)),
    )
    innerBorder = controlSurfaceBorderTrailingEdgeType(
        etaLE=doubleBaseType(valueOf_=str(innerEtaLE)),
        xsiLE=doubleBaseType(valueOf_=str(innerXsiLE)),
        leadingEdgeShape=myleadingEdgeShape,
    )
    outerBorder = controlSurfaceBorderTrailingEdgeType(
        etaLE=doubleBaseType(valueOf_=str(outerEtaLE)),
        xsiLE=doubleBaseType(valueOf_=str(outerXsiLE)),
        leadingEdgeShape=myleadingEdgeShape,
    )

    myOuterShape = controlSurfaceOuterShapeTrailingEdgeType(innerBorder=innerBorder, outerBorder=outerBorder)

    cpacsElevator = trailingEdgeDeviceType(
        uID="elevatorUID", name=myName, description=myDescription, parentUID=myParentUID, outerShape=myOuterShape
    )

    createPath(cpacsElevator, "elevator")

    if type(cpacsComponentSegment.get_controlSurfaces()) == NoneType:
        cpacsComponentSegment.set_controlSurfaces(controlSurfacesType())
    if type(cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices()) == NoneType:
        cpacsComponentSegment.get_controlSurfaces().set_trailingEdgeDevices(trailingEdgeDevicesType())

    cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices().add_trailingEdgeDevice(cpacsElevator)
Ejemplo n.º 10
0
def createAileron(parentWingCPACS, parentWingVAMPzero, myAileron):
    '''
    This is the main export method for the wings aileron
    '''
    cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + parentWingVAMPzero.id + ']'
    cpacsWing = getObjfromXpath(parentWingCPACS, cpacsPath)
    cpacsComponentSegment = cpacsWing.get_componentSegments(
    ).get_componentSegment()[0]

    #===========================================================================
    # Header
    #===========================================================================
    myName = stringBaseType(None, None, None, 'aileron')
    myDescription = stringBaseType(None, None, None, 'aileron from VAMPzero')
    myParentUID = stringUIDBaseType(None, None, 'True', None, 'wing_Cseg')

    #===========================================================================
    # Initialization, i.e. fetching values throughout the code
    #===========================================================================
    xsiSparRoot = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[3].get_xsi().valueOf_)
    xsiSparFuselage = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[4].get_xsi().valueOf_)
    xsiSparKink = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[5].get_xsi().valueOf_)
    xsiSparTip = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[6].get_xsi().valueOf_)

    etaSparRoot = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[3].get_eta().valueOf_)
    etaSparFuselage = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[4].get_eta().valueOf_)
    etaSparKink = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[5].get_eta().valueOf_)
    etaSparTip = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[6].get_eta().valueOf_)

    xsiSpar_interp = scipy.interpolate.interp1d(
        [etaSparRoot, etaSparFuselage, etaSparKink, etaSparTip],
        [xsiSparRoot, xsiSparFuselage, xsiSparKink, xsiSparTip])

    sparOffset = 0.1
    wingSpan = parentWingVAMPzero.span.getValue() / 2.
    #===========================================================================
    # Outer Shape
    #===========================================================================
    # The outer border eta station is set to 96 percent
    outerEtaLE = 0.96
    # The outer chord station is determined from the wing's chord at eta = 0.96
    # and the rear spar location + the spar offset
    outerXsiLE = xsiSpar_interp(0.96) + sparOffset
    outerWingChord = calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero,
                                          cpacsWing)

    cTip = (1 - outerXsiLE) * outerWingChord

    # now we need to determine the necessary span for the aileron by gently increasing the span
    # this is an iterative process as the chord of the aileron is a function of the inbound span
    aileronArea = parentWingVAMPzero.aileron.refArea.getValue()
    delta = 0.01
    calcArea = 0.
    while abs(calcArea - aileronArea) > 0.1:
        if delta > outerEtaLE:
            parentWingVAMPzero.log.warning(
                'VAMPzero EXPORT: Cannot determine the span of the aileron')
            parentWingVAMPzero.log.warning('VAMPzero EXPORT: aileronArea= ' +
                                           str(aileronArea))
            parentWingVAMPzero.log.warning(
                'VAMPzero EXPORT: Decreasing Spar Offset')
            sparOffset = sparOffset - 0.02
            delta = 0.01

        innerEtaLE = outerEtaLE - delta
        innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset
        innerWingChord = calcChordLengthAtEta(innerEtaLE, parentWingVAMPzero,
                                              cpacsWing)
        cRoot = (1 - innerXsiLE) * innerWingChord

        calcArea = (cTip + cRoot) / 2 * (outerEtaLE - innerEtaLE) * wingSpan
        delta += 0.005

    # start outer shape
    myleadingEdgeShape = leadingEdgeShapeType(
        relHeightLE=doubleBaseType(valueOf_=str(0.5)),
        xsiUpperSkin=doubleBaseType(valueOf_=str(0.85)),
        xsiLowerSkin=doubleBaseType(valueOf_=str(0.85)))
    innerBorder = controlSurfaceBorderTrailingEdgeType(
        etaLE=doubleBaseType(valueOf_=str(innerEtaLE)),
        etaTE=doubleBaseType(valueOf_=str(innerEtaLE)),
        xsiLE=doubleBaseType(valueOf_=str(innerXsiLE)),
        leadingEdgeShape=myleadingEdgeShape)
    outerBorder = controlSurfaceBorderTrailingEdgeType(
        etaLE=doubleBaseType(valueOf_=str(outerEtaLE)),
        etaTE=doubleBaseType(valueOf_=str(outerEtaLE)),
        xsiLE=doubleBaseType(valueOf_=str(outerXsiLE)),
        leadingEdgeShape=myleadingEdgeShape)
    myOuterShape = controlSurfaceOuterShapeTrailingEdgeType(
        innerBorder=innerBorder, outerBorder=outerBorder)

    # structure
    myStructure = wingComponentSegmentStructureType()
    cpacsAileron = trailingEdgeDeviceType(uID='aileronUID',
                                          name=myName,
                                          description=myDescription,
                                          parentUID=myParentUID,
                                          outerShape=myOuterShape,
                                          structure=myStructure)
    createAileronStructure(cpacsAileron)

    # Forward information about innerEtaLE to the flap
    parentWingVAMPzero.flap.maxEta = parameter(
        value=innerEtaLE,
        doc=
        'This it the inner position of the aileron, the flap may not exceed it'
    )

    # moveables
    deltaEta = outerEtaLE - innerEtaLE
    innerParentXsi = xsiSpar_interp(innerEtaLE + 0.3 * deltaEta) + 0.02
    outerParentXsi = xsiSpar_interp(innerEtaLE + 0.7 * deltaEta) + 0.02

    createPath(cpacsAileron, 'aileron')
    createTracks(cpacsAileron, 'aileron')
    createActuators(cpacsAileron, 'aileron', [innerParentXsi, outerParentXsi])

    if type(cpacsComponentSegment.get_controlSurfaces()) == NoneType:
        cpacsComponentSegment.set_controlSurfaces(controlSurfacesType())
    if type(cpacsComponentSegment.get_controlSurfaces().
            get_trailingEdgeDevices()) == NoneType:
        cpacsComponentSegment.get_controlSurfaces().set_trailingEdgeDevices(
            trailingEdgeDevicesType())

    cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices(
    ).add_trailingEdgeDevice(cpacsAileron)
Ejemplo n.º 11
0
def createElevator(parentHtpCPACS, parentHtpVAMPzero, myElevator):
    '''
    This is the main export method for the htp elevator
    '''
    cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + parentHtpVAMPzero.id + ']'
    cpacsHtp = getObjfromXpath(parentHtpCPACS, cpacsPath)
    cpacsComponentSegment = cpacsHtp.get_componentSegments(
    ).get_componentSegment()[0]

    #===========================================================================
    # Header
    #===========================================================================
    myName = stringBaseType(None, None, None, 'elevator')
    myDescription = stringBaseType(None, None, None, 'elevator from VAMPzero')
    myParentUID = stringUIDBaseType(None, None, 'True', None,
                                    parentHtpVAMPzero.id)

    #===========================================================================
    # Outer Shape
    #===========================================================================
    # the inner border eta is determined from the rooYLocation of the Elevator and the htp span
    htpSpan = parentHtpVAMPzero.span.getValue() / 2.
    innerEtaLE = myElevator.rootYLocation.getValue() / htpSpan

    # the inner border xsi is determined from the Root Chord and the Chord of the Htp at the location
    phiLE = parentHtpVAMPzero.phiLE.getValue()
    phiTE = parentHtpVAMPzero.phiTE.getValue()
    x1 = tan(phiLE * rad) * htpSpan * innerEtaLE
    x2 = tan(phiTE * rad) * htpSpan * innerEtaLE
    cInnerWing = (x2 + parentHtpVAMPzero.cRoot.getValue()) - x1
    innerXsiLE = 1 - (myElevator.cRoot.getValue() / cInnerWing)

    # The outer border eta station is set to the inner eta plus the span of the elevator
    outerEtaLE = innerEtaLE + myElevator.span.getValue() / htpSpan

    # The outer border xsi is determined in the same way as the inner border xsi
    x1 = tan(phiLE * rad) * htpSpan * outerEtaLE
    x2 = tan(phiTE * rad) * htpSpan * outerEtaLE
    cOuterWing = (x2 + parentHtpVAMPzero.cRoot.getValue()) - x1
    outerXsiLE = 1 - (myElevator.cTip.getValue() / cOuterWing)

    # start writing back
    myleadingEdgeShape = leadingEdgeShapeType(
        relHeightLE=doubleBaseType(valueOf_=str(0.5)),
        xsiUpperSkin=doubleBaseType(valueOf_=str(0.85)),
        xsiLowerSkin=doubleBaseType(valueOf_=str(0.85)))
    innerBorder = controlSurfaceBorderTrailingEdgeType(
        etaLE=doubleBaseType(valueOf_=str(innerEtaLE)),
        xsiLE=doubleBaseType(valueOf_=str(innerXsiLE)),
        leadingEdgeShape=myleadingEdgeShape)
    outerBorder = controlSurfaceBorderTrailingEdgeType(
        etaLE=doubleBaseType(valueOf_=str(outerEtaLE)),
        xsiLE=doubleBaseType(valueOf_=str(outerXsiLE)),
        leadingEdgeShape=myleadingEdgeShape)

    myOuterShape = controlSurfaceOuterShapeTrailingEdgeType(
        innerBorder=innerBorder, outerBorder=outerBorder)

    cpacsElevator = trailingEdgeDeviceType(uID='elevatorUID',
                                           name=myName,
                                           description=myDescription,
                                           parentUID=myParentUID,
                                           outerShape=myOuterShape)

    createPath(cpacsElevator, 'elevator')

    if type(cpacsComponentSegment.get_controlSurfaces()) == NoneType:
        cpacsComponentSegment.set_controlSurfaces(controlSurfacesType())
    if type(cpacsComponentSegment.get_controlSurfaces().
            get_trailingEdgeDevices()) == NoneType:
        cpacsComponentSegment.get_controlSurfaces().set_trailingEdgeDevices(
            trailingEdgeDevicesType())

    cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices(
    ).add_trailingEdgeDevice(cpacsElevator)
Ejemplo n.º 12
0
def createElevator(parentHtpCPACS, parentHtpVAMPzero, myElevator):
    '''
    This is the main export method for the htp elevator
    '''
    cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + parentHtpVAMPzero.id + ']'
    cpacsHtp = getObjfromXpath(parentHtpCPACS, cpacsPath)
    cpacsComponentSegment = cpacsHtp.get_componentSegments().get_componentSegment()[0]

    #===========================================================================
    # Header
    #===========================================================================
    myName = stringBaseType(None, None, None, 'elevator')
    myDescription = stringBaseType(None, None, None, 'elevator from VAMPzero')
    myParentUID = stringUIDBaseType(None, None, 'True', None, parentHtpVAMPzero.id)
    
    #===========================================================================
    # Outer Shape
    #===========================================================================
    # the inner border eta is determined from the rooYLocation of the Elevator and the htp span
    htpSpan = parentHtpVAMPzero.span.getValue() / 2.
    innerEtaLE = myElevator.rootYLocation.getValue() / htpSpan
    
    # the inner border xsi is determined from the Root Chord and the Chord of the Htp at the location
    # the inner border xsi is determined from the Root Chord and the Chord of the Htp at the location
    cTipHtp = parentHtpVAMPzero.cTip.getValue()
    cRootHtp = parentHtpVAMPzero.cRoot.getValue()
    cInnerWing = cRootHtp - (cRootHtp - cTipHtp)*innerEtaLE
    innerXsiLE = 1 - (myElevator.cRoot.getValue() / cInnerWing)

    if innerXsiLE < 0.2:
        parentHtpVAMPzero.log.warning('VAMPzero EXPORT: The Elevator tap inner border is larger than the available chord')
        parentHtpVAMPzero.log.warning('VAMPzero EXPORT: The Elevator tap inner border is now set to 0.1')
        innerXsiLE = 0.2

    # The outer border eta station is set to the inner eta plus the span of the elevator
    outerEtaLE = innerEtaLE + myElevator.span.getValue() / htpSpan
    
    # The outer border xsi is determined in the same way as the inner border xsi
    cOuterWing = cRootHtp - (cRootHtp - cTipHtp)*outerEtaLE
    outerXsiLE = 1 - (myElevator.cTip.getValue() / cOuterWing)

    if outerXsiLE < 0.2:
        parentHtpVAMPzero.log.warning('VAMPzero EXPORT: The Elevator tap outer border is larger than the available chord')
        parentHtpVAMPzero.log.warning('VAMPzero EXPORT: The Elevator tap outer border is now set to 0.1')
        outerXsiLE = 0.2

    # start writing back
    myleadingEdgeShape = leadingEdgeShapeType(relHeightLE=doubleBaseType(valueOf_=str(0.5)), xsiUpperSkin=doubleBaseType(valueOf_=str(0.85)), xsiLowerSkin=doubleBaseType(valueOf_=str(0.85)))
    innerBorder = controlSurfaceBorderTrailingEdgeType(etaLE=doubleBaseType(valueOf_=str(innerEtaLE)), xsiLE=doubleBaseType(valueOf_=str(innerXsiLE)), leadingEdgeShape=myleadingEdgeShape)
    outerBorder = controlSurfaceBorderTrailingEdgeType(etaLE=doubleBaseType(valueOf_=str(outerEtaLE)), xsiLE=doubleBaseType(valueOf_=str(outerXsiLE)), leadingEdgeShape=myleadingEdgeShape)
    
    myOuterShape = controlSurfaceOuterShapeTrailingEdgeType(innerBorder=innerBorder, outerBorder=outerBorder)

    cpacsElevator = trailingEdgeDeviceType(uID='elevatorUID', name=myName, description=myDescription, parentUID=myParentUID, outerShape=myOuterShape)

    createPath(cpacsElevator, 'elevator')

    if type(cpacsComponentSegment.get_controlSurfaces()) == NoneType:
        cpacsComponentSegment.set_controlSurfaces(controlSurfacesType())
    if type(cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices()) == NoneType:
        cpacsComponentSegment.get_controlSurfaces().set_trailingEdgeDevices(trailingEdgeDevicesType())
    
    cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices().add_trailingEdgeDevice(cpacsElevator)
Ejemplo n.º 13
0
def createSpoilersSBW(parentWingCPACS, parentWingVAMPzero, mySpoiler):
    '''
    This is the main export method for the wing's spoilers

    * It assumes a constant absolut chord for all spoilers
    * Spoiler start outboard and move inboard close behind the rearspar
    * They are rectangular

    '''
    cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + parentWingVAMPzero.id + ']'
    cpacsWing = getObjfromXpath(parentWingCPACS, cpacsPath)
    cpacsComponentSegment = cpacsWing.get_componentSegments().get_componentSegment()[0]
    mySpoilers = []

    # Initialization, i.e. fetching values throughout the code
    span = parentWingVAMPzero.span.getValue() / 2.
    yFus = parentWingVAMPzero.yFuselage.getValue()
    etaFus = yFus / span

    spoilerArea = mySpoiler.refArea.getValue()
    spoilerChord = mySpoiler.chord.getValue()
    spoilerOuterEta = mySpoiler.outerEta.getValue()

    sparOffset = 0.02

    # Rear spar locations
    xsis = []
    etas = []
    for i in range(3,7):
        try:
            xsis.append(eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[i].get_xsi().valueOf_))
            etas.append(eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[i].get_eta().valueOf_))
        except IndexError:
            pass

    xsiSpar_interp = scipy.interpolate.interp1d(etas, xsis)

    # Outer Spoilers
    outerSpan = (spoilerOuterEta - etaFus) * span
    #outerArea = spoilerChord * outerSpan
    #nOuterSpoiler = outerSpan ** 2 / (outerArea * 2.)
    #log.debug('VAMPzero SPOILER: Exporting %s Spoiler outside of the kink for an area of %s m2.' % (str(nOuterSpoiler), str(outerArea)))

    calcArea = 0.
    maxInnerArea = (spoilerOuterEta - etaFus) * span * spoilerChord
    innerSpan = 0.
    while True:
        innerSpan += .01
        oldArea = calcArea
        calcArea = innerSpan * spoilerChord

        # This is the break condition that should be hit normally
        if abs(spoilerArea - calcArea) < 0.1:
            break

        if innerSpan > (spoilerOuterEta - etaFus) * span:
            log.warning('VAMPzero SPOILER: The spoiler span of the  spoiler exceeds the available span between fuselage and kink, continuing with calcArea = %s' % str(calcArea))
            break
        if oldArea > calcArea:
            log.warning('VAMPzero SPOILER: Spoiler area apparently reached a maximum, continuing with calcArea = %s' % str(calcArea))
            break

    nSpoiler = innerSpan ** 2 / (calcArea * 3.)
    log.debug('VAMPzero SPOILER: Exporting %s Spoiler inside of the kink for an area of %s m2.' % (str(nSpoiler), str(calcArea)))

    # 1 Spoiler
    if nSpoiler <= 1.:
        # The outer eta of the leading Edge is correspondent to the outerEta of the spoiler
        outerEtaLE = spoilerOuterEta
        # The inner eta of the leading edge is the outer eta minus the span of the outer spoiler
        innerEtaLE = spoilerOuterEta - outerSpan / span
        # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset

        spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE, innerXsiLE, parentWingVAMPzero, cpacsWing)
        deltaEta = sin(spoilerPhi) * spoilerChord
        deltaXsi = cos(spoilerPhi) * spoilerChord

        outerEtaTE = outerEtaLE - deltaEta / span
        outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE - deltaEta / span
        innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        # We do not want the spoiler to overlap the kink as the inner Spoilers will start here
        if innerEtaTE < etaFus:
            innerEtaTE = etaFus
            innerXsiTE = innerXsiLE + spoilerChord / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)

        mySpoilers.append(createSpoiler('Spoiler1', parentWingVAMPzero.id, innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE))

    # 2 Spoiler
    elif nSpoiler > 1. and nSpoiler <= 2.:
        # The outer eta of the leading Edge is correspondent to the outerEta of the spoiler
        outerEtaLE = spoilerOuterEta
        # The inner eta of the leading edge is the outer eta minus the span of the outer spoiler
        innerEtaLE = spoilerOuterEta - outerSpan / span / 2.
        # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset

        spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE, innerXsiLE, parentWingVAMPzero, cpacsWing)
        deltaEta = sin(spoilerPhi) * spoilerChord
        deltaXsi = cos(spoilerPhi) * spoilerChord

        outerEtaTE = outerEtaLE - deltaEta / span
        outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE - deltaEta / span
        innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)

        mySpoilers.append(createSpoiler('Spoiler2', parentWingVAMPzero.id, innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE))

        # old outer is new inner
        outerEtaLE = innerEtaLE
        # new inner is min next to kink
        innerEtaLE = spoilerOuterEta - outerSpan / span
        # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset

        spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE, innerXsiLE, parentWingVAMPzero, cpacsWing)
        deltaEta = sin(spoilerPhi) * spoilerChord
        deltaXsi = cos(spoilerPhi) * spoilerChord

        outerEtaTE = outerEtaLE - deltaEta / span
        outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE - deltaEta / span
        innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        # We do not want the spoiler to overlap the kink as the inner Spoilers will start here
        if innerEtaTE < etaFus:
            innerEtaTE = etaFus
            innerXsiTE = innerXsiLE + spoilerChord / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        mySpoilers.append(createSpoiler('Spoiler1', parentWingVAMPzero.id, innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE))

    # n Spoiler
    elif nSpoiler > 2.:
        n = int(ceil(nSpoiler))
        # The outer eta of the leading Edge is correspondent to the outerEta of the spoiler
        outerEtaLE = spoilerOuterEta
        # The inner eta of the leading edge is the outer eta minus the span of the outer spoiler
        innerEtaLE = outerEtaLE - outerSpan / span / n
        # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset

        spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE, innerXsiLE, parentWingVAMPzero, cpacsWing)
        deltaEta = sin(spoilerPhi) * spoilerChord
        deltaXsi = cos(spoilerPhi) * spoilerChord

        outerEtaTE = outerEtaLE - deltaEta / span
        outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE - deltaEta / span
        innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        mySpoilers.append(createSpoiler('Spoiler' + str(n), parentWingVAMPzero.id, innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE))

        for i in range(2, n):
            # old outer is new inner
            outerEtaLE = innerEtaLE
            # new inner is min next to kink
            innerEtaLE = outerEtaLE - outerSpan / span / n
            # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
            outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
            innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset

            spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE, innerXsiLE, parentWingVAMPzero, cpacsWing)
            deltaEta = sin(spoilerPhi) * spoilerChord
            deltaXsi = cos(spoilerPhi) * spoilerChord

            outerEtaTE = outerEtaLE - deltaEta / span
            outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)
            innerEtaTE = innerEtaLE - deltaEta / span
            innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
            mySpoilers.append(createSpoiler('Spoiler' + str(n - i + 1), parentWingVAMPzero.id, innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE))

        # old outer is new inner
        outerEtaLE = innerEtaLE
        # new inner is min next to kink
        innerEtaLE = spoilerOuterEta - outerSpan / span
        # The inner and outer Xsi coordinate of the leading edge are defined by the rear spar location and the sparOffset
        outerXsiLE = xsiSpar_interp(outerEtaLE) + sparOffset
        innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset

        spoilerPhi = calcPhiLESpoiler(outerEtaLE, innerEtaLE, outerXsiLE, innerXsiLE, parentWingVAMPzero, cpacsWing)
        deltaEta = sin(spoilerPhi) * spoilerChord
        deltaXsi = cos(spoilerPhi) * spoilerChord

        outerEtaTE = outerEtaLE - deltaEta / span
        outerXsiTE = outerXsiLE + deltaXsi / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)
        innerEtaTE = innerEtaLE - deltaEta / span
        innerXsiTE = innerXsiLE + deltaXsi / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        # We do not want the spoiler to overlap the kink as the inner Spoilers will start here
        if innerEtaTE < etaFus:
            innerEtaTE = etaFus
            innerXsiTE = innerXsiLE + spoilerChord / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        mySpoilers.append(createSpoiler('Spoiler1', parentWingVAMPzero.id, innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE))

    # Output to CPACS
    if type(cpacsComponentSegment.get_controlSurfaces()) == NoneType:
        cpacsComponentSegment.set_controlSurfaces(controlSurfacesType())
    if type(cpacsComponentSegment.get_controlSurfaces().get_spoilers()) == NoneType:
        cpacsComponentSegment.get_controlSurfaces().set_spoilers(spoilersType())

    log.debug('VAMPzero Spoiler: Exporting %s Spoilers to CPACS.' % (str(len(mySpoilers))))
    for spoiler in mySpoilers:
        cpacsComponentSegment.get_controlSurfaces().get_spoilers().add_spoiler(spoiler)
Ejemplo n.º 14
0
def createAileron(parentWingCPACS, parentWingVAMPzero, myAileron):
    '''
    This is the main export method for the wings aileron
    '''
    cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + parentWingVAMPzero.id + ']'
    cpacsWing = getObjfromXpath(parentWingCPACS, cpacsPath)
    cpacsComponentSegment = cpacsWing.get_componentSegments().get_componentSegment()[0]

    # Header
    myName = stringBaseType(None, None, None, 'aileron')
    myDescription = stringBaseType(None, None, None, 'aileron from VAMPzero')
    myParentUID = stringUIDBaseType(None, None, 'True', None, 'wing_Cseg')

    # Initialization, i.e. fetching values throughout the code
    xsis = []
    etas = []
    for i in range(3,7):
        try:
            xsis.append(eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[i].get_xsi().valueOf_))
            etas.append(eval(cpacsComponentSegment.get_structure().get_spars().get_sparPositions().get_sparPosition()[i].get_eta().valueOf_))
        except IndexError:
            pass

    xsiSpar_interp = scipy.interpolate.interp1d(etas, xsis)
    
    sparOffset = 0.1
    wingSpan = parentWingVAMPzero.span.getValue() / 2.

    # Outer Shape
    # The outer border eta station is set to 96 percent
    outerEtaLE = 0.96
    # The outer chord station is determined from the wing's chord at eta = 0.96
    # and the rear spar location + the spar offset
    outerXsiLE = xsiSpar_interp(0.96) + sparOffset
    outerWingChord = calcChordLengthAtEta(outerEtaLE, parentWingVAMPzero, cpacsWing)
    
    cTip = (1 - outerXsiLE) * outerWingChord
    
    # now we need to determine the necessary span for the aileron by gently increasing the span
    # this is an iterative process as the chord of the aileron is a function of the inbound span
    aileronArea = parentWingVAMPzero.aileron.refArea.getValue()
    delta = 0.01
    calcArea = 0.
    while abs(calcArea - aileronArea) > 0.1:
        if delta > outerEtaLE:
            parentWingVAMPzero.log.warning('VAMPzero EXPORT: Cannot determine the span of the aileron')
            parentWingVAMPzero.log.warning('VAMPzero EXPORT: aileronArea= '+str(aileronArea))
            parentWingVAMPzero.log.warning('VAMPzero EXPORT: Decreasing Spar Offset')
            sparOffset = sparOffset - 0.02
            delta = 0.01
            
        innerEtaLE = outerEtaLE - delta
        innerXsiLE = xsiSpar_interp(innerEtaLE) + sparOffset        
        innerWingChord = calcChordLengthAtEta(innerEtaLE, parentWingVAMPzero, cpacsWing)
        cRoot = (1 - innerXsiLE) * innerWingChord

        calcArea = (cTip + cRoot) / 2 * (outerEtaLE - innerEtaLE) * wingSpan
        delta += 0.005
 
    # start outer shape
    myleadingEdgeShape = leadingEdgeShapeType(relHeightLE=doubleBaseType(valueOf_=str(0.5)), xsiUpperSkin=doubleBaseType(valueOf_=str(0.85)), xsiLowerSkin=doubleBaseType(valueOf_=str(0.85)))
    innerBorder = controlSurfaceBorderTrailingEdgeType(etaLE=doubleBaseType(valueOf_=str(innerEtaLE)), etaTE=doubleBaseType(valueOf_=str(innerEtaLE)), xsiLE=doubleBaseType(valueOf_=str(innerXsiLE)), leadingEdgeShape=myleadingEdgeShape)
    outerBorder = controlSurfaceBorderTrailingEdgeType(etaLE=doubleBaseType(valueOf_=str(outerEtaLE)), etaTE=doubleBaseType(valueOf_=str(outerEtaLE)), xsiLE=doubleBaseType(valueOf_=str(outerXsiLE)), leadingEdgeShape=myleadingEdgeShape)
    myOuterShape = controlSurfaceOuterShapeTrailingEdgeType(innerBorder=innerBorder, outerBorder=outerBorder)
    
    # structure
    myStructure = wingComponentSegmentStructureType()
    cpacsAileron = trailingEdgeDeviceType(uID='aileronUID', name=myName, description=myDescription, parentUID=myParentUID, outerShape=myOuterShape, structure=myStructure)
    createAileronStructure(cpacsAileron)
    
    # Forward information about innerEtaLE to the flap
    parentWingVAMPzero.flap.maxEta = parameter(value=innerEtaLE, doc='This it the inner position of the aileron, the flap may not exceed it')
    
    # moveables
    deltaEta = outerEtaLE - innerEtaLE 
    innerParentXsi = xsiSpar_interp(innerEtaLE + 0.3 * deltaEta) + 0.02
    outerParentXsi = xsiSpar_interp(innerEtaLE + 0.7 * deltaEta) + 0.02

    createPath(cpacsAileron, 'aileron')
    createTracks(cpacsAileron, 'aileron')
    createActuators(cpacsAileron, 'aileron', [innerParentXsi, outerParentXsi])

    if type(cpacsComponentSegment.get_controlSurfaces()) == NoneType:
        cpacsComponentSegment.set_controlSurfaces(controlSurfacesType())
    if type(cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices()) == NoneType:
        cpacsComponentSegment.get_controlSurfaces().set_trailingEdgeDevices(trailingEdgeDevicesType())
    
    cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices().add_trailingEdgeDevice(cpacsAileron)
Ejemplo n.º 15
0
def createSlats(parentWingCPACS, parentWingVAMPzero, mySlat):
    '''
    This is the main export method for the wing's slats
    It assumes a constant absolut chord for all slats.
    At the engine position a 5% span gap is included for the slats
    Slats end 5% prior to the wing tip
    '''
    cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + parentWingVAMPzero.id + ']'
    cpacsWing = getObjfromXpath(parentWingCPACS, cpacsPath)
    cpacsComponentSegment = cpacsWing.get_componentSegments().get_componentSegment()[0]
    mySlats = []
    
    #===========================================================================
    # Initialization, i.e. fetching values throughout the code
    #===========================================================================
    yFus = parentWingVAMPzero.yFuselage.getValue()
    span = parentWingVAMPzero.span.getValue() / 2.
    etaFus = yFus / span

    slatArea = mySlat.refArea.getValue()

    # The absolut chord of all slats is equal it is determined by the  
    # total slat area over the remaining span
    # the remaining span is the span minus the fuselage section minus 5% around the engine
    # and 5% at the tip
    cSlat = slatArea / ((1.0 - etaFus - 0.1) * span)
    
    if cSlat > calcChordLengthAtEta(etaFus, parentWingVAMPzero, cpacsWing) * 0.075:
        log.warning('VAMPzero SLAT: The slat chord is larger than 7.5% of the wing\'s chord at the fuselage intersection.')

    
    #===========================================================================
    # Inner Wing Slats
    # ----------------
    #
    # At first inner wing slats are defined. These do only extend up to the engine
    # a plus minus 2.5% span are reserved for the slats
    # Note the calculation is only valid for nEngine == 2
    # The aspect ratio of a slat should not be higher than 5.5    
    #===========================================================================
    etaEngine = parentWingVAMPzero.etaEngine.getValue()
    innerSpan = span * (etaEngine - 0.025 - etaFus)
    innerArea = innerSpan * cSlat
    nInnerSlats = innerSpan ** 2. / (innerArea * 5.5)
    log.debug('VAMPzero SLAT: Exporting %s Slats inside of the engine for an area of %s m2.' % (str(nInnerSlats), str(innerArea)))

    #===========================================================================
    # 1 Slat
    #===========================================================================
    if nInnerSlats <= 1.:
        # the inner border eta is located at the Fuselage
        innerEtaTE = etaFus
        innerXsiTE = cSlat / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)

        # the outer border eta is determined from the span of the outer flap
        outerEtaTE = etaFus + innerSpan / span
        outerXsiTE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)

        #Slats extend 50% of their chord lenght
        innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        
        mySlats.append(createSlat('InnerSlat1', parentWingVAMPzero.id, innerEtaTE, innerXsiTE, outerEtaTE, outerXsiTE, innerX=innerX, outerX=outerX))
    
    #===========================================================================
    # 2 Slats
    #===========================================================================
    elif nInnerSlats > 1. and nInnerSlats < 2.:
        # the inner border eta is located at the Fuselage
        innerEtaTE = etaFus
        innerXsiTE = cSlat / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)

        # the outer border eta is determined from the span of the outer flap
        outerEtaTE = etaFus + innerSpan / 2. / span
        outerXsiTE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)

        #Slats extend 50% of their chord lenght
        innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5

        mySlats.append(createSlat('InnerSlat1', parentWingVAMPzero.id, innerEtaTE, innerXsiTE, outerEtaTE, outerXsiTE, innerX=innerX, outerX=outerX))
        
        # new inner is the old outer 
        innerEtaLE = outerEtaTE
        innerXsiLE = outerXsiTE
        # the outer border eta is determined from the full span of the total outer flap
        outerEtaLE = etaFus + innerSpan / span
        outerXsiLE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)

        #Slats extend 50% of their chord lenght
        innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5

        mySlats.append(createSlat('InnerSlat2', parentWingVAMPzero.id, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, innerX=innerX, outerX=outerX))
    else:
        log.warning('VAMPzero EXPORT: Need more inner slats')

    #===========================================================================
    # Outer Wing Slats
    # ----------------
    #
    # Determine the number of remaining slats
    # The aspect ratio of a slat should not be higher than 5.5 
    #===========================================================================
    slatArea = slatArea - innerArea
    calcArea = 0.
    spanSlat = 0.
     
    while abs(calcArea - slatArea) > 0.5:
        spanSlat += .01
        calcArea = spanSlat * cSlat

    #===========================================================================
    # Determine the number of slats
    # The aspect ratio of a slats should not be higher than 5.5 
    #===========================================================================
    nSlats = spanSlat ** 2. / (slatArea * 5.5)
    log.debug('VAMPzero SLAT: Exporting %s Slats outboard of the engine for an area of %s m2.' % (str(nSlats), str(slatArea)))
    
    #===========================================================================
    # 1 Slat
    #===========================================================================
    if nSlats <= 1.:
        # the inner border eta is located at the Fuselage
        innerEtaTE = etaEngine + 0.025
        innerXsiTE = cSlat / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)

        # the outer border eta is determined from the span of the outer flap
        outerEtaTE = innerEtaTE + spanSlat / span
        outerXsiTE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)

        #Slats extend 50% of their chord lenght
        innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5

        mySlats.append(createSlat('OuterSlat1', parentWingVAMPzero.id, innerEtaTE, innerXsiTE, outerEtaTE, outerXsiTE, innerX=innerX, outerX=outerX))
    
    #===========================================================================
    # 2 Slats
    #===========================================================================
    elif nSlats > 1. and nSlats < 2.:
        # the inner border eta is located at the Fuselage
        innerEtaTE = etaEngine + 0.025
        innerXsiTE = cSlat / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)

        # the outer border eta is determined from the span of the outer flap
        outerEtaTE = innerEtaTE + spanSlat / 2. / span
        outerXsiTE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)

        #Slats extend 50% of their chord lenght
        innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5

        mySlats.append(createSlat('OuterSlat1', parentWingVAMPzero.id, innerEtaTE, innerXsiTE, outerEtaTE, outerXsiTE, innerX=innerX, outerX=outerX))
        
        # new inner is the old outer 
        innerEtaTE = outerEtaTE
        innerXsiTE = outerXsiTE
        # the outer border eta is determined from the full span of the total outer flap
        outerEtaTE = innerEtaTE + spanSlat / span
        outerXsiTE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)

        #Slats extend 50% of their chord lenght
        innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5

        mySlats.append(createSlat('OuterSlat2', parentWingVAMPzero.id, innerEtaTE, innerXsiTE, outerEtaTE, outerXsiTE, innerX=innerX, outerX=outerX))
    else:
    #===========================================================================
    # n Slats
    #===========================================================================
        # the inner border eta is located at the Fuselage
        n = int(ceil(nSlats))
        innerEtaTE = etaEngine + 0.025
        innerXsiTE = cSlat / calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing)
        
        # First Slat
        # the outer border eta is determined from the span of the outer flap
        outerEtaTE = innerEtaTE + spanSlat / n / span
        outerXsiTE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)

        #Slats extend 50% of their chord lenght
        innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5

        mySlats.append(createSlat('OuterSlat1', parentWingVAMPzero.id, innerEtaTE, innerXsiTE, outerEtaTE, outerXsiTE, innerX=innerX, outerX=outerX))
        
        for i in range(2, n):
            # new inner is the old outer 
            innerEtaTE = outerEtaTE
            innerXsiTE = outerXsiTE
            # the outer border eta is determined from the full span of the total outer flap
            outerEtaTE = innerEtaTE + spanSlat / n / span
            outerXsiTE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)
            
            #Slats extend 50% of their chord lenght
            innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
            outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
            
            mySlats.append(createSlat('OuterSlat' + str(i), parentWingVAMPzero.id, innerEtaTE, innerXsiTE, outerEtaTE, outerXsiTE, innerX=innerX, outerX=outerX))

        # Last Slat
        # new inner is the old outer 
        innerEtaTE = outerEtaTE
        innerXsiTE = outerXsiTE
        # the outer border eta is determined from the full span of the total outer flap
        outerEtaTE = innerEtaTE + spanSlat / n / span
        outerXsiTE = cSlat / calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing)

        #Slats extend 50% of their chord lenght
        innerX = innerXsiTE * calcChordLengthAtEta(innerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = outerXsiTE * calcChordLengthAtEta(outerEtaTE, parentWingVAMPzero, cpacsWing) * 0.5
        
        mySlats.append(createSlat('OuterSlat' + str(n), parentWingVAMPzero.id, innerEtaTE, innerXsiTE, outerEtaTE, outerXsiTE, innerX=innerX, outerX=outerX))
    
    #===========================================================================
    # Output to CPACS
    #===========================================================================
    if type(cpacsComponentSegment.get_controlSurfaces()) == NoneType:
        cpacsComponentSegment.set_controlSurfaces(controlSurfacesType())
    if type(cpacsComponentSegment.get_controlSurfaces().get_leadingEdgeDevices()) == NoneType:
        cpacsComponentSegment.get_controlSurfaces().set_leadingEdgeDevices(leadingEdgeDevicesType())
    
    log.debug('VAMPzero SLAT: Exporting %s Slats to CPACS.' % (str(len(mySlats))))
    for slat in mySlats:
        cpacsComponentSegment.get_controlSurfaces().get_leadingEdgeDevices().add_leadingEdgeDevice(slat)
Ejemplo n.º 16
0
def createFlapsSBW(parentWingCPACS, parentWingVAMPzero, myFlap):
    '''
    This is the main export method for the wings flaps

    @todo: it is possible that the inner flap overlaps the kink area
    '''
    cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + parentWingVAMPzero.id + ']'
    cpacsWing = getObjfromXpath(parentWingCPACS, cpacsPath)
    cpacsComponentSegment = cpacsWing.get_componentSegments(
    ).get_componentSegment()[0]
    myFlaps = []

    #===========================================================================
    # Initialization, i.e. fetching values throughout the code
    #===========================================================================
    xsiSparRoot = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[3].get_xsi().valueOf_)
    xsiSparFuselage = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[4].get_xsi().valueOf_)
    xsiSparKink = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[5].get_xsi().valueOf_)
    xsiSparTip = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[6].get_xsi().valueOf_)

    etaSparRoot = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[3].get_eta().valueOf_)
    etaSparFuselage = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[4].get_eta().valueOf_)
    etaSparKink = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[5].get_eta().valueOf_)
    etaSparTip = eval(cpacsComponentSegment.get_structure().get_spars(
    ).get_sparPositions().get_sparPosition()[6].get_eta().valueOf_)

    xsiSpar_interp = scipy.interpolate.interp1d(
        [etaSparRoot, etaSparFuselage, etaSparKink, etaSparTip],
        [xsiSparRoot, xsiSparFuselage, xsiSparKink, xsiSparTip])

    yFus = parentWingVAMPzero.yFuselage.getValue()
    span = parentWingVAMPzero.span.getValue() / 2.
    etaFus = yFus / span
    etaKink = parentWingVAMPzero.etaKink.getValue()
    cRoot = parentWingVAMPzero.cRoot.getValue()
    cKink = calcChordLengthAtEta(etaKink, parentWingVAMPzero, cpacsWing)
    phiLE = parentWingVAMPzero.phiLE.getValue()

    innerFlapArea = myFlap.refAreaInnerFlap.getValue()
    outerFlapArea = myFlap.refAreaOuterFlap.getValue()

    #===========================================================================
    # OuterFlap
    #===========================================================================
    sparOffset = 0.08

    # maxX is the maximum extension of the flap
    maxX = cRoot * (1. - (xsiSparRoot + sparOffset)) / 2.
    newOuterFlapArea = innerFlapArea + outerFlapArea
    cRootOuterFlap = cRoot * (1. - (xsiSparRoot + sparOffset))

    #===========================================================================
    # Determine the total flap span by iteration
    #===========================================================================
    calcArea = 0.
    spanOuterFlap = 0.
    absSparOffset = sparOffset * cKink

    # Obtain the maxEtaValue. This is forwarded from the ailerons export routine.
    maxEta = myFlap.maxEta.getValue() - 0.02

    # the tip root length is a function of the span (as the xsi location of the spar changes)
    while abs(calcArea - newOuterFlapArea) > 0.1:
        spanOuterFlap += .01
        cTipOuterFlap = calcChordLengthAtEta(
            etaFus + spanOuterFlap / span, parentWingVAMPzero, cpacsWing
        ) * (1 - xsiSpar_interp(etaFus + spanOuterFlap / span)) - absSparOffset
        oldcalcArea = calcArea
        calcArea = spanOuterFlap * (cRootOuterFlap + cTipOuterFlap) / 2.

        if calcArea < oldcalcArea:
            log.warning(
                'VAMPzero FLAP: Outer Flap Area can not be established decreasing spar offset by 2% chord!'
            )
            sparOffset = sparOffset - 0.02
            calcArea = 0.
            spanOuterFlap = 0.
            absSparOffset = sparOffset * cKink
            break

        if spanOuterFlap / span + etaFus > maxEta:
            log.warning(
                'VAMPzero FLAP: Outer Flap overlaps with the aileron decreasing spar offset by 2% chord!'
            )
            sparOffset = sparOffset - 0.02
            calcArea = 0.
            spanOuterFlap = 0.
            absSparOffset = sparOffset * cRoot
            break

    while abs(calcArea - newOuterFlapArea) > 0.1:
        spanOuterFlap += .01
        cTipOuterFlap = calcChordLengthAtEta(
            etaKink + spanOuterFlap / span, parentWingVAMPzero, cpacsWing) * (
                1 -
                xsiSpar_interp(etaKink + spanOuterFlap / span)) - absSparOffset
        oldcalcArea = calcArea
        calcArea = spanOuterFlap * (cRootOuterFlap + cTipOuterFlap) / 2.

        if calcArea < oldcalcArea:
            log.warning(
                'VAMPzero FLAP: Outer Flap Area can not be established! Continuing with outerArea = %s'
                % str(calcArea))
            newOuterFlapArea = calcArea
            break

        if spanOuterFlap / span + etaFus > maxEta:
            log.warning(
                'VAMPzero FLAP: Outer Flap overlaps with the aileron! Continuing with outerArea = %s'
                % str(calcArea))
            newOuterFlapArea = calcArea
            break

    #===========================================================================
    # Determine the number of flaps
    # The aspect ratio of a flap should not be higher than 6.
    #===========================================================================
    nOuterFlaps = spanOuterFlap**2. / (newOuterFlapArea * 6.)
    log.debug(
        'VAMPzero FLAP: Exporting %s Flaps outboard of the engine for an area of %s m2.'
        % (str(nOuterFlaps), str(newOuterFlapArea)))

    #===========================================================================
    # 1 Flap
    #===========================================================================
    if nOuterFlaps <= 1.:
        # the inner border eta is located at the kink
        innerEtaLE = etaFus + 0.05
        innerXsiLE = xsiSparRoot + sparOffset
        # the outer border eta is determined from the span of the outer flap
        outerEtaLE = etaFus + 0.05 + spanOuterFlap / span
        outerXsiLE = 1 - (cTipOuterFlap / calcChordLengthAtEta(
            outerEtaLE, parentWingVAMPzero, cpacsWing))

        #Fowler Motion is restricted to 75% of the flap depth
        innerX = (1. - innerXsiLE) * calcChordLengthAtEta(
            innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = (1. - outerXsiLE) * calcChordLengthAtEta(
            outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        myFlaps.append(
            createFlap('outerFlap1',
                       parentWingVAMPzero.id,
                       innerEtaLE,
                       innerXsiLE,
                       outerEtaLE,
                       outerXsiLE,
                       maxX,
                       appendInnerCruiseRoller=True,
                       type='flap',
                       innerX=innerX,
                       outerX=outerX))

    #===========================================================================
    # 2 Flaps
    #===========================================================================
    elif nOuterFlaps > 1. and nOuterFlaps <= 2.:
        # the inner border eta is located at the kink
        innerEtaLE = etaFus + 0.05
        innerXsiLE = xsiSparKink + sparOffset
        # the outer border eta is determined from the half span of the total outer flap
        outerEtaLE = etaFus + 0.05 + spanOuterFlap / (2 * span)
        outerXsiLE = xsiSpar_interp(
            outerEtaLE) + absSparOffset / calcChordLengthAtEta(
                outerEtaLE, parentWingVAMPzero, cpacsWing)
        #Fowler Motion is restricted to 75% of the flap depth
        innerX = (1. - innerXsiLE) * calcChordLengthAtEta(
            innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = (1. - outerXsiLE) * calcChordLengthAtEta(
            outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        myFlaps.append(
            createFlap('outerFlap1',
                       parentWingVAMPzero.id,
                       innerEtaLE,
                       innerXsiLE,
                       outerEtaLE,
                       outerXsiLE,
                       maxX,
                       type='flap',
                       innerX=innerX,
                       outerX=outerX))

        # new inner is the old outer
        innerEtaLE = outerEtaLE
        innerXsiLE = outerXsiLE
        # the outer border eta is determined from the full span of the total outer flap
        outerEtaLE = etaFus + 0.05 + spanOuterFlap / span
        outerXsiLE = 1 - (cTipOuterFlap / calcChordLengthAtEta(
            outerEtaLE, parentWingVAMPzero, cpacsWing))

        #Fowler Motion is restricted to 75% of the flap depth
        innerX = (1. - innerXsiLE) * calcChordLengthAtEta(
            innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = (1. - outerXsiLE) * calcChordLengthAtEta(
            outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        myFlaps.append(
            createFlap('outerFlap2',
                       parentWingVAMPzero.id,
                       innerEtaLE,
                       innerXsiLE,
                       outerEtaLE,
                       outerXsiLE,
                       maxX,
                       appendInnerCruiseRoller=True,
                       type='flap',
                       innerX=innerX,
                       outerX=outerX))

    #===========================================================================
    # n Flaps
    #===========================================================================
    elif nOuterFlaps > 2.:
        n = int(ceil(nOuterFlaps))
        # First Flap
        # the inner border eta is located at the kink
        innerEtaLE = etaFus + 0.05
        innerXsiLE = xsiSparKink + sparOffset
        # the outer border eta is determined from the half span of the total outer flap
        outerEtaLE = etaFus + 0.05 + spanOuterFlap / (n * span)
        outerXsiLE = xsiSpar_interp(
            outerEtaLE) + absSparOffset / calcChordLengthAtEta(
                outerEtaLE, parentWingVAMPzero, cpacsWing)

        #Fowler Motion is restricted to 75% of the flap depth
        innerX = (1. - innerXsiLE) * calcChordLengthAtEta(
            innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = (1. - outerXsiLE) * calcChordLengthAtEta(
            outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        myFlaps.append(
            createFlap('outerFlap1',
                       parentWingVAMPzero.id,
                       innerEtaLE,
                       innerXsiLE,
                       outerEtaLE,
                       outerXsiLE,
                       maxX,
                       type='flap',
                       innerX=innerX,
                       outerX=outerX))

        for i in range(2, n):
            # nth Flap
            # new inner is the old outer
            innerEtaLE = outerEtaLE
            innerXsiLE = outerXsiLE
            # the outer border eta is determined from the full span of the total outer flap
            outerEtaLE = innerEtaLE + spanOuterFlap / n / span
            outerXsiLE = xsiSpar_interp(
                outerEtaLE) + absSparOffset / calcChordLengthAtEta(
                    outerEtaLE, parentWingVAMPzero, cpacsWing)

            #Fowler Motion is restricted to 75% of the flap depth
            innerX = (1. - innerXsiLE) * calcChordLengthAtEta(
                innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
            outerX = (1. - outerXsiLE) * calcChordLengthAtEta(
                outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
            myFlaps.append(
                createFlap('outerFlap' + str(i),
                           parentWingVAMPzero.id,
                           innerEtaLE,
                           innerXsiLE,
                           outerEtaLE,
                           outerXsiLE,
                           maxX,
                           appendInnerCruiseRoller=True,
                           type='flap',
                           innerX=innerX,
                           outerX=outerX))

        # Last Flap
        # new inner is the old outer
        innerEtaLE = outerEtaLE
        innerXsiLE = outerXsiLE
        # the outer border eta is determined from the full span of the total outer flap
        outerEtaLE = etaFus + 0.05 + spanOuterFlap / span
        outerXsiLE = 1 - (cTipOuterFlap / calcChordLengthAtEta(
            outerEtaLE, parentWingVAMPzero, cpacsWing))

        #Fowler Motion is restricted to 75% of the flap depth
        innerX = (1. - innerXsiLE) * calcChordLengthAtEta(
            innerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        outerX = (1. - outerXsiLE) * calcChordLengthAtEta(
            outerEtaLE, parentWingVAMPzero, cpacsWing) * 0.5
        myFlaps.append(
            createFlap('outerFlap' + str(n),
                       parentWingVAMPzero.id,
                       innerEtaLE,
                       innerXsiLE,
                       outerEtaLE,
                       outerXsiLE,
                       maxX,
                       appendInnerCruiseRoller=True,
                       type='flap',
                       innerX=innerX,
                       outerX=outerX))

    #===============================================================================
    # Output to Spoiler
    # as the spoiler is relying on data of the flaps some basic information is written
    # back to the the VAMPzero components
    #===============================================================================
    parentWingVAMPzero.spoiler.outerEta = parameter(
        parent=parentWingVAMPzero.spoiler,
        value=outerEtaLE,
        unit='',
        status='calc',
        doc=
        'The outermost eta coordinate of all flaps. This overlaps with the outer eta coordinate of the spoiler'
    )
    spoilerChord = maxX
    parentWingVAMPzero.spoiler.chord = parameter(
        spoilerChord,
        'm',
        'calc',
        'The absolute chord of the spoiler: 5% of the kink chord length + 50% of the innerFlap Chord length',
        parent=parentWingVAMPzero.spoiler)

    #===========================================================================
    # Output to CPACS
    #===========================================================================
    if type(cpacsComponentSegment.get_controlSurfaces()) == NoneType:
        cpacsComponentSegment.set_controlSurfaces(controlSurfacesType())
    if type(cpacsComponentSegment.get_controlSurfaces().
            get_trailingEdgeDevices()) == NoneType:
        cpacsComponentSegment.get_controlSurfaces().set_trailingEdgeDevices(
            trailingEdgeDevicesType())

    log.debug('VAMPzero SLAT: Exporting %s Flaps to CPACS.' %
              (str(len(myFlaps))))
    for flap in myFlaps:
        cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices(
        ).add_trailingEdgeDevice(flap)
Ejemplo n.º 17
0
def createRudder(parentVtpCPACS, parentVtpVAMPzero, myRudder):
    '''
    This is the main export method for the wings aileron
    '''
    cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + parentVtpVAMPzero.id + ']'
    cpacsVtp = getObjfromXpath(parentVtpCPACS, cpacsPath)
    cpacsComponentSegment = cpacsVtp.get_componentSegments(
    ).get_componentSegment()[0]

    #===========================================================================
    # Header
    #===========================================================================
    myName = stringBaseType(None, None, None, 'rudder')
    myDescription = stringBaseType(None, None, None, 'rudder from VAMPzero')
    myParentUID = stringUIDBaseType(None, None, 'True', None, 'vtp_Cseg')

    #===========================================================================
    # Outer Shape
    # With the rudder this is pretty simple as it is supposed to cover
    # the same span as the VTP
    #===========================================================================
    # the inner border eta is determined from the rooYLocation of the Rudder and the vtp span
    vtpSpan = parentVtpVAMPzero.span.getValue() / 2.
    innerEtaLE = 0.
    outerEtaLE = 1.

    innerXsiLE = myRudder.cRoot.getValue() / parentVtpVAMPzero.cRoot.getValue()
    outerXsiLE = myRudder.cTip.getValue() / parentVtpVAMPzero.cTip.getValue()

    # start writing back
    myleadingEdgeShape = leadingEdgeShapeType(
        relHeightLE=doubleBaseType(valueOf_=str(0.5)),
        xsiUpperSkin=doubleBaseType(valueOf_=str(0.85)),
        xsiLowerSkin=doubleBaseType(valueOf_=str(0.85)))
    innerBorder = controlSurfaceBorderTrailingEdgeType(
        etaLE=doubleBaseType(valueOf_=str(innerEtaLE)),
        xsiLE=doubleBaseType(valueOf_=str(innerXsiLE)),
        leadingEdgeShape=myleadingEdgeShape)
    outerBorder = controlSurfaceBorderTrailingEdgeType(
        etaLE=doubleBaseType(valueOf_=str(outerEtaLE)),
        xsiLE=doubleBaseType(valueOf_=str(outerXsiLE)),
        leadingEdgeShape=myleadingEdgeShape)

    myOuterShape = controlSurfaceOuterShapeTrailingEdgeType(
        innerBorder=innerBorder, outerBorder=outerBorder)

    cpacsRudder = trailingEdgeDeviceType(uID='rudderUID',
                                         name=myName,
                                         description=myDescription,
                                         parentUID=myParentUID,
                                         outerShape=myOuterShape)

    createPath(cpacsRudder, 'rudder')

    if type(cpacsComponentSegment.get_controlSurfaces()) == NoneType:
        cpacsComponentSegment.set_controlSurfaces(controlSurfacesType())
    if type(cpacsComponentSegment.get_controlSurfaces().
            get_trailingEdgeDevices()) == NoneType:
        cpacsComponentSegment.get_controlSurfaces().set_trailingEdgeDevices(
            trailingEdgeDevicesType())

    cpacsComponentSegment.get_controlSurfaces().get_trailingEdgeDevices(
    ).add_trailingEdgeDevice(cpacsRudder)