peterdsharpe / AeroSandbox

Aircraft design optimization made fast through modern automatic differentiation. Composable analysis tools for aerodynamics, propulsion, structures, trajectory design, and much more.
https://peterdsharpe.github.io/AeroSandbox/
MIT License
687 stars 111 forks source link

AVL Fortran runtime error: End of file #71

Closed sr71684 closed 2 years ago

sr71684 commented 2 years ago

Bug Description

When running 01 - AVL.ipynb AVL produces the following error:


 Reading file: airplane.avl  ...

 Configuration: Example Airplane                                            

   Building surface: Wing                                    
At line 629 of file ../src/ainput.f
Fortran runtime error: End of file

Error termination. Backtrace:
#0  0x7f67df8dcd5a
#1  0x7f67df8dd869
#2  0x7f67df8de54f
#3  0x7f67dfb21c5b
#4  0x7f67dfb1b15c
#5  0x7f67dfb1bdc9
#6  0x5606701ea350
#7  0x5606701cb015
#8  0x5606701cc652
#9  0x7f67df5870b2
#10  0x5606701c86bd
#11  0xffffffffffffffff

Steps to Reproduce

  1. I first installed AVL using steps found here: https://ubuntuforums.org/showthread.php?t=2274062
  2. Added AVL to system path.
  3. Ran 01 - Basic Aircraft Geometry.ipynb 01 - AVL.ipynb

System Information

Other Information

I tested AVL on the supergee.avl example and obtained the following plots, so I am confident it is installed correctly. image image

sr71684 commented 2 years ago

Upon further digging. if I change lines 311, 312 of /geometry/airplane.py from

AIRFOIL
{xsec.airfoil.repanel(50).write_dat(filepath=None, include_name=False)}

to

AFIL
ag45c.dat

The error is avoided. This leads me to believe the write_avl method may produce an .avl that is incompatable with AVL version 3.32.

peterdsharpe commented 2 years ago

Hey @sr71684 ,

Thanks for the bug report, and nice work tracing the source! :)

I spent a bit of time this morning on my Linux install (via Windows Subsystem for Linux) trying to reproduce this with my AVL 3.35 and was unable. When I find the time (later this week hopefully?), I'll try building 3.32 and see if I can reproduce this exception with that.

In the meantime, some general ideas:

adamwass commented 2 years ago

Hey @sr71684 ,

As @peterdsharpe mentioned, I am working on the asb.AVL module and have been running AVL on Linux. I am running Ubuntu 20.04, AVL 3.36, and AeroSandbox 3.3.0.

You may be onto something with regards to the AIRFOIL keyword vs. AFILE, as AIRFOIL includes the coordinates directly in the .avl file as opposed to in a separate text file. However, I am having trouble trying to recreate the issue.

First, I don't see any calls to AVL in 01 - Basic Aircraft Geometry.ipynb? Is it possible you're talking about 01 - AVL.ipynb in the tutorial/06 - Aerodynamics/02 - Interfaces to External Aerodynamics Tools folder?

Second, although I am not sure how to recreate your case exactly, I will say that I have been running AVL successfully using asb.AVL's stock AIRFOIL behavior with a repanaling parameter of 50 (Which is roughly 100 total coordinate pairs it looks like), including files with multiple AIRFOIL declarations.

One complicating factor here is the process for building AVL on Linux. It was pretty difficult for me to build AVL 3.36 on Linux, as the steps in that forum thread you linked to did not seem to work. I had to modify some of the makefiles through trial and error, and honestly I'm not sure exactly what I did to make it work. Additionally, there were build options I did not understand, which may affect behavior. For example, single vs. double precision compile flags. I did not change the precision compile flags from their defaults, so I guess I'm running single precision? I have seen an intermittent warning from AVL that looked something like IEEE underflow... that may be related, but I'm not sure.

Anyway, all that is to say that I suspect the AVL issue you are seeing might have more to do with the specifics of the AVL version and how it is built than with AeroSandbox. If you're interested in trying AVL 3.36, I can piece together what I did to make it work and write up a procedure.

sr71684 commented 2 years ago

Hey @peterdsharpe

Firstly, thanks for your response. I really admire your work.

you can pass in the working_directory parameter when you instantiate asb.AVL

I initially tried that by setting working_directory=os.path.join(os.getcwd(), "out"),. Sadly, the same identical backtrace is thrown.

Does changing the repaneling parameter from 50 to say, 10, help anything?

No, the same identical backtrace is thrown.

perhaps try changing the offending airfoils to different ones

I did try this initially. Sadly, the same identical backtrace is thrown.

I also tried:

  1. Using AeroSandbox (with no modification to /geometry/airplane.py) to generate the airplane.avl.
  2. Manually calling AVL from the command line and loading airplane.avl with: LOAD ./airplane.avl

This produces the following result:

 AVL   c>  load out/airplane.avl

 Reading file: out/airplane.avl  ...

 Configuration: Athena's Nemesis                                            

   Building surface: Wing                                    
At line 629 of file ../src/ainput.f
Fortran runtime error: End of file

