Databases and OpenSCAD

Airfoils



What is it?

This tutorial is based on the work of members of La Crosse Inventers Guild. It uses a php script to convert all the airfoils from the UIUC Airfoil Coordinates Database (about 1550 or so ) to scad and stl files.

Airfoils

How does the shape of the blade affect the ability to go higher?
What variables can you change to affect flight?

Here's what you need to think about:

  1. Drag

    Drag is air resistance, the force that is working against the blades, causing them to slow down.You want to design your blades so that they have as little drag as possible.

    Drag increases with the area facing the wind. Changing the angle of the blades will change the area facing the apparent wind (the real wind combined with the wind created with the blades movement or headwind). Changing the angle of the blades changes the area facing the wind. A blade pitch angle between 10-20° has less drag than greater angles.

    Drag also increases with wind speed, so the faster the blades move through the air, the more drag force it experiences. The tips of the blade move faster than the base which is why the shape changes along the length of the blade.

  2. Lift

    Lift is the force that opposes drag. Your goal is to generate as much lift while minimizing the drag.

    The amount of lift a blade can generate is determined by
    1. shape
    2. speed of air passing around blade
    3. the angle of the blade relative to the apparent wind


  3. Shape

    Shape is how you can take advantage of the Bernoulli Effect:
    Faster moving air has lower pressure. Wind turbines are cambered so that the air molecules moving around the blade travel faster on the downwind side than on the upwind side. This shape is like a teardrop. The downwind side is curved, while the upwind side is almost flat. Air moves faster on the curved, downwind side of the blade so there is less pressure on this side of the blade. The difference in pressure on the other side of the blade causes the blade to be lifted toward the curve of the airfoil.

    airfoil_shapes.png


    The profile of a blade changes down its length. It should get flatter and narrower toward the tip in order to optimize the lift and minimize the drag.


  4. Speed

    The faster the blade moves, the more drag it experiences. As the blades move faster, lift also increases. The faster that the air passes over the blade, the more lift can be generated.



  5. Angle

    The angle affects the amount of lift generated. The angle of the blade relative to the plane of rotation is the pitch angle.The angle of the blade relative to the apparent wind is called the angle of attack. Generally an angle of attack of 10-15° creates the least drag.

  6. Torque

    Torque is the force that turns or rotates something. Torque is equal to the force multiplied by distance, so the longer the blade, the more torque can be generated. But increasing the torque increases the drag.




So when you design, you need to think about:

  • shape
  • size
  • number of blades
  • angle of blades
  • airfoil shape
  • pitch




Helpful links for Blade Design:


Wind Turbines

Converting kinetic energy into electrical energy. Kinetic energy of wind turns the blades which drives a generator that converts the kinetic energy to electromagnetic energy.

The current is used to do work, while voltage (the resulting force after overcoming resistance) is the energy required to drive the flow of the current.

A Turbine

The basic concept is simple. A framework or support column holds up a large wheel or turbine blades that looks like a fan or airplane propeller. The angled blades catch passing winds and deflect some of the wind's energy, which pushes the blades around, turning a central shaft. The shaft can be connected via gears or belts to machinery on the ground or in a nearby structure. Alternatively, the shaft can be connected directly to a generator that produces electricity, which is then transmitted.

Blades

Blades of a windmill spin because of two principles:
  1. Newton's Third Law—For every action there is an equal and opposite reaction. So when the wind hits the blade, the blade is pushed. If the blade is at a certain angle, the wind is deflected at an opposite angle, which pushes the blades away from the deflected wind. You can see this in action with the flat blade. If you push the blade it will will move in the direction away from your finger.

  2. The Bernoulli Effect—Faster moving air has lower pressure. Wind turbines are cambered so that the air molecules moving around the blade travel faster on the downwind side than on the upwind side. This shape is like a teardrop. The downwind side is curved, while the upwind side is almost flat. Air moves faster on the curved, downwind side of the blade so there is less pressure on this side of the blade. The difference in pressure on the other side of the blade causes the blade to be lifted toward the curve of the airfoil.

    Experiment:

    1. Take two pieces of paper
    2. Fold them in half
    3. Unfold them and place them together so that the folds you made line up but the creases should be on the outside
    4. Blow between the papers
    5. Did it match your expectations


    The speed of the air is higher between the two pieces of paper than outside the papers. Higher velocity leads to a lower pressure between the sheets.



