-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodes_vibration_beam.py
More file actions
134 lines (105 loc) · 4.75 KB
/
Copy pathmodes_vibration_beam.py
File metadata and controls
134 lines (105 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Libraries
import numpy as np
import numpy.ma as ma
from scipy import linalg
np.set_printoptions(precision=3)
nel = 1
nnos = nel + 1
L = 1
alldof = np.linspace(1, 1,2*nnos) # all degrees of freedom
kf = np.zeros((2*nnos,2*nnos)) # global stiffness matrix pre-allocation
m = np.zeros((2*nnos,2*nnos)) # global stiffness matrix pre-allocation
coord = np.zeros((nnos, 2)) # coordinate matrix pre-allocation
inci = np.zeros((nel, 5)) # incidence matrix pre-allocation
for i in range(0, nnos):
coord[i,0] = i + 1 # node number
coord[i,1] = i*L/(nnos-1) # node position
for i in range(0, nel):
inci[i,0] = i + 1 # element number
inci[i,1] = i + 1 # first node
inci[i,2] = i + 2 # second node
# Material properties
E = 70e9
ro = 3e3
b = 0.03
h = 0.05
A = b*h
inertia = b*h**3/12
l = L/nel
# Boundary conditions
# bc=[node | degree of freedom | value]
#
# Degree of freedom 1 --> y
# Degree of freedom 2 --> oz
bc = np.array([[1,1,0],[1,2,0]])
mask = np.zeros((2*nnos,2*nnos))
for i in range(0, np.size(bc,0)):
if bc[i,1] == 1:
mask[2*(bc[i,0] - 1),2*(bc[i,0] - 1)] = 1
elif bc[i,1] == 2:
mask[2*(bc[i,0] - 1)+1,2*(bc[i,0] - 1) + 1] = 1
mask = ma.masked_equal(mask, 1)
mask = ma.mask_rowcols(mask)
mask = (mask==False)
# Consistent mass matrix
for i in range(nel):
node1 = inci[i,1] # first node element
node2 = inci[i,2] # second node element
# local stiffness matrix
kf_e = E*inertia/l**3*np.array([[ 12, 6*l, -12, 6*l],
[ 6*l, 4*l**2, -6*l, 2*l**2],
[ -12, -6*l, 12, -6*l],
[ 6*l, 2*l**2, -6*l, 4*l**2]])
# local mass matrix
m_e = ro*A*l/420*np.array([[ 156, 22*l, 54, -13*l],
[ 22*l, 4*l**2, 13*l, -3*l**2],
[ 54, 13*l, 156, -22*l],
[ -13*l, -3*l**2, -22*l, 4*l**2]])
# localization vector
loc = [2*node1-2,2*node1-1,2*node2-2,2*node2-1]
# global stiffness matrix
kf[[[int(loc[0])],[int(loc[1])],[int(loc[2])], [int(loc[3])]], [int(loc[0]),int(loc[1]),int(loc[2]),int(loc[3])]] = kf[[[int(loc[0])],[int(loc[1])],[int(loc[2])], [int(loc[3])]], [int(loc[0]),int(loc[1]),int(loc[2]),int(loc[3])]] + kf_e
m[[[int(loc[0])],[int(loc[1])],[int(loc[2])], [int(loc[3])]], [int(loc[0]),int(loc[1]),int(loc[2]),int(loc[3])]] = m[[[int(loc[0])],[int(loc[1])],[int(loc[2])], [int(loc[3])]], [int(loc[0]),int(loc[1]),int(loc[2]),int(loc[3])]] + m_e
m_ = m[mask.data]
m_ = np.reshape(m_, (2*nnos-np.size(bc,0), 2*nnos-np.size(bc,0)))
kf_ = kf[mask.data]
kf_ = np.reshape(kf_, (2*nnos-np.size(bc,0), 2*nnos-np.size(bc,0)))
w, v = linalg.eig(kf_, m_)
# First mode
w = np.min(np.real(w))
omega = np.sqrt(w)
f = omega/2/np.pi
print('omega = ' + str(format(omega, '.4f')) + ' rad/s')
print('f = ' + str(format(f, '.4f')) + ' Hz')
(1.875)**2*np.sqrt(E*inertia/ro/A)
# Lumped mass matrix
kf = np.zeros((2*nnos,2*nnos)) # global stiffness matrix pre-allocation
m = np.zeros((2*nnos,2*nnos)) # global stiffness matrix pre-allocation
for i in range(nel):
node1 = inci[i,1] # first node element
node2 = inci[i,2] # second node element
# local stiffness matrix
kf_e = E*inertia/l**3*np.array([[ 12, 6*l, -12, 6*l],
[ 6*l, 4*l**2, -6*l, 2*l**2],
[ -12, -6*l, 12, -6*l],
[ 6*l, 2*l**2, -6*l, 4*l**2]])
# local mass matrix
m_e = ro*A*l/2*np.array([[ 1, 0, 0, 0],
[ 0, 0, 0, 0],
[ 0, 0, 1, 0],
[ 0, 0, 0, 0]])
# localization vector
loc = [2*node1-2,2*node1-1,2*node2-2,2*node2-1]
# global stiffness matrix
kf[[[int(loc[0])],[int(loc[1])],[int(loc[2])], [int(loc[3])]], [int(loc[0]),int(loc[1]),int(loc[2]),int(loc[3])]] = kf[[[int(loc[0])],[int(loc[1])],[int(loc[2])], [int(loc[3])]], [int(loc[0]),int(loc[1]),int(loc[2]),int(loc[3])]] + kf_e
m[[[int(loc[0])],[int(loc[1])],[int(loc[2])], [int(loc[3])]], [int(loc[0]),int(loc[1]),int(loc[2]),int(loc[3])]] = m[[[int(loc[0])],[int(loc[1])],[int(loc[2])], [int(loc[3])]], [int(loc[0]),int(loc[1]),int(loc[2]),int(loc[3])]] + m_e
m_ = m[mask.data]
m_ = np.reshape(m_, (2*nnos-np.size(bc,0), 2*nnos-np.size(bc,0)))
kf_ = kf[mask.data]
kf_ = np.reshape(kf_, (2*nnos-np.size(bc,0), 2*nnos-np.size(bc,0)))
w, v = linalg.eig(kf_, m_)
w = np.min(np.real(w))
omega = np.sqrt(w)
f = omega/2/np.pi
print('omega = ' + str(format(omega, '.4f')) + ' rad/s')
print('f = ' + str(format(f, '.4f')) + ' Hz')