I wrote this article a long time ago about how to use the class-shape-transformation (CST) parameters to create an airfoil:

Short note on CST method for airfoil parameterization ( MATLAB Code included)

I think some people want to find the CST parameters for an existing airfoil, which can be used later for optimization purpose (for example). If you want to do this, basically you have to minimize the error between your CST-generated airfoil and the target airfoil. In this post I will give you some simple example in MATLAB about how to do this. First, let us define the following error measure in a matlab-like language: error = mean(abs(yt-yp)), which means that we want to compute the mean absolute error between the y-coordinate of the target airfoil (yt) and the CST-generated airfoil (yp). We can easily see that the ‘error’ is the y-coordinate deviation of your CST airfoil to the target airfoil, measured at every point in the x-coordinate including the upper and lower surface. In order to do this, you have to create a computer code that calculate this error and then set the error as the output of the code. The input of the code itself is exactly the CST weights themselves. Please note that the principle is similar regardless the parameterization method that you used (CST, PARSEC, or anything else).

Let me you give an example. Here we want to fit the RAE 2822 airfoil with CST parameters of 4 weights each in the upper and lower surface (so in total there are 8 parameters to be determined). The main program is the ‘airfoilfit.m’ with error term as the output. The ‘airfoilfit.m’ code calls the ‘CST_airfoil_fit.m code’, which is the CST generation code that I modified specifically for this purpose. I also include the sample of the RAE 2822 airfoil for this demonstration.

In order to find the CST parameters that fit your airfoil, we have to do the optimization procedure with the objective is to minimize the error mentioned before. This can be done simply by using the fmincon (or you can use the unconstrained fminunc) as follows:

[Wopt]=fmincon(@(W) airfoilfit(W,yt,XL,XU,0),[-1 -1 -1 -1 1 1 1 1],[],[],[],[],ones(1,8)*-1,ones(1,8),[]);

where yt is the y-coordinate of the target airfoil (lower+upper surface), while the XL and XU are the x-coordinate of the lower and upper surface, respectively. I also set the trailing edge thickness to zero to match the RAE 2822 data. Here, what we want to find is the W (CST weights) that returns the lowest error, where the initial solution is [-1 -1 -1 -1 1 1 1 1] and we set the minimum and maximum search bounds as -1 and 1 for all weights. Note that the first four weights are for the lower surface , while the rest are for the upper surface. The output of this optimization procedure is the ‘Wopt’ that hopefully could match the RAE 2822 airfoil.

Just run the script ‘demo.m’, and.. voila! you will have the CST airfoil that closely matches the RAE 2822 airfoil. The Wopt values that I found is [-0.1235 -0.1735 -0.1787 0.0583 0.1262 0.1516 0.2070 0.1957], with the error value of 0.0002. The shape is not perfectly similar especially in the lower surface, since it is more difficult to be approximated. This can be further refined by adding the amount of the CST weights, or by setting a different initial solution. I suggest to try it with different initial solution in order to find the optimum CST parameters that return the lowest error. Following is the final plot from the demo.m code:

Please download the demonstration and code in the following dropbox link:

https://www.dropbox.com/s/71qo1cr2viiaxxo/CST_AIRFOIL_FIT_DEMO.zip?dl=0

The code is quite a draft and perhaps is quite ugly, so please modify it by yourself if you want a better-looking code.

Have fun!

Pram

Pingback: Short note on CST method for airfoil parameterization ( MATLAB Code included) | Pramudita Satria Palar

Bryan

said:Hi!

I tried to fit my airfoil (s1223) but i couldn’t :c

could you help me? i don’t know what am i doing wrong:

Im defining the geometry of the airfoil as a variable, then i redefine all the other variables (like XU XL YU YL etc.) but the CST parameterization doesn’t work :C

I tried to add more Bernstein coefficients, but i had the same result, a crocked airfoil that doesn’t fit at all the target airfoil :c

I’m trying to do my thesis, but i can’t move on if a don’t get any result.

Your help would be truly appreciated by this little aeronautics student C:

Thanks!

pramuditasatriapalar

said:Hi bryan! First of all, I apologize for a very late reply. Can you send me the picture of your crocked airfoil? Perhaps you can send me a snippet of your code so I can see what’s wrong.