h2lib-tests 13.1.2601__py3-none-any.whl → 13.1.3102__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='H2LibThread process died before or while executing set_aerosections_windspeed'):
43
+ h2.set_aerosections_windspeed(uvw)
44
+ out = capfd.readouterr().out
45
+ assert "Please call init_ad or init_al be" 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:
@@ -1,3 +1,4 @@
1
+ import os
1
2
  from h2lib._h2lib import H2Lib, MultiH2Lib
2
3
 
3
4
  from numpy import testing as npt
@@ -9,10 +10,11 @@ from h2lib_tests.test_files import tfp
9
10
  import matplotlib.pyplot as plt
10
11
  import numpy as np
11
12
  from wetb.hawc2.at_time_file import AtTimeFile
13
+ import h5py
12
14
 
13
15
 
14
16
  def get_h2(htc_path='htc/DTU_10MW_RWT.htc'):
15
- h2 = H2Lib(suppress_output=True)
17
+ h2 = H2Lib(suppress_output=1)
16
18
  h2.read_input(htc_path=htc_path, model_path=tfp + 'DTU_10_MW')
17
19
  return h2
18
20
 
@@ -65,17 +67,17 @@ def test_induction(h2):
65
67
 
66
68
  def test_rotor_orientation_multi_instance():
67
69
  dtu10 = DTU10MW()
70
+ dtu10.simulation.visualization = 'visu', .5, 1.5
68
71
  dtu10.output.buffer = 1
69
72
  dtu10.output.data_format = 'gtsdf64'
70
73
  dtu10.set_name('tmp_5_0')
71
-
72
74
  dtu10.save()
73
75
 
74
76
  tilt_ref, yaw_ref = 6, 10
75
77
  dtu10.set_tilt_cone_yaw(tilt=tilt_ref, cone=0, yaw=yaw_ref)
76
78
  dtu10.set_name('tmp_6_10')
77
79
  dtu10.save()
78
- with MultiH2Lib(2, suppress_output=True) as mh2:
80
+ with MultiH2Lib(2, suppress_output=1) as mh2:
79
81
  mh2.read_input(['htc/tmp_5_0.htc', 'htc/tmp_6_10.htc'], model_path=tfp + "DTU_10_MW")
80
82
  # h2.suppress_output = False
81
83
  s_id = mh2.add_sensor('aero power')[0]
@@ -98,6 +100,12 @@ def test_rotor_orientation_multi_instance():
98
100
  npt.assert_allclose(data[:, 0], res[1:-1, 0] % 360 - 180, rtol=0.002) # azi
99
101
  npt.assert_array_almost_equal(data[:, 10], res[1:-1, 1]) # power
100
102
  npt.assert_array_almost_equal(data[:, 15:18], res[1:-1, 2:5]) # rotor position
103
+ assert os.path.isfile(mh2.model_path[0] + '/visualization/tmp_5_0.hdf5')
104
+
105
+ with h5py.File(mh2.model_path[0] + '/visualization/tmp_5_0.hdf5') as f:
106
+ assert f.attrs['time_start'][0] == 0.5
107
+ assert f.attrs['time_stop'][0] == 1.5
108
+ assert os.path.isfile(mh2.model_path[1] + '/visualization/tmp_6_10.hdf5')
101
109
 
102
110
 
103
111
  def test_rotor_avg_windspeed():
@@ -115,14 +123,14 @@ def test_rotor_avg_windspeed():
115
123
 
116
124
 
117
125
  def test_aerosections():
118
- plot = False
126
+ plot = 0
119
127
  h2 = get_h2(htc_path='htc/DTU_10MW_RWT_no_aerodrag.htc')
120
128
  # blade 1, global coo, r>30
121
129
  pos_ids = [h2.add_sensor(f'aero position 3 1 {xyz} 30')[0] for xyz in [1, 2, 3]]
122
130
  wsp_ids = [h2.add_sensor(f'aero windspeed 3 1 {xyz} 30')[0] for xyz in [1, 2, 3]]
123
131
  frc_ids = [h2.add_sensor(f'aero secforce 1 {xyz} 30 3')[0] for xyz in [1, 2, 3]]
124
132
  mom_ids = [h2.add_sensor(f'aero secmoment 1 {xyz} 30 3')[0] for xyz in [1, 2, 3]]
125
- h2.init()
133
+ h2.init_AL(epsilon_smearing=5)
126
134
 
127
135
  a = h2.get_aerosections_position()
128
136
  if plot:
@@ -146,7 +154,7 @@ def test_aerosections():
146
154
  npt.assert_array_almost_equal(a[0, i], [h2.get_sensor_values(id) for id in pos_ids])
147
155
  uvw = a * 0
148
156
  uvw[:, :, 0] = 6
149
- uvw[0, i, 0] = 12
157
+ h2.set_aerosections_windspeed(uvw)
150
158
  h2.run(3)
151
159
  npt.assert_array_equal(h2.get_sensor_values(wsp_ids), [0, 6, 0])
