wawi 0.0.16__py3-none-any.whl → 0.0.18__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.
- wawi/__init__.py +1 -1
- wawi/fe.py +259 -12
- wawi/general.py +538 -70
- wawi/identification.py +33 -11
- wawi/io.py +206 -3
- wawi/modal.py +384 -6
- wawi/model/_model.py +1 -1
- wawi/plot.py +403 -107
- wawi/prob.py +28 -0
- wawi/random.py +218 -2
- wawi/signal.py +111 -3
- wawi/structural.py +317 -59
- wawi/time_domain.py +122 -1
- wawi/tools.py +23 -0
- wawi/wave.py +668 -123
- wawi/wind.py +775 -32
- wawi/wind_code.py +26 -0
- {wawi-0.0.16.dist-info → wawi-0.0.18.dist-info}/METADATA +42 -4
- wawi-0.0.18.dist-info/RECORD +38 -0
- {wawi-0.0.16.dist-info → wawi-0.0.18.dist-info}/WHEEL +1 -1
- wawi-0.0.16.dist-info/RECORD +0 -38
- {wawi-0.0.16.dist-info → wawi-0.0.18.dist-info}/licenses/LICENSE +0 -0
- {wawi-0.0.16.dist-info → wawi-0.0.18.dist-info}/top_level.txt +0 -0
wawi/__init__.py
CHANGED
wawi/fe.py
CHANGED
@@ -7,15 +7,32 @@ FE-related tools.
|
|
7
7
|
'''
|
8
8
|
|
9
9
|
def intpoints_from_elements(nodes, elements, sort_axis=0):
|
10
|
-
|
11
|
-
|
10
|
+
"""
|
11
|
+
Calculates the integration points (midpoints) for each element based on node coordinates.
|
12
12
|
|
13
13
|
Parameters
|
14
|
-
|
15
|
-
nodes :
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
----------
|
15
|
+
nodes : np.ndarray
|
16
|
+
Array of node coordinates with shape (n_nodes, 4), where columns represent node index and x, y, z coordinates.
|
17
|
+
elements : np.ndarray
|
18
|
+
Array of element connectivity with shape (n_elements, 2), where each row contains indices of the two nodes forming an element.
|
19
|
+
sort_axis : int, optional
|
20
|
+
Axis (0 for x, 1 for y, 2 for z) to sort the integration points by. Default is 0 (x-axis).
|
21
|
+
|
22
|
+
Returns
|
23
|
+
-------
|
24
|
+
x : np.ndarray
|
25
|
+
Array of x-coordinates of the integration points, sorted by the specified axis.
|
26
|
+
y : np.ndarray
|
27
|
+
Array of y-coordinates of the integration points, sorted by the specified axis.
|
28
|
+
z : np.ndarray
|
29
|
+
Array of z-coordinates of the integration points, sorted by the specified axis.
|
30
|
+
|
31
|
+
Notes
|
32
|
+
-----
|
33
|
+
Assumes that `nodeix_from_elements` is a function that returns the indices of the nodes for each element. Docstring is generated by Github Copilot.
|
34
|
+
"""
|
35
|
+
|
19
36
|
nodeix = nodeix_from_elements(elements, nodes).astype('int')
|
20
37
|
|
21
38
|
intpoints = (nodes[nodeix[:,0], 1:4]+nodes[nodeix[:,1], 1:4])/2
|
@@ -30,13 +47,37 @@ def intpoints_from_elements(nodes, elements, sort_axis=0):
|
|
30
47
|
|
31
48
|
|
32
49
|
def nodeix_from_elements(element_matrix, node_matrix, return_as_flat=False):
|
33
|
-
|
34
|
-
|
50
|
+
"""
|
51
|
+
Map element node labels to their corresponding indices in the node matrix.
|
52
|
+
|
53
|
+
Parameters
|
54
|
+
----------
|
55
|
+
element_matrix : np.ndarray
|
56
|
+
Array of elements with shape (n_elements, m), where columns 1 and 2 contain node IDs for each element.
|
57
|
+
node_matrix : np.ndarray
|
58
|
+
Array of nodes with shape (n_nodes, k), where column 0 contains node IDs.
|
59
|
+
return_as_flat : bool, optional
|
60
|
+
If True, returns a 1D array of unique node indices used by all elements.
|
61
|
+
If False, returns a 2D array of shape (n_elements, 2) with node indices for each element.
|
62
|
+
Default is False.
|
63
|
+
|
64
|
+
Returns
|
65
|
+
-------
|
66
|
+
np.ndarray
|
67
|
+
If return_as_flat is False, returns a 2D array of node indices for each element (shape: n_elements, 2).
|
68
|
+
If return_as_flat is True, returns a 1D array of unique node indices.
|
69
|
+
|
70
|
+
Notes
|
71
|
+
-----
|
72
|
+
Each element is assumed to be defined by two node labels in columns 1 and 2 of element_matrix. Docstring is generated by GitHub Copilot.
|
73
|
+
"""
|
74
|
+
nodeix = [None] * len(element_matrix[:, 0])
|
75
|
+
for element_ix, __ in enumerate(element_matrix[:, 0]):
|
35
76
|
node1 = element_matrix[element_ix, 1]
|
36
77
|
node2 = element_matrix[element_ix, 2]
|
37
78
|
|
38
|
-
nodeix1 = np.where(node_matrix[:,0]==node1)[0][0]
|
39
|
-
nodeix2 = np.where(node_matrix[:,0]==node2)[0][0]
|
79
|
+
nodeix1 = np.where(node_matrix[:, 0] == node1)[0][0]
|
80
|
+
nodeix2 = np.where(node_matrix[:, 0] == node2)[0][0]
|
40
81
|
nodeix[element_ix] = [nodeix1, nodeix2]
|
41
82
|
|
42
83
|
nodeix = np.array(nodeix)
|
@@ -48,6 +89,36 @@ def nodeix_from_elements(element_matrix, node_matrix, return_as_flat=False):
|
|
48
89
|
|
49
90
|
|
50
91
|
def create_node_dict(element_dict, node_labels, x_nodes, y_nodes, z_nodes):
|
92
|
+
"""
|
93
|
+
Creates a dictionary mapping element keys to their corresponding node data.
|
94
|
+
|
95
|
+
Parameters
|
96
|
+
----------
|
97
|
+
element_dict : dict
|
98
|
+
A dictionary where each key corresponds to an element and each value contains information
|
99
|
+
about the nodes associated with that element.
|
100
|
+
node_labels : array-like
|
101
|
+
An array of node labels/IDs.
|
102
|
+
x_nodes : array-like
|
103
|
+
An array of x-coordinates for each node.
|
104
|
+
y_nodes : array-like
|
105
|
+
An array of y-coordinates for each node.
|
106
|
+
z_nodes : array-like
|
107
|
+
An array of z-coordinates for each node.
|
108
|
+
|
109
|
+
Returns
|
110
|
+
-------
|
111
|
+
node_dict : dict
|
112
|
+
A dictionary where each key matches an element key from `element_dict`, and each value is
|
113
|
+
an array containing the node label and coordinates (label, x, y, z) for the nodes
|
114
|
+
associated with that element.
|
115
|
+
|
116
|
+
Notes
|
117
|
+
-----
|
118
|
+
This function relies on the helper function `nodeix_from_elements` to determine the indices
|
119
|
+
of nodes associated with each element. Docstring is generated by GitHub Copilot.
|
120
|
+
"""
|
121
|
+
|
51
122
|
node_dict = dict()
|
52
123
|
node_matrix = np.vstack([node_labels, x_nodes, y_nodes, z_nodes]).T
|
53
124
|
|
@@ -59,6 +130,38 @@ def create_node_dict(element_dict, node_labels, x_nodes, y_nodes, z_nodes):
|
|
59
130
|
|
60
131
|
|
61
132
|
def elements_with_node(element_matrix, node_label):
|
133
|
+
"""
|
134
|
+
Finds elements containing a specific node and returns their labels, indices, and local node indices.
|
135
|
+
|
136
|
+
Parameters
|
137
|
+
----------
|
138
|
+
element_matrix : np.ndarray
|
139
|
+
A 2D array where each row represents an element. The first column contains element labels,
|
140
|
+
and the second and third columns contain node labels associated with each element.
|
141
|
+
node_label : int or float
|
142
|
+
The node label to search for within the element matrix.
|
143
|
+
|
144
|
+
Returns
|
145
|
+
-------
|
146
|
+
element_labels : np.ndarray
|
147
|
+
Array of element labels that contain the specified node.
|
148
|
+
element_ixs : np.ndarray
|
149
|
+
Array of indices in `element_matrix` where the specified node is found.
|
150
|
+
local_node_ix : np.ndarray
|
151
|
+
Array indicating the local node index (0 or 1) within each element where the node is found.
|
152
|
+
|
153
|
+
Examples
|
154
|
+
--------
|
155
|
+
>>> element_matrix = np.array([[1, 10, 20],
|
156
|
+
... [2, 20, 30],
|
157
|
+
... [3, 10, 30]])
|
158
|
+
>>> elements_with_node(element_matrix, 10)
|
159
|
+
(array([1, 3]), array([0, 2]), array([0., 0.]))
|
160
|
+
|
161
|
+
Notes
|
162
|
+
---------
|
163
|
+
Docstring is generated by GitHub Copilot.
|
164
|
+
"""
|
62
165
|
element_ixs1 = np.array(np.where(element_matrix[:,1]==node_label)).flatten()
|
63
166
|
element_ixs2 = np.array(np.where(element_matrix[:,2]==node_label)).flatten()
|
64
167
|
|
@@ -73,6 +176,35 @@ def elements_with_node(element_matrix, node_label):
|
|
73
176
|
|
74
177
|
|
75
178
|
def nodes_to_beam_element_matrix(node_labels, first_element_label=1):
|
179
|
+
"""
|
180
|
+
Generates an element connectivity matrix for beam elements from a sequence of node labels.
|
181
|
+
|
182
|
+
Parameters
|
183
|
+
----------
|
184
|
+
node_labels : array_like
|
185
|
+
Sequence of node labels (integers or floats) defining the order of nodes along the beam.
|
186
|
+
first_element_label : int, optional
|
187
|
+
The label to assign to the first element. Default is 1.
|
188
|
+
|
189
|
+
Returns
|
190
|
+
-------
|
191
|
+
element_matrix : ndarray of shape (n_elements, 3)
|
192
|
+
Array where each row represents a beam element. The columns are:
|
193
|
+
[element_label, start_node_label, end_node_label].
|
194
|
+
|
195
|
+
Examples
|
196
|
+
--------
|
197
|
+
>>> nodes = [10, 20, 30, 40]
|
198
|
+
>>> nodes_to_beam_element_matrix(nodes)
|
199
|
+
array([[ 1., 10., 20.],
|
200
|
+
[ 2., 20., 30.],
|
201
|
+
[ 3., 30., 40.]])
|
202
|
+
|
203
|
+
Notes
|
204
|
+
---------
|
205
|
+
Docstring is generated by GitHub Copilot.
|
206
|
+
"""
|
207
|
+
|
76
208
|
n_nodes = len(node_labels)
|
77
209
|
n_elements = n_nodes-1
|
78
210
|
|
@@ -85,6 +217,35 @@ def nodes_to_beam_element_matrix(node_labels, first_element_label=1):
|
|
85
217
|
|
86
218
|
|
87
219
|
def node_ix_to_dof_ix(node_ix, n_dofs=6):
|
220
|
+
"""
|
221
|
+
Converts a node index to a degree of freedom (DOF) index.
|
222
|
+
Each node has n_dofs degrees of freedom, and this function returns the corresponding DOF indices.
|
223
|
+
|
224
|
+
Parameters
|
225
|
+
----------
|
226
|
+
node_ix : int
|
227
|
+
Index of the node for which to find the DOF indices.
|
228
|
+
n_dofs : int, optional
|
229
|
+
Number of degrees of freedom per node. Default is 6.
|
230
|
+
|
231
|
+
Returns
|
232
|
+
-------
|
233
|
+
dof_ix : np.ndarray
|
234
|
+
Array of DOF indices corresponding to the given node index.
|
235
|
+
|
236
|
+
Examples
|
237
|
+
--------
|
238
|
+
>>> node_ix = 2
|
239
|
+
>>> n_dofs = 6
|
240
|
+
>>> dof_ix = node_ix_to_dof_ix(node_ix, n_dofs)
|
241
|
+
>>> print(dof_ix)
|
242
|
+
[12 13 14 15 16 17]
|
243
|
+
|
244
|
+
Notes
|
245
|
+
--------
|
246
|
+
Docstring is generated by GitHub Copilot.
|
247
|
+
|
248
|
+
"""
|
88
249
|
start = node_ix*n_dofs
|
89
250
|
stop = node_ix*n_dofs+n_dofs
|
90
251
|
dof_ix = []
|
@@ -97,6 +258,38 @@ def node_ix_to_dof_ix(node_ix, n_dofs=6):
|
|
97
258
|
|
98
259
|
|
99
260
|
def dof_sel(arr, dof_sel, n_dofs=6, axis=0):
|
261
|
+
"""
|
262
|
+
Selects degrees of freedom (DOFs) from an array along a specified axis.
|
263
|
+
|
264
|
+
Parameters
|
265
|
+
----------
|
266
|
+
arr : np.ndarray
|
267
|
+
Input array from which to select DOFs.
|
268
|
+
dof_sel : array-like
|
269
|
+
Indices of the DOFs to select (relative to each block of n_dofs).
|
270
|
+
n_dofs : int, optional
|
271
|
+
Number of DOFs per node or block. Default is 6.
|
272
|
+
axis : int, optional
|
273
|
+
Axis along which to select DOFs. Default is 0.
|
274
|
+
|
275
|
+
Returns
|
276
|
+
-------
|
277
|
+
arr_sel : np.ndarray
|
278
|
+
Array containing only the selected DOFs along the specified axis.
|
279
|
+
|
280
|
+
Examples
|
281
|
+
--------
|
282
|
+
>>> arr = np.arange(18).reshape(3, 6)
|
283
|
+
>>> dof_sel(arr, [0, 2], n_dofs=6, axis=1)
|
284
|
+
array([[ 0, 2],
|
285
|
+
[ 6, 8],
|
286
|
+
[12, 14]])
|
287
|
+
|
288
|
+
Notes
|
289
|
+
-------
|
290
|
+
Docstring is generated by GitHub Copilot.
|
291
|
+
"""
|
292
|
+
|
100
293
|
N = np.shape(arr)[axis]
|
101
294
|
all_ix = [range(dof_sel_i, N, n_dofs) for dof_sel_i in dof_sel]
|
102
295
|
sel_ix = np.array(all_ix).T.flatten()
|
@@ -109,13 +302,67 @@ def dof_sel(arr, dof_sel, n_dofs=6, axis=0):
|
|
109
302
|
|
110
303
|
|
111
304
|
def elements_from_common_nodes(element_matrix, selected_nodes):
|
112
|
-
|
305
|
+
"""
|
306
|
+
Find elements that have both nodes in `selected_nodes`.
|
307
|
+
|
308
|
+
Parameters
|
309
|
+
----------
|
310
|
+
element_matrix : np.ndarray
|
311
|
+
Array of elements with shape (n_elements, 3), where columns are [element_id, node1, node2].
|
312
|
+
selected_nodes : array-like
|
313
|
+
List or array of node labels to search for.
|
314
|
+
|
315
|
+
Returns
|
316
|
+
-------
|
317
|
+
selected_element_matrix : np.ndarray
|
318
|
+
Subset of `element_matrix` where both nodes are in `selected_nodes`.
|
319
|
+
sel_ix : np.ndarray
|
320
|
+
Indices of the selected elements in the original `element_matrix`.
|
321
|
+
|
322
|
+
Notes
|
323
|
+
-----
|
324
|
+
Only elements where both node1 and node2 are in `selected_nodes` are selected. Docstring is generated by GitHub Copilot.
|
325
|
+
"""
|
326
|
+
|
327
|
+
mask = np.isin(element_matrix[:, 1], selected_nodes) & np.isin(element_matrix[:, 2], selected_nodes)
|
328
|
+
sel_ix = np.where(mask)[0]
|
113
329
|
selected_element_matrix = element_matrix[sel_ix, :]
|
114
330
|
|
115
331
|
return selected_element_matrix, sel_ix
|
116
332
|
|
117
333
|
|
118
334
|
def transform_elements(node_matrix, element_matrix, e2p, repeats=1):
|
335
|
+
"""
|
336
|
+
Transforms elements from global to local coordinates.
|
337
|
+
Given a node matrix and an element matrix, this function computes the transformation matrices
|
338
|
+
from global to local coordinates for each element. The transformation is based on the direction
|
339
|
+
vector between the nodes of each element. The transformation matrices are constructed using
|
340
|
+
the `transform_unit` function and are repeated as specified.
|
341
|
+
|
342
|
+
Parameters
|
343
|
+
----------
|
344
|
+
node_matrix : np.ndarray
|
345
|
+
Array of node data. The first column should contain node IDs, and the remaining columns
|
346
|
+
should contain node coordinates.
|
347
|
+
element_matrix : np.ndarray
|
348
|
+
Array of element data. Each row corresponds to an element, with the first column as the
|
349
|
+
element ID and the next columns as node IDs defining the element.
|
350
|
+
e2p : np.ndarray or similar
|
351
|
+
Additional parameter passed to `transform_unit` for transformation construction.
|
352
|
+
repeats : int, optional
|
353
|
+
Number of times to repeat the transformation block (default is 1).
|
354
|
+
|
355
|
+
Returns
|
356
|
+
-------
|
357
|
+
list of np.ndarray
|
358
|
+
List of transformation matrices, one for each element, mapping global to local coordinates.
|
359
|
+
|
360
|
+
Notes
|
361
|
+
-----
|
362
|
+
- Assumes that `transform_unit` and `blkdiag` functions are defined elsewhere.
|
363
|
+
- The function matches node IDs between `element_matrix` and `node_matrix` to determine node positions.
|
364
|
+
Docstring is generated by GitHub Copilot.
|
365
|
+
"""
|
119
366
|
|
120
367
|
n_elements = np.shape(element_matrix)[0]
|
121
368
|
T_g2el = [None]*n_elements
|