]> hackdaworld.org Git - physik/posic.git/commitdiff
more mods
authorhackbard <hackbard>
Mon, 27 Mar 2006 14:29:07 +0000 (14:29 +0000)
committerhackbard <hackbard>
Mon, 27 Mar 2006 14:29:07 +0000 (14:29 +0000)
Makefile
init/init.c
moldyn.c
moldyn.h
posic.c
visual/visual.c

index a6ba0558554f30b4f774161d93d2d70022a1d464..b6e31c03eb7477b32b27a9a476ea703c7240fd3e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ OBJS=init/init.o visual/visual.o math/math.o moldyn.o
 
 all: moldyn.o posic
 
-posic:
+posic: moldyn.o $(OBJS)
        $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) posic.c
 
 clean:
index 07b4dc6fd061e120f2af3b749b7ca2ff7462e97c..daeb3b14b6891848643c9570712ba62f42653a3a 100644 (file)
@@ -35,16 +35,17 @@ int fcc_init(int a,int b,int c,double lc,t_atom *atom,t_3dvec *origin) {
        }
 
        v3_zero(&r);
-       v3_add(&r,&r,&o);
        count=0;
        
        /* fill up the room */
+       r.x=o.x;
        while(r.x<x) {
-               r.y=.0;
+               r.y=o.y;
                while(r.y<y) {
-                       r.z=.0;
+                       r.z=o.z;
                        while(r.z<z) {
                                v3_copy(&(atom[count].r),&r);
+                               atom[count].element=1;
                                count+=1;
                                for(i=0;i<3;i++) {
                                        v3_add(&n,&r,&basis[i]);
index ba3c1a30c8c2bd995a2ac2264d9a79984db01015..e96cdd4bd66e32632087321d07d12173024bec24 100644 (file)
--- a/moldyn.c
+++ b/moldyn.c
@@ -42,8 +42,8 @@ int create_lattice(unsigned char type,int element,double mass,double lc,
                        ret=diamond_init(a,b,c,lc,*atom,&origin);
                        break;
                default:
-                       ret=-1;
                        printf("unknown lattice type (%02x)\n",type);
+                       return -1;
        }
 
        /* debug */
@@ -51,6 +51,7 @@ int create_lattice(unsigned char type,int element,double mass,double lc,
                printf("ok, there is something wrong ...\n");
                printf("calculated -> %d atoms\n",count);
                printf("created -> %d atoms\n",ret);
+               return -1;
        }
 
        while(count) {
@@ -62,3 +63,38 @@ int create_lattice(unsigned char type,int element,double mass,double lc,
        return ret;
 }
 
+int thermal_init(t_atom *atom,int count,double t) {
+
+       /*
+        * - gaussian distribution of velocities
+        * - velocity scaling (E = 3/2 N k T), E: kinetic energy
+        */
+
+       int i;
+       double e,c,v;
+
+       e=.0;
+
+       for(i=0;i<count;i++) {
+               /* x direction */
+               v=gauss_rand();
+               atom[count].v.x=v;
+               e+=0.5*atom[count].mass*v*v;
+               /* y direction */
+               v=gauss_rand();
+               atom[count].v.y=v;
+               e+=0.5*atom[count].mass*v*v;
+               /* z direction */
+               v=gauss_rand();
+               atom[count].v.z=v;
+               e+=0.5*atom[count].mass*v*v;
+       }
+
+       c=sqrt((2.0*e)/(3.0*count*K_BOLTZMANN));
+
+       for(i=0;i<count;i++)
+               v3_scale(&(atom[count].v),&(atom[count].v),(1.0/c));
+
+       return 0;
+}
+
index 1f9800c61b950dc66c2c127a617bb62438573fb2..85bbfd73d894115234476408a66f0fd7747c1164 100644 (file)
--- a/moldyn.h
+++ b/moldyn.h
@@ -23,6 +23,8 @@ typedef struct s_atom {
 
 /* defines */
 
+#define K_BOLTZMANN            1.3807E-23;
+
 #define FCC                    0x01
 #define DIAMOND                        0x02
 
diff --git a/posic.c b/posic.c
index 6d1256fbf6513d40b0ce32146c60b3a7bc5d9ed9..0f05b2b6b6ecd2b6bbbe0317efdb9dd7f715ab58 100644 (file)
--- a/posic.c
+++ b/posic.c
@@ -31,7 +31,7 @@ int main(int argc,char **argv) {
 
        /* init */
        printf("placing silicon atoms\n");
-       count=create_lattice(FCC,Si,M_SI,LC_SI,a,b,c,&si);
+       count=create_lattice(DIAMOND,Si,M_SI,LC_SI,a,b,c,&si);
 
        visual_atoms(&vis,0.0,si,count);
 
index ce4ceaf97cbdd2fdf1873b2b84c35af92d1f67a7..7b7862e02bf15d0a06e4dd5158d489d43b90d26f 100644 (file)
@@ -78,8 +78,8 @@ int visual_atoms(t_visual *v,double time,t_atom *atom,int n) {
        /* script file update */
        dprintf(v->fd,"load xyz %s\n",file);
        dprintf(v->fd,"spacefill 200\n");
-       dprintf(v->fd,"rotate x 11\n");
-       dprintf(v->fd,"rotate y 13\n");
+       dprintf(v->fd,"rotate x 100\n");
+       dprintf(v->fd,"rotate y 10\n");
        dprintf(v->fd,"set ambient 20\n");
        dprintf(v->fd,"set specular on\n");
        sprintf(file,"%s-%.15f.ppm",v->fb,time);