152
160
  npt.assert_array_almost_equal(h2.get_sensor_values(frc_ids), h2.get_aerosections_forces()[0, i] / 1000)
@@ -157,10 +165,11 @@ def test_aerosections():
157
165
  plt.figure()
158
166
  plt.plot(frc_before[:, :, 1].T)
159
167
 
160
- npt.assert_array_almost_equal(h2.get_rotor_avg_wsp(), [0, 6, 0], 10)
161
- h2.set_aerosections_windspeed(uvw)
162
- # rotor avg freestream wsp unknown after setting wsp incl induction at aero section
168
+ # rotor avg freestream wsp unknown after init_AD
163
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
+
164
173
  h2.step()
165
174
  frc_after = h2.get_aerosections_forces()
166
175
  mom_after = h2.get_aerosections_moments()
@@ -172,7 +181,7 @@ def test_aerosections():
172
181
  assert frc_before[0, i, 1] * 2 < frc_after[0, i, 1]
173
182
 
174
183
  # rest is similar (within 7N/m, max Fxyz along blade is [331 , 378, 288]
175
- 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
176
185
  npt.assert_allclose(frc_before, frc_after, atol=7)
177
186
  h2.close()
178
187
 
@@ -227,7 +236,7 @@ def test_compare_aerosection_coupling():
227
236
 
228
237
  dtu10.set_name('tmp1')
229
238
  dtu10.save()
230
- with H2Lib(suppress_output=True) as h2:
239
+ with H2Lib(suppress_output=1) as h2:
231
240
  h2.init(dtu10.filename, dtu10.modelpath)
232
241
  h2.run(T)
233
242
 
@@ -236,8 +245,8 @@ def test_compare_aerosection_coupling():
236
245
  dtu10.set_name('tmp2')
237
246
  dtu10.save()
238
247
 
239
- with H2Lib(suppress_output=True) as h2:
240
- 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)
241
250
  last_pos_gl_xyz = np.array(h2.get_aerosections_position(), order='F')
242
251
  while h2.time < T:
243
252
  pos_gl_xyz = np.array(h2.get_aerosections_position(), order='F')
h2lib_tests/test_lin.py CHANGED
@@ -35,6 +35,7 @@ def test_system_not_linearized_3(h2_dtu_10mw_only_blade):
35
35
 
36
36
 
37
37
  def test_linearize(h2_dtu_10mw_only_blade):
38
+ h2_dtu_10mw_only_blade.structure_reset()
38
39
  n_tdofs, n_rdofs = h2_dtu_10mw_only_blade.linearize()
39
40
  assert n_rdofs == 26 * 6 # = number of nodes * 6
40
41
  assert n_tdofs == 26 * 6 * 2 # times 2 because of speed.
@@ -57,16 +58,14 @@ def test_sys_eig_no_damping(h2_dtu_10mw_only_blade):
57
58
  # Test against: result at the time of writing.
58
59
  npt.assert_allclose(
59
60
  natural_frequencies,
60
- np.array([0.610409, 0.930466, 1.739094, 2.761632]),
61
+ np.array([0.610409, 0.930443, 1.739081, 2.761946]),
61
62
  rtol=1e-6,
62
63
  )
63
64
 
64
65
 
65
66
  def test_sys_eig_no_damping_wrong_n_modes(h2_dtu_10mw_only_blade):
66
67
  with pytest.raises(ValueError, match="TOO_MANY_MODES_REQUESTED"):
67
- h2_dtu_10mw_only_blade.get_system_eigenvalues_and_eigenvectors(
68
- 1000, 156
69
- )
68
+ h2_dtu_10mw_only_blade.get_system_eigenvalues_and_eigenvectors(1000, 156)
70
69
 
71
70
 
72
71
  def test_sys_eig_no_damping_wrong_ny(h2_dtu_10mw_only_blade):
@@ -77,10 +76,8 @@ def test_sys_eig_no_damping_wrong_ny(h2_dtu_10mw_only_blade):
77
76
  def test_sys_eig_no_damping_eigv(h2_dtu_10mw_only_blade):
78
77
  n_modes = 4
79
78
  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
- )
79
+ eig_val, eig_vec = h2_dtu_10mw_only_blade.get_system_eigenvalues_and_eigenvectors(
80
+ n_modes, n_rdofs, include_damping=False
84
81
  )
85
82
  assert eig_val.size == n_modes
86
83
  assert eig_vec.shape == (n_modes, n_rdofs)
@@ -88,7 +85,7 @@ def test_sys_eig_no_damping_eigv(h2_dtu_10mw_only_blade):
88
85
  assert eig_vec.dtype == np.float64
89
86
  npt.assert_allclose(
90
87
  eig_val,
91
- np.array([3.83531, 5.846293, 10.927047, 17.351849]),
88
+ np.array([3.835311, 5.846144, 10.92697, 17.353821]),
92
89
  )
93
90
 
94
91
 
@@ -98,20 +95,18 @@ def test_sys_eig_with_damping(h2_dtu_10mw_only_blade):
98
95
  )
99
96
  # Test against: result at the time of writing.
