h2lib-tests 13.1.303__py3-none-any.whl → 13.1.501__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- h2lib_tests/test_files/DTU_10_MW/data/DTU_10MW_RWT_Tower_st.dat.v3.enc +0 -0
- h2lib_tests/test_static_solver_wrapper.py +20 -0
- h2lib_tests/test_topology_h2lib.py +143 -0
- h2lib_tests/test_write_htc.py +59 -0
- {h2lib_tests-13.1.303.dist-info → h2lib_tests-13.1.501.dist-info}/METADATA +2 -2
- {h2lib_tests-13.1.303.dist-info → h2lib_tests-13.1.501.dist-info}/RECORD +8 -4
- {h2lib_tests-13.1.303.dist-info → h2lib_tests-13.1.501.dist-info}/WHEEL +1 -1
- {h2lib_tests-13.1.303.dist-info → h2lib_tests-13.1.501.dist-info}/top_level.txt +0 -0
Binary file
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import pytest
|
2
|
+
|
3
|
+
from h2lib._h2lib import H2Lib
|
4
|
+
from h2lib_tests.test_files import tfp
|
5
|
+
|
6
|
+
from .test_write_htc import write_dtu10mw_only_tower
|
7
|
+
|
8
|
+
|
9
|
+
def test_init_static_solver(write_dtu10mw_only_tower):
|
10
|
+
with H2Lib() as h2:
|
11
|
+
# Load a basic model.
|
12
|
+
model_path = tfp + "DTU_10_MW/"
|
13
|
+
h2.init("htc/DTU_10MW_RWT_only_tower.htc", model_path)
|
14
|
+
|
15
|
+
# First execution is fine.
|
16
|
+
h2.init_static_solver()
|
17
|
+
|
18
|
+
# The next should give an error.
|
19
|
+
with pytest.raises(RuntimeError, match="STATIC_SOLVER_ALREADY_INITIALIZED"):
|
20
|
+
h2.init_static_solver()
|
@@ -0,0 +1,143 @@
|
|
1
|
+
from h2lib._h2lib import H2Lib
|
2
|
+
|
3
|
+
from numpy import testing as npt
|
4
|
+
from h2lib_tests.test_files import tfp
|
5
|
+
import numpy as np
|
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
|
+
|
43
|
+
|
44
|
+
def test_number_of_bodies_and_constraints(
|
45
|
+
h2_dtu_10mw_only_tower,
|
46
|
+
):
|
47
|
+
nbdy, ncst = h2_dtu_10mw_only_tower.get_number_of_bodies_and_constraints()
|
48
|
+
assert nbdy == 3
|
49
|
+
assert ncst == 9
|
50
|
+
|
51
|
+
|
52
|
+
def test_number_of_bodies_and_constraints_encrypted(
|
53
|
+
h2_dtu_10mw_only_tower_encrypted,
|
54
|
+
):
|
55
|
+
with pytest.raises(RuntimeError, match="STRUCTURE_IS_CONFIDENTIAL"):
|
56
|
+
h2_dtu_10mw_only_tower_encrypted.get_number_of_bodies_and_constraints()
|
57
|
+
|
58
|
+
|
59
|
+
def test_get_number_of_elements(h2_dtu_10mw_only_tower):
|
60
|
+
nelem = h2_dtu_10mw_only_tower.get_number_of_elements()
|
61
|
+
npt.assert_array_equal(nelem, np.array([3, 3, 4]))
|
62
|
+
|
63
|
+
|
64
|
+
def test_get_number_of_elements_encrypted(
|
65
|
+
h2_dtu_10mw_only_tower_encrypted,
|
66
|
+
):
|
67
|
+
# This test is not really needed, since the check for confidential structure
|
68
|
+
# is already done by test_number_of_bodies_and_constraints_encrypted().
|
69
|
+
with pytest.raises(RuntimeError, match="STRUCTURE_IS_CONFIDENTIAL"):
|
70
|
+
h2_dtu_10mw_only_tower_encrypted.get_number_of_elements()
|
71
|
+
|
72
|
+
|
73
|
+
def test_get_timoshenko_location(
|
74
|
+
h2_dtu_10mw_only_tower,
|
75
|
+
):
|
76
|
+
# Test first element.
|
77
|
+
l, r1, r12, tes = h2_dtu_10mw_only_tower.get_timoshenko_location(ibdy=0, ielem=0)
|
78
|
+
assert l - 11.5 < 1e-14
|
79
|
+
npt.assert_array_equal(r1, np.array([0.0, 0.0, 0]))
|
80
|
+
npt.assert_array_almost_equal_nulp(r12, np.array([0.0, 0.0, -11.5]))
|
81
|
+
npt.assert_array_equal(
|
82
|
+
tes,
|
83
|
+
np.array([[-1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, -1.0]]),
|
84
|
+
)
|
85
|
+
|
86
|
+
# Test last element.
|
87
|
+
l, r1, r12, tes = h2_dtu_10mw_only_tower.get_timoshenko_location(ibdy=2, ielem=3)
|
88
|
+
assert l - 12.13 < 1e-14
|
89
|
+
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)
|
91
|
+
npt.assert_array_equal(
|
92
|
+
tes,
|
93
|
+
np.array([[-1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, -1.0]]),
|
94
|
+
)
|
95
|
+
|
96
|
+
|
97
|
+
def test_get_timoshenko_location_body_does_not_exist(
|
98
|
+
h2_dtu_10mw_only_tower,
|
99
|
+
):
|
100
|
+
with pytest.raises(IndexError, match="BODY_DOES_NOT_EXIST"):
|
101
|
+
h2_dtu_10mw_only_tower.get_timoshenko_location(ibdy=1000, ielem=0)
|
102
|
+
|
103
|
+
|
104
|
+
def test_get_timoshenko_location_element_does_not_exist(
|
105
|
+
h2_dtu_10mw_only_tower,
|
106
|
+
):
|
107
|
+
with pytest.raises(IndexError, match="ELEMENT_DOES_NOT_EXIST"):
|
108
|
+
h2_dtu_10mw_only_tower.get_timoshenko_location(ibdy=0, ielem=1000)
|
109
|
+
|
110
|
+
|
111
|
+
def test_get_timoshenko_location_encrypted(
|
112
|
+
h2_dtu_10mw_only_tower_encrypted,
|
113
|
+
):
|
114
|
+
with pytest.raises(RuntimeError, match="STRUCTURE_IS_CONFIDENTIAL"):
|
115
|
+
h2_dtu_10mw_only_tower_encrypted.get_timoshenko_location(ibdy=0, ielem=0)
|
116
|
+
|
117
|
+
|
118
|
+
def test_get_body_rotation_tensor_1(h2_dtu_10mw_only_tower):
|
119
|
+
amat = h2_dtu_10mw_only_tower.get_body_rotation_tensor(ibdy=0)
|
120
|
+
npt.assert_array_equal(amat, np.eye(3))
|
121
|
+
|
122
|
+
|
123
|
+
def test_get_body_rotation_tensor_2(
|
124
|
+
h2_dtu_10mw_only_tower_rotated, write_dtu10mw_only_tower_rotated
|
125
|
+
):
|
126
|
+
amat = h2_dtu_10mw_only_tower_rotated.get_body_rotation_tensor(ibdy=0)
|
127
|
+
_, alpha = write_dtu10mw_only_tower_rotated
|
128
|
+
alpha_rad = np.deg2rad(alpha)
|
129
|
+
sa = np.sin(alpha_rad)
|
130
|
+
ca = np.cos(alpha_rad)
|
131
|
+
npt.assert_array_almost_equal_nulp(
|
132
|
+
amat, np.array([[1.0, 0.0, 0.0], [0.0, ca, -sa], [0.0, sa, ca]])
|
133
|
+
)
|
134
|
+
|
135
|
+
|
136
|
+
def test_get_body_rotation_tensor_body_does_not_exist(h2_dtu_10mw_only_tower):
|
137
|
+
with pytest.raises(IndexError, match="BODY_DOES_NOT_EXIST"):
|
138
|
+
h2_dtu_10mw_only_tower.get_body_rotation_tensor(ibdy=1000)
|
139
|
+
|
140
|
+
|
141
|
+
def test_get_body_rotation_tensor_encrypted(h2_dtu_10mw_only_tower_encrypted):
|
142
|
+
with pytest.raises(RuntimeError, match="STRUCTURE_IS_CONFIDENTIAL"):
|
143
|
+
h2_dtu_10mw_only_tower_encrypted.get_body_rotation_tensor(ibdy=0)
|
@@ -0,0 +1,59 @@
|
|
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()
|
@@ -6,6 +6,9 @@ h2lib_tests/test_h2lib.py,sha256=ZKp8pfQQpCUQ7IBXypTmvewbJwTQowSiCEt6t4R9TgY,133
|
|
6
6
|
h2lib_tests/test_h2rotor.py,sha256=kaE9AFDYSPaMFSgBAbeegd7-l6Z_4_BsQaWie0k32q4,6210
|
7
7
|
h2lib_tests/test_mpi.py,sha256=emBgXRAvvFFOsVrAziiQCUZvEF9HS5Wc-x4KqqltQP0,6835
|
8
8
|
h2lib_tests/test_multiprocessinterface.py,sha256=h2o4havtK6IuMXsplNjGUa3VxOnbpEYGxdrrAKQilj0,1470
|
9
|
+
h2lib_tests/test_static_solver_wrapper.py,sha256=xCWDkxtW8K2kD6l6MRgyPS1kz91IpbRA0Cc3BG7o3Es,604
|
10
|
+
h2lib_tests/test_topology_h2lib.py,sha256=cClNtAIc1wR_gZa7eDO4ZySvhScqCEIHVMKZEhk29QE,4980
|
11
|
+
h2lib_tests/test_write_htc.py,sha256=t78STsVoQ2qR5WB-jkYhaMOy0jWHHsDfuO2nfyPj4ag,2242
|
9
12
|
h2lib_tests/test_files/__init__.py,sha256=9e6ZUPb42e0wf2E1rutdcTM8hROcWFRVPXtZriU3ySw,50
|
10
13
|
h2lib_tests/test_files/my_test_cls.py,sha256=7ZDsFkxrLfOY6q00U5Y-daxfuhATK-K5H04RP-VmQdE,850
|
11
14
|
h2lib_tests/test_files/DTU_10_MW/control/dtu_we_controller.dll,sha256=C5T_CuAFtIuDgCXSYAoNu24yKPwj2nWOeORacJbLN9s,1134592
|
@@ -28,6 +31,7 @@ h2lib_tests/test_files/DTU_10_MW/data/DTU_10MW_RWT_Blade_st.dat,sha256=7stkwSf7R
|
|
28
31
|
h2lib_tests/test_files/DTU_10_MW/data/DTU_10MW_RWT_Hub_st.dat,sha256=UPIVkaThyxRsEeMIyjhXIr_n9kr1SAGQYudgj_ofJ04,916
|
29
32
|
h2lib_tests/test_files/DTU_10_MW/data/DTU_10MW_RWT_Shaft_st.dat,sha256=Jz_QA1hJUY6ZG4re1oFj0_7MkXu8az9jn2-WLGb0jY0,905
|
30
33
|
h2lib_tests/test_files/DTU_10_MW/data/DTU_10MW_RWT_Tower_st.dat,sha256=0asFvlyhL1CZltWve-PNGgjfpfdMGRCCwMf3U0K_x_c,8367
|
34
|
+
h2lib_tests/test_files/DTU_10_MW/data/DTU_10MW_RWT_Tower_st.dat.v3.enc,sha256=2MIV4QV0Y5XZ6hHsUdO95pG4b1HVlNWeuIzSM6n-88A,8422
|
31
35
|
h2lib_tests/test_files/DTU_10_MW/data/DTU_10MW_RWT_Towertop_st.dat,sha256=iW8RzjgQe7D3y9DEQMD74e0PWqJ4d7meYGTT6Fsl4D0,955
|
32
36
|
h2lib_tests/test_files/DTU_10_MW/data/DTU_10MW_RWT_ae.dat,sha256=LkAlElRW_Fl1V4GD8hQZIgLD4IW0o3uxXL2olnEU3dI,1531
|
33
37
|
h2lib_tests/test_files/DTU_10_MW/data/DTU_10MW_RWT_pc.dat,sha256=2Nc_ofcqfCB3iu8dSFRj8Ub6AhaQADdW0O8BXBWj5Uk,26888
|
@@ -79,7 +83,7 @@ h2lib_tests/test_files/minimal/res/minimal_mann_turb.hdf5,sha256=Q3cs3bZyplZjBpo
|
|
79
83
|
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
|
80
84
|
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
|
81
85
|
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
|
82
|
-
h2lib_tests-13.1.
|
83
|
-
h2lib_tests-13.1.
|
84
|
-
h2lib_tests-13.1.
|
85
|
-
h2lib_tests-13.1.
|
86
|
+
h2lib_tests-13.1.501.dist-info/METADATA,sha256=-kMUlvOUDYWvd8sU6fjj7n0bG-MWPRHm4Sz4fb4qrcI,360
|
87
|
+
h2lib_tests-13.1.501.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
88
|
+
h2lib_tests-13.1.501.dist-info/top_level.txt,sha256=WufAL3LO35YJBhWg1AfgTjSld-6l_WuRkXAkNKczUrM,12
|
89
|
+
h2lib_tests-13.1.501.dist-info/RECORD,,
|
File without changes
|