Trisurf Monte Carlo simulator
Samo Penic
2015-03-09 a00f10fd48a1de31c3ac923c2106969f84e831e0
commit | author | age
88f451 1 #include "general.h"
SP 2 #include "vertex.h"
3 #include "initial_distribution.h"
4 #include "io.h"
5 #include "vesicle.h"
6 #include "sh.h"
7 #include "frame.c"
8 #include <math.h>
9 #include <stdlib.h>
10 int main(int argc, char *argv[]){
11
12 ts_fprintf(stdout,"SHdiscover was called with %d coefficients!\n",argc-1);
13 ts_uint n,i,j,l;
14 ts_int m;
15 ts_double fi,theta,r,Y;
16 ts_vesicle *vesicle=initial_distribution_dipyramid(17,60,60,60,0.15);
17 ts_vertex_list *vlist=vesicle->vlist;
18 centermass(vesicle);
19 ts_fprintf(stdout,"Vesicle has a CenterMass in %f,%f,%f\n",vesicle->cm[0],vesicle->cm[1], vesicle->cm[2]);
20
21 n=vlist->n;
22
23 ts_fprintf(stdout,"Tests\n");
24 ts_fprintf(stdout,"P(0,0,0.5)=%f (%f)\n",plgndr(0,0,0.5),1.0);
25 ts_fprintf(stdout,"P(1,0,0.5)=%f (%f)\n",plgndr(1,0,0.5),0.5);
26 ts_fprintf(stdout,"P(2,0,0.5)=%f (%f)\n",plgndr(2,0,0.5),0.5*(3*0.5*0.5-1));
af3bad 27 ts_fprintf(stdout,"P(2,2,0.5)=%f (ni to:%f)\n",plgndr(2,2,0.5),0.5*(3*0.5*0.5-1));
88f451 28
SP 29 ts_fprintf(stdout,"Y(0,0,pi/6,pi/4)=%f (%f)\n",shY(0,0,M_PI/6,M_PI/4),sqrt(1/(4*M_PI)));
30 ts_fprintf(stdout,"Y(1,0,pi/6,pi/4)=%f (%f)\n",shY(1,0,M_PI/6,M_PI/4),sqrt(3/(4*M_PI))*cos(M_PI/6));
31 ts_fprintf(stdout,"Y(1,0,4*pi/6,6*pi/4)=%f (%f)\n",shY(1,0,4*M_PI/6,6*M_PI/4),sqrt(3/(4*M_PI))*cos(4*M_PI/6));
af3bad 32 ts_fprintf(stdout,"Y(1,1,pi/6,pi/4)=%f (%f)\n",shY(1,1,M_PI/6,M_PI/4),-sqrt(3/(8*M_PI))*sin(M_PI/6)*cos(M_PI/4));
88f451 33 ts_fprintf(stdout,"Y(2,0,pi/6,pi/4)=%f (%f)\n",shY(2,0,M_PI/6,M_PI/4),sqrt(5/(4*M_PI))*(3.0/2.0*cos(M_PI/6)*cos(M_PI/6)-1.0/2.0));
SP 34 ts_fprintf(stdout,"Y(2,-2,pi/6,pi/4)=%f (0)\n",shY(2,-2,M_PI/6,M_PI/4));
af3bad 35 ts_fprintf(stdout,"Y(2,2,pi/6,pi/3)=%f (%f)\n",shY(2,2,M_PI/6,M_PI/3), sqrt(15.0/(32.0*M_PI))*sin(M_PI/6)*sin(M_PI/6)*cos(2*M_PI/3));
88f451 36     
SP 37     for(j=1;j<argc;j++){
38         l=(int)sqrt(j-1); /* determine l from dataline */
39         m=j-1-l*(l+1); /* determine m from dataline */
40         ts_fprintf(stdout,"l=%d, m=%d, u=%s\n",l,m,argv[j]);
41     }
42
43 /*we calculate new position of each vertex of vesicle */
44 for(i=0;i<n;i++){
8f6a69 45     fi=atan2(vlist->vtx[i]->y, vlist->vtx[i]->x);
88f451 46 /*    theta=atan2(
SP 47         sqrt(vlist->vtx[i]->data->x*vlist->vtx[i]->data->x + 
48         vlist->vtx[i]->data->y*vlist->vtx[i]->data->y),
49         vlist->vtx[i]->data->z 
50         ); */
51     theta=acos(
8f6a69 52         vlist->vtx[i]->z /
SP 53         sqrt(vlist->vtx[i]->x*vlist->vtx[i]->x + 
54         vlist->vtx[i]->y*vlist->vtx[i]->y+
55         vlist->vtx[i]->z*vlist->vtx[i]->z)
88f451 56
SP 57         );
58
59
60
61     r=0.0;
62     for(j=1;j<argc;j++){
63         l=(int)sqrt(j-1); /* determine l from dataline */
64         m=j-1-l*(l+1); /* determine m from dataline */
65         Y=shY(l,m,theta,fi);
66         r+=fabs(atof(argv[j])*Y);
67         /*ts_fprintf(stdout,"l=%d, m=%d, u=%s\n",l,m,argv[j]);*/
68     }
69
8f6a69 70     vlist->vtx[i]->z=fabs(r)*cos(theta);
SP 71     vlist->vtx[i]->x=fabs(r)*sin(theta)*cos(fi);
72     vlist->vtx[i]->y=fabs(r)*sin(theta)*sin(fi);
88f451 73 }
SP 74
75 write_vertex_xml_file(vesicle,0);
76 write_master_xml_file("test.pvd");
77
78
79 vesicle_free(vesicle);
80 return 0;
81 }