100
97
  npt.assert_allclose(
101
- freq, np.array([0.610409, 0.930468, 1.739098, 2.761702]), rtol=1e-6
98
+ freq, np.array([0.610409, 0.930444, 1.739086, 2.762015]), rtol=1e-6
102
99
  )
103
100
  npt.assert_allclose(
104
- damp, np.array([0.004826, 0.004758, 0.013395, 0.014194]), atol=1e-6
101
+ damp, np.array([0.004826, 0.004758, 0.013395, 0.014198]), atol=1e-6
105
102
  )
106
103
 
107
104
 
108
105
  def test_sys_eig_with_damping_eigv(h2_dtu_10mw_only_blade):
109
106
  n_modes = 4
110
107
  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
- )
108
+ eig_val, eig_vec = h2_dtu_10mw_only_blade.get_system_eigenvalues_and_eigenvectors(
109
+ n_modes, n_rdofs, include_damping=True
115
110
  )
116
111
  assert eig_val.size == n_modes
117
112
  assert eig_vec.shape == (n_modes, 2 * n_rdofs)
@@ -121,10 +116,10 @@ def test_sys_eig_with_damping_eigv(h2_dtu_10mw_only_blade):
121
116
  eig_val,
122
117
  np.array(
123
118
  [
124
- -0.01851 - 3.835266j,
125
- -0.027817 - 5.846237j,
126
- -0.146367 - 10.926094j,
127
- -0.246296 - 17.350536j,
119
+ -0.01851 - 3.835268j,
120
+ -0.027814 - 5.846088j,
121
+ -0.146364 - 10.926018j,
122
+ -0.246401 - 17.352505j,
128
123
  ]
129
124
  ),
130
125
  atol=1e-6,
@@ -152,6 +147,7 @@ def test_get_system_matrices(h2_dtu_10mw_only_blade):
152
147
 
153
148
 
154
149
  def test_sys_eig_encrypted(h2_dtu_10mw_only_tower_encrypted):
150
+ h2_dtu_10mw_only_tower_encrypted.structure_reset()
155
151
  n_tdofs, n_rdofs = h2_dtu_10mw_only_tower_encrypted.linearize()
156
152
  n_modes = 4
157
153
  freq, damp = h2_dtu_10mw_only_tower_encrypted.do_system_eigenanalysis(
@@ -185,7 +181,7 @@ def test_sys_eig_encrypted(h2_dtu_10mw_only_tower_encrypted):
185
181
  )
186
182
 
187
183
 
188
- def test_test_get_system_matrices_encrypted(h2_dtu_10mw_only_tower_encrypted):
184
+ def test_get_system_matrices_encrypted(h2_dtu_10mw_only_tower_encrypted):
189
185
  n_tdofs, n_rdofs = h2_dtu_10mw_only_tower_encrypted.linearize()
190
186
  with pytest.raises(RuntimeError, match="STRUCTURE_IS_CONFIDENTIAL"):
191
187
  h2_dtu_10mw_only_tower_encrypted.get_system_matrices(n_tdofs, n_rdofs)
h2lib_tests/test_mpi.py CHANGED
@@ -1,24 +1,49 @@
1
- import h2lib
2
- from h2lib._h2lib import H2LibProcess, MultiH2Lib, set_LD_LIBRARY_PATH
3
1
  import os
2
+ import sys
4
3
  import time
4
+ import traceback
5
5
 
6
+ from h2lib_tests.test_files import tfp
6
7
  from numpy import testing as npt
7
8
  import pytest
9
+ from wetb.hawc2.htc_file import HTCFile
8
10
 
11
+ import h2lib
12
+ from h2lib._h2lib import H2LibProcess, MultiH2Lib, set_LD_LIBRARY_PATH
13
+ from h2lib_tests.test_files.my_test_cls import MyTest
14
+ from multiclass_interface import mpi_interface
9
15
  from multiclass_interface.mpi_interface import MPIClassInterface
10
16
  from multiclass_interface.multiprocess_interface import ProcessClass, MultiProcessClassInterface
11
-
12
- from h2lib_tests.test_files import tfp
13
17
  import numpy as np
14
- from h2lib_tests.test_files.my_test_cls import MyTest
15
- from multiclass_interface import mpi_interface
18
+ import shutil
19
+
16
20
 
17
21
  set_LD_LIBRARY_PATH
18
22
 
23
+ mpi_available = shutil.which('mpirun') is not None
24
+
25
+
26
+ def mpirun(f):
27
+ if 'string' in traceback.format_stack()[0]:
28
+ return f
29
+ else:
30
+ n = f.__name__
31
+
32
+ def wrap():
33
+ if mpi_available:
34
+ exe = sys.executable.replace("\\", "/")
35
+ cmd = f'''mpirun -n 4 {exe} -c "from h2lib_tests.test_mpi import {n}; {n}()"'''
36
+ # print(cmd)
37
+ assert os.system(cmd) == 0, n
38
+ else:
39
+ pytest.xfail('mpirun not available')
40
+ wrap.__name__ = n
41
+ return wrap
19
42
 
