h2lib-tests 13.1.3101__py3-none-any.whl → 13.1.3103__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.
@@ -1,8 +1,9 @@
1
- from h2lib._h2lib import MultiH2Lib, H2LibThread
1
+ from h2lib._h2lib import MultiH2Lib, H2LibThread, H2Lib
2
2
  import numpy as np
3
3
  from wetb.hawc2.htc_file import HTCFile
4
4
  from numpy import newaxis as na
5
5
  from h2lib_tests.test_files import tfp
6
+ import pytest
6
7
 
7
8
 
8
9
  class Ellipsys():
@@ -23,17 +24,38 @@ class Ellipsys():
23
24
  pass
24
25
 
25
26
 
27
+ def test_set_aerosections_windspeeds_without_init(capfd):
28
+
29
+ with H2Lib(suppress_output=0) as h2:
30
+ el = Ellipsys()
31
+ htc = HTCFile(tfp + 'DTU_10_MW/htc/DTU_10MW_RWT_no_aerodrag.htc')
32
+ htc.set_name(f'wt0')
33
+ htc.save()
34
+
35
+ h2.init(htc_path=f'htc/wt0.htc', model_path=tfp + 'DTU_10_MW')
36
+ wt_pos = np.array([0, 0, 0])
37
+
38
+ el.step()
39
+ pos_gl_xyz = np.array(h2.get_aerosections_position(), order='F') + wt_pos[na, na, :]
40
+ uvw = np.asfortranarray(el.get_uvw(pos_gl_xyz))
41
+
42
+ with pytest.raises(Exception, match='Please call init_AD or init_AL before set_aerosections_windspeed'):
43
+ h2.set_aerosections_windspeed(uvw)
44
+ out = capfd.readouterr().out
45
+ assert "Please call init_AD or init_AL before set_aerosections_windspeed" in out
46
+
47
+
26
48
  def test_ellipsys_dummy_workflow_1wt():
27
49
 
28
50
  N = 1
29
- with MultiH2Lib(N, suppress_output=True) as h2:
51
+ with MultiH2Lib(N, suppress_output=0) as h2:
30
52
  el = Ellipsys()
31
53
  htc = HTCFile(tfp + 'DTU_10_MW/htc/DTU_10MW_RWT_no_aerodrag.htc')
32
54
  for i in range(N):
33
55
  htc.set_name(f'wt{i}')
34
56
  htc.save()
35
57
 
36
- h2.init(htc_path=f'htc/wt0.htc', model_path=tfp + 'DTU_10_MW')
58
+ h2.init_AD(htc_path=f'htc/wt0.htc', model_path=tfp + 'DTU_10_MW', tiploss_shen_c2=28)
37
59
  wt_pos = np.array([0, 0, 0])
38
60
 
39
61
  while True:
@@ -51,15 +73,14 @@ def test_ellipsys_dummy_workflow_1wt():
51
73
  def test_ellipsys_dummy_workflow():
52
74
 
53
75
  N = 4
54
- with MultiH2Lib(N, suppress_output=True) as h2:
76
+ with MultiH2Lib(N, suppress_output=1) as h2:
55
77
  el = Ellipsys()
56
78
  htc = HTCFile(tfp + 'DTU_10_MW/htc/DTU_10MW_RWT_no_aerodrag.htc')
57
79
  for i in range(N):
58
80
  htc.set_name(f'wt{i}')
59
81
  htc.save()
60
82
 
61
- h2.init(htc_path=[f'htc/wt{i}.htc' for i in range(N)],
62
- model_path=tfp + 'DTU_10_MW')
83
+ h2.init_AD(htc_path=[f'htc/wt{i}.htc' for i in range(N)], model_path=tfp + 'DTU_10_MW', tiploss_shen_c2=28)
63
84
  wt_pos = np.array([[0, 0, 0], [0, 500, 0], [0, 1000, 0], [0, 1500, 0]])
64
85
 
65
86
  while True:
h2lib_tests/test_h2lib.py CHANGED
@@ -301,7 +301,7 @@ def test_process_died():
301
301
  h2.echo_version()
302
302
 
303
303
 
304
- def test_error():
304
+ def test_error(capfd):
305
305
  model_path = tfp + "minimal/"
306
306
  htc = HTCFile(model_path + 'htc/minimal_mann_turb.htc')
307
307
  htc.wind.scale_time_start = 200
@@ -310,44 +310,39 @@ def test_error():
310
310
  htc.set_name('tmp')
311
311
  htc.save()
312
312
 
