def resultExport(component, path, componentWise=True): ''' This function exports the given component to the file given by the path parameter. @author: Jonas Jepsen @param component: component for export @param path: path to export file ''' log = zeroLogger('resultExport') log.info('') log.info( "##############################################################################" ) log.info("VAMPzero Result Export to %s" % (path)) log.info( "##############################################################################" ) #reset outfile try: remove(path) except: pass outfile = open(path, 'w') for para in component.getParameters(componentWise): if hasattr(para, 'resultExport'): # check should not be necessary para.resultExport(outfile) outfile.close() log.info("VAMPzero RESULT EXPORT: done.")
def cpacsExport(component, path=".\\cpacs.xml"): """ This function exports the given component to the file given by the path parameter. @author: Jonas Jepsen @param component: component for export @param path: path to export file """ log = zeroLogger("cpacsExport") log.info("") log.info("##############################################################################") log.info("VAMPzero CPACS Export to %s" % (path)) log.info("##############################################################################") # reset outfile try: remove(path) except: pass outfile = open(path, "w") outfile.writelines(["<cpacs></cpacs>"]) outfile.close() # pars CPACS export file CPACSObj = parse(path) component.cpacsExport(CPACSObj) outfile = open(path, "w") # outfile.write('<?xml version="1.0" encoding="UTF-8"?>'+"\n") CPACSObj.export(outfile, 0) outfile.close() log.info("VAMPzero CPACS EXPORT: done.")
def resultExport(component, path, componentWise=True): """ This function exports the given component to the file given by the path parameter. @author: Jonas Jepsen @param component: component for export @param path: path to export file """ log = zeroLogger("resultExport") log.info("") log.info("##############################################################################") log.info("VAMPzero Result Export to %s" % (path)) log.info("##############################################################################") # reset outfile try: remove(path) except: pass outfile = open(path, "w") for para in component.getParameters(componentWise): if hasattr(para, "resultExport"): # check should not be necessary para.resultExport(outfile) outfile.close() log.info("VAMPzero RESULT EXPORT: done.")
def setParameter(myAircraft, nameC, nameP, valueP, factorP, statusP, exportP): ''' will try to set a value from importGUI input ''' nameMappingDict = { 'Htpairfoil': ['htp', 'htpairfoil'], 'Vtpairfoil': ['vtp', 'vtpairfoil'], 'Wingairfoil': ['wing', 'wingairfoil'], 'Aircraft': [], 'Flap': ['wing', 'flap'], 'Landinggear': ['landingGear'], '': [] } nameCList = [] if nameC not in nameMappingDict.keys(): nameCList = nameC.lower().strip('.').split('.') else: nameCList = nameMappingDict[nameC] log = zeroLogger('General') myList = nameCList + [nameP] param = getParameter(myAircraft, myList) if factorP != '' and not factorP is None: try: log.debug('VAMPzero GUI: setting factor of %s to %s' % ('.'.join(myList), factorP)) param.setFactor(float(factorP)) except: log.warning('VAMPzero GUI: no success in setting factor of %s' % '.'.join(myList)) if valueP != '' and not valueP is None: try: log.debug('VAMPzero GUI: setting value of %s to %s' % ('.'.join(myList), valueP)) param.setValueFix(float(valueP)) except: log.warning('VAMPzero GUI: no success in setting value of %s' % '.'.join(myList)) if statusP != '' and not statusP is None: try: log.debug('VAMPzero GUI: setting status of %s to %s' % ('.'.join(myList), statusP)) param['status'] = statusP except: log.warning('VAMPzero GUI: no success in setting status of %s' % '.'.join(myList)) if exportP in ('true', 'True', '1.0', '1.', '1'): try: log.debug('VAMPzero GUI: setting exportTS of %s to True' % ('.'.join(myList))) param['exportTS'] = True except: log.warning('VAMPzero GUI: no success in setting exportTS of %s' % '.'.join(myList))
def __init__(self,zeroTree,prefix=''): self.log = zeroLogger('SchemaHandler') self.out = [] self.log.info('VAMPzero SCHEMA Created an object of toolSpecificSchema') self.log.info('VAMPzero SCHEMA Starting to create toolSpecificSchema') self.convertZeroTree(zeroTree, prefix)
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 setParameter(myAircraft, nameC, nameP, valueP, factorP, statusP, exportP): ''' will try to set a value from importGUI input ''' nameMappingDict = {'Htpairfoil': ['htp', 'htpairfoil'], 'Vtpairfoil': ['vtp', 'vtpairfoil'], 'Wingairfoil': ['wing', 'wingairfoil'], 'Aircraft': [], 'Flap': ['wing', 'flap'], 'Landinggear': ['landingGear'], 'LandingGear': ['landingGear'], '': []} nameCList = [] if nameC not in nameMappingDict.keys(): nameCList = nameC.lower().strip('.').split('.') else: nameCList = nameMappingDict[nameC] log = zeroLogger('General') myList = nameCList + [nameP] param = getParameter(myAircraft, myList) if factorP != '' and not factorP is None: try: log.debug('VAMPzero GUI: setting factor of %s to %s' %('.'.join(myList), factorP)) param.setFactor(float(factorP)) except: log.warning('VAMPzero GUI: no success in setting factor of %s'%'.'.join(myList)) if valueP != '' and not valueP is None: try: log.debug('VAMPzero GUI: setting value of %s to %s' %('.'.join(myList), valueP)) param.setValueFix(float(valueP)) except: log.warning('VAMPzero GUI: no success in setting value of %s'%'.'.join(myList)) if statusP != '' and not statusP is None: try: log.debug('VAMPzero GUI: setting status of %s to %s' %('.'.join(myList), statusP)) param['status'] = statusP except: log.warning('VAMPzero GUI: no success in setting status of %s'%'.'.join(myList)) if exportP in ('true', 'True', '1.0', '1.', '1'): try: log.debug('VAMPzero GUI: setting exportTS of %s to True' %('.'.join(myList))) param['exportTS'] = True except: log.warning('VAMPzero GUI: no success in setting exportTS of %s'%'.'.join(myList))
def createXML(path): ''' Creates an XML File specified by Path Location TIXI Handle must be given ''' log = zeroLogger('TIXI') TIXIHandle = c_int(2) error = TIXI.tixiCreateDocument(path, byref(TIXIHandle)) if error: log.warning("VAMPzero TIXI: document could not be created %s" %path) return TIXIHandle
def importMatlab(myAircraft, path="./ToolInput/toolInput.m"): ''' This is an import routine for simple input from an m-File. m Files can be created using Matlab. This import routine enables users to loop VAMPzero easily by placing input statements into the file specified by the path parameter. 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.m The structure of the m-File should be a simple as possible. It will be just a plain list of values. The value names are a combination of component and parameter. For each parameter their may be an additional factor: *aircraft.mTOM=73500; *engine.sfcCR.factor=0.97; This would result in a new maximum takeofff weight of 73.5t and a calibration factor for the SFC of the engine in cruise condition of 0.97 ''' log = zeroLogger('General') log.info('') log.info( "##############################################################################" ) log.info('VAMPzero MATLAB: importing values from: %s' % path) log.info("reading matlab inputs") log.info( "##############################################################################" ) myFile = open(path, 'r') myLines = myFile.readlines() for line in myLines: valueP = '' factorP = '' backup = line nameC = line.split('.')[0] nameP = line.split('.')[1].split('=')[0] if line.find('factor') != -1: factorP = backup.split('=')[1].replace(';', '') else: valueP = backup.split('=')[1].replace(';', '') setParameter(myAircraft, nameC, nameP, valueP, factorP)
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 importMatlab(myAircraft,path="./ToolInput/toolInput.m"): ''' This is an import routine for simple input from an m-File. m Files can be created using Matlab. This import routine enables users to loop VAMPzero easily by placing input statements into the file specified by the path parameter. 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.m The structure of the m-File should be a simple as possible. It will be just a plain list of values. The value names are a combination of component and parameter. For each parameter their may be an additional factor: *aircraft.mTOM=73500; *engine.sfcCR.factor=0.97; This would result in a new maximum takeofff weight of 73.5t and a calibration factor for the SFC of the engine in cruise condition of 0.97 ''' log = zeroLogger('General') log.info('') log.info("##############################################################################") log.info('VAMPzero MATLAB: importing values from: %s'%path) log.info("reading matlab inputs") log.info("##############################################################################") myFile = open(path,'r') myLines = myFile.readlines() for line in myLines: valueP = '' factorP = '' backup = line nameC = line.split('.')[0] nameP = line.split('.')[1].split('=')[0] if line.find('factor')!=-1: factorP = backup.split('=')[1].replace(';','') else: valueP = backup.split('=')[1].replace(';','') setParameter(myAircraft, nameC, nameP, valueP,factorP)
def setParameter(myAircraft, nameC, nameP, valueP, factorP): ''' will try to set a value from importGUI input ''' nameC = nameC.capitalize() if not cmp(nameC, 'Htpairfoil'): nameC = 'htp.htpairfoil' if not cmp(nameC, 'Vtpairfoil'): nameC = 'vtp.vtpairfoil' if not cmp(nameC, 'Wingairfoil'): nameC = 'wing.wingairfoil' if not cmp(nameC, 'Aircraft'): nameC = '' if not cmp(nameC, 'Landinggear'): nameC = 'landingGear.' if not cmp(nameC, '') == 0 and not cmp(nameC, 'landingGear.') == 0: nameC = nameC.lower() + '.' log = zeroLogger('General') if factorP != '' and not factorP is None: try: command = str('myAircraft.' + nameC + nameP + '.setFactor(' + factorP + ')') log.debug('VAMPzero MATLAB: executing %s' % command) exec command except: log.warning('VAMPzero MATLAB: no success in: %s' % command) if valueP != '' and not valueP is None: try: command = str('myAircraft.' + nameC + nameP + '.setValueFix(' + valueP + ')') log.debug('VAMPzero MATLAB: executing %s' % command) exec command except: log.warning('VAMPzero MATLAB: no success in: %s' % command)
def setParameter(myAircraft,nameC,nameP,valueP,factorP): ''' will try to set a value from importGUI input ''' nameC = nameC.capitalize() if not cmp(nameC, 'Htpairfoil'): nameC='htp.htpairfoil' if not cmp(nameC, 'Vtpairfoil'): nameC='vtp.vtpairfoil' if not cmp(nameC, 'Wingairfoil'): nameC='wing.wingairfoil' if not cmp(nameC, 'Aircraft'): nameC='' if not cmp(nameC, 'Landinggear'): nameC='landingGear.' if not cmp(nameC,'')==0 and not cmp(nameC,'landingGear.')==0: nameC = nameC.lower()+'.' log = zeroLogger('General') if factorP != '' and not factorP is None: try: command = str('myAircraft.'+nameC+nameP+'.setFactor('+factorP+')') log.debug('VAMPzero MATLAB: executing %s'%command) exec command except: log.warning('VAMPzero MATLAB: no success in: %s'%command) if valueP != '' and not valueP is None: try: command = str('myAircraft.'+nameC+nameP+'.setValueFix('+valueP+')') log.debug('VAMPzero MATLAB: executing %s'%command) exec command except: log.warning('VAMPzero MATLAB: no success in: %s'%command)
def cpacsExport(component, path='.\\cpacs.xml'): ''' This function exports the given component to the file given by the path parameter. @author: Jonas Jepsen @param component: component for export @param path: path to export file ''' log = zeroLogger('cpacsExport') log.info('') log.info( "##############################################################################" ) log.info("VAMPzero CPACS Export to %s" % (path)) log.info( "##############################################################################" ) #reset outfile try: remove(path) except: pass outfile = open(path, 'w') outfile.writelines(['<cpacs></cpacs>']) outfile.close() # pars CPACS export file CPACSObj = parse(path) component.cpacsExport(CPACSObj) outfile = open(path, 'w') #outfile.write('<?xml version="1.0" encoding="UTF-8"?>'+"\n") CPACSObj.export(outfile, 0) outfile.close() log.info("VAMPzero CPACS EXPORT: done.")
stringBaseType, stringUIDBaseType, wingComponentSegmentStructureType from VAMPzero.Lib.Log.log import zeroLogger from math import pi, tan, sqrt, ceil from types import NoneType import scipy.interpolate import sys from VAMPzero.Handler.Parameter import parameter from VAMPzero.Lib.CPACS.Export.Wing.Structure.functions import createShell, \ createSpars, createRibs from VAMPzero.Lib.CPACS.Export.Wing.ControlSurface.Track.track import createTracks from VAMPzero.Lib.CPACS.Export.Wing.ControlSurface.Path.path import createPath from VAMPzero.Lib.CPACS.Export.Wing.ControlSurface.CruiseRoller.cruiseRoller import createCruiseRollers rad = pi / 180. log = zeroLogger('Flap') def calcChordLengthAtEta(eta, parentWingVAMPzero, parentWingCPACS): ''' A function to calculate the absolute length of the wings chord depending on the relative eta coordinate. This function is valid for the export case of the adv double trapezoid wing The parentWingVAMPzero is a VAMPzero wing component, not a CPACS vile ''' cRoot = eval(parentWingCPACS.get_sections().get_section()[0].get_transformation().get_scaling().get_x().valueOf_) cKink = eval(parentWingCPACS.get_sections().get_section()[2].get_transformation().get_scaling().get_x().valueOf_) cTip = eval(parentWingCPACS.get_sections().get_section()[3].get_transformation().get_scaling().get_x().valueOf_) etaFus = parentWingVAMPzero.yFuselage.getValue() / parentWingVAMPzero.span.getValue() / 2. etaKink= parentWingVAMPzero.etaKink.getValue() # if eta lies at the fuselage than return cRoot if eta <= etaFus:
def __init__(self): # Used for Logging Stuff self.log = zeroLogger('Component')
import inspect import sys import time from numpy.lib.function_base import interp from VAMPzero.Lib.Log.log import zeroLogger global t0 rad = pi / 180. log = zeroLogger('General') def printHeader(): #choosing the appropriate splitter for the running filename if sys.platform == 'win32': splitter = '\\' else: splitter = '/' log.info("##############################################################################") log.info(" VAMPzero ") log.info(" Conceptual design as it should be ") log.info(" ") log.info(" Licensed under the Apache License, Version 2.0 ")
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Copyright: Deutsches Zentrum fuer Luft- und Raumfahrt e.V., 2015 (c) Contact: [email protected] and [email protected] ''' from ctypes import cdll, byref, CDLL, c_int, c_double, util #todo: windll Handler is not available in Linux import sys, os from VAMPzero.Lib.Log.log import zeroLogger from math import pi log = zeroLogger('TIGL') # open TIXI and TIGL shared libraries if sys.platform == 'win32' or sys.platform == 'win64': os.environ['PATH'] = os.path.dirname( sys.executable) + "\shared" + ';' + os.environ['PATH'] log.debug("VAMPzero TIGL: Assuming this is windows") log.debug("VAMPzero TIGL: trying to load TIGL from sys.PATH") try: TIGL = cdll.TIGL except WindowsError, e: log.warning("VAMPzero TIGL: could not load TIGL from sys.PATH; %s" % e) try: from ctypes import windll TIGL = windll.LoadLibrary('TIGL.dll') except WindowsError, e:
''' from VAMPzero.Lib.CPACS.Export.Wing.ControlSurface.Flap.Flap import \ calcChordLengthAtEta from VAMPzero.Lib.CPACS.Export.export import getObjfromXpath from VAMPzero.Lib.CPACS.cpacs import controlSurfaceBorderLeadingEdgeType, \ leadingEdgeShapeType, doubleBaseType, controlSurfacesType, \ controlSurfaceOuterShapeLeadingEdgeType, stringBaseType, leadingEdgeDevicesType, \ leadingEdgeDeviceType, stringUIDBaseType from math import pi, ceil from types import NoneType from VAMPzero.Lib.Log.log import zeroLogger from VAMPzero.Lib.CPACS.Export.Wing.ControlSurface.Path.path import createPath rad = pi / 180. log = zeroLogger('Slat') 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()
from VAMPzero.Lib.CPACS.Export.export import getObjfromXpath from VAMPzero.Lib.CPACS.cpacs import controlSurfaceBorderSpoilerType, \ leadingEdgeShapeType, doubleBaseType, controlSurfacesType, \ controlSurfaceOuterShapeSpoilerType, stringBaseType, leadingEdgeDevicesType, \ leadingEdgeDeviceType, stringUIDBaseType, spoilersType, \ wingComponentSegmentStructureType, spoilerType from math import pi, ceil, tan, atan, sin, cos from types import NoneType import scipy.interpolate from VAMPzero.Lib.Log.log import zeroLogger from VAMPzero.Lib.CPACS.Export.Wing.Structure.functions import createShell, \ createSpars, createRibs rad = pi / 180. log = zeroLogger('Spoiler') 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 = []
def __init__(self, component): self.log = zeroLogger('outMapping') self.log.info('VAMPzero MAP: Created an Instance of outMapping') self.log.info('VAMPzero MAP: Creating mappingOut.xml') self.createMapping(component)
calcChordLengthAtEta from VAMPzero.Lib.CPACS.Export.export import getObjfromXpath from VAMPzero.Lib.CPACS.cpacs import controlSurfaceBorderSpoilerType, \ leadingEdgeShapeType, doubleBaseType, controlSurfacesType, \ controlSurfaceOuterShapeSpoilerType, stringBaseType, leadingEdgeDevicesType, \ leadingEdgeDeviceType, stringUIDBaseType, spoilersType, \ wingComponentSegmentStructureType, spoilerType from math import pi, ceil, tan, atan, sin, cos from types import NoneType import scipy.interpolate from VAMPzero.Lib.Log.log import zeroLogger from VAMPzero.Lib.CPACS.Export.Wing.Structure.functions import createShell, \ createSpars, createRibs rad = pi / 180. log = zeroLogger('Spoiler') 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]
def __init__(self, value=0.0, unit='', status='init', doc='Default Doc', factor=1., cpacsPath='', name='', parent='', **kwargs): def setname(me): ''' Returns the name of the parameter from its type definition ''' return str(type(me)).split('\'')[1].split('.')[-1] def setparent(me): ''' finds the parent component from the caller frames This will only work if a parameter is constructed from a component not from a toplevel script first frame is this function second is the constructor of the parameter third is the component ''' try: frame = inspect.currentframe().f_back.f_back.f_back.f_locals except: me.log.warning( 'VAMPzero CONSTRUCTOR: Could not find parent for : %s: ' % me.getName()) try: caller = frame['self'] except: caller = None me.log.warning( 'VAMPzero CONSTRUCTOR: Could not find parent for : %s: ' % me.getName()) if issubclass(type(caller), VAMPzero.Handler.Component.component): return caller else: # try the same for one frame more if there is no parameter specific constructor # note: this could probably done recursively as it goes done more frames, but I would # think this may end in loops to quick try: frame = inspect.currentframe().f_back.f_back.f_locals except: me.log.warning( 'VAMPzero CONSTRUCTOR: Could not find parent for : %s: ' % me.getName()) try: caller = frame['self'] except: me.log.warning( 'VAMPzero CONSTRUCTOR: Could not find parent for : %s: ' % me.getName()) if issubclass(type(caller), VAMPzero.Handler.Component.component): return caller self.log = zeroLogger(setname(self)) self.parent = parent self["value"] = value # The parameters value self[ "unit"] = unit # it's unit, if possible please stick to metric units self["status"] = status # it's status, init,calc or fix self["doc"] = doc # the documentation string self["factor"] = factor # the technology factor self["cpacsPath"] = cpacsPath # the cpacsPath in X-Path notation self["caller"] = [ ] # a list of parameters who's calculations called the parameter self["callee"] = [ ] # a list of parameters that have been called by this parameter self["history"] = [] # the calculation history self["history"].append(self["value"]) self["name"] = setname(self) self["stdDeviation"] = None self["devFactor"] = random.gauss(0.0, 1.0) # (mean, std deviation) self["exportTS"] = False # get the discipline from the folder name! discipline = inspect.stack()[1][1].split(splitter)[-2] self["discipline"] = discipline if parent == "": self.parent = setparent(self) else: self.parent = parent self.longName = self.parent.id + '.' + self['name'] self.count = 0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Copyright: Deutsches Zentrum fuer Luft- und Raumfahrt e.V., 2015 (c) Contact: [email protected] and [email protected] ''' from ctypes import cdll, byref, CDLL, c_int, c_double, util #todo: windll Handler is not available in Linux import sys, os from VAMPzero.Lib.Log.log import zeroLogger from math import pi log = zeroLogger('TIGL') # open TIXI and TIGL shared libraries if sys.platform == 'win32' or sys.platform =='win64': os.environ['PATH'] = os.path.dirname(sys.executable)+"\shared" + ';' + os.environ['PATH'] log.debug("VAMPzero TIGL: Assuming this is windows") log.debug("VAMPzero TIGL: trying to load TIGL from sys.PATH") try: TIGL = cdll.TIGL except WindowsError, e: log.warning("VAMPzero TIGL: could not load TIGL from sys.PATH; %s" % e) try: from ctypes import windll TIGL = windll.LoadLibrary('TIGL.dll') except WindowsError, e: log.warning("VAMPzero TIGL: could not load TIGL from ./shared Folder; %s" % e)
''' from VAMPzero.Lib.CPACS.Export.Wing.ControlSurface.Flap.Flap import \ calcChordLengthAtEta from VAMPzero.Lib.CPACS.Export.export import getObjfromXpath from VAMPzero.Lib.CPACS.cpacs import controlSurfaceBorderLeadingEdgeType, \ leadingEdgeShapeType, doubleBaseType, controlSurfacesType, \ controlSurfaceOuterShapeLeadingEdgeType, stringBaseType, leadingEdgeDevicesType, \ leadingEdgeDeviceType, stringUIDBaseType from math import pi, ceil from types import NoneType from VAMPzero.Lib.Log.log import zeroLogger from VAMPzero.Lib.CPACS.Export.Wing.ControlSurface.Path.path import createPath rad = pi / 180. log = zeroLogger('Slat') 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
limitations under the License. Copyright: Deutsches Zentrum fuer Luft- und Raumfahrt e.V., 2015 (c) Contact: [email protected] and [email protected] ''' from ctypes import cdll, byref, CDLL, c_int, c_char_p import sys import os from VAMPzero.Lib.Log.log import zeroLogger from VAMPzero.Lib.CPACS.general import evalList # open TIXI and TIGL shared libraries log = zeroLogger('TIXI') if sys.platform == 'win32': os.environ['PATH'] = os.path.dirname(sys.executable)+"\shared" + ';' + os.environ['PATH'] log.debug("VAMPzero TIXI: Assuming this is windows") log.debug("VAMPzero TIXI: trying to load TIXI from sys.PATH") try: TIXI = cdll.TIXI except WindowsError, e: print e log.warning("VAMPzero TIXI: could not load TIXI from sys.PATH") try: from ctypes import windll TIXI = windll.LoadLibrary('TIXI.dll')
def __init__(self, value=0.0, unit='', status='init', doc='Default Doc', factor=1., cpacsPath='', name='', parent='', **kwargs): def setname(me): ''' Returns the name of the parameter from its type definition ''' return str(type(me)).split('\'')[1].split('.')[-1] def setparent(me): ''' finds the parent component from the caller frames This will only work if a parameter is constructed from a component not from a toplevel script first frame is this function second is the constructor of the parameter third is the component ''' try: frame = inspect.currentframe().f_back.f_back.f_back.f_locals except: me.log.warning('VAMPzero CONSTRUCTOR: Could not find parent for : %s: ' % me.getName()) try: caller = frame['self'] except: caller = None me.log.warning('VAMPzero CONSTRUCTOR: Could not find parent for : %s: ' % me.getName()) if issubclass(type(caller), VAMPzero.Handler.Component.component): return caller else: # try the same for one frame more if there is no parameter specific constructor # note: this could probably done recursively as it goes done more frames, but I would # think this may end in loops to quick try: frame = inspect.currentframe().f_back.f_back.f_locals except: me.log.warning('VAMPzero CONSTRUCTOR: Could not find parent for : %s: ' % me.getName()) try: caller = frame['self'] except: me.log.warning('VAMPzero CONSTRUCTOR: Could not find parent for : %s: ' % me.getName()) if issubclass(type(caller), VAMPzero.Handler.Component.component): return caller self.log = zeroLogger(setname(self)) self.parent = parent self["value"] = value # The parameters value self["unit"] = unit # it's unit, if possible please stick to metric units self["status"] = status # it's status, init,calc or fix self["doc"] = doc # the documentation string self["factor"] = factor # the technology factor self["cpacsPath"] = cpacsPath # the cpacsPath in X-Path notation self["caller"] = [] # a list of parameters who's calculations called the parameter self["callee"] = [] # a list of parameters that have been called by this parameter self["history"] = [] # the calculation history self["history"].append(self["value"]) self["name"] = setname(self) self["stdDeviation"] = None self["devFactor"] = random.gauss(0.0, 1.0) # (mean, std deviation) self["exportTS"] = False # get the discipline from the folder name! discipline = inspect.stack()[1][1].split(splitter)[-2] self["discipline"] = discipline if parent == "": self.parent = setparent(self) else: self.parent = parent self.longName = self.parent.id + '.' + self['name'] self.count = 0
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
Copyright: Deutsches Zentrum fuer Luft- und Raumfahrt e.V., 2015 (c) Contact: [email protected] and [email protected] ''' from math import pi, sqrt import inspect import sys import time from numpy.lib.function_base import interp from VAMPzero.Lib.Log.log import zeroLogger global t0 rad = pi / 180. log = zeroLogger('General') def printHeader(): #choosing the appropriate splitter for the running filename if sys.platform == 'win32': splitter = '\\' else: splitter = '/' log.info( "##############################################################################" ) log.info( " VAMPzero ")
controlSurfacesType, trailingEdgeDevicesType, controlSurfaceOuterShapeTrailingEdgeType, \ stringBaseType, stringUIDBaseType, wingComponentSegmentStructureType from VAMPzero.Lib.Log.log import zeroLogger from math import pi, tan, sqrt, ceil from types import NoneType import scipy.interpolate import sys from VAMPzero.Handler.Parameter import parameter from VAMPzero.Lib.CPACS.Export.Wing.Structure.functions import createShell, \ createSpars, createRibs from VAMPzero.Lib.CPACS.Export.Wing.ControlSurface.Track.track import createTracks from VAMPzero.Lib.CPACS.Export.Wing.ControlSurface.Path.path import createPath from VAMPzero.Lib.CPACS.Export.Wing.ControlSurface.CruiseRoller.cruiseRoller import createCruiseRollers rad = pi / 180. log = zeroLogger('Flap') def calcChordLengthAtEta(eta, parentWingVAMPzero, parentWingCPACS): ''' A function to calculate the absolute length of the wings chord depending on the relative eta coordinate. This function is valid for the export case of the adv double trapezoid wing The parentWingVAMPzero is a VAMPzero wing component, not a CPACS vile ''' cRoot = eval(parentWingCPACS.get_sections().get_section() [0].get_transformation().get_scaling().get_x().valueOf_) cKink = eval(parentWingCPACS.get_sections().get_section() [2].get_transformation().get_scaling().get_x().valueOf_) cTip = eval(parentWingCPACS.get_sections().get_section() [3].get_transformation().get_scaling().get_x().valueOf_)
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