peterdsharpe / AeroSandbox

Aircraft design optimization made fast through computational graph transformations (e.g., automatic differentiation). Composable analysis tools for aerodynamics, propulsion, structures, trajectory design, and much more.
https://peterdsharpe.github.io/AeroSandbox/
MIT License
761 stars 126 forks source link

airfoil.generate_polars can't work well in Ubuntu #94

Closed Zcaic closed 1 year ago

Zcaic commented 1 year ago

1.airfoil.generate_polars work well in Windows, but it can't work in Ubuntu22.04. I found it caused by Xfoil .

  1. I also found there is a bug "def _run_xfoil()" in Xfoil.py ( lines 264) , In linux , it does not support "try: command = f'{self.xfoil_command} {airfoil_file}' proc = subprocess.Popen( command, ................ "

I change line 264 to "command = [f'{self.xfoil_command}',f'{airfoil_file}']" , it can call Xfoil, but unfortunately, Xfoil can not work as expected.

peterdsharpe commented 1 year ago

Hey @Zcaic ,

Thank you for posting about this issue!

When you say

I change line 264 to "command = [f'{self.xfoil_command}',f'{airfoil_file}']" , it can call Xfoil, but unfortunately, Xfoil can not work as expected.

Can you describe:

a) Expected behavior b) Observed behavior

Similarly, when you say that the original command "does not support" on Linux, can you also describe the same expected and observed behavior here?

This will help us reproduce, understand, and fix the issue here. Thanks!

Zcaic commented 1 year ago

Hello @peterdsharpe, I'm glad you got back to me

I test aerosandbox/aerodynamics/aero_2D/xfoil.py in Ubuntu 22.04, I add "print (result_at_single_alpha)" at end. xfoil.py.txt

  1. a) Expected behavior: get correct result. b) Observed behavior: it raise :"FileNotFoundError: [Errno 2] No such file or directory: 'xfoil airfoil.dat'". then I found the reason of this error, I change line 272 "command = f'{self.xfoil_command} {airfoil_file}'" to "command = [self.xfoil_command,airfoil_file]",

  2. it does not raise error , but I sitll dont get correct result. b) Observed behavior: "{'alpha': array([], dtype=float64), 'CL': array([], dtype=float64), 'CD': array([], dtype=float64), 'CDp': array([], dtype=float64), 'CM': array([], dtype=float64), 'Top_Xtr': array([], dtype=float64), 'Bot_Xtr': array([], dtype=float64), 'Top_Itr': array([], dtype=float64), 'Bot_Itr': array([], dtype=float64)}" it can found that "result_at_single_alpha" is empty.

  3. then I Uncomment "verbose=true" in line 536 to see what happen, and it raise: " **Enter polar output filename s> At line 664 of file ../src/iopol.f (unit = 19, file = 'output.txt') Fortran runtime error: Unexpected element '(1X,F7.3 ,F9.4 ,F10.5 ,F10.5 ,F9.4 ,

Error termination. Backtrace:

0 0x7f15f8508a4f in data_transfer_init

    at /usr/src/debug/gcc/gcc/libgfortran/io/transfer.c:3161

1 0x55c188ea1e61 in ???

2 0x55c188e38582 in ???

3 0x55c188e24acb in ???

4 0x55c188e1c39e in ???

5 0x7f15f7eaf84f in ???

6 0x7f15f7eaf909 in ???

7 0x55c188e1c3c4 in ???

8 0xffffffffffffffff in ???**

" But it can work and print correct result in Windows, because I'm not familiar with xfoil, I guess the there is a problem with the parameter passed to xfoil in Linux。

Could you see what's wrong ,thanks!

Zcaic commented 1 year ago

It has same problem in Arch Linux, So I think it is not a problem caused by Ubuntu.

Zcaic commented 1 year ago

Thank you for your reply, I will try your proposal.

Zcaic commented 1 year ago

@max-97 thanks very much. I change code about "pwrt" and "pacc" as you said, it works as expect. Thanks a lot!

peterdsharpe commented 1 year ago

Glad to hear it @Zcaic ! Thanks for the tip here, @max-97 .

New versions of AeroSandbox will have the option of using our new NeuralFoil package to generate airfoil polar functions instead of XFoil - since NeuralFoil is pure Python + NumPy, this should eliminate the need to have a local XFoil copy for most users. This will make cross-platform use vastly easier.

A preview is available in the AeroSandbox feature/neuralfoil-merge branch, but should go live on master + develop soon.

peterdsharpe commented 1 year ago

@max-97 @Zcaic , the fix proposed by @max-97 has been worked into the feature/neuralfoil-merge WIP branch, and will be incorporated into the next AeroSandbox release (probably later this week). This fix has been verified to maintain compatibility on Windows as well.

https://github.com/peterdsharpe/AeroSandbox/commit/932f82db134b92e26462c6384f88ae87caffe144

Nice work!

Zcaic commented 1 year ago

I'm glad to hear the good news

Zcaic commented 1 year ago

@peterdsharpe When I learn DAWNDESIGNTOOL, I found the description of the function lib_winds.tropopause_altitude to be problematic. Code show as below: 微信截图_20230718020629 It seems that the comment inside the red box should be changed to

"latitude"   : latitude, in degree
peterdsharpe commented 1 year ago

Good catch, thanks! Fix committed, incoming here:

https://github.com/peterdsharpe/AeroSandbox/commit/d132cf40442ebaa34968b74d58bad37fa5544d0c