h2lib-tests 13.1.2301__py3-none-any.whl → 13.1.2302__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/conftest.py CHANGED
@@ -105,6 +105,9 @@ def write_dtu10mw_only_blade():
105
105
  htc.simulation.solvertype.comments = ""
106
106
  htc.simulation.initial_condition = 1
107
107
 
108
+ # Set low convergence limits.
109
+ htc.simulation.convergence_limits = [1e2, 1e-5, 1e-07]
110
+
108
111
  # No output, as we will use add_sensor().
109
112
 
110
113
  # Save the new file.
@@ -206,6 +209,9 @@ def write_dtu10mw_only_blade_rotate_relative():
206
209
  htc.simulation.solvertype.comments = ""
207
210
  htc.simulation.initial_condition = 1
208
211
 
212
+ # Set low convergence limits.
213
+ htc.simulation.convergence_limits = [1e2, 1e-5, 1e-07]
214
+
209
215
  # Save the new file.
210
216
  htc.save()
211
217
 
@@ -157,7 +157,10 @@ def test_aerosections():
157
157
  plt.figure()
158
158
  plt.plot(frc_before[:, :, 1].T)
159
159
 
160
+ npt.assert_array_almost_equal(h2.get_rotor_avg_wsp(), [0, 6, 0], 10)
160
161
  h2.set_aerosections_windspeed(uvw)
162
+ # rotor avg freestream wsp unknown after setting wsp incl induction at aero section
163
+ npt.assert_array_equal(h2.get_rotor_avg_wsp(), [np.nan, np.nan, np.nan])
161
164
  h2.step()
162
165
  frc_after = h2.get_aerosections_forces()
163
166
  mom_after = h2.get_aerosections_moments()
@@ -63,58 +63,65 @@ def test_static_solver_run_1(h2_dtu_10mw_only_blade):
63
63
  id = h2_dtu_10mw_only_blade.add_sensor("mbdy momentvec blade1 1 1 blade1")
64
64
 
65
65
  # Run the static solver.
66
- h2_dtu_10mw_only_blade.solver_static_run()
66
+ h2_dtu_10mw_only_blade.solver_static_run(reset_structure=True)
67
67
 
68
68
  # Do 1 step to get the output.
69
69
  h2_dtu_10mw_only_blade.step()
70
70
  val = h2_dtu_10mw_only_blade.get_sensor_values(id)
71
71
  # Test against: initial_condition 2; followed by time simulaiton.
72
72
  npt.assert_allclose(
73
- val, np.array([-1.07213851e04, -4.55385871e-02, -3.94623708e01])
73
+ val, np.array([-1.072139e+04, -3.856623e-02, -3.949042e+01]),
74
+ rtol=1e-6
74
75
  )
75
76
 
76
77
 
77
78
  def test_static_solver_run_2(h2_dtu_10mw_only_blade_rotate_base):
78
79
  # Apply centrifugal loading with the base command.
79
80
  # 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
+ id = h2_dtu_10mw_only_blade_rotate_base.add_sensor(
82
+ "mbdy forcevec blade1 1 1 blade1"
83
+ )
81
84
 
82
85
  # Run the static solver.
83
- h2_dtu_10mw_only_blade_rotate_base.solver_static_run()
86
+ h2_dtu_10mw_only_blade_rotate_base.solver_static_run(reset_structure=True)
84
87
 
85
88
  # Do 1 step to get the output.
86
89
  h2_dtu_10mw_only_blade_rotate_base.step()
87
90
  val = h2_dtu_10mw_only_blade_rotate_base.get_sensor_values(id)
88
91
  # Test against: result at the time of writing.
89
- npt.assert_allclose(
90
- val, np.array([10879.129998, 383.43168, 989.68145])
91
- )
92
+ npt.assert_allclose(val, np.array([10879.120647, 383.441758, 989.673212]))
92
93
 
93
94
 
94
95
  def test_static_solver_run_3(h2_dtu_10mw_only_blade_rotate_relative):
95
96
  # Apply centrifugal loading with the relative command.
