wawi 0.0.3__py3-none-any.whl → 0.0.5__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
wawi/__init__.py CHANGED
@@ -1,7 +1,7 @@
1
- __version__ = "0.0.3"
1
+ __version__ = "0.0.5"
2
2
 
3
3
  __pdoc__ = dict()
4
- __pdoc__['module.name'] = False
4
+ __pdoc__['wawi.abq'] = False
5
5
 
6
6
  # Other packages
7
7
  import numpy as np
wawi/general.py CHANGED
@@ -162,8 +162,6 @@ def merge_tr_phi(phi_trans, phi_rot, thread_stack=True):
162
162
  thread_stack: specify if the matrices should be thread in or not (if True, 3 translational DOFs and 3 rotational DOFs ...) (default = True)
163
163
  Returns:
164
164
  phi_combined: phi matrix with all DOFs
165
-
166
- AAJ / Knut Andreas Kvaale, 2017
167
165
  """
168
166
 
169
167
  Ndofs = phi_trans.shape[0]*2
@@ -204,7 +202,6 @@ def interp1z(z,mat,znew):
204
202
  Returns:
205
203
  matnew: interpolated 3D matrix (Numpy array)
206
204
 
207
- NTNU / Knut Andreas Kvaale, 2018
208
205
  """
209
206
 
210
207
  matnew = np.zeros([1,len(mat[0]),len(mat[0][0])])
@@ -226,7 +223,6 @@ def interpolate_3d(z, mat, zi):
226
223
  Returns:
227
224
  mati: interpolated matrix
228
225
 
229
- NTNU / Knut Andreas Kvaale, 2017
230
226
  """
231
227
  mat_shape = np.shape(mat)
232
228
  mati = np.zeros([mat_shape[0], mat_shape[1], len(zi)])
@@ -280,7 +276,6 @@ def rodrot(theta, rotaxis=[0, 0, 1], style='row'):
280
276
  Returns:
281
277
  T: transformation matrix in NumPy format
282
278
 
283
- NTNU / Knut Andreas Kvaale, 2017
284
279
  """
285
280
 
286
281
  axis = np.asarray(rotaxis)
