# Computation for the EigenValues of a 3DOF System in Structural Dynamics

In this example, we will look on how to solve a 3DOF system using python.
This uses the library of Sympy (Symbolic Python) to solve the equations in terms of variables (letters)

$$ m \ddot(x) + c \dot(x) + k (x) = 0 $$

## Step 1: Loading libraries


```python
# imports numpy and matplotlib
%pylab inline

# imports sympy
import sympy as sm

# prints output using LaTeX for pretty viewing
sm.init_printing(use_latex=True)
```

    Populating the interactive namespace from numpy and matplotlib


## Step 2: Establish Mass Matrix


```python
# assigning masses
m1 = 1000 #(kg)
m2 = 1500 #(kg)
m3 = 2000 #(kg)

# making the mass matrix
m = sm.Matrix([[m1,0,0],[0,m2,0],[0,0,m3]])

# printing the mass matrix
m
```


## Step 3: Establish Stiffness Matrix


```python
# computing for the stiffnesses
k1 = 600000 #(N/m)
k2 = 1200000 #(N/m)
k3 = 1800000 #(N/m)

# making the stiffness matrix
k = sm.Matrix([[k1,-k1,0],[-k1,k1+k2,-k2],[0,-k2,k2+k3]])

# printing the stiffness matrix
k
```

## Step 4: Solving the EigenValue Problem
Making the Matrix


```python
# assigning the "x" variable as a symbol
x = sm.Symbol('x')

# making the Eigen matrix
A = k-m*x**2

# printing the matrix
A
```

Getting the Determinant of the Matrix


```python
sm.det(A).simplify()
```

Solving the determinants and listing the types of modes


```python
# This step solves the equation in line
B = sm.solve(sm.det(A),x**2)

# This line converts the array into real number
C = real(B)

# This line makes an array into a complex numbers
D = array((C.astype(complex)))

# Gets the squareroot of the real part of the complex number
E = 1/(sqrt(D.real) / 2 / math.pi)

# printing the Modes
print("Period 1 = {0}, Period 2 = {1}, Period 3 = {2}".format(E[0],E[1],E[2]))
```

    Period 1 = 0.2023720283163326, Period 2 = 0.43267656159437806, Period 3 = 0.13629624070103266


ec594889b15702aa1f3b71ecac84931962a33ca1
ipynb
Jupyter Notebook
.ipynb_checkpoints/Structural Dynamics-checkpoint.ipynb
mjamezquidilla/ModalAnalysis
826e04b70600ccda543ebcb794076b405806a6c2
MIT
2022-03-01T23:33:56.000Z
2022-03-01T23:33:56.000Z
Structural Dynamics.ipynb
mjamezquidilla/ModalAnalysis
826e04b70600ccda543ebcb794076b405806a6c2
MIT
Structural Dynamics.ipynb
mjamezquidilla/ModalAnalysis
826e04b70600ccda543ebcb794076b405806a6c2
MIT
Qwen/Qwen-72B
1. YES
2. YES