96
97
  # 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
+ id = h2_dtu_10mw_only_blade_rotate_relative.add_sensor(
99
+ "mbdy forcevec blade1 1 1 blade1"
100
+ )
98
101
 
99
102
  # Run the static solver.
100
- h2_dtu_10mw_only_blade_rotate_relative.solver_static_run()
103
+ h2_dtu_10mw_only_blade_rotate_relative.solver_static_run(
104
+ reset_structure=True
105
+ )
101
106
 
102
107
  # Do 1 step to get the output.
103
108
  h2_dtu_10mw_only_blade_rotate_relative.step()
104
109
  val = h2_dtu_10mw_only_blade_rotate_relative.get_sensor_values(id)
105
110
  # Test against: result at the time of writing.
106
- npt.assert_allclose(
107
- val, np.array([10879.083576, 383.430039, 989.67935])
108
- )
111
+ npt.assert_allclose(val, np.array([10879.074041, 383.440111, 989.67438]))
109
112
 
110
113
 
111
114
  def test_static_solver_run_4(h2_dtu_10mw_only_blade_rotate_bearing3):
112
115
  # Apply centrifugal loading with the bearing3 command.
113
116
  # 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")
117
+ id = h2_dtu_10mw_only_blade_rotate_bearing3.add_sensor(
118
+ "mbdy momentvec blade1 1 1 blade1"
119
+ )
115
120
 
116
121
  # Run the static solver.
117
- h2_dtu_10mw_only_blade_rotate_bearing3.solver_static_run()
122
+ h2_dtu_10mw_only_blade_rotate_bearing3.solver_static_run(
123
+ reset_structure=True
124
+ )
118
125
 
119
126
  # Do 1 step to get the output.
120
127
  h2_dtu_10mw_only_blade_rotate_bearing3.step()
@@ -123,3 +130,73 @@ def test_static_solver_run_4(h2_dtu_10mw_only_blade_rotate_bearing3):
123
130
  npt.assert_allclose(
124
131
  val, np.array([-3094.986918, 115414.095937, 325.296806])
125
132
  )
133
+
134
+
135
+ def test_static_solver_run_no_reset(h2_dtu_10mw_only_blade):
136
+ # Use gravity to deflect the clamped blade.
137
+
138
+ # Run the static solver.
139
+ h2_dtu_10mw_only_blade.solver_static_run(reset_structure=True)
140
+
141
+ # Run it again, without resetting the structure.
142
+ # The static solver must exit immediately and output the same residuals.
143
+ _, resq_1, resg_1, resd_1 = h2_dtu_10mw_only_blade.check_convergence()
144
+ h2_dtu_10mw_only_blade.solver_static_run(reset_structure=False)
145
+ _, resq_2, resg_2, resd_2 = h2_dtu_10mw_only_blade.check_convergence()
146
+
147
+ npt.assert_allclose(
148
+ np.array([resq_2, resg_2, resd_2]), np.array([resq_2, resg_2, resd_2])
149
+ )
150
+
151
+
152
+ def test_static_solver_run_with_reset(h2_dtu_10mw_only_blade):
153
+ # Use gravity to deflect the clamped blade.
154
+
155
+ # Run the static solver.
156
+ h2_dtu_10mw_only_blade.solver_static_run(reset_structure=True)
157
+
158
+ # Run it again, but first reset the structure.
159
+ # The static solver must follow the same convergence history.
160
+ # Note that here we are only checking the last value of the residuals.
161
+ _, resq_1, resg_1, resd_1 = h2_dtu_10mw_only_blade.check_convergence()
162
+ h2_dtu_10mw_only_blade.solver_static_run(reset_structure=True)
163
+ _, resq_2, resg_2, resd_2 = h2_dtu_10mw_only_blade.check_convergence()
164
+
165
+ npt.assert_allclose(
166
+ np.array([resq_2, resg_2, resd_2]), np.array([resq_2, resg_2, resd_2])
167
+ )
168
+
169
+
170
+ def test_structure_reset():
171
+ # Apply centrifugal loading with the base command.
172
+ # We cannot use h2_dtu_10mw_only_blade_rotate_base because we need to add a sensor,
173
+ # and this must be done before init.
174
+
175
+ with H2Lib(suppress_output=True) as h2:
176
+ model_path = f"{tfp}DTU_10_MW/"
177
+ htc_path = "htc/DTU_10MW_RWT_only_blade_rotate_base.htc"
178
+ id = h2.add_sensor(
179
+ "mbdy statevec_new blade1 c2def global absolute 85.0 1.0 0.0 0.0"
180
+ )
181
+ h2.init(htc_path=htc_path, model_path=model_path)
182
+ h2.stop_on_error(False)
183
+
184
+ # Do 1 step to get the output. This is our reference.
185
+ h2.step()
186
+ val_desired = h2.get_sensor_values(id)
187
+
188
+ # Run static solver.
189
+ h2.solver_static_run(reset_structure=False)
190
+
191
+ # The deflection must have changed.
192
+ h2.step()
193
+ val_actual = h2.get_sensor_values(id)
194
+ npt.assert_raises(
195
+ AssertionError, npt.assert_allclose, val_actual, val_desired
196
+ )
197
+
198
+ # Reset the structure and check that we match the reference.
199
+ h2.structure_reset()
200
+ h2.step()
201
+ val_actual = h2.get_sensor_values(id)
202
+ npt.assert_allclose(val_actual, val_desired)
@@ -172,16 +172,27 @@ def test_set_orientation_base_without_reset_orientation(
172
172
  )
