CIE_4140_Lecture_3_1_Python#

Free vibration of an SDOF with viscous damping#

import sympy as sp
u = sp.symbols('u',cls=sp.Function)
t, omega_n, m, zeta = sp.symbols('t, omega_n, m, zeta',real=True,positive=True)
u_0, v_0 = sp.symbols('u_0, v_0')

The equation of motion:

Equation_of_Motion= sp.Eq(sp.diff(u(t),t,2)+2*zeta*omega_n*sp.diff(u(t),t)+omega_n **2 * u(t),0)
display(Equation_of_Motion)
\[\displaystyle \omega_{n}^{2} u{\left(t \right)} + 2 \omega_{n} \zeta \frac{d}{d t} u{\left(t \right)} + \frac{d^{2}}{d t^{2}} u{\left(t \right)} = 0\]
u_sol = sp.dsolve(Equation_of_Motion, u(t), ics={u(0): u_0 , u(t).diff(t , 1).subs(t , 0) : v_0}).rhs
display(u_sol)
\[\displaystyle \left(- \frac{u_{0} \zeta}{2 \sqrt{\zeta - 1} \sqrt{\zeta + 1}} + \frac{u_{0}}{2} - \frac{v_{0}}{2 \omega_{n} \sqrt{\zeta - 1} \sqrt{\zeta + 1}}\right) e^{- \omega_{n} t \left(\zeta + \sqrt{\zeta - 1} \sqrt{\zeta + 1}\right)} + \left(\frac{\omega_{n} u_{0} \zeta^{2}}{2 \omega_{n} \zeta^{2} - 2 \omega_{n}} + \frac{\omega_{n} u_{0} \zeta \sqrt{\zeta - 1} \sqrt{\zeta + 1}}{2 \omega_{n} \zeta^{2} - 2 \omega_{n}} - \frac{\omega_{n} u_{0}}{2 \omega_{n} \zeta^{2} - 2 \omega_{n}} + \frac{v_{0} \sqrt{\zeta - 1} \sqrt{\zeta + 1}}{2 \omega_{n} \zeta^{2} - 2 \omega_{n}}\right) e^{\omega_{n} t \left(- \zeta + \sqrt{\zeta - 1} \sqrt{\zeta + 1}\right)}\]

Super-critically damed system \(1 < \xi \)#

Example plot

sp.plot(u_sol.subs([(u_0,1),(v_0,1),(omega_n,1),(zeta,1.2)]),(t,0,12));
../_images/8f4f6a9d572a00ac812ba85e671e4e0838f30788a958db95b43b974a88c0774d.png

Effect of the initial displacement:

%matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
u_func = sp.lambdify((u_0,v_0,omega_n,zeta,t),u_sol)
fig, ax = plt.subplots()
tdata = np.linspace(0,12,100)
line, = ax.plot([], [])
ax.set_xlim(0, 12)
ax.set_ylim(0, 1.2)

def update(frame):
    ydata = u_func(u_0=frame,v_0=1,omega_n=1,zeta=1.2,t=tdata)
    ax.set_title("Displacement versus time for $u_0$ = "+str(np.round(frame,2)))
    line.set_data(tdata, ydata)

ani = FuncAnimation(fig, update, frames=np.linspace(0,1,100),interval = 100)
plt.show()

Effect of the initial velocity:

fig, ax = plt.subplots()
tdata = np.linspace(0,12,100)
line, = ax.plot([], [])
ax.set_xlim(0, 12)
ax.set_ylim(0, 1.2)

def update(frame):
    ydata = u_func(u_0=1,v_0=frame,omega_n=1,zeta=1.2,t=tdata)
    ax.set_title("Displacement versus time for $v_0$ = "+str(np.round(frame,2)))
    line.set_data(tdata, ydata)

ani = FuncAnimation(fig, update, frames=np.linspace(0,1,100),interval = 100)
plt.show()

Effect of the undamped natural frequency:

fig, ax = plt.subplots()
tdata = np.linspace(0,12,100)
line, = ax.plot([], [])
ax.set_xlim(0, 12)
ax.set_ylim(0, 1.2)

def update(frame):
    ydata = u_func(u_0=1,v_0=0.1,omega_n=frame,zeta=1.2,t=tdata)
    ax.set_title("Displacement versus time for $\omega_n$ = "+str(np.round(frame,2)))
    line.set_data(tdata, ydata)

ani = FuncAnimation(fig, update, frames=np.linspace(0.5,2,100),interval = 100)
plt.show()

Effect of the damping ratio:

fig, ax = plt.subplots()
tdata = np.linspace(0,12,100)
line, = ax.plot([], [])
ax.set_xlim(0, 12)
ax.set_ylim(0, 1.2)

def update(frame):
    ydata = u_func(u_0=1,v_0=0.1,omega_n=1,zeta=frame,t=tdata)
    ax.set_title("Displacement versus time for $\zeta$ = "+str(np.round(frame,2)))
    line.set_data(tdata, ydata)

ani = FuncAnimation(fig, update, frames=np.linspace(1.1,2,100),interval = 100)
plt.show()

Critically damed system \(\xi = 1 \)#

u_crit = sp.limit(u_sol,zeta,1)
display(u_crit)
\[\displaystyle \left(\omega_{n} t u_{0} + t v_{0} + u_{0}\right) e^{- \omega_{n} t}\]

Example plot

sp.plot(u_crit.subs([(u_0,1),(v_0,1),(omega_n,1),(zeta,1.2)]),(t,0,12));