20
- def mpitest_mpi_MyTest():
21
43
 
44
+ @mpirun
45
+ def test_mpi_MyTest():
46
+ mpi_interface.activate_mpi()
22
47
  N = 4
23
48
  try:
24
49
  with MPIClassInterface(MyTest, [(i,) for i in range(N)]) as m:
@@ -38,28 +63,31 @@ def mpitest_mpi_MyTest():
38
63
  with pytest.raises(Exception, match='Cannot make subset of SubsetMPIClassInterface'):
39
64
  m[:3][1]
40
65
 
41
- print("done, test_mpi_MyTest")
42
66
  except ChildProcessError:
43
67
  pass
44
68
 
45
69
 
46
- def mpitest_mpi_ProcessClass():
70
+ @mpirun
71
+ def test_mpi_ProcessClass():
72
+ mpi_interface.activate_mpi()
47
73
 
48
74
  with ProcessClass(MyTest) as cls:
49
75
  myTest = cls(1)
50
76
  assert myTest.get_id() == 1
51
- print("done, test_mpi_ProcessClass")
52
77
 
53
78
 
54
- def mpitest_mpi_H2LibProcess():
79
+ @mpirun
80
+ def test_mpi_H2LibProcess():
81
+ mpi_interface.activate_mpi()
55
82
  with H2LibProcess(suppress_output=False) as h2:
56
83
  assert h2lib.__version__.replace("+", "-").startswith(h2.get_version().strip()
57
84
  ), (h2.get_version().strip(), h2lib.__version__)
58
- print("done, test_mpi_H2LibProcess")
59
85
 
60
86
 
61
- def mpitest_MultiH2Lib():
62
- with MultiH2Lib(3) as mh2:
87
+ @mpirun
88
+ def test_MultiH2Lib():
89
+ mpi_interface.activate_mpi()
90
+ with MultiH2Lib(3, suppress_output=1) as mh2:
63
91
  assert all([h2lib.__version__.replace("+", "-").startswith(v.strip()) for v in mh2.get_version()])
64
92
  assert len(mh2.get_version()) == 3
65
93
  if mpi_interface.size > 1:
@@ -93,93 +121,72 @@ def mpitest_MultiH2Lib():
93
121
  with pytest.raises(Exception, match='Cannot close SubsetMPIClassInterface. Please close all instances at once'):
94
122
  mh2[:2].close()
95
123
  with pytest.raises(Exception, match='Cannot make subset of SubsetMPIClassInterface'):
96
- print(mh2[:2][1].getState())
97
- print('done, test_MPIH2Lib')
124
+ mh2[:2][1].getState()
98
125
 
99
126
 
100
- def ellipsys_mpi_dummy_workflow():
101
- from multiclass_interface import mpi_interface
127
+ def get_htc_lst(N=4):
128
+ htc = HTCFile(tfp + 'DTU_10_MW/htc/DTU_10MW_RWT_no_aerodrag.htc')
129
+ for i in range(N):
130
+ htc.set_name(f'wt{i}')
131
+ htc.save()
132
+ return [f'htc/wt{i}.htc' for i in range(N)]
133
+
134
+
135
+ @mpirun
136
+ def test_ellipsys_mpi_dummy_workflow():
137
+ mpi_interface.activate_mpi(collective_mpi=False)
102
138
  from h2lib_tests.test_ellipsys_couplings import Ellipsys
103
- from wetb.hawc2.htc_file import HTCFile
104
139
  from numpy import newaxis as na
105
- mpi_interface.LOOP_UNTIL_CLOSE = False
106
-
107
140
  rank = mpi_interface.rank
108
141
 
109
142
  N = 4
110
143
 
111
- with MultiH2Lib(N, suppress_output=True) as h2:
144
+ with MultiH2Lib(N, suppress_output=1) as h2:
112
145
  el = Ellipsys()
