Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Numerical Integration of Damped Harmonic Oscillator with Verlet Algorithm, Study notes of Physics

The fortran code for simulating the motion of a damped, driven harmonic oscillator using the verlet algorithm. The code includes the calculation of potential and kinetic energy, as well as the comparison of the numerical results with the analytical solution. The document also includes plots of the position differences between the exact and numerical solutions and the total energy conservation.

Typology: Study notes

2009/2010

Uploaded on 02/25/2010

koofers-user-9di
koofers-user-9di 🇺🇸

5

(1)

10 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Damped, driven oscillator
• Start with the case where q=0, FD=0
• y(t)= Acos ω0t + Bsin ω0t
• Initial conditions, A=y0, B=v0 /ω0
• Energy (kinetic + potential) should be conserved!
Compare with analytical to verify code, also
test energy conservation!
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Numerical Integration of Damped Harmonic Oscillator with Verlet Algorithm and more Study notes Physics in PDF only on Docsity!

Damped, driven oscillator

  • Start with the case where q=0, F D
  • y(t)= Acos ω 0 t + Bsin ω 0 t
  • Initial conditions, A=y 0 , B=v 0 /ω 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+ = 2y n - y n- - ω 0 2 dt 2 y n c force/mass from spring force = -om02ynow c integrate to get y at next time step, use Verlet ynext = 2.0d0ynow-ylast+dt*2force

Energy calculation, analytical, and output

potential = 0.5d0sk * ynow* kinetic = 0.5d0vnow* etot = potential + kinetic write (6,100) t,ynow,yanalytic,diff,potential,kinetic, : etot 100 format(f8.4,6(2x,f12.6)) c velocity at current timestep vnow = (ynext-ylast)/(2.0d0*dt)

For ω

0

= 1, dt=0.

gnuplot> set term jpeg Terminal type set to 'jpeg' Options are 'small size 640,480 ' gnuplot> set output 'displace.jpg' gnuplot> plot 'output','output' using 1:3,'output' using 1: Difference between exact and numerical

Damped, driven harmonic oscillator

  • Have to work out numerical integration using Verlet!
  • Case with q=0, F D =0 serves as starting point
  • Damping, driving force mean energy not conserved
  • Can still compare to analytical y(t) after transient decays y(t) = c e -qt sin(βt + φ) In the underdamped regime, q < ω 0 For q=0.01, ω 0 =1, transient decays away τ=1/q = 100 After decay of transient, analytical behavior is y(t) = A sin(Ω D t - γ)

Damped, driven oscillator, position vs. time

Terminal type set to 'jpeg' Options are 'small size 640,480 ' gnuplot> set output 'damped1.jpg' gnuplot> plot [300:400] 'output' using 1:2,'output' using 1:

Code for the analytical result, comparison

c Next three lines are for the damped, driven harmonic oscillator A = F/dsqrt((om02-om2)2+(2.0d0qom0)2)! used for damp phi = datan(2.0d0omq/(om02-om2))! used for damped driven yanalytic = Adcos(omt-phi)! used for damped driven oscillator diff = ynow - yanalytic Notice the transient behavior, which depends on the initial conditions, is not included here which explains the differences seen in the preceding slide