Trisurf Monte Carlo simulator
Samo Penic
2016-05-18 f4d6ca0fa0915bd12f42fd79c57f3d0aabff50f0
commit | author | age
7f6076 1 /* vim: set ts=4 sts=4 sw=4 noet : */
7958e9 2 #include<stdlib.h>
SP 3 #include<math.h>
4 #include<stdio.h>
5 #include "general.h"
6 #include "vertex.h"
7 #include "bond.h"
8 #include "vesicle.h"
9 #include "vertex.h"
10 #include "triangle.h"
11 #include "initial_distribution.h"
f74313 12 #include "energy.h"
1ab449 13 #include "poly.h"
8a6614 14 #include "io.h"
dc77e8 15 #include "sh.h"
459ff9 16 #include "shcomplex.h"
7958e9 17
SP 18 ts_vesicle *initial_distribution_dipyramid(ts_uint nshell, ts_uint ncmax1, ts_uint ncmax2, ts_uint ncmax3, ts_double stepsize){
1ab449 19     ts_fprintf(stdout,"Starting initial_distribution on vesicle with %u shells!...\n",nshell);
7958e9 20     ts_bool retval;
1ab449 21     ts_uint no_vertices=5*nshell*nshell+2;    
SP 22     ts_vesicle *vesicle=init_vesicle(no_vertices,ncmax1,ncmax2,ncmax3,stepsize);
23     vesicle->nshell=nshell;
24     //retval = vtx_set_global_values(vesicle);
25     retval = pentagonal_dipyramid_vertex_distribution(vesicle->vlist);
26     retval = init_vertex_neighbours(vesicle->vlist);
27     vesicle->vlist = init_sort_neighbours(vesicle->blist,vesicle->vlist);
b01cc1 28    // retval = init_vesicle_bonds(vesicle); // bonds are created in sort_neigh
1ab449 29     retval = init_triangles(vesicle);
SP 30     retval = init_triangle_neighbours(vesicle);
31     retval = init_common_vertex_triangle_neighbours(vesicle);
32     retval = init_normal_vectors(vesicle->tlist);
33     retval = mean_curvature_and_energy(vesicle);
34     ts_fprintf(stdout,"initial_distribution finished!\n");
41a035 35     if(retval);
7958e9 36     return vesicle;
SP 37
38
39
1ab449 40
SP 41 ts_vesicle *create_vesicle_from_tape(ts_tape *tape){
42     ts_vesicle *vesicle;
bcf455 43
1ab449 44     vesicle=initial_distribution_dipyramid(tape->nshell,tape->ncxmax,tape->ncymax,tape->nczmax,tape->stepsize);
698ae1 45         vesicle->tape=tape;
SP 46     set_vesicle_values_from_tape(vesicle);
47     return vesicle;
48 }
49
50 ts_bool set_vesicle_values_from_tape(ts_vesicle *vesicle){
58230a 51     // Nucleus:
698ae1 52     ts_vertex *vtx;
SP 53     ts_tape *tape=vesicle->tape;
fe24d2 54     vesicle->R_nucleus=tape->R_nucleus*tape->R_nucleus;
M 55
56     vesicle->clist->dmin_interspecies = tape->dmin_interspecies*tape->dmin_interspecies;
bcf455 57
58230a 58     //Initialize grafted polymers (brush):
624f81 59     vesicle->poly_list=init_poly_list(tape->npoly,tape->nmono, vesicle->vlist, vesicle);
1ab449 60     vesicle->spring_constant=tape->kspring;
SP 61     poly_assign_spring_const(vesicle);
bcf455 62
58230a 63     //Initialize filaments (polymers inside the vesicle):
M 64     vesicle->filament_list=init_poly_list(tape->nfil,tape->nfono, NULL, vesicle);
bcf455 65     poly_assign_filament_xi(vesicle,tape);
58230a 66
bcf455 67     ts_uint i,j;
M 68     for(i=0;i<vesicle->filament_list->n;i++){
69         for(j=0;j<vesicle->filament_list->poly[i]->blist->n;j++){
70             bond_vector(vesicle->filament_list->poly[i]->blist->bond[j]);
71             vesicle->filament_list->poly[i]->blist->bond[j]->bond_length = sqrt(vtx_distance_sq(vesicle->filament_list->poly[i]->blist->bond[j]->vtx1,vesicle->filament_list->poly[i]->blist->bond[j]->vtx2));
72         }
58230a 73     }
bcf455 74
M 75     for(i=0;i<vesicle->filament_list->n;i++){
76         for(j=0;j<vesicle->filament_list->poly[i]->vlist->n;j++){
77             vtx = vesicle->filament_list->poly[i]->vlist->vtx[j];
78             if(vtx->bond_no == 2){
79             vtx->energy = -(vtx->bond[0]->x*vtx->bond[1]->x + vtx->bond[0]->y*vtx->bond[1]->y + vtx->bond[0]->z*vtx->bond[1]->z)/vtx->bond[0]->bond_length/vtx->bond[1]->bond_length;
80             }
81         }
58230a 82     }
bcf455 83
ea1cce 84     for(i=0;i<vesicle->filament_list->n;i++){
M 85         vertex_list_assign_id(vesicle->filament_list->poly[i]->vlist,TS_ID_FILAMENT);
86     }
bcf455 87
58230a 88 //    vesicle->spring_constant=tape->kspring;
M 89 //    poly_assign_spring_const(vesicle);
90
1ab449 91     
SP 92     vesicle->nshell=tape->nshell;
93     vesicle->dmax=tape->dmax*tape->dmax; /* dmax^2 in the vesicle dmax variable */
94     vesicle->bending_rigidity=tape->xk0;
95     vtx_set_global_values(vesicle); /* make xk0 default value for every vertex */ 
f4d6ca 96 //    ts_fprintf(stdout, "Tape setting: xk0=%e\n",tape->xk0);
1ab449 97     vesicle->stepsize=tape->stepsize;
SP 98     vesicle->clist->ncmax[0]=tape->ncxmax;
99     vesicle->clist->ncmax[1]=tape->ncymax;
100     vesicle->clist->ncmax[2]=tape->nczmax;
101     vesicle->clist->max_occupancy=8; /* hard coded max occupancy? */
102
103     vesicle->pressure= tape->pressure;
104     vesicle->pswitch=tape->pswitch;
632960 105     if(tape->shc>0){
459ff9 106         vesicle->sphHarmonics=complex_sph_init(vesicle->vlist,tape->shc);
632960 107     }
SP 108     else {
109         vesicle->sphHarmonics=NULL;
110     }
698ae1 111     return TS_SUCCESS;
1ab449 112
SP 113 }
114
115
116
117
118
7958e9 119 ts_bool pentagonal_dipyramid_vertex_distribution(ts_vertex_list *vlist){
SP 120     /* Some often used relations */
121     const ts_double s1= sin(2.0*M_PI/5.0);
122     const ts_double s2= sin(4.0*M_PI/5.0);
123     const ts_double c1= cos(2.0*M_PI/5.0);
124     const ts_double c2= cos(4.0*M_PI/5.0);
125
126     /* Calculates projection lenght of an edge bond to pentagram plane */
127     const ts_double xl0=A0/(2.0*sin(M_PI/5.0));
128 #ifdef TS_DOUBLE_DOUBLE
129     const ts_double z0=sqrt(pow(A0,2)-pow(xl0,2));
130 #endif
131 #ifdef TS_DOUBLE_FLOAT
132     const ts_double z0=sqrtf(powf(A0,2)-powf(xl0,2));
133 #endif
134 #ifdef TS_DOUBLE_LONGDOUBLE
135     const ts_double z0=sqrtl(powl(A0,2)-powl(xl0,2));
136 #endif
137 //    const z0=sqrt(A0*A0 -xl0*xl0); /* I could use pow function but if pow is used make a check on the float type. If float then powf, if long double use powl */
138
139 /*placeholder for the pointer to vertex datastructure list... DIRTY: actual pointer points towards invalid address, one position before actual beginning of the list... This is to solve the difference between 1 based indexing in original program in fortran and 0 based indexing in C. All algorithms remain unchanged because of this!*/
140     ts_vertex **vtx=vlist->vtx -1 ; 
141
142
143     ts_uint nshell=(ts_uint)( sqrt((ts_double)(vlist->n-2)/5));
144 //    printf("nshell=%u\n",nshell);
145     ts_uint i,n0; // some for loop prereq
146     ts_int j,k;
147     ts_double dx,dy; // end loop prereq
148
149     /* topmost vertex */
8f6a69 150     vtx[1]->x=0.0;
SP 151     vtx[1]->y=0.0;
152     vtx[1]->z=z0*(ts_double)nshell;
7958e9 153     
SP 154     /* starting from to in circular order on pentagrams */    
155     for(i=1;i<=nshell;i++){
156         n0=2+5*i*(i-1)/2; //-1 would be for the reason that C index starts from 0 
8f6a69 157         vtx[n0]->x=0.0;
SP 158         vtx[n0]->y=(ts_double)i*xl0;
159         vtx[n0+i]->x=vtx[n0]->y*s1;
160         vtx[n0+i]->y=vtx[n0]->y*c1;
161         vtx[n0+2*i]->x=vtx[n0]->y*s2;
162         vtx[n0+2*i]->y=vtx[n0]->y*c2;
163         vtx[n0+3*i]->x=-vtx[n0+2*i]->x;
164         vtx[n0+3*i]->y=vtx[n0+2*i]->y;
165         vtx[n0+4*i]->x=-vtx[n0+i]->x;
166         vtx[n0+4*i]->y=vtx[n0+i]->y;
7958e9 167     }
SP 168
169     /* vertexes on the faces of the dipyramid */
170     for(i=1;i<=nshell;i++){
171         n0=2+5*i*(i-1)/2; // -1 would be because of C!
172         for(j=1;j<=i-1;j++){
8f6a69 173             dx=(vtx[n0]->x-vtx[n0+4*i]->x)/(ts_double)i;
SP 174             dy=(vtx[n0]->y-vtx[n0+4*i]->y)/(ts_double)i;
175             vtx[n0+4*i+j]->x=(ts_double)j*dx+vtx[n0+4*i]->x;
176             vtx[n0+4*i+j]->y=(ts_double)j*dy+vtx[n0+4*i]->y;
7958e9 177         }
SP 178         for(k=0;k<=3;k++){ // I would be worried about zero starting of for
8f6a69 179             dx=(vtx[n0+(k+1)*i]->x - vtx[n0+k*i]->x)/(ts_double) i;
SP 180             dy=(vtx[n0+(k+1)*i]->y - vtx[n0+k*i]->y)/(ts_double) i;
7958e9 181             for(j=1; j<=i-1;j++){
8f6a69 182                 vtx[n0+k*i+j]->x= (ts_double)j*dx+vtx[n0+k*i]->x;
SP 183                 vtx[n0+k*i+j]->y= (ts_double)j*dy+vtx[n0+k*i]->y;
7958e9 184             } 
SP 185         } 
186     }
187
188     for(i=1;i<=nshell;i++){
189         n0= 2+ 5*i*(i-1)/2;
190         for(j=0;j<=5*i-1;j++){
8f6a69 191         vtx[n0+j]->z= z0*(ts_double)(nshell-i);   // I would be worried about zero starting of for
7958e9 192         }
SP 193     }
194
195 /* for botom part of dipyramide we calculate the positions of vertices */
196     for(i=2+5*nshell*(nshell+1)/2;i<=vlist->n;i++){
8f6a69 197         vtx[i]->x=vtx[vlist->n - i +1]->x;
SP 198         vtx[i]->y=vtx[vlist->n - i +1]->y;
199         vtx[i]->z=-vtx[vlist->n - i +1]->z;
7958e9 200     }
SP 201
202     for(i=1;i<=vlist->n;i++){
203         for(j=1;j<=vlist->n;j++){
204             if(i!=j && vtx_distance_sq(vtx[i],vtx[j])<0.001){
205                 printf("Vertices %u and %u are the same!\n",i,j);
206             }
207         }
208     }
209     return TS_SUCCESS;
210 }
211
212
213
214 ts_bool init_vertex_neighbours(ts_vertex_list *vlist){
215     ts_vertex **vtx=vlist->vtx -1; // take a look at dipyramid function for comment.
216     const ts_double eps=0.001; //TODO: find out if you can use EPS from math.h
217     ts_uint i,j;
218     ts_double dist2; // Square of distance of neighbours
219     /*this is not required if we zero all data in vertex structure at initialization */
220     /*if we force zeroing at initialization this for loop can safely be deleted */
221     //for(i=1;i<=vlist->n;i++){
222     //    vtx[i].neigh_no=0;
223     //}
224     for(i=1;i<=vlist->n;i++){
225         for(j=1;j<=vlist->n;j++){
226             dist2=vtx_distance_sq(vtx[i],vtx[j]);
227             if( (dist2>eps) && (dist2<(A0*A0+eps))){ 
228     //if it is close enough, but not too much close (solves problem of comparing when i==j)
229                 vtx_add_neighbour(vtx[i],vtx[j]);
230             }
231         }
232     //        printf ("vertex %u ima %u sosedov!\n",i,vtx[i]->data->neigh_no);
233     }
234
235     return TS_SUCCESS;
236 }
237
b01cc1 238 // TODO: with new datastructure can be rewritten. Partially it is done, but it is complicated.
SP 239 ts_vertex_list *init_sort_neighbours(ts_bond_list *blist,ts_vertex_list *vlist){
7958e9 240     ts_vertex **vtx=vlist->vtx -1; // take a look at dipyramid function for comment.
SP 241     ts_uint i,l,j,jj,jjj,k=0;   
242     ts_double eps=0.001; // Take a look if EPS from math.h can be used
243
244 /*lets initialize memory for temporary vertex_list. Should we write a function instead */
b01cc1 245     ts_vertex_list *tvlist=vertex_list_copy(vlist);
7958e9 246     ts_vertex **tvtx=tvlist->vtx -1;  /* again to compensate for 0-indexing */
SP 247
248     ts_double dist2; // Square of distance of neighbours
249     ts_double direct; // Something, dont know what, but could be normal of some kind
250     for(i=1;i<=vlist->n;i++){
251         k++; // WHY i IS NOT GOOD??
8f6a69 252            vtx_add_cneighbour(blist,tvtx[k], tvtx[vtx[i]->neigh[0]->idx+1]); //always add 1st
7958e9 253            jjj=1;
SP 254            jj=1;
8f6a69 255            for(l=2;l<=vtx[i]->neigh_no;l++){
SP 256                for(j=2;j<=vtx[i]->neigh_no;j++){
257                    dist2=vtx_distance_sq(vtx[i]->neigh[j-1],vtx[i]->neigh[jj-1]);
258                    direct=vtx_direct(vtx[i],vtx[i]->neigh[j-1],vtx[i]->neigh[jj-1]);
259 // TODO: check if fabs can be used with all floating point types!!
7958e9 260                    if( (fabs(dist2-A0*A0)<=eps) && (direct>0.0) && (j!=jjj) ){
8f6a69 261                        vtx_add_cneighbour(blist,tvtx[k],tvtx[vtx[i]->neigh[j-1]->idx+1]);
7958e9 262                        jjj=jj;
SP 263                        jj=j;
264                        break;
265                    }
266                }
267            }    
268     }
b01cc1 269 /* We use the temporary vertex for our main vertices and we abandon main
SP 270  * vertices, because their neighbours are not correctly ordered */
271    // tvtx=vlist->vtx;
272    // vlist->vtx=tvtx;
273    // tvlist->vtx=vtx;
274     vtx_list_free(vlist);
275 /* Let's make a check if the number of bonds is correct */
276     if((blist->n)!=3*(tvlist->n-2)){
277         ts_fprintf(stderr,"Number of bonds is %u should be %u!\n", blist->n, 3*(tvlist->n-2));
278         fatal("Number of bonds is not 3*(no_vertex-2).",4);
7958e9 279     }
SP 280
b01cc1 281     return tvlist;
7958e9 282 }
SP 283
284
285 ts_bool init_vesicle_bonds(ts_vesicle *vesicle){
286     ts_vertex_list *vlist=vesicle->vlist;
287     ts_bond_list *blist=vesicle->blist;
288     ts_vertex **vtx=vesicle->vlist->vtx - 1; // Because of 0 indexing
289 /* lets make correct clockwise ordering of in nearest neighbour list */
290     ts_uint i,j,k;
291     for(i=1;i<=vlist->n;i++){
292         for(j=i+1;j<=vlist->n;j++){
8f6a69 293             for(k=0;k<vtx[i]->neigh_no;k++){ // has changed 0 to < instead of 1 and <=
SP 294                 if(vtx[i]->neigh[k]==vtx[j]){  //if addresses matches it is the same
7958e9 295                     bond_add(blist,vtx[i],vtx[j]);
SP 296                     break;
297                 }
298             }
299         }
300     } 
301 /* Let's make a check if the number of bonds is correct */
302     if((blist->n)!=3*(vlist->n-2)){
303         ts_fprintf(stderr,"Number of bonds is %u should be %u!\n", blist->n, 3*(vlist->n-2));
304         fatal("Number of bonds is not 3*(no_vertex-2).",4);
305     }
306     return TS_SUCCESS;
307 }
308
309
310
311 ts_bool init_triangles(ts_vesicle *vesicle){
312     ts_uint i,j,jj,k;
313     ts_vertex **vtx=vesicle->vlist->vtx -1; // difference between 0 indexing and 1 indexing
314     ts_triangle_list *tlist=vesicle->tlist;
315     ts_double dist, direct;
316     ts_double eps=0.001; // can we use EPS from math.h?
317     k=0;
318     for(i=1;i<=vesicle->vlist->n;i++){
8f6a69 319         for(j=1;j<=vtx[i]->neigh_no;j++){
SP 320             for(jj=1;jj<=vtx[i]->neigh_no;jj++){
7958e9 321         //        ts_fprintf(stderr,"%u: (%u,%u) neigh_no=%u ",i,j,jj,vtx[i].neigh_no);
SP 322         //      ts_fprintf(stderr,"%e, %e",vtx[i].neigh[j-1]->x,vtx[i].neigh[jj-1]->x);
8f6a69 323                 dist=vtx_distance_sq(vtx[i]->neigh[j-1],vtx[i]->neigh[jj-1]);
SP 324                 direct=vtx_direct(vtx[i],vtx[i]->neigh[j-1],vtx[i]->neigh[jj-1]);                
325 // TODO: same as above                
326                 if(fabs(dist-A0*A0)<=eps && direct < 0.0 && vtx[i]->neigh[j-1]->idx+1 > i && vtx[i]->neigh[jj-1]->idx+1 >i){
327                     triangle_add(tlist,vtx[i],vtx[i]->neigh[j-1],vtx[i]->neigh[jj-1]);
7958e9 328                 }    
SP 329             }    
330         }
331     }
332 /* We check if all triangles have 3 vertices and if the number of triangles
333  * matches the theoretical value.
334  */
335     for(i=0;i<tlist->n;i++){
336         k=0;
337         for(j=0;j<3;j++){
41a035 338             if(tlist->tria[i]->vertex[j]!=NULL)
7958e9 339             k++;
SP 340         }
341             if(k!=3){
8f6a69 342                 fatal("Some triangles have less than 3 vertices..",4);
7958e9 343             }   
SP 344     } 
345     if(tlist->n!=2*(vesicle->vlist->n -2)){
346         ts_fprintf(stderr,"The number of triangles is %u but should be %u!\n",tlist->n,2*(vesicle->vlist->n -2));
347         fatal("The number of triangles doesn't match 2*(no_vertex -2).",4);
348     }
349     return TS_SUCCESS;
350 }
351
352
353
354 ts_bool init_triangle_neighbours(ts_vesicle *vesicle){
355     ts_uint i,j,nobo;
356     ts_vertex *i1,*i2,*i3,*j1,*j2,*j3;
357 //    ts_vertex **vtx=vesicle->vlist->vtx -1; // difference between 0 indexing and 1 indexing
358     ts_triangle_list *tlist=vesicle->tlist;
359     ts_triangle **tria=tlist->tria -1;
360     nobo=0;
361     for(i=1;i<=tlist->n;i++){
41a035 362         i1=tria[i]->vertex[0]; 
SP 363         i2=tria[i]->vertex[1]; 
364         i3=tria[i]->vertex[2]; 
7958e9 365         for(j=1;j<=tlist->n;j++){
SP 366             if(j==i) continue;
41a035 367             j1=tria[j]->vertex[0]; 
SP 368             j2=tria[j]->vertex[1]; 
369             j3=tria[j]->vertex[2]; 
7958e9 370             if((i1==j1 && i3==j2) || (i1==j2 && i3==j3) || (i1==j3 && i3==j1)){
SP 371                     triangle_add_neighbour(tria[i],tria[j]);
372                     nobo++;
373             }
374         }
375     }
376     for(i=1;i<=tlist->n;i++){
41a035 377         i1=tria[i]->vertex[0]; 
SP 378         i2=tria[i]->vertex[1]; 
379         i3=tria[i]->vertex[2]; 
7958e9 380         for(j=1;j<=tlist->n;j++){
SP 381             if(j==i) continue;
41a035 382             j1=tria[j]->vertex[0]; 
SP 383             j2=tria[j]->vertex[1]; 
384             j3=tria[j]->vertex[2]; 
7958e9 385             if((i1==j1 && i2==j3) || (i1==j3 && i2==j2) || (i1==j2 && i2==j1)){
SP 386                 triangle_add_neighbour(tria[i],tria[j]);
387                 nobo++;
388             }
389         }
390     }
391     for(i=1;i<=tlist->n;i++){
41a035 392         i1=tria[i]->vertex[0]; 
SP 393         i2=tria[i]->vertex[1]; 
394         i3=tria[i]->vertex[2]; 
7958e9 395         for(j=1;j<=tlist->n;j++){
SP 396             if(j==i) continue;
41a035 397             j1=tria[j]->vertex[0]; 
SP 398             j2=tria[j]->vertex[1]; 
399             j3=tria[j]->vertex[2]; 
7958e9 400             if((i2==j1 && i3==j3) || (i2==j3 && i3==j2) || (i2==j2 && i3==j1)){
SP 401                 triangle_add_neighbour(tria[i],tria[j]);
402                 nobo++;
403             }
404         }
405     }
406     if(nobo != vesicle->blist->n*2) {
407             ts_fprintf(stderr,"Number of triangles= %u, number of bonds= %u\n",nobo/2, vesicle->blist->n);
408             fatal("Number of triangle neighbour pairs differs from double the number of bonds!",4);
409     }
410     return TS_SUCCESS;
411 }
412
413
414 ts_bool init_common_vertex_triangle_neighbours(ts_vesicle *vesicle){
415     ts_uint i,j,jp,k;
416     ts_vertex *k1,*k2,*k3,*k4,*k5;
417     ts_vertex **vtx=vesicle->vlist->vtx -1; // difference between 0 indexing and 1 indexing
418     ts_triangle_list *tlist=vesicle->tlist;
419     ts_triangle **tria=tlist->tria -1;
420
421     for(i=1;i<=vesicle->vlist->n;i++){
8f6a69 422         for(j=1;j<=vtx[i]->neigh_no;j++){
SP 423             k1=vtx[i]->neigh[j-1];
7958e9 424             jp=j+1;
8f6a69 425             if(j == vtx[i]->neigh_no) jp=1;
SP 426             k2=vtx[i]->neigh[jp-1];
7958e9 427             for(k=1;k<=tlist->n;k++){        // VERY NON-OPTIMAL!!! too many loops (vlist.n * vtx.neigh * tlist.n )!
41a035 428                 k3=tria[k]->vertex[0];
SP 429                 k4=tria[k]->vertex[1];
430                 k5=tria[k]->vertex[2];
7958e9 431 //                ts_fprintf(stderr,"%u %u: k=(%u %u %u)\n",k1,k2,k3,k4,k5);
SP 432                 if((vtx[i]==k3 && k1==k4 && k2==k5) ||
433                 (vtx[i]==k4 && k1==k5 && k2==k3) ||
434                 (vtx[i]==k5 && k1==k3 && k2==k4)){
b01cc1 435
SP 436 //TODO: probably something wrong with neighbour distribution.
437 //                if(vtx[i]==k3 || vtx[i]==k4 || vtx[i]==k5){
dac2e5 438     //                    if(i==6) ts_fprintf(stdout, "Vtx[%u] > Added to tristar!\n",i);
7958e9 439                     vertex_add_tristar(vtx[i],tria[k]);
SP 440                 }
441             }
442         }
443 /*        ts_fprintf(stderr,"TRISTAR for %u (%u):",i-1,vtx[i].tristar_no);
444         for(j=0;j<vtx[i].tristar_no;j++){
445             ts_fprintf(stderr," %u,",vtx[i].tristar[j]->idx);
446         }
447         ts_fprintf(stderr,"\n"); */
448     }
449     return TS_SUCCESS;
450 }
451
452
453 ts_bool init_normal_vectors(ts_triangle_list *tlist){
454     /* Normals point INSIDE vesicle */
455     ts_uint k;
456     ts_triangle **tria=tlist->tria -1; //for 0 indexing
457     for(k=1;k<=tlist->n;k++){
458         triangle_normal_vector(tria[k]);    
459     }
460     return TS_SUCCESS;
461 }