Package windSimSuite :: Package interface :: Module figures
[hide private]

Source Code for Module windSimSuite.interface.figures

  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  """Possible figures plotted by Matplotlib. This module needs some heavy 
 23  organisation and simplification because it was done in a hurry. 
 24   
 25  For a specific object, like a rotor or blade, the object is passed. 
 26  Others kinds of figures could be imagined: power and 
 27  Weibull distribution, the power of the 3 blades, rotational speed 
 28  and torque... 
 29   
 30  The figure manager can be activated, whether from a GTK tree, 
 31  (for example by "Plot Power") or else from a predefined action in a menu.  
 32  A L{PLOT_TABLE} has been built, it means that each 
 33  possible figure has a key. This key is given by the GTK interface.  
 34  For some object, the key is the name of an attribute, for example 
 35  "power" for the C{Rotor} instance. 
 36  """  
 37   
38 -def plot_power(fig, obj, simu):
39 """Plot the power of an object C{obj}""" 40 axes = fig.add_subplot(111) 41 axes.set_xlabel("Time [s]") 42 axes.set_ylabel("Power [W]") 43 time = simu.results.time 44 values = getattr(obj.results, "power") 45 axes.plot(time, values) 46 axes.axis([time[0], time[-1], 0., 1.1*max(values)]) 47 48 fig.tab_name = "Power of '%s'" % obj.name
49
50 -def plot_electrical_power(fig, obj, simu):
51 """Plot the electrical power of an object C{obj}""" 52 axes = fig.add_subplot(111) 53 axes.set_xlabel("Time [s]") 54 axes.set_ylabel("Elec. Power [W]") 55 time = simu.results.time 56 values = getattr(obj.results, "electrical_power") 57 axes.plot(time, values) 58 axes.axis([time[0], time[-1], 0., 1.1*max(values)]) 59 60 fig.tab_name = "Elec. Power of '%s'" % obj.name
61 62
63 -def plot_tangential_force(fig, obj, simu):
64 """Plot the tangential force of an object C{obj}""" 65 axes = fig.add_subplot(111) 66 axes.set_xlabel("Time [s]") 67 axes.set_ylabel("Tangential force [N]") 68 time = simu.results.time 69 values = getattr(obj.results, "tangential_force") 70 axes.plot(time, values) 71 axes.axis([time[0], time[-1], 0., 1.1*max(values)]) 72 73 fig.tab_name = "Tangential force of '%s'" % obj.name
74
75 -def plot_normal_force(fig, obj, simu):
76 """Plot the normal force of an object C{obj}""" 77 axes = fig.add_subplot(111) 78 axes.set_xlabel("Time [s]") 79 axes.set_ylabel("Normal force [N]") 80 time = simu.results.time 81 values = getattr(obj.results, "normal_force") 82 axes.plot(time, values) 83 axes.axis([time[0], time[-1], 0., 1.1*max(values)]) 84 85 fig.tab_name = "Normal force of '%s'" % obj.name
86
87 -def plot_torque(fig, obj, simu):
88 """Plot the torque of the rotor""" 89 axes = fig.add_subplot(111) 90 axes.set_xlabel("Time [s]") 91 axes.set_ylabel("Torque [Nm]") 92 time = simu.results.time 93 values = getattr(obj.results, "torque") 94 axes.plot(time, values) 95 axes.axis([time[0], time[-1], 0., 1.1*max(values)]) 96 97 fig.tab_name = "Torque of '%s'" % obj.name
98
99 -def plot_electrical_torque(fig, obj, simu):
100 """Plot the electrical torque of the rotor""" 101 axes = fig.add_subplot(111) 102 axes.set_xlabel("Time [s]") 103 axes.set_ylabel("Electrical torque [Nm]") 104 time = simu.results.time 105 values = obj.results.electrical_torque 106 axes.plot(time, values) 107 axes.axis([time[0], time[-1], 0., 1.1*max(values)]) 108 109 fig.tab_name = "Elec. Torque of '%s'" % obj.name
110
111 -def plot_airfoil(fig, section, simu):
112 """Plot an airfoil""" 113 axes = fig.add_subplot(111) 114 curves = section.airfoil.curves 115 axes.set_xlabel("Angle [rad]") 116 axes.set_ylabel("Coefficient") 117 for key, curve in curves.items(): 118 axes.plot(curve.angles, curve.coeffs, ".-", label=key) 119 axes.legend() 120 121 fig.tab_name = "Airfoil '%s' of '%s'" % (section.airfoil.name, 122 section.name)
123
124 -def plot_blade_pressures(fig, blade, simu):
125 """Plot the pressures on the blade""" 126 axes = fig.add_subplot(111) 127 fid = simu.current_frame_id 128 129 lst = {"radius" : [], "tang" : [], "norm" : []} 130 axes.set_xlabel("Radial position [m]") 131 axes.set_ylabel("Section pressure [N/m]") 132 for section in blade.sections: 133 lst["radius"].append(section.radial_position) 134 lst["tang"].append(section.results.tangential_press[fid]) 135 lst["norm"].append(section.results.normal_press[fid]) 136 axes.plot(lst["radius"], lst["norm"], ".-", label="Normal") 137 axes.plot(lst["radius"], lst["tang"], ".-", label="Tangential") 138 axes.legend(loc=2) 139 140 fig.tab_name = "Pressures of '%s' at frame %i" % (blade.name, 141 fid)
142
143 -def plot_rotational_speed(fig, rotor, simu):
144 """Plot the rotor rotational speed""" 145 axes = fig.add_subplot(111) 146 147 axes.set_xlabel("Time [s]") 148 axes.set_ylabel("Rotational speed [rad/s]") 149 time = simu.res.time 150 rot_speed = rotor.results.rotational_speed_value 151 axes.plot(time, rot_speed) 152 axes.axis([time[0], time[-1], 0, 1.1 * max(rot_speed)]) 153 fig.tab_name = "Rotational speed of '%s'" % rotor.name
154
155 -def plot_coupling_torque(fig, obj, simu):
156 """Plot the aerodynamic torque produced by a blade""" 157 axes = fig.add_subplot(111) 158 159 axes.set_xlabel("Time [s]") 160 axes.set_ylabel("Coupling torque [Nm]") 161 time = simu.res.time 162 torque = obj.results.coupling_torque 163 axes.plot(time, torque) 164 axes.axis([time[0], time[-1], 0, 1.1 * max(torque)]) 165 166 fig.tab_name = "Done for the couling torque of %s" % obj.name
167 168 PLOT_TABLE = { 169 "power" : plot_power, 170 "tangential_force" : plot_tangential_force, 171 "normal_force" : plot_normal_force, 172 "torque" : plot_torque, 173 "airfoil" : plot_airfoil, 174 "plot_pressures" : plot_blade_pressures, 175 "rotational_speed_value" : plot_rotational_speed, 176 "coupling_torque" : plot_coupling_torque, 177 "electrical_power" : plot_electrical_power, 178 "electrical_torque" : plot_electrical_torque 179 } 180