top of page
Search

Fortran Code for simulation simple harmonic oscilator.

  • Satyendra Soni (MS.c. Physics)
  • Jan 3, 2018
  • 1 min read

program shm implicit none ! real (kind=16) ::dt=20, m=1, v=0, x=1 , real (kind=16) ::dt=0.1, m=1, v=0, x=1 , & k, f, f1, pe,ke, y integer ::i ! k= 2e-7 k= 1 open (11,file='trajectory',status='unknown') open (12,file='energy',status='unknown') open (13,file='traj.xyz',status='unknown') do i= 1,10000 f= -k*x x = x + dt*v + f/(2*m) * dt**2 f1= -k*x v= v + (f1+f)*dt/(2*m) pe= 0.5*k*x**2 ke= 0.5*m*v**2 !.............writing the trajectory in the file write (11,*) i*dt,x,v write (12,*) x,pe,ke !................................ !.... writing trajectory in VMD................ write (13,*) 1 ! 1 indicate that we have one particle write (13,*) !here you can write comment or else leave it blank write (13,*) "m",x,0,0 ! here you can write the position coordinates !.............................................. end do !................. important information....................... print *, "file= trajectory = i*dt,x,v" print *, "file= energy = x,pe,ke " print *, "file= traj_vmd.xyz = x,pe,ke " !................................................. end program

! for any Query call me 9009035593

! email satyends@iitk.ac.in

 
 
 

Comments


Follow

  • Facebook
  • Twitter
  • LinkedIn

Contact

9009035593,8085474851

Address

Sihora, Madhya Pradesh 483225, India

©2017 BY KC CLASSES. PROUDLY CREATED WITH WIX.COM

bottom of page