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.
@@ -238,23 +238,36 @@ def test_set_orientation_base_speed(h2_dtu_10mw_only_blade):
238
238
  )
239
239
 
240
240
 
241
+ def test_set_c2_def_too_few_sections(h2_dtu_10mw_only_blade):
242
+ blade_id = h2_dtu_10mw_only_blade.get_mainbody_name_dict()["blade1"]
243
+ with pytest.raises(ValueError, match="TOO_FEW_SECTIONS_IN_C2DEF"):
244
+ h2_dtu_10mw_only_blade.set_c2_def(blade_id, np.zeros((1, 4)))
245
+
246
+
247
+ def test_set_c2_def_wrong_number_of_columns(h2_dtu_10mw_only_blade):
248
+ blade_id = h2_dtu_10mw_only_blade.get_mainbody_name_dict()["blade1"]
249
+ with pytest.raises(ValueError, match="WRONG_NUMBER_OF_COLUMNS"):
250
+ h2_dtu_10mw_only_blade.set_c2_def(blade_id, np.zeros((2, 6)))
251
+
252
+
241
253
  def test_set_c2_def_main_body_not_found(h2_dtu_10mw_only_blade):
242
254
  with pytest.raises(ValueError, match="MAIN_BODY_NOT_FOUND"):
243
255
  h2_dtu_10mw_only_blade.set_c2_def(
244
- "tower",
256
+ -10,
257
+ np.array([[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0]]),
258
+ )
259
+ with pytest.raises(ValueError, match="MAIN_BODY_NOT_FOUND"):
260
+ h2_dtu_10mw_only_blade.set_c2_def(
261
+ 123,
245
262
  np.array([[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0]]),
246
263
  )
247
-
248
-
249
- def test_set_c2_def_too_few_sections(h2_dtu_10mw_only_blade):
250
- with pytest.raises(ValueError, match="TOO_FEW_SECTIONS_IN_C2DEF"):
251
- h2_dtu_10mw_only_blade.set_c2_def("blade1", np.zeros((1, 4)))
252
264
 
253
265
 
254
266
  def test_set_c2_def_different_nsec(h2_dtu_10mw_only_blade):
267
+ blade_id = h2_dtu_10mw_only_blade.get_mainbody_name_dict()["blade1"]
255
268
  with pytest.raises(ValueError, match="DIFFERENT_NSEC"):
256
269
  h2_dtu_10mw_only_blade.set_c2_def(
257
- "blade1",
270
+ blade_id,
258
271
  np.array([[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0]]),
259
272
  )
260
273
 
@@ -262,19 +275,21 @@ def test_set_c2_def_different_nsec(h2_dtu_10mw_only_blade):
262
275
  def test_set_c2_def_uniform_node_distribution(
263
276
  h2_dtu_10mw_only_blade_uniform_node_distribution,
264
277
  ):
278
+ blade_id = h2_dtu_10mw_only_blade_uniform_node_distribution.get_mainbody_name_dict()["blade1"]
265
279
  with pytest.raises(
266
280
  NotImplementedError,
267
281
  ):
268
282
  h2_dtu_10mw_only_blade_uniform_node_distribution.set_c2_def(
269
- "blade1", np.ones((27, 4), dtype=np.float64, order="F")
283
+ blade_id, np.ones((27, 4), dtype=np.float64, order="F")
270
284
  )
271
285
 
272
286
 
273
287
  def test_set_c2_def_beam_too_short(h2_dtu_10mw_only_blade):
274
288
  c2def = np.zeros((27, 4), dtype=np.float64, order="F")
275
289
  c2def[:, 2] = np.linspace(0.0, 1e-9, c2def.shape[0])
290
+ blade_id = h2_dtu_10mw_only_blade.get_mainbody_name_dict()["blade1"]
276
291
  with pytest.raises(ValueError, match="BEAM_TOO_SHORT"):
277
- h2_dtu_10mw_only_blade.set_c2_def("blade1", c2def)
292
+ h2_dtu_10mw_only_blade.set_c2_def(blade_id, c2def)
278
293
 
279
294
 