313
- with H2Lib() as h2:
314
- with pytest.raises(Exception, match=re.escape('H2LibThread process died before or while executing init(htc/tmp.htc, ')):
313
+ with H2Lib(suppress_output=0) as h2:
314
+ version = h2.get_version()
315
+ with pytest.raises(Exception, match='Turbulence scale_time_start >= simulation length'):
315
316
  h2.init('htc/tmp.htc', model_path)
317
+ out, err = capfd.readouterr()
318
+ assert "*** ERROR *** Turbulence scale_time_start >= simulation length" in out
319
+ assert h2.get_version() == version # hawc2 still alive
320
+ with pytest.raises(ValueError):
321
+ h2.get_version() # now it is closed
316
322
 
317
323
  with MultiH2Lib(2) as h2:
318
- with pytest.raises(Exception, match=re.escape('H2LibThread process died before or while executing init(...)')):
324
+ version = h2.get_version()
325
+ with pytest.raises(Exception, match='Turbulence scale_time_start >= simulation length'):
319
326
  h2.init('htc/tmp.htc', model_path)
327
+ assert h2.get_version() == version # hawc2 still alive
320
328
 
321
329
 
322
330
  def test_fail():
323
331
  with H2Lib() as h2:
324
- with pytest.raises(Exception, match=re.escape('H2LibThread process died before or while executing fail(MyError)')):
332
+ version = h2.get_version()
333
+ with pytest.raises(Exception, match='MyError'):
325
334
  h2.fail('MyError')
335
+ assert h2.get_version() == version # hawc2 still alive
336
+ stop_code = 0
337
+
338
+ # cover get_stop_code, get_stop_message and reset_stop_code_and_message, but
339
+ # reset_stop_code_and_message is already called, so stop_code and stop_message are 0 and ""
340
+ assert h2.get_stop_code(stop_code)[0][0] == 0
341
+ stop_msg = " " * 1024
342
+ assert h2.get_stop_message(stop_msg)[0][0].strip() == ''
343
+ h2.reset_stop_code_and_message()
326
344
 
327
345
  with MultiH2Lib(2) as h2:
328
346
  # , match=re.escape('H2LibThread process died before or while executing fail(...)')):
329
- with pytest.raises(Exception):
347
+ with pytest.raises(Exception, match='MyError'):
330
348
  h2.fail('MyError')
331
-
332
-
333
- def test_dont_stop(capfd):
334
- # This test is the same as test_error(), but instead we disable stop.
335
- model_path = tfp + "minimal/"
336
- htc = HTCFile(model_path + 'htc/minimal_mann_turb.htc')
337
- htc.wind.scale_time_start = 200
338
- htc.wind.turb_format = 1
339
- htc.wind.mann.dont_scale = 0
340
- htc.set_name('tmp')
341
- htc.save()
342
-
343
- with H2Lib() as h2:
344
- h2.stop_on_error(False)
345
- h2.init('htc/tmp.htc', model_path)
346
- out, err = capfd.readouterr()
347
- assert "*** ERROR *** Turbulence scale_time_start >= simulation length" in out
348
-
349
- with MultiH2Lib(2) as h2:
350
- h2.stop_on_error(False)
351
- h2.init('htc/tmp.htc', model_path)
352
- out, err = capfd.readouterr()
353
- assert "*** ERROR *** Turbulence scale_time_start >= simulation length" in out
@@ -14,7 +14,7 @@ import h5py
14
14
 
15
15
 
16
16
  def get_h2(htc_path='htc/DTU_10MW_RWT.htc'):
17
- h2 = H2Lib(suppress_output=True)
17
+ h2 = H2Lib(suppress_output=1)
18
18
  h2.read_input(htc_path=htc_path, model_path=tfp + 'DTU_10_MW')
19
19
  return h2
20
20
 
@@ -123,14 +123,14 @@ def test_rotor_avg_windspeed():
123
123
 
124
124
 
125
125
  def test_aerosections():
126
- plot = False
126
+ plot = 0
127
127
  h2 = get_h2(htc_path='htc/DTU_10MW_RWT_no_aerodrag.htc')
128
128
  # blade 1, global coo, r>30
129
129
  pos_ids = [h2.add_sensor(f'aero position 3 1 {xyz} 30')[0] for xyz in [1, 2, 3]]
130
130
  wsp_ids = [h2.add_sensor(f'aero windspeed 3 1 {xyz} 30')[0] for xyz in [1, 2, 3]]
131
131
  frc_ids = [h2.add_sensor(f'aero secforce 1 {xyz} 30 3')[0] for xyz in [1, 2, 3]]
