Frontmatter

If you are publishing this notebook on the web, you can set the parameters below to provide HTML metadata. This is useful for search engines and social media.

using Plots, PlutoUI
2.6 s

Demonstrating a typical second order system

A typical second order system has the following form:

$$ \ddot x + 2 \zeta \omega_n \dot x + \omega_n^2 = 0 $$

where $\omega_n$ is the natural frequency of the system and $\zeta$ is the damping ratio. Depending on the $\zeta$ we can observe four distinct behaviors for any given initial dispalcement $x_0$ and velocity $v_0$. See the textbook or lecture note 13.

md"""#### Demonstrating a typical second order system

A typical second order system has the following form:

```math

\ddot x + 2 \zeta \omega_n \dot x + \omega_n^2 = 0
```

where $\omega_n$ is the natural frequency of the system and $\zeta$ is the damping ratio. Depending on the $\zeta$ we can observe four distinct behaviors for any given initial dispalcement $x_0$ and velocity $v_0$. See the textbook or lecture note 13.
"""
2.4 ms

Set the value of the natural frequency and damping coefficient of the system using the slider below:

ωₙ: 10

ζ: 1.0

md""" Set the value of the natural frequency and damping coefficient of the system using the slider below:

ωₙ: $(@bind freq Slider(2:1:50, default=10, show_value=true))

ζ: $(@bind damp Slider([0,0.001,0.01, 0.1, 1, 1.5], default=1, show_value =true))
"""
332 ms

Undamped: If $\zeta=0$ we say that the system is undamped and its solution is

$$x(t) = x_0 \cos (\omega_n t) + \dfrac{v_0}{\omega_n} \sin (\omega_n t)$$

which oscillates forever (a pure sinsoid) which corresponds to purely imaginary roots for the characteristic equation.

$$s^2 + 2 \omega_n \zeta s + \omega_n^2 = 0 $$

Underdamped: If $\zeta \in (0, 1)$, the system is said to be under-damped and we get

$$x(t) = \left[ x_0 \cos (\omega_d t) + \dfrac{v_0 + \zeta \omega_n x_0}{\omega_d} \sin(\omega_d t) \right] e^{-\zeta \omega_nt}$$

where $\omega_d = \omega_n \sqrt{1-\zeta^2}$ is called the damped frequency. In this case the oscillations eventually die out because we have an exponentially decay term multiplying the sinusoid. This corresponds the case of general complex roots.

md"""
**Undamped:** If $\zeta=0$ we say that the system is undamped and its solution is
```math
x(t) = x_0 \cos (\omega_n t) + \dfrac{v_0}{\omega_n} \sin (\omega_n t)
```
which oscillates forever (a pure sinsoid) which corresponds to purely imaginary roots for the characteristic equation.

```math
s^2 + 2 \omega_n \zeta s + \omega_n^2 = 0
```
**Underdamped:** If $\zeta \in (0, 1)$, the system is said to be under-damped and we get
```math
x(t) = \left[ x_0 \cos (\omega_d t) + \dfrac{v_0 + \zeta \omega_n x_0}{\omega_d} \sin(\omega_d t) \right] e^{-\zeta \omega_nt}
```

where $\omega_d = \omega_n \sqrt{1-\zeta^2}$ is called the damped frequency. In this case the oscillations eventually die out because we have an exponentially decay term multiplying the sinusoid. This corresponds the case of general complex roots.
"""
482 μs

Set the value of the initial displacement & initial velocity below:

x₀: 0.5

v₀: 0

md"""Set the value of the initial displacement & initial velocity below:


x₀: $(@bind initdisp Slider(-1:0.1:1, default=0.5, show_value=true))

v₀: $(@bind initvel Slider(-70:1:70, default=0, show_value=true))
"""
113 ms
begin
plot(t, response(freq, damp, initdisp, initvel), label=false, ylim=(-5, 5))
end
78.3 ms

Overdamped: If $\zeta>1$ the system is called over-damped and the solution is

$$x(t) = \left[ x_0 \cos(\beta t) + \dfrac{v_0 + \zeta \omega_d x_0}{\omega_d}\sin (\beta t)\right]e^{-\zeta \omega_n t}$$

where $\beta = \omega_n \sqrt{\zeta^1-1}$. In this case the system never oscillates and corresponds to having no complex roots, i.e. purely real roots.

Critically damped: Finally the system is called critically damped when $\zeta=1$ and in this case

$$x(t) = \left( x_0 +\omega_n x_0 t +v_0t\right)e^{-\omega_n t}$$

This is an interesting case because this is the case in which the system reaches steady state fastest. This occurs when the charactersistic equation only has a single repeated root.

md"""
**Overdamped:** If $\zeta>1$ the system is called over-damped and the solution is
```math
x(t) = \left[ x_0 \cos(\beta t) + \dfrac{v_0 + \zeta \omega_d x_0}{\omega_d}\sin (\beta t)\right]e^{-\zeta \omega_n t}
```
where $\beta = \omega_n \sqrt{\zeta^1-1}$. In this case the system never oscillates and corresponds to having no complex roots, i.e. purely real roots.


**Critically damped:** Finally the system is called critically damped when $\zeta=1$ and in this case
```math
x(t) = \left( x_0 +\omega_n x_0 t +v_0t\right)e^{-\omega_n t}
```
This is an interesting case because this is the case in which the system reaches steady state fastest. This occurs when the charactersistic equation only has a single repeated root.
"""
452 μs
const t = 0.:1e-3:2;
3.0 ms
response (generic function with 5 methods)
function response(f₀ = 10., ξ = 0.01, x₀ = 1., v₀ = 1.)
ω₀ = 2π*f₀ # Natural angular frequency
if 0.ξ < 1. # Undamped/Under-damped response
Ω₀ = ω₀*√(1. - ξ^2)
x = (x₀*cos.(Ω₀*t) + (v₀ + ξ*ω₀*x₀)*sin.(Ω₀*t)/Ω₀).*exp.(-ξ*ω₀*t)
elseif ξ == 1. # Critically damped response
x = @. (x₀ + ω₀*x₀*t + v₀*t)*exp(-ω₀*t)
else # Over-damped response
β = ω₀*√(ξ^2 - 1.)
x = @. (x₀*cosh(β*t) + (v₀ + ξ*ω₀*x₀*sinh(β*t))/β)*exp(-ξ*ω₀*t)
end
end
5.0 ms
damping (generic function with 1 method)
function damping(value)
if value == 1
return 0.
elseif value == 2
return 0.001
elseif value == 3
return 0.01
elseif value == 4
return 0.1
elseif value == 5
return 1.
else
return 1.5
end
end
736 μs