Package mbdyn :: Package elts :: Module aerodynamic
[hide private]

Source Code for Module mbdyn.elts.aerodynamic

  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  """The elements for the aerodynamic group""" 
 23  from mbdyn.references import NONE_REF, NODE_REF 
 24  from mbdyn.common import MANAGER, get_mbdyn_name 
 25   
 26  from mbdyn.elements_base import CommonElement, ElementWithNode 
 27   
 28  AERODYNAMIC_CLASS = {} 
 29   
30 -class AerodynamicBeam(CommonElement):
31 """The MBDyn aerodynamic beam. This object is currently 32 not in use, it needs to be reviewed. 33 """ 34
35 - def __init__(self, name="Aerodynamic beam"):
36 CommonElement.__init__(self, name) 37 self.ref = NONE_REF 38 self.mbdyn_type = "aerodynamic beam" 39 self.class_key = "AerodynamicBeam" 40 self.group_key = "AERODYNAMIC" 41 42 self.beam = None 43 self.mbdyn_beam = None 44 self.rotor = None 45 self.mbdyn_rotor = None 46 self.arg_names = ["label", "beam", "rotor", 47 "offset1", "orientation_matrix1", 48 "offset2", "orientation_matrix2", 49 "offset3", "orientation_matrix3"] 50 51 52 self.control_data_with_values = [("aerodynamic elements", 53 "+1 # %s" % self.name)] 54 self.chord_dist = [] 55 self.twist_dist = [] 56 self.airfoil_desc = [] 57 self.mbdyn_airfoil_data = []
58
59 - def set_offset1(self, *args, **kargs):
60 """Set the first relative surface offset""" 61 if kargs.has_key("ref"): 62 if kargs["ref"] == "node": 63 kargs["ref"] = NODE_REF 64 MANAGER.add_vector(self, "offset1", args, kargs)
65
66 - def set_orientation_matrix1(self, *args, **kargs):
67 """Set the first orientation matrix of the surface offset""" 68 MANAGER.add_orientation_matrix(self, "orientation_matrix1", args, kargs)
69
70 - def set_offset2(self, *args, **kargs):
71 """Set the second relative surface offset""" 72 if kargs.has_key("ref"): 73 if kargs["ref"] == "node": 74 kargs["ref"] = NODE_REF 75 MANAGER.add_vector(self, "offset2", args, kargs)
76
77 - def set_orientation_matrix2(self, *args, **kargs):
78 """Set the second orientation matrix of the surface offset""" 79 MANAGER.add_orientation_matrix(self, "orientation_matrix2", args, kargs)
80
81 - def set_offset3(self, *args, **kargs):
82 """Set the third relative surface offset""" 83 if kargs.has_key("ref"): 84 if kargs["ref"] == "node": 85 kargs["ref"] = NODE_REF 86 MANAGER.add_vector(self, "offset3", args, kargs)
87
88 - def set_orientation_matrix3(self, *args, **kargs):
89 """Set the third orientation matrix of the surface offset""" 90 MANAGER.add_orientation_matrix(self, "orientation_matrix3", args, kargs)
91
92 - def attach_to_beam(self, beam):
93 """Attach the aerodynamic beam to a structural one""" 94 self.beam = beam
95
96 - def attach_to_rotor(self, rotor):
97 """Attach the aerodynamic beam to a rotor""" 98 self.rotor = rotor
99
100 - def set_labels(self):
101 """Set the MBDyn labels for writing the input file""" 102 self.mbdyn_beam = self.beam.mbdyn_label 103 rotor_label = self.rotor.mbdyn_label.value 104 import copy 105 self.mbdyn_rotor = copy.copy(self.rotor.mbdyn_label) 106 self.mbdyn_rotor.set_value("rotor, " + str(rotor_label))
107
108 - def set_chord_shape_function(self, keyword, com=None):
109 """Enter the chord shape function type""" 110 MANAGER.add_argument(self, "chord_shape_function", keyword, com)
111
112 - def set_twist_shape_function(self, keyword, com=None):
113 """Set the twist shape function""" 114 MANAGER.add_argument(self, "twist_shape_function", keyword, com)
115
116 - def add_chord(self, radius, chord):
117 """Add a chord distribution to the aerodynamic beam""" 118 self.chord_dist.append((radius, chord))
119
120 - def add_twist(self, radius, twist):
121 """Add a twist distribution""" 122 self.twist_dist.append((radius, twist))
123
124 - def add_airfoil(self, filename, radius_limit, com=None):
125 """Add an airfoil contained in a filename""" 126 self.airfoil_desc.append((filename, radius_limit, com))
127
128 - def set_shape_position_value(self, value, com=None):
129 """Set the value of the shape position""" 130 MANAGER.add_argument(self, "shape_position_value", value, com, 131 mbdyn_value = "const, %s" % str(value))
132
133 - def set_shape_velocity_value(self, value, com=None):
134 """The the velocity of the shape""" 135 MANAGER.add_argument(self, "shape_velocity_value", value, com, 136 mbdyn_value = "const, %s" % str(value))
137
138 - def set_integration_points_nb(self, value, com=None):
139 """Set the number of integration points""" 140 MANAGER.add_argument(self, "aero_integration_points", value, com)
141
142 - def update_data(self):
143 """Update the properties set on the object""" 144 self._set_chord() 145 self._add_shape_values_ref() 146 self._set_twist() 147 self._set_airfoil_header() 148 self._set_airfoils()
149
150 - def _set_chord(self):
151 """Set the chord on the beam""" 152 self.arg_names += ["chord_shape_function", "chord_nb"] 153 MANAGER.add_argument(self, "chord_nb", len(self.chord_dist)) 154 for i, (radius, chord) in enumerate(self.chord_dist): 155 arg_name = "chord %01d" % (i+1) 156 self.arg_names += [arg_name] 157 mbdyn_value = "%s, %s" % (str(radius), str(chord)) 158 MANAGER.add_argument(self, arg_name, (radius, chord), 159 mbdyn_value=mbdyn_value)
160
161 - def _add_shape_values_ref(self):
162 """Set the shape values for MBDyn""" 163 self.arg_names += ["shape_position_value", "shape_velocity_value"]
164
165 - def _set_twist(self):
166 """Set the twist on the beam""" 167 self.arg_names += ["twist_shape_function", "twist_nb"] 168 MANAGER.add_argument(self, "twist_nb", len(self.twist_dist)) 169 for i, (radius, twist) in enumerate(self.twist_dist): 170 arg_name = "twist %01d" % (i+1) 171 self.arg_names += [arg_name] 172 mbdyn_value = "%s, %s" % (str(radius), str(twist)) 173 MANAGER.add_argument(self, arg_name, (radius, twist), 174 mbdyn_value=mbdyn_value)
175
176 - def _set_airfoil_header(self):
177 """Set the airfoil headers""" 178 self.arg_names += ["aero_integration_points"] 179 arg_name = "aero_type" 180 self.arg_names += [arg_name] 181 MANAGER.add_argument(self, arg_name, ("c81", "multiple"), 182 mbdyn_value="c81, multiple")
183
184 - def _set_airfoils(self):
185 """Set the airgoil filename with their labels""" 186 arg_name = "airfoil_nb" 187 self.arg_names += [arg_name] 188 MANAGER.add_argument(self, arg_name, len(self.airfoil_desc)) 189 for i, (filename, radius_limit, com) in enumerate(self.airfoil_desc): 190 indice = i+1 191 192 arg_name = "aero_profile%i" % indice 193 mbdyn_value = 'c81 data: %i, "%s";' % (indice, filename) 194 MANAGER.add_argument(self, arg_name, filename, com, 195 mbdyn_value=mbdyn_value) 196 mbdyn_inst = getattr(self, get_mbdyn_name(arg_name)) 197 self.mbdyn_airfoil_data.append(mbdyn_inst.get_line(separator="")) 198 199 arg_name = "airfoil%i" % indice 200 self.arg_names += [arg_name] 201 mbdyn_value = "%i, %s" % (indice, radius_limit) 202 MANAGER.add_argument(self, arg_name, (filename, radius_limit), 203 com, 204 mbdyn_value)
205 206 207 AERODYNAMIC_CLASS["AerodynamicBeam"] = AerodynamicBeam 208 209
210 -class Rotor(ElementWithNode):
211 """Used to associate the aerodynamic elements. The rotor element 212 is able to compute the induced velocity at an arbitrary point of 213 the rotor disk. Finally this element is not currently used. 214 """ 215
216 - def __init__(self, name="rotor"):
217 ElementWithNode.__init__(self, name) 218 self.mbdyn_type = "rotor" 219 self.class_key = "Rotor" 220 self.mbdyn_group = "ROTOR" 221 222 self.craft_node = None 223 self.mbdyn_craft_node = None 224 self.rotor_node = None 225 self.mbdyn_rotor_node = None 226 self.arg_names += ["craft_node", "rotor_node", 227 "induced_velocity_model", 228 "reference_omega", "reference_radius"]
229
230 - def attach_to_node(self, node):
231 """Not relevant in that case because two nodes are used: 232 the craft and rotor nodes. 233 Use L{set_craft_node} and L{set_rotor_node} instead.""" 234 print self.attach_to_node.__doc__
235
236 - def set_craft_node(self, node, com=None):
237 """Set the craft node of the rotor""" 238 MANAGER.add_argument(self, "craft_node", node, com)
239
240 - def set_rotor_node(self, node, com=None):
241 """Set the rotor node""" 242 MANAGER.add_argument(self, "rotor_node", node, com)
243
244 - def set_induced_velocity_model(self, keyword, com=None):
245 """Set the induced velocity model: uniform, glauert or mangler""" 246 arg_name = "induced_velocity_model" 247 MANAGER.add_argument(self, arg_name, keyword, com, 248 "induced velocity, %s" % keyword)
249
250 - def set_reference_omega(self, value, com=None):
251 """To decide whether to inhibit or not the induced velocity 252 computation if the rotor speed is very low, in [rad/s]""" 253 MANAGER.add_argument(self, "reference_omega", value, com)
254
255 - def set_reference_radius(self, value, com=None):
256 """Used in the adimensionalization of the rotor related parameters, 257 in [m].""" 258 MANAGER.add_argument(self, "reference_radius", value, com)
259
260 - def set_node_label(self):
261 """Set the label for the MBDyn input file of the craft and rotor 262 nodes""" 263 self.mbdyn_craft_node = self.craft_node.mbdyn_label 264 self.mbdyn_rotor_node = self.rotor_node.mbdyn_label
265