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

Executable, executable name, and problem list conversion #2

Closed julietbravo closed 8 years ago

julietbravo commented 8 years ago

Just been playing around with your code, thanks for sharing it! I had a few minor issues getting the code running:

I can't seem to find any info on which kind of OS you compiled Xfoil, which might be a useful note in the Readme file? On OS X the executable didn't work, so I had to compile Xfoil myself.

In xfoil.py, the executable name is xfoil, while the executable itself is named xfoil.exe?

I got some errors in data_array = np.array([clean_split(dataline) for dataline in datalines], dtype='float'), as the list being converted to a Numpy array contained some empty strings. I don't know if this is related to the Xfoil version I'm using (6.97), but I fixed it for now as:

data_list = [clean_split(dataline) for dataline in datalines]
if len(data_list) > 0 and '' in data_list[0]:
        data_list[0].remove('')
data_array = np.array(data_list, dtype='float')
The-Fonz commented 8 years ago

Glad you've been playing with my code! Hope it's useful.

I indeed included the windows binary of Xfoil. Executing xfoil on the command line in windows will assume it's an executable. Good idea of putting it in the readme. Maybe you can send me your binary so I can include it?

I suspect different newline characters on different OS's cause the problem you mention. Then this fix might work: Add import os to xfoil.py Change clean_split to def clean_split(s): return re.split('\s+', s.replace(os.linesep,''))[1:]

But can't test it as I have no mac.

julietbravo commented 8 years ago

This: def clean_split(s): return re.split('\s+', s.replace(os.linesep,''))[1:] indeed works (and is much prettier than my solution :)), thanks.

I attached the executable (XFoil 6.97, compiled with GFortran 4.8 on OS X 10.10): xfoil.zip

alexkenan commented 7 years ago

Did either you or @julietbravo have troubles with never encountering an end marker in xfoil? I'm trying to port these files over to Mac and Python3.5 and the xfoil.py file is hanging around lines 104-109 because the output is forever None so it's getting stuck in an infinite loop of Nones.

The-Fonz commented 7 years ago

@alexkenan It's been a while since I spinned it up but it should recognize the end marker when the polar is listed, as the end marker is simply 'typed in' programatically (xfoil.py line 95). To troubleshoot, you can run Xfoil manually and type in the sequence of commands shown in xfoil.py. Then see what it does. Other possible causes I can think of: the Xfoil binary doesn't run on your system, or there's some unicode problems due to Python 3.5 interpreting the output as a byte stream and it needs to be encoded as 'utf-8'.