Trisurf Monte Carlo simulator
Samo Penic
2014-12-16 6bc95bfe19012a33f185adf1476e623d98d33465
commit | author | age
262607 1 #include<stdio.h>
SP 2 #include<math.h>
3 #include "general.h"
4 #include "vertex.h"
5 #include "bond.h"
6 #include "triangle.h"
7 #include "cell.h"
8 #include "vesicle.h"
9 #include "io.h"
10 #include "initial_distribution.h"
11 #include "frame.h"
12 #include "timestep.h"
13 #include "sh.h"
14
15 /** Entrance function to the program
16   * @param argv is a number of parameters used in program call (including the program name
17   * @param argc is a pointer to strings (character arrays) which holds the arguments
18   * @returns returns 0 on success, any other number on fail.
19 */
20 ts_bool saveAvgUlm2(ts_vesicle *vesicle);
21 int main(int argv, char *argc[]){
a63f17 22 ts_uint i,j,k;
262607 23 ts_vesicle *vesicle;
SP 24 ts_double r0;
25 vesicle=initial_distribution_dipyramid(17,60,60,60,0.15);
26 //parsetape(vesicle,&i);
27
59c7f5 28 //similar to nmax in fortran code
M 29 ts_uint nmax;
30
262607 31 //these four must come from parsetype!
SP 32 vesicle->dmax=1.67*1.67;
33 vesicle->stepsize=0.15;
34 vesicle->clist->max_occupancy=8;
35 vesicle->bending_rigidity=25.0;
36 //fprintf(stderr,"xk=%f",vesicle->bending_rigidity);
37
919555 38     centermass(vesicle);
a63f17 39 cell_occupation(vesicle);
SP 40
41 //test if the structure is internally organized into cells correctly 
42 ts_uint cind;
43 for(i=0;i<vesicle->vlist->n;i++){
44     cind=vertex_self_avoidance(vesicle, vesicle->vlist->vtx[i]);
45
46     if(vesicle->clist->cell[cind]==vesicle->vlist->vtx[i]->cell){
47         //fprintf(stdout,"(T) Idx match!\n");
48     } else {
49         fprintf(stderr,"(T) ***** Idx don't match!\n");
50
51     }
52 }
53 //end test
262607 54 vesicle->sphHarmonics=sph_init(vesicle->vlist, 21);
SP 55
56 vesicle_volume(vesicle);
57 r0=getR0(vesicle);
58
59 preparationSh(vesicle,r0);
60 calculateYlmi(vesicle);
61 calculateUlm(vesicle);
62
60bc6a 63 //preloop:
37d14a 64 ts_double vmsr, bfsr;
60bc6a 65 for(i=0;i<1000;i++){
M 66     cell_occupation(vesicle);
67     for(j=0;j<1000;j++){
37d14a 68         single_timestep(vesicle, &vmsr, &bfsr);
60bc6a 69     }    
M 70     centermass(vesicle);
71     fprintf(stderr, "Preloop %d completed.\n",i+1);
72 }
73
59c7f5 74 nmax=1000;
M 75 for(i=0;i<nmax;i++){
672ae4 76     for(j=0;j<200;j++){
a63f17 77         cell_occupation(vesicle);
SP 78         for(k=0;k<5;k++){
37d14a 79         single_timestep(vesicle, &vmsr, &bfsr);
a63f17 80         }
SP 81         centermass(vesicle);
262607 82     }    
919555 83     vesicle_volume(vesicle);
SP 84     r0=getR0(vesicle);
262607 85
919555 86     preparationSh(vesicle,r0);
SP 87     calculateYlmi(vesicle);
88     calculateUlm(vesicle);
262607 89
919555 90     storeUlm2(vesicle);
SP 91     saveAvgUlm2(vesicle);
262607 92
SP 93     write_vertex_xml_file(vesicle,i);
59c7f5 94     fprintf(stderr, "Loop %d out of %d completed.\n",i+1,nmax);
a63f17 95
262607 96 }
a63f17 97
262607 98 write_master_xml_file("test.pvd");
SP 99 write_dout_fcompat_file(vesicle,"dout");
100 vesicle_free(vesicle);
101
102 return 0; //program finished perfectly ok. We return 0.
103 }
104
105
106