Trisurf Monte Carlo simulator
Samo Penic
2011-03-19 af3bad5b0ffbe0f19b0f85519c85a385326dec03
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++){
SP 12         vesicle->cm[0]+=vtx[i]->data->x;
13         vesicle->cm[1]+=vtx[i]->data->y;
14         vesicle->cm[2]+=vtx[i]->data->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);
SP 28
f74313 29     cell_list_cell_occupation_clear(vesicle->clist);
SP 30     for(i=0;i<n;i++){
31     cellidx=vertex_self_avoidance(vesicle, vesicle->vlist->vtx[i]);
32     vesicle->vlist->vtx[i]->data->cell=vesicle->clist->cell[cellidx];
d7639a 33
f74313 34     cell_add_vertex(vesicle->clist->cell[cellidx],vesicle->vlist->vtx[i]);
d7639a 35
SP 36   //  if(ncx > vesicle->clist.ncmax[0]) vesicle->clist.ncmax[0]=ncx;
37   //  if(ncy > vesicle->clist.ncmax[1]) vesicle->clist.ncmax[1]=ncy;
38   //  if(ncz > vesicle->clist.ncmax[2]) vesicle->clist.ncmax[2]=ncz;
39     }
dac2e5 40     //fprintf(stderr, "Bil sem tu\n"); 
d7639a 41
SP 42
43 /* This was already done in previous for loop.... Have I gained some time? 
44
45
46     for(i=0;i<vesicle->clist.ncmax[0]*vesicle->clist.ncmax[1]*vesicle->clist.ncmax[2];i++){
47         vesicle->clist.cell[i].nvertex=0;
48         for(j=0;j<vesicle->vlist.n;j++){
49             //add_vertextocell;
50             //add_vertextomonomer;
51         }
52     }
53
54 */
55     return TS_SUCCESS;
56 }