Trisurf Monte Carlo simulator
Samo Penic
2014-03-08 62681163a4c47fc6dbd6b2b96f84171b20cba3ed
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){
3a018d 6     ts_uint i,j, n=vesicle->vlist->n;
f74313 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;
919555 19
SP 20     for(i=0;i<n;i++){
21         vtx[i]->x-=vesicle->cm[0];
22         vtx[i]->y-=vesicle->cm[1];
23         vtx[i]->z-=vesicle->cm[2]; 
24     } 
25
3a018d 26     for(i=0;i<vesicle->poly_list->n;i++){
M 27         for(j=0;j<vesicle->poly_list->poly[i]->vlist->n;j++){
28             vesicle->poly_list->poly[i]->vlist->vtx[j]->x-=vesicle->cm[0];
29             vesicle->poly_list->poly[i]->vlist->vtx[j]->y-=vesicle->cm[1];
30             vesicle->poly_list->poly[i]->vlist->vtx[j]->z-=vesicle->cm[2];
31         }
32     }
33
34
a63f17 35     vesicle->cm[0]=0;
SP 36     vesicle->cm[1]=0;
37     vesicle->cm[2]=0;
38
d7639a 39     return TS_SUCCESS;
SP 40 }
41
f74313 42 ts_bool cell_occupation(ts_vesicle *vesicle){
48bb92 43     ts_uint i,j,cellidx, n=vesicle->vlist->n;
M 44     //ts_double shift;
45     //ts_double dcell;
46     //shift=(ts_double) vesicle->clist->ncmax[0]/2;
47     //dcell=1.0/(1.0 + vesicle->stepsize);
34d3de 48     //`fprintf(stderr, "Bil sem tu\n"); 
d7639a 49
f74313 50     cell_list_cell_occupation_clear(vesicle->clist);
SP 51     for(i=0;i<n;i++){
52     cellidx=vertex_self_avoidance(vesicle, vesicle->vlist->vtx[i]);
a63f17 53 //    already done in cell_add_vertex
SP 54 //    vesicle->vlist->vtx[i]->cell=vesicle->clist->cell[cellidx];
d7639a 55
f74313 56     cell_add_vertex(vesicle->clist->cell[cellidx],vesicle->vlist->vtx[i]);
d7639a 57     }
48bb92 58
M 59     for(i=0;i<vesicle->poly_list->n;i++){
60     for(j=0;j<vesicle->poly_list->poly[i]->vlist->n;j++){
61         cellidx=vertex_self_avoidance(vesicle, vesicle->poly_list->poly[i]->vlist->vtx[j]);
62         cell_add_vertex(vesicle->clist->cell[cellidx],vesicle->poly_list->poly[i]->vlist->vtx[j]);
63     }
64     }
65
66     
67
dac2e5 68     //fprintf(stderr, "Bil sem tu\n"); 
48bb92 69     //if(dcell);
M 70     //if(shift);
d7639a 71     return TS_SUCCESS;
SP 72 }