This code is a panel method solver for 2D airfoils and multi airfoil wings. It is based on the potential flow theory and uses a source and vortex distribution to model the flow around the airfoil. The code is composed the panel_method module, which contains the main functions for the panel method solver and a streamlit app.
The method assumes a potential flow. The flow is modeled using a combination of source and vortex distributions along the surface of the airfoil. The goal of the solver is to determine the strength of these distributions such that the following boundary conditions are satisfied:
- The flow tangency condition: The flow velocity at each panel must be tangent to the surface of the airfoil.
- The Kutta condition: The tangential velocity at the trailing edge's upper and lower panel must be zero.
To achieve this, a system of linear equations is formulated based on the influence of each panel on every other panel. To assemble this system, it is, first, necessary to calculate some geometrical parameters for the whole wing:
In the code the following index are used:
$i$ : Index of the control panel$j$ : Index of the panel influenceing the control panel$k$ : Index of x and y coordinates (0 for x and 1 for y)
The basic input is a list of points that define the airfoil shape. In the code, this information is represented by the following np.array object:
Then, the control point of each panel is calculated as the midpoint between the two endpoints:
The length of each panel is calculated as:
Then, the tangent and normal vectors of each panel are calculated as:
Where
The previous calculations are made with respect to the global coordinate system. However, to calculate the influence coefficients, it is easier to transform the coordinates to a local system aligned with each panel. This can be done by using the normal and/or tangent vectors to define the transformation (the
Tis tensor stores the vector from the j-th panel to the i-th control point. Then, the local coordinates are calculated as:
With all this information, it is possible to calculate the influence coefficients of each panel on every other panel. Two different influences are considered: the source influence and the vortex influence. Both of them impose a
Analogously, the vortex influence can be calculated as:
Now, it is necessary to transform the influence back to the global coordinate system. This can be done using the following transformations:
Now, that all the influence coefficients are calculated, it is possible to assemble the system of linear equations:
That means that we have to solve for
The matrix
Therefore, each of the sub-matrices and sub-vectors can be build as:
A11 = np.einsum('ik,ijk->ij', N, dVs)
A12 = np.add.reduceat(np.einsum('ik,ijk->ij', N, dVv), ids_reduce, axis=1)
A21 = np.einsum('ik,ijk->ij', T[n_kutta[:,0], :], dVs[n_kutta[:,0], :, :]) + np.einsum('ik,ijk->ij', T[n_kutta[:,1], :], dVs[n_kutta[:,1], :, :])
A22 = np.add.reduceat(np.einsum('ik,ijk->ij', T[n_kutta[:,0], :], dVv[n_kutta[:,0], :, :]) + np.einsum('ik,ijk->ij', T[n_kutta[:,1], :], dVv[n_kutta[:,1], :, :]), ids_reduce, axis=1)And:
b1 = -Vinf.dot(N.T).T
b2 = -(Vinf.dot(T[n_kutta[:,0], :].T) + Vinf.dot(T[n_kutta[:,1], :].T)).TThis code is responsible to provide the class used as input to the solver which allow us to simulate.
This code is responsable to generate the wing. It works with 2 base base class: Airfoil e Wing. The first is responsible to adjust the flap so that the solver can interpret it without problems. That means that it has to do a few operations besides the collection, translation and rotation of points. Those operations can be seen in the code itself. The Wing class by the other side is responsible to collect all the airfoils and create a list with all of them and a few other things...
This is the run code. In it you can see the solver for the metho and the class responsable for holding the results provided by tghe functions
This code is resposable for the analysis of the results previously obtained. It is runly resposable for the contour and grid generation so that we can have a better visualization of the flow.
This code is responsible to make the results visualization better in order to understand the results in a more efficient way.
The streamlit app is composed by the main file Home.py and a few pages in the pages folder. This main file is responsible to provide the general layout of the app and show this README, and the pages are responsible to provide the functionalities for the simulation.
run streamlit Home.py
All the packages used in this code are listed in the requirements.txt file. To install them just run the following command in your terminal:
pip install requirements.txtAlthought this code is functional, it still have a long way to go in terms of performance and funcionalities. In this section I list a few od the next few steps I believe can be done in order to make this code better.
-
Add more pre biuild funcionalities. Add more functions and improve the app. Including the Profile Editor page to edit the points file.
-
Validate the results comparing then to ones obtained on xFoil. I left this for last because it should be the first one I remove.
-
Add turbulent viscous flow model to the code. This will allow the results to be much closer to real ones and use higher angle of attacks with more fidelity on the results at a larger range.
Below are some useful references used during the development of this code:
- Katz, Plotkin: Low Speed Aerodynamics
- Oregon State - Intermediate Fluid Mechanics (specially chapter 4, 5 and 6)
- Science Direct - Panel Method Overview
