Presentation is loading. Please wait.

Presentation is loading. Please wait.

SPRING TWO MASSES – CREATING XYZ FILE AND ANIMATION.

Similar presentations


Presentation on theme: "SPRING TWO MASSES – CREATING XYZ FILE AND ANIMATION."— Presentation transcript:

1 SPRING TWO MASSES – CREATING XYZ FILE AND ANIMATION

2 XYZ file format

3 XYZ file format - animation

4 SPRING OPEN NEW SCRIPT!

5 SPRING - initial values
clc clear L=1; k=1; m=1; T=10; dt=0.1; n=T/dt;

6 SPRING - initial values
x1(1)=-0.5; x2(1)=L+1; t(1)=0;

7 SPRING - animation f=mopen("harmonic.xyz", "w"); //creating file "harmonic.xyz" for writing mfprintf(f,"2\n"); // 2 for the number of atoms and "\n" for the new line mfprintf(f,"\n"); mfprintf(f,"C %8.3f %8.3f %8.3f\n",x1(1),0,0); mfprintf(f,"C %8.3f %8.3f %8.3f\n",x2(1),0,0); // C is the symbol of atom, 8 represents the size of the text box with number, 3 - number of decimal digits, x2(1) represents x coordinate, y and z

8 SPRING - loop for i=1:n dl=(x2(i)-x1(i)-L); dv1=k*dl/m*dt; dv2=-dv1;
v1(i+1)=v1(i)+dv1; v2(i+1)=v2(i)+dv2; x1(i+1)=x1(i)+v1(i+1)*dt; x2(i+1)=x2(i)+v2(i+1)*dt; t(i+1)=t(i)+dt; mfprintf(f,"2\n"); mfprintf(f,"\n"); mfprintf(f,"C %8.3f %8.3f %8.3f\n",x1(i+1),0,0); mfprintf(f,"C %8.3f %8.3f %8.3f\n",x2(i+1),0,0); end plot(t,x1,t,x2) mclose(f) // closing the file

9 TO EXECUTE

10 SPRING - results

11 SPRING - animation Open VMD. Go to File|New Molecule…

12 SPRING - animation In the Molecule File Browser click Browse…
Look for file: harmonic.xyz in the Documents and open it. Click Load.

13 SPRING - animation Then go to Graphics| Representations…

14 SPRING - animation Go to Drawing method and choose CPK.
Open VMD OpenGL Display Window and enjoy the result.


Download ppt "SPRING TWO MASSES – CREATING XYZ FILE AND ANIMATION."

Similar presentations


Ads by Google