Trisurf Monte Carlo simulator
root
2016-07-03 35efb0f73e86dc197cda350d2128ea25c9d06128
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"
21 #include <string.h>
22 #include <getopt.h>
23 #include <sys/stat.h>
24 #include <sys/types.h>
25 #include <dirent.h>
26 #include <errno.h>
27 #include <snapshot.h>
28 #include<gsl/gsl_complex.h>
29 #include<gsl/gsl_complex_math.h>
30
31
32 ts_vesicle *restoreVesicle(char *filename){
33     ts_vesicle *vesicle = parseDump(filename);
34     return vesicle;
35 }
36
37 void vesicle_calculate_ulm2(ts_vesicle *vesicle){
38     //complex_sph_free(vesicle->sphHarmonics);
39
40     //vesicle->sphHarmonics=complex_sph_init(vesicle->vlist,21);
41     vesicle_volume(vesicle);
42     preparationSh(vesicle,getR0(vesicle));
43     calculateUlmComplex(vesicle);
44     ts_int i,j;
45     for(i=0;i<vesicle->sphHarmonics->l;i++){
46             for(j=i;j<2*i+1;j++){
47             printf("%e ", gsl_complex_abs2(vesicle->sphHarmonics->ulmComplex[i][j]));
48             }
49     }
50         printf("\n");
51
52 }
53
89434d 54
SP 55
56 int count_bonds_with_energy(ts_bond_list *blist){
57
58     unsigned int i, cnt;
59     cnt=0;
60     for(i=0;i<blist->n;i++){
61         if(fabs(blist->bond[i]->energy)>1e-16) cnt++;
62     }
63     return cnt;
64 }
65
22a18c 66 int main(){
SP 67     ts_vesicle *vesicle;
68     ts_char *i,*j;
69     ts_uint tstep,n;
70         ts_char *number;
71     struct dirent **list;
72     ts_double l1,l2,l3;
73     int count;
74     ts_fprintf(stderr,"TRISURF-NG v. %s, compiled on: %s %s.\n", TS_VERSION, __DATE__, __TIME__);
75
89434d 76     fprintf(stdout, "OuterLoop Volume Area lamdba1 lambda2 lambda3 Nbw/Nb\n");
22a18c 77
SP 78
79     count=scandir(".",&list,0,alphasort);
80     if(count<0){
81         fatal("Error, cannot open directory.",1);
82     }
83         tstep=0;
84     for(n=0;n<count;n++){
85         struct dirent *ent;
86         ent=list[n];    
87                 i=rindex(ent->d_name,'.');
88                 if(i==NULL) {
89                 continue;
90         }
91                 if(strcmp(i+1,"vtu")==0){
92                     j=rindex(ent->d_name,'_');
93                     if(j==NULL) continue;
94                     number=strndup(j+1,j-i); 
95             quiet=1;
96                     ts_fprintf(stdout,"timestep: %u filename: %s\n",atoi(number),ent->d_name);
97 //            printf("%u ",atoi(number));
98             vesicle=restoreVesicle(ent->d_name);
99 //            vesicle_calculate_ulm2(vesicle);
100             vesicle_volume(vesicle);
101             vesicle_area(vesicle);
102             gyration_eigen(vesicle,&l1,&l2,&l3);
89434d 103             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 104                         tstep++;
SP 105
106                     free(number);
107             tape_free(vesicle->tape);
108             vesicle_free(vesicle);
109                 }
110         }
111     for (n = 0; n < count; n++)
112       {
113           free(list[n]);
114       }
115     
116     free(list);
117     return 0;
118 }
119