280
295
  def test_set_c2_def_blade_static_back_to_original(
@@ -288,8 +303,9 @@ def test_set_c2_def_blade_static_back_to_original(
288
303
  # 4. Revert it to the original one and check that the static solution matches the one from step 2.
289
304
 
290
305
  # Get the clamped DTU 10 MW blade subjected to high gravity loading.
291
- _, blade_c2def = write_dtu10mw_only_blade_high_gravity
306
+ _, blade_c2def, _ = write_dtu10mw_only_blade_high_gravity
292
307
  h2 = h2_dtu10mw_only_blade_high_gravity
308
+ blade_id = h2.get_mainbody_name_dict()["blade1"]
293
309
 
294
310
  # Sensors 1 to 6 are the displacement and rotation of the blade tip.
295
311
  # h2.get_sensor_info(1)
@@ -302,7 +318,7 @@ def test_set_c2_def_blade_static_back_to_original(
302
318
  c2def_new = blade_c2def.copy()
303
319
  for factor in (0.6, 0.7, 0.8, 0.9, 1.1, 1.2, 1.3, 1.4):
304
320
  c2def_new[:, 2] = factor * blade_c2def[:, 2]
305
- h2.set_c2_def("blade1", c2def_new)
321
+ h2.set_c2_def(blade_id, c2def_new)
306
322
  # Since we are smoothly changing c2_def, it makes sense to start the static solver from the last converged solution.
307
323
  h2.solver_static_run(reset_structure=False)
308
324
 
@@ -314,7 +330,7 @@ def test_set_c2_def_blade_static_back_to_original(
314
330
  npt.assert_allclose(blade_tip_actual, blade_tip_desired)
315
331
 
316
332
  # Restore blade c2_def.
317
- h2.set_c2_def("blade1", blade_c2def)
333
+ h2.set_c2_def(blade_id, blade_c2def)
318
334
  h2.solver_static_run(reset_structure=True)
319
335
  blade_tip_actual = h2.get_sensor_values((1, 2, 3, 4, 5, 6))
320
336
  npt.assert_allclose(blade_tip_actual, blade_tip_desired)
@@ -333,15 +349,16 @@ def test_set_c2_def_blade_static_deformed(
333
349
  # Set c2_def in the original blade, thus making it equivalent to the deformed one.
334
350
  # Then, solve again the static problem.
335
351
  _, c2def_deformed = write_dtu10mw_only_blade_high_gravity_deformed
336
- h2_dtu10mw_only_blade_high_gravity.set_c2_def("blade1", c2def_deformed)
352
+ blade_id = h2_dtu10mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
353
+ h2_dtu10mw_only_blade_high_gravity.set_c2_def(blade_id, c2def_deformed)
337
354
  h2_dtu10mw_only_blade_high_gravity.solver_static_run(reset_structure=True)
338
355
  blade_tip_actual = h2_dtu10mw_only_blade_high_gravity_deformed.get_sensor_values((1, 2, 3, 4, 5, 6))
339
356
 
340
357
  npt.assert_allclose(blade_tip_actual, blade_tip_desired)
341
358
 
342
359
  # Restore c2_def.
343
- _, c2def_original = write_dtu10mw_only_blade_high_gravity
344
- h2_dtu10mw_only_blade_high_gravity.set_c2_def("blade1", c2def_original)
360
+ _, c2def_original, _ = write_dtu10mw_only_blade_high_gravity
361
+ h2_dtu10mw_only_blade_high_gravity.set_c2_def(blade_id, c2def_original)
345
362
 
346
363
 
347
364
  @pytest.mark.skip(reason="The system eigenanalysis cannot be called more than once.")
@@ -351,8 +368,9 @@ def test_set_c2_def_blade_eig_back_to_original(
351
368
  ):
352
369
  # Get the clamped DTU 10 MW blade.
353
370
  # We use the fixture with high gravity because it also returns c2_def.
354
- _, blade_c2def = write_dtu10mw_only_blade_high_gravity
371
+ _, blade_c2def, _ = write_dtu10mw_only_blade_high_gravity
355
372
  h2 = h2_dtu10mw_only_blade_high_gravity
373
+ blade_id = h2.get_mainbody_name_dict()["blade1"]
356
374
 
357
375
  # Solve the eigenvalue problem.
358
376
  h2.structure_reset()
@@ -363,7 +381,7 @@ def test_set_c2_def_blade_eig_back_to_original(
363
381
  c2def_new = blade_c2def.copy()
364
382
  for factor in (0.6, 0.7, 0.8, 0.9, 1.1, 1.2, 1.3, 1.4):
365
383
  c2def_new[:, 2] = factor * blade_c2def[:, 2]
366
- h2.set_c2_def("blade1", c2def_new)
384
+ h2.set_c2_def(blade_id, c2def_new)
367
385
  h2.structure_reset()
368
386
  h2.linearize()
369
387
  natural_frequencies_actual, damping_ratios_actual = h2.do_system_eigenanalysis(n_modes=6, include_damping=True)
@@ -375,7 +393,7 @@ def test_set_c2_def_blade_eig_back_to_original(
375
393
  npt.assert_allclose(damping_ratios_actual, damping_ratios_desired)
376
394
 
377
395
  # Restore blade c2_def.
378
- h2.set_c2_def("blade1", blade_c2def)
396
+ h2.set_c2_def(blade_id, blade_c2def)
379
397
  h2.structure_reset()
380
398
  h2.linearize()
381
399
  natural_frequencies_actual, damping_ratios_actual = h2.do_system_eigenanalysis(n_modes=6, include_damping=True)
@@ -383,14 +401,15 @@ def test_set_c2_def_blade_eig_back_to_original(
383
401
  npt.assert_allclose(damping_ratios_actual, damping_ratios_desired)
384
402
 
385
403
 
386
- def test_set_c2_def_blade_mass_back_to_original(
404
+ def test_set_c2_def_blade_inertia_back_to_original(
387
405
  write_dtu10mw_only_blade_high_gravity_1_body,
388
406
  h2_dtu10mw_only_blade_high_gravity_1_body,
389
407
  ):
390
- # Get the clamped DTU 10 MW blade.
408
+ # Get the clamped DTU 10 MW blade with only 1 body.
391
409
  # We use the fixture with high gravity because it also returns c2_def.
392
- _, blade_c2def = write_dtu10mw_only_blade_high_gravity_1_body
410
+ _, blade_c2def, _ = write_dtu10mw_only_blade_high_gravity_1_body
393
411
  h2 = h2_dtu10mw_only_blade_high_gravity_1_body
412
+ blade_id = h2.get_mainbody_name_dict()["blade1"]
394
413
 
395
414
  # Get the inertia properties.
396
415
  h2.structure_reset()
@@ -400,7 +419,7 @@ def test_set_c2_def_blade_mass_back_to_original(
400
419
  c2def_new = blade_c2def.copy()
401
420
  for factor in (0.6, 0.7, 0.8, 0.9, 1.1, 1.2, 1.3, 1.4):
402
421
  c2def_new[:, 2] = factor * blade_c2def[:, 2]
403
- h2.set_c2_def("blade1", c2def_new)
422
+ h2.set_c2_def(blade_id, c2def_new)
404
423
  inertia_actual = h2.body_output_mass(0)
405
424
 
406
425
  # Must differ from the desired ones.
@@ -409,13 +428,13 @@ def test_set_c2_def_blade_mass_back_to_original(
409
428
  npt.assert_allclose(inertia_actual[i], inertia_desired[i])
410
429
 
411
430
  # Restore blade c2_def.
412
- h2.set_c2_def("blade1", blade_c2def)
431
+ h2.set_c2_def(blade_id, blade_c2def)
413
432
  inertia_actual = h2.body_output_mass(0)
414
433
  for i in range(4): # Loop over tuple of arrays.
415
434
  npt.assert_allclose(inertia_actual[i], inertia_desired[i])
416
435
 
417
436
 
418
- def test_set_c2_def_blade_mass_deformed(
437
+ def test_set_c2_def_blade_inertia_deformed(
419
438
  write_dtu10mw_only_blade_high_gravity,
420
439
  write_dtu10mw_only_blade_high_gravity_deformed,
421
440
  h2_dtu10mw_only_blade_high_gravity,
@@ -427,7 +446,8 @@ def test_set_c2_def_blade_mass_deformed(
427
446
 
428
447
  # Set c2_def in the original blade, thus making it equivalent to the deformed one.
429
448
  _, c2def_deformed = write_dtu10mw_only_blade_high_gravity_deformed
430
- h2_dtu10mw_only_blade_high_gravity.set_c2_def("blade1", c2def_deformed)
449
+ blade_id = h2_dtu10mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
450
+ h2_dtu10mw_only_blade_high_gravity.set_c2_def(blade_id, c2def_deformed)
431
451
 
432
452
  # Compare inertia properties for all bodies.
433
453
  nbdy, _ = h2_dtu10mw_only_blade_high_gravity_deformed.get_number_of_bodies_and_constraints()
@@ -439,8 +459,8 @@ def test_set_c2_def_blade_mass_deformed(
439
459
  npt.assert_allclose(inertia_actual[i], inertia_desired[i], rtol=1e-6)
440
460
 
441
461
  # Restore c2_def.
442
- _, c2def_original = write_dtu10mw_only_blade_high_gravity
443
- h2_dtu10mw_only_blade_high_gravity.set_c2_def("blade1", c2def_original)
462
+ _, c2def_original, _ = write_dtu10mw_only_blade_high_gravity
463
+ h2_dtu10mw_only_blade_high_gravity.set_c2_def(blade_id, c2def_original)
444
464
 
445
465
 
446
466
  def test_set_c2_def_blade_element_deformed(
@@ -455,7 +475,8 @@ def test_set_c2_def_blade_element_deformed(
455
475
 
456
476
  # Set c2_def in the original blade, thus making it equivalent to the deformed one.
457
477
  _, c2def_deformed = write_dtu10mw_only_blade_high_gravity_deformed
458
- h2_dtu10mw_only_blade_high_gravity.set_c2_def("blade1", c2def_deformed)
478
+ blade_id = h2_dtu10mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
479
+ h2_dtu10mw_only_blade_high_gravity.set_c2_def(blade_id, c2def_deformed)
459
480
 
460
481
  # Compare element matrices for all bodies.
461
482
  nelem = h2_dtu10mw_only_blade_high_gravity_deformed.get_number_of_elements()
@@ -469,8 +490,377 @@ def test_set_c2_def_blade_element_deformed(
469
490
  npt.assert_allclose(mat_actual[2], mat_desired[2], rtol=1e-10) # damping
470
491
 
471
492
  # Restore c2_def.
472
- _, c2def_original = write_dtu10mw_only_blade_high_gravity
473
- h2_dtu10mw_only_blade_high_gravity.set_c2_def("blade1", c2def_original)
493
+ _, c2def_original, _ = write_dtu10mw_only_blade_high_gravity
494
+ h2_dtu10mw_only_blade_high_gravity.set_c2_def(blade_id, c2def_original)
495
+
496
+
497
+ def test_set_st_wrong_number_of_columns(h2_dtu_10mw_only_blade):
498
+ blade_id = h2_dtu_10mw_only_blade.get_mainbody_name_dict()["blade1"]
499
+ with pytest.raises(ValueError, match="WRONG_NUMBER_OF_COLUMNS"):
500
+ h2_dtu_10mw_only_blade.set_st(blade_id, np.empty((2, 6)))
501
+
502
+
503
+ def test_set_st_main_body_not_found(h2_dtu_10mw_only_blade):
504
+ with pytest.raises(ValueError, match="MAIN_BODY_NOT_FOUND"):
505
+ h2_dtu_10mw_only_blade.set_st(-3, np.empty((2, 19)))
506
+ with pytest.raises(ValueError, match="MAIN_BODY_NOT_FOUND"):
507
+ h2_dtu_10mw_only_blade.set_st(123, np.empty((2, 19)))
508
+
509
+
510
+ def test_set_st_z_not_continuously_increasing(h2_dtu_10mw_only_blade):
511
+ blade_id = h2_dtu_10mw_only_blade.get_mainbody_name_dict()["blade1"]
512
+ with pytest.raises(ValueError, match="ST_Z_NOT_CONTINUOUSLY_INCREASING"):
513
+ h2_dtu_10mw_only_blade.set_st(blade_id, np.zeros((3, 19)))
514
+
515
+
516
+ def test_set_st_uniform_node_distribution(
517
+ h2_dtu_10mw_only_blade_uniform_node_distribution,
518
+ ):
519
+ blade_id = h2_dtu_10mw_only_blade_uniform_node_distribution.get_mainbody_name_dict()["blade1"]
520
+ with pytest.raises(NotImplementedError):
521
+ st = np.zeros((2, 19))
522
+ st[1, 0] = 1.0
523
+ h2_dtu_10mw_only_blade_uniform_node_distribution.set_st(blade_id, st)
524
+
525
+
526
+ def test_set_st_classic_timoshenko_blade_static_back_to_original(
527
+ write_dtu10mw_only_blade_high_gravity,
528
+ h2_dtu10mw_only_blade_high_gravity,
529
+ ):
530
+ # This test will:
531
+ # 1. Take the DTU 10 MW blade subjected to high gravity loading.
532
+ # 2. Compute the static solution.
533
+ # 3. Change ST a few times and re-compute the static solution.
534
+ # 4. Revert it to the original one and check that the static solution matches the one from step 2.
535
+
536
+ # Get the clamped DTU 10 MW blade subjected to high gravity loading.
537
+ _, _, blade_st = write_dtu10mw_only_blade_high_gravity
538
+ h2 = h2_dtu10mw_only_blade_high_gravity
539
+ blade_id = h2.get_mainbody_name_dict()["blade1"]
540
+
541
+ # Sensors 1 to 6 are the displacement and rotation of the blade tip.
542
+ # h2.get_sensor_info(1)
543
+
544
+ # Run the static solver and get the blade tip position and rotation.
545
+ h2.solver_static_run(reset_structure=True)
546
+ blade_tip_desired = h2.get_sensor_values((1, 2, 3, 4, 5, 6))
547
+
548
+ # Change blade ST and run the static solver.
549
+ rng = np.random.default_rng(seed=582)
550
+ for _ in range(10):
551
+ factor = rng.uniform(low=0.7, high=1.3, size=19)
552
+ st_new = factor * blade_st.main_data_sets[1][1]
553
+ # We do not change z, to prevent ST_Z_NOT_CONTINUOUSLY_INCREASING.
554
+ st_new[:, 0] = blade_st.main_data_sets[1][1][:, 0]
555
+ h2.set_st(blade_id, st_new)
556
+ h2.solver_static_run(reset_structure=True)
557
+
558
+ # Get new blade displacement.
559
+ blade_tip_actual = h2.get_sensor_values((1, 2, 3, 4, 5, 6))
560
+
561
+ # Must differ from blade_tip_desired.
562
+ with npt.assert_raises(AssertionError):
563
+ npt.assert_allclose(blade_tip_actual, blade_tip_desired)
564
+
565
+ # Restore blade c2_def.
566
+ h2.set_st(blade_id, blade_st.main_data_sets[1][1])
567
+ h2.solver_static_run(reset_structure=True)
568
+ blade_tip_actual = h2.get_sensor_values((1, 2, 3, 4, 5, 6))
569
+ npt.assert_allclose(blade_tip_actual, blade_tip_desired)
570
+
571
+
572
+ def test_set_st_classic_timoshenko_blade_static_changed_st(
573
+ write_dtu10mw_only_blade_high_gravity,
574
+ write_dtu10mw_only_blade_high_gravity_changed_st,
575
+ h2_dtu10mw_only_blade_high_gravity,
576
+ h2_dtu10mw_only_blade_high_gravity_changed_st,
577
+ ):
578
+ blade_id = h2_dtu10mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
579
+ # Solve the static problem with the changed ST loaded directly by HAWC2.
580
+ h2_dtu10mw_only_blade_high_gravity_changed_st.solver_static_run(reset_structure=True)
581
+ blade_tip_desired = h2_dtu10mw_only_blade_high_gravity_changed_st.get_sensor_values((1, 2, 3, 4, 5, 6))
582
+
583
+ # Set ST in the original blade, thus making it equivalent to the changed one.
584
+ # Then, solve again the static problem.
585
+ _, st_changed = write_dtu10mw_only_blade_high_gravity_changed_st
586
+ h2_dtu10mw_only_blade_high_gravity.set_st(blade_id, st_changed.main_data_sets[1][1])
587
+ h2_dtu10mw_only_blade_high_gravity.solver_static_run(reset_structure=True)
588
+ blade_tip_actual = h2_dtu10mw_only_blade_high_gravity_changed_st.get_sensor_values((1, 2, 3, 4, 5, 6))
589
+
590
+ npt.assert_allclose(blade_tip_actual, blade_tip_desired)
591
+
592
+ # Restore c2_def.
593
+ _, _, st_riginal = write_dtu10mw_only_blade_high_gravity
594
+ h2_dtu10mw_only_blade_high_gravity.set_st(blade_id, st_riginal.main_data_sets[1][1])
595
+
596
+
597
+ def test_set_st_classic_timoshenko_inertia_back_to_original(
598
+ write_dtu10mw_only_blade_high_gravity_1_body,
599
+ h2_dtu10mw_only_blade_high_gravity_1_body,
600
+ ):
601
+ # Get the clamped DTU 10 MW blade with only 1 body.
602
+ # We use the fixture with high gravity because it also returns st.
603
+ _, _, st = write_dtu10mw_only_blade_high_gravity_1_body
604
+ h2 = h2_dtu10mw_only_blade_high_gravity_1_body
605
+ blade_id = h2.get_mainbody_name_dict()["blade1"]
606
+
607
+ # Get the inertia properties.
608
+ h2.structure_reset()
609
+ inertia_desired = h2.body_output_mass(0)
610
+
611
+ # Change blade density and compute inertia properties.
612
+ mass_original = st.m()
613
+ rng = np.random.default_rng(seed=582)
614
+ for _ in range(10):
615
+ # Uniformly scale to change the mass.
616
+ density_new = rng.uniform(low=0.5, high=2.0) * mass_original
617
+ # Make the blade tip heavier to change center of gravity.
618
+ density_new *= np.linspace(0.8, 2.5, density_new.size)
619
+ st.set_value(mset=1, set=1, m=density_new)
620
+ h2.set_st(blade_id, st.main_data_sets[1][1])
621
+ inertia_actual = h2.body_output_mass(0)
622
+
623
+ # Must differ from the desired ones.
624
+ for i in range(4): # Loop over tuple of arrays.
625
+ with npt.assert_raises(AssertionError):
626
+ npt.assert_allclose(inertia_actual[i], inertia_desired[i])
627
+
628
+ # Restore ST.
629
+ st.set_value(mset=1, set=1, m=mass_original)
630
+ h2.set_st(blade_id, st.main_data_sets[1][1])
631
+ inertia_actual = h2.body_output_mass(0)
632
+ for i in range(4): # Loop over tuple of arrays.
633
+ npt.assert_allclose(inertia_actual[i], inertia_desired[i])
634
+
635
+
636
+ def test_set_st_classic_timoshenko_blade_inertia_changed_st(
637
+ write_dtu10mw_only_blade_high_gravity,
638
+ write_dtu10mw_only_blade_high_gravity_changed_st,
639
+ h2_dtu10mw_only_blade_high_gravity,
640
+ h2_dtu10mw_only_blade_high_gravity_changed_st,
641
+ ):
642
+ # Revert blades to the undeflected configuration.
643
+ h2_dtu10mw_only_blade_high_gravity.structure_reset()
644
+ h2_dtu10mw_only_blade_high_gravity_changed_st.structure_reset()
645
+
646
+ # Set ST in the original blade, thus making it equivalent to the changed one.
647
+ _, st_changed = write_dtu10mw_only_blade_high_gravity_changed_st
648
+ blade_id = h2_dtu10mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
649
+ h2_dtu10mw_only_blade_high_gravity.set_st(blade_id, st_changed.main_data_sets[1][1])
650
+
651
+ # Compare inertia properties for all bodies.
652
+ nbdy, _ = h2_dtu10mw_only_blade_high_gravity_changed_st.get_number_of_bodies_and_constraints()
653
+ for i in range(nbdy):
654
+ inertia_desired = h2_dtu10mw_only_blade_high_gravity_changed_st.body_output_mass(i)
655
+ inertia_actual = h2_dtu10mw_only_blade_high_gravity.body_output_mass(i)
656
+
657
+ for i in range(4): # Loop over tuple of arrays.
658
+ npt.assert_allclose(inertia_actual[i], inertia_desired[i])
659
+
660
+ # Restore ST.
661
+ _, _, st_original = write_dtu10mw_only_blade_high_gravity
662
+ h2_dtu10mw_only_blade_high_gravity.set_st(blade_id, st_original.main_data_sets[1][1])
663
+
664
+
665
+ def test_set_st_classic_timoshenko_blade_element_changed_st(
666
+ write_dtu10mw_only_blade_high_gravity,
667
+ write_dtu10mw_only_blade_high_gravity_changed_st,
668
+ h2_dtu10mw_only_blade_high_gravity,
669
+ h2_dtu10mw_only_blade_high_gravity_changed_st,
670
+ ):
671
+ # Revert blades to the undeflected configuration.
672
+ h2_dtu10mw_only_blade_high_gravity.structure_reset()
673
+ h2_dtu10mw_only_blade_high_gravity_changed_st.structure_reset()
674
+
675
+ # Set ST in the original blade, thus making it equivalent to the changed one.
676
+ _, st_changed = write_dtu10mw_only_blade_high_gravity_changed_st
677
+ blade_id = h2_dtu10mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
678
+ h2_dtu10mw_only_blade_high_gravity.set_st(blade_id, st_changed.main_data_sets[1][1])
679
+
680
+ # Compare element matrices for all bodies.
681
+ nelem = h2_dtu10mw_only_blade_high_gravity_changed_st.get_number_of_elements()
682
+ for ibdy in range(nelem.size):
683
+ for ielem in range(nelem[ibdy]):
684
+ mat_desired = h2_dtu10mw_only_blade_high_gravity_changed_st.body_output_element(ibdy, ielem)
685
+ mat_actual = h2_dtu10mw_only_blade_high_gravity.body_output_element(ibdy, ielem)
686
+
687
+ npt.assert_allclose(mat_actual[0], mat_desired[0], rtol=1e-14) # mass
688
+ npt.assert_allclose(mat_actual[1], mat_desired[1], rtol=1e-14) # stiffness
689
+ npt.assert_allclose(mat_actual[2], mat_desired[2], rtol=1e-14) # damping
690
+
691
+ # Restore ST.
692
+ _, _, st_original = write_dtu10mw_only_blade_high_gravity
693
+ h2_dtu10mw_only_blade_high_gravity.set_st(blade_id, st_original.main_data_sets[1][1])
694
+
695
+
696
+ def test_set_st_fpm_blade_static_back_to_original(
697
+ write_iea22mw_only_blade_high_gravity,
698
+ h2_iea22mw_only_blade_high_gravity,
699
+ ):
700
+ # This test will:
701
+ # 1. Take the IEA 22 MW blade subjected to high gravity loading.
702
+ # 2. Compute the static solution.
703
+ # 3. Change ST a few times and re-compute the static solution.
704
+ # 4. Revert it to the original one and check that the static solution matches the one from step 2.
705
+
706
+ # Get the clamped IEA 22 MW blade subjected to high gravity loading.
707
+ _, _, blade_st = write_iea22mw_only_blade_high_gravity
708
+ h2 = h2_iea22mw_only_blade_high_gravity
709
+ blade_id = h2.get_mainbody_name_dict()["blade1"]
710
+
711
+ # Sensors 1 to 6 are the displacement and rotation of the blade tip.
712
+ # h2.get_sensor_info(1)
713
+
714
+ # Run the static solver and get the blade tip position and rotation.
715
+ h2.solver_static_run(reset_structure=True)
716
+ blade_tip_desired = h2.get_sensor_values((1, 2, 3, 4, 5, 6))
717
+
718
+ # Change blade ST and run the static solver.
719
+ rng = np.random.default_rng(seed=582)
720
+ for _ in range(10):
721
+ factor = rng.uniform(low=0.7, high=1.3, size=30)
722
+ st_new = factor * blade_st.main_data_sets[1][1]
723
+ # We do not change z, to prevent ST_Z_NOT_CONTINUOUSLY_INCREASING.
724
+ st_new[:, 0] = blade_st.main_data_sets[1][1][:, 0]
725
+ h2.set_st(blade_id, st_new)
726
+ h2.solver_static_run(reset_structure=True)
727
+
728
+ # Get new blade displacement.
729
+ blade_tip_actual = h2.get_sensor_values((1, 2, 3, 4, 5, 6))
730
+
731
+ # Must differ from blade_tip_desired.
732
+ with npt.assert_raises(AssertionError):
733
+ npt.assert_allclose(blade_tip_actual, blade_tip_desired)
734
+
735
+ # Restore blade c2_def.
736
+ h2.set_st(blade_id, blade_st.main_data_sets[1][1])
737
+ h2.solver_static_run(reset_structure=True)
738
+ blade_tip_actual = h2.get_sensor_values((1, 2, 3, 4, 5, 6))
739
+ npt.assert_allclose(blade_tip_actual, blade_tip_desired)
740
+
741
+
742
+ def test_set_st_fpm_blade_static_changed_st(
743
+ write_iea22mw_only_blade_high_gravity,
744
+ write_iea22mw_only_blade_high_gravity_changed_st,
745
+ h2_iea22mw_only_blade_high_gravity,
746
+ h2_iea22mw_only_blade_high_gravity_changed_st,
747
+ ):
748
+ # Solve the static problem with the changed ST loaded directly by HAWC2.
749
+ h2_iea22mw_only_blade_high_gravity_changed_st.solver_static_run(reset_structure=True)
750
+ blade_tip_desired = h2_iea22mw_only_blade_high_gravity_changed_st.get_sensor_values((1, 2, 3, 4, 5, 6))
751
+
752
+ # Set ST in the original blade, thus making it equivalent to the changed one.
753
+ # Then, solve again the static problem.
754
+ _, st_changed = write_iea22mw_only_blade_high_gravity_changed_st
755
+ blade_id = h2_iea22mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
756
+ h2_iea22mw_only_blade_high_gravity.set_st(blade_id, st_changed.main_data_sets[1][1])
757
+ h2_iea22mw_only_blade_high_gravity.solver_static_run(reset_structure=True)
758
+ blade_tip_actual = h2_iea22mw_only_blade_high_gravity_changed_st.get_sensor_values((1, 2, 3, 4, 5, 6))
759
+
760
+ npt.assert_allclose(blade_tip_actual, blade_tip_desired)
761
+
762
+ # Restore c2_def.
763
+ _, _, st_riginal = write_iea22mw_only_blade_high_gravity
764
+ h2_iea22mw_only_blade_high_gravity.set_st(blade_id, st_riginal.main_data_sets[1][1])
765
+
766
+
767
+ def test_set_st_fpm_inertia_back_to_original(
768
+ write_iea22mw_only_blade_high_gravity_1_body,
769
+ h2_iea22mw_only_blade_high_gravity_1_body,
770
+ ):
771
+ # Get the clamped DTU 10 MW blade with only 1 body.
772
+ # We use the fixture with high gravity because it also returns st.
773
+ _, _, st = write_iea22mw_only_blade_high_gravity_1_body
774
+ h2 = h2_iea22mw_only_blade_high_gravity_1_body
775
+ blade_id = h2.get_mainbody_name_dict()["blade1"]
776
+
777
+ # Get the inertia properties.
778
+ h2.structure_reset()
779
+ inertia_desired = h2.body_output_mass(0)
780
+
781
+ # Change blade density and compute inertia properties.
782
+ mass_original = st.m()
783
+ rng = np.random.default_rng(seed=582)
784
+ for _ in range(10):
785
+ # Uniformly scale to change the mass.
786
+ density_new = rng.uniform(low=0.5, high=2.0) * mass_original
787
+ # Make the blade tip heavier to change center of gravity.
788
+ density_new *= np.linspace(0.8, 2.5, density_new.size)
789
+ st.set_value(mset=1, set=1, m=density_new)
790
+ h2.set_st(blade_id, st.main_data_sets[1][1])
791
+ inertia_actual = h2.body_output_mass(0)
792
+
793
+ # Must differ from the desired ones.
794
+ for i in range(4): # Loop over tuple of arrays.
795
+ with npt.assert_raises(AssertionError):
796
+ npt.assert_allclose(inertia_actual[i], inertia_desired[i])
797
+
798
+ # Restore ST.
799
+ st.set_value(mset=1, set=1, m=mass_original)
800
+ h2.set_st(blade_id, st.main_data_sets[1][1])
801
+ inertia_actual = h2.body_output_mass(0)
802
+ for i in range(4): # Loop over tuple of arrays.
803
+ npt.assert_allclose(inertia_actual[i], inertia_desired[i])
804
+
805
+
806
+ def test_set_st_fpm_blade_inertia_changed_st(
807
+ write_iea22mw_only_blade_high_gravity,
808
+ write_iea22mw_only_blade_high_gravity_changed_st,
809
+ h2_iea22mw_only_blade_high_gravity,
810
+ h2_iea22mw_only_blade_high_gravity_changed_st,
811
+ ):
812
+ # Revert blades to the undeflected configuration.
813
+ h2_iea22mw_only_blade_high_gravity.structure_reset()
814
+ h2_iea22mw_only_blade_high_gravity_changed_st.structure_reset()
815
+
816
+ # Set ST in the original blade, thus making it equivalent to the changed one.
817
+ _, st_changed = write_iea22mw_only_blade_high_gravity_changed_st
818
+ blade_id = h2_iea22mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
819
+ h2_iea22mw_only_blade_high_gravity.set_st(blade_id, st_changed.main_data_sets[1][1])
820
+
821
+ # Compare inertia properties for all bodies.
822
+ nbdy, _ = h2_iea22mw_only_blade_high_gravity_changed_st.get_number_of_bodies_and_constraints()
823
+ for i in range(nbdy):
824
+ inertia_desired = h2_iea22mw_only_blade_high_gravity_changed_st.body_output_mass(i)
825
+ inertia_actual = h2_iea22mw_only_blade_high_gravity.body_output_mass(i)
826
+
827
+ for i in range(4): # Loop over tuple of arrays.
828
+ npt.assert_allclose(inertia_actual[i], inertia_desired[i])
829
+
830
+ # Restore ST.
831
+ _, _, st_original = write_iea22mw_only_blade_high_gravity
832
+ h2_iea22mw_only_blade_high_gravity.set_st(blade_id, st_original.main_data_sets[1][1])
833
+
834
+
835
+ def test_set_st_fpm_blade_element_changed_st(
836
+ write_iea22mw_only_blade_high_gravity,
837
+ write_iea22mw_only_blade_high_gravity_changed_st,
838
+ h2_iea22mw_only_blade_high_gravity,
839
+ h2_iea22mw_only_blade_high_gravity_changed_st,
840
+ ):
841
+ # Revert blades to the undeflected configuration.
842
+ h2_iea22mw_only_blade_high_gravity.structure_reset()
843
+ h2_iea22mw_only_blade_high_gravity_changed_st.structure_reset()
844
+
845
+ # Set ST in the original blade, thus making it equivalent to the changed one.
846
+ _, st_changed = write_iea22mw_only_blade_high_gravity_changed_st
847
+ blade_id = h2_iea22mw_only_blade_high_gravity.get_mainbody_name_dict()["blade1"]
848
+ h2_iea22mw_only_blade_high_gravity.set_st(blade_id, st_changed.main_data_sets[1][1])
849
+
850
+ # Compare element matrices for all bodies.
851
+ nelem = h2_iea22mw_only_blade_high_gravity_changed_st.get_number_of_elements()
852
+ for ibdy in range(nelem.size):
853
+ for ielem in range(nelem[ibdy]):
854
+ mat_desired = h2_iea22mw_only_blade_high_gravity_changed_st.body_output_element(ibdy, ielem)
855
+ mat_actual = h2_iea22mw_only_blade_high_gravity.body_output_element(ibdy, ielem)
856
+
857
+ npt.assert_allclose(mat_actual[0], mat_desired[0], rtol=1e-14) # mass
858
+ npt.assert_allclose(mat_actual[1], mat_desired[1], rtol=1e-14) # stiffness
859
+ npt.assert_allclose(mat_actual[2], mat_desired[2], rtol=1e-14) # damping
860
+
861
+ # Restore ST.
862
+ _, _, st_original = write_iea22mw_only_blade_high_gravity
863
+ h2_iea22mw_only_blade_high_gravity.set_st(blade_id, st_original.main_data_sets[1][1])
474
864
 
475
865
 
476
866
  def test_set_orientation_relative_main_body_not_found(
@@ -605,5 +995,5 @@ def test_set_orientation_relative_static(
605
995
  # %% Main.
606
996
 
607
997
  if __name__ == "__main__":
608
- # pytest.main([__file__])
609
- pytest.main([__file__, "-k test_set_c2_def_blade_element_deformed"])
998
+ pytest.main([__file__])
999
+ # pytest.main([__file__, "-k test_set_st_fpm_blade_element_changed_st"])
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: h2lib-tests
3
- Version: 13.2.702
4
- Summary: Tests and test_files for test h2lib (13.2.7+4-gb779ee7)
3
+ Version: 13.2.901
4
+ Summary: Tests and test_files for test h2lib (13.2.9+4-gfd77867)
5
5
  Download-URL:
6
6
  Author: Mads M Pedersen
7
7
  Author-email:
@@ -13,6 +13,7 @@ Requires-Dist: pytest-cov
13
13
  Requires-Dist: hipersim
14
14
  Requires-Dist: wetb
15
15
  Requires-Dist: h2lib
16
+ Requires-Dist: Hawc2Models==0.0.4
16
17
  Dynamic: author
17
18
  Dynamic: requires-dist
18
19
  Dynamic: summary
@@ -1,16 +1,16 @@
1
1
  h2lib_tests/__init__.py,sha256=VjSqfGg8BzdmSjfSFhJh4hZbYZ_cME7xp9EWFKHQphA,61
2
- h2lib_tests/conftest.py,sha256=o9bkMEaB40rr_KSGovy1nuvq2Y09rKfQWxTcTGZ0MfY,21607
2
+ h2lib_tests/conftest.py,sha256=r4p868zCfJ5MMd2hs6XvGaiqu3jYlSR5G0OKAk5WX7Y,29629
3
3
  h2lib_tests/dtu10mw.py,sha256=a7SXfyDwDQPastYKb5CgghOQcYfgO1eTwGrd-H3Enok,4374
4
4
  h2lib_tests/test_calc.py,sha256=VNLfr2J9R2Jy9xTbdZ9dfbQ4dCwr7H7nbZRI3yP69fQ,2152
5
- h2lib_tests/test_distributed_sections.py,sha256=JtguIddd2nmRyNsy2jqjPFB8E5cGpH2_IVErP1wGPPg,5432
5
+ h2lib_tests/test_distributed_sections.py,sha256=xYcQwNGL3IQyVaguHGZrm0EZGYIMw4LRq9q5xwird1E,19413
6
6
  h2lib_tests/test_ellipsys_couplings.py,sha256=mfSTk1IamaKETU6Be8p8W9vA-yostWJl17m5sFlEK3Q,3345
7
- h2lib_tests/test_h2lib.py,sha256=LEV1n0Fwa1llQwIM06Mcqr07Y6WOn-j8mNxjzlCEOl0,14219
8
- h2lib_tests/test_h2rotor.py,sha256=yAcG9RDD3uO4g4w8LJnJ3Md_bC-_mBn1--4KHwvlTRc,12963
7
+ h2lib_tests/test_h2lib.py,sha256=t2jwmXzibej9DQoAkldwWX1MmEmpcV0kp2hLDRV5dbQ,13836
8
+ h2lib_tests/test_h2rotor.py,sha256=cF3KMdzTyGoZGyihhHCJqdH_n_t2vjS1BPHDaUCk9pU,13918
9
9
  h2lib_tests/test_lin.py,sha256=yydbsMX44ym_MSqR1cbQkqil8qC4icSW_JccPSElGac,6292
10
10
  h2lib_tests/test_mpi.py,sha256=CTT160yc6uZFRr_QNFWxyOwJ-y0qHiIp8jPYs1MQpyg,7111
11
11
  h2lib_tests/test_multiprocessinterface.py,sha256=h2o4havtK6IuMXsplNjGUa3VxOnbpEYGxdrrAKQilj0,1470
12
12
  h2lib_tests/test_static_solver.py,sha256=IuUkKrEoz_EKLCmGQ94CLFgjKPvO20iVx4773JTKO-8,6503
13
- h2lib_tests/test_topology_h2lib.py,sha256=7ZfVjEUYBJacPcFCDi_Qb0LqW6W-0no_zTBUKbNcKQw,23858
13
+ h2lib_tests/test_topology_h2lib.py,sha256=8SCrrjd8VZh_1pX9KDm_b2aCCyCZ-YbjwRgBRCOKNwQ,42472
14
14
  h2lib_tests/test_files/__init__.py,sha256=9e6ZUPb42e0wf2E1rutdcTM8hROcWFRVPXtZriU3ySw,50
15
15
  h2lib_tests/test_files/my_test_cls.py,sha256=7ZDsFkxrLfOY6q00U5Y-daxfuhATK-K5H04RP-VmQdE,850
16
16
  h2lib_tests/test_files/DTU_10_MW/control/dtu_we_controller.dll,sha256=C5T_CuAFtIuDgCXSYAoNu24yKPwj2nWOeORacJbLN9s,1134592
@@ -91,7 +91,7 @@ h2lib_tests/test_files/minimal/res/minimal_mann_turb.hdf5,sha256=Q3cs3bZyplZjBpo
91
91
  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
92
92
  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
93
93
  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
94
- h2lib_tests-13.2.702.dist-info/METADATA,sha256=Bm3FrFz3BYvqhQnv-UOFNbfIkg1fbgEcP8KAc9QYMtk,417
95
- h2lib_tests-13.2.702.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
96
- h2lib_tests-13.2.702.dist-info/top_level.txt,sha256=WufAL3LO35YJBhWg1AfgTjSld-6l_WuRkXAkNKczUrM,12
97
- h2lib_tests-13.2.702.dist-info/RECORD,,
94
+ h2lib_tests-13.2.901.dist-info/METADATA,sha256=tsWn93wEcdivKQ20oO9utThtj-uQRsQWDZmGR_khWj0,452
95
+ h2lib_tests-13.2.901.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
96
+ h2lib_tests-13.2.901.dist-info/top_level.txt,sha256=WufAL3LO35YJBhWg1AfgTjSld-6l_WuRkXAkNKczUrM,12
97
+ h2lib_tests-13.2.901.dist-info/RECORD,,