h2lib-tests 13.2.801__py3-none-any.whl → 13.2.901__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- h2lib_tests/test_distributed_sections.py +260 -52
- h2lib_tests/test_topology_h2lib.py +75 -44
- {h2lib_tests-13.2.801.dist-info → h2lib_tests-13.2.901.dist-info}/METADATA +2 -2
- {h2lib_tests-13.2.801.dist-info → h2lib_tests-13.2.901.dist-info}/RECORD +6 -6
- {h2lib_tests-13.2.801.dist-info → h2lib_tests-13.2.901.dist-info}/WHEEL +0 -0
- {h2lib_tests-13.2.801.dist-info → h2lib_tests-13.2.901.dist-info}/top_level.txt +0 -0
@@ -1,12 +1,48 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
|
1
3
|
from h2lib_tests import tfp
|
4
|
+
from numpy import testing as npt
|
2
5
|
import pytest
|
6
|
+
from scipy.spatial.transform import Rotation as R
|
7
|
+
from wetb.hawc2.htc_file import HTCFile
|
8
|
+
from wetb.hawc2.st_file import StFile
|
3
9
|
|
4
|
-
from h2lib
|
5
|
-
from h2lib.distributed_sections import
|
6
|
-
|
7
|
-
from numpy import testing as npt
|
10
|
+
from h2lib import H2Lib
|
11
|
+
from h2lib.distributed_sections import LinkType
|
12
|
+
from h2lib_tests.dtu10mw import DTU10MWSimple
|
8
13
|
import matplotlib.pyplot as plt
|
9
|
-
|
14
|
+
import numpy as np
|
15
|
+
|
16
|
+
|
17
|
+
class Plot():
|
18
|
+
def __init__(self, h2, ds_lst, ax=None):
|
19
|
+
self.h2 = h2
|
20
|
+
self.ds_lst = ds_lst
|
21
|
+
self.ax = ax or plt.figure().add_subplot(projection='3d')
|
22
|
+
|
23
|
+
def __call__(self, label, coo_index=[], h2=None, ds_lst=None, mainbody_coo=0):
|
24
|
+
self.h2 = h2 or self.h2
|
25
|
+
self.ds_lst = ds_lst or self.ds_lst
|
26
|
+
for ds in self.ds_lst:
|
27
|
+
sec_pos, sec_tsg = self.h2.get_distributed_section_position_orientation(ds, mainbody_coo_nr=mainbody_coo)
|
28
|
+
x, y, z = sec_pos.T
|
29
|
+
self.ax.plot(y, x, z, label=f'{label}, {ds.name}')
|
30
|
+
|
31
|
+
for (x, y, z), tsg in zip(sec_pos[coo_index], sec_tsg[coo_index]):
|
32
|
+
for (ex, ey, ez), c in zip(tsg.T * 10, 'rgb'):
|
33
|
+
plt.plot([y, y + ey], [x, x + ex], [z, z + ez], c)
|
34
|
+
|
35
|
+
def show(self, show):
|
36
|
+
if show:
|
37
|
+
plt.axis('equal')
|
38
|
+
self.ax.set_zlim([10, -220])
|
39
|
+
plt.legend()
|
40
|
+
self.ax.set_xlabel('x')
|
41
|
+
self.ax.set_ylabel('y')
|
42
|
+
self.ax.set_zlabel('z')
|
43
|
+
plt.show()
|
44
|
+
else:
|
45
|
+
plt.close('all')
|
10
46
|
|
11
47
|
|
12
48
|
def test_distributed_sections():
|
@@ -15,22 +51,11 @@ def test_distributed_sections():
|
|
15
51
|
model_path = f"{tfp}DTU_10_MW/"
|
16
52
|
htc_path = f"{tfp}DTU_10_MW/htc/DTU_10MW_RWT.htc"
|
17
53
|
h2.init(htc_path=htc_path, model_path=model_path)
|
54
|
+
ds_lst = [h2.get_distributed_sections(LinkType.BLADE, link_id=i) for i in [1, 2, 3]]
|
55
|
+
plot = Plot(h2, ds_lst)
|
56
|
+
plot('', slice(None))
|
57
|
+
plot.show(0)
|
18
58
|
|
19
|
-
ax = plt.figure().add_subplot(projection='3d')
|
20
|
-
for i in [1, 2, 3]:
|
21
|
-
# ds = DistributedSections(name='', link_type=1, link_id=i, nsec=50)
|
22
|
-
ds = h2.get_distributed_sections(LinkType.BLADE, link_id=i)
|
23
|
-
|
24
|
-
sec_pos, sec_tsg = h2.get_distributed_section_position_orientation(ds, mainbody_coo_nr=0)
|
25
|
-
x, y, z = sec_pos.T
|
26
|
-
ax.plot(y, x, -z, label=ds.name)
|
27
|
-
for (x, y, z), tsg in zip(sec_pos, sec_tsg):
|
28
|
-
for (ex, ey, ez), c in zip(tsg.T * 10, 'rgb'):
|
29
|
-
plt.plot([y, y + ey], [x, x + ex], [-z, -z - ez], c)
|
30
|
-
plt.legend()
|
31
|
-
plt.axis('equal')
|
32
|
-
if 0:
|
33
|
-
plt.show()
|
34
59
|
ds = h2.get_distributed_sections(LinkType.BLADE, link_id=2)
|
35
60
|
sec_pos, sec_tsg = h2.get_distributed_section_position_orientation(ds, mainbody_coo_nr=0)
|
36
61
|
npt.assert_array_almost_equal(sec_pos[40], [70.58938502, -16.98280589, -77.95555399], 6)
|
@@ -46,21 +71,9 @@ def test_distributed_sections():
|
|
46
71
|
for mbdy_name in mbdy_name_lst}
|
47
72
|
h2.initialize_distributed_sections()
|
48
73
|
ds_dict['blade1_aero'] = h2.get_distributed_sections(LinkType.BLADE, 1)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
sec_pos, sec_tsg = h2.get_distributed_section_position_orientation(ds, mbdy_name_dict['hub2'])
|
53
|
-
x, y, z = sec_pos.T
|
54
|
-
ax.plot(y, x, -z, label=name)
|
55
|
-
for (x, y, z), tsg in zip(sec_pos, sec_tsg):
|
56
|
-
for (ex, ey, ez), c in zip(tsg.T * 10, 'rgb'):
|
57
|
-
|
58
|
-
plt.plot([y, y + ey], [x, x + ex], [-z, -z - ez], c)
|
59
|
-
|
60
|
-
plt.axis('equal')
|
61
|
-
if 0:
|
62
|
-
plt.show()
|
63
|
-
|
74
|
+
plot = Plot(h2, ds_dict.values())
|
75
|
+
plot('test', slice(None), mainbody_coo=mbdy_name_dict['hub2'])
|
76
|
+
plot.show(0)
|
64
77
|
# print(ds_lst[6].name, ds_lst[3].name)
|
65
78
|
# mb_pos, b1_mb_tbg, b1_sec_pos, sec_tsb = h2.get_distributed_section_position_orientation(ds_lst[6])
|
66
79
|
# hub_id = h2.get_mainbody_name_dict()['hub1']
|
@@ -92,16 +105,11 @@ def test_distributed_sections():
|
|
92
105
|
frc[:, 1] = 100000
|
93
106
|
h2.set_distributed_section_force_and_moment(ds_dict['tower'], sec_frc=frc, sec_mom=np.zeros((4, 3)))
|
94
107
|
|
108
|
+
plot = Plot(h2, ds_dict.values())
|
109
|
+
plot('t=0')
|
95
110
|
h2.run(2)
|
96
|
-
|
97
|
-
|
98
|
-
x, y, z = sec_pos.T
|
99
|
-
ax.plot(y, x, -z, '--', label=ds.name)
|
100
|
-
plt.legend()
|
101
|
-
plt.axis('scaled')
|
102
|
-
if 0:
|
103
|
-
plt.show()
|
104
|
-
plt.close('all')
|
111
|
+
plot('t=2')
|
112
|
+
plot.show(0)
|
105
113
|
np.set_printoptions(linewidth=200)
|
106
114
|
sec_pos, sec_tsb = h2.get_distributed_section_position_orientation(ds_dict['tower'])
|
107
115
|
# print(np.round(mb_pos + [mb_tbg@sp for sp in sec_pos], 1).tolist())
|
@@ -112,6 +120,61 @@ def test_distributed_sections():
|
|
112
120
|
[0.0, 3.5, -115.6]], 1)
|
113
121
|
|
114
122
|
|
123
|
+
def test_distributed_section_positions():
|
124
|
+
|
125
|
+
mp = Path(tfp) / 'DTU_10_MW/'
|
126
|
+
htc_path = mp / 'htc/DTU_10MW_RWT_only_tower.htc'
|
127
|
+
st = StFile(mp / 'data/DTU_10MW_RWT_Tower_st.dat')
|
128
|
+
st_new = st.main_data_sets[1][1].copy()
|
129
|
+
st_new[:, -2] = .4
|
130
|
+
st_new[:, -1] = .3
|
131
|
+
st.main_data_sets[1][1] = st_new
|
132
|
+
st.save(mp / 'data/DTU_10MW_RWT_Tower_st_tmp.dat')
|
133
|
+
htc = HTCFile(htc_path)
|
134
|
+
htc.new_htc_structure.main_body.timoschenko_input.filename = str(mp / 'data/DTU_10MW_RWT_Tower_st_tmp.dat')
|
135
|
+
htc.set_name('DTU_10MW_RWT_only_tower_tmp.htc')
|
136
|
+
htc.save()
|
137
|
+
|
138
|
+
with H2Lib() as h2:
|
139
|
+
h2.init(htc_path=htc.filename, model_path=htc.modelpath)
|
140
|
+
ds = h2.add_distributed_sections(mainbody_name='tower', section_relative_position=[0, .1, .5, 1])
|
141
|
+
h2.initialize_distributed_sections()
|
142
|
+
|
143
|
+
ax = plt.figure().add_subplot(projection='3d')
|
144
|
+
pos = h2.get_mainbody_nodes_state(1, 'pos')
|
145
|
+
npt.assert_array_equal(pos[:, :2].T, [[-0.4, -0.4, -0.4, -0.4, -0.4, -0.4, -0.4, -0.4, -0.4, -0.4, -0.4],
|
146
|
+
[0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3]])
|
147
|
+
ax.plot(*pos.T, '.-', label='initial nodes position')
|
148
|
+
|
149
|
+
sec_pos, sec_tsg = h2.get_distributed_section_position_orientation(ds)
|
150
|
+
npt.assert_array_almost_equal(sec_pos[:, :2], 0, 10)
|
151
|
+
ax.plot(*sec_pos.T, '.-', label='initial distributed sections, c2def')
|
152
|
+
|
153
|
+
st_new[:, -2] = 0.8
|
154
|
+
st_new[:, -1] = 0.9
|
155
|
+
|
156
|
+
h2.set_st(main_body_nr=1, st=st_new)
|
157
|
+
|
158
|
+
pos = h2.get_mainbody_nodes_state(1, 'pos')
|
159
|
+
npt.assert_array_equal(pos[:, :2].T, [[-0.8, -0.8, -0.8, -0.8, -0.8, -0.8, -0.8, -0.8, -0.8, -0.8, -0.8],
|
160
|
+
[0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9]])
|
161
|
+
ax.plot(*pos.T, '.-', label='exy=1, nodes position')
|
162
|
+
|
163
|
+
sec_pos, sec_tsg = h2.get_distributed_section_position_orientation(ds)
|
164
|
+
ax.plot(*sec_pos.T, '.-', label='exy=1 distributed sections, c2def')
|
165
|
+
|
166
|
+
plt.legend()
|
167
|
+
ax.set_xlabel('x')
|
168
|
+
ax.set_ylabel('y')
|
169
|
+
ax.set_zlabel('z')
|
170
|
+
ax.set_zlim([0, -120])
|
171
|
+
if 0:
|
172
|
+
plt.show()
|
173
|
+
plt.close('all')
|
174
|
+
|
175
|
+
npt.assert_array_equal(sec_pos[:, :2], 0, 10)
|
176
|
+
|
177
|
+
|
115
178
|
def test_distributed_sections_static_solver():
|
116
179
|
with H2Lib() as h2:
|
117
180
|
model_path = f"{tfp}DTU_10_MW/"
|
@@ -137,16 +200,17 @@ def test_distributed_sections_static_solver():
|
|
137
200
|
frc[:, 1] = 100000
|
138
201
|
h2.set_distributed_section_force_and_moment(ds, sec_frc=frc, sec_mom=frc * 0)
|
139
202
|
h2.solver_static_run(reset_structure=True)
|
140
|
-
draw('set frc + static solver', [0.0, 1.
|
203
|
+
draw('set frc + static solver', [0.0, 1.8293, -115.6123])
|
141
204
|
c2_def = np.concatenate([pos, pos[:, :1]], 1)
|
142
205
|
c2_def[:, 0] = np.r_[np.arange(0, 60, 10), np.arange(50, 0, -10)]
|
143
|
-
h2.
|
206
|
+
tower_id = h2.get_mainbody_name_dict()["tower"]
|
207
|
+
h2.set_c2_def(tower_id, c2_def)
|
144
208
|
draw('set_c2_def', [10.0, 0.1184, -115.6296])
|
145
209
|
h2.solver_static_run(reset_structure=True)
|
146
|
-
draw('static solver', [10.
|
210
|
+
draw('static solver', [10.2695, 2.8081, -115.5122])
|
147
211
|
h2.set_distributed_section_force_and_moment(ds, sec_frc=-frc, sec_mom=frc * 0)
|
148
212
|
h2.solver_static_run(reset_structure=True)
|
149
|
-
draw('set -frc + static solver', [10.
|
213
|
+
draw('set -frc + static solver', [10.2695, -2.8081, -115.5122])
|
150
214
|
if 0:
|
151
215
|
plt.legend()
|
152
216
|
plt.show()
|
@@ -160,9 +224,11 @@ def test_set_distributed_section_force_and_moment_coo():
|
|
160
224
|
htc = HTCFile(model_path + "htc/DTU_10MW_RWT_only_tower.htc")
|
161
225
|
htc.new_htc_structure.orientation.base.body_eulerang = 0, 0, 90
|
162
226
|
htc.save(model_path + "htc/DTU_10MW_RWT_only_tower_rot90.htc")
|
163
|
-
print(htc)
|
164
227
|
h2.init(htc_path=htc.filename, model_path=model_path)
|
165
228
|
ds = h2.add_distributed_sections(mainbody_name='tower', section_relative_position=[0, .5, 1])
|
229
|
+
with pytest.raises(AssertionError, match='Call initialize_distributed_sections before get_distributed_section_force_and_moment'):
|
230
|
+
h2.get_distributed_section_force_and_moment(ds)
|
231
|
+
|
166
232
|
h2.initialize_distributed_sections()
|
167
233
|
|
168
234
|
ax = plt.figure().add_subplot(projection='3d')
|
@@ -170,7 +236,7 @@ def test_set_distributed_section_force_and_moment_coo():
|
|
170
236
|
def draw(label, ref):
|
171
237
|
h2.solver_static_run()
|
172
238
|
pos = h2.get_mainbody_nodes_state(mainbody_nr=1, state='pos')
|
173
|
-
print(label, np.round(pos[-1], 4).tolist())
|
239
|
+
# print(label, np.round(pos[-1], 4).tolist())
|
174
240
|
ax.plot(*pos.T, marker='.', label=label)
|
175
241
|
npt.assert_array_almost_equal(pos[-1], ref, 4)
|
176
242
|
|
@@ -178,10 +244,10 @@ def test_set_distributed_section_force_and_moment_coo():
|
|
178
244
|
frc = np.zeros((3, 3))
|
179
245
|
frc[:, 1] = 2e6
|
180
246
|
h2.set_distributed_section_force_and_moment(ds, sec_frc=frc, sec_mom=frc * 0)
|
181
|
-
draw('frc_y_global', [
|
247
|
+
draw('frc_y_global', [0.0, 33.8576, -110.0939])
|
182
248
|
|
183
249
|
h2.set_distributed_section_force_and_moment(ds, sec_frc=frc, sec_mom=frc * 0, mainbody_coo_nr=1)
|
184
|
-
draw('frc_y_tower', [-
|
250
|
+
draw('frc_y_tower', [-33.8576, -0.0, -110.0939])
|
185
251
|
|
186
252
|
if 0:
|
187
253
|
ax.axis('equal')
|
@@ -195,3 +261,145 @@ def test_set_distributed_section_force_and_moment_coo():
|
|
195
261
|
plt.show()
|
196
262
|
else:
|
197
263
|
plt.close('all')
|
264
|
+
|
265
|
+
|
266
|
+
def test_set_frc_blade():
|
267
|
+
with H2Lib(suppress_output=0) as h2:
|
268
|
+
htc = DTU10MWSimple(rotor_speed=.6, pitch=0, nbodies=1)
|
269
|
+
htc.set_name('DTU_10MW_RWT_fixed_rotspeed')
|
270
|
+
htc.aero.aerocalc_method = 0
|
271
|
+
htc.save()
|
272
|
+
h2.init(htc_path=htc.filename, model_path=htc.modelpath)
|
273
|
+
|
274
|
+
ds_lst = [h2.get_distributed_sections(LinkType.BLADE, link_id=i) for i in [1, 2, 3]]
|
275
|
+
h2.solver_static_run()
|
276
|
+
plot = Plot(h2, ds_lst)
|
277
|
+
plot('initial', [-1])
|
278
|
+
ini_tip_pos = [h2.get_distributed_section_position_orientation(ds, mainbody_coo_nr=0)[0][-1] for ds in ds_lst]
|
279
|
+
ini_tip3_tsg = h2.get_distributed_section_position_orientation(ds_lst[2], mainbody_coo_nr=9)[1][-1]
|
280
|
+
zeros = np.zeros((50, 3))
|
281
|
+
h2.set_distributed_section_force_and_moment(ds=ds_lst[0], sec_frc=zeros + [10000, 0, 0], sec_mom=zeros)
|
282
|
+
h2.set_distributed_section_force_and_moment(ds=ds_lst[1], sec_frc=zeros + [0, 10000, 0], sec_mom=zeros)
|
283
|
+
h2.set_distributed_section_force_and_moment(ds=ds_lst[2], sec_frc=zeros, sec_mom=zeros + [0, 0, 100000])
|
284
|
+
h2.solver_static_run()
|
285
|
+
|
286
|
+
plot('deflected', [-1])
|
287
|
+
def_tip_pos = [h2.get_distributed_section_position_orientation(ds, mainbody_coo_nr=0)[0][-1] for ds in ds_lst]
|
288
|
+
def_tip3_tsg = h2.get_distributed_section_position_orientation(ds_lst[2], mainbody_coo_nr=9)[1][-1]
|
289
|
+
npt.assert_array_almost_equal(np.array(def_tip_pos) - ini_tip_pos,
|
290
|
+
[[7.545511, -0.270957, 0.189638], # mainly x
|
291
|
+
[0.942178, 11.676871, 2.980586], # mainly y
|
292
|
+
[0.596675, -6.677523, -2.850951]], # complex due to bend-twist coupling
|
293
|
+
6)
|
294
|
+
|
295
|
+
npt.assert_array_almost_equal(R.from_matrix(ini_tip3_tsg @ def_tip3_tsg).as_euler('xyz', 1),
|
296
|
+
[30.762956, 0.310381, 44.774262], 6) # rotation around z (but also x due to bend-twist coupling
|
297
|
+
plot.show(0)
|
298
|
+
|
299
|
+
|
300
|
+
@pytest.mark.parametrize('coo_nr', [-1, 0, 1])
|
301
|
+
def test_get_set_frc_blade(coo_nr):
|
302
|
+
'''
|
303
|
+
1 Run static solver with aerodynamic and extract position, frc and mom of distributed sections
|
304
|
+
2 New simulation, set frc and mom and run static solver without aerocalc
|
305
|
+
3 compare position of distributed sections
|
306
|
+
'''
|
307
|
+
with H2Lib(suppress_output=0) as h2:
|
308
|
+
htc = DTU10MWSimple(rotor_speed=.6, pitch=0, nbodies=1)
|
309
|
+
htc.set_name('DTU_10MW_RWT_fixed_rotspeed')
|
310
|
+
htc.simulation.convergence_limits.delete()
|
311
|
+
htc.wind.wsp = 10
|
312
|
+
htc.aero.tiploss_method = 0 # tiploss makes the static solver unstable
|
313
|
+
htc.save()
|
314
|
+
h2.init(htc_path=htc.filename, model_path=htc.modelpath)
|
315
|
+
|
316
|
+
aero_ds_lst = [h2.get_distributed_sections(LinkType.BLADE, link_id=i) for i in [1, 2, 3]]
|
317
|
+
|
318
|
+
mb_dict = h2.get_mainbody_name_dict()
|
319
|
+
p = h2.get_distributed_section_position_orientation(aero_ds_lst[0], mb_dict['blade1'])[0]
|
320
|
+
r = np.r_[0, np.cumsum(np.sqrt((np.diff(p, 1, 0)**2).sum(1)))] # curve-length radius
|
321
|
+
rR = r / r[-1]
|
322
|
+
for ds in aero_ds_lst:
|
323
|
+
h2.add_distributed_sections(ds.name, rR)
|
324
|
+
h2.initialize_distributed_sections()
|
325
|
+
|
326
|
+
body_ds_lst = [h2.get_distributed_sections(link_type=LinkType.BODY, link_id=i) for i in [1, 2, 3]]
|
327
|
+
|
328
|
+
plot = Plot(h2, aero_ds_lst)
|
329
|
+
h2.solver_static_run()
|
330
|
+
plot('aerosections after static solver')
|
331
|
+
# plot('bodysections after static solver', ds_lst=body_ds_lst)
|
332
|
+
pos_coo = np.maximum(coo_nr, 0)
|
333
|
+
ref_pos = [h2.get_distributed_section_position_orientation(ds, pos_coo)[0] for ds in aero_ds_lst]
|
334
|
+
aero2body = [np.array(h2.get_distributed_section_position_orientation(aero_ds, pos_coo)[0]) -
|
335
|
+
h2.get_distributed_section_position_orientation(body_ds, pos_coo)[0]
|
336
|
+
for aero_ds, body_ds in zip(aero_ds_lst, body_ds_lst)]
|
337
|
+
frc, mom = zip(*[h2.get_distributed_section_force_and_moment(ds, mainbody_coo_nr=coo_nr)
|
338
|
+
for ds in aero_ds_lst])
|
339
|
+
if coo_nr == 0:
|
340
|
+
aero_frc = h2.get_aerosections_forces()
|
341
|
+
aero_mom = h2.get_aerosections_moments()
|
342
|
+
aero_pos = h2.get_aerosections_position()
|
343
|
+
npt.assert_array_equal(aero_frc, frc)
|
344
|
+
npt.assert_array_almost_equal(aero_mom, mom)
|
345
|
+
|
346
|
+
npt.assert_array_equal(ref_pos, aero_pos)
|
347
|
+
|
348
|
+
with H2Lib(suppress_output=0) as h2:
|
349
|
+
htc = DTU10MWSimple(rotor_speed=.6, pitch=0, nbodies=1)
|
350
|
+
htc.simulation.convergence_limits.delete()
|
351
|
+
htc.set_name('DTU_10MW_RWT_fixed_rotspeed')
|
352
|
+
htc.aero.aerocalc_method = 0
|
353
|
+
htc.save()
|
354
|
+
h2.init(htc_path=htc.filename, model_path=htc.modelpath)
|
355
|
+
|
356
|
+
aero_ds_lst = [h2.get_distributed_sections(LinkType.BLADE, link_id=i) for i in [1, 2, 3]]
|
357
|
+
|
358
|
+
# set_distributed_section_force_and_moment maps the moment from section moments to moments around
|
359
|
+
# elastic axis. This mapping depends on the deflection, so we need to run a couple of times to
|
360
|
+
# get the right deflection and thereby the right mapping
|
361
|
+
for _ in range(5):
|
362
|
+
for sec_frc, sec_mom, ds in zip(frc, mom, aero_ds_lst):
|
363
|
+
h2.set_distributed_section_force_and_moment(ds, sec_frc, sec_mom, mainbody_coo_nr=coo_nr)
|
364
|
+
h2.solver_static_run()
|
365
|
+
|
366
|
+
pos = [h2.get_distributed_section_position_orientation(ds, np.maximum(coo_nr, 0))[0] for ds in aero_ds_lst]
|
367
|
+
plot = Plot(h2, aero_ds_lst, ax=plot.ax)
|
368
|
+
plot('set frc')
|
369
|
+
plot.show(0)
|
370
|
+
npt.assert_array_almost_equal(ref_pos, pos)
|
371
|
+
|
372
|
+
if coo_nr >= 0:
|
373
|
+
# for global and blade1 coordinates:
|
374
|
+
# apply forces and moments (mapped to c2df) to distributed sections (at c2def)
|
375
|
+
# and compare position of aerodynamic sections
|
376
|
+
with H2Lib(suppress_output=0) as h2:
|
377
|
+
htc = DTU10MWSimple(rotor_speed=.6, pitch=0, nbodies=1)
|
378
|
+
htc.simulation.convergence_limits.delete()
|
379
|
+
htc.set_name('DTU_10MW_RWT_fixed_rotspeed')
|
380
|
+
htc.aero.aerocalc_method = 0
|
381
|
+
htc.save()
|
382
|
+
h2.init(htc_path=htc.filename, model_path=htc.modelpath)
|
383
|
+
|
384
|
+
aero_ds_lst = [h2.get_distributed_sections(LinkType.BLADE, link_id=i) for i in [1, 2, 3]]
|
385
|
+
|
386
|
+
for ds in aero_ds_lst:
|
387
|
+
h2.add_distributed_sections(ds.name, rR)
|
388
|
+
h2.initialize_distributed_sections()
|
389
|
+
|
390
|
+
body_ds_lst = [h2.get_distributed_sections(link_type=LinkType.BODY, link_id=i) for i in [1, 2, 3]]
|
391
|
+
|
392
|
+
# set_distributed_section_force_and_moment maps the moment from section moments to moments around
|
393
|
+
# elastic axis. This mapping depends on the deflection, so we need to run a couple of times to
|
394
|
+
# get the right deflection and thereby the right mapping
|
395
|
+
for _ in range(5):
|
396
|
+
for sec_frc, sec_mom, ds, a2b in zip(frc, mom, body_ds_lst, aero2body):
|
397
|
+
body_mom = sec_mom + np.cross(sec_frc, -a2b)
|
398
|
+
h2.set_distributed_section_force_and_moment(ds, sec_frc, body_mom, mainbody_coo_nr=coo_nr)
|
399
|
+
h2.solver_static_run()
|
400
|
+
pos = [h2.get_distributed_section_position_orientation(ds, np.maximum(coo_nr, 0))[0] for ds in aero_ds_lst]
|
401
|
+
plot = Plot(h2, aero_ds_lst, ax=plot.ax)
|
402
|
+
plot('set frc')
|
403
|
+
plot.show(0)
|
404
|
+
# not sure why the accuracy is much worse. Maybe the distributed
|
405
|
+
npt.assert_array_almost_equal(ref_pos, pos, 2)
|
@@ -239,27 +239,35 @@ def test_set_orientation_base_speed(h2_dtu_10mw_only_blade):
|
|
239
239
|
|
240
240
|
|
241
241
|
def test_set_c2_def_too_few_sections(h2_dtu_10mw_only_blade):
|
242
|
+
blade_id = h2_dtu_10mw_only_blade.get_mainbody_name_dict()["blade1"]
|
242
243
|
with pytest.raises(ValueError, match="TOO_FEW_SECTIONS_IN_C2DEF"):
|
243
|
-
h2_dtu_10mw_only_blade.set_c2_def(
|
244
|
+
h2_dtu_10mw_only_blade.set_c2_def(blade_id, np.zeros((1, 4)))
|
244
245
|
|
245
246
|
|
246
247
|
def test_set_c2_def_wrong_number_of_columns(h2_dtu_10mw_only_blade):
|
248
|
+
blade_id = h2_dtu_10mw_only_blade.get_mainbody_name_dict()["blade1"]
|
247
249
|
with pytest.raises(ValueError, match="WRONG_NUMBER_OF_COLUMNS"):
|
248
|
-
h2_dtu_10mw_only_blade.set_c2_def(
|
250
|
+
h2_dtu_10mw_only_blade.set_c2_def(blade_id, np.zeros((2, 6)))
|
249
251
|
|
250
252
|
|
251
253
|
def test_set_c2_def_main_body_not_found(h2_dtu_10mw_only_blade):
|
252
254
|
with pytest.raises(ValueError, match="MAIN_BODY_NOT_FOUND"):
|
253
255
|
h2_dtu_10mw_only_blade.set_c2_def(
|
254
|
-
|
256
|
+
-10,
|
257
|
+
np.array([[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0]]),
|
258
|
+
)
|
259
|
+
with pytest.raises(ValueError, match="MAIN_BODY_NOT_FOUND"):
|
260
|
+
h2_dtu_10mw_only_blade.set_c2_def(
|
261
|
+
123,
|
255
262
|
np.array([[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0]]),
|
256
263
|
)
|
257
264
|
|
258
265
|
|
259
266
|
def test_set_c2_def_different_nsec(h2_dtu_10mw_only_blade):
|
267
|
+
blade_id = h2_dtu_10mw_only_blade.get_mainbody_name_dict()["blade1"]
|
260
268
|
with pytest.raises(ValueError, match="DIFFERENT_NSEC"):
|
261
269
|
h2_dtu_10mw_only_blade.set_c2_def(
|
262
|
-
|
270
|
+
blade_id,
|
263
271
|
np.array([[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0]]),
|
264
272
|
)
|
265
273
|
|
@@ -267,19 +275,21 @@ def test_set_c2_def_different_nsec(h2_dtu_10mw_only_blade):
|
|
267
275
|
def test_set_c2_def_uniform_node_distribution(
|
268
276
|
h2_dtu_10mw_only_blade_uniform_node_distribution,
|
269
277
|
):
|
278
|
+
blade_id = h2_dtu_10mw_only_blade_uniform_node_distribution.get_mainbody_name_dict()["blade1"]
|
270
279
|
with pytest.raises(
|
271
280
|
NotImplementedError,
|
272
281
|
):
|
273
282
|
h2_dtu_10mw_only_blade_uniform_node_distribution.set_c2_def(
|
274
|
-
|
283
|
+
blade_id, np.ones((27, 4), dtype=np.float64, order="F")
|
275
284
|
)
|
276
285
|
|
277
286
|
|
278
287
|
def test_set_c2_def_beam_too_short(h2_dtu_10mw_only_blade):
|
279
288
|
c2def = np.zeros((27, 4), dtype=np.float64, order="F")
|
280
289
|
c2def[:, 2] = np.linspace(0.0, 1e-9, c2def.shape[0])
|
290
|
+
blade_id = h2_dtu_10mw_only_blade.get_mainbody_name_dict()["blade1"]
|
281
291
|
with pytest.raises(ValueError, match="BEAM_TOO_SHORT"):
|
282
|
-
h2_dtu_10mw_only_blade.set_c2_def(
|
292
|
+
h2_dtu_10mw_only_blade.set_c2_def(blade_id, c2def)
|
283
293
|
|
284
294
|
|
285
295
|
def test_set_c2_def_blade_static_back_to_original(
|
@@ -295,6 +305,7 @@ def test_set_c2_def_blade_static_back_to_original(
|
|
295
305
|
# Get the clamped DTU 10 MW blade subjected to high gravity loading.
|
296
306
|
_, blade_c2def, _ = write_dtu10mw_only_blade_high_gravity
|
297
307
|
h2 = h2_dtu10mw_only_blade_high_gravity
|
308
|
+
blade_id = h2.get_mainbody_name_dict()["blade1"]
|
298
309
|
|
299
310
|
# Sensors 1 to 6 are the displacement and rotation of the blade tip.
|
300
311
|
# h2.get_sensor_info(1)
|
@@ -307,7 +318,7 @@ def test_set_c2_def_blade_static_back_to_original(
|
|
307
318
|
c2def_new = blade_c2def.copy()
|
308
319
|
for factor in (0.6, 0.7, 0.8, 0.9, 1.1, 1.2, 1.3, 1.4):
|
309
320
|
c2def_new[:, 2] = factor * blade_c2def[:, 2]
|
310
|
-
h2.set_c2_def(
|
321
|
+
h2.set_c2_def(blade_id, c2def_new)
|
311
322
|
# Since we are smoothly changing c2_def, it makes sense to start the static solver from the last converged solution.
|
312
323
|
h2.solver_static_run(reset_structure=False)
|
313
324
|
|
@@ -319,7 +330,7 @@ def test_set_c2_def_blade_static_back_to_original(
|
|
319
330
|
npt.assert_allclose(blade_tip_actual, blade_tip_desired)
|
320
331
|
|
321
332
|
# Restore blade c2_def.
|
322
|
-
h2.set_c2_def(
|
333
|
+
h2.set_c2_def(blade_id, blade_c2def)
|
323
334
|
h2.solver_static_run(reset_structure=True)
|
324
335
|
blade_tip_actual = h2.get_sensor_values((1, 2, 3, 4, 5, 6))
|
325
336
|
npt.assert_allclose(blade_tip_actual, blade_tip_desired)
|
@@ -338,7 +349,8 @@ def test_set_c2_def_blade_static_deformed(
|
|
338
349
|
# Set c2_def in the original blade, thus making it equivalent to the deformed one.
|
339
350
|
# Then, solve again the static problem.
|
340
351
|
_, c2def_deformed = write_dtu10mw_only_blade_high_gravity_deformed
|
341
|
-
h2_dtu10mw_only_blade_high_gravity.
|
352
|
+
blade_id = h2_dtu10mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
|
353
|
+
h2_dtu10mw_only_blade_high_gravity.set_c2_def(blade_id, c2def_deformed)
|
342
354
|
h2_dtu10mw_only_blade_high_gravity.solver_static_run(reset_structure=True)
|
343
355
|
blade_tip_actual = h2_dtu10mw_only_blade_high_gravity_deformed.get_sensor_values((1, 2, 3, 4, 5, 6))
|
344
356
|
|
@@ -346,7 +358,7 @@ def test_set_c2_def_blade_static_deformed(
|
|
346
358
|
|
347
359
|
# Restore c2_def.
|
348
360
|
_, c2def_original, _ = write_dtu10mw_only_blade_high_gravity
|
349
|
-
h2_dtu10mw_only_blade_high_gravity.set_c2_def(
|
361
|
+
h2_dtu10mw_only_blade_high_gravity.set_c2_def(blade_id, c2def_original)
|
350
362
|
|
351
363
|
|
352
364
|
@pytest.mark.skip(reason="The system eigenanalysis cannot be called more than once.")
|
@@ -358,6 +370,7 @@ def test_set_c2_def_blade_eig_back_to_original(
|
|
358
370
|
# We use the fixture with high gravity because it also returns c2_def.
|
359
371
|
_, blade_c2def, _ = write_dtu10mw_only_blade_high_gravity
|
360
372
|
h2 = h2_dtu10mw_only_blade_high_gravity
|
373
|
+
blade_id = h2.get_mainbody_name_dict()["blade1"]
|
361
374
|
|
362
375
|
# Solve the eigenvalue problem.
|
363
376
|
h2.structure_reset()
|
@@ -368,7 +381,7 @@ def test_set_c2_def_blade_eig_back_to_original(
|
|
368
381
|
c2def_new = blade_c2def.copy()
|
369
382
|
for factor in (0.6, 0.7, 0.8, 0.9, 1.1, 1.2, 1.3, 1.4):
|
370
383
|
c2def_new[:, 2] = factor * blade_c2def[:, 2]
|
371
|
-
h2.set_c2_def(
|
384
|
+
h2.set_c2_def(blade_id, c2def_new)
|
372
385
|
h2.structure_reset()
|
373
386
|
h2.linearize()
|
374
387
|
natural_frequencies_actual, damping_ratios_actual = h2.do_system_eigenanalysis(n_modes=6, include_damping=True)
|
@@ -380,7 +393,7 @@ def test_set_c2_def_blade_eig_back_to_original(
|
|
380
393
|
npt.assert_allclose(damping_ratios_actual, damping_ratios_desired)
|
381
394
|
|
382
395
|
# Restore blade c2_def.
|
383
|
-
h2.set_c2_def(
|
396
|
+
h2.set_c2_def(blade_id, blade_c2def)
|
384
397
|
h2.structure_reset()
|
385
398
|
h2.linearize()
|
386
399
|
natural_frequencies_actual, damping_ratios_actual = h2.do_system_eigenanalysis(n_modes=6, include_damping=True)
|
@@ -396,6 +409,7 @@ def test_set_c2_def_blade_inertia_back_to_original(
|
|
396
409
|
# We use the fixture with high gravity because it also returns c2_def.
|
397
410
|
_, blade_c2def, _ = write_dtu10mw_only_blade_high_gravity_1_body
|
398
411
|
h2 = h2_dtu10mw_only_blade_high_gravity_1_body
|
412
|
+
blade_id = h2.get_mainbody_name_dict()["blade1"]
|
399
413
|
|
400
414
|
# Get the inertia properties.
|
401
415
|
h2.structure_reset()
|
@@ -405,7 +419,7 @@ def test_set_c2_def_blade_inertia_back_to_original(
|
|
405
419
|
c2def_new = blade_c2def.copy()
|
406
420
|
for factor in (0.6, 0.7, 0.8, 0.9, 1.1, 1.2, 1.3, 1.4):
|
407
421
|
c2def_new[:, 2] = factor * blade_c2def[:, 2]
|
408
|
-
h2.set_c2_def(
|
422
|
+
h2.set_c2_def(blade_id, c2def_new)
|
409
423
|
inertia_actual = h2.body_output_mass(0)
|
410
424
|
|
411
425
|
# Must differ from the desired ones.
|
@@ -414,7 +428,7 @@ def test_set_c2_def_blade_inertia_back_to_original(
|
|
414
428
|
npt.assert_allclose(inertia_actual[i], inertia_desired[i])
|
415
429
|
|
416
430
|
# Restore blade c2_def.
|
417
|
-
h2.set_c2_def(
|
431
|
+
h2.set_c2_def(blade_id, blade_c2def)
|
418
432
|
inertia_actual = h2.body_output_mass(0)
|
419
433
|
for i in range(4): # Loop over tuple of arrays.
|
420
434
|
npt.assert_allclose(inertia_actual[i], inertia_desired[i])
|
@@ -432,7 +446,8 @@ def test_set_c2_def_blade_inertia_deformed(
|
|
432
446
|
|
433
447
|
# Set c2_def in the original blade, thus making it equivalent to the deformed one.
|
434
448
|
_, c2def_deformed = write_dtu10mw_only_blade_high_gravity_deformed
|
435
|
-
h2_dtu10mw_only_blade_high_gravity.
|
449
|
+
blade_id = h2_dtu10mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
|
450
|
+
h2_dtu10mw_only_blade_high_gravity.set_c2_def(blade_id, c2def_deformed)
|
436
451
|
|
437
452
|
# Compare inertia properties for all bodies.
|
438
453
|
nbdy, _ = h2_dtu10mw_only_blade_high_gravity_deformed.get_number_of_bodies_and_constraints()
|
@@ -445,7 +460,7 @@ def test_set_c2_def_blade_inertia_deformed(
|
|
445
460
|
|
446
461
|
# Restore c2_def.
|
447
462
|
_, c2def_original, _ = write_dtu10mw_only_blade_high_gravity
|
448
|
-
h2_dtu10mw_only_blade_high_gravity.set_c2_def(
|
463
|
+
h2_dtu10mw_only_blade_high_gravity.set_c2_def(blade_id, c2def_original)
|
449
464
|
|
450
465
|
|
451
466
|
def test_set_c2_def_blade_element_deformed(
|
@@ -460,7 +475,8 @@ def test_set_c2_def_blade_element_deformed(
|
|
460
475
|
|
461
476
|
# Set c2_def in the original blade, thus making it equivalent to the deformed one.
|
462
477
|
_, c2def_deformed = write_dtu10mw_only_blade_high_gravity_deformed
|
463
|
-
h2_dtu10mw_only_blade_high_gravity.
|
478
|
+
blade_id = h2_dtu10mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
|
479
|
+
h2_dtu10mw_only_blade_high_gravity.set_c2_def(blade_id, c2def_deformed)
|
464
480
|
|
465
481
|
# Compare element matrices for all bodies.
|
466
482
|
nelem = h2_dtu10mw_only_blade_high_gravity_deformed.get_number_of_elements()
|
@@ -475,31 +491,36 @@ def test_set_c2_def_blade_element_deformed(
|
|
475
491
|
|
476
492
|
# Restore c2_def.
|
477
493
|
_, c2def_original, _ = write_dtu10mw_only_blade_high_gravity
|
478
|
-
h2_dtu10mw_only_blade_high_gravity.set_c2_def(
|
494
|
+
h2_dtu10mw_only_blade_high_gravity.set_c2_def(blade_id, c2def_original)
|
479
495
|
|
480
496
|
|
481
497
|
def test_set_st_wrong_number_of_columns(h2_dtu_10mw_only_blade):
|
498
|
+
blade_id = h2_dtu_10mw_only_blade.get_mainbody_name_dict()["blade1"]
|
482
499
|
with pytest.raises(ValueError, match="WRONG_NUMBER_OF_COLUMNS"):
|
483
|
-
h2_dtu_10mw_only_blade.set_st(
|
500
|
+
h2_dtu_10mw_only_blade.set_st(blade_id, np.empty((2, 6)))
|
484
501
|
|
485
502
|
|
486
503
|
def test_set_st_main_body_not_found(h2_dtu_10mw_only_blade):
|
487
504
|
with pytest.raises(ValueError, match="MAIN_BODY_NOT_FOUND"):
|
488
|
-
h2_dtu_10mw_only_blade.set_st(
|
505
|
+
h2_dtu_10mw_only_blade.set_st(-3, np.empty((2, 19)))
|
506
|
+
with pytest.raises(ValueError, match="MAIN_BODY_NOT_FOUND"):
|
507
|
+
h2_dtu_10mw_only_blade.set_st(123, np.empty((2, 19)))
|
489
508
|
|
490
509
|
|
491
510
|
def test_set_st_z_not_continuously_increasing(h2_dtu_10mw_only_blade):
|
511
|
+
blade_id = h2_dtu_10mw_only_blade.get_mainbody_name_dict()["blade1"]
|
492
512
|
with pytest.raises(ValueError, match="ST_Z_NOT_CONTINUOUSLY_INCREASING"):
|
493
|
-
h2_dtu_10mw_only_blade.set_st(
|
513
|
+
h2_dtu_10mw_only_blade.set_st(blade_id, np.zeros((3, 19)))
|
494
514
|
|
495
515
|
|
496
516
|
def test_set_st_uniform_node_distribution(
|
497
517
|
h2_dtu_10mw_only_blade_uniform_node_distribution,
|
498
518
|
):
|
519
|
+
blade_id = h2_dtu_10mw_only_blade_uniform_node_distribution.get_mainbody_name_dict()["blade1"]
|
499
520
|
with pytest.raises(NotImplementedError):
|
500
521
|
st = np.zeros((2, 19))
|
501
522
|
st[1, 0] = 1.0
|
502
|
-
h2_dtu_10mw_only_blade_uniform_node_distribution.set_st(
|
523
|
+
h2_dtu_10mw_only_blade_uniform_node_distribution.set_st(blade_id, st)
|
503
524
|
|
504
525
|
|
505
526
|
def test_set_st_classic_timoshenko_blade_static_back_to_original(
|
@@ -515,6 +536,7 @@ def test_set_st_classic_timoshenko_blade_static_back_to_original(
|
|
515
536
|
# Get the clamped DTU 10 MW blade subjected to high gravity loading.
|
516
537
|
_, _, blade_st = write_dtu10mw_only_blade_high_gravity
|
517
538
|
h2 = h2_dtu10mw_only_blade_high_gravity
|
539
|
+
blade_id = h2.get_mainbody_name_dict()["blade1"]
|
518
540
|
|
519
541
|
# Sensors 1 to 6 are the displacement and rotation of the blade tip.
|
520
542
|
# h2.get_sensor_info(1)
|
@@ -530,7 +552,7 @@ def test_set_st_classic_timoshenko_blade_static_back_to_original(
|
|
530
552
|
st_new = factor * blade_st.main_data_sets[1][1]
|
531
553
|
# We do not change z, to prevent ST_Z_NOT_CONTINUOUSLY_INCREASING.
|
532
554
|
st_new[:, 0] = blade_st.main_data_sets[1][1][:, 0]
|
533
|
-
h2.set_st(
|
555
|
+
h2.set_st(blade_id, st_new)
|
534
556
|
h2.solver_static_run(reset_structure=True)
|
535
557
|
|
536
558
|
# Get new blade displacement.
|
@@ -541,7 +563,7 @@ def test_set_st_classic_timoshenko_blade_static_back_to_original(
|
|
541
563
|
npt.assert_allclose(blade_tip_actual, blade_tip_desired)
|
542
564
|
|
543
565
|
# Restore blade c2_def.
|
544
|
-
h2.set_st(
|
566
|
+
h2.set_st(blade_id, blade_st.main_data_sets[1][1])
|
545
567
|
h2.solver_static_run(reset_structure=True)
|
546
568
|
blade_tip_actual = h2.get_sensor_values((1, 2, 3, 4, 5, 6))
|
547
569
|
npt.assert_allclose(blade_tip_actual, blade_tip_desired)
|
@@ -553,6 +575,7 @@ def test_set_st_classic_timoshenko_blade_static_changed_st(
|
|
553
575
|
h2_dtu10mw_only_blade_high_gravity,
|
554
576
|
h2_dtu10mw_only_blade_high_gravity_changed_st,
|
555
577
|
):
|
578
|
+
blade_id = h2_dtu10mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
|
556
579
|
# Solve the static problem with the changed ST loaded directly by HAWC2.
|
557
580
|
h2_dtu10mw_only_blade_high_gravity_changed_st.solver_static_run(reset_structure=True)
|
558
581
|
blade_tip_desired = h2_dtu10mw_only_blade_high_gravity_changed_st.get_sensor_values((1, 2, 3, 4, 5, 6))
|
@@ -560,7 +583,7 @@ def test_set_st_classic_timoshenko_blade_static_changed_st(
|
|
560
583
|
# Set ST in the original blade, thus making it equivalent to the changed one.
|
561
584
|
# Then, solve again the static problem.
|
562
585
|
_, st_changed = write_dtu10mw_only_blade_high_gravity_changed_st
|
563
|
-
h2_dtu10mw_only_blade_high_gravity.set_st(
|
586
|
+
h2_dtu10mw_only_blade_high_gravity.set_st(blade_id, st_changed.main_data_sets[1][1])
|
564
587
|
h2_dtu10mw_only_blade_high_gravity.solver_static_run(reset_structure=True)
|
565
588
|
blade_tip_actual = h2_dtu10mw_only_blade_high_gravity_changed_st.get_sensor_values((1, 2, 3, 4, 5, 6))
|
566
589
|
|
@@ -568,7 +591,7 @@ def test_set_st_classic_timoshenko_blade_static_changed_st(
|
|
568
591
|
|
569
592
|
# Restore c2_def.
|
570
593
|
_, _, st_riginal = write_dtu10mw_only_blade_high_gravity
|
571
|
-
h2_dtu10mw_only_blade_high_gravity.set_st(
|
594
|
+
h2_dtu10mw_only_blade_high_gravity.set_st(blade_id, st_riginal.main_data_sets[1][1])
|
572
595
|
|
573
596
|
|
574
597
|
def test_set_st_classic_timoshenko_inertia_back_to_original(
|
@@ -579,6 +602,7 @@ def test_set_st_classic_timoshenko_inertia_back_to_original(
|
|
579
602
|
# We use the fixture with high gravity because it also returns st.
|
580
603
|
_, _, st = write_dtu10mw_only_blade_high_gravity_1_body
|
581
604
|
h2 = h2_dtu10mw_only_blade_high_gravity_1_body
|
605
|
+
blade_id = h2.get_mainbody_name_dict()["blade1"]
|
582
606
|
|
583
607
|
# Get the inertia properties.
|
584
608
|
h2.structure_reset()
|
@@ -593,7 +617,7 @@ def test_set_st_classic_timoshenko_inertia_back_to_original(
|
|
593
617
|
# Make the blade tip heavier to change center of gravity.
|
594
618
|
density_new *= np.linspace(0.8, 2.5, density_new.size)
|
595
619
|
st.set_value(mset=1, set=1, m=density_new)
|
596
|
-
h2.set_st(
|
620
|
+
h2.set_st(blade_id, st.main_data_sets[1][1])
|
597
621
|
inertia_actual = h2.body_output_mass(0)
|
598
622
|
|
599
623
|
# Must differ from the desired ones.
|
@@ -603,7 +627,7 @@ def test_set_st_classic_timoshenko_inertia_back_to_original(
|
|
603
627
|
|
604
628
|
# Restore ST.
|
605
629
|
st.set_value(mset=1, set=1, m=mass_original)
|
606
|
-
h2.set_st(
|
630
|
+
h2.set_st(blade_id, st.main_data_sets[1][1])
|
607
631
|
inertia_actual = h2.body_output_mass(0)
|
608
632
|
for i in range(4): # Loop over tuple of arrays.
|
609
633
|
npt.assert_allclose(inertia_actual[i], inertia_desired[i])
|
@@ -621,7 +645,8 @@ def test_set_st_classic_timoshenko_blade_inertia_changed_st(
|
|
621
645
|
|
622
646
|
# Set ST in the original blade, thus making it equivalent to the changed one.
|
623
647
|
_, st_changed = write_dtu10mw_only_blade_high_gravity_changed_st
|
624
|
-
h2_dtu10mw_only_blade_high_gravity.
|
648
|
+
blade_id = h2_dtu10mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
|
649
|
+
h2_dtu10mw_only_blade_high_gravity.set_st(blade_id, st_changed.main_data_sets[1][1])
|
625
650
|
|
626
651
|
# Compare inertia properties for all bodies.
|
627
652
|
nbdy, _ = h2_dtu10mw_only_blade_high_gravity_changed_st.get_number_of_bodies_and_constraints()
|
@@ -634,7 +659,7 @@ def test_set_st_classic_timoshenko_blade_inertia_changed_st(
|
|
634
659
|
|
635
660
|
# Restore ST.
|
636
661
|
_, _, st_original = write_dtu10mw_only_blade_high_gravity
|
637
|
-
h2_dtu10mw_only_blade_high_gravity.set_st(
|
662
|
+
h2_dtu10mw_only_blade_high_gravity.set_st(blade_id, st_original.main_data_sets[1][1])
|
638
663
|
|
639
664
|
|
640
665
|
def test_set_st_classic_timoshenko_blade_element_changed_st(
|
@@ -649,7 +674,8 @@ def test_set_st_classic_timoshenko_blade_element_changed_st(
|
|
649
674
|
|
650
675
|
# Set ST in the original blade, thus making it equivalent to the changed one.
|
651
676
|
_, st_changed = write_dtu10mw_only_blade_high_gravity_changed_st
|
652
|
-
h2_dtu10mw_only_blade_high_gravity.
|
677
|
+
blade_id = h2_dtu10mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
|
678
|
+
h2_dtu10mw_only_blade_high_gravity.set_st(blade_id, st_changed.main_data_sets[1][1])
|
653
679
|
|
654
680
|
# Compare element matrices for all bodies.
|
655
681
|
nelem = h2_dtu10mw_only_blade_high_gravity_changed_st.get_number_of_elements()
|
@@ -664,7 +690,7 @@ def test_set_st_classic_timoshenko_blade_element_changed_st(
|
|
664
690
|
|
665
691
|
# Restore ST.
|
666
692
|
_, _, st_original = write_dtu10mw_only_blade_high_gravity
|
667
|
-
h2_dtu10mw_only_blade_high_gravity.set_st(
|
693
|
+
h2_dtu10mw_only_blade_high_gravity.set_st(blade_id, st_original.main_data_sets[1][1])
|
668
694
|
|
669
695
|
|
670
696
|
def test_set_st_fpm_blade_static_back_to_original(
|
@@ -680,6 +706,7 @@ def test_set_st_fpm_blade_static_back_to_original(
|
|
680
706
|
# Get the clamped IEA 22 MW blade subjected to high gravity loading.
|
681
707
|
_, _, blade_st = write_iea22mw_only_blade_high_gravity
|
682
708
|
h2 = h2_iea22mw_only_blade_high_gravity
|
709
|
+
blade_id = h2.get_mainbody_name_dict()["blade1"]
|
683
710
|
|
684
711
|
# Sensors 1 to 6 are the displacement and rotation of the blade tip.
|
685
712
|
# h2.get_sensor_info(1)
|
@@ -695,7 +722,7 @@ def test_set_st_fpm_blade_static_back_to_original(
|
|
695
722
|
st_new = factor * blade_st.main_data_sets[1][1]
|
696
723
|
# We do not change z, to prevent ST_Z_NOT_CONTINUOUSLY_INCREASING.
|
697
724
|
st_new[:, 0] = blade_st.main_data_sets[1][1][:, 0]
|
698
|
-
h2.set_st(
|
725
|
+
h2.set_st(blade_id, st_new)
|
699
726
|
h2.solver_static_run(reset_structure=True)
|
700
727
|
|
701
728
|
# Get new blade displacement.
|
@@ -706,7 +733,7 @@ def test_set_st_fpm_blade_static_back_to_original(
|
|
706
733
|
npt.assert_allclose(blade_tip_actual, blade_tip_desired)
|
707
734
|
|
708
735
|
# Restore blade c2_def.
|
709
|
-
h2.set_st(
|
736
|
+
h2.set_st(blade_id, blade_st.main_data_sets[1][1])
|
710
737
|
h2.solver_static_run(reset_structure=True)
|
711
738
|
blade_tip_actual = h2.get_sensor_values((1, 2, 3, 4, 5, 6))
|
712
739
|
npt.assert_allclose(blade_tip_actual, blade_tip_desired)
|
@@ -725,7 +752,8 @@ def test_set_st_fpm_blade_static_changed_st(
|
|
725
752
|
# Set ST in the original blade, thus making it equivalent to the changed one.
|
726
753
|
# Then, solve again the static problem.
|
727
754
|
_, st_changed = write_iea22mw_only_blade_high_gravity_changed_st
|
728
|
-
h2_iea22mw_only_blade_high_gravity.
|
755
|
+
blade_id = h2_iea22mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
|
756
|
+
h2_iea22mw_only_blade_high_gravity.set_st(blade_id, st_changed.main_data_sets[1][1])
|
729
757
|
h2_iea22mw_only_blade_high_gravity.solver_static_run(reset_structure=True)
|
730
758
|
blade_tip_actual = h2_iea22mw_only_blade_high_gravity_changed_st.get_sensor_values((1, 2, 3, 4, 5, 6))
|
731
759
|
|
@@ -733,7 +761,7 @@ def test_set_st_fpm_blade_static_changed_st(
|
|
733
761
|
|
734
762
|
# Restore c2_def.
|
735
763
|
_, _, st_riginal = write_iea22mw_only_blade_high_gravity
|
736
|
-
h2_iea22mw_only_blade_high_gravity.set_st(
|
764
|
+
h2_iea22mw_only_blade_high_gravity.set_st(blade_id, st_riginal.main_data_sets[1][1])
|
737
765
|
|
738
766
|
|
739
767
|
def test_set_st_fpm_inertia_back_to_original(
|
@@ -744,6 +772,7 @@ def test_set_st_fpm_inertia_back_to_original(
|
|
744
772
|
# We use the fixture with high gravity because it also returns st.
|
745
773
|
_, _, st = write_iea22mw_only_blade_high_gravity_1_body
|
746
774
|
h2 = h2_iea22mw_only_blade_high_gravity_1_body
|
775
|
+
blade_id = h2.get_mainbody_name_dict()["blade1"]
|
747
776
|
|
748
777
|
# Get the inertia properties.
|
749
778
|
h2.structure_reset()
|
@@ -758,7 +787,7 @@ def test_set_st_fpm_inertia_back_to_original(
|
|
758
787
|
# Make the blade tip heavier to change center of gravity.
|
759
788
|
density_new *= np.linspace(0.8, 2.5, density_new.size)
|
760
789
|
st.set_value(mset=1, set=1, m=density_new)
|
761
|
-
h2.set_st(
|
790
|
+
h2.set_st(blade_id, st.main_data_sets[1][1])
|
762
791
|
inertia_actual = h2.body_output_mass(0)
|
763
792
|
|
764
793
|
# Must differ from the desired ones.
|
@@ -768,7 +797,7 @@ def test_set_st_fpm_inertia_back_to_original(
|
|
768
797
|
|
769
798
|
# Restore ST.
|
770
799
|
st.set_value(mset=1, set=1, m=mass_original)
|
771
|
-
h2.set_st(
|
800
|
+
h2.set_st(blade_id, st.main_data_sets[1][1])
|
772
801
|
inertia_actual = h2.body_output_mass(0)
|
773
802
|
for i in range(4): # Loop over tuple of arrays.
|
774
803
|
npt.assert_allclose(inertia_actual[i], inertia_desired[i])
|
@@ -786,7 +815,8 @@ def test_set_st_fpm_blade_inertia_changed_st(
|
|
786
815
|
|
787
816
|
# Set ST in the original blade, thus making it equivalent to the changed one.
|
788
817
|
_, st_changed = write_iea22mw_only_blade_high_gravity_changed_st
|
789
|
-
h2_iea22mw_only_blade_high_gravity.
|
818
|
+
blade_id = h2_iea22mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
|
819
|
+
h2_iea22mw_only_blade_high_gravity.set_st(blade_id, st_changed.main_data_sets[1][1])
|
790
820
|
|
791
821
|
# Compare inertia properties for all bodies.
|
792
822
|
nbdy, _ = h2_iea22mw_only_blade_high_gravity_changed_st.get_number_of_bodies_and_constraints()
|
@@ -799,7 +829,7 @@ def test_set_st_fpm_blade_inertia_changed_st(
|
|
799
829
|
|
800
830
|
# Restore ST.
|
801
831
|
_, _, st_original = write_iea22mw_only_blade_high_gravity
|
802
|
-
h2_iea22mw_only_blade_high_gravity.set_st(
|
832
|
+
h2_iea22mw_only_blade_high_gravity.set_st(blade_id, st_original.main_data_sets[1][1])
|
803
833
|
|
804
834
|
|
805
835
|
def test_set_st_fpm_blade_element_changed_st(
|
@@ -814,7 +844,8 @@ def test_set_st_fpm_blade_element_changed_st(
|
|
814
844
|
|
815
845
|
# Set ST in the original blade, thus making it equivalent to the changed one.
|
816
846
|
_, st_changed = write_iea22mw_only_blade_high_gravity_changed_st
|
817
|
-
h2_iea22mw_only_blade_high_gravity.
|
847
|
+
blade_id = h2_iea22mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
|
848
|
+
h2_iea22mw_only_blade_high_gravity.set_st(blade_id, st_changed.main_data_sets[1][1])
|
818
849
|
|
819
850
|
# Compare element matrices for all bodies.
|
820
851
|
nelem = h2_iea22mw_only_blade_high_gravity_changed_st.get_number_of_elements()
|
@@ -829,7 +860,7 @@ def test_set_st_fpm_blade_element_changed_st(
|
|
829
860
|
|
830
861
|
# Restore ST.
|
831
862
|
_, _, st_original = write_iea22mw_only_blade_high_gravity
|
832
|
-
h2_iea22mw_only_blade_high_gravity.set_st(
|
863
|
+
h2_iea22mw_only_blade_high_gravity.set_st(blade_id, st_original.main_data_sets[1][1])
|
833
864
|
|
834
865
|
|
835
866
|
def test_set_orientation_relative_main_body_not_found(
|
@@ -964,5 +995,5 @@ def test_set_orientation_relative_static(
|
|
964
995
|
# %% Main.
|
965
996
|
|
966
997
|
if __name__ == "__main__":
|
967
|
-
|
968
|
-
pytest.main([__file__, "-k test_set_st_fpm_blade_element_changed_st"])
|
998
|
+
pytest.main([__file__])
|
999
|
+
# pytest.main([__file__, "-k test_set_st_fpm_blade_element_changed_st"])
|
@@ -2,7 +2,7 @@ h2lib_tests/__init__.py,sha256=VjSqfGg8BzdmSjfSFhJh4hZbYZ_cME7xp9EWFKHQphA,61
|
|
2
2
|
h2lib_tests/conftest.py,sha256=r4p868zCfJ5MMd2hs6XvGaiqu3jYlSR5G0OKAk5WX7Y,29629
|
3
3
|
h2lib_tests/dtu10mw.py,sha256=a7SXfyDwDQPastYKb5CgghOQcYfgO1eTwGrd-H3Enok,4374
|
4
4
|
h2lib_tests/test_calc.py,sha256=VNLfr2J9R2Jy9xTbdZ9dfbQ4dCwr7H7nbZRI3yP69fQ,2152
|
5
|
-
h2lib_tests/test_distributed_sections.py,sha256
|
5
|
+
h2lib_tests/test_distributed_sections.py,sha256=xYcQwNGL3IQyVaguHGZrm0EZGYIMw4LRq9q5xwird1E,19413
|
6
6
|
h2lib_tests/test_ellipsys_couplings.py,sha256=mfSTk1IamaKETU6Be8p8W9vA-yostWJl17m5sFlEK3Q,3345
|
7
7
|
h2lib_tests/test_h2lib.py,sha256=t2jwmXzibej9DQoAkldwWX1MmEmpcV0kp2hLDRV5dbQ,13836
|
8
8
|
h2lib_tests/test_h2rotor.py,sha256=cF3KMdzTyGoZGyihhHCJqdH_n_t2vjS1BPHDaUCk9pU,13918
|
@@ -10,7 +10,7 @@ h2lib_tests/test_lin.py,sha256=yydbsMX44ym_MSqR1cbQkqil8qC4icSW_JccPSElGac,6292
|
|
10
10
|
h2lib_tests/test_mpi.py,sha256=CTT160yc6uZFRr_QNFWxyOwJ-y0qHiIp8jPYs1MQpyg,7111
|
11
11
|
h2lib_tests/test_multiprocessinterface.py,sha256=h2o4havtK6IuMXsplNjGUa3VxOnbpEYGxdrrAKQilj0,1470
|
12
12
|
h2lib_tests/test_static_solver.py,sha256=IuUkKrEoz_EKLCmGQ94CLFgjKPvO20iVx4773JTKO-8,6503
|
13
|
-
h2lib_tests/test_topology_h2lib.py,sha256=
|
13
|
+
h2lib_tests/test_topology_h2lib.py,sha256=8SCrrjd8VZh_1pX9KDm_b2aCCyCZ-YbjwRgBRCOKNwQ,42472
|
14
14
|
h2lib_tests/test_files/__init__.py,sha256=9e6ZUPb42e0wf2E1rutdcTM8hROcWFRVPXtZriU3ySw,50
|
15
15
|
h2lib_tests/test_files/my_test_cls.py,sha256=7ZDsFkxrLfOY6q00U5Y-daxfuhATK-K5H04RP-VmQdE,850
|
16
16
|
h2lib_tests/test_files/DTU_10_MW/control/dtu_we_controller.dll,sha256=C5T_CuAFtIuDgCXSYAoNu24yKPwj2nWOeORacJbLN9s,1134592
|
@@ -91,7 +91,7 @@ h2lib_tests/test_files/minimal/res/minimal_mann_turb.hdf5,sha256=Q3cs3bZyplZjBpo
|
|
91
91
|
h2lib_tests/test_files/minimal/turb/hawc2_mann_l33.6_ae0.1000_g3.9_h0_512xd32xd16_2.000x3.00x4.00_s0001_u,sha256=byiorJmXDL6uKFbyfXthHTjJdm6ELvLR2lS202KrhRI,1048576
|
92
92
|
h2lib_tests/test_files/minimal/turb/hawc2_mann_l33.6_ae0.1000_g3.9_h0_512xd32xd16_2.000x3.00x4.00_s0001_v,sha256=cxK5Rfgfm3gyJsEYi_KlmYY8DIIl_G0aizN2jt18Glc,1048576
|
93
93
|
h2lib_tests/test_files/minimal/turb/hawc2_mann_l33.6_ae0.1000_g3.9_h0_512xd32xd16_2.000x3.00x4.00_s0001_w,sha256=xs61jAwhP3fIR1P5Oa8ovEt2baLoF8uCNs6pKIT8L4o,1048576
|
94
|
-
h2lib_tests-13.2.
|
95
|
-
h2lib_tests-13.2.
|
96
|
-
h2lib_tests-13.2.
|
97
|
-
h2lib_tests-13.2.
|
94
|
+
h2lib_tests-13.2.901.dist-info/METADATA,sha256=tsWn93wEcdivKQ20oO9utThtj-uQRsQWDZmGR_khWj0,452
|
95
|
+
h2lib_tests-13.2.901.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
96
|
+
h2lib_tests-13.2.901.dist-info/top_level.txt,sha256=WufAL3LO35YJBhWg1AfgTjSld-6l_WuRkXAkNKczUrM,12
|
97
|
+
h2lib_tests-13.2.901.dist-info/RECORD,,
|
File without changes
|
File without changes
|