Ven's Notes: Vibrations and Waves Simulation + Notes

I'm aspiring to build my own plasma physics simulations but I realized I can't code really slow and I rely on others' work too much. I thought challenging myself to code harmonic motion would be a good excercise by utilzing MIT OCW's course on Vibrations and Waves Problem Solving. I think it'll help a lot with general fundamentals and speed, and I'll see whether I recommend doing this for training this by the end (which should be at day 10).

Harmonic Oscillators

Boundary value solve: choose x(0), x(T), and T

Playback

Equation


        

day 1 / boundary-value SHM notes

Given positions at two times, solve the missing motion constants.

Show SHM boundary-value math
SHM boundary-value notes

Use x(t) as displacement from equilibrium.
Your handwritten notes sometimes use y(t) for vertical displacement.
After shifting the origin to equilibrium, x and y obey the same SHM equation.

Hooke + Newton:
F = -kx
mx'' = -kx
x'' = -(k/m)x
x'' = -omega0^2 x

Natural frequency:
omega0 = sqrt(k/m)

Vertical spring equilibrium offset:
k y0 = mg

After measuring from equilibrium, gravity cancels out of the motion equation:
y'' = -(k/m)y
y'' = -omega0^2 y

General solution:
x(t) = A cos(omega0 t + phi)

At t = 0:
x(0) = A cos(phi)
v(0) = -A omega0 sin(phi)

Boundary-value version:
given x(0) = x0 and x(T) = xT

The code first solves the missing v0:
v0 = omega0(xT - x0 cos(omega0 T)) / sin(omega0 T)

Then convert x0 and v0 into lecture-note constants:
A = sqrt(x0^2 + (v0/omega0)^2)
phi = atan2(-v0/omega0, x0)

Final position:
x(t) = A cos(omega0 t + phi)

Once x(t) is known:
v(t) = x'(t)
a(t) = x''(t) = -omega0^2 x(t)
F(t) = ma(t) = -kx(t)

Period:
Tperiod = 2pi/omega0
Tperiod = 2pi sqrt(m/k)

Singular boundary times:
sin(omega0 T) = 0
T = n*pi/omega0

At those times, the boundary target may be impossible or non-unique.
Show raw handwritten notes
Handwritten SHM notes spread
SHM review, spring force, omega, vertical spring setup.
Handwritten vertical spring notes
Vertical spring, equilibrium offset, no damping, period notes.