def setContribution(dataFile, nLines, keyWord, iDoNot, verbose): from numpy import size from polarSweepLib import parLocator import string # # default values # nameText = '' removeContribution = False # #----Determine if a given amily contribute to force # # Start by locating lines setting contribution # keyWord = keyWord.lower() ipar = parLocator(keyWord, dataFile, nLines, iDoNot, verbose) if ipar == -1: if verbose: print ' failed to locate ' + keyWord + ' in base input file; Set value to 1' paVal = 1 else: paLine = dataFile[ipar] icol = paLine.index(':') # Now identify the first part of this line firstPart = paLine[0:icol] # now find out where the standard text ends iBF = firstPart.lower().index('family') + 6 nameText = string.join(firstPart[iBF:].split(), "") # component name located. Now check about its contribution try: iComment = paLine.index('#') secondPart = paLine[icol + 1:iComment - 1].lower() except ValueError: secondPart = paLine[icol + 1:].lower() # find the second colon of this line icol2 = secondPart.index(':') try: iComment = secondPart.index('#') yesNoText = secondPart[icol2 + 1:iComment - 1].lower() except ValueError: yesNoText = secondPart[icol2 + 1:].lower() try: noFound = yesNoText.lower().index('no') removeContribution = True except ValueError: removeContribution = False if verbose: if ipar != -1: print ' part: ' + nameText + ' remove contribution: ' + str( removeContribution) return nameText, removeContribution, ipar
def readParameter(dataFile,nLines,keyWord,iDoNot,verbose): from numpy import size # #----read a parameter from a file-list # keyWord=keyWord.lower() ipar = parLocator(keyWord,dataFile,nLines,iDoNot,verbose) if ipar == -1: if verbose: print ' failed to locate '+keyWord+' in base input file; Set value to 1' paVal = 1 else: paLine=dataFile[ipar] icol=paLine.index(':') try: iComment=paLine.index('#') paVal=paLine[icol+1:iComment-1].lower() except ValueError: paVal=paLine[icol+1:].lower() if verbose: if ipar != -1: print keyWord+' = '+paVal return paVal,ipar
def readParameter(dataFile, nLines, keyWord, iDoNot, verbose): from numpy import size # #----read a parameter from a file-list # keyWord = keyWord.lower() ipar = parLocator(keyWord, dataFile, nLines, iDoNot, verbose) if ipar == -1: if verbose: print ' failed to locate ' + keyWord + ' in base input file; Set value to 1' paVal = 1 else: paLine = dataFile[ipar] icol = paLine.index(':') try: iComment = paLine.index('#') paVal = paLine[icol + 1:iComment - 1].lower() except ValueError: paVal = paLine[icol + 1:].lower() if verbose: if ipar != -1: print keyWord + ' = ' + paVal return paVal, ipar
def setContribution(dataFile,nLines,keyWord,iDoNot,verbose): from numpy import size from polarSweepLib import parLocator import string # # default values # nameText='' removeContribution = False # #----Determine if a given amily contribute to force # # Start by locating lines setting contribution # keyWord=keyWord.lower() ipar = parLocator(keyWord,dataFile,nLines,iDoNot,verbose) if ipar == -1: if verbose: print ' failed to locate '+keyWord+' in base input file; Set value to 1' paVal = 1 else: paLine=dataFile[ipar] icol=paLine.index(':') # Now identify the first part of this line firstPart = paLine[0:icol] # now find out where the standard text ends iBF=firstPart.lower().index('family')+6 nameText=string.join( firstPart[iBF:].split(), "") # component name located. Now check about its contribution try: iComment=paLine.index('#') secondPart=paLine[icol+1:iComment-1].lower() except ValueError: secondPart=paLine[icol+1:].lower() # find the second colon of this line icol2=secondPart.index(':') try: iComment=secondPart.index('#') yesNoText=secondPart[icol2+1:iComment-1].lower() except ValueError: yesNoText=secondPart[icol2+1:].lower() try: noFound=yesNoText.lower().index('no') removeContribution = True except ValueError: removeContribution = False if verbose: if ipar != -1: print ' part: '+nameText+' remove contribution: '+str(removeContribution) return nameText,removeContribution,ipar
def retreiveNumPar(ctrl, nc, keyWord, parType, verbose): # get the parameter from the control file. Set it to unity if not found # parType: 1 -> integer 2 -> float from polarSweepLib import parLocator # ipar = parLocator(keyWord, ctrl, nc, -1, verbose) if ipar == -1: # default value if parType == 1: parVal = 1 else: parVal = 1.0 else: PARLine = ctrl[ipar] icol = PARLine.index(':') if parType == 1: parVal = int(PARLine[icol + 1:]) else: parVal = float(PARLine[icol + 1:]) return parVal
def retreiveNumPar(ctrl,nc,keyWord,parType,verbose): # get the parameter from the control file. Set it to unity if not found # parType: 1 -> integer 2 -> float from polarSweepLib import parLocator # ipar = parLocator(keyWord,ctrl,nc,-1,verbose) if ipar == -1: # default value if parType == 1: parVal = 1 else: parVal = 1.0 else: PARLine=ctrl[ipar] icol=PARLine.index(':') if parType == 1: parVal= int(PARLine[icol+1:]) else: parVal=float(PARLine[icol+1:]) return parVal
def updatedControlFile(ctrl, nc, parAngle, ctrlFile, verbose): # generate a modified control file for case with addRun options from polarSweepLib import parLocator, readList import os # #-- get a proper list of updated parameter-angle st1 = str(parAngle) updatedAngleList = st1[1:-1] # Now let us find out which angles are specified in the control file, to figure out polarSweepType and polarVar # keyWordListAOA = 'angles of attack' iListAOA = parLocator(keyWordListAOA, ctrl, nc, -1, verbose) keyWordListPhi = 'roll angles' iListPhi = parLocator(keyWordListPhi, ctrl, nc, -1, verbose) keyWordListBeta = 'side slip angle' iListBeta = parLocator(keyWordListBeta, ctrl, nc, -1, verbose) keyWordListMRN = 'mach ramp numbers' iListMRN = parLocator(keyWordListMRN, ctrl, nc, -1, verbose) # # Check first if this is a Mach ramp session # if iListMRN > -1: polarSweepType = 4 # This is a Mach rmp session polarVar = 'MachRampNumbers' MachList, nMach = readList(ctrl, iListMRN, verbose) # # Now check if any angle was specified # if iListBeta == -1: nBeta = 0 beta = [] velDirOption = 1 # Velocity dirction vector v(alpha,phi). May be overwritten below else: beta, nBeta = readList(ctrl, iListBeta, verbose) velDirOption = 2 # Velocity dirction vector v(alpha,beta) if nBeta > 1: raise SystemExit( 'ERROR in control file: >>>>>>>> nBeta > 1 in a Mach Ramp session <<<<<<<<' ) if iListAOA == -1: if velDirOption == 2: alpha = [0.0] nAalpha = 1 else: alpha = [] nAalpha = 0 velDirOption = 0 # No specification of Velocity dirction vector. May be overwritten below else: alpha, nAalpha = readList(ctrl, iListAOA, verbose) if nAalpha > 1: raise SystemExit( 'ERROR in control file: >>>>>>>> nAlpha > 1 in a Mach Ramp session <<<<<<<<' ) if iListPhi == -1: if velDirOption != 1: phi = [] nPhi = 0 else: phi = [0.0] nPhi = 1 else: phi, nPhi = readList(ctrl, iListPhi, verbose) if nPhi > 1: raise SystemExit( 'ERROR in control file: >>>>>>>> nPhi > 1 in a Mach Ramp session <<<<<<<<' ) if velDirOption == 0: # if phi is specified, then this is a alpha,phi case, with alpha = 0 velDirOption = 1 alpha = [0.0] nAalpha = 1 if nPhi + nBeta >= 2: raise SystemExit( 'ERROR in control file: >>>>>>>> Both phi and Beta specified (in a Mach Ramp session) <<<<<<<<' ) ctrl[iListMRN] = ' Mach ramp numbers : ' + updatedAngleList + '\n' else: # # this is not a mach ramp MachList = [] nMach = 0 if iListPhi == -1: if iListBeta == -1: polarSweepType = 1 polarVar = 'aoa' # phi/beta not found. Polar sweep in alpha for phi=beta=0 phi = [0.0] nPhi = 1 nBeta = 0 beta = [] else: # beta was found in control file, phi is not there; check how about alpha nPhi = 0 phi = [] polarSweepType = 2 polarVar = 'aoa' beta, nBeta = readList(ctrl, iListBeta, verbose) if nBeta > 1: raise SystemExit( 'ERROR in control file: nBeta > 1. For polar sweep in beta exchange pitch-axis and use aoa' ) if iListAOA == -1: raise SystemExit( 'ERROR in control file: phi and alpha are missing. Polar sweep not defined' ) alpha, nAalpha = readList(ctrl, iListAOA, verbose) ctrl[iListAOA] = ' angles of attack : ' + updatedAngleList + '\n' else: # phi was found in control file, so beta must not be there if iListBeta > -1: raise SystemExit( 'ERROR in control file: both phi and beta specified. Polar sweep not defined ' ) nBeta = 0 beta = [] # Check now if alpha appears if iListAOA == -1: # phi found in control file, but alpha is missing, so it is a polar-sweep in phi with alpha=0 polarSweepType = 3 polarVar = 'phi' alpha = [0.0] nAalpha = 1 else: # # Both alpha and phi found in control file. Find out which one is a list # alpha, nAalpha = readList(ctrl, iListAOA, verbose) if nAalpha > 1: ctrl[ iListAOA] = ' angles of attack : ' + updatedAngleList + '\n' phi, nPhi = readList(ctrl, iListPhi, verbose) if nPhi > 1: ctrl[iListPhi] = ' roll angles : ' + updatedAngleList + '\n' # Prepare a backup of control file st1 = 'cp ' + ctrlFile + ' ' + ctrlFile + '.bck' os.system(st1) # # --- Write down the updated file fc = open(ctrlFile, 'w') fc.writelines(ctrl) fc.close() print 'More cases were added. Original ctrl file saved at ' + ctrlFile + '.bck File ' + ctrlFile + ' updated' return
def setPolaraType(ctrl, nc, verbose): # scan the control file and determine polara type and angles from polarSweepLib import parLocator, readList # Determine pitch direction from control file # --------------------------------------------------- keyWordPitchAxis = 'pitch axis' iPA = parLocator(keyWordPitchAxis, ctrl, nc, -1, verbose) if iPA == -1: PA = 'z' # This is the default else: paLine = ctrl[iPA] icol = paLine.index(':') paVal = paLine[icol + 1:].lower() zFound = 'z' in paVal if zFound: PA = 'z' else: yFound = 'y' in paVal if yFound: PA = 'y' else: raise SystemExit( 'ERROR in control file: only Y or Z can be given for control keyWord ->' + keyWordPitchAxis + '<-') if verbose: print 'Pitch axis is ' + PA.upper() # # angles definitions: # alpha ... angle of attack # beta ... side-slip angle # phi ... roll angle # # Note: Actually alpha here is the angle of rotation about the above-defined pitch axis # Thus, by replacing the pitch-axis, all that is said here about alpha is actually for beta # # Several combinations of angles are possible: #------------------------------------------------ # 1. Polar-sweep in alpha per given phi ...... polarVar = aoa # 2. Polar-sweep in alpha per given beta (side slip angle) ...... polarVar = aoa # 3. Polar-sweep in phi per given alpha ...... polarVar = phi # 4. Mach ramp (single values for alpha, phi or both permitted) ... polarVar = MachRampNumbers # # Note: Seting a list of both phi and beta is impossible # For mach ramp you can specify alpha, phi (or both), but not a list of either of them # # Now let us find out which angles are specified in the control file, to figure out polarSweepType and polarVar # keyWordListAOA = 'angles of attack' iListAOA = parLocator(keyWordListAOA, ctrl, nc, -1, verbose) keyWordListPhi = 'roll angles' iListPhi = parLocator(keyWordListPhi, ctrl, nc, -1, verbose) keyWordListBeta = 'side slip angle' iListBeta = parLocator(keyWordListBeta, ctrl, nc, -1, verbose) keyWordListMRN = 'mach ramp numbers' iListMRN = parLocator(keyWordListMRN, ctrl, nc, -1, verbose) # # Check first if this is a Mach ramp session # if iListMRN > -1: polarSweepType = 4 # This is a Mach rmp session polarVar = 'MachRampNumbers' MachList, nMach = readList(ctrl, iListMRN, verbose) # # Now check if any angle was specified # if iListBeta == -1: nBeta = 0 beta = [] velDirOption = 1 # Velocity dirction vector v(alpha,phi). May be overwritten below else: beta, nBeta = readList(ctrl, iListBeta, verbose) velDirOption = 2 # Velocity dirction vector v(alpha,beta) if nBeta > 1: raise SystemExit( 'ERROR in control file: >>>>>>>> nBeta > 1 in a Mach Ramp session <<<<<<<<' ) if iListAOA == -1: if velDirOption == 2: alpha = [0.0] nAalpha = 1 else: alpha = [] nAalpha = 0 velDirOption = 0 # No specification of Velocity dirction vector. May be overwritten below else: alpha, nAalpha = readList(ctrl, iListAOA, verbose) if nAalpha > 1: raise SystemExit( 'ERROR in control file: >>>>>>>> nAlpha > 1 in a Mach Ramp session <<<<<<<<' ) if iListPhi == -1: if velDirOption != 1: phi = [] nPhi = 0 else: phi = [0.0] nPhi = 1 else: phi, nPhi = readList(ctrl, iListPhi, verbose) if nPhi > 1: raise SystemExit( 'ERROR in control file: >>>>>>>> nPhi > 1 in a Mach Ramp session <<<<<<<<' ) if velDirOption == 0: # if phi is specified, then this is a alpha,phi case, with alpha = 0 velDirOption = 1 alpha = [0.0] nAalpha = 1 if nPhi + nBeta >= 2: raise SystemExit( 'ERROR in control file: >>>>>>>> Both phi and Beta specified (in a Mach Ramp session) <<<<<<<<' ) else: # # this is not a mach ramp MachList = [] nMach = 0 # # So, this is a polar-sweep and not mach ramp. # Now find out polarSweepType (1,2,or 3) # if iListPhi == -1: if iListBeta == -1: polarSweepType = 1 polarVar = 'aoa' # phi/beta not found. Polar sweep in alpha for phi=beta=0 velDirOption = 1 # Velocity dirction vector v(alpha,phi). phi = [0.0] nPhi = 1 nBeta = 0 beta = [] else: # beta was found in control file, phi is not there; check how about alpha nPhi = 0 phi = [] polarSweepType = 2 polarVar = 'aoa' velDirOption = 2 # Velocity dirction vector v(alpha,beta). beta, nBeta = readList(ctrl, iListBeta, verbose) if nBeta > 1: raise SystemExit( 'ERROR in control file: nBeta > 1. For polar sweep in beta exchange pitch-axis and use aoa' ) if iListAOA == -1: raise SystemExit( 'ERROR in control file: phi and alpha are missing. Polar sweep not defined' ) alpha, nAalpha = readList(ctrl, iListAOA, verbose) else: # # phi was found in control file, so beta must not be there # if iListBeta > -1: raise SystemExit( 'ERROR in control file: both phi and beta specified. Polar sweep not defined ' ) nBeta = 0 beta = [] velDirOption = 1 # Velocity dirction vector v(alpha,phi). # # Check now if alpha appears # if iListAOA == -1: # # phi found in control file, but alpha is missing, so it is a polar-sweep in phi with alpha=0 # polarSweepType = 3 polarVar = 'phi' alpha = [0.0] nAalpha = 1 else: # # Both alpha and phi found in control file. Find out which one is a list # alpha, nAalpha = readList(ctrl, iListAOA, verbose) phi, nPhi = readList(ctrl, iListPhi, verbose) if nAalpha == 1: if nPhi > 1: polarSweepType = 3 polarVar = 'phi' else: polarSweepType = 1 polarVar = 'aoa' nBeta = 0 beta = [] else: # #-----that is nAlpha > 1 # if nPhi > 1: raise SystemExit( 'ERROR in control file: read lists in both alpha and phi. Polar sweep not defined ' ) polarSweepType = 1 polarVar = 'aoa' nBeta = 0 beta = [] # # Here we end the long if cycle, refrring to Mach ramp or angle sweep #------------------------------------------------------------------------------------------- if verbose: if polarSweepType == 1: print 'Sweep type: ' + str( polarSweepType) + ' in alpha. nAalpha = ' + str( nAalpha) + ' phi = ' + str(phi) elif polarSweepType == 2: print 'Sweep type: ' + str( polarSweepType) + ' in alpha. nAalpha = ' + str( nAalpha) + ' beta = ' + str(beta) elif polarSweepType == 3: print 'Sweep type: ' + str( polarSweepType) + ' in phi. nPhi = ' + str( nPhi) + ' alpha = ', str(alpha) elif polarSweepType == 4: print 'Sweep type: ' + str( polarSweepType) + ' in Mach. nMach = ' + str(nMach) return PA, polarSweepType, velDirOption, nAalpha, nBeta, nPhi, nMach, alpha, beta, phi, MachList, polarVar
def updatedControlFile(ctrl,nc,parAngle,ctrlFile,verbose): # generate a modified control file for case with addRun options from polarSweepLib import parLocator, readList import os # #-- get a proper list of updated parameter-angle st1=str(parAngle) updatedAngleList=st1[1:-1] # Now let us find out which angles are specified in the control file, to figure out polarSweepType and polarVar # keyWordListAOA='angles of attack' iListAOA = parLocator(keyWordListAOA,ctrl,nc,-1,verbose) keyWordListPhi='roll angles' iListPhi = parLocator(keyWordListPhi,ctrl,nc,-1,verbose) keyWordListBeta='side slip angle' iListBeta = parLocator(keyWordListBeta,ctrl,nc,-1,verbose) keyWordListMRN='mach ramp numbers' iListMRN = parLocator(keyWordListMRN,ctrl,nc,-1,verbose) # # Check first if this is a Mach ramp session # if iListMRN > -1 : polarSweepType=4 ; # This is a Mach rmp session polarVar='MachRampNumbers' MachList,nMach=readList(ctrl,iListMRN,verbose); # # Now check if any angle was specified # if iListBeta == -1 : nBeta=0 ; beta=[ ]; velDirOption = 1; # Velocity dirction vector v(alpha,phi). May be overwritten below else: beta,nBeta=readList(ctrl,iListBeta,verbose) velDirOption = 2; # Velocity dirction vector v(alpha,beta) if nBeta > 1 : raise SystemExit('ERROR in control file: >>>>>>>> nBeta > 1 in a Mach Ramp session <<<<<<<<') if iListAOA == -1: if velDirOption == 2 : alpha = [0.0]; nAalpha =1; else: alpha =[ ] ; nAalpha=0; velDirOption = 0; # No specification of Velocity dirction vector. May be overwritten below else: alpha,nAalpha=readList(ctrl,iListAOA,verbose) if nAalpha > 1 : raise SystemExit('ERROR in control file: >>>>>>>> nAlpha > 1 in a Mach Ramp session <<<<<<<<') if iListPhi == -1 : if velDirOption != 1 : phi = [ ] ; nPhi = 0; else: phi = [0.0] ; nPhi = 1; else: phi,nPhi=readList(ctrl,iListPhi,verbose); if nPhi > 1 : raise SystemExit('ERROR in control file: >>>>>>>> nPhi > 1 in a Mach Ramp session <<<<<<<<') if velDirOption == 0 : # if phi is specified, then this is a alpha,phi case, with alpha = 0 velDirOption = 1; alpha = [0.0]; nAalpha =1; if nPhi + nBeta >= 2 : raise SystemExit('ERROR in control file: >>>>>>>> Both phi and Beta specified (in a Mach Ramp session) <<<<<<<<') ctrl[iListMRN]=' Mach ramp numbers : '+updatedAngleList+'\n' else: # # this is not a mach ramp MachList=[ ]; nMach=0; if iListPhi == -1 : if iListBeta == -1 : polarSweepType=1 ; polarVar='aoa' ; # phi/beta not found. Polar sweep in alpha for phi=beta=0 phi = [0.0] ; nPhi = 1; nBeta=0 ; beta=[ ]; else: # beta was found in control file, phi is not there; check how about alpha nPhi = 0 ; phi=[ ]; polarSweepType=2 ; polarVar='aoa' ; beta,nBeta=readList(ctrl,iListBeta,verbose) if nBeta > 1 : raise SystemExit('ERROR in control file: nBeta > 1. For polar sweep in beta exchange pitch-axis and use aoa') if iListAOA == -1 : raise SystemExit('ERROR in control file: phi and alpha are missing. Polar sweep not defined') alpha,nAalpha=readList(ctrl,iListAOA,verbose) ctrl[iListAOA]=' angles of attack : '+updatedAngleList+'\n' else: # phi was found in control file, so beta must not be there if iListBeta > -1: raise SystemExit('ERROR in control file: both phi and beta specified. Polar sweep not defined ') nBeta=0 ; beta=[ ]; # Check now if alpha appears if iListAOA == -1 : # phi found in control file, but alpha is missing, so it is a polar-sweep in phi with alpha=0 polarSweepType=3 ; polarVar='phi' ; alpha =[0.0] ; nAalpha=1 else: # # Both alpha and phi found in control file. Find out which one is a list # alpha,nAalpha=readList(ctrl,iListAOA,verbose) if nAalpha > 1 : ctrl[iListAOA]=' angles of attack : '+updatedAngleList+'\n' phi,nPhi=readList(ctrl,iListPhi,verbose) if nPhi > 1: ctrl[iListPhi]=' roll angles : '+updatedAngleList+'\n' # Prepare a backup of control file st1='cp '+ctrlFile+' '+ctrlFile+'.bck' os.system(st1) # # --- Write down the updated file fc=open(ctrlFile,'w') fc.writelines(ctrl) fc.close() print 'More cases were added. Original ctrl file saved at '+ctrlFile+'.bck File '+ctrlFile+' updated' return
def setPolaraType(ctrl,nc,verbose): # scan the control file and determine polara type and angles from polarSweepLib import parLocator, readList # Determine pitch direction from control file # --------------------------------------------------- keyWordPitchAxis='pitch axis' iPA = parLocator(keyWordPitchAxis,ctrl,nc,-1,verbose) if iPA == -1: PA='z' # This is the default else: paLine=ctrl[iPA] icol=paLine.index(':') paVal=paLine[icol+1:].lower() zFound = 'z' in paVal if zFound: PA='z' else: yFound = 'y' in paVal if yFound: PA='y' else: raise SystemExit('ERROR in control file: only Y or Z can be given for control keyWord ->'+keyWordPitchAxis+'<-') if verbose: print 'Pitch axis is '+PA.upper() # # angles definitions: # alpha ... angle of attack # beta ... side-slip angle # phi ... roll angle # # Note: Actually alpha here is the angle of rotation about the above-defined pitch axis # Thus, by replacing the pitch-axis, all that is said here about alpha is actually for beta # # Several combinations of angles are possible: #------------------------------------------------ # 1. Polar-sweep in alpha per given phi ...... polarVar = aoa # 2. Polar-sweep in alpha per given beta (side slip angle) ...... polarVar = aoa # 3. Polar-sweep in phi per given alpha ...... polarVar = phi # 4. Mach ramp (single values for alpha, phi or both permitted) ... polarVar = MachRampNumbers # # Note: Seting a list of both phi and beta is impossible # For mach ramp you can specify alpha, phi (or both), but not a list of either of them # # Now let us find out which angles are specified in the control file, to figure out polarSweepType and polarVar # keyWordListAOA='angles of attack' iListAOA = parLocator(keyWordListAOA,ctrl,nc,-1,verbose) keyWordListPhi='roll angles' iListPhi = parLocator(keyWordListPhi,ctrl,nc,-1,verbose) keyWordListBeta='side slip angle' iListBeta = parLocator(keyWordListBeta,ctrl,nc,-1,verbose) keyWordListMRN='mach ramp numbers' iListMRN = parLocator(keyWordListMRN,ctrl,nc,-1,verbose) # # Check first if this is a Mach ramp session # if iListMRN > -1 : polarSweepType=4 ; # This is a Mach rmp session polarVar='MachRampNumbers' MachList,nMach=readList(ctrl,iListMRN,verbose); # # Now check if any angle was specified # if iListBeta == -1 : nBeta=0 ; beta=[ ]; velDirOption = 1; # Velocity dirction vector v(alpha,phi). May be overwritten below else: beta,nBeta=readList(ctrl,iListBeta,verbose) velDirOption = 2; # Velocity dirction vector v(alpha,beta) if nBeta > 1 : raise SystemExit('ERROR in control file: >>>>>>>> nBeta > 1 in a Mach Ramp session <<<<<<<<') if iListAOA == -1: if velDirOption == 2 : alpha = [0.0]; nAalpha =1; else: alpha =[ ] ; nAalpha=0; velDirOption = 0; # No specification of Velocity dirction vector. May be overwritten below else: alpha,nAalpha=readList(ctrl,iListAOA,verbose) if nAalpha > 1 : raise SystemExit('ERROR in control file: >>>>>>>> nAlpha > 1 in a Mach Ramp session <<<<<<<<') if iListPhi == -1 : if velDirOption != 1 : phi = [ ] ; nPhi = 0; else: phi = [0.0] ; nPhi = 1; else: phi,nPhi=readList(ctrl,iListPhi,verbose); if nPhi > 1 : raise SystemExit('ERROR in control file: >>>>>>>> nPhi > 1 in a Mach Ramp session <<<<<<<<') if velDirOption == 0 : # if phi is specified, then this is a alpha,phi case, with alpha = 0 velDirOption = 1; alpha = [0.0]; nAalpha =1; if nPhi + nBeta >= 2 : raise SystemExit('ERROR in control file: >>>>>>>> Both phi and Beta specified (in a Mach Ramp session) <<<<<<<<') else: # # this is not a mach ramp MachList=[ ]; nMach=0; # # So, this is a polar-sweep and not mach ramp. # Now find out polarSweepType (1,2,or 3) # if iListPhi == -1 : if iListBeta == -1 : polarSweepType=1 ; polarVar='aoa' ; # phi/beta not found. Polar sweep in alpha for phi=beta=0 velDirOption = 1; # Velocity dirction vector v(alpha,phi). phi = [0.0] ; nPhi = 1; nBeta=0 ; beta=[ ]; else: # beta was found in control file, phi is not there; check how about alpha nPhi = 0 ; phi=[ ]; polarSweepType=2 ; polarVar='aoa' ; velDirOption = 2; # Velocity dirction vector v(alpha,beta). beta,nBeta=readList(ctrl,iListBeta,verbose) if nBeta > 1 : raise SystemExit('ERROR in control file: nBeta > 1. For polar sweep in beta exchange pitch-axis and use aoa') if iListAOA == -1 : raise SystemExit('ERROR in control file: phi and alpha are missing. Polar sweep not defined') alpha,nAalpha=readList(ctrl,iListAOA,verbose) else: # # phi was found in control file, so beta must not be there # if iListBeta > -1: raise SystemExit('ERROR in control file: both phi and beta specified. Polar sweep not defined ') nBeta=0 ; beta=[ ]; velDirOption = 1; # Velocity dirction vector v(alpha,phi). # # Check now if alpha appears # if iListAOA == -1 : # # phi found in control file, but alpha is missing, so it is a polar-sweep in phi with alpha=0 # polarSweepType=3 ; polarVar='phi' ; alpha =[0.0] ; nAalpha=1 else: # # Both alpha and phi found in control file. Find out which one is a list # alpha,nAalpha=readList(ctrl,iListAOA,verbose) phi,nPhi=readList(ctrl,iListPhi,verbose) if nAalpha == 1: if nPhi > 1 : polarSweepType=3 polarVar='phi' else: polarSweepType=1 polarVar='aoa' nBeta=0; beta=[ ]; else: # #-----that is nAlpha > 1 # if nPhi > 1 : raise SystemExit('ERROR in control file: read lists in both alpha and phi. Polar sweep not defined ') polarSweepType=1 ; polarVar='aoa'; nBeta=0; beta=[ ]; # # Here we end the long if cycle, refrring to Mach ramp or angle sweep #------------------------------------------------------------------------------------------- if verbose: if polarSweepType == 1 : print 'Sweep type: '+str(polarSweepType)+' in alpha. nAalpha = '+str(nAalpha)+' phi = '+str(phi) elif polarSweepType == 2 : print 'Sweep type: '+str(polarSweepType)+' in alpha. nAalpha = '+str(nAalpha)+' beta = '+str(beta) elif polarSweepType == 3 : print 'Sweep type: '+str(polarSweepType)+' in phi. nPhi = '+str(nPhi)+' alpha = ',str(alpha) elif polarSweepType == 4 : print 'Sweep type: '+str(polarSweepType)+' in Mach. nMach = '+str(nMach) return PA,polarSweepType,velDirOption,nAalpha,nBeta,nPhi,nMach,alpha,beta,phi,MachList,polarVar