Example #1
0
    def calcJpolar(self, Mach, Re, alphaStart, alphaEnd, alphaStep,flap=False):
        path = myPaths()
        path.setRandPrefix()
        tmpJournal = path.getTmpFile('jfscript')
        tmpAfFile = path.getTmpFile('dat','af')
        tmpPolar  = path.getTmpFile('pol')
        
        if flap:
            afLib.writeFlap(tmpAfFile, self.airfoil)
        else:
            afLib.writeAirfoil(tmpAfFile,self.airfoil)
            
        self.M = Mach
        self.Re = Re

        jouFile = open(tmpJournal,'wt')
        jouFile.write('Options.Country(0)\nGeometry.Clear()\n')
        jouFile.write('Geometry.Open(\"%s\")\n' %tmpAfFile)
        jouFile.write('Options.MachNumber(%.4f)\n'%Mach)
        jouFile.write('Options.StallModel(0)\n')
        jouFile.write('Options.TransitionModel(1)\n')
        jouFile.write('Options.GroundEffect(0)\n')
        jouFile.write('Options.HeightOverSpan(0.5)\n')
        jouFile.write('Options.AspectRatio(0)\n')
        jouFile.write('Polar.Analyze(%.0f;%.0f;%.0f;%.0f;%.0f;%.0f;100;100;0;0)\n'%(Re,Re,0,alphaStart, alphaEnd, alphaStep))
        jouFile.write('Polar.Save(\"%s\")\n'%tmpPolar)
        jouFile.write('Exit()')
        jouFile.close()
        cmd = ('\"\"%s\" -cp \"%s\" -jar \"%s\" Script=\"%s\"\"'%(path.java,path.mhclasses,path.javafoil,tmpJournal))
        os.system(cmd)
        self.readJpolar(tmpPolar)
        os.remove(tmpJournal)
        os.remove(tmpAfFile)
        os.remove(tmpPolar)
Example #2
0
    def calcXpolar(self,Mach, Re,alphaStart, alphaEnd, alphaStep, Iter=10, Graphic = True, Smooth=False):
        path = myPaths()
        path.setRandPrefix()
        tmpAfFile = path.getTmpFile('dat','af')
        tmpPolar  = path.getTmpFile('pol')
        tmpDump   = path.getTmpFile('dmp')

        afLib.writeAirfoil(tmpAfFile,self.airfoil)
        self.M = Mach
        self.Re = Re
    
        def issueCmd(cmd,echo=True):
            ps.stdin.write(cmd+'\n')
            if echo: print cmd
        ps = sp.Popen([path.Xfoil], stdin=sp.PIPE, stdout=None, stderr=None)
        
        if Graphic == False: issueCmd('PLOP\nG\n')
        issueCmd('LOAD')
        issueCmd('%s' %tmpAfFile)
        if Smooth == True:issueCmd('GDES\nCADD\n\n\n\n\nPANEL')
        issueCmd('OPER')
        issueCmd('VISC\n%.0f' % self.Re)
        issueCmd('MACH\n%.4f' % self.M)
        if Iter>10: issueCmd('ITER\n%d' % Iter)
        issueCmd('PACC')
        issueCmd('%s\n%s' % (tmpPolar,tmpDump))

        if alphaStep == 0:
            issueCmd('ALFA\n%.2f'%alphaStart)
        elif alphaStart*alphaEnd<0:
            issueCmd('ASEQ\n%.2f\n%.2f\n%.2f'%(-alphaStep, alphaStart, -alphaStep))
            issueCmd('ASEQ\n%.2f\n%.2f\n%.2f'%(0, alphaEnd, alphaStep))
        else:
            issueCmd('ASEQ\n%.2f\n%.2f\n%.2f'%(alphaStart, alphaEnd, alphaStep))
        issueCmd('\nQUIT')
        ps.wait()
    
        self.readXpolar(tmpPolar)
    
        os.remove(tmpAfFile)
        os.remove(tmpPolar)
        os.remove(tmpDump)
Example #3
0
 def saveAsIgs(self,filename,airfoil,flap=False):
     path = myPaths()
     path.setRandPrefix()
     tmpJournal = path.getTmpFile('jfscript')
     tmpAfFile = path.getTmpFile('dat','af')
     
     if flap:
         afLib.writeFlap(tmpAfFile, self.airfoil)
     else:
         afLib.writeAirfoil(tmpAfFile,self.airfoil)
         
     jouFile = open(tmpJournal,'wt')
     jouFile.write('Options.Country(0)\nGeometry.Clear()\n')
     jouFile.write('Geometry.Open(\"%s\")\n' %tmpAfFile)
     jouFile.write('Geometry.Save(\"%s\")\n' %filename)
     jouFile.write('Exit()')
     jouFile.close()
     cmd = ('\"\"%s\" -cp \"%s\" -jar \"%s\" Script=\"%s\"\"'%(path.java,path.mhclasses,path.javafoil,tmpJournal))
     
     os.system(cmd)
     os.remove(tmpJournal)
     os.remove(tmpAfFile)