|
3 | 3 | """ |
4 | 4 |
|
5 | 5 | import numpy |
6 | | -from numpy import array, zeros, dot |
| 6 | +from numpy import array, zeros, dot, identity |
| 7 | +import scipy |
7 | 8 | import pystran.section |
8 | 9 |
|
9 | 10 | # These are the designations of degrees of freedom (directions in space), plus a |
@@ -201,3 +202,53 @@ def solve_statics(m): |
201 | 202 | joint["displacements"] = U[joint["dof"]] |
202 | 203 |
|
203 | 204 | 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