Trisurf Monte Carlo simulator
Samo
2012-07-10 a0f0a3ac3363a9cc058e1de3f64dac2598d9c787
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[]){
22 ts_uint i,j;
23 ts_vesicle *vesicle;
24 ts_double r0;
25 vesicle=initial_distribution_dipyramid(17,60,60,60,0.15);
26 //parsetape(vesicle,&i);
27
28 //these four must come from parsetype!
29 vesicle->dmax=1.67*1.67;
30 vesicle->stepsize=0.15;
31 vesicle->clist->max_occupancy=8;
32 vesicle->bending_rigidity=25.0;
33 //fprintf(stderr,"xk=%f",vesicle->bending_rigidity);
34
919555 35     centermass(vesicle);
262607 36 vesicle->sphHarmonics=sph_init(vesicle->vlist, 21);
SP 37
38 vesicle_volume(vesicle);
39 r0=getR0(vesicle);
40
41 preparationSh(vesicle,r0);
42 calculateYlmi(vesicle);
43 calculateUlm(vesicle);
44
45
46
91c712 47 for(i=0;i<10000;i++){
262607 48     cell_occupation(vesicle);
SP 49     for(j=0;j<1000;j++){
50         single_timestep(vesicle);
51     }    
919555 52     centermass(vesicle);
SP 53     vesicle_volume(vesicle);
54     r0=getR0(vesicle);
262607 55
919555 56     preparationSh(vesicle,r0);
SP 57     calculateYlmi(vesicle);
58     calculateUlm(vesicle);
262607 59
919555 60     storeUlm2(vesicle);
SP 61     saveAvgUlm2(vesicle);
262607 62
SP 63     write_vertex_xml_file(vesicle,i);
64     fprintf(stderr, "Loop %d completed.\n",i+1);
65 }
66 write_master_xml_file("test.pvd");
67 write_dout_fcompat_file(vesicle,"dout");
68 vesicle_free(vesicle);
69
70 return 0; //program finished perfectly ok. We return 0.
71 }
72
73
74
75 ts_bool saveAvgUlm2(ts_vesicle *vesicle){
76
77     FILE *fh;
78     
79     fh=fopen("sph2out.dat", "w");
80     if(fh==NULL){
81         err("Cannot open file %s for writing");
82         return TS_FAIL;
83     }
84
85     ts_spharm *sph=vesicle->sphHarmonics;
86     ts_int i,j;
87     fprintf(fh,"l,\tm,\tulm^2avg\n");
88     for(i=0;i<sph->l;i++){
89             for(j=0;j<2*i+1;j++){
90         fprintf(fh,"%d,\t%d,\t%e\n", i, j-i, sph->sumUlm2[i][j]/(ts_double)sph->N);
91
92             }
443ba1 93     fprintf(fh,"\n");
262607 94     }
SP 95     fclose(fh);
96     return TS_SUCCESS;
97 }