Trisurf Monte Carlo simulator
Samo Penic
2012-06-27 262607715dced9c01b742ac2127af65750a3be3b
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
35 vesicle->sphHarmonics=sph_init(vesicle->vlist, 21);
36
37 vesicle_volume(vesicle);
38 r0=getR0(vesicle);
39
40 preparationSh(vesicle,r0);
41 calculateYlmi(vesicle);
42 calculateUlm(vesicle);
43
44
45
46 for(i=0;i<10;i++){
47     centermass(vesicle);
48     cell_occupation(vesicle);
49     for(j=0;j<1000;j++){
50         single_timestep(vesicle);
51     }    
52 vesicle_volume(vesicle);
53 r0=getR0(vesicle);
54
55 preparationSh(vesicle,r0);
56 calculateYlmi(vesicle);
57 calculateUlm(vesicle);
58
59 storeUlm2(vesicle);
60 saveAvgUlm2(vesicle);
61
62     write_vertex_xml_file(vesicle,i);
63     fprintf(stderr, "Loop %d completed.\n",i+1);
64 }
65 write_master_xml_file("test.pvd");
66 write_dout_fcompat_file(vesicle,"dout");
67 vesicle_free(vesicle);
68
69 return 0; //program finished perfectly ok. We return 0.
70 }
71
72
73
74 ts_bool saveAvgUlm2(ts_vesicle *vesicle){
75
76     FILE *fh;
77     
78     fh=fopen("sph2out.dat", "w");
79     if(fh==NULL){
80         err("Cannot open file %s for writing");
81         return TS_FAIL;
82     }
83
84     ts_spharm *sph=vesicle->sphHarmonics;
85     ts_int i,j;
86     fprintf(fh,"l,\tm,\tulm^2avg\n");
87     for(i=0;i<sph->l;i++){
88             for(j=0;j<2*i+1;j++){
89         fprintf(fh,"%d,\t%d,\t%e\n", i, j-i, sph->sumUlm2[i][j]/(ts_double)sph->N);
90
91             }
92     }
93     fclose(fh);
94     return TS_SUCCESS;
95 }