173
173
 
174
174
 
175
- def test_set_orientation_base_speed(
176
- h2_dtu_10mw_only_blade
177
- ):
175
+ def test_set_orientation_base_speed(h2_dtu_10mw_only_blade):
176
+ # Add a sensor for the blade root force, in this case only due to centrifugal force.
177
+ id = h2_dtu_10mw_only_blade.add_sensor("mbdy forcevec blade1 1 1 blade1")
178
+
178
179
  # Set speed.
179
180
  h2_dtu_10mw_only_blade.set_orientation_base(
180
181
  main_body="blade1",
181
182
  reset_orientation=False,
182
183
  mbdy_ini_rotvec_d1=np.array([0.0, 1.0, 0.0, 1.0]),
183
184
  )
184
- # TODO: check against h2_dtu_10mw_only_blade_rotate_base.
185
+ # Run static solver.
186
+ h2_dtu_10mw_only_blade.solver_static_run(reset_structure=True)
187
+
188
+ # Do 1 step to get the output.
189
+ h2_dtu_10mw_only_blade.step()
190
+ val = h2_dtu_10mw_only_blade.get_sensor_values(id)
191
+
192
+ # Test against: result at the time of writing.
193
+ # The result is close, but not identical, to test_static_solver_run_2.
194
+ npt.assert_allclose(val, np.array([10879.429172, 793.66543, 1033.395135]))
195
+
185
196
  # Reset speed.
