Professional Documents
Culture Documents
Requirement dx p
= (5)
dt m
Study the simple harmonic oscillator problem
using molecular dynamics. dp
= −K ⋅ x (6)
dt
Introduction
The error plot can be verified by having a look The Fig.(3) shows a periodic behavior with
at the Fig.(2) showing a comparison of the computed time. The error in position increases with time to a
energies with the analytic value. The analytic energy local maximum and then drops down to near zero, and
is a constant that was calculated earlier using the then increases again. This behavior is observed to
system parameters see eqn.(4). Both the Figs.(1),(2) have a periodicity with time. Also the integrated error
show the same behavior. shows a gradual increase with time.
x = 2 E ⋅ Sin (ω ⋅ t ) (8)
here,
K
ω= = 1.0 and (9)
m
E = 8.0 units
References
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#include<limits.h>
#include<time.h>
#define M 1.0
#define K 1.0
#define INITIAL_T 0.0
#define FINAL_T 10.0
#define ENERGY 8.0
#define INITIAL_X 0.0
#define DELTA 0.01
FILE *fp,*error_fp;
fprintf(stderr,"Simulation Completed\n");
}
// END OF MAIN PROGRAM
//FUNCTION DEFINITIONS
//THIS FUNCTION PERFORMS THE OPENING AND CLOSING OF DATA FILES
void do_calculation()
{
double x,p,t,e,analytic_x;
double new_x,new_p,error_e,error_x;