Xero64 / pyxfoil

Run XFoil from within Python and work with results.
MIT License
4 stars 1 forks source link

Error when following steps in Readme #1

Closed asanchez2k22 closed 1 year ago

asanchez2k22 commented 1 year ago

Hi,

I was trying to follow the steps described in Readme to run an example (see code below) but it throwed me the following error. Could you please help on how to solve it?

Error

Traceback (most recent call last):
  File "C:\Users\andre\PycharmProjects\BEMT_Test\Main\xfoil_test.py", line 19, in <module>
    rescase = foil.run_result(ali,mach=mach,re=re1)
  File "C:\Users\andre\PycharmProjects\BEMT_Test\venv\lib\site-packages\pyxfoil\xfoil.py", line 75, in run_result
    system('{:s} < {:s}'.format(xfoilexe, sesfilepath))
TypeError: unsupported format string passed to NoneType.__format__

Code

from pyxfoil import Xfoil,set_workdir

set_workdir('C:\Xfoil_WIP')

foil = Xfoil('S815')
foil.points_from_dat('../Files/S815.dat')
foil.set_ppar(66)

al = [-2.0,0.0,2.0,4.0,6.0]

almin = -10.0
almax = 25
alint = 0.5
mach = 0.1
re1 = 10000.0
re2 = 20000.0

for ali in al:
    rescase = foil.run_result(ali,mach=mach,re=re1)

ax1 = foil.plot_profile(ls='-')

Thanks!

Xero64 commented 1 year ago

Hi,

The likely issue is that xfoil.exe cannot be found in the folders of your PATH environment variable.

You can directly point to the xfoil.exe by importing the set_xfoilexe function and using the function as shown in the below example.

from pyxfoil import Xfoil, set_workdir, set_xfoilexe
set_workdir('C:/Xfoil_WIP') # Sets the working directory for pyxfoil.
set_xfoilexe('C:/Xfoil-6.99/xfoil.exe') # Sets the path of the xfoil executable.

I hope this resolves your error.

Please let me know if it does or does not.

asanchez2k22 commented 1 year ago

Hi,

That was exactly the situation, now it runs perfectly.

One more question, when it runs it opens really fast the plots but closes them again, and it generates files .POL and .SES.

Thanks

Xero64 commented 1 year ago

Hi,

You should be able to plot many of the result plots in Python, so the intent of this package is not to keep the xfoil window open.

One solution to your problem would be to run the session file directly with xfoil through the command line. If you use a session file generated by pyxfoil then you need to remove the last line in that session file that quits xfoil.

Any text editor like notepad or vscode can open .POL or .SES files.

I will close this issue since the original problem is solved.