Trisurf Monte Carlo simulator
Samo Penic
2012-06-07 5bb11d36948f9ccc243711d4e9caf4b19b3c384b
commit | author | age
d7639a 1 #include<stdlib.h>
SP 2 #include "general.h"
3 #include "cell.h"
f74313 4 #include "frame.h"
d7639a 5 ts_bool centermass(ts_vesicle *vesicle){
f74313 6     ts_uint i, n=vesicle->vlist->n;
SP 7     ts_vertex **vtx=vesicle->vlist->vtx;
d7639a 8     vesicle->cm[0]=0;
SP 9     vesicle->cm[1]=0;
10     vesicle->cm[2]=0;
f74313 11     for(i=0;i<n;i++){
8f6a69 12         vesicle->cm[0]+=vtx[i]->x;
SP 13         vesicle->cm[1]+=vtx[i]->y;
14         vesicle->cm[2]+=vtx[i]->z; 
d7639a 15     } 
dac2e5 16     vesicle->cm[0]/=(ts_float)n;
SP 17     vesicle->cm[1]/=(ts_float)n;
18     vesicle->cm[2]/=(ts_float)n;
d7639a 19     return TS_SUCCESS;
SP 20 }
21
f74313 22 ts_bool cell_occupation(ts_vesicle *vesicle){
SP 23     ts_uint i,cellidx, n=vesicle->vlist->n;
d7639a 24     ts_double shift;
SP 25     ts_double dcell;
f74313 26     shift=(ts_double) vesicle->clist->ncmax[0]/2;
d7639a 27     dcell=1.0/(1.0 + vesicle->stepsize);
34d3de 28     //`fprintf(stderr, "Bil sem tu\n"); 
d7639a 29
f74313 30     cell_list_cell_occupation_clear(vesicle->clist);
SP 31     for(i=0;i<n;i++){
32     cellidx=vertex_self_avoidance(vesicle, vesicle->vlist->vtx[i]);
8f6a69 33     vesicle->vlist->vtx[i]->cell=vesicle->clist->cell[cellidx];
d7639a 34
f74313 35     cell_add_vertex(vesicle->clist->cell[cellidx],vesicle->vlist->vtx[i]);
d7639a 36
SP 37     }
dac2e5 38     //fprintf(stderr, "Bil sem tu\n"); 
41a035 39     if(dcell);
SP 40     if(shift);
d7639a 41     return TS_SUCCESS;
SP 42 }