Error termination. Backtrace:
#0  0x7fcccf260d5a
#1  0x7fcccf261869
#2  0x7fcccf26254f
#3  0x7fcccf4a5c5b
#4  0x7fcccf49f15c
#5  0x7fcccf49fdc9
#6  0x560c4a488350
#7  0x560c4a469a82
#8  0x560c4a46a652
#9  0x7fcccef0b0b2
#10  0x560c4a4666bd
#11  0xffffffffffffffff
sr71684 commented 2 years ago

Hey @adamwass

Thanks for your detailed suggestions. They are much appreciated.

Is it possible you're talking about 01 - AVL.ipynb in the tutorial/06 - Aerodynamics/02 - Interfaces to External Aerodynamics Tools folder?

Yes, my mistake. Sorry about that.

You may be onto something with regards to the AIRFOIL keyword vs. AFILE

I used AFIL not AFILE.

supergee.avl used AFIL, thus inspiring me to try it in my debugging process. AFIL is sparsely documented in the 3.30 AVL user guide. I am not able to rigorously describe their difference.

I am not sure how to recreate your case exactly

I have attached minimum working example. Hopefully, this will better describe my application case.

One complicating factor here is the process for building AVL on Linux

Agreed. I believe this is where the true issue lies. After reading the 3.30 AVL user guide, I believe AeroSandbox produces syntactically correct *.avl files. I tried setting up AVL 3.36, but ran into the same installation issues you described. I would greatly appreciate and pointers you might have.

Might I suggest adding the version of AVL that AeroSandbox was developed for to the readme.md?

adamwass commented 2 years ago

@sr71684

Build procedure for AVL 3.36 (I think this will give you single precision). Also this was cobbled together from my bash command history since I don't have a clean install to test on, so no guarantees:

Prequisites:

  1. A fortran compiler of your choice. I used gfortran, and the rest of this procedure will assume gfortran, but feel free to replace the relevant code with whatever you need for your chosen compiler.
  2. libx11. This is some kind of windowing tool required to manage the plot window in AVL I think? Either way, I could not build the Xplot11 library required for AVL without it:
    sudo dpkg --configure -a
    sudo apt-get install libx11-dev

Installing AVL:

  1. Download and unpack AVL 3.36 from the internet to a folder of your choice (mine is called ~/packages):
    cd ~/packages
    wget http://web.mit.edu/drela/Public/web/avl/avl3.36.tgz
    tar -xvf avl3.36.tgz
    cd Avl
  2. We will generally be following the build procedure laid out in the README file in the main AVL directory but with one modification:
    cd bin

    Open Makefile.gfortran in a text editor, and change BINDIR = /home/codes/bin/ to BINDIR = /usr/bin/ on line 7. Save.

Explanation: AVL cannot install without this change because /home/codes/bin/ does not exist. Instead, AVL should be installed to /usr/bin/ so it can be accessed from anywhere by typing avl in the terminal. Not sure where this error came from or if it even is an error or simply a difference between different versions of Linux?

  1. Follow the instructions in README, reproduced below:

    cd ../plotlib
    make gfortran
    cd ../eispack
    make -f Makefile.gfortran
    cd ../bin
    sudo make -f Makefile.gfortran avl
  2. AVL should now be installed. Type avl in the terminal from any directory to run. Let me know if it works!

  3. If you mess up the installation in bin, delete all generated files, which is the entire contents of bin except:

    make-dev
    Makefile.gfortran
    Makefile.ifort
    Makefile.mingw

    This will allow you to try again.

  4. If you want to delete an existing installation of AVL, do the above steps, then:

    cd /usr/bin
    sudo rm ./avl

    This will delete the thing that actually runs when you type avl. Note: Be careful when working in /usr/bin not to delete anything important! Note: Not sure if deleting avl is necessary or if a new build will simply overwrite it.

Final note: This should work, but I should really figure out how to enable the double precision compiler flags. @peterdsharpe Also, after someone who actually knows how AVL works on the fortran level reviews this, maybe the README for AVL should be updated?

sr71684 commented 2 years ago

@adamwass

Your setup instructions enabled me to successfully run AVL 3.36 on my system. Further, it appears upgrading to 3.36 also resolved my original issue. I can now successfully run AVL via AeroSandbox. Thanks very much for your help.

I should note that the IEEE message you mentioned earlier now appears.

avl airplane.avl < keystroke_file.txt
Note: The following floating-point exceptions are signalling: IEEE_DIVIDE_BY_ZERO
'Sref': 9.0,
 'Cref': 0.9,
 'Bref': 10.0,
 'Xref': 0.5,
 'Yref': 0.0,
 'Zref': 0.0,
 'alpha': 5.0,
 'pb/2V': -0.0,
 "p'b/2V": -0.0,
...
peterdsharpe commented 2 years ago

Yay! Well done @adamwass! :) Glad things are working!

Adam, I'll forward your 3.36 build guide to Drela and see about a) if he'd like to add your guide to the AVL documentation and b) help on the double-precision flags.