-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgeneral_functions.py
More file actions
52 lines (39 loc) · 1.41 KB
/
general_functions.py
File metadata and controls
52 lines (39 loc) · 1.41 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
import matplotlib.pyplot as plt
import numpy as np
import sympy as sp
from random import randint
def PrintDofDisplacement(disp,time,dof,Label,line_sytle):
len_array = len(time)
dof_disp = []
for i in range(len_array):
dof_disp.append(disp[i][dof])
plt.plot(time,dof_disp,line_sytle, label='dof ' + str(dof) + ' ' + Label)
def PrintDisplacement(disp,time,ListOfDof,Head,Label,style):
number_dof = len(ListOfDof)
style_guide = ['-', '--', '-.', ':']
for i in range(number_dof):
PrintDofDisplacement(disp,time,ListOfDof[i],Label,style_guide[style])
plt.legend()
plt.grid(True)
plt.xlabel('time t')
plt.ylabel('displacement')
plt.title(Head)
def ShowPrint():
plt.show()
def FindEigenValues(MassMatrix,StiffnessMatrix,ListOfBc):
number_of_Bc = len(ListOfBc)
old_mat_size = MassMatrix.shape[0]
new_mat_size = old_mat_size - number_of_Bc
M_mod = sp.zeros(old_mat_size,old_mat_size)
K_mod = sp.zeros(old_mat_size,old_mat_size)
for i in range(old_mat_size):
for j in range(old_mat_size):
M_mod[i,j] = MassMatrix[i,j]
K_mod[i,j] = StiffnessMatrix[i,j]
alpha = sp.Symbol('alpha')
MK = K_mod - M_mod * alpha
MK_det = MK.det()
eigenvalues = sp.solve(MK_det,alpha)
eigen_array = []
for i in range(new_mat_size): eigen_array.append(np.sqrt(np.float(eigenvalues[i])))
return eigen_array