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;
}
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);
}
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;
}
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;
}