]> hackdaworld.org Git - physik/posic.git/commitdiff
more changes ...
authorhackbard <hackbard>
Sun, 26 Nov 2006 23:05:00 +0000 (23:05 +0000)
committerhackbard <hackbard>
Sun, 26 Nov 2006 23:05:00 +0000 (23:05 +0000)
moldyn.c
moldyn.h

index c7243e04ef82a9d7004059429ce73e00999b52a0..fe54330f002f414d345295ff73dd4d1e6b6b557d 100644 (file)
--- a/moldyn.c
+++ b/moldyn.c
@@ -227,20 +227,22 @@ int moldyn_shutdown(t_moldyn *moldyn) {
        return 0;
 }
 
-int create_lattice(u8 type,int element,double mass,double lc,
-                   int a,int b,int c,t_atom **atom) {
+int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass,
+                   u8 attr,u8 bnum,int a,int b,int c) {
 
        int count;
        int ret;
        t_3dvec origin;
+       t_atom *atom;
 
        count=a*b*c;
+       atom=moldyn->atom;
 
        if(type==FCC) count*=4;
        if(type==DIAMOND) count*=8;
 
-       *atom=malloc(count*sizeof(t_atom));
-       if(*atom==NULL) {
+       atom=malloc(count*sizeof(t_atom));
+       if(atom==NULL) {
                perror("malloc (atoms)");
                return -1;
        }
@@ -249,10 +251,10 @@ int create_lattice(u8 type,int element,double mass,double lc,
 
        switch(type) {
                case FCC:
-                       ret=fcc_init(a,b,c,lc,*atom,&origin);
+                       ret=fcc_init(a,b,c,lc,atom,&origin);
                        break;
                case DIAMOND:
-                       ret=diamond_init(a,b,c,lc,*atom,&origin);
+                       ret=diamond_init(a,b,c,lc,atom,&origin);
                        break;
                default:
                        printf("unknown lattice type (%02x)\n",type);
@@ -268,17 +270,45 @@ int create_lattice(u8 type,int element,double mass,double lc,
        }
 
        while(count) {
-               (*atom)[count-1].element=element;
-               (*atom)[count-1].mass=mass;
+               atom[count-1].element=element;
+               atom[count-1].mass=mass;
+               atom[count-1].attr=attr;
+               atom[count-1].bnum=bnum;
                count-=1;
        }
 
        return ret;
 }
 
-int destroy_lattice(t_atom *atom) {
+int add_atom(t_moldyn *moldyn,int element,double mass,u8 bnum,u8 attr,
+             t_3dvec r,t_3dvec v) {
+
+       t_atom *atom;
+       void *ptr;
+       int count;
+       
+       atom=moldyn->atom;
+       count=++(moldyn->count);
 
-       if(atom) free(atom);
+       ptr=realloc(atom,count*sizeof(t_atom));
+       if(!ptr) {
+               perror("[moldyn] realloc (add atom)");
+               return -1;
+       }
+       
+       atom=ptr;
+       atom->r=r;
+       atom->v=v;
+       atom->element=element;
+       atom->bnum=bnum;
+       atom->attr=attr;
+
+       return 0;
+}
+
+int destroy_atoms(t_moldyn *moldyn) {
+
+       if(moldyn->atom) free(moldyn->atom);
 
        return 0;
 }
@@ -547,14 +577,36 @@ int link_cell_shutdown(t_moldyn *moldyn) {
        return 0;
 }
 
-int moldyn_add_schedule(t_moldyn *moldyn,) {
+int moldyn_add_schedule(t_moldyn *moldyn,int runs,double tau ) {
+
+       int count;
+       void *ptr;
+       t_moldyn_schedule *schedule;
+
+       schedule=moldyn->schedule;
+       count=++(schedule->content_count);
 
+       ptr=realloc(moldyn->schedule.runs,count*sizeof(int));
+       if(!ptr) {
+               perror("[moldyn] realloc (runs)");
+               return -1;
+       }
+       moldyn->schedule.runs[count-1]=runs;
+
+       ptr=realloc(schedule->tau,count*sizeof(double));
+       if(!ptr) {
+               perror("[moldyn] realloc (tau)");
+               return -1;
+       }
+       moldyn->schedule.tau[count-1]=tau;
 
        return 0;
 }
 
 int moldyn_set_schedule_hook(t_moldyn *moldyn,void *hook,void *hook_params) {
 
+       moldyn->schedule.hook=hook;
+       moldyn->schedule.hook_params=hook_params;
        
        return 0;
 }
index a76b3b4f804c9ad83bad01ab0b445b65066b5b1d..a7fa60a2311a4487712ef3f646adbb950430c180 100644 (file)
--- a/moldyn.h
+++ b/moldyn.h
@@ -53,11 +53,11 @@ typedef struct s_linkcell {
 
 #include "visual/visual.h"
 
-# moldyn schedule structure */
+/* moldyn schedule structure */
 typedef struct s_moldyn_schedule {
        int content_count;
        int *runs;
-       int *tau;
+       double *tau;
        int (*hook)(t_moldyn *,void *);
        void *hook_params;
 } t_moldyn_schedule;