186
197
  h2_dtu_10mw_only_blade.set_orientation_base(
187
198
  main_body="blade1",
@@ -189,15 +200,23 @@ def test_set_orientation_base_speed(
189
200
  )
190
201
 
191
202
 
192
- def test_set_orientation_relative_main_body_not_found(h2_dtu_10mw_only_blade_rotate_relative):
203
+ def test_set_orientation_relative_main_body_not_found(
204
+ h2_dtu_10mw_only_blade_rotate_relative,
205
+ ):
193
206
  h2_dtu_10mw_only_blade_rotate_relative.stop_on_error(False)
194
207
  with pytest.raises(ValueError, match="MAIN_BODY_NOT_FOUND"):
195
- h2_dtu_10mw_only_blade_rotate_relative.set_orientation_relative("hub1", "last", "blade", 0)
208
+ h2_dtu_10mw_only_blade_rotate_relative.set_orientation_relative(
209
+ "hub1", "last", "blade", 0
210
+ )
196
211
 
197
212
 
198
- def test_set_orientation_relative_rot_not_found(h2_dtu_10mw_only_blade_rotate_relative):
213
+ def test_set_orientation_relative_rot_not_found(
214
+ h2_dtu_10mw_only_blade_rotate_relative,
215
+ ):
199
216
  with pytest.raises(ValueError, match="RELATIVE_ROTATION_NOT_FOUND"):
200
- h2_dtu_10mw_only_blade_rotate_relative.set_orientation_relative("hub1", "last", "blade1", "last")
217
+ h2_dtu_10mw_only_blade_rotate_relative.set_orientation_relative(
218
+ "hub1", "last", "blade1", "last"
219
+ )
201
220
 
202
221
 
203
222
  def test_set_orientation_relative_reset(
@@ -273,3 +292,43 @@ def test_set_orientation_relative_2(
273
292
  h2_dtu_10mw_only_blade_rotate_relative.get_body_rotation_tensor(ibdy=1)
274
293
  )
275
294
  npt.assert_array_almost_equal_nulp(amat_actual, amat_desired)
295
+
296
+
297
+ def test_set_orientation_relative_static(
298
+ h2_dtu_10mw_only_blade_rotate_relative,
299
+ ):
300
+ # Add a sensor for the blade root force.
301
+ id = h2_dtu_10mw_only_blade_rotate_relative.add_sensor(
302
+ "mbdy forcevec blade1 1 1 blade1"
303
+ )
304
+
305
+ # Set arbitrary orientation and speed.
306
+ h2_dtu_10mw_only_blade_rotate_relative.set_orientation_relative(
307
+ main_body_1="hub1",
308
+ node_1="last",
309
+ main_body_2="blade1",
310
+ node_2=0,
311
+ reset_orientation=True,
312
+ mbdy2_eulerang_table=np.array([-80.0, 0.0, 0.0]),
313
+ mbdy2_ini_rotvec_d1=[0.0, 1.0, 0.0, 0.8],
314
+ )
315
+ # Run static solver.
316
+ h2_dtu_10mw_only_blade_rotate_relative.solver_static_run(reset_structure=True)
317
+
318
+ # Do 1 step to get the output.
319
+ h2_dtu_10mw_only_blade_rotate_relative.step()
320
+ val = h2_dtu_10mw_only_blade_rotate_relative.get_sensor_values(id)
321
+
322
+ # Test against: result at the time of writing.
323
+ npt.assert_allclose(val, np.array([8702.239718, 306.617339, 638.840412]))
324
+
325
+ # Reset to original value.
326
+ h2_dtu_10mw_only_blade_rotate_relative.set_orientation_relative(
327
+ main_body_1="hub1",
328
+ node_1="last",
329
+ main_body_2="blade1",
330
+ node_2=0,
331
+ mbdy2_eulerang_table=np.array([-90.0, 0.0, 0.0]),
332
+ reset_orientation=True,
333
+ mbdy2_ini_rotvec_d1=np.array([0.0, 1.0, 0.0, 1.0]),
334
+ )
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: h2lib-tests
3
- Version: 13.1.2301
4
- Summary: Tests and test_files for test h2lib (13.1.23+5-gcdb6f43)
3
+ Version: 13.1.2302
4
+ Summary: Tests and test_files for test h2lib (13.1.25)
5
5
  Download-URL:
6
6
  Author: Mads M Pedersen
7
7
  Author-email:
@@ -1,15 +1,15 @@
1
1
  h2lib_tests/__init__.py,sha256=VjSqfGg8BzdmSjfSFhJh4hZbYZ_cME7xp9EWFKHQphA,61
2
- h2lib_tests/conftest.py,sha256=uJrYYp-R7bVpBhfdzJH0CUrshS-S1_hAzST36JJZNbo,14559
2
+ h2lib_tests/conftest.py,sha256=DAxRUsOP7-3-JUTglMSuyr1qcsdrqeKEDerEtenL0lA,14753
3
3
  h2lib_tests/dtu10mw.py,sha256=a7SXfyDwDQPastYKb5CgghOQcYfgO1eTwGrd-H3Enok,4374
4
4
  h2lib_tests/test_calc.py,sha256=VNLfr2J9R2Jy9xTbdZ9dfbQ4dCwr7H7nbZRI3yP69fQ,2152
5
5
  h2lib_tests/test_ellipsys_couplings.py,sha256=GUvO43QF2YKxXby7eoBObv6Iu0rgMhtOXGcuCHO2JtM,2424
6
6
  h2lib_tests/test_h2lib.py,sha256=opgVOkZWOD9CrnTDfwRrBaD-weBsNnutm6FeOijDa88,14197
7
- h2lib_tests/test_h2rotor.py,sha256=SP4NTByJGJDc9yezR9QdijYlsJjMJ4BwItbhksijL1U,10597
7
+ h2lib_tests/test_h2rotor.py,sha256=b3enflMN4l4Hvy3odWLXsZ4-9VBRjVaWUSllBRzXbMM,10838
8
8
  h2lib_tests/test_lin.py,sha256=FxuDvPuu1MjWE4B7dIWC3qR-9NtjqodGPO1aurUDBwY,6362
9
9
  h2lib_tests/test_mpi.py,sha256=sDiUMnZ5j-3y7fOpUy5-s624guTejKwlP-NHRZet3iY,6847
10
10
  h2lib_tests/test_multiprocessinterface.py,sha256=h2o4havtK6IuMXsplNjGUa3VxOnbpEYGxdrrAKQilj0,1470
11
- h2lib_tests/test_static_solver.py,sha256=OiabTF7IwIskkvBslp32c5o4v53YHQNTTV3vOU5vVb8,4679
12
- h2lib_tests/test_topology_h2lib.py,sha256=AIPgO6ePVoZbjX_ECmlQu8Iog1dIBzd192hkXBvg1V0,9651
11
+ h2lib_tests/test_static_solver.py,sha256=mGapb1vwSoe0Uqpc3-xjDegqauf2R_XMHshnvVojwmY,7509
12
+ h2lib_tests/test_topology_h2lib.py,sha256=dCwvfgO1eHb53PCXwm-nr6iwKdsviU2tuAnU0WIrsJc,11645
13
13
  h2lib_tests/test_files/__init__.py,sha256=9e6ZUPb42e0wf2E1rutdcTM8hROcWFRVPXtZriU3ySw,50
14
14
  h2lib_tests/test_files/my_test_cls.py,sha256=7ZDsFkxrLfOY6q00U5Y-daxfuhATK-K5H04RP-VmQdE,850
15
15
  h2lib_tests/test_files/DTU_10_MW/control/dtu_we_controller.dll,sha256=C5T_CuAFtIuDgCXSYAoNu24yKPwj2nWOeORacJbLN9s,1134592
@@ -89,7 +89,7 @@ h2lib_tests/test_files/minimal/res/minimal_mann_turb.hdf5,sha256=Q3cs3bZyplZjBpo
89
89
  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
90
90
  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
91
91
  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
92
- h2lib_tests-13.1.2301.dist-info/METADATA,sha256=OUugVXDBqUPSq4FO51fyoNuSbB_kT1ucDZA3BfpGsZU,419
93
- h2lib_tests-13.1.2301.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
94
- h2lib_tests-13.1.2301.dist-info/top_level.txt,sha256=WufAL3LO35YJBhWg1AfgTjSld-6l_WuRkXAkNKczUrM,12
95
- h2lib_tests-13.1.2301.dist-info/RECORD,,
92
+ h2lib_tests-13.1.2302.dist-info/METADATA,sha256=2xAxSCnVwrOtfNcEru0fQ9fCtEhYR9ZLmvkfTvF5_zk,408
93
+ h2lib_tests-13.1.2302.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
94
+ h2lib_tests-13.1.2302.dist-info/top_level.txt,sha256=WufAL3LO35YJBhWg1AfgTjSld-6l_WuRkXAkNKczUrM,12
95
+ h2lib_tests-13.1.2302.dist-info/RECORD,,