wawi/io.py CHANGED
@@ -48,7 +48,7 @@ def import_folder(model_folder, pontoon_stl='pontoon.stl', aero_sections='aero_s
48
48
 
49
49
  Notes
50
50
  ---------------
51
- Add info here describing the structure and contents of all files.
51
+ TODO: Add info here describing the structure and contents of all files.
52
52
 
53
53
  See `importing-folder.ipynb` for a full example.
54
54
  '''
@@ -105,7 +105,7 @@ def import_folder(model_folder, pontoon_stl='pontoon.stl', aero_sections='aero_s
105
105
  common_ptype_settings = pontoon_type_settings.pop('*')
106
106
 
107
107
  except:
108
- print('Valid pontoon types file not found. No pontoon_types definitions applied.')
108
+ print('Valid pontoon type settings file not found. No definitions applied.')
109
109
  pontoon_type_settings = {}
110
110
 
111
111
  else:
@@ -152,22 +152,28 @@ def import_folder(model_folder, pontoon_stl='pontoon.stl', aero_sections='aero_s
152
152
 
153
153
  # Modal dry object
154
154
  if 'xi0' in modal:
155
- xi0 = np.array(modal['xi0'])
155
+ xi0 = np.array(modal.pop('xi0'))
156
156
  else:
157
157
  xi0 = 0.0
158
158
 
159
159
  if 'm_min' in modal:
160
- m_min = modal['m_min']
160
+ m_min = modal.pop('m_min')
161
161
  else:
162
162
  m_min = 0.0
163
163
 
164
164
  if 'phi_x' in modal:
165
- phi_x = modal['phi_x']
165
+ phi_x = modal.pop('phi_x')
166
166
  else:
167
167
  phi_x = None
168
-
169
- modal_dry = ModalDry(modal['phi'], m=np.array(modal['m']), k=np.array(modal['k']),
170
- local_phi=modal['local'], xi0=xi0, phi_x=phi_x, m_min=m_min)
168
+
169
+ if 'local' in modal:
170
+ local_phi = modal.pop('local')
171
+ else:
172
+ local_phi = False
173
+
174
+ phi = modal.pop('phi')
175
+
176
+ modal_dry = ModalDry(phi, xi0=xi0, local_phi=local_phi, phi_x=phi_x, m_min=m_min, **modal)
171
177
 
172
178
  # Element definition
173
179
  if element_data != {}:
@@ -184,7 +190,25 @@ def import_folder(model_folder, pontoon_stl='pontoon.stl', aero_sections='aero_s
184
190
  node_matrix = np.array(element_data['node_matrix'])
185
191
  node_matrix[:,0] = node_matrix[:,0].astype(int)
186
192
  element_matrix = np.array(element_data['element_matrix'])
187
-
193
+ element_matrix = element_matrix.astype(int)
194
+
195
+ # Remove elements without valid nodes
196
+ remove_ix = []
197
+ remove_els = []
198
+
199
+ for ix,row in enumerate(element_matrix):
200
+ el,node1,node2 = row
201
+ # print(row)
202
+
203
+ if (node1 not in node_matrix[:,0].astype(int)) or (node2 not in node_matrix[:,0].astype(int)):
204
+ remove_ix.append(ix)
205
+ remove_els.append(el)
206
+
207
+ if len(remove_els)>0:
208
+ print(f'Elements {remove_els} do not have valid nodes - not included in model.')
209
+
210
+ element_matrix = np.delete(element_matrix, remove_ix, axis=0)
211
+
188
212
  eldef = Part(node_matrix, element_matrix, sections=sections,
189
213
  assemble=False, forced_ndofs=6)
190
214
 
@@ -211,7 +235,6 @@ def import_folder(model_folder, pontoon_stl='pontoon.stl', aero_sections='aero_s
211
235
  for el_label in elements:
212
236
  el = eldef.get_element(int(el_label))
213
237
 
214
-
215
238
  el.assign_e2(e2)
216
239
  el.assign_e3(e3)
217
240
 
@@ -219,7 +242,7 @@ def import_folder(model_folder, pontoon_stl='pontoon.stl', aero_sections='aero_s
219
242
  else:
220
243
  eldef = None
221
244
 
222
- # Create model object
245
+ # Create model object (only hydro part)
223
246
  model = Model.from_nodes_and_types(pontoon_nodes, [ptypes[pt] for pt in pontoon_types], modal_dry=modal_dry,
224
247
  rotation=pontoon_rotation, eldef=eldef, labels=pontoon_names)
225
248
 
@@ -249,7 +272,7 @@ def import_folder(model_folder, pontoon_stl='pontoon.stl', aero_sections='aero_s
249
272
  model.assign_drag_elements(data)
250
273
  except:
251
274
  print('Specified drag_elements file found or invalid. No drag elements defined.')
252
-
275
+
253
276
  model.connect_eldef()
254
277
  model.assign_dry_modes()
255
278
 
wawi/wind.py CHANGED
@@ -610,10 +610,10 @@ def generic_kaimal_matrix(omega, nodes, T_wind, A, sigma, C, Lx, U, options=None
610
610
  return SvSv
611
611
 
612
612
 
613
- def loadmatrix_fe(V, load_coefficients, rho, B, D, Admittance = None):
613
+ def loadmatrix_fe(V, load_coefficients, rho, B, D, admittance=None):
614
614
 
615
- if Admittance is None :
616
- Admittance = lambda omega_k: np.ones( (4,3) )
615
+ if admittance is None :
616
+ admittance = lambda omega_k: np.ones( (4,3) )
617
617
 
618
618
  Cd = load_coefficients['Cd']
619
619
  dCd = load_coefficients['dCd']
@@ -623,7 +623,7 @@ def loadmatrix_fe(V, load_coefficients, rho, B, D, Admittance = None):
623
623
  dCm = load_coefficients['dCm']
624
624
 
625
625
  # Equation 7 from Oiseth, 2010
626
- BqBq = lambda omega_k: 1/2*rho*V*B*Admittance(omega_k*B/V/2/np.pi)*np.array([[0, 0, 0],
626
+ BqBq = lambda omega_k: 1/2*rho*V*B*admittance(omega_k*B/V/2/np.pi)*np.array([[0, 0, 0],
627
627
  [0, 2*D/B*Cd, (D/B*dCd-Cl)],
628
628
  [0, 2*Cl, (dCl+D/B*Cd)],
629
629
  [0, -2*B*Cm, -B*dCm]])
@@ -636,10 +636,10 @@ def loadmatrix_fe_static(V, load_coefficients, rho, B, D ):
636
636
  Cl = load_coefficients['Cl']
637
637
  Cm = load_coefficients['Cm']
638
638
 
639
- BqBq = 1/2*rho*V**2*B*np.array([[ 0, 0 , 0 ],
640
- [ D/B*Cd, 0 , 0 ],
641
- [ 0, 0 , Cl ],
642
- [ 0, B*Cm , 0 ]])
639
+ BqBq = 1/2*rho*V**2*B*np.array([[ 0 ],
640
+ [ D/B*Cd ],
641
+ [ Cl ],
642
+ [ -B*Cm ]])
643
643
  return BqBq
644
644
 
645
645
  def loadvector(T_el, Bq, T_wind, L, static = False):
@@ -660,15 +660,16 @@ def loadvector(T_el, Bq, T_wind, L, static = False):
660
660
 
661
661
  # Transform from wind coordinates to local element coordinates
662
662
 
663
- if static is False:
664
- T = T_el @ T_wind.T
665
- else:
666
- T = T_el @ T_wind.T @ np.ones( [3,1] )
663
+ T = T_el @ T_wind.T
667
664
 
668
665
  T_full = blkdiag(T_el, 4) # Block diagonal - repeated 4 times to transform both trans and rot DOFs at each node (2+2)
669
666
 
670
667
  # T_full.T transforms L-->G
671
- R = T_full.T @ G @ Bq @ T
668
+ if static is False:
669
+ R = T_full.T @ G @ Bq @ T
670
+ else:
671
+ R = T_full.T @ G @ Bq
672
+
672
673
  R1 = R[0:6] # Element node 1
673
674
  R2 = R[6:12] # Element node 2
674
675
 
@@ -678,7 +679,7 @@ def loadvector(T_el, Bq, T_wind, L, static = False):
678
679
 
679
680
  def windaction(omega, S, load_coefficients, elements, T_wind,
680
681
  phi, B, D, U, omega_reduced=None, rho=1.225, print_progress=True,
681
- section_lookup=None, nodes=None, Admittance = None):
682
+ section_lookup=None, nodes=None, admittance=None):
682
683
 
683
684
  if nodes is None:
684
685
  nodes = list(set([a for b in [el.nodes for el in elements] for a in b]))
@@ -704,7 +705,7 @@ def windaction(omega, S, load_coefficients, elements, T_wind,
704
705
  lc_fun = lambda el: load_coefficients
705
706
  B_fun = lambda el: B
706
707
  D_fun = lambda el: D
707
- Admittance_fun = lambda el: Admittance
708
+ admittance_fun = lambda el: admittance
708
709
  else:
709
710
  def get_sec(el):
710
711
  for key in section_lookup:
@@ -715,7 +716,7 @@ def windaction(omega, S, load_coefficients, elements, T_wind,
715
716
  B_fun = lambda el: B[get_sec(el)]
716
717
  D_fun = lambda el: D[get_sec(el)]
717
718
 
718
- if Admittance is None: # omit the frequency loop if ADmittance is not included - faster !
719
+ if admittance is None: # omit the frequency loop if ADmittance is not included - faster !
719
720
  RG = np.zeros([len(nodes)*n_dofs, 3])
720
721
  for el in elements:
721
722
  node1_dofs = el.nodes[0].global_dofs
@@ -724,7 +725,7 @@ def windaction(omega, S, load_coefficients, elements, T_wind,
724
725
  mean_wind = U(el.get_cog())
725
726
  Vn = normal_wind(T_wind, el.T0)*mean_wind # Find the normal wind
726
727
  BqBq = loadmatrix_fe(Vn, lc_fun(el), rho, B_fun(el), D_fun(el))
727
- R1, R2 = loadvector(el.T0, BqBq, T_wind, el.L) # Obtain the load vector for each element
728
+ R1, R2 = loadvector(el.T0, BqBq(1), T_wind, el.L) # Obtain the load vector for each element
728
729
 
729
730
  RG[node1_dofs, :] = RG[node1_dofs, :] + R1 # Add the contribution from the element (end 1) to the system
730
731
  RG[node2_dofs, :] = RG[node2_dofs, :] + R2 # Add the contribution from the element (end 2) to the system
@@ -747,7 +748,7 @@ def windaction(omega, S, load_coefficients, elements, T_wind,
747
748
  genSqSq_reduced[:, :, k] = phiT_RG_block @ S(omega_k) @ phiT_RG_block.T # to modal coordinates
748
749
 
749
750
  else: # admittance is given - triple loop (the old way, slower)
750
- Admittance_fun = lambda el: Admittance[get_sec(el)]
751
+ admittance_fun = lambda el: admittance[get_sec(el)]
751
752
 
752
753
  for k, omega_k in enumerate(omega_reduced):
753
754
  if print_progress:
@@ -763,7 +764,7 @@ def windaction(omega, S, load_coefficients, elements, T_wind,
763
764
 
764
765
  mean_wind = U(el.get_cog())
765
766
  Vn = normal_wind(T_wind, el.T0)*mean_wind # Find the normal wind
766
- BqBq = loadmatrix_fe(Vn, lc_fun(el), rho, B_fun(el), D_fun(el), Admittance = Admittance_fun(el))
767
+ BqBq = loadmatrix_fe(Vn, lc_fun(el), rho, B_fun(el), D_fun(el), admittance=admittance_fun(el))
767
768
  R1, R2 = loadvector(el.T0, BqBq(omega_k), T_wind, el.L) # Obtain the load vector for each element
768
769
 
769
770
  RG[node1_dofs, :] = RG[node1_dofs, :] + R1 # Add the contribution from the element (end 1) to the system
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: wawi
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: WAve and WInd response prediction
5
5
  Author-email: "Knut A. Kvåle" <knut.a.kvale@ntnu.no>, Ole Øiseth <ole.oiseth@ntnu.no>, Aksel Fenerci <aksel.fenerci@ntnu.no>, Øivind Wiig Petersen <oyvind.w.petersen@ntnu.no>
6
6
  License: MIT License
@@ -1,9 +1,8 @@
1
- wawi/__init__.py,sha256=QHZAh_Xn6XY-OJjNJfylCc7nxgq1uXVgu1IQtnv1VPI,161
2
- wawi/abq.py,sha256=Sb58fd_REKbOmWngLzzB3_3PxCR-iO_HK1CpdM8sjKs,42660
1
+ wawi/__init__.py,sha256=UmlmJ1lvY8_pmiLPeP6iSfUoh1tH7dgtviM54FItU8Y,158
3
2
  wawi/fe.py,sha256=22QKI1GlfsG7o_TpFXaKJfzmbO2_2zdIMaoJmaIZdmY,4001
4
- wawi/general.py,sha256=BWlI7oNnYTwfEwztwySl_j45YD6s634rczFO5D8iolI,13935
3
+ wawi/general.py,sha256=xHRoDkcchrL6Y7pTUqGsjBHh8YBLvX9dYcNXXCjQap8,13787
5
4
  wawi/identification.py,sha256=bVB6EVRR6J39OO9ckuzNJ6f0FwIo4cLqfYgrsIN89TE,1748
6
- wawi/io.py,sha256=XANKEHBPGC_1-Rn2QPlI_ygpntAR1Haw962IovER8jA,24586
5
+ wawi/io.py,sha256=5p3q_lQStQR85yo5hZ1Syl25RS2C__zIyV6e_2qRRw4,25308
7
6
  wawi/modal.py,sha256=c8cZ98y8BZuFcfrwweE75AAX7QGFDfjLeYK07hzAvCo,20249
8
7
  wawi/plot.py,sha256=XVaQjkjXv26Kt-G8xtAULa4KbWcCIErTQfB6euPACLg,19750
9
8
  wawi/prob.py,sha256=0nCdKdwkNf4M6sHyCZuYlt06gD0NmqRNfl4KesgySWA,215
@@ -13,10 +12,10 @@ wawi/structural.py,sha256=t25ohH4uBbzUJ7Hqn_kUfYhxcikZkRp8da-9dn7aEbw,8341
13
12
  wawi/time_domain.py,sha256=Oe-jviwDtBgpSmA7ZVmKEqQ5tdvsekXwOakYO1qUsN4,3841
14
13
  wawi/tools.py,sha256=-hFBvf0qK4AMn2MQRhrOitDMMMKm2QuRkVfbPBefEkQ,332
15
14
  wawi/wave.py,sha256=hhKg3KhKMBhOoCI7g8PFOGUbYgVhDyGmnYdBEdJ8mkY,16064
16
- wawi/wind.py,sha256=uyKuNugXmkXDGFDRvddbPCAfoGfWkJR7Ge6qNm-uiLM,38548
15
+ wawi/wind.py,sha256=kyDT-CuVoRdyynDWFW4BLxCj08qrz073c5bi3TgMJFs,38451
17
16
  wawi/wind_code.py,sha256=8OKLPpqc84obNNKBoYb2NunKjcn6a3i_pAWpIFEwg4Q,223
18
- wawi-0.0.3.dist-info/LICENSE,sha256=bH1aWhrNbbPLrYnVFRaoYYzcUr-figHjry-kGB7Tc54,1076
19
- wawi-0.0.3.dist-info/METADATA,sha256=Wl2EVbB9D3m0LPJsgJX6D4jCNIUKpCYh3Jl40bBnuAg,3133
20
- wawi-0.0.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
21
- wawi-0.0.3.dist-info/top_level.txt,sha256=sE2NH_xVXnDKTGeIYzeX5IyU_j5vYDLl32v5uLiOMT4,5
22
- wawi-0.0.3.dist-info/RECORD,,
17
+ wawi-0.0.5.dist-info/LICENSE,sha256=bH1aWhrNbbPLrYnVFRaoYYzcUr-figHjry-kGB7Tc54,1076
18
+ wawi-0.0.5.dist-info/METADATA,sha256=SM_H-uu51J62GxpCklSaS5af_vanAGTVTrEB23Ws36M,3133
19
+ wawi-0.0.5.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
20
+ wawi-0.0.5.dist-info/top_level.txt,sha256=sE2NH_xVXnDKTGeIYzeX5IyU_j5vYDLl32v5uLiOMT4,5
21
+ wawi-0.0.5.dist-info/RECORD,,