Effect of the initial displacement

u_crit_func = sp.lambdify((u_0,v_0,omega_n,zeta,t),u_crit)
fig, ax = plt.subplots()
tdata = np.linspace(0,12,100)
line, = ax.plot([], [])
ax.set_xlim(0, 12)
ax.set_ylim(0, 1.2)

def update(frame):
    ydata = u_crit_func(u_0=frame,v_0=1,omega_n=1,zeta=1.2,t=tdata)
    ax.set_title("Displacement versus time for $u_0$ = "+str(np.round(frame,2)))
    line.set_data(tdata, ydata)

ani = FuncAnimation(fig, update, frames=np.linspace(0,1,100),interval = 100)
plt.show()

Effect of the initial velocity

fig, ax = plt.subplots()
tdata = np.linspace(0,12,100)
line, = ax.plot([], [])
ax.set_xlim(0, 12)
ax.set_ylim(0, 1.2)

def update(frame):
    ydata = u_crit_func(u_0=1,v_0=frame,omega_n=1,zeta=1.2,t=tdata)
    ax.set_title("Displacement versus time for $v_0$ = "+str(np.round(frame,2)))
    line.set_data(tdata, ydata)

ani = FuncAnimation(fig, update, frames=np.linspace(0,1,100),interval = 100)
plt.show()

Effect of undamped natural frequency

fig, ax = plt.subplots()
tdata = np.linspace(0,12,100)
line, = ax.plot([], [])
ax.set_xlim(0, 12)
ax.set_ylim(0, 1.2)

def update(frame):
    ydata = u_crit_func(u_0=1,v_0=0.1,omega_n=frame,zeta=1.2,t=tdata)
    ax.set_title("Displacement versus time for $\omega_n$ = "+str(np.round(frame,2)))
    line.set_data(tdata, ydata)

ani = FuncAnimation(fig, update, frames=np.linspace(0.5,2,100),interval = 100)
plt.show()

Sub-critically damped system \(\xi < 1 \)#

u_sol_sub = sp.exp(-zeta*omega_n*t)*(u_0*sp.cos(omega_n**sp.sqrt(1-zeta**2)*t)+(v_0+zeta*omega_n*u_0)/(omega_n*sp.sqrt(1-zeta**2))*sp.sin(omega_n*sp.sqrt(1-zeta**2)*t))
display(u_sol_sub)
\[\displaystyle \left(u_{0} \cos{\left(\omega_{n}^{\sqrt{1 - \zeta^{2}}} t \right)} + \frac{\left(\omega_{n} u_{0} \zeta + v_{0}\right) \sin{\left(\omega_{n} t \sqrt{1 - \zeta^{2}} \right)}}{\omega_{n} \sqrt{1 - \zeta^{2}}}\right) e^{- \omega_{n} t \zeta}\]

Example plot

sp.plot(u_sol_sub.subs([(u_0,1),(v_0,1),(omega_n,1),(zeta,0.05)]),(t,0,42));

Effect of the initial displacement:

u_sub_func = sp.lambdify((u_0,v_0,omega_n,zeta,t),u_sol_sub)
fig, ax = plt.subplots()
tdata = np.linspace(0,42,500)
line, = ax.plot([], [])
ax.set_xlim(0, 42)
ax.set_ylim(-1.5, 1.5)

def update(frame):
    ydata = u_sub_func(u_0=frame,v_0=1,omega_n=1,zeta=0.05,t=tdata)
    ax.set_title("Displacement versus time for $u_0$ = "+str(np.round(frame,2)))
    line.set_data(tdata, ydata)

ani = FuncAnimation(fig, update, frames=np.linspace(0,1,100),interval = 100)
plt.show()

Effect of the initial velocity:

fig, ax = plt.subplots()
tdata = np.linspace(0,42,500)
line, = ax.plot([], [])
ax.set_xlim(0, 42)
ax.set_ylim(-1.5, 1.5)

def update(frame):
    ydata = u_sub_func(u_0=1,v_0=frame,omega_n=1,zeta=0.05,t=tdata)
    ax.set_title("Displacement versus time for $v_0$ = "+str(np.round(frame,2)))
    line.set_data(tdata, ydata)

ani = FuncAnimation(fig, update, frames=np.linspace(0,1,100),interval = 100)
plt.show()

Effect of the undamped natural frequency:

fig, ax = plt.subplots()
tdata = np.linspace(0,42,500)
line, = ax.plot([], [])
ax.set_xlim(0, 42)
ax.set_ylim(-2.2,2.2)

def update(frame):
    ydata = u_sub_func(u_0=1,v_0=0.1,omega_n=frame,zeta=0.05,t=tdata)
    ax.set_title("Displacement versus time for $\omega_n$ = "+str(np.round(frame,2)))
    line.set_data(tdata, ydata)

ani = FuncAnimation(fig, update, frames=np.linspace(0.5,2,100),interval = 100)
plt.show()

Effect of the damping ratio

fig, ax = plt.subplots()
tdata = np.linspace(0,42,500)
line, = ax.plot([], [])
ax.set_xlim(0, 42)
ax.set_ylim(-1.5,1.5)

def update(frame):
    ydata = u_sub_func(u_0=1,v_0=1,omega_n=1,zeta=frame,t=tdata)
    ax.set_title("Displacement versus time for $\zeta$ = "+str(np.round(frame,2)))
    line.set_data(tdata, ydata)

ani = FuncAnimation(fig, update, frames=np.linspace(0.01,0.9,100),interval = 100)
plt.show()