projects
/
physik
/
posic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ff1bf11
)
check_per_bound, comparing real numbers <- problem! think about it!
author
hackbard
<hackbard>
Tue, 12 Dec 2006 15:58:40 +0000
(15:58 +0000)
committer
hackbard
<hackbard>
Tue, 12 Dec 2006 15:58:40 +0000
(15:58 +0000)
moldyn.c
patch
|
blob
|
history
diff --git
a/moldyn.c
b/moldyn.c
index
aaab0de
..
44b53b6
100644
(file)
--- a/
moldyn.c
+++ b/
moldyn.c
@@
-236,10
+236,11
@@
int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass,
count=a*b*c;
count=a*b*c;
+ /* how many atoms do we expect */
if(type==FCC) count*=4;
if(type==FCC) count*=4;
-
if(type==DIAMOND) count*=8;
if(type==DIAMOND) count*=8;
+ /* allocate space for atoms */
moldyn->atom=malloc(count*sizeof(t_atom));
if(moldyn->atom==NULL) {
perror("malloc (atoms)");
moldyn->atom=malloc(count*sizeof(t_atom));
if(moldyn->atom==NULL) {
perror("malloc (atoms)");
@@
-262,9
+263,10
@@
int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass,
/* debug */
if(ret!=count) {
/* debug */
if(ret!=count) {
- printf("ok, there is something wrong ...\n");
- printf("calculated -> %d atoms\n",count);
- printf("created -> %d atoms\n",ret);
+ printf("[moldyn] creating lattice failed\n");
+ printf(" amount of atoms\n");
+ printf(" - expected: %d\n",count);
+ printf(" - created: %d\n",ret);
return -1;
}
return -1;
}
@@
-280,7
+282,6
@@
int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass,
check_per_bound(moldyn,&(moldyn->atom[count].r));
}
check_per_bound(moldyn,&(moldyn->atom[count].r));
}
-
return ret;
}
return ret;
}
@@
-971,9
+972,9
@@
int check_per_bound(t_moldyn *moldyn,t_3dvec *a) {
dim=&(moldyn->dim);
dim=&(moldyn->dim);
- x=
0.5*dim->x
;
- y=
0.5*dim->y
;
- z=
0.5*dim->z
;
+ x=
dim->x/2
;
+ y=
dim->y/2
;
+ z=
dim->z/2
;
if(moldyn->status&MOLDYN_STAT_PBX) {
if(a->x>=x) a->x-=dim->x;
if(moldyn->status&MOLDYN_STAT_PBX) {
if(a->x>=x) a->x-=dim->x;
@@
-987,6
+988,7
@@
int check_per_bound(t_moldyn *moldyn,t_3dvec *a) {
if(a->z>=z) a->z-=dim->z;
else if(-a->z>z) a->z+=dim->z;
}
if(a->z>=z) a->z-=dim->z;
else if(-a->z>z) a->z+=dim->z;
}
+printf("%f %f %f\n",a->x,x,a->x/x);
return 0;
}
return 0;
}
@@
-1642,13
+1644,13
@@
int moldyn_bc_check(t_moldyn *moldyn) {
for(i=0;i<moldyn->count;i++) {
if(atom[i].r.x>=dim->x/2||-atom[i].r.x>dim->x/2)
printf("FATAL: atom %d: x: %.20f (%.20f)\n",
for(i=0;i<moldyn->count;i++) {
if(atom[i].r.x>=dim->x/2||-atom[i].r.x>dim->x/2)
printf("FATAL: atom %d: x: %.20f (%.20f)\n",
- i,atom[i].r.x
*1e10,dim->x/2*1e10
);
+ i,atom[i].r.x
,dim->x/2
);
if(atom[i].r.y>=dim->y/2||-atom[i].r.y>dim->y/2)
printf("FATAL: atom %d: y: %.20f (%.20f)\n",
if(atom[i].r.y>=dim->y/2||-atom[i].r.y>dim->y/2)
printf("FATAL: atom %d: y: %.20f (%.20f)\n",
- i,atom[i].r.y
*1e10,dim->y/2*1e10
);
+ i,atom[i].r.y
,dim->y/2
);
if(atom[i].r.z>=dim->z/2||-atom[i].r.z>dim->z/2)
printf("FATAL: atom %d: z: %.20f (%.20f)\n",
if(atom[i].r.z>=dim->z/2||-atom[i].r.z>dim->z/2)
printf("FATAL: atom %d: z: %.20f (%.20f)\n",
- i,atom[i].r.z
*1e10,dim->z/2*1e10
);
+ i,atom[i].r.z
,dim->z/2
);
}
return 0;
}
return 0;