This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Damped, driven oscillator • Start with the case where q=0, F D =0 • y(t)= Acos ω t + Bsin ω t • Initial conditions, A=y , B=v 0 / ω • Energy (kinetic + potential) should be conserved! Compare with analytical to verify code, also test energy conservation! Test with simple harmonic oscillator • Use Verlet algoritim y n+1 = 2y n- y n-1 - ω 2 dt 2 y n c force/mass from spring force = -om0**2*ynow c integrate to get y at next time step, use Verlet Test with simple harmonic oscillator • Use Verlet algoritim y n+1 = 2y n- y n-1 - ω 2 dt 2 y n c force/mass from spring force = -om0**2*ynow c integrate to get y at next time step, use Verlet ynext = 2.0d0*ynow-ylast+dt**2*force Initial conditions, analytic solution • Analytic result computed for comparison • Verlet algorithm needs position at two previous times • Translate into initial position and initial velocity y(t)= Acos ω t + Bsin ω t Initial conditions, A=y , B=v 0 / ω c velocity at current timestep vnow = (ynext-ylast)/(2.0d0*dt)vnow = (ynext-ylast)/(2....
View Full Document