def cpacsExport(self, CPACSObj): ''' Export routine for the engine ''' cpacsPath = '/cpacs/vehicles/aircraft/model/engines/engine' myEngine = getObjfromXpath(CPACSObj, cpacsPath) myEngine.set_uID('engine') myEngine.set_symmetry('x-z-plane') myEngine.set_parentUID(stringUIDBaseType(valueOf_="enginePylon")) x = doubleBaseType(valueOf_=str(self.xEngine.getValue())) y = doubleBaseType(valueOf_=str(self.yEngine.getValue())) z = doubleBaseType(valueOf_=str(self.zEngine.getValue())) myTranslation = pointAbsRelType(refType="absGlobal", x=x, y=y, z=z) myTransformation = transformationType(translation=myTranslation) myEngine.set_transformation(myTransformation) # Mass Export Engine Pylon mass = doubleBaseType(valueOf_=str(self.mEngine.getValue())) massIX = doubleBaseType(valueOf_=str(self.massIX.getValue())) massIY = doubleBaseType(valueOf_=str(self.massIY.getValue())) massIZ = doubleBaseType(valueOf_=str(self.massIZ.getValue())) massInertia = massInertiaType(Jxx=massIX, Jyy=massIY, Jzz=massIZ) cpacsPath = '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mPowerUnits' mEngines = getObjfromXpath(CPACSObj, cpacsPath) massDescription = genericMassType(uID='engine_mass', mass=mass, parentUID=stringUIDBaseType(valueOf_="engine"), massInertia=massInertia) mEngines.set_massDescription(massDescription) #call overall export method super(engine, self).cpacsExport(CPACSObj)
def createWingAirfoil(CPACSObj): # get airfoil holding object cpacsPath = '/cpacs/vehicles/profiles/wingAirfoils/wingAirfoil[NACA0009]' myAirfoil = getObjfromXpath(CPACSObj, cpacsPath) pointList = myAirfoil.get_pointList() if pointList is None: # print "Airfoil 'NACA0009' not found -> will be created." # create pointList pointList = pointListXYZVectorType() xVector = [] yVector = [] zVector = [] for x, y in NACA0009[::-1]: xVector.append(str(x)) yVector.append(str(0.0)) zVector.append(str(y)) x = stringVectorBaseType(mapType='vector',valueOf_=';'.join(xVector)) y = stringVectorBaseType(mapType='vector',valueOf_=';'.join(yVector)) z = stringVectorBaseType(mapType='vector',valueOf_=';'.join(zVector)) pointList.set_x(x) pointList.set_y(y) pointList.set_z(z) myAirfoil.set_pointList(pointList) myAirfoil.set_name(stringBaseType(valueOf_="NACA0009 Airfoil")) myAirfoil.set_description(stringBaseType(valueOf_="Profile generated automatically by VAMPzero cpacs-export")) # get airfoil holding object cpacsPath = '/cpacs/vehicles/profiles/wingAirfoils/wingAirfoil[NACA653218]' myAirfoil = getObjfromXpath(CPACSObj, cpacsPath) pointList = myAirfoil.get_pointList() if pointList is None: # print "Airfoil 'NACA0000' not found -> will be created." # create pointList pointList = pointListXYZVectorType() xVector = [] yVector = [] zVector = [] for x, y in NACA653218[::-1]: xVector.append(str(x)) yVector.append(str(0.0)) zVector.append(str(y)) x = stringVectorBaseType(mapType='vector',valueOf_=';'.join(xVector)) y = stringVectorBaseType(mapType='vector',valueOf_=';'.join(yVector)) z = stringVectorBaseType(mapType='vector',valueOf_=';'.join(zVector)) pointList.set_x(x) pointList.set_y(y) pointList.set_z(z) myAirfoil.set_pointList(pointList) myAirfoil.set_name(stringBaseType(valueOf_="NACA653218 Airfoil")) myAirfoil.set_description(stringBaseType(valueOf_="Profile generated automatically by VAMPzero cpacs-export"))
def createFuselageProfile(CPACSObj, profile='Circle'): ''' @author: Jonas Jepsen ''' # get airfoil holding object cpacsPath = '/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[%s]' % profile myProfile = getObjfromXpath(CPACSObj, cpacsPath) pointList = myProfile.get_pointList() if pointList is None: #print "Airfoil 'Circle' not found -> will be created." xVector, yVector, zVector = createCircleList() # create pointList pointList = pointListXYZVectorType() x = stringVectorBaseType(None, None, None, 'vector', ';'.join(xVector)) y = stringVectorBaseType(None, None, None, 'vector', ';'.join(yVector)) z = stringVectorBaseType(None, None, None, 'vector', ';'.join(zVector)) pointList.set_x(x) pointList.set_y(y) pointList.set_z(z) myProfile.set_pointList(pointList) myProfile.set_name(stringBaseType(None, None, None, "Circle Profile")) myProfile.set_description( stringBaseType( None, None, None, "Profile generated automatically by VAMPzero cpacs-export"))
def createHTP(CPACSObj, id, xRoot, zRoot, tcRoot, tcTip, cRoot, cTip, span, phiLE, dihedral, LoD=0, location=True): if LoD == WING_LOD.NONE: return # just for now cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + id + ']' # the next line is the one to use later on # cpacsPath = '/cpacs/vehicles/aircraft/model[model]/wings/wing[' + self.id + ']' # get the wing object from given cpacs path myWing = getObjfromXpath(CPACSObj, cpacsPath) myWing.set_name(stringBaseType(valueOf_='htp')) strUID = createHeader(myWing, id) myWing.set_symmetry('x-z-plane') if location: myWing.set_parentUID(stringUIDBaseType(isLink=True, valueOf_='fuselage')) createTransformation(myWing, 'absGlobal', xRoot, 0., zRoot) else: myWing.set_parentUID(stringUIDBaseType(isLink=True, valueOf_='vtp')) createTransformation(myWing, 'absGlobal', xRoot, 0., zRoot) # call corresponding wing creation method if LoD == WING_LOD.SINGLE: createTrapezoidWing(myWing, id, tcTip, tcRoot, cTip, cRoot, span, phiLE, dihedral, 0., strUID) if not location: createWingWingAttachment(myWing.get_componentSegments().get_componentSegment()[0], strUID, targetUID='vtp_Cseg', typeOfSeg='ttail')
def createFuselageProfile(CPACSObj, profile='Circle' ): ''' @author: Jonas Jepsen ''' # get airfoil holding object cpacsPath = '/cpacs/vehicles/profiles/fuselageProfiles/fuselageProfile[%s]'% profile myProfile = getObjfromXpath(CPACSObj,cpacsPath) pointList = myProfile.get_pointList() if pointList is None: #print "Airfoil 'Circle' not found -> will be created." xVector, yVector, zVector = createCircleList() # create pointList pointList = pointListXYZVectorType() x = stringVectorBaseType(mapType='vector',valueOf_=';'.join(xVector)) y = stringVectorBaseType(mapType='vector',valueOf_=';'.join(yVector)) z = stringVectorBaseType(mapType='vector',valueOf_=';'.join(zVector)) pointList.set_x(x) pointList.set_y(y) pointList.set_z(z) myProfile.set_pointList(pointList) myProfile.set_name(stringBaseType(valueOf_="Circle Profile")) myProfile.set_description(stringBaseType(valueOf_="Profile generated automatically by VAMPzero cpacs-export" ))
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)
def setUIDs(self): ################################################################################################### ##Set UIDS ################################################################################################### CPACSObj = cpacsLib.parse(self.cpacsOut) #UID for aircraft model cpacsPath = '/cpacs/vehicles/aircraft/model' myCPACSAircraft = exportLib.getObjfromXpath(CPACSObj, cpacsPath) myCPACSAircraft.set_uID(self.aircraft.modelUID.getValue()) #UID for engine cpacsPath = '/cpacs/vehicles/aircraft/model/engines/engine' myCPACSEngine = exportLib.getObjfromXpath(CPACSObj, cpacsPath) myCPACSEngine.set_uID(self.aircraft.engine.UID.getValue()) #save and close outfile = open(self.cpacsOut, 'w') CPACSObj.export(outfile, 0) outfile.close()
def setUIDs(self): ################################################################################################### ##Set UIDS ################################################################################################### CPACSObj = cpacsLib.parse(self.cpacsOut) #UID for aircraft model cpacsPath = '/cpacs/vehicles/aircraft/model' myCPACSAircraft = exportLib.getObjfromXpath(CPACSObj,cpacsPath) myCPACSAircraft.set_uID(self.aircraft.modelUID.getValue()) #UID for engine cpacsPath = '/cpacs/vehicles/aircraft/model/engines/engine' myCPACSEngine = exportLib.getObjfromXpath(CPACSObj,cpacsPath) myCPACSEngine.set_uID(self.aircraft.engine.UID.getValue()) #save and close outfile = open(self.cpacsOut,'w') CPACSObj.export(outfile,0) outfile.close()
def createFuselage(CPACSObj, id, dfus, lnose, lcabin, ltail, LoD=0): # just for now if LoD==FUSE_LOD.NONE: return cpacsPath = '/cpacs/vehicles/aircraft/model/fuselages/fuselage[' + id + ']' # the next line is the one to use later on #cpacsPath = '/cpacs/vehicles/aircraft/model[model]/fuselages/fuselage[' + self.id + ']' # gets a list of all wing elements myFuse = getObjfromXpath(CPACSObj,cpacsPath) strUID = myFuse.get_uID() myUID = strUID myName = stringBaseType(valueOf_=id) myDescr = stringBaseType(valueOf_=strUID) myFuse.set_uID(myUID) myFuse.set_name(myName) myFuse.set_description(myDescr) createTransformation(myFuse, 'absGlobal',0.,0.,0.) if LoD==FUSE_LOD.A320: nose = list(NOSE) cabin = list(CABIN) tail = list(TAIL) # remove double values cabin.pop(0) tail.pop(0) # sections will be created, all existing sections will be deleted createFuselageSections(myFuse, nose,cabin,tail, dfus, strUID, strUID, strUID) createFuselagePositionings(myFuse, nose,cabin,tail, lnose,lcabin,ltail, strUID, strUID) createFuselageSegments(myFuse, strUID, len(nose)+len(cabin)+len(tail)-1) elif LoD==FUSE_LOD.ZYL: # sections will be created, all existing sections will be deleted mySections = fuselageSectionsType() #calc fuselage radius #rfus = dfus/2. # make fuselage configuration data [x_rel,z-dist,height/2,width/2]] fuseConf = [0.,0.,0.5,0.5] createFuselageSection(mySections, dfus, fuseConf, 'Circle', strUID+'_Sec1', strUID+'_Sec1', strUID+'_Sec1') createFuselageSection(mySections, dfus, fuseConf, 'Circle', strUID+'_Sec2', strUID+'_Sec2', strUID+'_Sec2') createFuselageSection(mySections, dfus, fuseConf, 'Circle', strUID+'_Sec3', strUID+'_Sec3', strUID+'_Sec3') createFuselageSection(mySections, dfus, fuseConf, 'Circle', strUID+'_Sec4', strUID+'_Sec4', strUID+'_Sec4') myFuse.set_sections(mySections) myPositionings = positioningsType() createPositioning(myPositionings,str(id) + '_Pos1',None, str(id) + '_Sec1',0.,90.,0.,id + '_Pos1') createPositioning(myPositionings,str(id) + '_Pos2',str(id) + '_Sec1',str(id) + '_Sec2',lnose,90.,0,id + '_Pos2') createPositioning(myPositionings,str(id) + '_Pos3',str(id) + '_Sec2',str(id) + '_Sec3',lcabin,90.,0,id + '_Pos3') createPositioning(myPositionings,str(id) + '_Pos4',str(id) + '_Sec3',str(id) + '_Sec4',ltail,90.,0,id + '_Pos4') myFuse.set_positionings(myPositionings) createFuselageSegments(myFuse, strUID, 3)
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)
def setUIDs(self): ################################################################################################### ##Set UIDS ################################################################################################### CPACSObj = cpacsLib.parse(self.cpacsOut) #UID for aircraft model cpacsPath = '/cpacs/vehicles/aircraft/model' myCPACSAircraft = exportLib.getObjfromXpath(CPACSObj,cpacsPath) myCPACSAircraft.set_uID(self.aircraft.modelUID.getValue()) #UID for engine cpacsPath = '/cpacs/vehicles/aircraft/model/engines/engine' myCPACSEngine = exportLib.getObjfromXpath(CPACSObj,cpacsPath) myCPACSEngine.set_uID('model_engine') myCPACSEngine.set_engineUID(cpacsLib.stringUIDBaseType(valueOf_='engine')) myCPACSEngine.set_symmetry('x-z-plane') #save and close outfile = open(self.cpacsOut,'w') CPACSObj.export(outfile,0) outfile.close()
def cpacsExport(self, CPACSObj): ''' This method overwrites the cpacsExport method of parameter. This method will create the certification cases for CPACS ''' def createPointList(nparray): ''' create a point list for each cog location This method is currently without use, as long as there is no update to CPACS 2.2.1 ''' myPointList = pointListType() zero = doubleBaseType(valueOf_='0.') for item in nparray.tolist(): newPoint = pointType(x=doubleBaseType(valueOf_=str(item)),y=zero, z=zero) myPointList.add_point(newPoint) return myPointList def createVectorPointList(nparray): ''' create a point list for each cog location ''' myPointList = pointListType() x = '; '.join(str(x) for x in nparray.tolist()) zeros = np.zeros(nparray.shape) y = '; '.join(str(y) for y in zeros.tolist()) newPoint = pointType(x=doubleBaseType(valueOf_=str(x)),y=doubleBaseType(valueOf_=y), z=doubleBaseType(valueOf_=y)) myPointList.add_point(newPoint) return myPointList cpacsPath = '/cpacs/vehicles/aircraft/model/analyses/weightAndBalance/certificationCases' myCertificationCases = getObjfromXpath(CPACSObj, cpacsPath) # create mass Vector massVector = stringVectorBaseType(valueOf_='; '.join(str(mass) for mass in self.m_TOW_fuel_pay.tolist())) # create forward case, create backward case forwardPoints = createVectorPointList(self.posCoGMIN_fuel_pay0) rearwardPoints = createVectorPointList(self.posCoGMAX_fuel_pay0) forwardCertificationCase = weightAndBalanceCaseType(uID="cc_forwardLocations", coG=forwardPoints, mass=massVector) rearwardCertificationCase = weightAndBalanceCaseType(uID="cc_rearwardLocations", coG=rearwardPoints, mass=massVector) myCertificationCases.add_certificationCase(forwardCertificationCase) myCertificationCases.add_certificationCase(rearwardCertificationCase)
def cpacsExport(self, CPACSObj): ''' Export routine for the pylon ''' # pylon cpacsPath = '/cpacs/vehicles/aircraft/model/enginePylons/enginePylon' myPylon = getObjfromXpath(CPACSObj, cpacsPath) myPylon.set_uID('enginePylon') if self.aircraft.engine.location.getValue(): myPylon.set_parentUID(stringUIDBaseType(valueOf_="wing")) else: myPylon.set_parentUID(stringUIDBaseType(valueOf_="fuselage")) # Mass Export Engine Pylon mass = doubleBaseType(valueOf_=str(self.mPylon.getValue())) cpacsPath = '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mStructure/mPylons' mPylons = getObjfromXpath(CPACSObj, cpacsPath) massDescription = genericMassType(uID='pylon_mass', mass=mass, parentUID=stringUIDBaseType(valueOf_="enginePylon")) mPylons.set_massDescription(massDescription) #call overall export method super(pylon, self).cpacsExport(CPACSObj)
def cpacsExport(self, CPACSObj): ''' Export routine for the main and nose landing gear ''' # Main Gear Export cpacsPath = '/cpacs/vehicles/aircraft/model/landingGear/mainGears/mainGear' myMainGear = getObjfromXpath(CPACSObj, cpacsPath) myMainGear.set_parentUID(stringUIDBaseType(valueOf_="fuselage")) myMainGear.set_uID('mainGear') myMainGear.set_symmetry('x-z-plane') # Mass Export Main Landing Gear mass = doubleBaseType(valueOf_=str(self.mLandingGear.getValue())) cpacsPath = '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mStructure/mLandingGears' myLandingGears = getObjfromXpath(CPACSObj, cpacsPath) massDescription = genericMassType(uID='mainGear_Mass', mass=mass, parentUID=stringUIDBaseType(valueOf_="mainGear")) myRightMainGear = mLandingGearType(massDescription=massDescription) myLandingGears.add_mLandingGear(myRightMainGear) # Nose Gear Export cpacsPath = '/cpacs/vehicles/aircraft/model/landingGear/noseGears/noseGear' myNoseGear = getObjfromXpath(CPACSObj, cpacsPath) myNoseGear.set_parentUID(stringUIDBaseType(valueOf_="fuselage")) myNoseGear.set_uID('noseGear') # Mass Export Nose Landing Gear mass = doubleBaseType(valueOf_=str(self.mNoseGear.getValue())) cpacsPath = '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mStructure/mLandingGears' myLandingGears = getObjfromXpath(CPACSObj, cpacsPath) massDescription = genericMassType(uID='noseGear_mass', mass=mass, parentUID=stringUIDBaseType(valueOf_="noseGear")) myRightMainGear = mLandingGearType(massDescription=massDescription) myLandingGears.add_mLandingGear(myRightMainGear) #call overall export method super(landingGear, self).cpacsExport(CPACSObj)
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)
def cpacsExport(self, CPACSObj): ''' this methods exports self.value to self.cpacsPath in path cpacsPath must be filled path is an optional argument for the output Additionally, all values are parsed into the resultList so that they can be exported later on ''' if self.getCpacsPath() != '': para = getObjfromXpath(CPACSObj, self.getCpacsPath()) # the value has to be string for the cpacslib to work para.set_valueOf_(str(self.getValue())) self.log.debug( "VAMPzero EXPORT: %s = %s exported to %s" % (self.longName, para.get_valueOf_(), self.getCpacsPath())) if type(self.getValue()) == str: parameter.resultList.append(str(self.longName + '=\'' + str(self.getValue()) + '\';\n')) else: parameter.resultList.append(str(self.longName + '=' + str(self.getValue()) + ';\n'))
def createHTP(CPACSObj, id, xRoot, zRoot, tcRoot, tcTip, cRoot, cTip, span, phiLE, dihedral, LoD=0, location=True): if LoD == WING_LOD.NONE: return # just for now cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + id + ']' # the next line is the one to use later on # cpacsPath = '/cpacs/vehicles/aircraft/model[model]/wings/wing[' + self.id + ']' # get the wing object from given cpacs path myWing = getObjfromXpath(CPACSObj, cpacsPath) myWing.set_name(stringBaseType(valueOf_='htp')) strUID = createHeader(myWing, id) myWing.set_symmetry('x-z-plane') if location: myWing.set_parentUID( stringUIDBaseType(isLink=True, valueOf_='fuselage')) createTransformation(myWing, 'absGlobal', xRoot, 0., zRoot) else: myWing.set_parentUID(stringUIDBaseType(isLink=True, valueOf_='vtp')) createTransformation(myWing, 'absGlobal', xRoot, 0., zRoot) # call corresponding wing creation method if LoD == WING_LOD.SINGLE: createTrapezoidWing(myWing, id, tcTip, tcRoot, cTip, cRoot, span, phiLE, dihedral, 0., strUID) if not location: createWingWingAttachment( myWing.get_componentSegments().get_componentSegment()[0], strUID, targetUID='vtp_Cseg', typeOfSeg='ttail')
def createVTP(CPACSObj, id, xRoot, zRoot, tcRoot, tcTip, cRoot, cTip, span, phiLE, LoD=0): if LoD == WING_LOD.NONE: return # just for now cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + id + ']' # the next line is the one to use later on # cpacsPath = '/cpacs/vehicles/aircraft/model[model]/wings/wing[' + self.id + ']' # get the wing object from given cpacs path myWing = getObjfromXpath(CPACSObj, cpacsPath) myWing.set_name(stringBaseType(valueOf_='vtp')) myWing.set_parentUID(stringUIDBaseType(isLink=True, valueOf_='fuselage')) strUID = createHeader(myWing, id) # rotate vertical tail to correct orientation createTransformation(myWing, 'absGlobal', xRoot, 0., zRoot, 1., 1., 1., 90., 0., 0.) # As the vtp is not symmetrical span values must be dubbled for conversion span = span * 2 # call corresponding wing creation method if LoD == WING_LOD.SINGLE: createTrapezoidWing(myWing, id, tcRoot, tcTip, cTip, cRoot, span, phiLE, dihedral=0, twist=0., strUID=strUID)
def cpacsExport(self, CPACSObj): ''' this methods exports self.value to self.cpacsPath in path cpacsPath must be filled path is an optional argument for the output Additionally, all values are parsed into the resultList so that they can be exported later on ''' if self.getCpacsPath() != '': para = getObjfromXpath(CPACSObj, self.getCpacsPath()) # the value has to be string for the cpacslib to work para.set_valueOf_(str(self.getValue())) self.log.debug( "VAMPzero EXPORT: %s = %s exported to %s" % (self.longName, para.get_valueOf_(), self.getCpacsPath())) if type(self.getValue()) == str: parameter.resultList.append( str(self.longName + '=\'' + str(self.getValue()) + '\';\n')) else: parameter.resultList.append( str(self.longName + '=' + str(self.getValue()) + ';\n'))
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)
def createWingAirfoil(CPACSObj): # get airfoil holding object cpacsPath = '/cpacs/vehicles/profiles/wingAirfoils/wingAirfoil[NACA0009]' myAirfoil = getObjfromXpath(CPACSObj, cpacsPath) pointList = myAirfoil.get_pointList() if pointList is None: # print "Airfoil 'NACA0009' not found -> will be created." # create pointList pointList = pointListXYZVectorType() xVector = [] yVector = [] zVector = [] for x, y in NACA0009: xVector.append(str(x)) yVector.append(str(0.0)) zVector.append(str(y)) x = stringVectorBaseType(None, None, None, 'vector', ';'.join(xVector)) y = stringVectorBaseType(None, None, None, 'vector', ';'.join(yVector)) z = stringVectorBaseType(None, None, None, 'vector', ';'.join(zVector)) pointList.set_x(x) pointList.set_y(y) pointList.set_z(z) myAirfoil.set_pointList(pointList) myAirfoil.set_name(stringBaseType(None, None, None, "NACA0009 Airfoil")) myAirfoil.set_description( stringBaseType( None, None, None, "Profile generated automatically by VAMPzero cpacs-export")) # get airfoil holding object cpacsPath = '/cpacs/vehicles/profiles/wingAirfoils/wingAirfoil[NACA653218]' myAirfoil = getObjfromXpath(CPACSObj, cpacsPath) pointList = myAirfoil.get_pointList() if pointList is None: # print "Airfoil 'NACA0000' not found -> will be created." # create pointList pointList = pointListXYZVectorType() xVector = [] yVector = [] zVector = [] for x, y in NACA653218: xVector.append(str(x)) yVector.append(str(0.0)) zVector.append(str(y)) x = stringVectorBaseType(None, None, None, 'vector', ';'.join(xVector)) y = stringVectorBaseType(None, None, None, 'vector', ';'.join(yVector)) z = stringVectorBaseType(None, None, None, 'vector', ';'.join(zVector)) pointList.set_x(x) pointList.set_y(y) pointList.set_z(z) myAirfoil.set_pointList(pointList) myAirfoil.set_name( stringBaseType(None, None, None, "NACA653218 Airfoil")) myAirfoil.set_description( stringBaseType( None, None, None, "Profile generated automatically by VAMPzero cpacs-export"))
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)
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)
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)
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)
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)
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)
def exportVector(CPACSObj, cpacsPath, value): myVector = getObjfromXpath(CPACSObj, cpacsPath) myType = "vector" myVector.set_valueOf_(str(value)) myVector.set_mapType(myType)
def createWing(CPACSObj = None, zeroWing = None, id="1", LoD = 0.): """ This function triggers the different export modes of the wing depending on the desired level of detail. Options include a single trapezoid, double trapezoid, advanced double trapezoid (that includes a rectangular center fuselage section) and a strut-braced wing. Please note, these are the internal guts of VAMPzero's CPACS export. A lot of the code here is experimental and furthermore highly chaotic. In case of emergency contact Daniel or Jonas. :param CPACSObj: The overall CPACS object of the export :param zeroWing: The instance of the wing. :param id: The id of the wing, mostly sth. like wing :param LoD: The level of detail of the desired input. :return: CPACSObj including a new wing """ if LoD == WING_LOD.NONE: return # just for now cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + id + ']' # the next line is the one to use later on # cpacsPath = '/cpacs/vehicles/aircraft/model[model]/wings/wing[' + self.id + ']' # get the wing object from given cpacs path cpacsWing = getObjfromXpath(CPACSObj, cpacsPath) strUID = createHeader(cpacsWing, id) cpacsWing.set_symmetry('x-z-plane') cpacsWing.set_name(stringBaseType(valueOf_='wing')) cpacsWing.set_parentUID(stringUIDBaseType(isLink=True, valueOf_='fuselage')) xRoot = zeroWing.xRoot.getValue() zRoot = zeroWing.zRoot.getValue() cRoot = zeroWing.cRoot.getValue() cTip = zeroWing.cTip.getValue() span = zeroWing.span.getValue() dfus = zeroWing.aircraft.fuselage.dfus.getValue() phiLE = zeroWing.phiLE.getValue() dihedral = zeroWing.dihedral.getValue() twist = zeroWing.twist.getValue() Sref = zeroWing.refArea.getValue() xMAC25 = zeroWing.xMAC25.getValue() tcRoot = zeroWing.airfoilr.tc.getValue() tcTip = zeroWing.airfoilt.tc.getValue() try: etakf = zeroWing.etaKink.getValue() yFus = zeroWing.yFuselage.getValue() etaEng = zeroWing.etaEngine.getValue() etaFus = yFus/span*2. except AttributeError: pass #As not all components that call this method have a kink try: yRoot = zeroWing.yRoot.getValue() except AttributeError: pass #As not all components that call this method have a kink createTransformation(cpacsWing, 'absGlobal', xRoot, 0., zRoot) # call corresponding wing creation method if LoD == WING_LOD.SINGLE: createTrapezoidWing(cpacsWing, id, tcRoot, tcTip, cTip, cRoot, span, phiLE, dihedral, twist, strUID) elif LoD == WING_LOD.DOUBLE: createDoubleTrapezoidWing(cpacsWing, id, cTip, cRoot, span, Sref, phiLE, dihedral, twist, xMAC25, etakf, strUID) elif LoD == WING_LOD.ADVDOUBLE: createAdvDoubleTrapezoidWing(cpacsWing, id, cTip, cRoot, span, Sref, dfus, phiLE, dihedral, twist, xMAC25, etakf, strUID, yFus, xRoot, etaEng, tcRoot, tcTip) elif LoD == WING_LOD.UCAV: createUCAVWing(cpacsWing, id, cTip, cRoot, span, Sref, phiLE, dihedral, etakf, strUID) elif LoD == WING_LOD.SBW: etaStrut = zeroWing.aircraft.strut.etaStrut.getValue() createStrutBracedWing(cpacsWing, id=id, cTip=cTip, cRoot=cRoot, span=span, Sref=Sref, phiLE=phiLE, dihedral=dihedral, twist=twist, xMAC25=xMAC25, etaFus=etaFus, etaStrut=etaStrut, tcRoot=tcRoot, tcTip=tcTip, xRoot=xRoot, strUID=strUID) elif LoD == WING_LOD.SBWStraight: etaStrut = zeroWing.aircraft.strut.etaStrut.getValue() createStraightStrutBracedWing(cpacsWing, id=id, cTip=cTip, cRoot=cRoot, span=span, Sref=Sref, phiLE=phiLE, dihedral=dihedral, twist=twist, xMAC25=xMAC25, etaFus=etaFus, etaStrut=etaStrut, tcRoot=tcRoot, tcTip=tcTip, xRoot=xRoot, strUID=strUID) elif LoD == WING_LOD.STRUT: etaStrut = zeroWing.aircraft.strut.etaStrut.getValue() createStrut(cpacsWing, id=id, cTip=cTip, cRoot=cRoot, span=span, phiLE=phiLE, dihedral=dihedral, tcRoot=tcRoot, tcTip=tcTip, xRoot=xRoot, yRoot=yRoot, twist=twist, etaStrut=etaStrut, strUID=strUID)
def createFuselage(CPACSObj, id, dfus, lnose, lcabin, ltail, LoD=0): # just for now if LoD == FUSE_LOD.NONE: return cpacsPath = '/cpacs/vehicles/aircraft/model/fuselages/fuselage[' + id + ']' # the next line is the one to use later on #cpacsPath = '/cpacs/vehicles/aircraft/model[model]/fuselages/fuselage[' + self.id + ']' # gets a list of all wing elements myFuse = getObjfromXpath(CPACSObj, cpacsPath) strUID = myFuse.get_uID() myUID = strUID myName = stringBaseType(None, None, None, id) myDescr = stringBaseType(None, None, None, strUID) myFuse.set_uID(myUID) myFuse.set_name(myName) myFuse.set_description(myDescr) createTransformation(myFuse, 'absGlobal', 0., 0., 0.) if LoD == FUSE_LOD.A320: nose = list(NOSE) cabin = list(CABIN) tail = list(TAIL) # remove double values cabin.pop(0) tail.pop(0) # sections will be created, all existing sections will be deleted createFuselageSections(myFuse, nose, cabin, tail, dfus, strUID, strUID, strUID) createFuselagePositionings(myFuse, nose, cabin, tail, lnose, lcabin, ltail, strUID, strUID) createFuselageSegments(myFuse, strUID, len(nose) + len(cabin) + len(tail) - 1) elif LoD == FUSE_LOD.ZYL: # sections will be created, all existing sections will be deleted mySections = fuselageSectionsType() #calc fuselage radius #rfus = dfus/2. # make fuselage configuration data [x_rel,z-dist,height/2,width/2]] fuseConf = [0., 0., 0.5, 0.5] createFuselageSection(mySections, dfus, fuseConf, 'Circle', strUID + '_Sec1', strUID + '_Sec1', strUID + '_Sec1') createFuselageSection(mySections, dfus, fuseConf, 'Circle', strUID + '_Sec2', strUID + '_Sec2', strUID + '_Sec2') createFuselageSection(mySections, dfus, fuseConf, 'Circle', strUID + '_Sec3', strUID + '_Sec3', strUID + '_Sec3') createFuselageSection(mySections, dfus, fuseConf, 'Circle', strUID + '_Sec4', strUID + '_Sec4', strUID + '_Sec4') myFuse.set_sections(mySections) myPositionings = positioningsType() createPositioning(myPositionings, str(id) + '_Pos1', None, str(id) + '_Sec1', 0., 90., 0., id + '_Pos1') createPositioning(myPositionings, str(id) + '_Pos2', str(id) + '_Sec1', str(id) + '_Sec2', lnose, 90., 0, id + '_Pos2') createPositioning(myPositionings, str(id) + '_Pos3', str(id) + '_Sec2', str(id) + '_Sec3', lcabin, 90., 0, id + '_Pos3') createPositioning(myPositionings, str(id) + '_Pos4', str(id) + '_Sec3', str(id) + '_Sec4', ltail, 90., 0, id + '_Pos4') myFuse.set_positionings(myPositionings) createFuselageSegments(myFuse, strUID, 3)
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)
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)
def createWing(CPACSObj=None, zeroWing=None, id="1", LoD=0.): """ This function triggers the different export modes of the wing depending on the desired level of detail. Options include a single trapezoid, double trapezoid, advanced double trapezoid (that includes a rectangular center fuselage section) and a strut-braced wing. Please note, these are the internal guts of VAMPzero's CPACS export. A lot of the code here is experimental and furthermore highly chaotic. In case of emergency contact Daniel or Jonas. :param CPACSObj: The overall CPACS object of the export :param zeroWing: The instance of the wing. :param id: The id of the wing, mostly sth. like wing :param LoD: The level of detail of the desired input. :return: CPACSObj including a new wing """ if LoD == WING_LOD.NONE: return # just for now cpacsPath = '/cpacs/vehicles/aircraft/model/wings/wing[' + id + ']' # the next line is the one to use later on # cpacsPath = '/cpacs/vehicles/aircraft/model[model]/wings/wing[' + self.id + ']' # get the wing object from given cpacs path cpacsWing = getObjfromXpath(CPACSObj, cpacsPath) strUID = createHeader(cpacsWing, id) cpacsWing.set_symmetry('x-z-plane') cpacsWing.set_name(stringBaseType(valueOf_='wing')) cpacsWing.set_parentUID(stringUIDBaseType(isLink=True, valueOf_='fuselage')) xRoot = zeroWing.xRoot.getValue() zRoot = zeroWing.zRoot.getValue() cRoot = zeroWing.cRoot.getValue() cTip = zeroWing.cTip.getValue() span = zeroWing.span.getValue() dfus = zeroWing.aircraft.fuselage.dfus.getValue() phiLE = zeroWing.phiLE.getValue() dihedral = zeroWing.dihedral.getValue() twist = zeroWing.twist.getValue() Sref = zeroWing.refArea.getValue() xMAC25 = zeroWing.xMAC25.getValue() tcRoot = zeroWing.airfoilr.tc.getValue() tcTip = zeroWing.airfoilt.tc.getValue() try: etakf = zeroWing.etaKink.getValue() yFus = zeroWing.yFuselage.getValue() etaEng = zeroWing.etaEngine.getValue() etaFus = yFus / span * 2. except AttributeError: pass #As not all components that call this method have a kink try: yRoot = zeroWing.yRoot.getValue() except AttributeError: pass #As not all components that call this method have a kink createTransformation(cpacsWing, 'absGlobal', xRoot, 0., zRoot) # call corresponding wing creation method if LoD == WING_LOD.SINGLE: createTrapezoidWing(cpacsWing, id, tcRoot, tcTip, cTip, cRoot, span, phiLE, dihedral, twist, strUID) elif LoD == WING_LOD.DOUBLE: createDoubleTrapezoidWing(cpacsWing, id, cTip, cRoot, span, Sref, phiLE, dihedral, twist, xMAC25, etakf, strUID) elif LoD == WING_LOD.ADVDOUBLE: createAdvDoubleTrapezoidWing(cpacsWing, id, cTip, cRoot, span, Sref, dfus, phiLE, dihedral, twist, xMAC25, etakf, strUID, yFus, xRoot, etaEng, tcRoot, tcTip) elif LoD == WING_LOD.UCAV: createUCAVWing(cpacsWing, id, cTip, cRoot, span, Sref, phiLE, dihedral, etakf, strUID) elif LoD == WING_LOD.SBW: print "dihedral", dihedral etaStrut = zeroWing.aircraft.strut.etaStrut.getValue() createStrutBracedWing(cpacsWing, id=id, cTip=cTip, cRoot=cRoot, span=span, Sref=Sref, phiLE=phiLE, dihedral=dihedral, twist=twist, xMAC25=xMAC25, etaFus=etaFus, etaStrut=etaStrut, tcRoot=tcRoot, tcTip=tcTip, xRoot=xRoot, strUID=strUID) elif LoD == WING_LOD.STRUT: etaStrut = zeroWing.aircraft.strut.etaStrut.getValue() createStrut(cpacsWing, id=id, cTip=cTip, cRoot=cRoot, span=span, phiLE=phiLE, dihedral=dihedral, tcRoot=tcRoot, tcTip=tcTip, xRoot=xRoot, yRoot=yRoot, twist=twist, etaStrut=etaStrut, strUID=strUID)
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)
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)
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)
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 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)