1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """The reference frames for the unsteady Blade Element Momentum (BEM)
23 calculations"""
24 import numpy as N
25 from windSimSuite.common import BasicObject
26
27
29 """The top class of every reference frame. Only one reference
30 frame instance will exist but its reference will be shared
31 for every wind turbine component. The references to reference frames
32 will be kept in the L{ReferenceFrames}
33 instance: a list of needed reference frames."""
34
36 BasicObject.__init__(self, name)
37 self.key = None
38 self.array = N.zeros((3, 3))
39 self.matrix = N.asmatrix(self.array)
40
42 """Will be defined in the derived classes"""
43 pass
44
46 """Calculate the reference frame"""
47 self.update_array()
48 self.matrix = N.asmatrix(self.array)
49
50
52 """The yaw reference frame
53 """
54
55 - def __init__(self, name="yaw reference frame"):
59
61 """The yaw angle, instance from the C{Angle}
62 class in the C{mbdyn} package"""
63 self.yaw = yaw
64
66 """Update the transformation array from the yaw angle value"""
67 self.array = N.array([
68 [N.cos(self.yaw["rad"]), N.sin(self.yaw["rad"]), 0.],
69 [-N.sin(self.yaw["rad"]), N.cos(self.yaw["rad"]), 0.],
70 [0., 0., 1.]
71 ])
72
73
75 """The tilt reference frame
76 """
77
78 - def __init__(self, name="tilt reference frame"):
82
84 """The tilt angle, instance from the C{Angle}
85 class in the C{mbdyn} package"""
86 self.tilt = tilt
87
89 """Update the transformation array from the tilt angle value"""
90 self.array = N.array([
91 [N.cos(self.tilt["rad"]), 0., -N.sin(self.tilt["rad"])],
92 [0., 1., 0.],
93 [N.sin(self.tilt["rad"]), 0., N.cos(self.tilt["rad"])]
94 ])
95
96
98 """The wing reference frame
99 """
100
101 - def __init__(self, name="wing reference frame"):
105
107 """The wing angle, instance from the C{Angle}
108 class in the C{mbdyn} package"""
109 self.wing = wing
110
112 """Update the transformation array from the wing angle value"""
113 self.array = N.array([
114 [1., 0., 0.],
115 [0., N.cos(self.wing["rad"]), N.sin(self.wing["rad"])],
116 [0., -N.sin(self.wing["rad"]), N.cos(self.wing["rad"])]
117 ])
118
119
121 """The cone reference frame
122 """
123
124 - def __init__(self, name="cone reference frame"):
128
130 """The cone angle, instance from the C{Angle}
131 class in the C{mbdyn} package"""
132 self.cone = cone
133
135 """Update the transformation array from the cone angle value"""
136 self.array = N.array([
137 [N.cos(self.cone["rad"]), 0., -N.sin(self.cone["rad"])],
138 [0., 1., 0.],
139 [N.sin(self.cone["rad"]), 0., N.cos(self.cone["rad"])]
140 ])
141
142
144 """The pitch reference frame
145 """
146
147 - def __init__(self, name="pitch reference frame"):
151
153 """The pitch angle, instance from the C{Angle}
154 class in the C{mbdyn} package"""
155 self.pitch = pitch
156
158 """Update the transformation array from the pitch angle value"""
159 self.array = N.array([
160 [N.cos(self.pitch["rad"]), -N.sin(self.pitch["rad"]), 0.],
161 [N.sin(self.pitch["rad"]), N.cos(self.pitch["rad"]), 0.],
162 [0., 0., 1.]
163 ])
164
165
167 """Manipulate L{ReferenceFrame} references in a list.
168 The first reference frame is supposed to represent
169 the first transformation from the absolute reference frame, and so
170 on until the final transformation for reaching the base of work.
171 This object is used by every wind turbine component, that according
172 to its placement keep a different list of L{ReferenceFrame} references.
173 """
174
176 BasicObject.__init__(self, name)
177 self.nb_references = 0
178 self.refs = []
179 self.reference_keys = []
180
181 - def add(self, reference_frame):
182 """Append a reference frame to the list"""
183 self.refs.append(reference_frame)
184 self.reference_keys.append(reference_frame.key)
185 self.nb_references += 1
186
188 """Prepend a list of reference frames to the list.
189
190 @type refs_list: a list
191 @param refs_list: a list made of reference frame"""
192 for idx, reference_frame in enumerate(refs_list):
193 self.refs.insert(idx, reference_frame)
194 self.reference_keys.insert(idx, reference_frame.key)
195 self.nb_references += 1
196
198 """Return the transform matrix from the given
199 reference frame key to the global reference frame.
200 """
201 given_refid = self.reference_keys.index(key)
202 matrix = self.refs[0].matrix.T.copy()
203 for refid in range(1, given_refid + 1):
204 matrix *= self.refs[refid].matrix.T
205 return matrix
206
208 """Return a reference frame from its key"""
209 return self.refs[self.reference_keys.index(key)]
210
211
212 REFERENCE_FRAME = {
213 "yaw" : YawReferenceFrame,
214 "tilt" : TiltReferenceFrame,
215 "wing" : WingReferenceFrame,
216 "cone" : ConeReferenceFrame,
217 "pitch" : PitchReferenceFrame
218 }
219