Trisurf Monte Carlo simulator
Samo Penic
2016-07-05 8c91d2bcad7df7c647f1379483673183329ddfe8
commit | author | age
22a18c 1 /* vim: set ts=4 sts=4 sw=4 noet : */
SP 2 #include<stdio.h>
3 #include<math.h>
4 #include<stdlib.h>
5 #include "general.h"
6 //#include "vertex.h"
7 //#include "bond.h"
8 //#include "triangle.h"
9 //#include "cell.h"
10 #include "vesicle.h"
11 #include "io.h"
12 //#include "initial_distribution.h"
13 //#include "frame.h"
14 //#include "timestep.h"
15 //#include "poly.h"
16 #include "stats.h"
17 #include "sh.h"
18 #include "shcomplex.h"
19 #include "dumpstate.h"
20 #include "restore.h"
8c91d2 21 #include "cluster.h"
22a18c 22 #include <string.h>
SP 23 #include <getopt.h>
24 #include <sys/stat.h>
25 #include <sys/types.h>
26 #include <dirent.h>
27 #include <errno.h>
28 #include <snapshot.h>
29 #include<gsl/gsl_complex.h>
30 #include<gsl/gsl_complex_math.h>
31
32
33 ts_vesicle *restoreVesicle(char *filename){
34     ts_vesicle *vesicle = parseDump(filename);
35     return vesicle;
36 }
37
38 void vesicle_calculate_ulm2(ts_vesicle *vesicle){
39     //complex_sph_free(vesicle->sphHarmonics);
40
41     //vesicle->sphHarmonics=complex_sph_init(vesicle->vlist,21);
42     vesicle_volume(vesicle);
43     preparationSh(vesicle,getR0(vesicle));
44     calculateUlmComplex(vesicle);
45     ts_int i,j;
46     for(i=0;i<vesicle->sphHarmonics->l;i++){
47             for(j=i;j<2*i+1;j++){
48             printf("%e ", gsl_complex_abs2(vesicle->sphHarmonics->ulmComplex[i][j]));
49             }
50     }
51         printf("\n");
52
53 }
54
89434d 55
SP 56
57 int count_bonds_with_energy(ts_bond_list *blist){
58
59     unsigned int i, cnt;
60     cnt=0;
61     for(i=0;i<blist->n;i++){
62         if(fabs(blist->bond[i]->energy)>1e-16) cnt++;
63     }
64     return cnt;
65 }
66
22a18c 67 int main(){
SP 68     ts_vesicle *vesicle;
69     ts_char *i,*j;
70     ts_uint tstep,n;
71         ts_char *number;
72     struct dirent **list;
73     ts_double l1,l2,l3;
74     int count;
75     ts_fprintf(stderr,"TRISURF-NG v. %s, compiled on: %s %s.\n", TS_VERSION, __DATE__, __TIME__);
76
89434d 77     fprintf(stdout, "OuterLoop Volume Area lamdba1 lambda2 lambda3 Nbw/Nb\n");
22a18c 78
SP 79
80     count=scandir(".",&list,0,alphasort);
81     if(count<0){
82         fatal("Error, cannot open directory.",1);
83     }
84         tstep=0;
85     for(n=0;n<count;n++){
86         struct dirent *ent;
87         ent=list[n];    
88                 i=rindex(ent->d_name,'.');
89                 if(i==NULL) {
90                 continue;
91         }
92                 if(strcmp(i+1,"vtu")==0){
93                     j=rindex(ent->d_name,'_');
94                     if(j==NULL) continue;
95                     number=strndup(j+1,j-i); 
96             quiet=1;
97                     ts_fprintf(stdout,"timestep: %u filename: %s\n",atoi(number),ent->d_name);
98 //            printf("%u ",atoi(number));
99             vesicle=restoreVesicle(ent->d_name);
100 //            vesicle_calculate_ulm2(vesicle);
101             vesicle_volume(vesicle);
102             vesicle_area(vesicle);
103             gyration_eigen(vesicle,&l1,&l2,&l3);
89434d 104             fprintf(stdout,"%d %.17e %.17e %.17e %.17e %.17e %.17e\n",atoi(number),vesicle->volume, vesicle->area,l1,l2,l3, (ts_double)count_bonds_with_energy(vesicle->blist)/(ts_double)vesicle->blist->n),
22a18c 105                         tstep++;
SP 106
8c91d2 107             ts_cluster_list *cstlist=init_cluster_list();
SP 108             clusterize_vesicle(vesicle,cstlist);
109             printf("No clusters=%d\n",cstlist->n);
110             cluster_list_free(cstlist);
22a18c 111                     free(number);
SP 112             tape_free(vesicle->tape);
113             vesicle_free(vesicle);
114                 }
115         }
116     for (n = 0; n < count; n++)
117       {
118           free(list[n]);
119       }
120     
121     free(list);
122     return 0;
123 }
124