132
132
  mom_ids = [h2.add_sensor(f'aero secmoment 1 {xyz} 30 3')[0] for xyz in [1, 2, 3]]
133
- h2.init()
133
+ h2.init_AL(epsilon_smearing=5)
134
134
 
135
135
  a = h2.get_aerosections_position()
136
136
  if plot:
@@ -154,7 +154,7 @@ def test_aerosections():
154
154
  npt.assert_array_almost_equal(a[0, i], [h2.get_sensor_values(id) for id in pos_ids])
155
155
  uvw = a * 0
156
156
  uvw[:, :, 0] = 6
157
- uvw[0, i, 0] = 12
157
+ h2.set_aerosections_windspeed(uvw)
158
158
  h2.run(3)
159
159
  npt.assert_array_equal(h2.get_sensor_values(wsp_ids), [0, 6, 0])
160
160
  npt.assert_array_almost_equal(h2.get_sensor_values(frc_ids), h2.get_aerosections_forces()[0, i] / 1000)
@@ -165,10 +165,11 @@ def test_aerosections():
165
165
  plt.figure()
166
166
  plt.plot(frc_before[:, :, 1].T)
167
167
 
168
- npt.assert_array_almost_equal(h2.get_rotor_avg_wsp(), [0, 6, 0], 10)
169
- h2.set_aerosections_windspeed(uvw)
170
- # rotor avg freestream wsp unknown after setting wsp incl induction at aero section
168
+ # rotor avg freestream wsp unknown after init_AD
171
169
  npt.assert_array_equal(h2.get_rotor_avg_wsp(), [np.nan, np.nan, np.nan])
170
+ uvw[0, i, 0] = 12
171
+ h2.set_aerosections_windspeed(uvw)
172
+
172
173
  h2.step()
173
174
  frc_after = h2.get_aerosections_forces()
174
175
  mom_after = h2.get_aerosections_moments()
@@ -180,7 +181,7 @@ def test_aerosections():
180
181
  assert frc_before[0, i, 1] * 2 < frc_after[0, i, 1]
181
182
 
182
183
  # rest is similar (within 7N/m, max Fxyz along blade is [331 , 378, 288]
183
- frc_after[0, i, :] = frc_before[0, i, :]
184
+ frc_after[0, i, :] = frc_before[0, i, :] # reset frc at 30m to previous value. Now everything is similar
184
185
  npt.assert_allclose(frc_before, frc_after, atol=7)
185
186
  h2.close()
186
187
 
@@ -235,7 +236,7 @@ def test_compare_aerosection_coupling():
235
236
 
236
237
  dtu10.set_name('tmp1')
237
238
  dtu10.save()
238
- with H2Lib(suppress_output=True) as h2:
239
+ with H2Lib(suppress_output=1) as h2:
239
240
  h2.init(dtu10.filename, dtu10.modelpath)
240
241
  h2.run(T)
241
242
 
@@ -244,8 +245,8 @@ def test_compare_aerosection_coupling():
244
245
  dtu10.set_name('tmp2')
245
246
  dtu10.save()
246
247
 
247
- with H2Lib(suppress_output=True) as h2:
248
- h2.init(dtu10.filename, dtu10.modelpath)
248
+ with H2Lib(suppress_output=1) as h2:
249
+ h2.init_AD(htc_path=dtu10.filename, model_path=dtu10.modelpath, tiploss_method=0)
249
250
  last_pos_gl_xyz = np.array(h2.get_aerosections_position(), order='F')
250
251
  while h2.time < T:
251
252
  pos_gl_xyz = np.array(h2.get_aerosections_position(), order='F')
h2lib_tests/test_mpi.py CHANGED
@@ -146,7 +146,7 @@ def test_ellipsys_mpi_dummy_workflow():
146
146
  h2.read_input(htc_path=get_htc_lst(),
147
147
  model_path=tfp + 'DTU_10_MW')
148
148
  wt_pos = np.array([[0, 0, 0], [0, 500, 0], [0, 1000, 0], [0, 1500, 0]])
149
- h2.init()
149
+ h2.init_AD()
150
150
  t = 0
151
151
  while True:
152
152
  t = el.step()
@@ -176,7 +176,7 @@ def test_ellipsys_mpi_dummy_workflow_collective():
176
176
  h2.read_input(htc_path=get_htc_lst(),
177
177
  model_path=tfp + 'DTU_10_MW')
178
178
  wt_pos = np.array([[0, 0, 0], [0, 500, 0], [0, 1000, 0], [0, 1500, 0]])
179
- h2.init()
179
+ h2.init_AD()
180
180
  t = 0
181
181
  while True:
