The-Fonz / xfoil-optimization-toolbox

The Python XFOIL optimization toolbox can be used to optimize airfoils for a specific operating range, and might be useful to you for its XFOIL communication module, airfoil parametrizations, and optimization algorithms, i.e. all you need to do funky stuff with 2D airfoils.
The Unlicense
38 stars 16 forks source link

problems when starting xfoil subprocess #5

Closed enritoomey closed 7 years ago

enritoomey commented 7 years ago

i was checking your project, running example_naca4_drag.py in my windows machine when i got the following error:

  File "example_naca4_drag.py", line 33, in <module>
    polar = oper_visc_cl(temp_af_filename, Cl, Re, iterlim=500)
  File "C:\Users\enri\PYTHON_PROJECTS\xfoil-optimization-toolbox\xfoil\xfoil.py", line 37, in oper_visc_cl
    return _oper_visc(["Cl","CSEQ"], *args, **kwargs)
  File "C:\Users\enri\PYTHON_PROJECTS\xfoil-optimization-toolbox\xfoil\xfoil.py", line 61, in _oper_visc
    xf = Xfoil(path)
  File "C:\Users\enri\PYTHON_PROJECTS\xfoil-optimization-toolbox\xfoil\xfoil.py", line 154, in __init__
    stdin=subp.PIPE, stdout=subp.PIPE, stderr=subp.PIPE)
  File "C:\Python27\lib\subprocess.py", line 710, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
    startupinfo)
WindowsError: [Error 193] %1 is not a valid Win32 application

The problem was solved by changing the executable name in init() module of Xfoil class from xfoil to xfoil.exe. I'm using W10 os.

The-Fonz commented 7 years ago

Thanks for taking the time to mention the issue. The executables are a bit of a mess, as you need different ones for every platform... ideally xfoil is compiled from source, but that would be another mess altogether, and would add dependencies on compilers.

A good short-term solution would be to detect the operating system and then choose the correct binary, should be pretty easy. I currently have a million other projects going on but if anyone is interested in implementing this, feel free :)

TsingQAQ commented 7 years ago

@enritoomey You may have a try by changing the following line of Xfoil class in xfoil.py self.xfinst = subp.Popen(os.path.join(path, 'xfoil'), stdin=subp.PIPE, stdout=subp.PIPE, stderr=subp.PIPE) to: self.xfinst = subp.Popen(os.path.join(path, 'xfoil.exe'), stdin=subp.PIPE, stdout=subp.PIPE, stderr=subp.PIPE) I encountered the same problem(say not a valid win32..) and fixed this but now some other problems show

jasonhamilton commented 7 years ago

I've submitted a pull request to select binary by OS.

The-Fonz commented 7 years ago

Nice work, thanks! Merged it.