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