How blades capture wind power

Wind turbine blades work by generating lift with their shape. The more curved side generates low air pressures while high pressure air pushes on the other side of the airfoil. The net result is a lift force perpendicular to the direction of flow of the air.
lift_drag.png
Lift and Drag Vectors from WE Handbook- 2- Aerodynamics and Loads

The lift force increases as the blade is turned to present itself at a greater angle to the wind. This is called the angle of attack. At large angles of attack the blade stalls and the lift decreases again. When it comes to generating the maximum lift, there is an optimum angle of attack.

Another force also exists. This is called drag. This force is parallel to the wind flow, and also increases with angle of attack. If the airfoil shape is good, the lift force is much bigger than the drag. But at very high angles of attack, the drag will increase dramatically. When the angle is slightly less than the maximum lift angle, the blade will reach its maximum lift/drag ratio. The best operating point will be between these two angles.

The blade's own movement through the air means that the wind is blowing from a different angle. This is called apparent wind. The apparent wind is stronger than the true wind but its angle is less favorable: it rotates the angles of the lift and drag to reduce the effect of lift force pulling the blade round and increases the effect of drag slowing it down. So, to maintain a good angle of attack, your blade must be turned further from the true wind angle.

The closer to the tip of the blade you get, the faster the blade is moving through the air and the greater the apparent wind angle is. Therefore the blade needs to be turned further at the tips than at the root. Your blade must be built with a twist along its length. Typically the twist is around 10-20° from root to tip.

In general the best lift/drag characteristics are obtained by a blade that is fairly thin.

Length: The blade length determines how much wind power can be captured.

Aerodynamic Section: The blades have an aerodynamic profile in their cross section to create lift and rotate the turbine.

Planform Shape: The planform shape gets narrower towards the tip of the blade to maintain a constant slowing effect across the swept area. This ensures that none of the air leaves the turbine too slowly (causing turbulence), yet none is allowed to pass through too fast (which would represent wasted energy).

Airfoil Thickness: The thickness increases towards the root to take the structural loads, in particular the bending moments. If loads weren't important then the section thickness/chord ratio would be about 10-15% along the whole length.

Blade Twist: To maintain optimum angle of attack of the blade section to the wind, it must be twisted along its length.

Blade Number and Rotational Speed: Typically three blades.

Pitch Control: Because the wind power varies so greatly (with the cube of wind speed), the turbine must be able to generate power in light winds and withstand the loads in much stronger winds. Therefore, above the optimum wind speed, the blades are typically pitched either into the wind (feathering) or away from the wind (active stall) to reduce the generated power and regulate the loads.



