def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' imports the value for thrust00 for the current engine out of TWDat ''' if not TIXIHandle: TIXIHandle = openTIXI(path) if checkElement(TIXIHandle, '/cpacs/vehicles/engines/engine/analysis/thrust00'): self.thrust00 = eval( getText(TIXIHandle, '/cpacs/vehicles/engines/engine/analysis/thrust00')) self.importSuccess() else: self.importError() if checkElement(TIXIHandle, '/cpacs/vehicles/engines/engine/name'): name = getText(TIXIHandle, '/cpacs/vehicles/engines/engine/name') if name.find('scaled') != -1: self.originalScaling = eval(name.split()[-1]) self.log.info( "VAMPzero TIXI: imported previous scaling factor from TWDat: %s" % self.originalScaling) else: self.originalScaling = 1. else: self.importError()
def readConfig(self): ''' Read VAMPzeros configuration parameters. Command line arguments overwrite the configurations in the toolspecific part. ''' TIXIHandle = tixiLib.openTIXI(self.cpacsIn) if self.args.d != None: self.config['deviationAmplitude'] = float(self.args.d) else: devFactor = 0.0 devFactorStr = tixiLib.getText(TIXIHandle,'/cpacs/toolspecific/vampZero/toolSettings/deviationAmplitude') if devFactorStr != None: devFactor = float(devFactorStr) self.config['deviationAmplitude'] = devFactor # read configuration for extended output self.config['extendedOutput'] = True extendedOutput = tixiLib.getText(TIXIHandle,'/cpacs/toolspecific/vampZero/toolSettings/extendedOutput') if extendedOutput in ('False', 'false', '0.0', '0.', '0'): self.config['extendedOutput'] = False # read sensitivity configuration self.config['calcSensitivities'] = False calcSensitivities = tixiLib.getText(TIXIHandle,'/cpacs/toolspecific/vampZero/toolSettings/calcSensitivities') if calcSensitivities in ('True', 'true', '1.0', '1.', '1'): self.config['calcSensitivities'] = True # read not converging behavior self.config['notConvergingAction'] = 'exit' not_converging_action = tixiLib.getText(TIXIHandle,'/cpacs/toolspecific/vampZero/toolSettings/notConvergingAction') if not_converging_action in ('exit', 'copyInput', 'errorXML'): self.config['notConvergingAction'] = not_converging_action tixiLib.closeXML(TIXIHandle)
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' ''' if not TIXIHandle: TIXIHandle = openTIXI(path) error = 0 if checkElement( TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mStructure/mWingsStructure/mWingStructure[3]/massDescription/mass' ): self.mWingPrimary = eval( getText( TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mStructure/mWingsStructure/mWingStructure[3]/massDescription/mass' )) else: error = 1 if error == 0 and self.mWingPrimary is not None: self.setValueFix(self.mWingPrimary * 2.) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Overwrites the parameter's cpacsImport method! Will get the value for cDMINoffset from a CPACS aeroPerformanceMap. Does a monkey patch as it replaces cDMINoffset.calc with cDMINoffset.calcLiLi .. todo:: cpacsImport cDMINoffset catch error if cfy is unequal zero ''' try: if not TIXIHandle: TIXIHandle = openTIXI(path) self.refArea = eval(getText(TIXIHandle, '/cpacs/vehicles/aircraft/model/reference/area')) self.CfxList = getList(TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/aeroPerformanceMap/cfx') self.CfzList = getList(TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/aeroPerformanceMap/cfz') self.CfyList = getList(TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/aeroPerformanceMap/cfy') self.AOAList = getList(TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/aeroPerformanceMap/angleOfAttack') self.AOYList = getList(TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/aeroPerformanceMap/angleOfYaw') self.machList = getList(TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/aeroPerformanceMap/machNumber') self.reList = getList(TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/aeroPerformanceMap/reynoldsNumber') if self.CfxList: self.calc = self.calcLiLi self.monkeyPatch('LiftingLine') except: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Imports the values for the primary wing structure and applies formula to calculate mWing Value is set to FIX, but a correction factor is applied to get secondary wing mass from the imported primary wing structure mass. :Source: Analytical Fuselage and Wing Weight Estimation of Transport Aircraft, M. D. Ardema, M. C. Chambers, A. P. Patron, A. S. Hahn, H. Miura, M. D. Moore, NASA Technical Memorandum 110392, 1996, p. 22 eq. 109 ''' if not TIXIHandle: TIXIHandle = openTIXI(path) error = 0 if checkElement( TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mStructure/mWingsStructure/mWingStructure[1]/massDescription/mass' ): self.mWingPrimary = eval( getText( TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mStructure/mWingsStructure/mWingStructure[1]/massDescription/mass' )) else: error = 1 if error == 0 and self.mWingPrimary is not None: self.setValueFix(2. * self.mWingPrimary) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Overwrites the parameters cpacsImport method! Will get the value for dfus from CPACS via TIGL functions ''' if not TIXIHandle: TIXIHandle = openTIXI(path) if not TIGLHandle: TIGLHandle = openTIGL(TIXIHandle, self.parent.aircraft.modelUID.getValue()) if checkElement(TIXIHandle, '/cpacs/vehicles/aircraft/model/fuselages/fuselage'): lastSegment = getFuselageSegmentCount(TIGLHandle) dmax = 0. for i in range(lastSegment): diameter = getFuselageDiameter(TIGLHandle, i+1,1.) if diameter > dmax: dmax = diameter self.setValueFix(dmax) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Overwrites the parameters cpacsImport method! Will get the value for lfus from CPACS via TIGL functions ''' if not TIXIHandle: TIXIHandle = openTIXI(path) if not TIGLHandle: TIGLHandle = openTIGL(TIXIHandle, self.parent.aircraft.modelUID.getValue()) if checkElement(TIXIHandle, '/cpacs/vehicles/aircraft/model/fuselages/fuselage'): # get First Point from the Fuselage x1, y1, z1 = getFuselagePoint(TIGLHandle, 1, 0., 0.) lastSegment = getFuselageSegmentCount(TIGLHandle) x2, y2, z2 = getFuselagePoint(TIGLHandle, lastSegment, 1., 0.) self.setValueFix(x2 - x1) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' TIXI and TIGL Handle should be given, to save some valueable time Imports self.cpacsPath from path Input Values will be set to 'fix' ''' if not TIXIHandle: TIXIHandle = openTIXI(path) if self.getCpacsPath() != '': retVal = getText(TIXIHandle, self.getCpacsPath()) if retVal is not None and retVal is not '': try: self.setValueFix(eval(retVal)) self.importSuccess() # This may occur if UID or other strings will be imported except NameError: self.setValueFix(retVal) self.importSuccess() except SyntaxError: self.setValueFix(retVal) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Overwrites the parameters cpacsImport method! Will get the value for the htp span from CPACS via TIGL functions ''' if not TIXIHandle: TIXIHandle = openTIXI(path) if not TIGLHandle: TIGLHandle = openTIGL(TIXIHandle, self.parent.aircraft.modelUID.getValue()) if checkElement(TIXIHandle, '/cpacs/vehicles/aircraft/model/wings/wing[2]'): #get First Point from the WingRoot wingIndex = 2 x1, y1, z1 = getWingUpperPoint(TIGLHandle, wingIndex, 1, 0, 0) lastSegment = getWingSegmentCount(TIGLHandle, wingIndex) x2, y2, z2 = getWingUpperPoint(TIGLHandle, wingIndex, lastSegment, 1, 0) #todo: cpacsImport span: prototype version taking leading Edge Points self.setValueFix((y2 - y1) * 2.) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Retrieves the xRoot coordinate from TIGL. It will go for the main fuselage. The first sections x coordinate is read at eta and zeta equal 0. ''' if not TIXIHandle: TIXIHandle = openTIXI(path) if not TIGLHandle: TIGLHandle = openTIGL(TIXIHandle, self.parent.aircraft.modelUID.getValue()) if checkElement(TIXIHandle, '/cpacs/vehicles/aircraft/model/fuselages/fuselage'): self.log.debug('Importing fuselage x position...') try: # fuselage index is implicitly set to 1 in TIGL/tigl.py x1, _, _ = getFuselagePoint(TIGLHandle, 1, 0, 0) except Exception as e: self.log.warning(str(e)) self.log.debug('Importing fuselage x position... {}'.format(x1)) self.setValueFix(x1) self.importSuccess() else: self.importError()
def cpacsImport(self, path=".\\cpacs.xml", TIXIHandle=None, TIGLHandle=None): """ Imports the values for the primary wing structure and applies formula to calculate mWing Value is set to FIX, but a correction factor is applied to get secondary wing mass from the imported primary wing structure mass. :Source: Analytical Fuselage and Wing Weight Estimation of Transport Aircraft, M. D. Ardema, M. C. Chambers, A. P. Patron, A. S. Hahn, H. Miura, M. D. Moore, NASA Technical Memorandum 110392, 1996, p. 22 eq. 109 """ if not TIXIHandle: TIXIHandle = openTIXI(path) error = 0 if checkElement( TIXIHandle, "/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mStructure/mWingsStructure/mWingStructure[1]/massDescription/mass", ): self.mWingPrimary = eval( getText( TIXIHandle, "/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mStructure/mWingsStructure/mWingStructure[1]/massDescription/mass", ) ) else: error = 1 if error == 0 and self.mWingPrimary is not None: self.setValueFix(self.mWingPrimary) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Overwrites the parameters cpacsImport method! Will get the value for wingSpan from CPACS via TIGL functions ''' if not TIXIHandle: TIXIHandle = openTIXI(path) if not TIGLHandle: TIGLHandle = openTIGL(TIXIHandle, self.parent.aircraft.modelUID.getValue()) if checkElement(TIXIHandle, '/cpacs/vehicles/aircraft/model/wings/wing'): #get First Point from the WingRoot wingIndex = 1 x1, y1, z1 = getWingUpperPoint(TIGLHandle, wingIndex, 1, 0, 0) lastSegment = getWingSegmentCount(TIGLHandle, wingIndex) x2, y2, z2 = getWingUpperPoint(TIGLHandle, wingIndex, lastSegment, 1, 0) #todo: cpacsImport span: prototype version taking leading Edge Points self.setValueFix((y2 - y1) * 2.) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Imports the quarter chord sweep angle of the htp from TIGL. It takes the htp's first and last section and reads y and y coordinates and from these calculates the htp sweep. ''' wingIndex = 2 if not TIXIHandle: TIXIHandle = openTIXI(path) if not TIGLHandle: TIGLHandle = openTIGL(TIXIHandle, self.parent.aircraft.modelUID.getValue()) lastSeg = getWingSegmentCount(TIGLHandle, wingIndex) if checkElement(TIXIHandle, '/cpacs/vehicles/aircraft/model/wings/wing[2]'): x1, y1, z1 = getWingUpperPoint(TIGLHandle, wingIndex, 1, 0., 0.25) x2, y2, z2 = getWingUpperPoint(TIGLHandle, wingIndex, lastSeg, 1., 0.25) #Length of the hypothenuse so we do not need atan h = sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) self.setValueFix(asin((x2 - x1) / h) / rad) else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Overwrites the parameters cpacsImport method! Will get the value for dfus from CPACS via TIGL functions ''' if not TIXIHandle: TIXIHandle = openTIXI(path) if not TIGLHandle: TIGLHandle = openTIGL(TIXIHandle, self.parent.aircraft.modelUID.getValue()) if checkElement(TIXIHandle, '/cpacs/vehicles/aircraft/model/fuselages/fuselage'): lastSegment = getFuselageSegmentCount(TIGLHandle) dmax = 0. for i in range(lastSegment): diameter = getFuselageDiameter(TIGLHandle, i + 1, 1.) if diameter > dmax: dmax = diameter self.setValueFix(dmax) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' imports the values for summed up Nose and Main Landing Gear and set value to fix .. todo:: cpacsImport mLandingGear this is out dated since LGDesign does not apply to CPACS 1.4 ''' if not TIXIHandle: TIXIHandle = openTIXI(path) error = 0 if checkElement(TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/landingGear/mainGears/mainGear/totalMass/mass'): self.mMainGear = eval(getText(TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/landingGear/mainGears/mainGear/totalMass/mass')) else: error = 1 if checkElement(TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/landingGear/noseGears/noseGear/totalMass/mass'): self.mNoseGear = eval(getText(TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/landingGear/noseGears/noseGear/totalMass/mass')) else: error = 1 if not error: self.setValueFix(2 * self.mMainGear + self.mNoseGear) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Overwrites the parameter's cpacsImport method! Will get the value for the Oswald Factor from CPACS It will be assumed that the aeroperformanceMap holds LiLi values Does a monkey patch as it replaces oswald.calc with oswald.calcLiLi .. todo:: cpacsImport oswald catch error if cfy is unequal zero ''' try: if not TIXIHandle: TIXIHandle = openTIXI(path) self.refArea = eval( getText(TIXIHandle, '/cpacs/vehicles/aircraft/model/reference/area')) self.CfxList = getList( TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/aeroPerformanceMap/cfx' ) self.CfzList = getList( TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/aeroPerformanceMap/cfz' ) self.CfyList = getList( TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/aeroPerformanceMap/cfy' ) self.AOAList = getList( TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/aeroPerformanceMap/angleOfAttack' ) self.AOYList = getList( TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/aeroPerformanceMap/angleOfYaw' ) self.machList = getList( TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/aeroPerformanceMap/machNumber' ) self.reList = getList( TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/aeroPerformanceMap/reynoldsNumber' ) if self.CfxList: self.calc = self.calcLiLi self.monkeyPatch('LiftingLine') except: self.importError()
def resultToolspecExport(component, path): ''' Exports marked parameters into VAMPzeros toolspecific results node. @param component: should be the aircraft component ''' log = zeroLogger('resultToolspecExport') log.info('') log.info( "##############################################################################" ) log.info("VAMPzero Result Toolspecific Export to %s" % (path)) log.info( "##############################################################################" ) #reset outfile TIXIHandle = tixiLib.openTIXI(path) for para in component.getParameters(): if not para['exportTS']: continue # try to get componentNode compPathBase = '/cpacs/toolspecific/vampZero/results/components/component' compPath = compPathBase + '[name="%s"]' % para.parent.id discPathBase = compPath + '/disciplines/discipline' discPath = discPathBase + '[name="%s"]' % para["discipline"] paraPathBase = discPath + '/parameters/parameter' paraPath = paraPathBase + '[name="%s"]' % para.getName() # try to get component node exists = tixiLib.checkElement(TIXIHandle, compPath) if not exists: # create it tixiLib.buildTree(TIXIHandle, compPath + '/name') tixiLib.addText(TIXIHandle, compPathBase + '[last()]/name', para.parent.id) # try to get discipline node exists = tixiLib.checkElement(TIXIHandle, discPath) if not exists: # create it tixiLib.buildTree(TIXIHandle, discPath + '/name') tixiLib.addText(TIXIHandle, discPathBase + '[last()]/name', para["discipline"]) # try to get parameter node exists = tixiLib.checkElement(TIXIHandle, paraPath) if not exists: # create it tixiLib.buildTree(TIXIHandle, paraPath + '/name') tixiLib.addText(TIXIHandle, paraPathBase + '[last()]/name', para.getName()) tixiLib.setText(TIXIHandle, paraPath + '/value', para.getValue()) tixiLib.saveXML(path, TIXIHandle) tixiLib.closeXML(TIXIHandle) log.info("VAMPzero RESULT TOOLSPECIFIC EXPORT: done.")
def run(self, argv=None): ''' Runs VAMPzero. ''' if argv is None: argv = sys.argv try: generalLib.printHeader() print argv self.args = self.parser.parse_args() self.readConfig() ################################################################################################### ##VAMPzero Initialize ################################################################################################### self.aircraft.engine.sfcCR.calc = self.aircraft.engine.sfcCR.calcOverallEff self.setFixed() ################################################################################################### ##VAMPzero Imports ################################################################################################### if self.args.m: importMatlabLib.importMatlab(self.aircraft) else: guiLib.importGUI(self.aircraft, self.cpacsIn) tixiHandle = tixiLib.openTIXI(self.cpacsIn) hasModel = tixiLib.checkElement(tixiHandle,'/cpacs/vehicles/aircraft/model') if hasModel: self.aircraft.cpacsImport(self.cpacsIn) hasEngine = tixiLib.checkElement(tixiHandle,'/cpacs/vehicles/engines/engine') if hasEngine: self.aircraft.engine.cpacsImport(self.cpacsIn) self.aircraft.atmosphere.hCR.setValueFix(self.aircraft.altCR.getValue()) self.aircraft.atmosphere.MaCR.setValueFix(self.aircraft.machCR.getValue()) self.calc() self.finish() self.setUIDs() self.exportToolspecific() # needs to be called after the last use of cpacsLib (otherwise all nodes not in the schema will be removed) generalLib.printFooter() return 0 except (argparse.ArgumentError), err: print >>sys.stderr, err self.parser.print_help() return 2
def run(self, argv=None): ''' Runs VAMPzero. ''' if argv is None: argv = sys.argv try: generalLib.printHeader() print argv self.args = self.parser.parse_args() self.readConfig() ################################################################################################### ##VAMPzero Initialize ################################################################################################### self.aircraft.engine.sfcCR.calc = self.aircraft.engine.sfcCR.calcOverallEff self.setFixed() ################################################################################################### ##VAMPzero Imports ################################################################################################### if self.args.m: importMatlabLib.importMatlab(self.aircraft) else: guiLib.importGUI(self.aircraft, self.cpacsIn) tixiHandle = tixiLib.openTIXI(self.cpacsIn) hasModel = tixiLib.checkElement(tixiHandle, '/cpacs/vehicles/aircraft/model') if hasModel: self.aircraft.cpacsImport(self.cpacsIn) self.aircraft.atmosphere.hCR.setValueFix( self.aircraft.altCR.getValue()) self.aircraft.atmosphere.MaCR.setValueFix( self.aircraft.machCR.getValue()) self.calc() self.finish() self.setUIDs() self.exportToolspecific( ) # needs to be called after the last use of cpacsLib (otherwise all nodes not in the schema will be removed) generalLib.printFooter() return 0 except (argparse.ArgumentError), err: print >> sys.stderr, err self.parser.print_help() return 2
def cpacsImport(self, path='.\\cpacs.xml'): ''' Looks for parameter.CPACSPath in CPACSFilse defined by Path Transfers Value is possible Input Values will be set to 'fix' ''' self.log.info('') self.log.info( "##############################################################################" ) self.log.info("VAMPzero CPACS Import from %s" % path) self.log.info("trying to import and fix parameters") self.log.info( "##############################################################################" ) TIXIHandle = openTIXI(path) modelUID = getText(TIXIHandle, '/cpacs/toolspecific/vampZero/aircraftModelUID') if modelUID is None: self.log.info( "VAMPzero IMPORT: No modelUID specified in the toolspecific Block" ) try: modelUID = self.modelUID.getValue() self.log.info("VAMPzero IMPORT: loaded modelUID from VAMPzero") except AttributeError: modelUID = None self.log.info( "VAMPzero IMPORT: could not load modelUID from VAMPzero") if modelUID is not None: TIGLHandle = openTIGL(TIXIHandle, modelUID) if TIGLHandle is not None: self.log.debug( "VAMPzero IMPORT: Opened TIXI and TIGL in Component") else: TIGLHandle = None self.log.debug( "VAMPzero IMPORT: Opened only TIXI in Component as no modelUID was specified" ) self.importer(path, TIXIHandle, TIGLHandle) self.log.info("VAMPzero IMPORT: done.") closeXML(TIXIHandle)
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Overwrites the parameters cpacsImport method! Will get the value for wingSpan from CPACS via TIGL functions ''' def calcRootLength(tiglHandle, wingIndex): ''' Calculates the length of the root section chord ''' x1, y1, z1 = getWingUpperPoint(tiglHandle, wingIndex, 1, 0, 0) x2, y2, z2 = getWingUpperPoint(tiglHandle, wingIndex, 1, 0, 1) return pointDistance(x1, y1, z1, x2, y2, z2) def calcTipLength(tiglHandle, wingIndex): ''' Calculates the length of the tip section chord ''' lastSegment = getWingSegmentCount(tiglHandle, wingIndex) x1, y1, z1 = getWingUpperPoint(tiglHandle, wingIndex, lastSegment, 1, 0) x2, y2, z2 = getWingUpperPoint(tiglHandle, wingIndex, lastSegment, 1, 1) return pointDistance(x1, y1, z1, x2, y2, z2) #=============================================================================== # main cpacsImport #===============================================================================s wingIndex = 1 if not TIXIHandle: TIXIHandle = openTIXI(path) if not TIGLHandle: TIGLHandle = openTIGL(TIXIHandle, self.parent.aircraft.modelUID.getValue()) if checkElement(TIXIHandle, '/cpacs/vehicles/aircraft/model/wings/wing'): rootC = calcRootLength(TIGLHandle, wingIndex) tipC = calcTipLength(TIGLHandle, wingIndex) self.setValueFix(tipC / rootC) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' imports the values for summed up Nose and Main Landing Gear and set value to fix .. todo:: cpacsImport mLandingGear this is out dated since LGDesign does not apply to CPACS 1.4 ''' if not TIXIHandle: TIXIHandle = openTIXI(path) error = 0 if checkElement( TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/landingGear/mainGears/mainGear/totalMass/mass' ): self.mMainGear = eval( getText( TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/landingGear/mainGears/mainGear/totalMass/mass' )) else: error = 1 if checkElement( TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/landingGear/noseGears/noseGear/totalMass/mass' ): self.mNoseGear = eval( getText( TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/landingGear/noseGears/noseGear/totalMass/mass' )) else: error = 1 if not error: self.setValueFix(2 * self.mMainGear + self.mNoseGear) self.importSuccess() else: self.importError()
def resultToolspecExport(component, path): """ Exports marked parameters into VAMPzeros toolspecific results node. @param component: should be the aircraft component """ log = zeroLogger("resultToolspecExport") log.info("") log.info("##############################################################################") log.info("VAMPzero Result Toolspecific Export to %s" % (path)) log.info("##############################################################################") # reset outfile TIXIHandle = tixiLib.openTIXI(path) for para in component.getParameters(): if not para["exportTS"]: continue # try to get componentNode compPathBase = "/cpacs/toolspecific/vampZero/results/components/component" compPath = compPathBase + '[name="%s"]' % para.parent.id discPathBase = compPath + "/disciplines/discipline" discPath = discPathBase + '[name="%s"]' % para["discipline"] paraPathBase = discPath + "/parameters/parameter" paraPath = paraPathBase + '[name="%s"]' % para.getName() # try to get component node exists = tixiLib.checkElement(TIXIHandle, compPath) if not exists: # create it tixiLib.buildTree(TIXIHandle, compPath + "/name") tixiLib.addText(TIXIHandle, compPathBase + "[last()]/name", para.parent.id) # try to get discipline node exists = tixiLib.checkElement(TIXIHandle, discPath) if not exists: # create it tixiLib.buildTree(TIXIHandle, discPath + "/name") tixiLib.addText(TIXIHandle, discPathBase + "[last()]/name", para["discipline"]) # try to get parameter node exists = tixiLib.checkElement(TIXIHandle, paraPath) if not exists: # create it tixiLib.buildTree(TIXIHandle, paraPath + "/name") tixiLib.addText(TIXIHandle, paraPathBase + "[last()]/name", para.getName()) tixiLib.setText(TIXIHandle, paraPath + "/value", para.getValue()) tixiLib.saveXML(path, TIXIHandle) tixiLib.closeXML(TIXIHandle) log.info("VAMPzero RESULT TOOLSPECIFIC EXPORT: done.")
def cpacsImport(self, path=".\\cpacs.xml", TIXIHandle=None, TIGLHandle=None): """ Overwrites the parameters cpacsImport method! Will get the value for taperRatio from CPACS via TIGL functions """ def calcRootLength(tiglHandle, wingIndex): """ Calculates the length of the root section chord """ x1, y1, z1 = getWingUpperPoint(tiglHandle, wingIndex, 1, 0, 0) x2, y2, z2 = getWingUpperPoint(tiglHandle, wingIndex, 1, 0, 1) return pointDistance(x1, y1, z1, x2, y2, z2) def calcTipLength(tiglHandle, wingIndex): """ Calculates the length of the tip section chord """ lastSegment = getWingSegmentCount(tiglHandle, wingIndex) x1, y1, z1 = getWingUpperPoint(tiglHandle, wingIndex, lastSegment, 1, 0) x2, y2, z2 = getWingUpperPoint(tiglHandle, wingIndex, lastSegment, 1, 1) return pointDistance(x1, y1, z1, x2, y2, z2) # ======================================================================= # # ======================================================================= # @todo: cpacsImport taperRatio: Think about an import logic for the different wings wingIndex = 3 if not TIXIHandle: TIXIHandle = openTIXI(path) if not TIGLHandle: TIGLHandle = openTIGL(TIXIHandle, self.parent.aircraft.modelUID.getValue()) if checkElement(TIXIHandle, "/cpacs/vehicles/aircraft/model/wings/wing[3]"): rootC = calcRootLength(TIGLHandle, wingIndex) tipC = calcTipLength(TIGLHandle, wingIndex) self.setValueFix(tipC / rootC) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Overwrites the parameters cpacsImport method! Will get the value for refArea for HTP from CPACS via TIGL functions ''' if not TIXIHandle: TIXIHandle = openTIXI(path) if not TIGLHandle: TIGLHandle = openTIGL(TIXIHandle, self.parent.aircraft.modelUID.getValue()) #@todo: cpacsImport refArea: it is assumed that the htp is number 2 wing if checkElement(TIXIHandle, '/cpacs/vehicles/aircraft/model/wings/wing[2]'): area = getWingSurfaceArea(TIGLHandle, 2) self.setValueFix(area) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Retrieves the xRoot.py coordinate from TIGL. It will go for the vtp. The first sections x coordinate is read at eta and chord equal 0. ''' wingIndex = 3 if not TIXIHandle: TIXIHandle = openTIXI(path) if not TIGLHandle: TIGLHandle = openTIGL(TIXIHandle, self.parent.aircraft.modelUID.getValue()) if checkElement(TIXIHandle, '/cpacs/vehicles/aircraft/model/wings/wing[3]'): x1, y1, z1 = getWingUpperPoint(TIGLHandle, wingIndex, 1, 0, 0) self.setValueFix(x1) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Retrieves the xRoot coordinate from TIGL. It will go for the main wing. The first sections x coordinate is read at eta and chord equal 0. ''' wingIndex = 1 if not TIXIHandle: TIXIHandle = openTIXI(path) if not TIGLHandle: TIGLHandle = openTIGL(TIXIHandle, self.parent.aircraft.modelUID.getValue()) if checkElement(TIXIHandle, '/cpacs/vehicles/aircraft/model/wings/wing'): x1, y1, z1 = getWingUpperPoint(TIGLHandle, wingIndex, 1, 0, 0) self.setValueFix(x1) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Overwrites the parameters cpacsImport method! ''' #@todo: cpacsImport taperRatio: Think about an import logic for the different wings wingIndex = 2 if not TIXIHandle: TIXIHandle = openTIXI(path) if not TIGLHandle: TIGLHandle = openTIGL(TIXIHandle, self.parent.aircraft.modelUID.getValue()) if checkElement(TIXIHandle, '/cpacs/vehicles/aircraft/model/wings/wing[2]'): x1, y1, z1 = getWingUpperPoint(TIGLHandle, wingIndex, 1, 0, 0) self.setValueFix(x1) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Overwrites the parameters cpacsImport method! ''' #@todo: cpacsImport taperRatio: Think about an import logic for the different wings wingIndex = 2 if not TIXIHandle: TIXIHandle = openTIXI(path) if not TIGLHandle: TIGLHandle = openTIGL(TIXIHandle, self.parent.aircraft.modelUID.getValue()) if checkElement(TIXIHandle, '/cpacs/vehicles/aircraft/model/wings/wing[2]'): x1, y1, z1 = getWingUpperPoint(TIGLHandle, wingIndex, 1, 0, 0) self.setValueFix(z1) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' ''' if not TIXIHandle: TIXIHandle = openTIXI(path) error = 0 if checkElement(TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mStructure/mWingsStructure/mWingStructure[3]/massDescription/mass'): self.mWingPrimary = eval(getText(TIXIHandle, '/cpacs/vehicles/aircraft/model/analyses/massBreakdown/mOEM/mEM/mStructure/mWingsStructure/mWingStructure[3]/massDescription/mass')) else: error = 1 if error == 0 and self.mWingPrimary is not None: self.setValueFix(self.mWingPrimary * 2.) self.importSuccess() else: self.importError()
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' imports the value for thrust00 for the current engine out of TWDat ''' if not TIXIHandle: TIXIHandle = openTIXI(path) if checkElement(TIXIHandle, '/cpacs/vehicles/engines/engine/analysis/thrust00'): self.thrust00 = eval(getText(TIXIHandle, '/cpacs/vehicles/engines/engine/analysis/thrust00')) self.importSuccess() else: self.importError() if checkElement(TIXIHandle, '/cpacs/vehicles/engines/engine/name'): name = getText(TIXIHandle, '/cpacs/vehicles/engines/engine/name') if name.find('scaled') != -1: self.originalScaling = eval(name.split()[-1]) self.log.info("VAMPzero TIXI: imported previous scaling factor from TWDat: %s" % self.originalScaling) else: self.originalScaling = 1. else: self.importError()
def readConfig(self): ''' Read VAMPzeros configuration parameters. Command line arguments overwrite the configurations in the toolspecific part. ''' TIXIHandle = tixiLib.openTIXI(self.cpacsIn) if self.args.d != None: self.config['deviationAmplitude'] = float(self.args.d) else: devFactor = 0.0 devFactorStr = tixiLib.getText( TIXIHandle, '/cpacs/toolspecific/vampZero/toolSettings/deviationAmplitude') if devFactorStr != None: devFactor = float(devFactorStr) self.config['deviationAmplitude'] = devFactor # read configuration for extended output self.config['extendedOutput'] = True extendedOutput = tixiLib.getText( TIXIHandle, '/cpacs/toolspecific/vampZero/toolSettings/extendedOutput') if extendedOutput in ('False', 'false', '0.0', '0.', '0'): self.config['extendedOutput'] = False # read sensitivity configuration self.config['calcSensitivities'] = False calcSensitivities = tixiLib.getText( TIXIHandle, '/cpacs/toolspecific/vampZero/toolSettings/calcSensitivities') if calcSensitivities in ('True', 'true', '1.0', '1.', '1'): self.config['calcSensitivities'] = True # read not converging behavior self.config['notConvergingAction'] = 'exit' not_converging_action = tixiLib.getText( TIXIHandle, '/cpacs/toolspecific/vampZero/toolSettings/notConvergingAction') if not_converging_action in ('exit', 'copyInput', 'errorXML'): self.config['notConvergingAction'] = not_converging_action tixiLib.closeXML(TIXIHandle)
def cpacsImport(self, path='.\\cpacs.xml'): ''' Looks for parameter.CPACSPath in CPACSFilse defined by Path Transfers Value is possible Input Values will be set to 'fix' ''' self.log.info('') self.log.info("##############################################################################") self.log.info("VAMPzero CPACS Import from %s" % path) self.log.info("trying to import and fix parameters") self.log.info("##############################################################################") TIXIHandle = openTIXI(path) modelUID = getText(TIXIHandle, '/cpacs/toolspecific/vampZero/aircraftModelUID') if modelUID is None: self.log.info("VAMPzero IMPORT: No modelUID specified in the toolspecific Block") try: modelUID = self.modelUID.getValue() self.log.info("VAMPzero IMPORT: loaded modelUID from VAMPzero") except AttributeError: modelUID = None self.log.info("VAMPzero IMPORT: could not load modelUID from VAMPzero") if modelUID is not None: TIGLHandle = openTIGL(TIXIHandle, modelUID) if TIGLHandle is not None: self.log.debug("VAMPzero IMPORT: Opened TIXI and TIGL in Component") else: TIGLHandle = None self.log.debug("VAMPzero IMPORT: Opened only TIXI in Component as no modelUID was specified") self.importer(path, TIXIHandle, TIGLHandle) self.log.info("VAMPzero IMPORT: done.") closeXML(TIXIHandle)
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Overwrites the parameters cpacsImport method! Imports the enginePerformanceMap This method replaces the initial calc method by calcCPACS sfcCR will not be set fix because ongoing interpolation is necessary to find the correct values ''' if not TIXIHandle: TIXIHandle = openTIXI(path) if checkElement( TIXIHandle, '/cpacs/vehicles/engines/engine[last()]/analysis/performanceMaps/performanceMap' ): # Get performanceMap from CPACS Tmap = getText( TIXIHandle, "/cpacs/vehicles/engines/engine[last()]/analysis/performanceMaps/performanceMap/thrust" ).split(';') Mamap = getText( TIXIHandle, "/cpacs/vehicles/engines/engine[last()]/analysis/performanceMaps/performanceMap/machNumber" ).split(';') FLmap = getText( TIXIHandle, "/cpacs/vehicles/engines/engine[last()]/analysis/performanceMaps/performanceMap/flightLevel" ).split(';') mDotmap = getText( TIXIHandle, "/cpacs/vehicles/engines/engine[last()]/analysis/performanceMaps/performanceMap/mDotFuel" ).split(';') #Pop Last entries because of garbage FLmap.pop() mDotmap.pop() Tmap.pop() Mamap.pop() #Conversion FLmap = [float(val) for val in FLmap] Mamap = [float(val) for val in Mamap] Tmap = [float(val) for val in Tmap] mDotmap = [float(val) for val in mDotmap] #Dummies maList = [] flList = [] thList = [] #Go Through complete Data Set for i in range(len(FLmap)): thList.append([Tmap[i - 1], mDotmap[i - 1]]) if Mamap[i] != Mamap[i - 1]: maList.append([Mamap[i - 1], thList]) thList = [] if FLmap[i] != FLmap[i - 1]: flList.append([FLmap[i - 1], maList]) maList = [] # Final List of List of List for the engine deck self.TList = flList #set calcTWDat as the new Calculation method self.calc = self.calcCPACS self.monkeyPatch('CPACS') else: self.importError()
def importGUI(myAircraft, path): ''' This is an import routine for simple input from the tool-specific part of a CPACS file. This also reads all information that can be generated by the simple GUI available in the binary version of VAMPzero It takes an *aircraft* as input. This is necessary to set the values in the aircraft according to the information given in *path*. Usually *path* is specified as ./ToolInput/toolInput.xml ''' log = zeroLogger('General') log.info('') log.info( "##############################################################################" ) log.info('VAMPzero GUI: importing GUI Values from: %s' % path) log.info("reading toolspecific/GUI inputs") log.info( "##############################################################################" ) myAircraft.modelUID.cpacsImport(path) if myAircraft.modelUID.getValue() != '': log.info('VAMPzero GUI: Running with: %s as modelUID.' % myAircraft.modelUID.getValue()) else: log.warning('VAMPzero GUI: No valid information for modelUID!') TIXIHandle = openTIXI(path) cpacsVal = c_char_p() top = "/cpacs/toolspecific/vampZero/components/" ##Component############################################################# countC = 1 while 1 == 1: pathC = top + 'component[' + str(countC) + ']' if checkElement(TIXIHandle, pathC): nameC = getText(TIXIHandle, pathC + '/name') if nameC: log.debug('VAMPzero GUI: importing for component: %s' % nameC) else: break ##Discipline############################################################# countD = 1 while 1 == 1: pathD = pathC + '/disciplines/discipline[' + str(countD) + ']' if checkElement(TIXIHandle, pathD): ##Parameter############################################################# countP = 1 while 1 == 1: pathP = pathD + '/parameters/parameter[' + str( countP) + ']' if checkElement(TIXIHandle, pathP): nameP = getText(TIXIHandle, pathP + '/name') valueP = getText(TIXIHandle, pathP + '/value') factorP = getText(TIXIHandle, pathP + '/factor') statusP = getText(TIXIHandle, pathP + '/status') exportP = getText(TIXIHandle, pathP + '/exportTS') setParameter(myAircraft, nameC, nameP, valueP, factorP, statusP, exportP) countP += 1 else: break countD += 1 else: break countC += 1 else: break
def cpacsImport(self, path='.\\cpacs.xml', TIXIHandle=None, TIGLHandle=None): ''' Overwrites the parameters cpacsImport method! Imports the enginePerformanceMap This method replaces the initial calc method by calcCPACS sfcCR will not be set fix because ongoing interpolation is necessary to find the correct values ''' if not TIXIHandle: TIXIHandle = openTIXI(path) if checkElement(TIXIHandle, '/cpacs/vehicles/engines/engine[last()]/analysis/performanceMaps/performanceMap'): # Get performanceMap from CPACS Tmap = getText(TIXIHandle, "/cpacs/vehicles/engines/engine[last()]/analysis/performanceMaps/performanceMap/thrust").split( ';') Mamap = getText(TIXIHandle, "/cpacs/vehicles/engines/engine[last()]/analysis/performanceMaps/performanceMap/machNumber").split( ';') FLmap = getText(TIXIHandle, "/cpacs/vehicles/engines/engine[last()]/analysis/performanceMaps/performanceMap/flightLevel").split( ';') mDotmap = getText(TIXIHandle, "/cpacs/vehicles/engines/engine[last()]/analysis/performanceMaps/performanceMap/mDotFuel").split( ';') #Pop Last entries because of garbage FLmap.pop() mDotmap.pop() Tmap.pop() Mamap.pop() #Conversion FLmap = [float(val) for val in FLmap] Mamap = [float(val) for val in Mamap] Tmap = [float(val) for val in Tmap] mDotmap = [float(val) for val in mDotmap] #Dummies maList = [] flList = [] thList = [] #Go Through complete Data Set for i in range(len(FLmap)): thList.append([Tmap[i - 1], mDotmap[i - 1]]) if Mamap[i] != Mamap[i - 1]: maList.append([Mamap[i - 1], thList]) thList = [] if FLmap[i] != FLmap[i - 1]: flList.append([FLmap[i - 1], maList]) maList = [] # Final List of List of List for the engine deck self.TList = flList #set calcTWDat as the new Calculation method self.calc = self.calcCPACS self.monkeyPatch('CPACS') else: self.importError()
def importGUI(myAircraft,path): ''' This is an import routine for simple input from the tool-specific part of a CPACS file. This also reads all information that can be generated by the simple GUI available in the binary version of VAMPzero It takes an *aircraft* as input. This is necessary to set the values in the aircraft according to the information given in *path*. Usually *path* is specified as ./ToolInput/toolInput.xml ''' log = zeroLogger('General') log.info('') log.info("##############################################################################") log.info('VAMPzero GUI: importing GUI Values from: %s'%path) log.info("reading toolspecific/GUI inputs") log.info("##############################################################################") myAircraft.modelUID.cpacsImport(path) if myAircraft.modelUID.getValue() != '': log.info('VAMPzero GUI: Running with: %s as modelUID.'%myAircraft.modelUID.getValue()) else: log.warning('VAMPzero GUI: No valid information for modelUID!') TIXIHandle = openTIXI(path) cpacsVal = c_char_p() top = "/cpacs/toolspecific/vampZero/components/" ##Component############################################################# countC = 1 while 1==1: pathC = top+'component['+str(countC)+']' if checkElement(TIXIHandle,pathC): nameC = getText(TIXIHandle, pathC+'/name') if nameC: log.debug('VAMPzero GUI: importing for component: %s'%nameC) else: break ##Discipline############################################################# countD = 1 while 1==1: pathD = pathC+'/disciplines/discipline['+str(countD)+']' if checkElement(TIXIHandle,pathD): ##Parameter############################################################# countP = 1 while 1==1: pathP = pathD+'/parameters/parameter['+str(countP)+']' if checkElement(TIXIHandle,pathP): nameP = getText(TIXIHandle,pathP+'/name') valueP = getText(TIXIHandle,pathP+'/value') factorP = getText(TIXIHandle,pathP+'/factor') statusP = getText(TIXIHandle,pathP+'/status') exportP = getText(TIXIHandle,pathP+'/exportTS') setParameter(myAircraft, nameC, nameP, valueP, factorP, statusP, exportP) countP += 1 else: break countD += 1 else: break countC += 1 else: break
class Vampzero(object): ''' This class implements a convenience interface to setup a VAMPzero run. ''' def __init__(self, cpacsIn=None, cpacsOut=None, resultFile=None, resultOnErrorFile=None): ''' Initialize VAMPzero with standard properties. ''' if cpacsIn == None: cpacsIn = "./ToolInput/toolInput.xml" self.cpacsIn = cpacsIn if cpacsOut == None: cpacsOut = "./ToolOutput/toolOutput.xml" self.cpacsOut = cpacsOut if resultFile == None: resultFile = "./ReturnDirectory/VAMPzero.m" self.resultFile = resultFile if resultOnErrorFile == None: resultOnErrorFile = "./ReturnDirectory/ResultOnError.m" self.resultOnErrorFile = resultOnErrorFile self.args = None self.config = {} self.aircraft = aircraftLib.aircraft() self.initParser() def readConfig(self): ''' Read VAMPzeros configuration parameters. Command line arguments overwrite the configurations in the toolspecific part. ''' TIXIHandle = tixiLib.openTIXI(self.cpacsIn) if self.args.d != None: self.config['deviationAmplitude'] = float(self.args.d) else: devFactor = 0.0 devFactorStr = tixiLib.getText( TIXIHandle, '/cpacs/toolspecific/vampZero/toolSettings/deviationAmplitude') if devFactorStr != None: devFactor = float(devFactorStr) self.config['deviationAmplitude'] = devFactor # read configuration for extended output self.config['extendedOutput'] = True extendedOutput = tixiLib.getText( TIXIHandle, '/cpacs/toolspecific/vampZero/toolSettings/extendedOutput') if extendedOutput in ('False', 'false', '0.0', '0.', '0'): self.config['extendedOutput'] = False # read sensitivity configuration self.config['calcSensitivities'] = False calcSensitivities = tixiLib.getText( TIXIHandle, '/cpacs/toolspecific/vampZero/toolSettings/calcSensitivities') if calcSensitivities in ('True', 'true', '1.0', '1.', '1'): self.config['calcSensitivities'] = True # read not converging behavior self.config['notConvergingAction'] = 'exit' not_converging_action = tixiLib.getText( TIXIHandle, '/cpacs/toolspecific/vampZero/toolSettings/notConvergingAction') if not_converging_action in ('exit', 'copyInput', 'errorXML'): self.config['notConvergingAction'] = not_converging_action tixiLib.closeXML(TIXIHandle) def initParser(self): ''' Initializes the argument parser to process command line arguments. ''' #usage = "usage: %prog [options] arg1 arg2\n\ttype '%prog --help' for help" self.parser = argparse.ArgumentParser(prog='VAMPzero') self.parser.add_argument('-m', action='store_true', help='import Matlab') self.parser.add_argument('-d', default=None, help='calculate deviation') # self.parser.add_argument('--no_plots', action='store_false', help='deactivates plotting') def run(self, argv=None): ''' Runs VAMPzero. ''' if argv is None: argv = sys.argv try: generalLib.printHeader() print argv self.args = self.parser.parse_args() self.readConfig() ################################################################################################### ##VAMPzero Initialize ################################################################################################### self.aircraft.engine.sfcCR.calc = self.aircraft.engine.sfcCR.calcOverallEff self.setFixed() ################################################################################################### ##VAMPzero Imports ################################################################################################### if self.args.m: importMatlabLib.importMatlab(self.aircraft) else: guiLib.importGUI(self.aircraft, self.cpacsIn) tixiHandle = tixiLib.openTIXI(self.cpacsIn) hasModel = tixiLib.checkElement(tixiHandle, '/cpacs/vehicles/aircraft/model') if hasModel: self.aircraft.cpacsImport(self.cpacsIn) self.aircraft.atmosphere.hCR.setValueFix( self.aircraft.altCR.getValue()) self.aircraft.atmosphere.MaCR.setValueFix( self.aircraft.machCR.getValue()) self.calc() self.finish() self.setUIDs() self.exportToolspecific( ) # needs to be called after the last use of cpacsLib (otherwise all nodes not in the schema will be removed) generalLib.printFooter() return 0 except (argparse.ArgumentError), err: print >> sys.stderr, err self.parser.print_help() return 2 except (NotConvergingError), err: # write output to help with debugging exportLib.resultExport(self.aircraft, self.resultOnErrorFile, componentWise=True) if self.config['notConvergingAction'] in ('copyInput'): shutil.copyfile(self.cpacsIn, self.cpacsOut) TIXIHandle = tixiLib.openTIXI(self.cpacsOut) tixiLib.addText( TIXIHandle, '/cpacs/toolspecific/vampZero/toolSettings/exitCondition', 'NOT CONVERGED') tixiLib.saveXML(self.cpacsOut, TIXIHandle) tixiLib.closeXML(TIXIHandle) elif self.config['notConvergingAction'] in ('errorXML'): with open(self.cpacsOut, 'w') as outfile: outfile.write( '<cpacs><exitCondition>NOT CONVERGING</exitCondition></cpacs>' ) elif self.config['notConvergingAction'] in ('tryExportLastState'): self.finish() self.setUIDs() self.exportToolspecific() sys.exit() #@note: enter exit code here