SPRING TWO MASSES – CREATING XYZ FILE AND ANIMATION
XYZ file format
XYZ file format - animation
SPRING OPEN NEW SCRIPT!
SPRING - initial values clc clear L=1; k=1; m=1; T=10; dt=0.1; n=T/dt;
SPRING - initial values x1(1)=-0.5; x2(1)=L+1; t(1)=0;
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, 0 - y and z
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
TO EXECUTE
SPRING - results
SPRING - animation Open VMD. Go to File|New Molecule…
SPRING - animation In the Molecule File Browser click Browse… Look for file: harmonic.xyz in the Documents and open it. Click Load.
SPRING - animation Then go to Graphics| Representations…
SPRING - animation Go to Drawing method and choose CPK. Open VMD OpenGL Display Window and enjoy the result.