Author: Sandro Fergnani
I wrote rfile mainly because the CAD software I use to plot the templates of the airfoils for my models does include a sophisticated programming language, but too sophisticated and difficult to learn and master. I knew C and I decided it wasn't time to learn another programming language. I learned C by myself and, as a result, I'm not a good programmer, but I enjoy myself. As you will see, no user interface at all. Rfile is a DOS program. You can run it in a DOS shell of Windows 95 if you want, but it's a DOS program.
What does rfile do?? Rfile takes a file with airfoil coordinates and produces another ASCII file that contains:
1) the airfoil described in segments;
2) the coefficient of moment Cm0;
3) the 0 lift angle of the airfoil;
4) the mean line described by points.
Obviously the results are not as accurate as the ones you can get from the wind tunnel, but for my purposes they are enough, and, after all, nobody can forbid to make the calculation more accurate in the future.
- The airfoil MUST be described with a length of 1 unit.
- The coordinates must describe a curve that begins from trailing edge, to leading edge describing the upper surface, and then back to trailing edge describing the lower surface.
- Empty rows are ignored.
- Rows starting with the character '*' are treated as comments.
Example: file describing the Eppler E222 airfoil. Dashed lines are used to mark the data. They are not included in the file.
* Airfoil Eppler 222 (E222)
The program tries to interpolate the coordinates to get a smooth curve using spline algorithms that are quite complicated, but it works. By default the program calculates the airfoil using 100 segments for each surface of the airfoil (upper and lower), and the output (more on output options later) will contain the coordinates of starting and ending points of the segments. You can increase the number of segments up to 2048 with a command line switch.
Why segments?? There is a reason. The calculated segments are a single chain starting from trailing edge to leading edge and then back to trailing edge. Imported in my CAD program with little editing I obtain a file that can be sent to a plotter. I was lucky to find an old A3 plotter by Panasonic. I modified it to use not only pencils, but a steel tool that I took from my Dremel. So I can cut templates directly to phenolic boards!!! This is why I use segments.
The program computes the Cm0 and zero lift angle. This is the part that needs more improvement, but the first results are not bad (at least for me). One of the output options is the mean line, that is described by points.
The syntax of rfile is:
C:\>rfile inp_file [options] outp_file
inp_file = file that contains the coordinates
outp_file = file that contain the results (if omitted stdout is taken)
-n number = number of segments to be used to describe the airfoil. By default is 100 but up to 2048 is supported.
-fu number = scale factor to be applied to the upper surface of the airfoil. Useful to "play" with airfoils to get various versions. Number must be not negative. If > 1 it will be use as enlarging factor. If < 1 a reducing factor.
-fl number = the same as -fu, but it's applied to the lower surface of the airfoil.
-f number = value to be applied to both upper and lower surface.
-ml = print the mean line too.
Examples of use:
C:\>rfile e222 -n 1000 foobar Use the file e222 as input. Output goes into the file foobar. The airfoil will be described by 1000 segments.
C:\>rfile e222 -ml foobar As before, but 100 segments will be used (the default). The output file will contain the coordinates of the mean line.
C:\>rfile e222 -n 500 -fu 1.23 foobar 500 segments will be used and the upper surface of the airfoil will be 23% bigger.
I'm proud of the output options of the program because they are totally designed by me. Since the main design goal was to obtain "something" that can be imported in a CAD program, the output is highly customizable.
Rfile uses a template file called rfile.tpl that contain sections. A section begins with the character '#' followed by the section name. The section is ended by the token "$end". In each section there are some special tokens. Tokens start with the character '^'. There is no limit to the rows that can be present in a section (in theory). The program substitutes the tokens with the output values that it computes.
Actually, there are the following sections:
#airf_data --- Used to define how to print the values of Cm0 and zero lift angle. The two recognized tokens are ^cm0 and ^alfa0.
#print_upper --- The program uses this section before printing the segments that describe the upper surfaces. There are no tokens recognized in this section. I use it to put in the output file some instructions for my CAD program, for example set the color and/or the input layer.
#print_lower --- As before, but the contents of this section are printed in the output file before printing the segments that describe the lower surface of the airfoil. Nice place to put instructions for changing the color and or the input layer.
#after_lower --- This section does not contain recognized tokens, and it's printed after the segments that describe the lower surface.
#segments --- This is the most important section. The recognized tokens are:
^x1 --> X value of starting point of the segment
^y1 --> Y value of the starting point of the segment
^x2 --> X value of the ending point of the segment
^y2 --> Y value of the ending point of the segment
For example: In my CAD program the command that draws a single segment is "segmento singolo." Such command takes the coordinates of two points as parameters. In the syntax of my CAD, each couple of coordinates must be preceded by the character '/'. So, what is the content of my #segments section?
Here we go:
#segments segmento singolo / ^x1 ^y1 / ^x2 ^y2
(Please note that tokens don't need to be isolated. They can be mixed within other words. For example if the token is bla_bla^x1_bla_bla, the output could be bla_bla34.33434_bla_bla. Tokens can be repeated in the same line too. I don't see how this could be useful, but it's free !!)
#mean_line --- Rfile uses this section to print the points that describe the mean line. There are two recognized tokens: ^x and ^y that are the coordinates of the point.
#before_mean_line --- This section doesn't have any tokens but it's printed before the points of the mean line.
I think that the template file can be customized for almost any CAD. The sequence of section processing is:
1) #airf_data -> rfile prints the values of CM0 and zero lift angle.
2) #print_upper -> rfile prints this section.
3) #segments -> use this section to print the segments of the upper surface.
4) #print_lower -> rfile prints this section.
5) #segments -> use this section to print the segments of the lower surface.
6) #after_lower -> rfile prints this section.
7) #mean line -> use this to print the point of the mean line