What's the tutorial?

  1. If you do not have OpenSCAD installed, download the application from openscad.org


  2. Download the database. Look for Archives: Unix tar archive of Version 2.0 (1550 airfoils): [coord_seligFmt.tar.gz 618 kb] Note that the files are in the Unix EOF format. Zip archive: [coord_seligFmt.zip 911 kb]


  3. Here is the php script. Save it in the coord_seligFmt folder and be sure to change the openscad_exe path.
    <?php
    function read_all_files($root = '.'){ 
      $files  = array('files'=>array(), 'dirs'=>array()); 
      $directories  = array(); 
      $last_letter  = $root[strlen($root)-1]; 
      $root  = ($last_letter == '\\' || $last_letter == '/') ? $root : $root.DIRECTORY_SEPARATOR; 
      
      $directories[]  = $root; 
      
      while (sizeof($directories)) { 
        $dir  = array_pop($directories); 
        if ($handle = opendir($dir)) { 
          while (false !== ($file = readdir($handle))) { 
            if ($file == '.' || $file == '..') { 
              continue; 
            } 
            $file  = $dir.$file; 
            if (is_dir($file)) { 
              $directory_path = $file.DIRECTORY_SEPARATOR; 
              array_push($directories, $directory_path); 
              $files['dirs'][]  = $directory_path; 
            } elseif (is_file($file)) { 
              $files['files'][]  = $file; 
            } 
          } 
          closedir($handle); 
        } 
      } 
      
      return $files; 
    } 
    $file_dir = read_all_files();
    
    //Replace with your path
    $openscad_exe="/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD";
    $file_array = array();
    foreach( $file_dir['files'] as $file ){
        if( substr( $file , -3 ) == "dat" ){
            $file_array[] = $file;
        }
    }
    foreach( $file_array as $file ){
        $data = file_get_contents($file);
        //echo $data;
        $lines = explode( "\n" , $data );
        $return = "\t[\n";
        $x = 0;
    
        foreach( $lines as $line ){
            $subline = explode( " " , $line );
            if( count( $subline ) > 1 ){
                //var_dump( $subline);
                if( $x != 0 ){
                    $return .= ",\n";
                }
                if( is_numeric( preg_replace('/\s+/', '', $subline[0] ) ) && is_numeric( preg_replace('/\s+/', '', $subline[1] ) ) ) {
                    echo "int ";
                    $return .= "\t\t[ " .  preg_replace('/\s+/', '', str_replace('-.' , "-0." , $subline[0] ) ) . " , " .  preg_replace('/\s+/', '', str_replace('-.' , "-0." , $subline[1] ) ) . " ] ";
                    $x++;
                }
                
                echo "2 ";
            }
            
            echo "Line $line\n";
            
            }
            $return .= "\n\t]";
            $scad = "bracket_height=5;
            wing_width=200;
            difference(){
            linear_extrude(height=bracket_height,center=true) translate([-wing_width/2,0,0]) scale(wing_width,wing_width,1) polygon( $return , center=true);
            linear_extrude(height=bracket_height+2,center=true) translate([(-wing_width/2) *.8,1,0]) scale(wing_width*.8,wing_width*.8,1) polygon( $return , center=true);
        }
        intersection(){
        linear_extrude(height=bracket_height,center=true) translate([-wing_width/2,0,0]) scale(wing_width,wing_width,1) polygon( $return , center=true);
        union(){
        translate([-30,5,0]) difference(){
             union(){
                cube( [5,100,10] ,center=true);
                cylinder(h=100,r1=6,r2=6,center=true);
            }
            cylinder(h=100,r1=3,r2=3,center=true);
        }
        translate([30,5,0]) difference(){
             union(){
                cube( [5,100,10] ,center=true);
                cylinder(h=100,r1=6,r2=6,center=true);
            }
            cylinder(h=100,r1=3,r2=3,center=true);
        }
        }
        }
            ";
            file_put_contents(str_replace('dat' , 'scad' , preg_replace('/\s+/', '',$file) ) ,$scad);
            $exec= "\"$openscad_exe\" -o " . str_replace('dat' , 'stl' , preg_replace('/\s+/', '',$file) ) . " " .str_replace('dat' , 'scad' , preg_replace('/\s+/', '',$file )). "";
            //$exec= "\"$openscad_exe\" -o " . str_replace('dat' , 'stl' , preg_replace('/\s+/', '',$file) ) . " " .str_replace('dat' , 'scad' , preg_replace('/\s+/', '',$file )). "";
            echo $exec;
            shell_exec($exec);
        }
    ?>
    Openscad can be used with the command line. When called with the -o option, OpenSCAD will not start the GUI, but execute the given file and export to the output_file in a format depending on the extension (.stl / .off / .dxf, .csg). This is what happens in this line:
    shell_exec($exec);
    



  4. To run the script, open Terminal or your Command line prompt and navigate to the coord_seligFmt folder. Type in
    php dat_to_sdl.php


    Around 50% are ready to print, another 25% need some minor tweeking on the bracket placement, and the other 25% are unusable.




Why am I doing this?

You just created at least 500 usable files by using a database.

Now what?

  1. Upload one of your airfoils or something you created with one of them to Thingiverse
  2. Come back tomorrow for more information and inspiration!