h2lib-tests 13.2.702__py3-none-any.whl → 13.2.901__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 +212 -7
- h2lib_tests/test_distributed_sections.py +337 -43
- h2lib_tests/test_h2lib.py +0 -7
- h2lib_tests/test_h2rotor.py +17 -1
- h2lib_tests/test_topology_h2lib.py +422 -32
- {h2lib_tests-13.2.702.dist-info → h2lib_tests-13.2.901.dist-info}/METADATA +3 -2
- {h2lib_tests-13.2.702.dist-info → h2lib_tests-13.2.901.dist-info}/RECORD +9 -9
- {h2lib_tests-13.2.702.dist-info → h2lib_tests-13.2.901.dist-info}/WHEEL +0 -0
- {h2lib_tests-13.2.702.dist-info → h2lib_tests-13.2.901.dist-info}/top_level.txt +0 -0
h2lib_tests/conftest.py
CHANGED
@@ -4,12 +4,15 @@ from wetb.hawc2.htc_file import HTCFile
|
|
4
4
|
from wetb.hawc2.mainbody import MainBody
|
5
5
|
from h2lib_tests.test_files import tfp
|
6
6
|
from h2lib._h2lib import H2Lib
|
7
|
+
from hawc2models import IEA22MW
|
7
8
|
|
8
9
|
|
10
|
+
# %% Write HAWC2 models of the DTU 10 MW.
|
11
|
+
|
9
12
|
@pytest.fixture(scope="session")
|
10
13
|
def write_dtu10mw_only_tower():
|
11
14
|
# Start from DTU_10MW_RWT and delete everything except the tower.
|
12
|
-
htc = HTCFile(tfp
|
15
|
+
htc = HTCFile(f"{tfp}DTU_10_MW/htc/DTU_10MW_RWT.htc")
|
13
16
|
htc.set_name("DTU_10MW_RWT_only_tower")
|
14
17
|
for key1 in htc["new_htc_structure"].keys():
|
15
18
|
if key1.startswith("main_body"):
|
@@ -69,7 +72,7 @@ def write_dtu10mw_only_tower_encrypted(write_dtu10mw_only_tower):
|
|
69
72
|
@pytest.fixture(scope="session")
|
70
73
|
def write_dtu10mw_only_blade():
|
71
74
|
# Start from DTU_10MW_RWT and delete everything except the blade.
|
72
|
-
htc = HTCFile(tfp
|
75
|
+
htc = HTCFile(f"{tfp}DTU_10_MW/htc/DTU_10MW_RWT.htc")
|
73
76
|
htc.set_name("DTU_10MW_RWT_only_blade")
|
74
77
|
for key1 in htc["new_htc_structure"].keys():
|
75
78
|
if key1.startswith("main_body"):
|
@@ -177,7 +180,7 @@ def write_dtu10mw_only_blade_rotate_relative():
|
|
177
180
|
# Start from DTU_10MW_RWT and delete everything except the blade and hub.
|
178
181
|
# The blade now rotates because of the relative rotation.
|
179
182
|
# Because of the fix1 constraint, the blade will not rotate after time 0.
|
180
|
-
htc = HTCFile(tfp
|
183
|
+
htc = HTCFile(f"{tfp}DTU_10_MW/htc/DTU_10MW_RWT.htc")
|
181
184
|
htc.set_name("DTU_10MW_RWT_only_blade_rotate_relative")
|
182
185
|
for key1 in (
|
183
186
|
"main_body", # tower
|
@@ -265,7 +268,7 @@ def write_dtu10mw_only_blade_rotate_relative():
|
|
265
268
|
def write_dtu10mw_only_blade_rotate_bearing3():
|
266
269
|
# Start from DTU_10MW_RWT and delete everything except the blade and hub.
|
267
270
|
# The blade now rotates because of the bearing3 between the blade and hub.
|
268
|
-
htc = HTCFile(tfp
|
271
|
+
htc = HTCFile(f"{tfp}DTU_10_MW/htc/DTU_10MW_RWT.htc")
|
269
272
|
htc.set_name("DTU_10MW_RWT_only_blade_rotate_bearing3")
|
270
273
|
for key1 in (
|
271
274
|
"main_body", # tower
|
@@ -376,11 +379,12 @@ def write_dtu10mw_only_blade_high_gravity(
|
|
376
379
|
htc.new_htc_structure.main_body__7.gravity = 100.0
|
377
380
|
mb = MainBody(htc, "blade1")
|
378
381
|
blade_c2def = mb.c2def
|
382
|
+
blade_st = mb.stFile
|
379
383
|
# Somehow the wind and output blocks are back.
|
380
384
|
htc["wind"].delete()
|
381
385
|
htc["output"].delete()
|
382
386
|
htc.save()
|
383
|
-
return htc, blade_c2def
|
387
|
+
return htc, blade_c2def, blade_st
|
384
388
|
|
385
389
|
|
386
390
|
@pytest.fixture(scope="session")
|
@@ -388,17 +392,18 @@ def write_dtu10mw_only_blade_high_gravity_1_body(
|
|
388
392
|
write_dtu10mw_only_blade_high_gravity,
|
389
393
|
):
|
390
394
|
# Start from the write_dtu10mw_only_blade_high_gravity and then set 1 body.
|
391
|
-
htc_ori, _ = write_dtu10mw_only_blade_high_gravity
|
395
|
+
htc_ori, _, _ = write_dtu10mw_only_blade_high_gravity
|
392
396
|
htc = htc_ori.copy()
|
393
397
|
htc.set_name("DTU_10MW_RWT_only_blade_high_gravity_1_body")
|
394
398
|
htc.new_htc_structure.main_body__7.nbodies = 1
|
395
399
|
mb = MainBody(htc, "blade1")
|
396
400
|
blade_c2def = mb.c2def
|
401
|
+
blade_st = mb.stFile
|
397
402
|
# Somehow the wind and output blocks are back.
|
398
403
|
htc["wind"].delete()
|
399
404
|
htc["output"].delete()
|
400
405
|
htc.save()
|
401
|
-
return htc, blade_c2def
|
406
|
+
return htc, blade_c2def, blade_st
|
402
407
|
|
403
408
|
|
404
409
|
@pytest.fixture(scope="session")
|
@@ -429,6 +434,32 @@ def write_dtu10mw_only_blade_high_gravity_deformed(
|
|
429
434
|
return htc, blade_c2def
|
430
435
|
|
431
436
|
|
437
|
+
@pytest.fixture(scope="session")
|
438
|
+
def write_dtu10mw_only_blade_high_gravity_changed_st(
|
439
|
+
write_dtu10mw_only_blade,
|
440
|
+
):
|
441
|
+
# Start from the write_dtu10mw_only_blade and then increase the gravity loading.
|
442
|
+
htc = write_dtu10mw_only_blade.copy()
|
443
|
+
htc.set_name("DTU_10MW_RWT_only_blade_high_gravity_changed_st")
|
444
|
+
htc.new_htc_structure.main_body__7.gravity = 100.0
|
445
|
+
# Change ST
|
446
|
+
mb = MainBody(htc, "blade1")
|
447
|
+
blade_st = mb.stFile
|
448
|
+
rng = np.random.default_rng(seed=582)
|
449
|
+
factor = rng.uniform(low=0.7, high=1.3, size=19)
|
450
|
+
blade_st.main_data_sets[1][1] *= factor
|
451
|
+
# Current directory is hawc2lib/tests/h2lib_tests
|
452
|
+
blade_st.save(f"{tfp}DTU_10_MW/data/changed_st.dat", precision="%28.16e")
|
453
|
+
htc.new_htc_structure.main_body__7.timoschenko_input.filename = "./data/changed_st.dat"
|
454
|
+
# Somehow the wind and output blocks are back.
|
455
|
+
htc["wind"].delete()
|
456
|
+
htc["output"].delete()
|
457
|
+
htc.save()
|
458
|
+
return htc, blade_st
|
459
|
+
|
460
|
+
|
461
|
+
# %% Create H2Lib objects of the DTU 10 MW.
|
462
|
+
|
432
463
|
@pytest.fixture(scope="session")
|
433
464
|
def h2_dtu_10mw_only_tower(write_dtu10mw_only_tower):
|
434
465
|
h2 = H2Lib(suppress_output=True)
|
@@ -592,3 +623,177 @@ def h2_dtu10mw_only_blade_high_gravity_1_body(write_dtu10mw_only_blade_high_grav
|
|
592
623
|
h2.stop_on_error(False)
|
593
624
|
yield h2
|
594
625
|
h2.close()
|
626
|
+
|
627
|
+
|
628
|
+
@pytest.fixture(scope="session")
|
629
|
+
def h2_dtu10mw_only_blade_high_gravity_changed_st(write_dtu10mw_only_blade_high_gravity_changed_st):
|
630
|
+
h2 = H2Lib(suppress_output=True)
|
631
|
+
model_path = f"{tfp}DTU_10_MW/"
|
632
|
+
htc_path = "htc/DTU_10MW_RWT_only_blade_high_gravity_changed_st.htc"
|
633
|
+
h2.add_sensor("mbdy statevec_new blade1 c2def global absolute 90.0 1.0 0.0 0.0") # 1-6
|
634
|
+
h2.add_sensor("mbdy forcevec blade1 1 1 blade1") # 7, 8, 9
|
635
|
+
h2.add_sensor("mbdy momentvec blade1 1 1 blade1") # 10, 11, 12
|
636
|
+
h2.init(htc_path=htc_path, model_path=model_path)
|
637
|
+
h2.stop_on_error(False)
|
638
|
+
yield h2
|
639
|
+
h2.close()
|
640
|
+
|
641
|
+
|
642
|
+
# %% Write HAWC2 models of the IEA 22 MW.
|
643
|
+
|
644
|
+
@pytest.fixture(scope="session")
|
645
|
+
def write_iea22mw_rwt():
|
646
|
+
# Download HAWC2 model from GitHub repo.
|
647
|
+
htc = IEA22MW(folder=f"{tfp}IEA-22-280-RWT",
|
648
|
+
version="5f9bc425bcbda0723a1245bb4e0c1fc5d5439ed3") # Last commit on master from Aug 26, 2025
|
649
|
+
htc.make_onshore()
|
650
|
+
htc.save()
|
651
|
+
return htc
|
652
|
+
|
653
|
+
|
654
|
+
@pytest.fixture(scope="session")
|
655
|
+
def write_iea22mw_only_blade(write_iea22mw_rwt):
|
656
|
+
# Start from IEA-22-280-RWT and delete everything except the blade.
|
657
|
+
# htc = write_iea22mw_rwt.copy()
|
658
|
+
htc = HTCFile(f"{tfp}IEA-22-280-RWT/htc/iea_22mw_rwt.htc")
|
659
|
+
htc.set_name("IEA_22MW_RWT_only_blade")
|
660
|
+
for key1 in htc["new_htc_structure"].keys():
|
661
|
+
if key1.startswith("main_body"):
|
662
|
+
if "blade1" not in htc["new_htc_structure"][key1]["name"].values:
|
663
|
+
htc["new_htc_structure"][key1].delete()
|
664
|
+
if key1 == "orientation":
|
665
|
+
htc["new_htc_structure"][key1].delete()
|
666
|
+
if key1 == "constraint":
|
667
|
+
htc["new_htc_structure"][key1].delete()
|
668
|
+
htc["wind"].delete()
|
669
|
+
htc["aerodrag"].delete()
|
670
|
+
htc["aero"].delete()
|
671
|
+
htc["dll"].delete()
|
672
|
+
htc["output"].delete()
|
673
|
+
|
674
|
+
# Set the blade horizontal, to maximize gravity loading.
|
675
|
+
htc.new_htc_structure.add_section("orientation")
|
676
|
+
htc.new_htc_structure.orientation.add_section("base")
|
677
|
+
htc.new_htc_structure.orientation.base.mbdy = "blade1"
|
678
|
+
htc.new_htc_structure.orientation.base.inipos = [0.0, 0.0, 0.0]
|
679
|
+
htc.new_htc_structure.orientation.base["mbdy_eulerang"] = [90.0, 0.0, 0.0]
|
680
|
+
htc.new_htc_structure.orientation.base.mbdy_eulerang.comments = (
|
681
|
+
"Blade span is horizontal."
|
682
|
+
)
|
683
|
+
|
684
|
+
# Clamp the blade.
|
685
|
+
htc.new_htc_structure.add_section("constraint")
|
686
|
+
htc.new_htc_structure.constraint.add_section("fix0")
|
687
|
+
htc.new_htc_structure.constraint.fix0.mbdy = "blade1"
|
688
|
+
|
689
|
+
# Set low convergence limits.
|
690
|
+
htc.simulation.convergence_limits = [1e2, 1e-5, 1e-07]
|
691
|
+
|
692
|
+
# No output, as we will use add_sensor().
|
693
|
+
|
694
|
+
# Save the new file.
|
695
|
+
htc.save()
|
696
|
+
|
697
|
+
return htc
|
698
|
+
|
699
|
+
|
700
|
+
@pytest.fixture(scope="session")
|
701
|
+
def write_iea22mw_only_blade_high_gravity(write_iea22mw_only_blade):
|
702
|
+
# Start from the write_iea22mw_only_blade and then increase the gravity loading.
|
703
|
+
htc = write_iea22mw_only_blade.copy()
|
704
|
+
htc.set_name("IEA_22MW_RWT_only_blade_high_gravity")
|
705
|
+
htc.new_htc_structure.main_body__8.gravity = 100.0
|
706
|
+
mb = MainBody(htc, "blade1")
|
707
|
+
blade_c2def = mb.c2def
|
708
|
+
blade_st = mb.stFile
|
709
|
+
# Somehow the wind and output blocks are back.
|
710
|
+
htc["wind"].delete()
|
711
|
+
htc["output"].delete()
|
712
|
+
htc.save()
|
713
|
+
return htc, blade_c2def, blade_st
|
714
|
+
|
715
|
+
|
716
|
+
@pytest.fixture(scope="session")
|
717
|
+
def write_iea22mw_only_blade_high_gravity_1_body(
|
718
|
+
write_iea22mw_only_blade_high_gravity,
|
719
|
+
):
|
720
|
+
# Start from the write_dtu10mw_only_blade_high_gravity and then set 1 body.
|
721
|
+
htc_ori, _, _ = write_iea22mw_only_blade_high_gravity
|
722
|
+
htc = htc_ori.copy()
|
723
|
+
htc.set_name("IEA_22MW_RWT_only_blade_high_gravity_1_body")
|
724
|
+
htc.new_htc_structure.main_body__8.nbodies = 1
|
725
|
+
mb = MainBody(htc, "blade1")
|
726
|
+
blade_c2def = mb.c2def
|
727
|
+
blade_st = mb.stFile
|
728
|
+
# Somehow the wind and output blocks are back.
|
729
|
+
htc["wind"].delete()
|
730
|
+
htc["output"].delete()
|
731
|
+
htc.save()
|
732
|
+
return htc, blade_c2def, blade_st
|
733
|
+
|
734
|
+
|
735
|
+
@pytest.fixture(scope="session")
|
736
|
+
def write_iea22mw_only_blade_high_gravity_changed_st(
|
737
|
+
write_iea22mw_only_blade,
|
738
|
+
):
|
739
|
+
# Start from the write_iea22mw_only_blade and then increase the gravity loading.
|
740
|
+
htc = write_iea22mw_only_blade.copy()
|
741
|
+
htc.set_name("IEA_22MW_RWT_only_blade_high_gravity_changed_st")
|
742
|
+
htc.new_htc_structure.main_body__8.gravity = 100.0
|
743
|
+
# Change ST
|
744
|
+
mb = MainBody(htc, "blade1")
|
745
|
+
blade_st = mb.stFile
|
746
|
+
rng = np.random.default_rng(seed=582)
|
747
|
+
# We change all columns except for the curved length.
|
748
|
+
factor = rng.uniform(low=0.7, high=1.3, size=29)
|
749
|
+
blade_st.main_data_sets[1][1][:, 1:] *= factor
|
750
|
+
# Current directory is hawc2lib/tests/h2lib_tests
|
751
|
+
blade_st.save(f"{tfp}IEA-22-280-RWT/data/changed_st_fpm.dat", precision="%28.16e")
|
752
|
+
htc.new_htc_structure.main_body__8.timoschenko_input.filename = "./data/changed_st_fpm.dat"
|
753
|
+
# Somehow the wind and output blocks are back.
|
754
|
+
htc["wind"].delete()
|
755
|
+
htc["output"].delete()
|
756
|
+
htc.save()
|
757
|
+
return htc, blade_st
|
758
|
+
|
759
|
+
|
760
|
+
# %% Create H2Lib objects of the IEA 22 MW.
|
761
|
+
|
762
|
+
@pytest.fixture(scope="session")
|
763
|
+
def h2_iea22mw_only_blade_high_gravity(write_iea22mw_only_blade_high_gravity):
|
764
|
+
h2 = H2Lib(suppress_output=True)
|
765
|
+
model_path = f"{tfp}IEA-22-280-RWT/"
|
766
|
+
htc_path = "htc/IEA_22MW_RWT_only_blade_high_gravity.htc"
|
767
|
+
h2.add_sensor("mbdy statevec_new blade1 c2def global absolute 90.0 1.0 0.0 0.0") # 1-6
|
768
|
+
h2.add_sensor("mbdy forcevec blade1 1 1 blade1") # 7, 8, 9
|
769
|
+
h2.add_sensor("mbdy momentvec blade1 1 1 blade1") # 10, 11, 12
|
770
|
+
h2.init(htc_path=htc_path, model_path=model_path)
|
771
|
+
h2.stop_on_error(False)
|
772
|
+
yield h2
|
773
|
+
h2.close()
|
774
|
+
|
775
|
+
|
776
|
+
@pytest.fixture(scope="session")
|
777
|
+
def h2_iea22mw_only_blade_high_gravity_1_body(write_iea22mw_only_blade_high_gravity_1_body):
|
778
|
+
h2 = H2Lib(suppress_output=True)
|
779
|
+
model_path = f"{tfp}IEA-22-280-RWT/"
|
780
|
+
htc_path = "htc/IEA_22MW_RWT_only_blade_high_gravity_1_body.htc"
|
781
|
+
h2.add_sensor("mbdy statevec_new blade1 c2def global absolute 90.0 1.0 0.0 0.0")
|
782
|
+
h2.init(htc_path=htc_path, model_path=model_path)
|
783
|
+
h2.stop_on_error(False)
|
784
|
+
yield h2
|
785
|
+
h2.close()
|
786
|
+
|
787
|
+
|
788
|
+
@pytest.fixture(scope="session")
|
789
|
+
def h2_iea22mw_only_blade_high_gravity_changed_st(write_iea22mw_only_blade_high_gravity_changed_st):
|
790
|
+
h2 = H2Lib(suppress_output=True)
|
791
|
+
model_path = f"{tfp}IEA-22-280-RWT/"
|
792
|
+
htc_path = "htc/IEA_22MW_RWT_only_blade_high_gravity_changed_st.htc"
|
793
|
+
h2.add_sensor("mbdy statevec_new blade1 c2def global absolute 90.0 1.0 0.0 0.0") # 1-6
|
794
|
+
h2.add_sensor("mbdy forcevec blade1 1 1 blade1") # 7, 8, 9
|
795
|
+
h2.add_sensor("mbdy momentvec blade1 1 1 blade1") # 10, 11, 12
|
796
|
+
h2.init(htc_path=htc_path, model_path=model_path)
|
797
|
+
h2.stop_on_error(False)
|
798
|
+
yield h2
|
799
|
+
h2.close()
|