Skip to content

Source and vortex panel method codes referenced in my YouTube videos.

License

Notifications You must be signed in to change notification settings

wissenschaftler48/Panel_Methods

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Panel_Methods

This repository contains all the code related to panel methods. This includes scripts and functions, in both MATLAB and Python. It will be updated continuously as I finish the video series with the final Source Panel Method (SPM) and Vortex Panel Method (VPM) code. Explanations of the different files can be found in the sections below, which are pretty much the same as you'll find on my website launching page. Links to my YouTube videos and blog posts on my website are included. Note that functions are always named in all caps.

UIUC Airfoil Database File Download

This section is for downloading all the airfoil coordinates from the UIUC Airfoil Database. The files are all of type .dat, which can be opened in any text editor. This code is run in Python, since it's free to download. There are two scripts: one that downloads the files in the default coordinate format (which varies quite a bit), and one that downloads the files in Selig format (which is easier to load into your program of choice). If I were you, I would download them in Selig format.

Load Airfoil Coordinates in MATLAB and Python

With the airfoils download from the UIUC database in the previous section, we now need to read them into our MATLAB/Python code in order to use them in the panel code. Note that if you're planning on using Python, you need to download the files into Selig format from the previous section, since that's all I coded for the loading function in Python.

Running XFOIL from MATLAB and Python

This section is for running XFOIL from a script in MATLAB/Python. This is convenient if you want to be able to quickly change a parameter (or multiple parameters) and output the results, but you don't want to go into the command line of XFOIL every time. This is useful for getting airfoil data in a MATLAB GUI for instance. If you have an edit text box for changing the angle of attack, then every time it's changed by the user, the MATLAB program will call XFOIL using the updated AoA value and return the airfoil coordinates and pressure coefficient data (for example).

Compute Circulation

Circulation is a fundamental concept in aerodynamics (and more generally, in multivariable calculus). In order to find the lift of an airfoil using the vortex panel method, the circulation around the airfoil needs to be computed. For pretty much all of the remaining codes, you'll need to have either the MATLAB or Python COMPUTE_CIRCULATION function in the run directory. The script Circulation is an example file showing how to use the COMPUTE_CIRCULATION function, and is not needed for future codes.

Incompressible Potential Flow

When assuming that the flow is both irrotational and incompressible, we can simplify down some complicated equations into a simpler equation (Laplace's equation), and the resulting flow is called incompressible potential flow. There is no code here, but links to my explanation YouTube video and blog post can be found below.

Elementary Potential Flows

In order to build more complex flows, we need to understand the simplest types of potential flows. Here, we go through three elementary flows (uniform, source/sink, and vortex), along with two combinations of these flows (uniform + source/sink, uniform + vortex).

Panel Method Geometry

The first step in writing your own panel method code is to understand the geometry and its associated variables. Here, we go through this in detail for an arbitrary shape (circle approximated by eight panels). In the MATLAB and Python codes, we also show how this works for an airfoil. Note that for these codes to work, you will need to have the appropriate LOAD_AIRFOIL_SELIG function downloaded in the directory (unless you want to comment out the airfoil loading section).

Building More Complex Potential Flows

In the Elementary Potential Flows section, we went over all the relevant elementary incompressible potential flows. We can now use these to build up a more complex flow step-by-step. The end result of this section is to obtain an expression for the velocity potential induced at an arbitrary point P in the flow due to uniform flow and N source panels (that approximate the airfoil geometry).

Flow Around an Airfoil

How do we use the velocity potential equation derived in the previous section to compute the flow around an airfoil? This section explains the necessary conditions that we can use to compute the unknown source panel strengths. We use the boundary condition for an impermeable (solid) object to stipulate that the normal velocity at each panel control point should be zero. In the video, we also simplify down the resulting uniform flow term in the velocity equation.

Source Panel Method: Geometric Integrals

When we take the appropriate partial derivative (normal, tangential, X, or Y) of the velocity potential equation, we end up with a complicated integral expression inside the source panel term. In order to code up our system of equations in the next section, we need to find an explicit expression for this integral (also called the geometric integral since it only depends on the airfoil's geometry). The videos below have the full derivations for the normal, tangential, X, and Y geometric integrals. You should at least watch the I(ij) video since it includes the entire derivation, whereas the other videos don't repeat the portions that are the same as the I(ij) derivation video (to keep them shorter).

Source Panel Method System of Equations

Now that we have the normal velocity expression for each panel on the airfoil, we can set up a system of equations that can be easily solved.

Source Panel Method: Circular Cylinder

We have finally finished the derivations needed to code up a working version of the source panel method. Recall that this implementation uses constant source panel strengths (which can vary from panel to panel). This first implementation of the method is for the simplest case: flow over a circular cylinder. The reason to use this simple case is that it has an analytical solution for the pressure coefficient that we can compare to (and it is also generally used as a source panel method comparison test case). The code is provided for both MATLAB and Python. The main code is the SP_Circle file, which needs both functions to run properly (COMPUTE_IJ_SPM and STREAMLINE_SPM).

Source Panel Method: Airfoil

After making sure the simple validation case of the circular cylinder worked properly, we updated the code to be able to run with airfoils. There are a couple more functions, programs, and directories needed when running this code. You can run my code in either MATLAB or Python. Whichever you choose, make sure to download all the files with that extension (.m or .py) from the list below. You will also need the directory with the airfoils (Airfoil_DAT_Selig, make sure to extract after downloading the zip file) and the XFOIL executable (xfoil.exe) in the directory with all the code. To execute the code, run the SP_Airfoil script.

Vortex Panel Methods: Geometric Integrals

For the source panel method, we derived the geometric integral expressions for the normal, tangential, X, and Y directions. Here, we go through similar derivations, but this time for the vortex panel method.

Vortex Panel Method System of Equations

In the same way that we wrote the system of equations for the source panel method, we can write the system of equations for the vortex panel method. To include the Kutta condition equation in the matrix, we must remove one of the normal velocity equations for one of the control points.

Vortex Panel Method: Airfoil

The source panel method code was updated to be able to solve for the vortex panel strengths instead of the source panel strengths. You can run my code in either MATLAB or Python. Whichever you choose, make sure to download all the files with that extension (.m or .py) from the list below. You will also need the directory with the airfoils (Airfoil_DAT_Selig, make sure to extract after downloading the zip file) and the XFOIL executable (xfoil.exe) in the directory with all the code. To execute the code, run the VP_Airfoil script. The limitations of this VPM implementation are shown in my YouTube video, and motivate the need for the combined source/vortex panel method.

Source/Vortex Panel Method System of Equations

The previous video on the constant strength vortex panel method showed that there are still some limitations with this simplified method, and to improve it we can combine the source and vortex panel methods into one source panel/vortex panel (SPVP) method. This video covers how to build the system of equations for the SPVP method and how to derive and apply a different version of the Kutta condition.

Source/Vortex Panel Method: Airfoil

We can now implement the matrix system defined in the previous section in our code. Note that to run the code, you will need both the SPM and the VPM functions, since this method uses a combination of both of them. In the YouTube video, we will look at how to implement the changes in the code, and go through some examples of different airfoils.

Multi-Element Source/Vortex Panel Method

This is the final video of the series, where I adapt the code from the single-airfoil SPVP code to be able to handle multi-airfoil systems. In my YouTube video, I first show how to update the existing code, and then I go through some sanity check cases, some fun cases, and a quasi-validation case. If you're still here, thanks for sticking around until the end.

About

Source and vortex panel method codes referenced in my YouTube videos.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • MATLAB 59.3%
  • Python 40.7%