






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
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
1 / 10
This page cannot be seen from the preview
Don't miss anything!
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)
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
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:
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