182
182
  t = el.step()
@@ -189,9 +189,7 @@ def test_set_orientation_relative_main_body_not_found(
189
189
  ):
190
190
  h2_dtu_10mw_only_blade_rotate_relative.stop_on_error(False)
191
191
  with pytest.raises(ValueError, match="MAIN_BODY_NOT_FOUND"):
192
- h2_dtu_10mw_only_blade_rotate_relative.set_orientation_relative(
193
- "hub1", "last", "blade", 0
194
- )
192
+ h2_dtu_10mw_only_blade_rotate_relative.set_orientation_relative("hub1", "last", "blade", 0)
195
193
 
196
194
 
197
195
  def test_set_orientation_relative_rot_not_found(
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: h2lib-tests
3
- Version: 13.1.3101
4
- Summary: Tests and test_files for test h2lib (13.1.31+1-g14e98da)
3
+ Version: 13.1.3103
4
+ Summary: Tests and test_files for test h2lib (13.1.31+5-g08eea40)
5
5
  Download-URL:
6
6
  Author: Mads M Pedersen
7
7
  Author-email:
@@ -2,14 +2,14 @@ h2lib_tests/__init__.py,sha256=VjSqfGg8BzdmSjfSFhJh4hZbYZ_cME7xp9EWFKHQphA,61
2
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
- h2lib_tests/test_ellipsys_couplings.py,sha256=GUvO43QF2YKxXby7eoBObv6Iu0rgMhtOXGcuCHO2JtM,2424
6
- h2lib_tests/test_h2lib.py,sha256=opgVOkZWOD9CrnTDfwRrBaD-weBsNnutm6FeOijDa88,14197
7
- h2lib_tests/test_h2rotor.py,sha256=ZMhTdGvRYAORULd18X2woEDFrGB29DU-K2J2VA6sE-8,11262
5
+ h2lib_tests/test_ellipsys_couplings.py,sha256=JLos66l_zNDBY6glxwqSfDa6p0Uko5aRKAckh2uoSSM,3302
6
+ h2lib_tests/test_h2lib.py,sha256=LEV1n0Fwa1llQwIM06Mcqr07Y6WOn-j8mNxjzlCEOl0,14219
7
+ h2lib_tests/test_h2rotor.py,sha256=4P5bUGvwYDl8Z9hVNP_SXKa79DWhsA-ptpp0v0rT9ow,11309
8
8
  h2lib_tests/test_lin.py,sha256=KujYIy9YXTo-uxi_umRWIWZwcHu0oH8GyeVgMcMCq0o,6383
9
- h2lib_tests/test_mpi.py,sha256=l3V6fts0NJ2Vmsm7Tm5eYbOtewUyrcQurdaLJVITALM,6984
9
+ h2lib_tests/test_mpi.py,sha256=8bMeukbWboijMgWLJIIu3Pn0QtaDadOGhhL099MfMls,6990
10
10
  h2lib_tests/test_multiprocessinterface.py,sha256=h2o4havtK6IuMXsplNjGUa3VxOnbpEYGxdrrAKQilj0,1470
11
11
  h2lib_tests/test_static_solver.py,sha256=ckzcBAuVge5V5tdrac4PPYxrH5TheNTUc3PKksbB89A,7426
12
- h2lib_tests/test_topology_h2lib.py,sha256=VjJ1SUBHRHwuSn0EPI6KGzwAULZbPzA39rXdDGXyxkk,11510
12
+ h2lib_tests/test_topology_h2lib.py,sha256=U1NOREhoJ9m7cYxb8sLsVuKSHRqjkEde6hoyl88IF4A,11486
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.3101.dist-info/METADATA,sha256=oqZnjRxb1_2zZvCrPkhXUd9kJBvUb4AiVHf8m1UYclU,419
93
- h2lib_tests-13.1.3101.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
94
- h2lib_tests-13.1.3101.dist-info/top_level.txt,sha256=WufAL3LO35YJBhWg1AfgTjSld-6l_WuRkXAkNKczUrM,12
95
- h2lib_tests-13.1.3101.dist-info/RECORD,,
92
+ h2lib_tests-13.1.3103.dist-info/METADATA,sha256=2hyzPnwoJPCSkngKuqGVx5i49g2Kl_FRGaSA5OYxuek,419
93
+ h2lib_tests-13.1.3103.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
94
+ h2lib_tests-13.1.3103.dist-info/top_level.txt,sha256=WufAL3LO35YJBhWg1AfgTjSld-6l_WuRkXAkNKczUrM,12
95
+ h2lib_tests-13.1.3103.dist-info/RECORD,,