h2lib 13.1.901__py3-none-win_amd64.whl → 13.1.1701__py3-none-win_amd64.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/HAWC2Lib.dll CHANGED
Binary file
h2lib/_h2lib.py CHANGED
@@ -21,6 +21,7 @@ _ERROR_CODES = {
21
21
  300: ValueError("TOO_FEW_SECTIONS_IN_C2DEF"),
22
22
  301: ValueError("BEAM_TOO_SHORT"),
23
23
  302: ValueError("DIFFERENT_NSEC"),
24
+ 500: ValueError("RELATIVE_ROTATION_NOT_FOUND"),
24
25
  700: RuntimeError("SYSTEM_NOT_LINEARIZED"),
25
26
  701: RuntimeError("SYSTEM_EIGENANALYSIS_NOT_DONE"),
26
27
  702: ValueError("TOO_MANY_MODES_REQUESTED"),
@@ -47,11 +48,9 @@ class H2LibThread(H2LibSignatures, DLLWrapper):
47
48
  # doubles the speed of single instances and 2N of N instances on linux
48
49
  os.environ['MKL_THREADING_LAYER'] = 'sequential'
49
50
  filename = os.path.abspath(filename)
50
- p = Path(np.__file__).parents
51
- for i in range(2, 4):
52
- if (p[i] / 'Library/bin').exists():
53
- os.add_dll_directory(p[i] / 'Library/bin')
54
- break
51
+ for f in [sys.base_prefix, sys.prefix]:
52
+ if os.path.isdir(os.path.join(f, 'Library/bin')):
53
+ os.add_dll_directory(os.path.join(f, 'Library/bin'))
55
54
  DLLWrapper.__init__(self, filename, cwd=cwd, cdecl=True)
56
55
  self.suppress_output = suppress_output
57
56
  self._initialized = False
@@ -89,6 +88,23 @@ class H2LibThread(H2LibSignatures, DLLWrapper):
89
88
  s = " " * 255
90
89
  return H2LibSignatures.get_version(self, s)[0][0].strip()
91
90
 
91
+ def stop_on_error(self, flag):
92
+ """
93
+ Control if HAWC2 will terminate the execution upon encountering an error. The default HAWC2 behavior is to stop.
94
+
95
+ Parameters
96
+ ----------
97
+ flag : bool
98
+ If set to `True` an error will cause HAWC2 to terminate the execution with status code 1.
99
+ If set to `False` HAWC2 will still print a log message but not stop.
100
+
101
+ Returns
102
+ -------
103
+ None.
104
+
105
+ """
106
+ H2LibSignatures.stop_on_error(self, bool(flag))
107
+
92
108
  def get_wind_speed(self, pos_g):
93
109
  return self.get_lib_function('get_wind_speed')(np.asarray(pos_g, dtype=np.float64),
94
110
  np.asarray([0, 0, 0], dtype=np.float64))[0][1]
@@ -378,23 +394,23 @@ class H2LibThread(H2LibSignatures, DLLWrapper):
378
394
 
379
395
  def set_orientation_base(
380
396
  self,
381
- main_body_name,
397
+ main_body,
382
398
  mbdy_eulerang_table=None,
383
399
  angles_in_deg=True,
384
400
  reset_orientation=False,
385
401
  mbdy_ini_rotvec_d1=None,
386
402
  ):
387
403
  """
388
- Set an orientation / base command.
404
+ Set an `orientation` / `base` command.
389
405
 
390
- Function equivalent to the HAWC2 command orientation / base.
406
+ Function equivalent to the HAWC2 command `orientation` / `base`.
391
407
  For further details see the HAWC2 documentation.
392
- We assume that this base is already present in the htc file,
408
+ We assume that this base orientation is already present in the htc file,
393
409
  and therefore modify it here instead of creating a new one.
394
410
 
395
411
  Parameters
396
412
  ----------
397
- main_body_name : str
413
+ main_body : str
398
414
  Main body name. Same as HAWC2 `mbdy` parameter.
399
415
  mbdy_eulerang_table : (:, 3) ndarray, optional
400
416
  A sequence of Euler angles, one per row.
@@ -402,7 +418,7 @@ class H2LibThread(H2LibSignatures, DLLWrapper):
402
418
  A 1D array with 3 elements will be interpreted as 1 row.
403
419
  This table is additive with respect to the orientation / base command in the htc file,
404
420
  unless the flag `reset_orientation` is used.
405
- The default is `[0, 0, 0]`, which means that the base is coincident with the global frame.
421
+ The default is `[0, 0, 0]`, which means that no rotation is applied.
406
422
  angles_in_deg : bool, optional
407
423
  `True` if the angles in `mbdy_eulerang_table` are provided in degrees.
408
424
  `False` if they are in radians.
@@ -418,7 +434,7 @@ class H2LibThread(H2LibSignatures, DLLWrapper):
418
434
  Raises
419
435
  ------
420
436
  ValueError
421
- If the orientation / base command cannot be found.
437
+ If the `orientation` / `base` command cannot be found.
422
438
 
423
439
  Returns
424
440
  -------
@@ -434,9 +450,9 @@ class H2LibThread(H2LibSignatures, DLLWrapper):
434
450
  error_code = -1
435
451
  error_code = H2LibSignatures.set_orientation_base(
436
452
  self,
437
- main_body_name,
438
- np.asfortranarray(mbdy_eulerang_table.astype(np.float64)),
453
+ main_body,
439
454
  mbdy_eulerang_table.shape[0],
455
+ np.asfortranarray(mbdy_eulerang_table.astype(np.float64)),
440
456
  angles_in_deg,
441
457
  reset_orientation,
442
458
  np.asfortranarray(mbdy_ini_rotvec_d1.astype(np.float64)),
@@ -446,6 +462,97 @@ class H2LibThread(H2LibSignatures, DLLWrapper):
446
462
  if error_code > 0:
447
463
  raise _ERROR_CODES[error_code]
448
464
 
465
+ def set_orientation_relative(
466
+ self,
467
+ main_body_1,
468
+ node_1,
469
+ main_body_2,
470
+ node_2,
471
+ mbdy2_eulerang_table=None,
472
+ angles_in_deg=True,
473
+ reset_orientation=False,
474
+ mbdy2_ini_rotvec_d1=None,
475
+ ):
476
+ """
477
+ Set an `orientation` / `relative` command.
478
+
479
+ Function equivalent to the HAWC2 command `orientation` / `relative`.
480
+ For further details see the HAWC2 documentation.
481
+ We assume that this relative orientation is already present in the htc file,
482
+ and therefore modify it here instead of creating a new one.
483
+
484
+ Parameters
485
+ ----------
486
+ main_body_1 : str
487
+ Main body name to which the next main body is attached.
488
+ node_1 : int, str
489
+ Node number of `main_body_1` that is used for connection, starting from 0.
490
+ `"last"` can be specified which ensures that the last node on the main_body
491
+ is used, and `-1` refers to the origin of the main body coordinate system.
492
+ main_body_2 : str
493
+ Main_body name of the `main_body` that is positioned
494
+ in space by the relative command.
495
+ node_2 : int, str
496
+ Node number of `main_body_2` that is used for connection, starting from 0.
497
+ `"last"` can be specified which ensures that the last node on the main_body
498
+ is used, and `-1` refers to the origin of the main body coordinate system.
499
+ mbdy2_eulerang_table : : (:, 3) ndarray, optional
500
+ A sequence of Euler angles, one per row.
501
+ Equivalent to HAWC2 command `mbdy2_eulerang`.
502
+ A 1D array with 3 elements will be interpreted as 1 row.
503
+ This table is additive with respect to the orientation / relative command in the htc file,
504
+ unless the flag `reset_orientation` is used.
505
+ The default is `[0, 0, 0]`, which means that no rotation is applied.
506
+ angles_in_deg : bool, optional
507
+ `True` if the angles in `mbdy2_eulerang_table` are provided in degrees.
508
+ `False` if they are in radians.
509
+ The default is `True`.
510
+ reset_orientation : bool, optional,
511
+ If `True` this function will reset the orientation to no rotation
512
+ before applying `mbdy2_eulerang_table`. The default is `False`.
513
+ mbdy2_ini_rotvec_d1 : (4) ndarray, optional
514
+ Angular velocity. First 3 elements for the direction and last for the magnitude.
515
+ Equivalent to HAWC2 command `mbdy2_ini_rotvec_d1`.
516
+ The default is 0 speed.
517
+
518
+ Raises
519
+ ------
520
+ ValueError
521
+ If the `orientation` / `relative` command cannot be found,
522
+ or if the main bodies do not exist.
523
+
524
+ Returns
525
+ -------
526
+ None.
527
+
528
+ """
529
+ if mbdy2_eulerang_table is None:
530
+ mbdy2_eulerang_table = np.zeros((1, 3), dtype=np.float64, order="F")
531
+ if mbdy2_ini_rotvec_d1 is None:
532
+ mbdy2_ini_rotvec_d1 = np.zeros((4,), dtype=np.float64, order="F")
533
+ # 1D arrays are converted to 2D with 1 row.
534
+ mbdy2_eulerang_table = np.atleast_2d(mbdy2_eulerang_table)
535
+ # Convert node_1 and 2 to int.
536
+ if node_1 == "last":
537
+ node_1 = -2
538
+ if node_2 == "last":
539
+ node_2 = -2
540
+ error_code = -1
541
+ error_code = H2LibSignatures.set_orientation_relative(
542
+ self,
543
+ main_body_1,
544
+ node_1 + 1,
545
+ main_body_2,
546
+ node_2 + 1,
547
+ mbdy2_eulerang_table.shape[0],
548
+ np.asfortranarray(mbdy2_eulerang_table.astype(np.float64)),
549
+ bool(angles_in_deg),
550
+ reset_orientation,
551
+ np.asfortranarray(mbdy2_ini_rotvec_d1.astype(np.float64)),
552
+ error_code)[0][-1]
553
+ if error_code > 0:
554
+ raise _ERROR_CODES[error_code]
555
+
449
556
  def init_windfield(self, Nxyz, dxyz, box_offset_yz, transport_speed):
450
557
  """Initialize wind field which afterwards can be set using set_windfield
451
558
 
@@ -540,10 +647,12 @@ class H2LibThread(H2LibSignatures, DLLWrapper):
540
647
  return self._aero_sections_data_shape[rotor]
541
648
 
542
649
  def get_aerosections_position(self, rotor=0):
650
+ """Global xyz position of aero sections. Shape=(#blades, #sections, 3)"""
543
651
  position = np.zeros(self.aero_sections_data_shape(rotor), dtype=np.float64, order='F')
544
652
  return H2LibSignatures.get_aerosections_position(self, rotor + 1, position)[0][1]
545
653
 
546
654
  def set_aerosections_windspeed(self, uvw, rotor=0):
655
+ """Update wind speed at aero sections. uvw shape=(#blades, #sections, 3)"""
547
656
  return H2LibSignatures.set_aerosections_windspeed(self, rotor + 1, np.asarray(uvw, np.float64))
548
657
 
549
658
  def get_aerosections_forces(self, rotor=0):
h2lib/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # This file is autogenerated and should not be modified manually
2
- __version__ = '13.1.901'
3
- h2lib_version = '13.1.901'
4
- hawc2_version = '13.1.9+5-g2026dd7'
2
+ __version__ = '13.1.1701'
3
+ h2lib_version = '13.1.1701'
4
+ hawc2_version = '13.1.17'
h2lib/h2lib_signatures.py CHANGED
@@ -356,19 +356,44 @@ end subroutine'''
356
356
  return self.get_lib_function('set_aerosections_windspeed')(rotor, uvw)
357
357
 
358
358
  def set_orientation_base(self, main_body_name,
359
- mbdy_eulerang_table, n_rows, angles_in_deg, reset_orientation, mbdy_ini_rotvec_d1,
359
+ n_rows, mbdy_eulerang_table, angles_in_deg, reset_orientation, mbdy_ini_rotvec_d1,
360
360
  error_code):
361
- '''subroutine set_orientation_base(main_body_name,&
361
+ '''subroutine set_orientation_base(main_body_name, &
362
362
  character(kind=c_char, len=1), dimension(256), intent(in) :: main_body_name
363
- integer(kind=4), intent(in) :: n_rows
363
+ real(kind=c_double), dimension(n_rows, 3), intent(in) :: mbdy_eulerang_table
364
364
  logical, intent(in) :: angles_in_deg
365
365
  logical, intent(in) :: reset_orientation
366
366
  real(kind=c_double), dimension(4), intent(in) :: mbdy_ini_rotvec_d1
367
367
  end subroutine'''
368
368
  return self.get_lib_function('set_orientation_base')(main_body_name,
369
- mbdy_eulerang_table, n_rows, angles_in_deg, reset_orientation, mbdy_ini_rotvec_d1,
369
+ n_rows, mbdy_eulerang_table, angles_in_deg, reset_orientation, mbdy_ini_rotvec_d1,
370
370
  error_code)
371
371
 
372
+ def set_orientation_relative(self, main_body_1_name, node_1, main_body_2_name, node_2,
373
+ n_rows, mbdy2_eulerang_table, angles_in_deg,
374
+ reset_orientation,
375
+ mbdy2_ini_rotvec_d1,
376
+ error_code):
377
+ '''subroutine set_orientation_relative(main_body_1_name, node_1, main_body_2_name, node_2, &
378
+ character(kind=c_char, len=1), dimension(256), intent(in ) :: main_body_1_name ! Defined as an array of length 1 characters because of bind.
379
+ character(kind=c_char, len=1), dimension(256), intent(in ) :: main_body_2_name ! Defined as an array of length 1 characters because of bind.
380
+ integer(kind=8), intent(in ) :: node_1
381
+ integer(kind=8), intent(in ) :: node_2
382
+ real(kind=c_double), dimension(n_rows, 3), intent(in ) :: mbdy2_eulerang_table
383
+ logical, intent(in ) :: angles_in_deg
384
+ character(kind=c_char, len=256) :: mbdy_1_name ! Same as main_body_1_name, but as string instead of an array of characters.
385
+ character(kind=c_char, len=256) :: mbdy_2_name ! Same as main_body_2_name, but as string instead of an array of characters.
386
+ type(Tmain_body_input), pointer :: main_body_1 ! The main body pointer associated to main_body_1_name.
387
+ type(Tmain_body_input), pointer :: main_body_2 ! The main body pointer associated to main_body_1_name.
388
+ integer(kind=4) :: node_1_local, node_2_local ! Internal copy of node_1 and node_2.
389
+ real*8, dimension(3) :: eulerang ! Euler angles associated to 1 row of mbdy2_eulerang_table.
390
+ end subroutine'''
391
+ return self.get_lib_function('set_orientation_relative')(main_body_1_name, node_1, main_body_2_name, node_2,
392
+ n_rows, mbdy2_eulerang_table, angles_in_deg,
393
+ reset_orientation,
394
+ mbdy2_ini_rotvec_d1,
395
+ error_code)
396
+
372
397
  def set_variable_sensor_value(self, id, value):
373
398
  '''subroutine set_variable_sensor_value(id, value) bind(C, name="set_variable_sensor_value")
374
399
  integer*8, intent(in) :: id
@@ -426,6 +451,12 @@ end subroutine'''
426
451
  end function'''
427
452
  return self.get_lib_function('step')(restype=restype)
428
453
 
454
+ def stop_on_error(self, flag):
455
+ '''subroutine stop_on_error(flag) bind(C, name="stop_on_error")
456
+ logical, intent(in) :: flag
457
+ end subroutine'''
458
+ return self.get_lib_function('stop_on_error')(flag)
459
+
429
460
  def test_hdf5(self, ):
430
461
  '''subroutine test_hdf5() BIND(C, NAME='test_hdf5')
431
462
  !DEC$ ATTRIBUTES DLLEXPORT :: test_hdf5
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: h2lib
3
- Version: 13.1.901
4
- Summary: Python interface to HAWC2 (13.1.9+5-g2026dd7)
3
+ Version: 13.1.1701
4
+ Summary: Python interface to HAWC2 (13.1.17)
5
5
  Download-URL:
6
6
  Author: Mads M. Pedersen, S.G.Horcas and N.G.Ramos
7
7
  Author-email: mmpe@dtu.dk
@@ -11,11 +11,10 @@ Project-URL: Documentation, https://hawc2.pages.windenergy.dtu.dk/HAWC2Lib/
11
11
  Project-URL: Source, https://gitlab.windenergy.dtu.dk/HAWC2/HAWC2Lib
12
12
  Project-URL: Tracker, https://gitlab.windenergy.dtu.dk/HAWC2/HAWC2Lib/-/issues
13
13
  Requires-Dist: numpy
14
- Requires-Dist: intel-fortran-rt ==2021.3.0
15
- Requires-Dist: mkl ==2021.3.0
16
- Requires-Dist: multiclass-interface >=1.5
17
- Provides-Extra: mpi
18
- Requires-Dist: mpi4py ; extra == 'mpi'
14
+ Requires-Dist: intel-fortran-rt==2021.3.0
15
+ Requires-Dist: mkl==2021.3.0
16
+ Requires-Dist: multiclass_interface>=1.5
19
17
  Provides-Extra: test
20
- Requires-Dist: h2lib-tests ; extra == 'test'
21
-
18
+ Requires-Dist: h2lib_tests; extra == "test"
19
+ Provides-Extra: mpi
20
+ Requires-Dist: mpi4py; extra == "mpi"
@@ -0,0 +1,10 @@
1
+ h2lib/HAWC2Lib.dll,sha256=2f3ye1UAvxStkuQdfZ45KsPuWatlk6OKQIRGFRM-qD4,30801920
2
+ h2lib/__init__.py,sha256=f3fO4I6IEFRM9LaV2O3w9Pioj3GPI8qRl7P5Tg5ONtE,528
3
+ h2lib/_h2lib.py,sha256=oCWMTpkui3KIxuZrQcyecBAv-KBKx0exTf3UC1WTJzc,35053
4
+ h2lib/_version.py,sha256=aoq7oNXs_pDNUhj3g7OPtlrQRPyElXusqp2iqfeyvps,149
5
+ h2lib/dll_wrapper.py,sha256=CfuRfDPEmmfYlEGKUmiXiuMhNiMcf24ripPHgqd8CiE,12761
6
+ h2lib/h2lib_signatures.py,sha256=1CuaSNfaTgnbhqcSaehQGNVHhKpvLFwgs2UucKWVQJE,24289
7
+ h2lib-13.1.1701.dist-info/METADATA,sha256=LiH31EtB7-lMnREX8IcRQ3Sj1V7F5HhJJ8W_yEjiF7s,722
8
+ h2lib-13.1.1701.dist-info/WHEEL,sha256=pWXrJbnZSH-J-PhYmKs2XNn4DHCPNBYq965vsBJBFvA,101
9
+ h2lib-13.1.1701.dist-info/top_level.txt,sha256=y_a-tUqphEZQ_0nsWSMaSb21P8Lsd8hUxUdE9g2Dcbk,6
10
+ h2lib-13.1.1701.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.2.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp312-cp312-win_amd64
5
5
 
@@ -1,10 +0,0 @@
1
- h2lib/HAWC2Lib.dll,sha256=sIZhsbsubvdSV1FYMFwm3o182LX443SmME3ak8QwLWM,30803968
2
- h2lib/__init__.py,sha256=f3fO4I6IEFRM9LaV2O3w9Pioj3GPI8qRl7P5Tg5ONtE,528
3
- h2lib/_h2lib.py,sha256=povKoDnyzYF2xET29CxkBYKSYJc5yRjn7J4Xdw8qTow,30363
4
- h2lib/_version.py,sha256=36To1Vn7m9W0-ewELpaoXNd4wDAXEYhnaDUyBw5QI-k,157
5
- h2lib/dll_wrapper.py,sha256=CfuRfDPEmmfYlEGKUmiXiuMhNiMcf24ripPHgqd8CiE,12761
6
- h2lib/h2lib_signatures.py,sha256=BknUitXekKaOH9reEHDnBPN-ThAHFeHnfdD41UlJ8Y8,21780
7
- h2lib-13.1.901.dist-info/METADATA,sha256=IEbAB9rC-p8IT1nmtagD7xSRUhaY0l7vAZNYqeZg5_U,738
8
- h2lib-13.1.901.dist-info/WHEEL,sha256=62QJgqtUFevqILau0n0UncooEMoOyVCKVQitJpcuCig,101
9
- h2lib-13.1.901.dist-info/top_level.txt,sha256=y_a-tUqphEZQ_0nsWSMaSb21P8Lsd8hUxUdE9g2Dcbk,6
10
- h2lib-13.1.901.dist-info/RECORD,,