Trisurf Monte Carlo simulator
Samo Penic
2010-12-27 3131dcbf73ff8a0699a688119d57eaf386f49590
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     } 
f74313 16     vesicle->cm[0]/=(float)n;
SP 17     vesicle->cm[1]/=(float)n;
18     vesicle->cm[2]/=(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++){
d7639a 31   
f74313 32     cellidx=vertex_self_avoidance(vesicle, vesicle->vlist->vtx[i]);
SP 33     vesicle->vlist->vtx[i]->data->cell=vesicle->clist->cell[cellidx];
d7639a 34
f74313 35     cell_add_vertex(vesicle->clist->cell[cellidx],vesicle->vlist->vtx[i]);
d7639a 36
SP 37   //  if(ncx > vesicle->clist.ncmax[0]) vesicle->clist.ncmax[0]=ncx;
38   //  if(ncy > vesicle->clist.ncmax[1]) vesicle->clist.ncmax[1]=ncy;
39   //  if(ncz > vesicle->clist.ncmax[2]) vesicle->clist.ncmax[2]=ncz;
40     }
41
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 }