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 a6ba055..b6e31c0 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 07b4dc6..daeb3b1 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 ba3c1a3..e96cdd4 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 1f9800c..85bbfd7 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 6d1256f..0f05b2b 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 ce4ceaf..7b7862e 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);