h2lib-tests 13.1.505__py3-none-any.whl → 13.1.506__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_static_solver.py +98 -0
- h2lib_tests/test_write_htc.py +67 -0
- {h2lib_tests-13.1.505.dist-info → h2lib_tests-13.1.506.dist-info}/METADATA +2 -2
- {h2lib_tests-13.1.505.dist-info → h2lib_tests-13.1.506.dist-info}/RECORD +6 -6
- h2lib_tests/test_static_solver_wrapper.py +0 -20
- {h2lib_tests-13.1.505.dist-info → h2lib_tests-13.1.506.dist-info}/WHEEL +0 -0
- {h2lib_tests-13.1.505.dist-info → h2lib_tests-13.1.506.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,98 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
Test the static solver.
|
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
|
+
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
|
+
|
47
|
+
def test_solver_static_update_no_init(h2_dtu_10mw_only_blade):
|
48
|
+
with pytest.raises(RuntimeError, match="STATIC_SOLVER_NOT_INITIALIZED"):
|
49
|
+
h2_dtu_10mw_only_blade.solver_static_update()
|
50
|
+
|
51
|
+
|
52
|
+
def test_solver_static_solve_no_init(h2_dtu_10mw_only_blade):
|
53
|
+
with pytest.raises(RuntimeError, match="STATIC_SOLVER_NOT_INITIALIZED"):
|
54
|
+
h2_dtu_10mw_only_blade.solver_static_solve()
|
55
|
+
|
56
|
+
|
57
|
+
def test_solver_static_init(h2_dtu_10mw_only_blade):
|
58
|
+
|
59
|
+
# First execution is fine.
|
60
|
+
h2_dtu_10mw_only_blade.solver_static_init()
|
61
|
+
|
62
|
+
# The next should automatically deallocate the static solver and initialize it again.
|
63
|
+
h2_dtu_10mw_only_blade.solver_static_init()
|
64
|
+
|
65
|
+
|
66
|
+
def test_solver_static_update(h2_dtu_10mw_only_blade):
|
67
|
+
# This should happen after test_solver_static_init().
|
68
|
+
h2_dtu_10mw_only_blade.solver_static_update()
|
69
|
+
|
70
|
+
|
71
|
+
def test_solver_static_solve(h2_dtu_10mw_only_blade):
|
72
|
+
# This should happen after test_solver_static_update().
|
73
|
+
h2_dtu_10mw_only_blade.solver_static_solve()
|
74
|
+
|
75
|
+
|
76
|
+
def test_solver_static_delete(h2_dtu_10mw_only_blade):
|
77
|
+
h2_dtu_10mw_only_blade.solver_static_delete()
|
78
|
+
|
79
|
+
|
80
|
+
def test_static_solver_run(h2_dtu_10mw_only_blade):
|
81
|
+
# Add a sensor for the blade root moment, in this case only due to gravity.
|
82
|
+
id = h2_dtu_10mw_only_blade.add_sensor("mbdy momentvec blade1 1 1 blade1")
|
83
|
+
|
84
|
+
# Run the static solver.
|
85
|
+
h2_dtu_10mw_only_blade.solver_static_run()
|
86
|
+
|
87
|
+
# Do 1 step to get the output.
|
88
|
+
h2_dtu_10mw_only_blade.step()
|
89
|
+
val = h2_dtu_10mw_only_blade.get_sensor_values(id)
|
90
|
+
# Test against: initial_condition 2; followed by time simulaiton.
|
91
|
+
npt.assert_allclose(
|
92
|
+
val, np.array([-1.07213851e04, -4.55385871e-02, -3.94623708e01])
|
93
|
+
)
|
94
|
+
|
95
|
+
|
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()
|
h2lib_tests/test_write_htc.py
CHANGED
@@ -57,3 +57,70 @@ def write_dtu10mw_only_tower_encrypted(write_dtu10mw_only_tower):
|
|
57
57
|
# Only the tower is left.
|
58
58
|
htc.new_htc_structure.main_body.timoschenko_input.filename = "./data/DTU_10MW_RWT_Tower_st.dat.v3.enc"
|
59
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
|
@@ -6,9 +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/
|
9
|
+
h2lib_tests/test_static_solver.py,sha256=Ik_CgGiFVibEPq0dGzSfSYH3gv_dTm-qcz6JKmJiH_A,3228
|
10
10
|
h2lib_tests/test_topology_h2lib.py,sha256=cClNtAIc1wR_gZa7eDO4ZySvhScqCEIHVMKZEhk29QE,4980
|
11
|
-
h2lib_tests/test_write_htc.py,sha256=
|
11
|
+
h2lib_tests/test_write_htc.py,sha256=3KMHffkR8A6C1RXODxq_O522fEBfJwp3YpjDmUmiNjU,4774
|
12
12
|
h2lib_tests/test_files/__init__.py,sha256=9e6ZUPb42e0wf2E1rutdcTM8hROcWFRVPXtZriU3ySw,50
|
13
13
|
h2lib_tests/test_files/my_test_cls.py,sha256=7ZDsFkxrLfOY6q00U5Y-daxfuhATK-K5H04RP-VmQdE,850
|
14
14
|
h2lib_tests/test_files/DTU_10_MW/control/dtu_we_controller.dll,sha256=C5T_CuAFtIuDgCXSYAoNu24yKPwj2nWOeORacJbLN9s,1134592
|
@@ -87,7 +87,7 @@ h2lib_tests/test_files/minimal/res/minimal_mann_turb.hdf5,sha256=Q3cs3bZyplZjBpo
|
|
87
87
|
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
88
|
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
89
|
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.
|
91
|
-
h2lib_tests-13.1.
|
92
|
-
h2lib_tests-13.1.
|
93
|
-
h2lib_tests-13.1.
|
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,,
|
@@ -1,20 +0,0 @@
|
|
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()
|
File without changes
|
File without changes
|