113
- htc = HTCFile(tfp + 'DTU_10_MW/htc/DTU_10MW_RWT_no_aerodrag.htc')
114
- for i in range(N):
115
- htc.set_name(f'wt{i}')
116
- htc.save()
117
- h2.read_input(htc_path=[f'htc/wt{i}.htc' for i in range(N)],
146
+ h2.read_input(htc_path=get_htc_lst(),
118
147
  model_path=tfp + 'DTU_10_MW')
119
148
  wt_pos = np.array([[0, 0, 0], [0, 500, 0], [0, 1000, 0], [0, 1500, 0]])
120
- h2.init()
121
-
149
+ h2.init_AD()
122
150
  t = 0
123
151
  while True:
124
152
  t = el.step()
125
153
  h2.run(t)
126
- pos_gl_xyz = np.array(h2.get_aerosections_position(), order='F') + wt_pos[:, na, na, :]
127
-
128
- if rank == 0:
129
- assert pos_gl_xyz.shape == (4, 3, 50, 3), pos_gl_xyz.shape # wt, blades, aero_sections, xyz
130
- uvw = np.asfortranarray(el.get_uvw(pos_gl_xyz))
131
- else:
132
- uvw = None
154
+ pos_gl_xyz = np.array(h2.get_aerosections_position(), order='F') + wt_pos[[rank], na, na, :]
155
+ assert pos_gl_xyz.shape == (1, 3, 50, 3), pos_gl_xyz.shape # 1(current wt), blades, aero_sections, xyz
156
+ uvw = np.asfortranarray(el.get_uvw(pos_gl_xyz))
133
157
  h2.set_aerosections_windspeed(uvw)
134
158
  frc_gl_xyz = h2.get_aerosections_forces()
135
- if rank == 0:
136
- el.set_fxyz(pos_gl_xyz, frc_gl_xyz)
159
+ assert np.shape(frc_gl_xyz) == (1, 3, 50, 3)
160
+ el.set_fxyz(pos_gl_xyz, frc_gl_xyz)
137
161
  if t == 1:
138
162
  break
139
163
 
140
- mpi_interface.LOOP_UNTIL_CLOSE = True
141
164
 
142
-
143
- def mpitest_all():
165
+ @mpirun
166
+ def test_ellipsys_mpi_dummy_workflow_collective():
144
167
  mpi_interface.activate_mpi()
145
- mpi_interface.exit_mpi_on_close = False
168
+ from h2lib_tests.test_ellipsys_couplings import Ellipsys
169
+ from numpy import newaxis as na
146
170
  rank = mpi_interface.rank
147
- from h2lib_tests.test_ellipsys_couplings import test_ellipsys_dummy_workflow
148
- from h2lib_tests.test_h2lib import test_parallel_context_manager, test_parallel
149
- from h2lib_tests.test_h2rotor import test_rotor_orientation_multi_instance
150
- from h2lib_tests.test_multiprocessinterface import test_attribute, test_missing_attribute, test_execption, test_setattr, test_setattr_method
151
- mpi_interface.TERMINATE_ON_CLOSE = False
152
-
153
- def run(f, *args):
154
- try:
155
- if rank == 0:
156
- print(f"Rank {rank} start {f.__name__}", flush=True)
157
- f(*args)
158
- except ChildProcessError:
159
- pass
160
- finally:
161
- if rank == 0:
162
- print(f"Rank {rank} done {f.__name__}", flush=True)
163
- for f in [mpitest_mpi_MyTest,
164
- mpitest_mpi_ProcessClass, mpitest_mpi_H2LibProcess,
165
- mpitest_MultiH2Lib,
166
-
167
- test_parallel,
168
- test_parallel_context_manager,
169
- test_rotor_orientation_multi_instance,
170
- ellipsys_mpi_dummy_workflow,
171
-
172
- ]:
173
- run(f)
174
-
175
- try:
176
- with MPIClassInterface(MyTest, [(1,), (2,)]) as mpici:
177
- for f in [test_attribute, test_missing_attribute, test_execption, test_setattr, test_setattr_method]:
178
- break
179
- run(f, mpici)
171
+ N = 4
180
172
 
181
- except ChildProcessError:
182
- pass
183
- mpi_interface.TERMINATE_ON_CLOSE = True
184
- test_ellipsys_dummy_workflow()
185
- print(f"Rank {rank} Done test_all")
173
+ with MultiH2Lib(N, suppress_output=1) as h2:
174
+ with h2.release_mpi_workers():
175
+ el = Ellipsys()
176
+ h2.read_input(htc_path=get_htc_lst(),
177
+ model_path=tfp + 'DTU_10_MW')
178
+ wt_pos = np.array([[0, 0, 0], [0, 500, 0], [0, 1000, 0], [0, 1500, 0]])
179
+ h2.init_AD()
180
+ t = 0
181
+ while True:
182
+ t = el.step()
183
+ h2.run(t)
184
+ pos_gl_xyz = np.array(h2.get_aerosections_position(), order='F') + wt_pos[[rank], na, na, :]
185
+ assert pos_gl_xyz.shape == (1, 3, 50, 3), pos_gl_xyz.shape # 1(current wt), blades, aero_sections, xyz
186
+ uvw = np.asfortranarray(el.get_uvw(pos_gl_xyz))
187
+ h2.set_aerosections_windspeed(uvw)
188
+ frc_gl_xyz = h2.get_aerosections_forces()
189
+ assert np.shape(frc_gl_xyz) == (1, 3, 50, 3)
190
+ el.set_fxyz(pos_gl_xyz, frc_gl_xyz)
191
+ if t == 1:
192
+ break
@@ -70,8 +70,7 @@ def test_static_solver_run_1(h2_dtu_10mw_only_blade):
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.072139e+04, -3.856623e-02, -3.949042e+01]),
74
- rtol=1e-6
73
+ val, np.array([-1.072136e04, -3.978756e-02, -4.066154e01]), rtol=1e-6
75
74
  )
76
75
 
77
76
 
@@ -89,7 +88,7 @@ def test_static_solver_run_2(h2_dtu_10mw_only_blade_rotate_base):
89
88
  h2_dtu_10mw_only_blade_rotate_base.step()
