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