Skip to content

Commit 6064ad0

Browse files
committed
add free vibration
1 parent 0788fa2 commit 6064ad0

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

pystran/model.py

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"""
44

55
import numpy
6-
from numpy import array, zeros, dot
6+
from numpy import array, zeros, dot, identity
7+
import scipy
78
import pystran.section
89

910
# These are the designations of degrees of freedom (directions in space), plus a
@@ -201,3 +202,53 @@ def solve_statics(m):
201202
joint["displacements"] = U[joint["dof"]]
202203

203204
return None
205+
206+
207+
def solve_free_vibration(m):
208+
"""
209+
Solve the free vibration of the discrete model.
210+
"""
211+
nt, nf = m["ntotaldof"], m["nfreedof"]
212+
# Assemble global stiffness matrix
213+
K = zeros((nt, nt))
214+
for member in m["truss_members"].values():
215+
connectivity = member["connectivity"]
216+
i, j = m["joints"][connectivity[0]], m["joints"][connectivity[1]]
217+
pystran.truss.assemble_stiffness(K, member, i, j)
218+
for member in m["beam_members"].values():
219+
connectivity = member["connectivity"]
220+
i, j = m["joints"][connectivity[0]], m["joints"][connectivity[1]]
221+
pystran.beam.assemble_stiffness(K, member, i, j)
222+
223+
m["K"] = K
224+
225+
M = identity(nt)
226+
m["M"] = M
227+
228+
U = zeros(m["ntotaldof"])
229+
for joint in m["joints"].values():
230+
if "supports" in joint:
231+
for dof, value in joint["supports"].items():
232+
gr = joint["dof"][dof]
233+
U[gr] = 0.0
234+
m["U"] = U
235+
236+
# Solved the eigenvalue problem
237+
eigvals, eigvecs = scipy.linalg.eigh(K[0:nf, 0:nf], M[0:nf, 0:nf])
238+
print(eigvals)
239+
240+
m["eigvals"] = eigvals
241+
m["eigvecs"] = eigvecs
242+
243+
return
244+
245+
246+
def copy_mode(m, mode):
247+
"""
248+
Copy a mode to the displacement field of the model.
249+
"""
250+
nf = m["nfreedof"]
251+
m["U"][0:nf] = m["eigvecs"][:, mode]
252+
for joint in m["joints"].values():
253+
joint["displacements"] = m["U"][joint["dof"]]
254+
return None

0 commit comments

Comments
 (0)