90
89
  val = h2_dtu_10mw_only_blade_rotate_base.get_sensor_values(id)
91
90
  # Test against: result at the time of writing.
92
- npt.assert_allclose(val, np.array([10879.120647, 383.441758, 989.673212]))
91
+ npt.assert_allclose(val, np.array([10879.057846, 383.58397, 991.216685]))
93
92
 
94
93
 
95
94
  def test_static_solver_run_3(h2_dtu_10mw_only_blade_rotate_relative):
@@ -100,15 +99,13 @@ def test_static_solver_run_3(h2_dtu_10mw_only_blade_rotate_relative):
100
99
  )
101
100
 
102
101
  # Run the static solver.
103
- h2_dtu_10mw_only_blade_rotate_relative.solver_static_run(
104
- reset_structure=True
105
- )
102
+ h2_dtu_10mw_only_blade_rotate_relative.solver_static_run(reset_structure=True)
106
103
 
107
104
  # Do 1 step to get the output.
108
105
  h2_dtu_10mw_only_blade_rotate_relative.step()
109
106
  val = h2_dtu_10mw_only_blade_rotate_relative.get_sensor_values(id)
110
107
  # Test against: result at the time of writing.
111
- npt.assert_allclose(val, np.array([10879.074041, 383.440111, 989.67438]))
108
+ npt.assert_allclose(val, np.array([10879.011239, 383.582323, 991.217846]))
112
109
 
113
110
 
114
111
  def test_static_solver_run_4(h2_dtu_10mw_only_blade_rotate_bearing3):
@@ -119,17 +116,13 @@ def test_static_solver_run_4(h2_dtu_10mw_only_blade_rotate_bearing3):
119
116
  )
120
117
 
121
118
  # Run the static solver.
122
- h2_dtu_10mw_only_blade_rotate_bearing3.solver_static_run(
123
- reset_structure=True
124
- )
119
+ h2_dtu_10mw_only_blade_rotate_bearing3.solver_static_run(reset_structure=True)
125
120
 
126
121
  # Do 1 step to get the output.
127
122
  h2_dtu_10mw_only_blade_rotate_bearing3.step()
128
123
  val = h2_dtu_10mw_only_blade_rotate_bearing3.get_sensor_values(id)
129
124
  # Test against: result at the time of writing.
130
- npt.assert_allclose(
131
- val, np.array([-3094.986918, 115414.095937, 325.296806])
132
- )
125
+ npt.assert_allclose(val, np.array([-3097.095312, 115414.360165, 366.321024]))
133
126
 
134
127
 
135
128
  def test_static_solver_run_no_reset(h2_dtu_10mw_only_blade):
@@ -191,9 +184,7 @@ def test_structure_reset():
191
184
  # The deflection must have changed.
192
185
  h2.step()
193
186
  val_actual = h2.get_sensor_values(id)
194
- npt.assert_raises(
195
- AssertionError, npt.assert_allclose, val_actual, val_desired
196
- )
187
+ npt.assert_raises(AssertionError, npt.assert_allclose, val_actual, val_desired)
197
188
 
198
189
  # Reset the structure and check that we match the reference.
199
190
  h2.structure_reset()
@@ -39,9 +39,7 @@ def test_get_timoshenko_location(
39
39
  h2_dtu_10mw_only_tower,
40
40
  ):
41
41
  # Test first element.
42
- l, r1, r12, tes = h2_dtu_10mw_only_tower.get_timoshenko_location(
43
- ibdy=0, ielem=0
44
- )
42
+ l, r1, r12, tes = h2_dtu_10mw_only_tower.get_timoshenko_location(ibdy=0, ielem=0)
45
43
  assert l - 11.5 < 1e-14
46
44
  npt.assert_array_equal(r1, np.array([0.0, 0.0, 0]))
47
45
  npt.assert_array_almost_equal_nulp(r12, np.array([0.0, 0.0, -11.5]))
@@ -51,14 +49,10 @@ def test_get_timoshenko_location(
51
49
  )
52
50
 
53
51
  # Test last element.
54
- l, r1, r12, tes = h2_dtu_10mw_only_tower.get_timoshenko_location(
55
- ibdy=2, ielem=3
56
- )
52
+ l, r1, r12, tes = h2_dtu_10mw_only_tower.get_timoshenko_location(ibdy=2, ielem=3)
57
53
  assert l - 12.13 < 1e-14
58
54
  npt.assert_array_almost_equal_nulp(r1, np.array([0.0, 0.0, -34.5]))
