h2lib-tests 13.1.506__py3-none-any.whl → 13.1.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.
@@ -0,0 +1,365 @@
1
+ import pytest
2
+ import numpy as np
3
+ from wetb.hawc2.htc_file import HTCFile
4
+ from h2lib_tests.test_files import tfp
5
+ from h2lib._h2lib import H2Lib
6
+
7
+
8
+ @pytest.fixture(scope="session")
9
+ def write_dtu10mw_only_tower():
10
+ # Start from DTU_10MW_RWT and delete everything except the tower.
11
+ htc = HTCFile(tfp + "DTU_10_MW/htc/DTU_10MW_RWT.htc")
12
+ htc.set_name("DTU_10MW_RWT_only_tower")
13
+ for key1 in htc["new_htc_structure"].keys():
14
+ if key1.startswith("main_body"):
15
+ if "tower" not in htc["new_htc_structure"][key1]["name"].values:
16
+ htc["new_htc_structure"][key1].delete()
17
+ if key1 == "orientation":
18
+ for key2 in htc["new_htc_structure"]["orientation"].keys():
19
+ if key2.startswith("relative"):
20
+ htc["new_htc_structure"]["orientation"][key2].delete()
21
+ if key1 == "constraint":
22
+ for key2 in htc["new_htc_structure"]["constraint"].keys():
23
+ if key2 != "fix0":
24
+ htc["new_htc_structure"]["constraint"][key2].delete()
25
+ htc["wind"].delete()
26
+ htc["aerodrag"].delete()
27
+ htc["aero"].delete()
28
+ htc["dll"].delete()
29
+ htc["output"].delete()
30
+ # Reduce simulation time.
31
+ htc.simulation.time_stop = 10.0
32
+ # Change number of bodies in the tower.
33
+ htc.new_htc_structure.main_body.nbodies = 3
34
+ # Save the new file.
35
+ htc.save()
36
+ return htc
37
+
38
+
39
+ @pytest.fixture(scope="session")
40
+ def write_dtu10mw_only_tower_rotated(write_dtu10mw_only_tower):
41
+ # Start from the DTU_10MW_RWT_only_tower and rotate the tower.
42
+ htc = write_dtu10mw_only_tower.copy()
43
+ htc.set_name("DTU_10MW_RWT_only_tower_rotated")
44
+ alpha = 30.0
45
+ htc.new_htc_structure.orientation.base.body_eulerang = [
46
+ alpha,
47
+ 0.0,
48
+ 0.0,
49
+ ]
50
+ htc["wind"].delete()
51
+ htc["output"].delete()
52
+ htc.save()
53
+ return (htc, alpha)
54
+
55
+
56
+ @pytest.fixture(scope="session")
57
+ def write_dtu10mw_only_tower_encrypted(write_dtu10mw_only_tower):
58
+ # Start from the DTU_10MW_RWT_only_tower and then encrypt the tower.
59
+ htc = write_dtu10mw_only_tower.copy()
60
+ htc.set_name("DTU_10MW_RWT_only_tower_encrypted")
61
+ # Only the tower is left.
62
+ htc.new_htc_structure.main_body.timoschenko_input.filename = "./data/DTU_10MW_RWT_Tower_st.dat.v3.enc"
63
+ htc.save()
64
+
65
+
66
+ @pytest.fixture(scope="session")
67
+ def write_dtu10mw_only_blade():
68
+ # Start from DTU_10MW_RWT and delete everything except the blade.
69
+ htc = HTCFile(tfp + "DTU_10_MW/htc/DTU_10MW_RWT.htc")
70
+ htc.set_name("DTU_10MW_RWT_only_blade")
71
+ for key1 in htc["new_htc_structure"].keys():
72
+ if key1.startswith("main_body"):
73
+ if "blade1" not in htc["new_htc_structure"][key1]["name"].values:
74
+ htc["new_htc_structure"][key1].delete()
75
+ if key1 == "orientation":
76
+ htc["new_htc_structure"][key1].delete()
77
+ if key1 == "constraint":
78
+ htc["new_htc_structure"][key1].delete()
79
+ htc["wind"].delete()
80
+ htc["aerodrag"].delete()
81
+ htc["aero"].delete()
82
+ htc["dll"].delete()
83
+ htc["output"].delete()
84
+
85
+ # Set the blade horizontal, to maximize gravity loading.
86
+ htc.new_htc_structure.add_section("orientation")
87
+ htc.new_htc_structure.orientation.add_section("base")
88
+ htc.new_htc_structure.orientation.base.mbdy = "blade1"
89
+ htc.new_htc_structure.orientation.base.inipos = [0.0, 0.0, 0.0]
90
+ htc.new_htc_structure.orientation.base["mbdy_eulerang"] = [90.0, 0.0, 0.0]
91
+ htc.new_htc_structure.orientation.base.mbdy_eulerang.comments = "Blade span is horizontal."
92
+
93
+ # Clamp the blade.
94
+ htc.new_htc_structure.add_section("constraint")
95
+ htc.new_htc_structure.constraint.add_section("fix0")
96
+ htc.new_htc_structure.constraint.fix0.mbdy = "blade1"
97
+
98
+ # Set as many bodies as elements.
99
+ htc.new_htc_structure.main_body__7.nbodies = 26
100
+
101
+ htc.simulation.log_deltat.delete()
102
+
103
+ # Do not use static solver, since it will be done during the test.
104
+ htc.simulation.solvertype = 2
105
+ htc.simulation.solvertype.comments = ""
106
+ htc.simulation.initial_condition = 1
107
+
108
+ # No output, as we will use add_sensor().
109
+
110
+ # Save the new file.
111
+ htc.save()
112
+
113
+ return htc
114
+
115
+
116
+ @pytest.fixture(scope="session")
117
+ def write_dtu10mw_only_blade_low_max_iter(write_dtu10mw_only_blade):
118
+ # Start from the write_dtu10mw_only_blade and thenreduce the number of max iterations,
119
+ # so that the static solver will not have time to converge.
120
+ htc = write_dtu10mw_only_blade.copy()
121
+ htc.set_name("DTU_10MW_RWT_only_blade_low_max_iter")
122
+ htc.simulation.max_iterations = 1
123
+ htc.save()
124
+
125
+ return htc
126
+
127
+
128
+ @pytest.fixture(scope="session")
129
+ def write_dtu10mw_only_blade_rotate_base(write_dtu10mw_only_blade):
130
+ # Start from the write_dtu10mw_only_blade and then make it rotate by using the base command.
131
+ # HAWC2 will use the initial condition, but then the blade will not rotate because of the fix0 constraint.
132
+ # So, running the simulation will show a clamped blade that vibrates.
133
+ # Rotate at about 9.5 rpm.
134
+ htc = write_dtu10mw_only_blade.copy()
135
+ htc.set_name("DTU_10MW_RWT_only_blade_rotate_base")
136
+ speed = 1.0 # [rad/s]
137
+ htc.new_htc_structure.orientation.base["mbdy_ini_rotvec_d1"] = [0.0, 1.0, 0.0, speed]
138
+ htc.new_htc_structure.orientation.base.mbdy_ini_rotvec_d1.comments = f"= {speed * 30.0 / np.pi:.2f} rpm"
139
+ htc.new_htc_structure.main_body__7.gravity = 0.0
140
+ htc["wind"].delete()
141
+ htc["output"].delete()
142
+ htc.save()
143
+
144
+
145
+ @pytest.fixture(scope="session")
146
+ def write_dtu10mw_only_blade_rotate_relative():
147
+ # Start from DTU_10MW_RWT and delete everything except the blade and hub.
148
+ # The blade now rotates because of the relative rotation.
149
+ # Because of the fix1 constraint, the blade will not rotate after time 0.
150
+ htc = HTCFile(tfp + "DTU_10_MW/htc/DTU_10MW_RWT.htc")
151
+ htc.set_name("DTU_10MW_RWT_only_blade_rotate_relative")
152
+ for key1 in ("main_body", # tower
153
+ "main_body__2", # towertop
154
+ "main_body__3", # shaft
155
+ "main_body__5", # hub2
156
+ "main_body__6", # hub3
157
+ "main_body__8", # blade2
158
+ "main_body__9", # blade3
159
+ "orientation",
160
+ "constraint",
161
+ ):
162
+ htc["new_htc_structure"][key1].delete()
163
+ htc["wind"].delete()
164
+ htc["aerodrag"].delete()
165
+ htc["aero"].delete()
166
+ htc["dll"].delete()
167
+ htc["output"].delete()
168
+
169
+ # Set the hub as vertical.
170
+ htc.new_htc_structure.add_section("orientation")
171
+ htc.new_htc_structure.orientation.add_section("base")
172
+ htc.new_htc_structure.orientation.base.mbdy = "hub1"
173
+ htc.new_htc_structure.orientation.base.inipos = [0.0, 0.0, 0.0]
174
+ htc.new_htc_structure.orientation.base["mbdy_eulerang"] = [180.0, 0.0, 0.0]
175
+ htc.new_htc_structure.orientation.base.mbdy_eulerang.comments = "Hub axis is up."
176
+
177
+ # Set the blade horizontal.
178
+ htc.new_htc_structure.orientation.add_section("relative")
179
+ htc.new_htc_structure.orientation.relative.mbdy1 = "hub1 last"
180
+ htc.new_htc_structure.orientation.relative.mbdy2 = "blade1 1"
181
+ htc.new_htc_structure.orientation.relative["mbdy2_eulerang"] = [-90.0, 0.0, 0.0]
182
+ htc.new_htc_structure.orientation.relative.mbdy2_eulerang.comments = "Blade span is horizontal."
183
+ speed = 1.0 # [rad/s]
184
+ htc.new_htc_structure.orientation.relative["mbdy2_ini_rotvec_d1"] = [0.0, 1.0, 0.0, speed]
185
+ htc.new_htc_structure.orientation.relative.mbdy2_ini_rotvec_d1.comments = f"= {speed * 30.0 / np.pi:.2f} rpm"
186
+
187
+ # Disable gravity.
188
+ htc.new_htc_structure.main_body__7.gravity = 0.0
189
+ htc.new_htc_structure.main_body__4.gravity = 0.0
190
+
191
+ # Clamp the hub and blade.
192
+ htc.new_htc_structure.add_section("constraint")
193
+ htc.new_htc_structure.constraint.add_section("fix0")
194
+ htc.new_htc_structure.constraint.fix0.mbdy = "hub1"
195
+ htc.new_htc_structure.constraint.add_section("fix1")
196
+ htc.new_htc_structure.constraint.fix1.mbdy1 = "hub1 last"
197
+ htc.new_htc_structure.constraint.fix1.mbdy2 = "blade1 1"
198
+
199
+ # Set as many bodies as elements.
200
+ htc.new_htc_structure.main_body__7.nbodies = 26
201
+
202
+ htc.simulation.log_deltat.delete()
203
+
204
+ # Do not use static solver, since it will be done during the test.
205
+ htc.simulation.solvertype = 2
206
+ htc.simulation.solvertype.comments = ""
207
+ htc.simulation.initial_condition = 1
208
+
209
+ # Save the new file.
210
+ htc.save()
211
+
212
+ return htc
213
+
214
+
215
+ @pytest.fixture(scope="session")
216
+ def write_dtu10mw_only_blade_rotate_bearing3():
217
+ # Start from DTU_10MW_RWT and delete everything except the blade and hub.
218
+ # The blade now rotates because of the bearing3 between the blade and hub.
219
+ htc = HTCFile(tfp + "DTU_10_MW/htc/DTU_10MW_RWT.htc")
220
+ htc.set_name("DTU_10MW_RWT_only_blade_rotate_bearing3")
221
+ for key1 in ("main_body", # tower
222
+ "main_body__2", # towertop
223
+ "main_body__3", # shaft
224
+ "main_body__5", # hub2
225
+ "main_body__6", # hub3
226
+ "main_body__8", # blade2
227
+ "main_body__9", # blade3
228
+ "orientation",
229
+ "constraint",
230
+ ):
231
+ htc["new_htc_structure"][key1].delete()
232
+ htc["wind"].delete()
233
+ htc["aerodrag"].delete()
234
+ htc["aero"].delete()
235
+ htc["dll"].delete()
236
+ htc["output"].delete()
237
+
238
+ # Set the hub as vertical.
239
+ htc.new_htc_structure.add_section("orientation")
240
+ htc.new_htc_structure.orientation.add_section("base")
241
+ htc.new_htc_structure.orientation.base.mbdy = "hub1"
242
+ htc.new_htc_structure.orientation.base.inipos = [0.0, 0.0, 0.0]
243
+ htc.new_htc_structure.orientation.base["mbdy_eulerang"] = [180.0, 0.0, 0.0]
244
+ htc.new_htc_structure.orientation.base.mbdy_eulerang.comments = "Hub axis is up."
245
+
246
+ # Set the blade horizontal.
247
+ htc.new_htc_structure.orientation.add_section("relative")
248
+ htc.new_htc_structure.orientation.relative.mbdy1 = "hub1 last"
249
+ htc.new_htc_structure.orientation.relative.mbdy2 = "blade1 1"
250
+ htc.new_htc_structure.orientation.relative["mbdy2_eulerang"] = [-90.0, 0.0, 0.0]
251
+ htc.new_htc_structure.orientation.relative.mbdy2_eulerang.comments = "Blade span is horizontal."
252
+
253
+ # Disable gravity.
254
+ htc.new_htc_structure.main_body__7.gravity = 0.0
255
+ htc.new_htc_structure.main_body__4.gravity = 0.0
256
+
257
+ # Clamp the hub.
258
+ htc.new_htc_structure.add_section("constraint")
259
+ htc.new_htc_structure.constraint.add_section("fix0")
260
+ htc.new_htc_structure.constraint.fix0.mbdy = "hub1"
261
+
262
+ # Insert bearing3.
263
+ htc.new_htc_structure.constraint.add_section("bearing3")
264
+ htc.new_htc_structure.constraint.bearing3.name = "bearing"
265
+ htc.new_htc_structure.constraint.bearing3.mbdy1 = "hub1 last"
266
+ htc.new_htc_structure.constraint.bearing3.mbdy2 = "blade1 1"
267
+ htc.new_htc_structure.constraint.bearing3.bearing_vector = [1, 0.0, 0.0, 1.0]
268
+ speed = 1.0 # [rad/s]
269
+ htc.new_htc_structure.constraint.bearing3.omegas = speed
270
+ htc.new_htc_structure.constraint.bearing3.omegas.comments = f"= {speed * 30.0 / np.pi:.2f} rpm"
271
+
272
+ # Set as many bodies as elements.
273
+ htc.new_htc_structure.main_body__7.nbodies = 26
274
+
275
+ htc.simulation.log_deltat.delete()
276
+
277
+ # Do not use static solver, since it will be done during the test.
278
+ htc.simulation.solvertype = 2
279
+ htc.simulation.solvertype.comments = ""
280
+ htc.simulation.initial_condition = 1
281
+
282
+ # Save the new file.
283
+ htc.save()
284
+
285
+ return htc
286
+
287
+
288
+ @pytest.fixture(scope="session")
289
+ def h2_dtu_10mw_only_tower(write_dtu10mw_only_tower):
290
+ h2 = H2Lib(suppress_output=True)
291
+ model_path = f"{tfp}DTU_10_MW/"
292
+ htc_path = "htc/DTU_10MW_RWT_only_tower.htc"
293
+ h2.init(htc_path=htc_path, model_path=model_path)
294
+ yield h2
295
+ h2.close()
296
+
297
+
298
+ @pytest.fixture(scope="session")
299
+ def h2_dtu_10mw_only_tower_rotated(write_dtu10mw_only_tower_rotated):
300
+ h2 = H2Lib(suppress_output=True)
301
+ model_path = f"{tfp}DTU_10_MW/"
302
+ htc_path = "htc/DTU_10MW_RWT_only_tower_rotated.htc"
303
+ h2.init(htc_path=htc_path, model_path=model_path)
304
+ yield h2
305
+ h2.close()
306
+
307
+
308
+ @pytest.fixture(scope="session")
309
+ def h2_dtu_10mw_only_tower_encrypted(write_dtu10mw_only_tower_encrypted):
310
+ h2 = H2Lib(suppress_output=True)
311
+ model_path = f"{tfp}DTU_10_MW/"
312
+ htc_path = "htc/DTU_10MW_RWT_only_tower_encrypted.htc"
313
+ h2.init(htc_path=htc_path, model_path=model_path)
314
+ yield h2
315
+ h2.close()
316
+
317
+
318
+ @pytest.fixture(scope="session")
319
+ def h2_dtu_10mw_only_blade(write_dtu10mw_only_blade):
320
+ h2 = H2Lib(suppress_output=True)
321
+ model_path = f"{tfp}DTU_10_MW/"
322
+ htc_path = "htc/DTU_10MW_RWT_only_blade.htc"
323
+ h2.init(htc_path=htc_path, model_path=model_path)
324
+ yield h2
325
+ h2.close()
326
+
327
+
328
+ @pytest.fixture(scope="session")
329
+ def h2_dtu10mw_only_blade_low_max_iter(write_dtu10mw_only_blade_low_max_iter):
330
+ h2 = H2Lib(suppress_output=True)
331
+ model_path = f"{tfp}DTU_10_MW/"
332
+ htc_path = "htc/DTU_10MW_RWT_only_blade_low_max_iter.htc"
333
+ h2.init(htc_path=htc_path, model_path=model_path)
334
+ yield h2
335
+ h2.close()
336
+
337
+
338
+ @pytest.fixture(scope="session")
339
+ def h2_dtu_10mw_only_blade_rotate_base(write_dtu10mw_only_blade_rotate_base):
340
+ h2 = H2Lib(suppress_output=True)
341
+ model_path = f"{tfp}DTU_10_MW/"
342
+ htc_path = "htc/DTU_10MW_RWT_only_blade_rotate_base.htc"
343
+ h2.init(htc_path=htc_path, model_path=model_path)
344
+ yield h2
345
+ h2.close()
346
+
347
+
348
+ @pytest.fixture(scope="session")
349
+ def h2_dtu_10mw_only_blade_rotate_relative(write_dtu10mw_only_blade_rotate_relative):
350
+ h2 = H2Lib(suppress_output=True)
351
+ model_path = f"{tfp}DTU_10_MW/"
352
+ htc_path = "htc/DTU_10MW_RWT_only_blade_rotate_relative.htc"
353
+ h2.init(htc_path=htc_path, model_path=model_path)
354
+ yield h2
355
+ h2.close()
356
+
357
+
358
+ @pytest.fixture(scope="session")
359
+ def h2_dtu_10mw_only_blade_rotate_bearing3(write_dtu10mw_only_blade_rotate_bearing3):
360
+ h2 = H2Lib(suppress_output=True)
361
+ model_path = f"{tfp}DTU_10_MW/"
362
+ htc_path = "htc/DTU_10MW_RWT_only_blade_rotate_bearing3.htc"
363
+ h2.init(htc_path=htc_path, model_path=model_path)
364
+ yield h2
365
+ h2.close()
@@ -0,0 +1,191 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Test the system-eigenanalysis.
4
+
5
+ @author: ricriv
6
+ """
7
+
8
+ # Here we are relying on the default behavior of pytest, which is to execute
9
+ # the tests in the same order that they are specified.
10
+ # If one day this will not be the case anymore, we can enforce the order by
11
+ # using the solution proposed at: https://stackoverflow.com/a/77793427/3676517
12
+
13
+ import pytest
14
+
15
+ import numpy as np
16
+ from numpy import testing as npt
17
+
18
+ from h2lib._h2lib import H2Lib
19
+ from h2lib_tests.test_files import tfp
20
+
21
+
22
+ def test_system_not_linearized_1(h2_dtu_10mw_only_blade):
23
+ with pytest.raises(RuntimeError, match="SYSTEM_NOT_LINEARIZED"):
24
+ h2_dtu_10mw_only_blade.do_system_eigenanalysis(2)
25
+
26
+
27
+ def test_system_not_linearized_2(h2_dtu_10mw_only_blade):
28
+ with pytest.raises(RuntimeError, match="SYSTEM_NOT_LINEARIZED"):
29
+ h2_dtu_10mw_only_blade.get_system_eigenvalues_and_eigenvectors(2, 2)
30
+
31
+
32
+ def test_system_not_linearized_3(h2_dtu_10mw_only_blade):
33
+ with pytest.raises(RuntimeError, match="SYSTEM_NOT_LINEARIZED"):
34
+ h2_dtu_10mw_only_blade.get_system_matrices(312, 156)
35
+
36
+
37
+ def test_linearize(h2_dtu_10mw_only_blade):
38
+ n_tdofs, n_rdofs = h2_dtu_10mw_only_blade.linearize()
39
+ assert n_rdofs == 26 * 6 # = number of nodes * 6
40
+ assert n_tdofs == 26 * 6 * 2 # times 2 because of speed.
41
+
42
+
43
+ def test_too_many_modes(h2_dtu_10mw_only_blade):
44
+ with pytest.raises(ValueError, match="TOO_MANY_MODES_REQUESTED"):
45
+ h2_dtu_10mw_only_blade.do_system_eigenanalysis(n_modes=1000)
46
+
47
+
48
+ def test_sys_eig_not_done(h2_dtu_10mw_only_blade):
49
+ with pytest.raises(RuntimeError, match="SYSTEM_EIGENANALYSIS_NOT_DONE"):
50
+ h2_dtu_10mw_only_blade.get_system_eigenvalues_and_eigenvectors(2, 2)
51
+
52
+
53
+ def test_sys_eig_no_damping(h2_dtu_10mw_only_blade):
54
+ natural_frequencies = h2_dtu_10mw_only_blade.do_system_eigenanalysis(
55
+ n_modes=4, include_damping=False
56
+ )
57
+ # Test against: result at the time of writing.
58
+ npt.assert_allclose(
59
+ natural_frequencies,
60
+ np.array([0.610409, 0.930466, 1.739094, 2.761632]),
61
+ rtol=1e-6,
62
+ )
63
+
64
+
65
+ def test_sys_eig_no_damping_wrong_n_modes(h2_dtu_10mw_only_blade):
66
+ with pytest.raises(ValueError, match="TOO_MANY_MODES_REQUESTED"):
67
+ h2_dtu_10mw_only_blade.get_system_eigenvalues_and_eigenvectors(
68
+ 1000, 156
69
+ )
70
+
71
+
72
+ def test_sys_eig_no_damping_wrong_ny(h2_dtu_10mw_only_blade):
73
+ with pytest.raises(ValueError, match="WRONG_REDUCED_DOF"):
74
+ h2_dtu_10mw_only_blade.get_system_eigenvalues_and_eigenvectors(4, 2)
75
+
76
+
77
+ def test_sys_eig_no_damping_eigv(h2_dtu_10mw_only_blade):
78
+ n_modes = 4
79
+ n_rdofs = 156
80
+ eig_val, eig_vec = (
81
+ h2_dtu_10mw_only_blade.get_system_eigenvalues_and_eigenvectors(
82
+ n_modes, n_rdofs, include_damping=False
83
+ )
84
+ )
85
+ assert eig_val.size == n_modes
86
+ assert eig_vec.shape == (n_modes, n_rdofs)
87
+ assert eig_val.dtype == np.float64
88
+ assert eig_vec.dtype == np.float64
89
+ npt.assert_allclose(
90
+ eig_val,
91
+ np.array([3.83531, 5.846293, 10.927047, 17.351849]),
92
+ )
93
+
94
+
95
+ def test_sys_eig_with_damping(h2_dtu_10mw_only_blade):
96
+ freq, damp = h2_dtu_10mw_only_blade.do_system_eigenanalysis(
97
+ n_modes=4, include_damping=True
98
+ )
99
+ # Test against: result at the time of writing.
100
+ npt.assert_allclose(
101
+ freq, np.array([0.610409, 0.930468, 1.739098, 2.761702]), rtol=1e-6
102
+ )
103
+ npt.assert_allclose(
104
+ damp, np.array([0.004826, 0.004758, 0.013395, 0.014194]), atol=1e-6
105
+ )
106
+
107
+
108
+ def test_sys_eig_with_damping_eigv(h2_dtu_10mw_only_blade):
109
+ n_modes = 4
110
+ n_rdofs = 156
111
+ eig_val, eig_vec = (
112
+ h2_dtu_10mw_only_blade.get_system_eigenvalues_and_eigenvectors(
113
+ n_modes, n_rdofs, include_damping=True
114
+ )
115
+ )
116
+ assert eig_val.size == n_modes
117
+ assert eig_vec.shape == (n_modes, 2 * n_rdofs)
118
+ assert eig_val.dtype == np.complex128
119
+ assert eig_vec.dtype == np.complex128
120
+ npt.assert_allclose(
121
+ eig_val,
122
+ np.array(
123
+ [
124
+ -0.01851 - 3.835266j,
125
+ -0.027817 - 5.846237j,
126
+ -0.146367 - 10.926094j,
127
+ -0.246296 - 17.350536j,
128
+ ]
129
+ ),
130
+ atol=1e-6,
131
+ )
132
+
133
+
134
+ def test_get_system_matrices_wrong_nt(h2_dtu_10mw_only_blade):
135
+ with pytest.raises(ValueError, match="WRONG_TOTAL_DOF"):
136
+ h2_dtu_10mw_only_blade.get_system_matrices(300, 156)
137
+
138
+
139
+ def test_get_system_matrices_wrong_nr(h2_dtu_10mw_only_blade):
140
+ with pytest.raises(ValueError, match="WRONG_REDUCED_DOF"):
141
+ h2_dtu_10mw_only_blade.get_system_matrices(312, 150)
142
+
143
+
144
+ def test_get_system_matrices(h2_dtu_10mw_only_blade):
145
+ n_rdofs = 26 * 6
146
+ n_tdofs = 2 * n_rdofs
147
+ M, C, K, R = h2_dtu_10mw_only_blade.get_system_matrices(n_tdofs, n_rdofs)
148
+ assert M.shape == (n_rdofs, n_rdofs)
149
+ assert C.shape == (n_rdofs, n_rdofs)
150
+ assert K.shape == (n_rdofs, n_rdofs)
151
+ assert R.shape == (n_tdofs, n_rdofs)
152
+
153
+
154
+ def test_sys_eig_encrypted(h2_dtu_10mw_only_tower_encrypted):
155
+ n_tdofs, n_rdofs = h2_dtu_10mw_only_tower_encrypted.linearize()
156
+ n_modes = 4
157
+ freq, damp = h2_dtu_10mw_only_tower_encrypted.do_system_eigenanalysis(
158
+ n_modes=n_modes, include_damping=True
159
+ )
160
+ eig_val = h2_dtu_10mw_only_tower_encrypted.get_system_eigenvalues_and_eigenvectors(
161
+ n_modes=n_modes, n_rdofs=n_rdofs, include_damping=True
162
+ )
163
+ npt.assert_allclose(
164
+ freq,
165
+ np.array([0.770592, 0.770592, 3.449993, 3.449993]),
166
+ rtol=1e-6,
167
+ )
168
+
169
+ npt.assert_allclose(
170
+ damp,
171
+ np.array([0.010006, 0.010006, 0.044675, 0.044675]),
172
+ atol=1e-6,
173
+ )
174
+ npt.assert_allclose(
175
+ eig_val,
176
+ np.array(
177
+ [
178
+ -0.048444 - 4.84153j,
179
+ -0.048444 - 4.84153j,
180
+ -0.968409 - 21.6553j,
181
+ -0.968409 - 21.6553j,
182
+ ]
183
+ ),
184
+ atol=1e-6,
185
+ )
186
+
187
+
188
+ def test_test_get_system_matrices_encrypted(h2_dtu_10mw_only_tower_encrypted):
189
+ n_tdofs, n_rdofs = h2_dtu_10mw_only_tower_encrypted.linearize()
190
+ with pytest.raises(RuntimeError, match="STRUCTURE_IS_CONFIDENTIAL"):
191
+ h2_dtu_10mw_only_tower_encrypted.get_system_matrices(n_tdofs, n_rdofs)
@@ -18,31 +18,6 @@ from numpy import testing as npt
18
18
  from h2lib._h2lib import H2Lib
19
19
  from h2lib_tests.test_files import tfp
20
20
 
21
- from .test_write_htc import (
22
- write_dtu10mw_only_blade,
23
- write_dtu10mw_only_blade_low_max_iter,
24
- )
25
-
26
-
27
- @pytest.fixture(scope="module")
28
- def h2_dtu_10mw_only_blade(write_dtu10mw_only_blade):
29
- h2 = H2Lib(suppress_output=True)
30
- model_path = f"{tfp}DTU_10_MW/"
31
- htc_path = "htc/DTU_10MW_RWT_only_blade.htc"
32
- h2.init(htc_path=htc_path, model_path=model_path)
33
- yield h2
34
- h2.close()
35
-
36
-
37
- @pytest.fixture(scope="module")
38
- def h2_dtu10mw_only_blade_low_max_iter(write_dtu10mw_only_blade_low_max_iter):
39
- h2 = H2Lib(suppress_output=True)
40
- model_path = f"{tfp}DTU_10_MW/"
41
- htc_path = "htc/DTU_10MW_RWT_only_blade_low_max_iter.htc"
42
- h2.init(htc_path=htc_path, model_path=model_path)
43
- yield h2
44
- h2.close()
45
-
46
21
 
47
22
  def test_solver_static_update_no_init(h2_dtu_10mw_only_blade):
48
23
  with pytest.raises(RuntimeError, match="STATIC_SOLVER_NOT_INITIALIZED"):
@@ -77,7 +52,13 @@ def test_solver_static_delete(h2_dtu_10mw_only_blade):
77
52
  h2_dtu_10mw_only_blade.solver_static_delete()
78
53
 
79
54
 
80
- def test_static_solver_run(h2_dtu_10mw_only_blade):
55
+ def test_static_solver_run_fail(h2_dtu10mw_only_blade_low_max_iter):
56
+ with pytest.raises(RuntimeError, match="STATIC_SOLVER_DID_NOT_CONVERGE"):
57
+ h2_dtu10mw_only_blade_low_max_iter.solver_static_run()
58
+
59
+
60
+ def test_static_solver_run_1(h2_dtu_10mw_only_blade):
61
+ # Use gravity to deflect the clamped blade.
81
62
  # Add a sensor for the blade root moment, in this case only due to gravity.
82
63
  id = h2_dtu_10mw_only_blade.add_sensor("mbdy momentvec blade1 1 1 blade1")
83
64
 
@@ -93,6 +74,52 @@ def test_static_solver_run(h2_dtu_10mw_only_blade):
93
74
  )
94
75
 
95
76
 
96
- def test_static_solver_run_fail(h2_dtu10mw_only_blade_low_max_iter):
97
- with pytest.raises(RuntimeError, match="STATIC_SOLVER_DID_NOT_CONVERGE"):
98
- h2_dtu10mw_only_blade_low_max_iter.solver_static_run()
77
+ def test_static_solver_run_2(h2_dtu_10mw_only_blade_rotate_base):
78
+ # Apply centrifugal loading with the base command.
79
+ # Add a sensor for the blade root force, in this case only due to centrifugal force.
80
+ id = h2_dtu_10mw_only_blade_rotate_base.add_sensor("mbdy forcevec blade1 1 1 blade1")
81
+
82
+ # Run the static solver.
83
+ h2_dtu_10mw_only_blade_rotate_base.solver_static_run()
84
+
85
+ # Do 1 step to get the output.
86
+ h2_dtu_10mw_only_blade_rotate_base.step()
87
+ val = h2_dtu_10mw_only_blade_rotate_base.get_sensor_values(id)
88
+ # Test against: result at the time of writing.
89
+ npt.assert_allclose(
90
+ val, np.array([10879.129998, 383.43168, 989.68145])
91
+ )
92
+
93
+
94
+ def test_static_solver_run_3(h2_dtu_10mw_only_blade_rotate_relative):
95
+ # Apply centrifugal loading with the relative command.
96
+ # Add a sensor for the blade root force, in this case only due to centrifugal force.
97
+ id = h2_dtu_10mw_only_blade_rotate_relative.add_sensor("mbdy forcevec blade1 1 1 blade1")
98
+
99
+ # Run the static solver.
100
+ h2_dtu_10mw_only_blade_rotate_relative.solver_static_run()
101
+
102
+ # Do 1 step to get the output.
103
+ h2_dtu_10mw_only_blade_rotate_relative.step()
104
+ val = h2_dtu_10mw_only_blade_rotate_relative.get_sensor_values(id)
105
+ # Test against: result at the time of writing.
106
+ npt.assert_allclose(
107
+ val, np.array([10879.083576, 383.430039, 989.67935])
108
+ )
109
+
110
+
111
+ def test_static_solver_run_4(h2_dtu_10mw_only_blade_rotate_bearing3):
112
+ # Apply centrifugal loading with the bearing3 command.
113
+ # Add a sensor for the blade root moment, in this case only due to centrifugal force.
114
+ id = h2_dtu_10mw_only_blade_rotate_bearing3.add_sensor("mbdy momentvec blade1 1 1 blade1")
115
+
116
+ # Run the static solver.
117
+ h2_dtu_10mw_only_blade_rotate_bearing3.solver_static_run()
118
+
119
+ # Do 1 step to get the output.
120
+ h2_dtu_10mw_only_blade_rotate_bearing3.step()
121
+ val = h2_dtu_10mw_only_blade_rotate_bearing3.get_sensor_values(id)
122
+ # Test against: result at the time of writing.
123
+ npt.assert_allclose(
124
+ val, np.array([-3094.986918, 115414.095937, 325.296806])
125
+ )
@@ -4,41 +4,6 @@ from numpy import testing as npt
4
4
  from h2lib_tests.test_files import tfp
5
5
  import numpy as np
6
6
  import pytest
7
- from .test_write_htc import (
8
- write_dtu10mw_only_tower,
9
- write_dtu10mw_only_tower_rotated,
10
- write_dtu10mw_only_tower_encrypted
11
- )
12
-
13
-
14
- @pytest.fixture(scope="module")
15
- def h2_dtu_10mw_only_tower(write_dtu10mw_only_tower):
16
- h2 = H2Lib(suppress_output=True)
17
- model_path = f"{tfp}DTU_10_MW/"
18
- htc_path = "htc/DTU_10MW_RWT_only_tower.htc"
19
- h2.init(htc_path=htc_path, model_path=model_path)
20
- yield h2
21
- h2.close()
22
-
23
-
24
- @pytest.fixture(scope="module")
25
- def h2_dtu_10mw_only_tower_rotated(write_dtu10mw_only_tower_rotated):
26
- h2 = H2Lib(suppress_output=True)
27
- model_path = f"{tfp}DTU_10_MW/"
28
- htc_path = "htc/DTU_10MW_RWT_only_tower_rotated.htc"
29
- h2.init(htc_path=htc_path, model_path=model_path)
30
- yield h2
31
- h2.close()
32
-
33
-
34
- @pytest.fixture(scope="module")
35
- def h2_dtu_10mw_only_tower_encrypted(write_dtu10mw_only_tower_encrypted):
36
- h2 = H2Lib(suppress_output=True)
37
- model_path = f"{tfp}DTU_10_MW/"
38
- htc_path = "htc/DTU_10MW_RWT_only_tower_encrypted.htc"
39
- h2.init(htc_path=htc_path, model_path=model_path)
40
- yield h2
41
- h2.close()
42
7
 
43
8
 
44
9
  def test_number_of_bodies_and_constraints(
@@ -74,7 +39,9 @@ def test_get_timoshenko_location(
74
39
  h2_dtu_10mw_only_tower,
75
40
  ):
76
41
  # Test first element.
77
- l, r1, r12, tes = h2_dtu_10mw_only_tower.get_timoshenko_location(ibdy=0, ielem=0)
42
+ l, r1, r12, tes = h2_dtu_10mw_only_tower.get_timoshenko_location(
43
+ ibdy=0, ielem=0
44
+ )
78
45
  assert l - 11.5 < 1e-14
79
46
  npt.assert_array_equal(r1, np.array([0.0, 0.0, 0]))
80
47
  npt.assert_array_almost_equal_nulp(r12, np.array([0.0, 0.0, -11.5]))
@@ -84,10 +51,14 @@ def test_get_timoshenko_location(
84
51
  )
85
52
 
86
53
  # Test last element.
87
- l, r1, r12, tes = h2_dtu_10mw_only_tower.get_timoshenko_location(ibdy=2, ielem=3)
54
+ l, r1, r12, tes = h2_dtu_10mw_only_tower.get_timoshenko_location(
55
+ ibdy=2, ielem=3
56
+ )
88
57
  assert l - 12.13 < 1e-14
89
58
  npt.assert_array_almost_equal_nulp(r1, np.array([0.0, 0.0, -34.5]))
90
- npt.assert_array_almost_equal_nulp(r12, np.array([0.0, 0.0, -12.13]), nulp=3)
59
+ npt.assert_array_almost_equal_nulp(
60
+ r12, np.array([0.0, 0.0, -12.13]), nulp=3
61
+ )
91
62
  npt.assert_array_equal(
92
63
  tes,
93
64
  np.array([[-1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, -1.0]]),
@@ -112,7 +83,9 @@ def test_get_timoshenko_location_encrypted(
112
83
  h2_dtu_10mw_only_tower_encrypted,
113
84
  ):
114
85
  with pytest.raises(RuntimeError, match="STRUCTURE_IS_CONFIDENTIAL"):
115
- h2_dtu_10mw_only_tower_encrypted.get_timoshenko_location(ibdy=0, ielem=0)
86
+ h2_dtu_10mw_only_tower_encrypted.get_timoshenko_location(
87
+ ibdy=0, ielem=0
88
+ )
116
89
 
117
90
 
118
91
  def test_get_body_rotation_tensor_1(h2_dtu_10mw_only_tower):
@@ -141,3 +114,76 @@ def test_get_body_rotation_tensor_body_does_not_exist(h2_dtu_10mw_only_tower):
141
114
  def test_get_body_rotation_tensor_encrypted(h2_dtu_10mw_only_tower_encrypted):
142
115
  with pytest.raises(RuntimeError, match="STRUCTURE_IS_CONFIDENTIAL"):
143
116
  h2_dtu_10mw_only_tower_encrypted.get_body_rotation_tensor(ibdy=0)
117
+
118
+
119
+ def test_set_orientation_base_not_found(h2_dtu_10mw_only_tower):
120
+ with pytest.raises(ValueError, match="MAIN_BODY_NOT_FOUND"):
121
+ h2_dtu_10mw_only_tower.set_orientation_base(main_body_name="blade")
122
+
123
+
124
+ def test_set_orientation_base_1(
125
+ h2_dtu_10mw_only_tower, h2_dtu_10mw_only_tower_rotated
126
+ ):
127
+ # Start from h2_dtu_10mw_only_tower and rotate the base.
128
+ # See if it matches h2_dtu_10mw_only_tower_rotated.
129
+ h2_dtu_10mw_only_tower.set_orientation_base(
130
+ main_body_name="tower", mbdy_eulerang_table=np.array([30.0, 0.0, 0.0])
131
+ )
132
+ amat_desired = h2_dtu_10mw_only_tower_rotated.get_body_rotation_tensor(
133
+ ibdy=0
134
+ )
135
+ amat_actual = h2_dtu_10mw_only_tower.get_body_rotation_tensor(ibdy=0)
136
+ npt.assert_array_almost_equal_nulp(amat_actual, amat_desired)
137
+ # Reset orientation.
138
+ h2_dtu_10mw_only_tower.set_orientation_base(main_body_name="tower")
139
+
140
+
141
+ def test_set_orientation_base_with_reset_orientation(
142
+ h2_dtu_10mw_only_tower_rotated,
143
+ ):
144
+ h2_dtu_10mw_only_tower_rotated.set_orientation_base(
145
+ main_body_name="tower", reset_orientation=True
146
+ )
147
+ amat_actual = h2_dtu_10mw_only_tower_rotated.get_body_rotation_tensor(
148
+ ibdy=0
149
+ )
150
+ npt.assert_array_almost_equal_nulp(amat_actual, np.eye(3))
151
+ # Reset orientation.
152
+ h2_dtu_10mw_only_tower_rotated.set_orientation_base(
153
+ main_body_name="tower", mbdy_eulerang_table=np.array([30.0, 0.0, 0.0])
154
+ )
155
+
156
+
157
+ def test_set_orientation_base_without_reset_orientation(
158
+ h2_dtu_10mw_only_tower_rotated,
159
+ ):
160
+ h2_dtu_10mw_only_tower_rotated.set_orientation_base(
161
+ main_body_name="tower",
162
+ mbdy_eulerang_table=np.array([-30.0, 0.0, 0.0]),
163
+ reset_orientation=False,
164
+ )
165
+ amat_actual = h2_dtu_10mw_only_tower_rotated.get_body_rotation_tensor(
166
+ ibdy=0
167
+ )
168
+ npt.assert_array_almost_equal_nulp(amat_actual, np.eye(3))
169
+ # Reset orientation.
170
+ h2_dtu_10mw_only_tower_rotated.set_orientation_base(
171
+ main_body_name="tower", mbdy_eulerang_table=np.array([30.0, 0.0, 0.0])
172
+ )
173
+
174
+
175
+ def test_set_orientation_base_speed(
176
+ h2_dtu_10mw_only_blade
177
+ ):
178
+ # Set speed.
179
+ h2_dtu_10mw_only_blade.set_orientation_base(
180
+ main_body_name="blade1",
181
+ reset_orientation=False,
182
+ mbdy_ini_rotvec_d1=np.array([0.0, 1.0, 0.0, 1.0]),
183
+ )
184
+ # TODO: check against h2_dtu_10mw_only_blade_rotate_base.
185
+ # Reset speed.
186
+ h2_dtu_10mw_only_blade.set_orientation_base(
187
+ main_body_name="blade1",
188
+ reset_orientation=False,
189
+ )
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: h2lib-tests
3
- Version: 13.1.506
4
- Summary: Tests and test_files for test h2lib (13.1.8)
3
+ Version: 13.1.901
4
+ Summary: Tests and test_files for test h2lib (13.1.9+5-g2026dd7)
5
5
  Download-URL:
6
6
  Author: Mads M Pedersen
7
7
  Author-email:
@@ -1,14 +1,15 @@
1
1
  h2lib_tests/__init__.py,sha256=VjSqfGg8BzdmSjfSFhJh4hZbYZ_cME7xp9EWFKHQphA,61
2
+ h2lib_tests/conftest.py,sha256=bKGq79oRIYFbGGCEUjNHxrTYJlitHws-IwK0KZ5bm2c,14326
2
3
  h2lib_tests/dtu10mw.py,sha256=a7SXfyDwDQPastYKb5CgghOQcYfgO1eTwGrd-H3Enok,4374
3
4
  h2lib_tests/test_calc.py,sha256=VNLfr2J9R2Jy9xTbdZ9dfbQ4dCwr7H7nbZRI3yP69fQ,2152
4
5
  h2lib_tests/test_ellipsys_couplings.py,sha256=69I_2h_PMfuIUgxnlLp_6bkS5IEpWMWnnPV1sRrWEp0,2399
5
6
  h2lib_tests/test_h2lib.py,sha256=ZKp8pfQQpCUQ7IBXypTmvewbJwTQowSiCEt6t4R9TgY,13384
6
7
  h2lib_tests/test_h2rotor.py,sha256=kaE9AFDYSPaMFSgBAbeegd7-l6Z_4_BsQaWie0k32q4,6210
8
+ h2lib_tests/test_lin.py,sha256=FxuDvPuu1MjWE4B7dIWC3qR-9NtjqodGPO1aurUDBwY,6362
7
9
  h2lib_tests/test_mpi.py,sha256=emBgXRAvvFFOsVrAziiQCUZvEF9HS5Wc-x4KqqltQP0,6835
8
10
  h2lib_tests/test_multiprocessinterface.py,sha256=h2o4havtK6IuMXsplNjGUa3VxOnbpEYGxdrrAKQilj0,1470
9
- h2lib_tests/test_static_solver.py,sha256=Ik_CgGiFVibEPq0dGzSfSYH3gv_dTm-qcz6JKmJiH_A,3228
10
- h2lib_tests/test_topology_h2lib.py,sha256=cClNtAIc1wR_gZa7eDO4ZySvhScqCEIHVMKZEhk29QE,4980
11
- h2lib_tests/test_write_htc.py,sha256=3KMHffkR8A6C1RXODxq_O522fEBfJwp3YpjDmUmiNjU,4774
11
+ h2lib_tests/test_static_solver.py,sha256=OiabTF7IwIskkvBslp32c5o4v53YHQNTTV3vOU5vVb8,4679
12
+ h2lib_tests/test_topology_h2lib.py,sha256=OJj61anq0xT0X-LDoGTYk0E0kkB-MbkxafQWg31Oiys,6527
12
13
  h2lib_tests/test_files/__init__.py,sha256=9e6ZUPb42e0wf2E1rutdcTM8hROcWFRVPXtZriU3ySw,50
13
14
  h2lib_tests/test_files/my_test_cls.py,sha256=7ZDsFkxrLfOY6q00U5Y-daxfuhATK-K5H04RP-VmQdE,850
14
15
  h2lib_tests/test_files/DTU_10_MW/control/dtu_we_controller.dll,sha256=C5T_CuAFtIuDgCXSYAoNu24yKPwj2nWOeORacJbLN9s,1134592
@@ -87,7 +88,7 @@ h2lib_tests/test_files/minimal/res/minimal_mann_turb.hdf5,sha256=Q3cs3bZyplZjBpo
87
88
  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
88
89
  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
89
90
  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
90
- h2lib_tests-13.1.506.dist-info/METADATA,sha256=wvzBrJm0RO6QivFp3_Hx4Pol3PqGCk_9WyxwgOtyuao,349
91
- h2lib_tests-13.1.506.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
92
- h2lib_tests-13.1.506.dist-info/top_level.txt,sha256=WufAL3LO35YJBhWg1AfgTjSld-6l_WuRkXAkNKczUrM,12
93
- h2lib_tests-13.1.506.dist-info/RECORD,,
91
+ h2lib_tests-13.1.901.dist-info/METADATA,sha256=TUVzzgIneiYy2rlkF4hIDhuRxNBj9oBgdh25r7GvLLA,360
92
+ h2lib_tests-13.1.901.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
93
+ h2lib_tests-13.1.901.dist-info/top_level.txt,sha256=WufAL3LO35YJBhWg1AfgTjSld-6l_WuRkXAkNKczUrM,12
94
+ h2lib_tests-13.1.901.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: setuptools (75.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,126 +0,0 @@
1
- import pytest
2
- from wetb.hawc2.htc_file import HTCFile
3
- from h2lib_tests.test_files import tfp
4
-
5
-
6
- @pytest.fixture(scope="module")
7
- def write_dtu10mw_only_tower():
8
- # Start from DTU_10MW_RWT and delete everything except the tower.
9
- htc = HTCFile(tfp + "DTU_10_MW/htc/DTU_10MW_RWT.htc")
10
- htc.set_name("DTU_10MW_RWT_only_tower")
11
- for key1 in htc["new_htc_structure"].keys():
12
- if key1.startswith("main_body"):
13
- if "tower" not in htc["new_htc_structure"][key1]["name"].values:
14
- htc["new_htc_structure"][key1].delete()
15
- if key1 == "orientation":
16
- for key2 in htc["new_htc_structure"]["orientation"].keys():
17
- if key2.startswith("relative"):
18
- htc["new_htc_structure"]["orientation"][key2].delete()
19
- if key1 == "constraint":
20
- for key2 in htc["new_htc_structure"]["constraint"].keys():
21
- if key2 != "fix0":
22
- htc["new_htc_structure"]["constraint"][key2].delete()
23
- htc["wind"].delete()
24
- htc["aerodrag"].delete()
25
- htc["aero"].delete()
26
- htc["dll"].delete()
27
- htc["output"].delete()
28
- # Reduce simulation time.
29
- htc.simulation.time_stop = 10.0
30
- # Change number of bodies in the tower.
31
- htc.new_htc_structure.main_body.nbodies = 3
32
- # Save the new file.
33
- htc.save()
34
- return htc
35
-
36
-
37
- @pytest.fixture(scope="module")
38
- def write_dtu10mw_only_tower_rotated(write_dtu10mw_only_tower):
39
- # Start from the DTU_10MW_RWT_only_tower and rotate the tower.
40
- htc = write_dtu10mw_only_tower.copy()
41
- htc.set_name("DTU_10MW_RWT_only_tower_rotated")
42
- alpha = 30.0
43
- htc.new_htc_structure.orientation.base.body_eulerang = [
44
- alpha,
45
- 0.0,
46
- 0.0,
47
- ]
48
- htc.save()
49
- return (htc, alpha)
50
-
51
-
52
- @pytest.fixture(scope="module")
53
- def write_dtu10mw_only_tower_encrypted(write_dtu10mw_only_tower):
54
- # Start from the DTU_10MW_RWT_only_tower and then encrypt the tower.
55
- htc = write_dtu10mw_only_tower.copy()
56
- htc.set_name("DTU_10MW_RWT_only_tower_encrypted")
57
- # Only the tower is left.
58
- htc.new_htc_structure.main_body.timoschenko_input.filename = "./data/DTU_10MW_RWT_Tower_st.dat.v3.enc"
59
- htc.save()
60
-
61
-
62
- @pytest.fixture(scope="module")
63
- def write_dtu10mw_only_blade():
64
- # Start from DTU_10MW_RWT and delete everything except the blade.
65
- htc = HTCFile(tfp + "DTU_10_MW/htc/DTU_10MW_RWT.htc")
66
- htc.set_name("DTU_10MW_RWT_only_blade")
67
- for key1 in htc["new_htc_structure"].keys():
68
- if key1.startswith("main_body"):
69
- if "blade1" not in htc["new_htc_structure"][key1]["name"].values:
70
- htc["new_htc_structure"][key1].delete()
71
- if key1 == "orientation":
72
- htc["new_htc_structure"][key1].delete()
73
- if key1 == "constraint":
74
- htc["new_htc_structure"][key1].delete()
75
- htc["wind"].delete()
76
- htc["aerodrag"].delete()
77
- htc["aero"].delete()
78
- htc["dll"].delete()
79
- htc["output"].delete()
80
-
81
- # Set the blade horizontal, to maximize gravity loading.
82
- htc.new_htc_structure.add_section("orientation")
83
- htc.new_htc_structure.orientation.add_section("base")
84
- htc.new_htc_structure.orientation.base.mbdy = "blade1"
85
- htc.new_htc_structure.orientation.base.inipos = [0.0, 0.0, 0.0]
86
- htc.new_htc_structure.orientation.base["mbdy_eulerang"] = [90.0, 0.0, 0.0]
87
- htc.new_htc_structure.orientation.base.mbdy_eulerang.comments = "Blade span is horizontal."
88
-
89
- # Clamp the blade.
90
- htc.new_htc_structure.add_section("constraint")
91
- htc.new_htc_structure.constraint.add_section("fix0")
92
- htc.new_htc_structure.constraint.fix0.mbdy = "blade1"
93
-
94
- # Set as many bodies as elements.
95
- htc.new_htc_structure.main_body__7.nbodies = 26
96
-
97
- # Reduce simulation time to 1 time step.
98
- htc.simulation.time_stop = 0.01
99
- htc.simulation.log_deltat.delete()
100
-
101
- # Do not use static solver, since it will be done during the test.
102
- htc.simulation.solvertype = 2
103
- htc.simulation.solvertype.comments = ""
104
- htc.simulation.initial_condition = 1
105
-
106
- # No output, as we will use add_sensor().
107
- # htc.add_section("output")
108
- # htc.output.data_format = "gtsdf"
109
- # htc.output.buffer = 10000
110
-
111
- # Save the new file.
112
- htc.save()
113
-
114
- return htc
115
-
116
-
117
- @pytest.fixture(scope="module")
118
- def write_dtu10mw_only_blade_low_max_iter(write_dtu10mw_only_blade):
119
- # Start from the write_dtu10mw_only_blade and thenreduce the number of max iterations,
120
- # so that the static solver will not have time to converge.
121
- htc = write_dtu10mw_only_blade.copy()
122
- htc.set_name("DTU_10MW_RWT_only_blade_low_max_iter")
123
- htc.simulation.max_iterations = 1
124
- htc.save()
125
-
126
- return htc