DARcorporation / xfoil-python

Stripped down version of XFOIL as compiled python module
GNU General Public License v3.0
87 stars 60 forks source link

Not getting the converged values #2

Open ckesanapalli opened 5 years ago

ckesanapalli commented 5 years ago

I tried to run the demo code in the ReadMe file, but for the command


>>> from xfoil import XFoil
>>> xf = XFoil()
>>> from xfoil.test import naca0012
>>> xf.airfoil = naca0012
 Number of input coordinate points: 160
 Clockwise ordering
 Max thickness =     0.000000  at x =   0.000
 Max camber    =     0.000000  at x =   0.000

  LE  x,y  =  -0.06001  -0.06001  |   Chord =   0.08487
  TE  x,y  =   0.00000   0.00000  |

 Current airfoil nodes set from buffer airfoil nodes ( 160 )
>>> xf.Re = 1e6
>>> xf.max_iter = 40

But for the following command,

a, cl, cd, cm, co = xf.aseq(0, 1, 0.5)

I got the output as

 Calculating wake trajectory ...
 Calculating source influence matrix ...

 Solving the BL system ...

 Initializing BL ...
    side            1  ...
 TRCHEK2: N2 convergence failed.
 x:  0.08352  0.08353  0.08353  N:  0.000  9.000    NaN  Nx:     NaN   dN:       NaN
 Calculating wake trajectory ...
 Calculating source influence matrix ...

 Solving the BL system ...

 Initializing BL ...
    side            1  ...
 TRCHEK2: N2 convergence failed.
 x:  0.08352  0.08353  0.08353  N:  0.000  9.000    NaN  Nx:     NaN   dN:       NaN

The values are print(a, cl, cd, cm, co)

[nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan
 nan nan] [nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan
 nan nan] [nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan
 nan nan] [nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan
 nan nan] [nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan
 nan nan]

May I know how to resolve this issue

@daniel-de-vries: Your python code is really great and looks really apt for my project. I would really appreciate if you could help me resolving this issue.

maidmentdaniel commented 5 years ago

I get a bunch of nan's too. I'm not sure why.

from xfoil import XFoil
from xfoil.test import naca0012

xf = XFoil()
xf.airfoil = naca0012
xf.Re = 1e6
xf.max_iter = 40
a, cl, cd, cm, co = xf.aseq(-20, 20, 0.5)

returns: output

ajwahab commented 5 years ago

Encountering the same on macOS 10.14.3. Noticed that the max thickness, chord, LE, and TE values differ from those given in README.md.
What I get:

>>> xf.airfoil = naca0012

 Number of input coordinate points: 160
 Clockwise ordering
 Max thickness =     0.000000  at x =   0.000
 Max camber    =     0.000000  at x =   0.000

  LE  x,y  =  -0.06001  -0.06001  |   Chord =   0.08487
  TE  x,y  =   0.00000   0.00000  |

What the README.md indicates I should be getting:

>>>  xf.airfoil = naca0012

 Number of input coordinate points: 160
 Counterclockwise ordering
 Max thickness =     0.120008  at x =   0.308
 Max camber    =     0.000000  at x =   0.033

  LE  x,y  =  -0.00000   0.00000  |   Chord =   1.00000
  TE  x,y  =   1.00000   0.00000  |

Seeing that the thickness, among other values, is computed from the airfoil coordinates, perhaps there is an issue with how the naca0012 coordinate array in test.py is being parsed by the fortran routines?

Seems to work just fine on Ubuntu 18.04, though aseq now also outputs 5 values (minimum pressure coefficient co was recently added in [4354e485d979b318b8d583bca0720d32697c61a4]), so README.md should be updated to:

>>>  a, cl, cd, cm, co = xf.aseq(-20, 20, 0.5)

This project is fantastic!

ckesanapalli commented 5 years ago

@ninfinity How did you install xfoil module it in ubuntu. I am trying to install in ubuntu but I am getting a bunch of errors.

ajwahab commented 5 years ago

Try my fork of the project. I’ve submitted a pull request that includes a minor edit that lowers the minimum cmake version requirement to 3.10, which seems to be the current default in Ubuntu 18.04.

ckesanapalli commented 5 years ago

@ninfinity : can you give me instructions on how to install your version. I am trying but I am getting error.

home/chaitu1351/anaconda3/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'zip_save'
      warnings.warn(msg)
    error: can't copy 'build/lib.linux-x86_64-3.7/xfoil/xfoil.cpython-37m-x86_64-linux-gnu.so': doesn't exist or not a regular file
    ['-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/home/chaitu1351/src/xfoil/build/lib.linux-x86_64-3.7/xfoil', '-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=build/temp.linux-x86_64-3.7', '-DPYTHON_EXECUTABLE=/home/chaitu1351/anaconda3/bin/python']
Nick-Zhang1996 commented 5 years ago

@maidmentdaniel @ckesanapalli @ninfinity The problem you're having is resulted from an improper call to self._lib.get_airfoil() in xfoil.py. Somehow the memory buffer used for x and y are entangled and the function gets same array for x and y. If you check xf.airfoil you'll see xf.airfoil.x is actually set to the values of xf.airfoil.y. I suspect this is a bug with ctypes library, and by changing platform I believe @ninfinity switched to a different version of ctypes, which fixed the problem. I have a fix in my fork of this library and I have absolutely no idea why it works. If you come across this issue, my version may help you.

wzc001 commented 3 years ago

Excuse me,I also encountered this problem(NAN). Have you solved it?

ckesanapalli commented 3 years ago

Nope.