59
- npt.assert_array_almost_equal_nulp(
60
- r12, np.array([0.0, 0.0, -12.13]), nulp=3
61
- )
55
+ npt.assert_array_almost_equal_nulp(r12, np.array([0.0, 0.0, -12.13]), nulp=3)
62
56
  npt.assert_array_equal(
63
57
  tes,
64
58
  np.array([[-1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, -1.0]]),
@@ -83,9 +77,7 @@ def test_get_timoshenko_location_encrypted(
83
77
  h2_dtu_10mw_only_tower_encrypted,
84
78
  ):
85
79
  with pytest.raises(RuntimeError, match="STRUCTURE_IS_CONFIDENTIAL"):
86
- h2_dtu_10mw_only_tower_encrypted.get_timoshenko_location(
87
- ibdy=0, ielem=0
88
- )
80
+ h2_dtu_10mw_only_tower_encrypted.get_timoshenko_location(ibdy=0, ielem=0)
89
81
 
90
82
 
91
83
  def test_get_body_rotation_tensor_1(h2_dtu_10mw_only_tower):
@@ -121,17 +113,13 @@ def test_set_orientation_base_not_found(h2_dtu_10mw_only_tower):
121
113
  h2_dtu_10mw_only_tower.set_orientation_base(main_body="blade")
122
114
 
123
115
 
124
- def test_set_orientation_base_1(
125
- h2_dtu_10mw_only_tower, h2_dtu_10mw_only_tower_rotated
126
- ):
116
+ def test_set_orientation_base_1(h2_dtu_10mw_only_tower, h2_dtu_10mw_only_tower_rotated):
127
117
  # Start from h2_dtu_10mw_only_tower and rotate the base.
128
118
  # See if it matches h2_dtu_10mw_only_tower_rotated.
129
119
  h2_dtu_10mw_only_tower.set_orientation_base(
130
120
  main_body="tower", mbdy_eulerang_table=np.array([30.0, 0.0, 0.0])
131
121
  )
132
- amat_desired = h2_dtu_10mw_only_tower_rotated.get_body_rotation_tensor(
133
- ibdy=0
134
- )
122
+ amat_desired = h2_dtu_10mw_only_tower_rotated.get_body_rotation_tensor(ibdy=0)
135
123
  amat_actual = h2_dtu_10mw_only_tower.get_body_rotation_tensor(ibdy=0)
136
124
  npt.assert_array_almost_equal_nulp(amat_actual, amat_desired)
137
125
  # Reset orientation.
@@ -144,9 +132,7 @@ def test_set_orientation_base_with_reset_orientation(
144
132
  h2_dtu_10mw_only_tower_rotated.set_orientation_base(
145
133
  main_body="tower", reset_orientation=True
146
134
  )
147
- amat_actual = h2_dtu_10mw_only_tower_rotated.get_body_rotation_tensor(
148
- ibdy=0
149
- )
135
+ amat_actual = h2_dtu_10mw_only_tower_rotated.get_body_rotation_tensor(ibdy=0)
150
136
  npt.assert_array_almost_equal_nulp(amat_actual, np.eye(3))
151
137
  # Reset orientation.
152
138
  h2_dtu_10mw_only_tower_rotated.set_orientation_base(
@@ -162,9 +148,7 @@ def test_set_orientation_base_without_reset_orientation(
162
148
  mbdy_eulerang_table=np.array([-30.0, 0.0, 0.0]),
163
149
  reset_orientation=False,
164
150
  )
165
- amat_actual = h2_dtu_10mw_only_tower_rotated.get_body_rotation_tensor(
166
- ibdy=0
167
- )
151
+ amat_actual = h2_dtu_10mw_only_tower_rotated.get_body_rotation_tensor(ibdy=0)
168
152
  npt.assert_array_almost_equal_nulp(amat_actual, np.eye(3))
169
153
  # Reset orientation.
170
154
  h2_dtu_10mw_only_tower_rotated.set_orientation_base(
@@ -191,7 +175,7 @@ def test_set_orientation_base_speed(h2_dtu_10mw_only_blade):
191
175
 
192
176
  # Test against: result at the time of writing.
193
177
  # 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]))
178
+ npt.assert_allclose(val, np.array([10879.363636, 793.815211, 1034.923463]))
195
179
 
196
180
  # Reset speed.
197
181
  h2_dtu_10mw_only_blade.set_orientation_base(
@@ -232,12 +216,12 @@ def test_set_orientation_relative_reset(
232
216
  reset_orientation=True,
233
217
  )
234
218
  # Get orientation of blade root.
235
- amat_actual = (
236
- h2_dtu_10mw_only_blade_rotate_relative.get_body_rotation_tensor(ibdy=1)
219
+ amat_actual = h2_dtu_10mw_only_blade_rotate_relative.get_body_rotation_tensor(
220
+ ibdy=1
237
221
  )
238
222
  # It must be the same as the hub.
239
- amat_desired = (
240
- h2_dtu_10mw_only_blade_rotate_relative.get_body_rotation_tensor(ibdy=0)
223
+ amat_desired = h2_dtu_10mw_only_blade_rotate_relative.get_body_rotation_tensor(
224
+ ibdy=0
241
225
  )
242
226
  npt.assert_array_almost_equal_nulp(amat_actual, amat_desired)
243
227
  # This matches a rotation around x by 180 deg.
@@ -263,8 +247,8 @@ def test_set_orientation_relative_2(
263
247
  h2_dtu_10mw_only_blade_rotate_relative,
264
248
  ):
265
249
  # Get orientation of blade root.
266
- amat_desired = (
267
- h2_dtu_10mw_only_blade_rotate_relative.get_body_rotation_tensor(ibdy=1)
250
+ amat_desired = h2_dtu_10mw_only_blade_rotate_relative.get_body_rotation_tensor(
251
+ ibdy=1
268
252
  )
269
253
  # Change orientation a few times.
270
254
  rng = np.random.default_rng(seed=123)
@@ -288,8 +272,8 @@ def test_set_orientation_relative_2(
288
272
  mbdy2_ini_rotvec_d1=np.array([0.0, 1.0, 0.0, 1.0]),
289
273
  )
290
274
  # Check.
291
- amat_actual = (
292
- h2_dtu_10mw_only_blade_rotate_relative.get_body_rotation_tensor(ibdy=1)
275
+ amat_actual = h2_dtu_10mw_only_blade_rotate_relative.get_body_rotation_tensor(
276
+ ibdy=1
293
277
  )
294
278
  npt.assert_array_almost_equal_nulp(amat_actual, amat_desired)
295
279
 
@@ -320,7 +304,7 @@ def test_set_orientation_relative_static(
320
304
  val = h2_dtu_10mw_only_blade_rotate_relative.get_sensor_values(id)
321
305
 
322
306
  # Test against: result at the time of writing.
323
- npt.assert_allclose(val, np.array([8702.239718, 306.617339, 638.840412]))
307
+ npt.assert_allclose(val, np.array([8702.206018, 306.728782, 640.051269]))
324
308
 
325
309
  # Reset to original value.
326
310
  h2_dtu_10mw_only_blade_rotate_relative.set_orientation_relative(
@@ -1,7 +1,7 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: h2lib-tests
3
- Version: 13.1.2601
4
- Summary: Tests and test_files for test h2lib (13.1.26)
3
+ Version: 13.1.3102
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
5
+ h2lib_tests/test_ellipsys_couplings.py,sha256=cAo036WqDkwksCX0EXdUUoJ9mJHjpkUPuIlKLW7GnzY,3284
6
6
  h2lib_tests/test_h2lib.py,sha256=opgVOkZWOD9CrnTDfwRrBaD-weBsNnutm6FeOijDa88,14197
7
- h2lib_tests/test_h2rotor.py,sha256=b3enflMN4l4Hvy3odWLXsZ4-9VBRjVaWUSllBRzXbMM,10838
8
- h2lib_tests/test_lin.py,sha256=FxuDvPuu1MjWE4B7dIWC3qR-9NtjqodGPO1aurUDBwY,6362
9
- h2lib_tests/test_mpi.py,sha256=sDiUMnZ5j-3y7fOpUy5-s624guTejKwlP-NHRZet3iY,6847
7
+ h2lib_tests/test_h2rotor.py,sha256=4P5bUGvwYDl8Z9hVNP_SXKa79DWhsA-ptpp0v0rT9ow,11309
8
+ h2lib_tests/test_lin.py,sha256=KujYIy9YXTo-uxi_umRWIWZwcHu0oH8GyeVgMcMCq0o,6383
9
+ h2lib_tests/test_mpi.py,sha256=8bMeukbWboijMgWLJIIu3Pn0QtaDadOGhhL099MfMls,6990
10
10
  h2lib_tests/test_multiprocessinterface.py,sha256=h2o4havtK6IuMXsplNjGUa3VxOnbpEYGxdrrAKQilj0,1470
11
- h2lib_tests/test_static_solver.py,sha256=mGapb1vwSoe0Uqpc3-xjDegqauf2R_XMHshnvVojwmY,7509
12
- h2lib_tests/test_topology_h2lib.py,sha256=dCwvfgO1eHb53PCXwm-nr6iwKdsviU2tuAnU0WIrsJc,11645
11
+ h2lib_tests/test_static_solver.py,sha256=ckzcBAuVge5V5tdrac4PPYxrH5TheNTUc3PKksbB89A,7426
12
+ h2lib_tests/test_topology_h2lib.py,sha256=VjJ1SUBHRHwuSn0EPI6KGzwAULZbPzA39rXdDGXyxkk,11510
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.2601.dist-info/METADATA,sha256=k-4FO0odue2--QCwk0naVXRxBtySjpp3PRP-SvoNWYI,408
93
- h2lib_tests-13.1.2601.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
94
- h2lib_tests-13.1.2601.dist-info/top_level.txt,sha256=WufAL3LO35YJBhWg1AfgTjSld-6l_WuRkXAkNKczUrM,12
95
- h2lib_tests-13.1.2601.dist-info/RECORD,,
92
+ h2lib_tests-13.1.3102.dist-info/METADATA,sha256=FgPhvGVItQe7EYP_eXjmrMXOnxfT3yXxTI4ALJgN99I,419
93
+ h2lib_tests-13.1.3102.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
94
+ h2lib_tests-13.1.3102.dist-info/top_level.txt,sha256=WufAL3LO35YJBhWg1AfgTjSld-6l_WuRkXAkNKczUrM,12
95
+ h2lib_tests-13.1.3102.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (78.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5