Compiling Xfoil on OS X
Posted on January 23, 2014 by Paul
If you are into airfoil analysis as an amateur or as a professional you will need a quick way to estimate the aerodynamic characteristics (lift, drag and momentum coefficients) of a given airfoil. The classical approach to calculate the performance of an airfoil is to use a coupled inviscid/viscous flow solver. On a modern computer this analysis will usually take less than a minute. Compare this with a full CFD approach that uses the Navier-Stokes equations for the laminar part of the flow and the Reynolds Averaged Navier-Stokes equations for the turbulent part of the flow. In the former case a typical analysis can run from a few minutes to a few hours on a modern PC.
Xfoil is an open source interactive program for the design and analysis of subsonic isolated airfoils. Xfoil uses a potential flow solver coupled with a Boundary Layer solver to calculate the flow field around an airfoil. The author, Mark Drela, provides a Windows binary on Xfoil’s web page. If you are a Linux user building Xfoil from sources is straightforward. For OS X, well, it is a bit more complicated to build the code from sources.
A typical Xfoil result is presented in the next figure:
In order to be able to build and run Xfoil on OS X you will need an X server like XQuartz. Xfoil is implemented in Fortran and C, so we’ll need a C and Fortran compiler. Xcode will give you the C compiler. A Fortran compiler can be built from sources or installed from Homebrew. On my machine, I’ve built GCC from sources with the C, C++ and Fortran compilers, but you can safely use the ones from Homebrew if you prefer.
Assuming that you have all the requirements (XQuartz, gfortran, gcc) installed, we can start the actual compilation of Xfoil. You can download the latest sources from Xfoil’s web page. In the remaining of this post I will suppose that you have extracted Xfoil in your home folder.
Open a Terminal and navigate to the orrs folder from Xfoil:
Next we will need the absolute path to the orrs folder, this can be found with:
On my machine the result of the above command was /Users/sol/Xfoil/orrs, be sure to use your own user name instead of sol.
Go further in the directory tree of Xfoil with:
and open osmap.f in your favorite text editor. At about line 101 you will find this line:
change it to reflect the actual path to your orrs folder (the result of pwd from above), again be sure to use your own user name instead of sol:
Save and close osmap.f.
Next, we need to go in the bin folder of orrs:
Open Makefile and replace all occurrences of /home/codes/Xplot with /Users/sol/Xfoil/. Find the compiler flags:
and change them to:
Find the flags for the Intel Fortran Compiler:
and comment them:
Save the Makefile and write the next set of commands in your Terminal:
Next, we are going to build the plot library used by Xfoil:
Open the Makefile from ~/Xfoil/plotlib and change:
Save and close the Makefile.
Open config.make and change
Save and close the file.
Edit the Makefile from ~/Xfoil/bin by changing:
Find the default compilers options:
and change them to:
and add the next line at the end of the above lines:
Save the Makefile.
Last steps in the compilation:
Now, you should be able to run Xfoil with:
or, optionally, you can add the next line at the end of your .bash_profile file:
Save and run in the Terminal:
If you are interested in learning more about the method used by Xfoil for solving the inviscid flow field I would recommend reading Low-Speed Aerodynamics by J. Katz and A. Plotkin:
For a good introduction into the Boundary Layer theory and numerical solutions of these equations, a good introduction is Boundary Layer Analysis by J.A. Schetz and R.D.W. Bowersox: