Package windSimSuite :: Package models :: Package tjaerborgData :: Module airfoils
[hide private]

Source Code for Module windSimSuite.models.tjaerborgData.airfoils

 1  #!/usr/bin/env python 
 2  # -*- coding: utf-8 -*- 
 3  # 
 4  # This file is part of MBDyn sim suite. 
 5  # Copyright (C) 2007 André ESPAZE, as part of a Master thesis supervised by 
 6  # Martin O.L.Hansen (DTU) and Nicolas Chauvat (Logilab) 
 7   
 8  # MBDyn sim suite is free software; you can redistribute it and/or modify 
 9  # it under the terms of the GNU General Public License as published by 
10  # the Free Software Foundation; either version 2 of the License, or 
11  # (at your option) any later version. 
12  # 
13  # This program is distributed in the hope that it will be useful, 
14  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
16  # GNU General Public License for more details. 
17  # 
18  # You should have received a copy of the GNU General Public License 
19  # along with this program; if not, write to the Free Software 
20  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
21  # 
22  """A module loading the Tjaereborg airfoils.  
23  C{Airfoil} instances are created from the L{windSimSuite.sections} module. 
24  All the airfoils are then stored in the L{AIRFOILS} dictionary. 
25  """ 
26  import os 
27   
28  from windSimSuite.common import Angle 
29  from windSimSuite.sections import Airfoil, Curve 
30   
31 -def load_airfoil(file_name):
32 """Return an C{Airfoil} instance from its filename""" 33 fid = open(file_name) 34 lines = fid.readlines() 35 fid.close() 36 37 airfoil = Airfoil() 38 attached_lift_curve = Curve() 39 separated_lift_curve = Curve() 40 drag_curve = Curve() 41 42 for line in lines: 43 values = map(float, line.split()) 44 angle = Angle(values[0], "deg") 45 attached_lift_curve.add_point(angle, 46 values[1]) 47 drag_curve.add_point(angle, values[2]) 48 separated_lift_curve.add_point(angle, 49 values[-1]) 50 airfoil.set_lift(attached_lift_curve, 51 separated_lift_curve) 52 airfoil.set_drag(drag_curve) 53 return airfoil
54 55 56 57 AIR_DIR = os.path.join(os.path.dirname(__file__), "datas") 58 59 AIRFOILS = {} 60 for idx in range(4, 15): 61 key = "%02d" % idx 62 filename = "tjaere%s_ds.dat" % key 63 airfoil_obj = load_airfoil(os.path.join(AIR_DIR, filename)) 64 airfoil_obj.set_name(key) 65 AIRFOILS[key] = airfoil_obj 66