def createComponentSegment(parent, parentUID, fromElement='_Sec1_Elem1'): ''' Used for generation of componentSegments within a wing create numOfComponentSegs in a wing @param parent: wingType object, Sections-object will be added here @param parentUID: UID of parent object [string] ''' #=========================================================================== # Create Component Segement #=========================================================================== myUID = parentUID + '_Cseg' myName = stringBaseType(valueOf_= parentUID + '_CSeg') myDescr = stringBaseType(valueOf_= parentUID + '_CSeg') myFromElem = stringBaseType(valueOf_=parentUID + fromElement) index = str(len(parent.get_sections().get_section())) myToElem = stringBaseType(valueOf_=parentUID + '_Sec' + index + '_Elem1') myStructure = wingComponentSegmentStructureType() #=========================================================================== # Back to CPACS #=========================================================================== myComponentSegments = componentSegmentsType() myComponentSegment = componentSegmentType(uID=myUID, name=myName, description=myDescr, fromElementUID=myFromElem, toElementUID=myToElem, structure=myStructure) myComponentSegments.add_componentSegment(myComponentSegment) parent.set_componentSegments(myComponentSegments)
def createSpoiler(name, parentUID, innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE): #=========================================================================== # Header #=========================================================================== log.debug('VAMPzero SPOILER: Creating Spoiler: %s' % (str(name))) log.debug('VAMPzero SPOILER: innerEtaLE: %s' % str(innerEtaLE)) log.debug('VAMPzero SPOILER: innerEtaTE: %s' % str(innerEtaTE)) log.debug('VAMPzero SPOILER: innerXsiLE: %s' % str(innerXsiLE)) log.debug('VAMPzero SPOILER: innerXsiTE: %s' % str(innerXsiTE)) log.debug('VAMPzero SPOILER: outerEtaLE: %s' % str(outerEtaLE)) log.debug('VAMPzero SPOILER: outerEtaTE: %s' % str(outerEtaTE)) log.debug('VAMPzero SPOILER: outerXsiLE: %s' % str(outerXsiLE)) log.debug('VAMPzero SPOILER: outerXsiTE: %s' % str(outerXsiTE)) myName = stringBaseType(None, None, None, name) myDescription = stringBaseType(None, None, None, 'spoiler from VAMPzero') myParentUID = stringUIDBaseType(None, None, 'True', None, parentUID) myleadingEdgeShape = leadingEdgeShapeType(relHeightLE=doubleBaseType(valueOf_=str(0.75))) innerBorder = controlSurfaceBorderSpoilerType(etaLE=doubleBaseType(valueOf_=str(innerEtaLE)), etaTE=doubleBaseType(valueOf_=str(innerEtaTE)), xsiLE=doubleBaseType(valueOf_=str(innerXsiLE)), xsiTE=doubleBaseType(valueOf_=str(innerXsiTE)), leadingEdgeShape=myleadingEdgeShape) outerBorder = controlSurfaceBorderSpoilerType(etaLE=doubleBaseType(valueOf_=str(outerEtaLE)), etaTE=doubleBaseType(valueOf_=str(outerEtaTE)), xsiLE=doubleBaseType(valueOf_=str(outerXsiLE)), xsiTE=doubleBaseType(valueOf_=str(outerXsiTE)), leadingEdgeShape=myleadingEdgeShape) myOuterShape = controlSurfaceOuterShapeSpoilerType(innerBorder=innerBorder, outerBorder=outerBorder) myStructure = wingComponentSegmentStructureType() mySpoiler = spoilerType(uID=name + 'UID', name=myName, description=myDescription, parentUID=myParentUID, outerShape=myOuterShape, structure=myStructure) createSpoilerStructure(mySpoiler) return mySpoiler
def createComponentSegment(parent, parentUID, fromElement='_Sec1_Elem1'): ''' Used for generation of componentSegments within a wing create numOfComponentSegs in a wing @param parent: wingType object, Sections-object will be added here @param parentUID: UID of parent object [string] ''' #=========================================================================== # Create Component Segement #=========================================================================== myUID = parentUID + '_Cseg' myName = stringBaseType(None, None, None, parentUID + '_CSeg') myDescr = stringBaseType(None, None, None, parentUID + '_CSeg') myFromElem = stringBaseType(None, None, None, parentUID + fromElement) index = str(len(parent.get_sections().get_section())) myToElem = stringBaseType(None, None, None, parentUID + '_Sec' + index + '_Elem1') myStructure = wingComponentSegmentStructureType() #=========================================================================== # Back to CPACS #=========================================================================== myComponentSegments = componentSegmentsType() myComponentSegment = componentSegmentType(None, None, None, myUID, myName, myDescr, myFromElem, myToElem, myStructure, None, None) myComponentSegments.add_componentSegment(myComponentSegment) parent.set_componentSegments(myComponentSegments)
def createFlap(name, parentUID, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, maxX, appendInnerCruiseRoller=False, type='flap', innerX=0., outerX=0.): log.debug('VAMPzero FLAP: Creating Flap: %s' % (str(name))) log.debug('VAMPzero FLAP: innerEtaLE: %s' % str(innerEtaLE)) log.debug('VAMPzero FLAP: outerEtaLE: %s' % str(outerEtaLE)) log.debug('VAMPzero FLAP: innerXsiLE: %s' % str(innerXsiLE)) log.debug('VAMPzero FLAP: outerXsiLE: %s' % str(outerXsiLE)) myName = stringBaseType(None, None, None, name) myDescription = stringBaseType(None, None, None, 'innerFlap from VAMPzero') myParentUID = stringUIDBaseType(None, None, 'True', None, parentUID) myleadingEdgeShape = leadingEdgeShapeType( relHeightLE=doubleBaseType(valueOf_=str(0.2)), xsiUpperSkin=doubleBaseType(valueOf_=str(0.5)), xsiLowerSkin=doubleBaseType(valueOf_=str(0.95))) 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) myStructure = wingComponentSegmentStructureType() myFlap = trailingEdgeDeviceType(uID=name + 'UID', name=myName, description=myDescription, parentUID=myParentUID, outerShape=myOuterShape, structure=myStructure) createFlapStructure(myFlap, maxX, innerXsiLE, outerXsiLE, appendInnerCruiseRoller, type=type, innerX=innerX, outerX=outerX) return myFlap
def createSpoiler(name, parentUID, innerEtaLE, innerEtaTE, innerXsiLE, innerXsiTE, outerEtaLE, outerEtaTE, outerXsiLE, outerXsiTE): #=========================================================================== # Header #=========================================================================== log.debug('VAMPzero SPOILER: Creating Spoiler: %s' % (str(name))) log.debug('VAMPzero SPOILER: innerEtaLE: %s' % str(innerEtaLE)) log.debug('VAMPzero SPOILER: innerEtaTE: %s' % str(innerEtaTE)) log.debug('VAMPzero SPOILER: innerXsiLE: %s' % str(innerXsiLE)) log.debug('VAMPzero SPOILER: innerXsiTE: %s' % str(innerXsiTE)) log.debug('VAMPzero SPOILER: outerEtaLE: %s' % str(outerEtaLE)) log.debug('VAMPzero SPOILER: outerEtaTE: %s' % str(outerEtaTE)) log.debug('VAMPzero SPOILER: outerXsiLE: %s' % str(outerXsiLE)) log.debug('VAMPzero SPOILER: outerXsiTE: %s' % str(outerXsiTE)) myName = stringBaseType(None, None, None, name) myDescription = stringBaseType(None, None, None, 'spoiler from VAMPzero') myParentUID = stringUIDBaseType(None, None, 'True', None, parentUID) myleadingEdgeShape = leadingEdgeShapeType(relHeightLE=doubleBaseType( valueOf_=str(0.75))) innerBorder = controlSurfaceBorderSpoilerType( etaLE=doubleBaseType(valueOf_=str(innerEtaLE)), etaTE=doubleBaseType(valueOf_=str(innerEtaTE)), xsiLE=doubleBaseType(valueOf_=str(innerXsiLE)), xsiTE=doubleBaseType(valueOf_=str(innerXsiTE)), leadingEdgeShape=myleadingEdgeShape) outerBorder = controlSurfaceBorderSpoilerType( etaLE=doubleBaseType(valueOf_=str(outerEtaLE)), etaTE=doubleBaseType(valueOf_=str(outerEtaTE)), xsiLE=doubleBaseType(valueOf_=str(outerXsiLE)), xsiTE=doubleBaseType(valueOf_=str(outerXsiTE)), leadingEdgeShape=myleadingEdgeShape) myOuterShape = controlSurfaceOuterShapeSpoilerType(innerBorder=innerBorder, outerBorder=outerBorder) myStructure = wingComponentSegmentStructureType() mySpoiler = spoilerType(uID=name + 'UID', name=myName, description=myDescription, parentUID=myParentUID, outerShape=myOuterShape, structure=myStructure) createSpoilerStructure(mySpoiler) return mySpoiler
def createFlap(name, parentUID, innerEtaLE, innerXsiLE, outerEtaLE, outerXsiLE, maxX, appendInnerCruiseRoller=False, type='flap', innerX=0., outerX=0.): log.debug('VAMPzero FLAP: Creating Flap: %s' % (str(name))) log.debug('VAMPzero FLAP: innerEtaLE: %s' % str(innerEtaLE)) log.debug('VAMPzero FLAP: outerEtaLE: %s' % str(outerEtaLE)) log.debug('VAMPzero FLAP: innerXsiLE: %s' % str(innerXsiLE)) log.debug('VAMPzero FLAP: outerXsiLE: %s' % str(outerXsiLE)) myName = stringBaseType(None, None, None, name) myDescription = stringBaseType(None, None, None, 'innerFlap from VAMPzero') myParentUID = stringUIDBaseType(None, None, 'True', None, parentUID) myleadingEdgeShape = leadingEdgeShapeType(relHeightLE=doubleBaseType(valueOf_=str(0.2)), xsiUpperSkin=doubleBaseType(valueOf_=str(0.5)), xsiLowerSkin=doubleBaseType(valueOf_=str(0.95))) 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) myStructure = wingComponentSegmentStructureType() myFlap = trailingEdgeDeviceType(uID=name + 'UID', name=myName, description=myDescription, parentUID=myParentUID, outerShape=myOuterShape, structure=myStructure) createFlapStructure(myFlap, maxX, innerXsiLE, outerXsiLE, appendInnerCruiseRoller, type=type, innerX=innerX, outerX=outerX) return myFlap
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)
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)