h2lib 13.2.702__py3-none-win_amd64.whl → 13.2.901__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
@@ -22,6 +22,7 @@ _ERROR_CODES = {
22
22
  300: ValueError("TOO_FEW_SECTIONS_IN_C2DEF"),
23
23
  301: ValueError("BEAM_TOO_SHORT"),
24
24
  302: ValueError("DIFFERENT_NSEC"),
25
+ 400: ValueError("ST_Z_NOT_CONTINUOUSLY_INCREASING"),
25
26
  500: ValueError("RELATIVE_ROTATION_NOT_FOUND"),
26
27
  700: RuntimeError("SYSTEM_NOT_LINEARIZED"),
27
28
  701: RuntimeError("SYSTEM_EIGENANALYSIS_NOT_DONE"),
@@ -65,25 +66,25 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
65
66
 
66
67
  def close(self):
67
68
  if self._initialized:
68
- self.write_output()
69
- self.finalize()
69
+ self._write_output()
70
+ self._finalize()
70
71
  DLLWrapper.close(self)
71
72
  return "closed h2lib"
72
73
 
73
74
  def getState(self):
74
- return H2LibSignatures.getState(self, restype=np.int32)[1]
75
+ return H2LibSignatures._getState(self, restype=np.int32)[1]
75
76
 
76
77
  def work(self, time):
77
78
  """Return number of loops"""
78
- return H2LibSignatures.work(self, np.float64(time), restype=np.int64)[1]
79
+ return H2LibSignatures._work(self, np.float64(time), restype=np.int64)[1]
79
80
 
80
81
  def loop(self, N):
81
82
  """Return time to compute N loops"""
82
- return H2LibSignatures.loop(self, int(N), restype=np.float64)[1]
83
+ return H2LibSignatures._loop(self, int(N), restype=np.float64)[1]
83
84
 
84
85
  def get_version(self):
85
86
  s = " " * 255
86
- return H2LibSignatures.get_version(self, s)[0][0].strip()
87
+ return H2LibSignatures._get_version(self, s)[0][0].strip()
87
88
 
88
89
  def stop_on_error(self, flag):
89
90
  """
@@ -100,7 +101,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
100
101
  None.
101
102
 
102
103
  """
103
- H2LibSignatures.stop_on_error(self, bool(flag))
104
+ H2LibSignatures._stop_on_error(self, bool(flag))
104
105
 
105
106
  def get_wind_speed(self, pos_g):
106
107
  return self.get_lib_function('get_wind_speed')(np.asfortranarray(pos_g, dtype=np.float64),
@@ -111,18 +112,18 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
111
112
  return [vy, vx, -vz]
112
113
 
113
114
  def get_time(self):
114
- return np.round(H2LibSignatures.get_time(self, time=0.)[0][0], 6)
115
+ return np.round(H2LibSignatures._get_time(self, time=0.)[0][0], 6)
115
116
 
116
117
  def read_input(self, htc_path, model_path='.'):
117
118
  if htc_path is not None:
118
119
  self._model_path = model_path
119
120
  self.cwd = self.model_path
120
- return H2LibSignatures.read_input(self, htc_path)
121
+ return H2LibSignatures._read_input(self, htc_path)
121
122
 
122
123
  def init(self, htc_path=None, model_path='.'):
123
124
  assert not self._initialized, "h2lib already initialized via init, init_AD or init_AL"
124
125
  self.read_input(htc_path, model_path)
125
- r = H2LibSignatures.init(self)
126
+ r = H2LibSignatures._init(self)
126
127
  self._initialized = True
127
128
  return r
128
129
 
@@ -139,8 +140,8 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
139
140
  """
140
141
  assert not self._initialized, "h2lib already initialized via init, init_AD or init_AL"
141
142
  self.read_input(htc_path, model_path)
142
- r = H2LibSignatures.init_AD(self, rotor + 1, int(tiploss_method),
143
- float(tiploss2_shen_c2), float(tiploss2_shen_h))
143
+ r = H2LibSignatures._init_AD(self, rotor + 1, int(tiploss_method),
144
+ float(tiploss2_shen_c2), float(tiploss2_shen_h))
144
145
  self._initialized = True
145
146
  return r
146
147
 
@@ -158,12 +159,12 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
158
159
  """
159
160
  assert not self._initialized, "h2lib already initialized via init, init_AD or init_AL"
160
161
  self.read_input(htc_path, model_path)
161
- r = H2LibSignatures.init_AL(self, rotor=rotor + 1, epsilon_smearing=float(epsilon_smearing))
162
+ r = H2LibSignatures._init_AL(self, rotor=rotor + 1, epsilon_smearing=float(epsilon_smearing))
162
163
  self._initialized = True
163
164
  return r
164
165
 
165
166
  def step(self):
166
- self.time = np.round(H2LibSignatures.step(self, restype=np.float64)[1], 6)
167
+ self.time = np.round(H2LibSignatures._step(self, restype=np.float64)[1], 6)
167
168
  return self.time
168
169
 
169
170
  def predict(self): # pragma: no cover
@@ -175,7 +176,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
175
176
  self.get_lib_function('step_correct_hawc2')()
176
177
 
177
178
  def run(self, time):
178
- self.time = np.round(H2LibSignatures.run(self, np.float64(time), restype=np.float64)[1], 6)
179
+ self.time = np.round(H2LibSignatures._run(self, np.float64(time), restype=np.float64)[1], 6)
179
180
  return self.time
180
181
 
181
182
  def check_convergence(self):
@@ -197,7 +198,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
197
198
  resq = -1.0
198
199
  resg = -1.0
199
200
  resd = -1.0
200
- bconv, resq, resg, resd = H2LibSignatures.check_convergence(self, bconv, resq, resg, resd)[0]
201
+ bconv, resq, resg, resd = H2LibSignatures._check_convergence(self, bconv, resq, resg, resd)[0]
201
202
  return bconv, resq, resg, resd
202
203
 
203
204
  def linearize(self):
@@ -214,7 +215,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
214
215
  """
215
216
  n_tdofs = -1
216
217
  n_rdofs = -1
217
- res = H2LibSignatures.linearize(self, n_tdofs, n_rdofs)[0]
218
+ res = H2LibSignatures._linearize(self, n_tdofs, n_rdofs)[0]
218
219
  return res
219
220
 
220
221
  def do_system_eigenanalysis(self, n_modes, include_damping=True):
@@ -249,7 +250,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
249
250
  error_code = -1
250
251
 
251
252
  _, _, natural_frequencies, damping_ratios, error_code = (
252
- H2LibSignatures.do_system_eigenanalysis(
253
+ H2LibSignatures._do_system_eigenanalysis(
253
254
  self,
254
255
  include_damping,
255
256
  n_modes,
@@ -304,11 +305,11 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
304
305
  if include_damping:
305
306
  ny = 2 * n_rdofs
306
307
  dtype = np.complex128
307
- f = H2LibSignatures.get_system_eigval_eigvec_with_damping
308
+ f = H2LibSignatures._get_system_eigval_eigvec_with_damping
308
309
  else:
309
310
  ny = n_rdofs
310
311
  dtype = np.float64
311
- f = H2LibSignatures.get_system_eigval_eigvec_without_damping
312
+ f = H2LibSignatures._get_system_eigval_eigvec_without_damping
312
313
 
313
314
  error_code = -1
314
315
  eigenvalues = np.zeros((n_modes,), dtype=dtype, order="F")
@@ -337,7 +338,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
337
338
  None.
338
339
 
339
340
  """
340
- H2LibSignatures.solver_static_init(self)
341
+ H2LibSignatures._solver_static_init(self)
341
342
 
342
343
  def solver_static_update(self):
343
344
  """
@@ -354,7 +355,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
354
355
 
355
356
  """
356
357
  error_code = -1
357
- error_code = H2LibSignatures.solver_static_update(self, error_code)[0][0]
358
+ error_code = H2LibSignatures._solver_static_update(self, error_code)[0][0]
358
359
  if error_code > 0:
359
360
  raise _ERROR_CODES[error_code]
360
361
 
@@ -373,7 +374,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
373
374
 
374
375
  """
375
376
  error_code = -1
376
- error_code = H2LibSignatures.solver_static_solve(self, error_code)[0][0]
377
+ error_code = H2LibSignatures._solver_static_solve(self, error_code)[0][0]
377
378
  if error_code > 0:
378
379
  raise _ERROR_CODES[error_code]
379
380
 
@@ -386,7 +387,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
386
387
  None.
387
388
 
388
389
  """
389
- H2LibSignatures.solver_static_delete(self)
390
+ H2LibSignatures._solver_static_delete(self)
390
391
 
391
392
  def solver_static_run(self, reset_structure=False):
392
393
  """
@@ -416,13 +417,13 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
416
417
 
417
418
  """
418
419
  error_code = -1
419
- _, error_code = H2LibSignatures.solver_static_run(self, reset_structure, error_code, check_stop=False)[0]
420
+ _, error_code = H2LibSignatures._solver_static_run(self, reset_structure, error_code, check_stop=False)[0]
420
421
  if error_code > 0:
421
422
  raise _ERROR_CODES[error_code]
422
423
 
423
424
  def structure_reset(self):
424
425
  """Reset the structure deflection and orientation."""
425
- H2LibSignatures.structure_reset(self)
426
+ H2LibSignatures._structure_reset(self)
426
427
 
427
428
  def add_sensor(self, sensor_line):
428
429
  """Add sensor to hawc2. The sensor will be accessible from h2lib but will not show up in the output file of HAWC2
@@ -441,7 +442,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
441
442
  if ";" not in sensor_line:
442
443
  sensor_line += ";"
443
444
  index_start, index_stop = 0, 0
444
- index_start, index_stop = H2LibSignatures.add_sensor(self, sensor_line.lower(), index_start, index_stop)[0][1:]
445
+ index_start, index_stop = H2LibSignatures._add_sensor(self, sensor_line.lower(), index_start, index_stop)[0][1:]
445
446
  return tuple(range(index_start, index_stop + 1))
446
447
 
447
448
  def get_sensor_info(self, id):
@@ -449,7 +450,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
449
450
  if isinstance(id, tuple):
450
451
  return [self.get_sensor_info(i) for i in id]
451
452
  return [s[:-1].strip() # remove null termination
452
- for s in H2LibSignatures.get_sensor_info(self, id, name=" " * 30, unit=" " * 10, desc=" " * 512)[0][1:]]
453
+ for s in H2LibSignatures._get_sensor_info(self, id, name=" " * 30, unit=" " * 10, desc=" " * 512)[0][1:]]
453
454
 
454
455
  def get_sensor_values(self, id_lst):
455
456
  """Get sensor values from HAWC2
@@ -467,10 +468,10 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
467
468
  return self.get_sensor_values([id_lst])[0]
468
469
  values = np.zeros(len(id_lst), dtype=np.float64)
469
470
  id_lst = np.array(id_lst, dtype=np.int64)
470
- return H2LibSignatures.get_sensor_values(self, id_lst, values, len(id_lst))[0][1]
471
+ return H2LibSignatures._get_sensor_values(self, id_lst, values, len(id_lst))[0][1]
471
472
 
472
473
  def set_variable_sensor_value(self, id, value):
473
- return H2LibSignatures.set_variable_sensor_value(self, id, np.float64(value))
474
+ return H2LibSignatures._set_variable_sensor_value(self, id, np.float64(value))
474
475
 
475
476
  def set_orientation_base(
476
477
  self,
@@ -528,7 +529,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
528
529
  # 1D arrays are converted to 2D with 1 row.
529
530
  mbdy_eulerang_table = np.atleast_2d(mbdy_eulerang_table)
530
531
  error_code = -1
531
- error_code = H2LibSignatures.set_orientation_base(
532
+ error_code = H2LibSignatures._set_orientation_base(
532
533
  self,
533
534
  main_body,
534
535
  mbdy_eulerang_table.shape[0],
@@ -618,7 +619,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
618
619
  if node_2 == "last":
619
620
  node_2 = -2
620
621
  error_code = -1
621
- error_code = H2LibSignatures.set_orientation_relative(
622
+ error_code = H2LibSignatures._set_orientation_relative(
622
623
  self,
623
624
  main_body_1,
624
625
  node_1 + 1,
@@ -669,8 +670,8 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
669
670
  repeated in the longitudinal direction
670
671
 
671
672
  """
672
- return H2LibSignatures.init_windfield(self, np.array(Nxyz, dtype=np.int64), np.array(dxyz, dtype=np.float64),
673
- np.array(box_offset_yz, dtype=np.float64), np.float64(transport_speed))
673
+ return H2LibSignatures._init_windfield(self, np.array(Nxyz, dtype=np.int64), np.array(dxyz, dtype=np.float64),
674
+ np.array(box_offset_yz, dtype=np.float64), np.float64(transport_speed))
674
675
 
675
676
  def set_windfield(self, uvw, box_offset_x, time=None):
676
677
  """Set wind field, must be called after init_windfield and init
@@ -699,32 +700,39 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
699
700
  time = self.get_time()
700
701
  uvw = np.asfortranarray(uvw, dtype=np.float32)
701
702
  assert np.all(np.isfinite(uvw)), "uvw passed to h2lib.set_windfield contains nan or inf"
702
- return H2LibSignatures.set_windfield(self, uvw, np.float64(box_offset_x), np.float64(time))
703
+ return H2LibSignatures._set_windfield(self, uvw, np.float64(box_offset_x), np.float64(time))
703
704
 
704
705
  def set_c2_def(
705
- self, main_body_name, c2_def, twist_in_deg=True, check_length=True
706
+ self, main_body_nr, c2_def, twist_in_deg=True, check_length=True, update_structure=True
706
707
  ):
707
708
  """
708
- Set c2_def, which defines the centerline of the specified main body.
709
+ Set `c2_def` or `cx_def` for the specified main body.
709
710
 
710
711
  Parameters
711
712
  ----------
712
- main_body_name : str
713
- Name of main body that must be updated.
714
- c2_def : (:, 4) ndarray
715
- New c2_def. It is an array with at least 2 rows and 4 columns for x, y, z and twist.
713
+ main_body_nr : int
714
+ Number of main body that must be updated.
715
+ The mapping between main body name and number can be obtained with `get_mainbody_name_dict`.
716
+ c2_def : (:, 4) or (:, 5) ndarray
717
+ New c2_def/cx_def. It is an array with at least 2 rows and 4 columns for x, y, z and twist.
718
+ Optionally, the 5th column can be used for dx (default is 0.)
716
719
  The number of rows, i.e. sections, must match the ones in the original c2_def.
717
720
  twist_in_deg : bool, optional
718
721
  `True` if the twist (last column in c2_def) is given in [deg].
719
722
  `False` if it is given in [rad]. The default is `True`.
720
723
  check_length : bool, optional
721
724
  `True` if the new beam length needs to be checked, `False` otherwise. The default is `False`.
725
+ update_structure : bool, optional
726
+ If `True` (default) triggers the recomputation of the element matrices, constraints and so on.
727
+ It is required for the changes to c2_def to take effect. If the user updates both c2_def/cx_def
728
+ and st, only 1 structure update is required.
722
729
 
723
730
  Raises
724
731
  ------
725
732
  ValueError
726
733
  Can be due to:
727
734
  - MAIN_BODY_NOT_FOUND: none of the main bodies is called `main_body_name`.
735
+ - WRONG_NUMBER_OF_COLUMNS: cx_def must have 4 or 5 columns.
728
736
  - TOO_FEW_SECTIONS_IN_C2DEF: `c2_def` must have at least 2 sections, i.e. rows.
729
737
  - BEAM_TOO_SHORT: the minimum beam length is 1.0e-7.
730
738
  - DIFFERENT_NSEC: this command does not allow to add or remove sections,
@@ -738,13 +746,15 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
738
746
 
739
747
  """
740
748
  error_code = -1
741
- error_code = H2LibSignatures.set_c2_def(
749
+ error_code = H2LibSignatures._set_cx_def(
742
750
  self,
743
- main_body_name,
744
- np.asfortranarray(c2_def.astype(np.float64)),
751
+ main_body_nr,
745
752
  c2_def.shape[0],
753
+ c2_def.shape[1],
754
+ np.asfortranarray(c2_def, dtype=np.float64),
746
755
  bool(twist_in_deg),
747
756
  bool(check_length),
757
+ bool(update_structure),
748
758
  error_code,
749
759
  check_stop=False,
750
760
  )[0][-1]
@@ -752,6 +762,55 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
752
762
  if error_code > 0:
753
763
  raise _ERROR_CODES[error_code]
754
764
 
765
+ def set_st(
766
+ self, main_body_nr, st, update_structure=True
767
+ ):
768
+ """
769
+ Set STructural data for the specified main body.
770
+
771
+ Parameters
772
+ ----------
773
+ main_body_nr : int
774
+ Number of main body that must be updated.
775
+ The mapping between main body name and number can be obtained with `get_mainbody_name_dict`.
776
+ st : (:, :) ndarray
777
+ New ST. It is an array with an arbitrary number of rows and 19 or 30 columns.
778
+ Both the classical Timoshenko and the FPM model are supported.
779
+ update_structure : bool, optional
780
+ If `True` (default) triggers the recomputation of the element matrices, constraints and so on.
781
+ It is required for the changes to st to take effect. If the user updates both c2_def/cx_def
782
+ and st, only 1 structure update is required.
783
+
784
+ Raises
785
+ ------
786
+ ValueError
787
+ Can be due to:
788
+ - MAIN_BODY_NOT_FOUND: none of the main bodies is called `main_body_name`.
789
+ - WRONG_NUMBER_OF_COLUMNS: `st` must have 19 or 30 columns.
790
+ - ST_Z_NOT_CONTINUOUSLY_INCREASING: The z coordinate must always increase.
791
+ NotImplementedError
792
+ Only the c2_def node distribution is supported.
793
+
794
+ Returns
795
+ -------
796
+ None.
797
+
798
+ """
799
+ error_code = -1
800
+ error_code = H2LibSignatures._set_st(
801
+ self,
802
+ main_body_nr,
803
+ st.shape[0],
804
+ st.shape[1],
805
+ np.asfortranarray(st, dtype=np.float64),
806
+ bool(update_structure),
807
+ error_code,
808
+ check_stop=False,
809
+ )[0][-1]
810
+ self.initialize_distributed_sections()
811
+ if error_code > 0:
812
+ raise _ERROR_CODES[error_code]
813
+
755
814
  # ===================================================================================================================
756
815
  # H2rotor
757
816
  # ===================================================================================================================
@@ -761,16 +820,16 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
761
820
  for r in range(self.get_nrotors())]
762
821
 
763
822
  def get_nrotors(self):
764
- return H2LibSignatures.get_nrotors(self, restype=np.int64)[1]
823
+ return H2LibSignatures._get_nrotors(self, restype=np.int64)[1]
765
824
 
766
825
  def get_nblades(self, rotor=0):
767
- return H2LibSignatures.get_nblades(self, rotor + 1, restype=np.int64)[1]
826
+ return H2LibSignatures._get_nblades(self, rotor + 1, restype=np.int64)[1]
768
827
 
769
828
  def get_nSections(self, rotor=0, blade=0):
770
- return H2LibSignatures.get_nSections(self, rotor + 1, blade + 1, restype=np.int64)[1]
829
+ return H2LibSignatures._get_nSections(self, rotor + 1, blade + 1, restype=np.int64)[1]
771
830
 
772
831
  def get_diameter(self, rotor=0):
773
- return H2LibSignatures.get_diameter(self, rotor + 1, restype=np.float64)[1]
832
+ return H2LibSignatures._get_diameter(self, rotor + 1, restype=np.float64)[1]
774
833
 
775
834
  def aero_sections_data_shape(self, rotor):
776
835
  if rotor not in self._aero_sections_data_shape:
@@ -780,63 +839,63 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
780
839
  def get_aerosections_position(self, rotor=0):
781
840
  """Global xyz position of aero sections. Shape=(#blades, #sections, 3)"""
782
841
  position = np.zeros(self.aero_sections_data_shape(rotor), dtype=np.float64, order='F')
783
- return H2LibSignatures.get_aerosections_position(self, rotor + 1, position)[0][1]
842
+ return H2LibSignatures._get_aerosections_position(self, rotor + 1, position)[0][1]
784
843
 
785
844
  def set_aerosections_windspeed(self, uvw, rotor=0):
786
845
  """Update wind speed at aero sections. uvw shape=(#blades, #sections, 3)"""
787
- return H2LibSignatures.set_aerosections_windspeed(self, rotor + 1, np.asfortranarray(uvw, np.float64))
846
+ return H2LibSignatures._set_aerosections_windspeed(self, rotor + 1, np.asfortranarray(uvw, np.float64))
788
847
 
789
848
  def get_aerosections_forces(self, rotor=0):
790
849
  shape = self.aero_sections_data_shape(rotor)
791
850
  Fxyz = np.zeros(shape, dtype=np.float64, order='F')
792
- return H2LibSignatures.get_aerosections_forces(self, rotor + 1, Fxyz)[0][1]
851
+ return H2LibSignatures._get_aerosections_forces(self, rotor + 1, Fxyz)[0][1]
793
852
 
794
853
  def get_aerosections_moments(self, rotor=0):
795
854
  shape = self.aero_sections_data_shape(rotor)
796
855
  Mxyz = np.zeros(shape, dtype=np.float64, order='F')
797
- return H2LibSignatures.get_aerosections_moments(self, rotor + 1, Mxyz)[0][1]
856
+ return H2LibSignatures._get_aerosections_moments(self, rotor + 1, Mxyz)[0][1]
798
857
 
799
858
  def get_bem_grid_dim(self, rotor=0):
800
859
  """returns (nazi, nrad)"""
801
- return H2LibSignatures.get_bem_grid_dim(self, rotor + 1, 0, 0)[0][1:]
860
+ return H2LibSignatures._get_bem_grid_dim(self, rotor + 1, 0, 0)[0][1:]
802
861
 
803
862
  def get_bem_grid(self, rotor=0):
804
863
  """returns azi, rad"""
805
864
  nazi, nrad = self.get_bem_grid_dim(rotor)
806
- return H2LibSignatures.get_bem_grid(self, rotor + 1,
807
- np.zeros(nazi, dtype=np.float64, order='F'),
808
- np.zeros(nrad, dtype=np.float64, order='F'))[0][1:]
865
+ return H2LibSignatures._get_bem_grid(self, rotor + 1,
866
+ np.zeros(nazi, dtype=np.float64, order='F'),
867
+ np.zeros(nrad, dtype=np.float64, order='F'))[0][1:]
809
868
 
810
869
  def get_induction_polargrid(self, rotor=0):
811
870
  nazi, nrad = self.get_bem_grid_dim(rotor)
812
871
  induction = np.zeros((nazi, nrad), dtype=np.float64, order='F')
813
- return H2LibSignatures.get_induction_polargrid(self, rotor + 1, induction)[0][1]
872
+ return H2LibSignatures._get_induction_polargrid(self, rotor + 1, induction)[0][1]
814
873
 
815
874
  def get_induction_axisymmetric(self, rotor=0):
816
875
  nrad = self.get_bem_grid_dim(rotor)[1]
817
876
  induction = np.zeros(nrad, dtype=np.float64)
818
- return H2LibSignatures.get_induction_axisymmetric(self, rotor + 1, induction)[0][1]
877
+ return H2LibSignatures._get_induction_axisymmetric(self, rotor + 1, induction)[0][1]
819
878
 
820
879
  def get_induction_rotoravg(self, rotor=0):
821
880
  induction = np.float64(0)
822
- return H2LibSignatures.get_induction_rotoravg(self, rotor + 1, induction)[0][1]
881
+ return H2LibSignatures._get_induction_rotoravg(self, rotor + 1, induction)[0][1]
823
882
 
824
883
  def get_rotor_orientation(self, rotor=0, deg=False):
825
884
  """return yaw, tilt, azi(of first blade) in rad(default) or deg"""
826
- r = H2LibSignatures.get_rotor_orientation(self, rotor=rotor + 1, yaw=0., tilt=0., azi=0.)[0][1:]
885
+ r = H2LibSignatures._get_rotor_orientation(self, rotor=rotor + 1, yaw=0., tilt=0., azi=0.)[0][1:]
827
886
  if deg:
828
887
  return np.rad2deg(r)
829
888
  else:
830
889
  return r
831
890
 
832
891
  def get_rotor_position(self, rotor=0):
833
- return H2LibSignatures.get_rotor_position(self, rotor=rotor + 1, position=np.zeros(3, dtype=np.float64))[0][1]
892
+ return H2LibSignatures._get_rotor_position(self, rotor=rotor + 1, position=np.zeros(3, dtype=np.float64))[0][1]
834
893
 
835
894
  def get_rotor_avg_wsp(self, coo=1, rotor=0):
836
895
  """Returns the rotor averaged wind speed in global(coo=1, default) or rotor(coo=2) coordinates."""
837
896
  assert self.time > 0
838
897
  wsp = np.zeros(3, dtype=np.float64)
839
- return H2LibSignatures.get_rotor_avg_wsp(self, coo=coo, rotor=rotor + 1, wsp=wsp)[0][2]
898
+ return H2LibSignatures._get_rotor_avg_wsp(self, coo=coo, rotor=rotor + 1, wsp=wsp)[0][2]
840
899
 
841
900
  def get_rotor_avg_uvw(self, rotor=0):
842
901
  vx, vy, vz = self.get_rotor_avg_wsp(1, rotor)
@@ -866,7 +925,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
866
925
  nbdy,
867
926
  ncst,
868
927
  error_code,
869
- ) = H2LibSignatures.get_number_of_bodies_and_constraints(
928
+ ) = H2LibSignatures._get_number_of_bodies_and_constraints(
870
929
  self, nbdy, ncst, error_code, check_stop=False
871
930
  )[
872
931
  0
@@ -894,7 +953,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
894
953
 
895
954
  nelem = np.zeros((nbdy, ), dtype=np.int64, order="F")
896
955
  error_code = -1
897
- _, nelem, error_code = H2LibSignatures.get_number_of_elements(
956
+ _, nelem, error_code = H2LibSignatures._get_number_of_elements(
898
957
  self, nbdy, nelem, error_code, check_stop=False
899
958
  )[0]
900
959
 
@@ -947,7 +1006,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
947
1006
  r12,
948
1007
  tes,
949
1008
  error_code,
950
- ) = H2LibSignatures.get_timoshenko_location(
1009
+ ) = H2LibSignatures._get_timoshenko_location(
951
1010
  self, ibdy + 1, ielem + 1, l, r1, r12, tes, error_code, check_stop=False)[0]
952
1011
  if error_code > 0:
953
1012
  raise _ERROR_CODES[error_code]
@@ -977,7 +1036,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
977
1036
  """
978
1037
  amat = np.zeros((3, 3), order="F")
979
1038
  error_code = -1
980
- _, amat, error_code = H2LibSignatures.get_body_rotation_tensor(
1039
+ _, amat, error_code = H2LibSignatures._get_body_rotation_tensor(
981
1040
  self, ibdy + 1, amat, error_code, check_stop=False)[0]
982
1041
  if error_code > 0:
983
1042
  raise _ERROR_CODES[error_code]
@@ -1017,7 +1076,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
1017
1076
  error_code = -1
1018
1077
 
1019
1078
  _, body_mass, body_inertia, cog_global_frame, cog_body_frame, error_code = (
1020
- H2LibSignatures.body_output_mass(
1079
+ H2LibSignatures._body_output_mass(
1021
1080
  self,
1022
1081
  ibdy + 1,
1023
1082
  body_mass,
@@ -1063,7 +1122,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
1063
1122
  stiffness = np.zeros_like(mass)
1064
1123
  damping = np.zeros_like(mass)
1065
1124
  error_code = -1
1066
- _, _, mass, stiffness, damping, error_code = H2LibSignatures.body_output_element(
1125
+ _, _, mass, stiffness, damping, error_code = H2LibSignatures._body_output_element(
1067
1126
  self,
1068
1127
  ibdy + 1,
1069
1128
  ielem + 1,
@@ -1115,7 +1174,7 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
1115
1174
  R = np.zeros((n_tdofs, n_rdofs), dtype=np.float64, order="F")
1116
1175
  error_code = -1
1117
1176
 
1118
- _, _, M, C, K, R, error_code = H2LibSignatures.get_system_matrices(
1177
+ _, _, M, C, K, R, error_code = H2LibSignatures._get_system_matrices(
1119
1178
  self, n_tdofs, n_rdofs, M, C, K, R, error_code, check_stop=False)[0]
1120
1179
 
1121
1180
  if error_code > 0:
@@ -1123,19 +1182,48 @@ class H2LibThread(DLLWrapper, H2Lib_DistributedSections, H2LibSignatures):
1123
1182
  return M, C, K, R
1124
1183
 
1125
1184
  def get_no_mainbodies(self):
1126
- return H2LibSignatures.get_number_of_mainbodies(self, restype=np.int64)[1]
1185
+ return H2LibSignatures._get_number_of_mainbodies(self, restype=np.int64)[1]
1127
1186
 
1128
1187
  def get_mainbody_name_dict(self):
1129
1188
  s = " " * 256
1130
- return {H2LibSignatures.get_mainbody_name(self, mainbody_nr=int(i), mainbody_name=s)[0][1].strip(): i
1131
- for i in np.arange(self.get_no_mainbodies()) + 1}
1189
+ return {H2LibSignatures._get_mainbody_name(self, mainbody_nr=int(i), mainbody_name=s)[0][1].strip(): i
1190
+ for i in np.arange(1, self.get_no_mainbodies() + 1)}
1132
1191
 
1133
1192
  def get_mainbody_position_orientation(self, mainbody_nr, mainbody_coo_nr=0):
1134
1193
  mbdy_pos = np.zeros(3, dtype=np.float64, order="F")
1135
1194
  mbdy_tbg = np.zeros((3, 3), dtype=np.float64, order="F")
1136
- return H2Lib_DistributedSections.get_mainbody_position_orientation(
1195
+ return H2LibSignatures._get_mainbody_position_orientation(
1137
1196
  self, int(mainbody_nr), mbdy_pos, mbdy_tbg, int(mainbody_coo_nr))[0][1:-1]
1138
1197
 
1198
+ def get_mainbody_nodes_state(self, mainbody_nr, state, mainbody_coo_nr=0):
1199
+ """Return the state (pos, vel or acc) of mainbody nodes
1200
+ Note, the state refers to the structural nodes at the elastic axis
1201
+
1202
+ Parameters
1203
+ ----------
1204
+ mainbody_nr : int
1205
+ Index of mainbody (can be obtained from get_mainbody_name_dict())
1206
+ state : {'pos','vel','acc'}
1207
+ state type (position, velocity, acceleration) to compute
1208
+ mainbody_coo_nr : int, optional
1209
+ Specifies the coodinate system of the returned position and orientation.
1210
+ If 0 (default), the output is in global coordinates
1211
+ Otherwise the output is transformed to the coordinate system of the mainbody with the specified index.
1212
+ The index can be obtained from get_mainbody_name_dict
1213
+
1214
+
1215
+ Returns
1216
+ -------
1217
+ state : array_like
1218
+ state data shape=(no_nodes,3) containing the (x,y,z) position, velocity or acceleration of the nodes
1219
+
1220
+ """
1221
+ state = ['pos', 'vel', 'acc'].index(state) + 1
1222
+ nnodes = H2LibSignatures._get_mainbody_nnodes(self, int(mainbody_nr), restype=int)[1]
1223
+ nodes_state = np.zeros((nnodes, 3), dtype=np.float64, order="F")
1224
+ return H2LibSignatures._get_mainbody_nodes_state(
1225
+ self, int(mainbody_nr), int(state), int(nnodes), int(mainbody_coo_nr), nodes_state)[0][-1]
1226
+
1139
1227
 
1140
1228
  @contextmanager
1141
1229
  def set_LD_LIBRARY_PATH():
h2lib/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # This file is autogenerated and should not be modified manually
2
- __version__ = '13.2.702'
3
- h2lib_version = '13.2.702'
4
- hawc2_version = '13.2.7+4-gb779ee7'
2
+ __version__ = '13.2.901'
3
+ h2lib_version = '13.2.901'
4
+ hawc2_version = '13.2.9+4-gfd77867'