]> hackdaworld.org Git - physik/posic.git/commitdiff
more testing
authorhackbard <hackbard>
Mon, 20 Mar 2006 23:29:00 +0000 (23:29 +0000)
committerhackbard <hackbard>
Mon, 20 Mar 2006 23:29:00 +0000 (23:29 +0000)
clean [new file with mode: 0755]
doit [new file with mode: 0755]
perms [new file with mode: 0755]
posic.c
posic.h
ppm2avi [new file with mode: 0755]

diff --git a/clean b/clean
new file mode 100755 (executable)
index 0000000..2e1cd0e
--- /dev/null
+++ b/clean
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+rm -f saves/* video/*
diff --git a/doit b/doit
new file mode 100755 (executable)
index 0000000..04ece04
--- /dev/null
+++ b/doit
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+./clean
+gcc -o posic posic.c -Wall
+./posic
+./perms
+rasmol
+./ppm2avi
+mplayer video/md.avi
diff --git a/perms b/perms
new file mode 100755 (executable)
index 0000000..d1f5e41
--- /dev/null
+++ b/perms
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+chmod 640 saves/*
diff --git a/posic.c b/posic.c
index 997127e75a0a6490a31396fe3abb1c6f01b6b99c..8910dddecd353f04004e11d9eddc20135882703e 100644 (file)
--- a/posic.c
+++ b/posic.c
@@ -26,7 +26,8 @@ int main(int argc,char **argv) {
        double lj1,lj2,lj;
 
        /* silicon */
-       amount_si=AMOUNT_SI;
+       //amount_si=AMOUNT_SI;
+       amount_si=2;
        printf("simulating %d silicon atoms\n",amount_si);
        si=malloc(amount_si*sizeof(t_atom));
        if(!si) {
@@ -38,6 +39,7 @@ int main(int argc,char **argv) {
 
        /* init */
        printf("placing silicon atoms\n");
+       /*
        for(i=0;i<amount_si;i++) {
                si[i].x=RAND(LEN_X);
                si[i].y=RAND(LEN_Y);
@@ -49,6 +51,13 @@ int main(int argc,char **argv) {
                si[i].fy=.0;
                si[i].fz=.0;
        }
+       */
+       si[0].x=-2.0;
+       si[1].x=+2.0;
+       si[0].y=0;
+       si[0].z=0;
+       si[1].y=0;
+       si[1].z=0;
 
        /* time */
        time=.0;
@@ -93,6 +102,10 @@ int main(int argc,char **argv) {
                si[i].vx+=(tau*si[i].fx/m2);
                si[i].vy+=(tau*si[i].fy/m2);
                si[i].vz+=(tau*si[i].fz/m2);
+               /* reset of forces */
+               si[i].fx=.0;
+               si[i].fy=.0;
+               si[i].fz=.0;
        }
        for(i=0;i<amount_si;i++) {
                /* calculation of forces at new positions r(t+h) */
@@ -121,21 +134,23 @@ int main(int argc,char **argv) {
                                lj1*=LJ_SIGMA_12;
                                lj2*=LJ_SIGMA_06;
                                lj=-2*lj1+lj2;
-                               si[i].fx=lj*deltax;
-                               si[i].fy=lj*deltay;
-                               si[i].fz=lj*deltaz;
-                               si[i].fx=-lj*deltax;
-                               si[i].fy=-lj*deltay;
-                               si[i].fz=-lj*deltaz;
+                               si[i].fx-=lj*deltax;
+                               si[i].fy-=lj*deltay;
+                               si[i].fz-=lj*deltaz;
+                               si[j].fx+=lj*deltax;
+                               si[j].fy+=lj*deltay;
+                               si[j].fz+=lj*deltaz;
                        }
                }
+       }
+       for(i=0;i<amount_si;i++) {
                /* calculation of new velocities v(t+h) */
                si[i].vx+=(tau*si[i].fx/m2);
                si[i].vy+=(tau*si[i].fy/m2);
                si[i].vz+=(tau*si[i].fz/m2);
        }
 
-       if(!(runs%10)) {
+       if(!(runs%100)) {
 
        /* rasmol script & xyz file */
        sprintf(xyz,"./saves/si-%.15f.xyz",time);
@@ -146,17 +161,27 @@ int main(int argc,char **argv) {
                return -1;
        }
        dprintf(fd2,"load xyz %s\n",xyz);
-       dprintf(fd2,"spacefill 200\n");
+       //dprintf(fd2,"spacefill 200\n");
+       dprintf(fd2,"spacefill\n");
        dprintf(fd2,"rotate x 11\n");
        dprintf(fd2,"rotate y 13\n");
        dprintf(fd2,"set ambient 20\n");
        dprintf(fd2,"set specular on\n");
        dprintf(fd2,"write ppm %s\n",ppm);
        dprintf(fd2,"zap\n");
-       dprintf(fd1,"%d\nsilicon\n",amount_si);
+       dprintf(fd1,"%d\nsilicon\n",amount_si+9);
        for(i=0;i<amount_si;i++)
                dprintf(fd1,"Si %f %f %f %f\n",
                        si[i].x,si[i].y,si[i].z,time);
+       dprintf(fd1,"H 0.0 0.0 0.0 %f\n",time);
+       dprintf(fd1,"He %f %f %f %f\n",LX,LY,LZ,time);
+       dprintf(fd1,"He %f %f %f %f\n",-LX,LY,LZ,time);
+       dprintf(fd1,"He %f %f %f %f\n",LX,-LY,LZ,time);
+       dprintf(fd1,"He %f %f %f %f\n",LX,LY,-LZ,time);
+       dprintf(fd1,"He %f %f %f %f\n",-LX,-LY,LZ,time);
+       dprintf(fd1,"He %f %f %f %f\n",-LX,LY,-LZ,time);
+       dprintf(fd1,"He %f %f %f %f\n",LX,-LY,-LZ,time);
+       dprintf(fd1,"He %f %f %f %f\n",-LX,-LY,-LZ,time);
        close(fd1);
 
        }
diff --git a/posic.h b/posic.h
index fa0846e71d9b52102e096082ff4ddf2e774e904c..755ddc6eae9592155af3807f0eb1681922c2b35b 100644 (file)
--- a/posic.h
+++ b/posic.h
@@ -24,7 +24,7 @@
 #define LEN_Z 50
 #define LZ (1.0*LEN_Z/2)
 
-#define RUNS 1000
+#define RUNS 10000
 #define TAU 0.001
 
 #define R_CUTOFF 20
diff --git a/ppm2avi b/ppm2avi
new file mode 100755 (executable)
index 0000000..febe86c
--- /dev/null
+++ b/ppm2avi
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+for i in video/*.ppm; do
+       convert $i video/$(basename $i ppm)png
+done
+
+mencoder mf://video/*.png -ovc copy -o video/md.avi