Trisurf Monte Carlo simulator
Samo Penic
2016-05-31 4891eb093f61d37056c50c572e669349dd49a65a
commit | author | age
7f6076 1 /* vim: set ts=4 sts=4 sw=4 noet : */
aec47d 2 #include<stdlib.h>
SP 3 #include<math.h>
4 #include "general.h"
5 #include "vertex.h"
6 #include "bond.h"
7 #include "triangle.h"
8 #include "vesicle.h"
9 #include "energy.h"
10 #include "timestep.h"
11 #include "cell.h"
12 //#include "io.h"
9166cb 13 #include "io.h"
aec47d 14 #include<stdio.h>
SP 15 #include "vertexmove.h"
1ad6d1 16 #include <string.h>
43c042 17 #include "constvol.h"
aec47d 18
fedf2b 19 ts_bool single_verticle_timestep(ts_vesicle *vesicle,ts_vertex *vtx,ts_double *rn){
aec47d 20     ts_uint i;
SP 21     ts_double dist;
22     ts_bool retval; 
23     ts_uint cellidx; 
c0ae90 24     ts_double delta_energy, delta_energy_cv,oenergy,dvol=0.0, darea=0.0;
ed31fe 25     ts_double costheta,sintheta,phi,r;
1ad6d1 26     //This will hold all the information of vtx and its neighbours
958e0e 27     ts_vertex backupvtx[20], *constvol_vtx_moved=NULL, *constvol_vtx_backup=NULL;
dcd350 28     memcpy((void *)&backupvtx[0],(void *)vtx,sizeof(ts_vertex));
a63f17 29
SP 30     //Some stupid tests for debugging cell occupation!
31 /*         cellidx=vertex_self_avoidance(vesicle, vtx);
32     if(vesicle->clist->cell[cellidx]==vtx->cell){
33         fprintf(stderr,"Idx match!\n");
34     } else {
35         fprintf(stderr,"***** Idx don't match!\n");
36         fatal("ENding.",1);
37     }
38 */
39
352fad 40         //temporarly moving the vertex
672ae4 41 //    vtx->x=vtx->x+vesicle->stepsize*(2.0*rn[0]-1.0);
SP 42 //        vtx->y=vtx->y+vesicle->stepsize*(2.0*rn[1]-1.0);
43 //        vtx->z=vtx->z+vesicle->stepsize*(2.0*rn[2]-1.0);
44
c0ae90 45 //random move in a sphere with radius stepsize:
ed31fe 46     r=vesicle->stepsize*rn[0];
M 47     phi=rn[1]*2*M_PI;
48     costheta=2*rn[2]-1;
49     sintheta=sqrt(1-pow(costheta,2));
672ae4 50     vtx->x=vtx->x+r*sintheta*cos(phi);
SP 51     vtx->y=vtx->y+r*sintheta*sin(phi);
52     vtx->z=vtx->z+r*costheta;
53
54
c0ae90 55 //distance with neighbours check
8f6a69 56     for(i=0;i<vtx->neigh_no;i++){
352fad 57         dist=vtx_distance_sq(vtx,vtx->neigh[i]);
8f6a69 58         if(dist<1.0 || dist>vesicle->dmax) {
c0ae90 59             vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
SP 60             return TS_FAIL;
8f6a69 61         }
aec47d 62     }
304510 63
M 64 // Distance with grafted poly-vertex check:    
65     if(vtx->grafted_poly!=NULL){
66         dist=vtx_distance_sq(vtx,vtx->grafted_poly->vlist->vtx[0]);
67         if(dist<1.0 || dist>vesicle->dmax) {
68         vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
69         return TS_FAIL;
70         }
71     }
72
fe24d2 73 // TODO: Maybe faster if checks only nucleus-neighboring cells
M 74 // Nucleus penetration check:
37791b 75 if(vesicle->R_nucleus>0.0){
fe24d2 76     if (vtx->x*vtx->x + vtx->y*vtx->y + vtx->z*vtx->z < vesicle->R_nucleus){
M 77         vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
78         return TS_FAIL;
79     }
37791b 80 } else if(vesicle->R_nucleusX>0.0){
SP 81 //    fprintf(stderr,"DEBUG, (Rx, Ry,Rz)^2=(%f,%f,%f)\n",vesicle->R_nucleusX, vesicle->R_nucleusY, vesicle->R_nucleusZ);
82     if ((vtx->x*vtx->x)/vesicle->R_nucleusX + vtx->y*vtx->y/vesicle->R_nucleusY + (vtx->z*vtx->z)/vesicle->R_nucleusZ < 1.0){
83         vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
84         return TS_FAIL;
85     }
86
87 }
fe24d2 88
M 89 //self avoidance check with distant vertices
90     cellidx=vertex_self_avoidance(vesicle, vtx);
91     //check occupation number
92     retval=cell_occupation_number_and_internal_proximity(vesicle->clist,cellidx,vtx);
93
aec47d 94     if(retval==TS_FAIL){
dcd350 95         vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
aec47d 96         return TS_FAIL;
SP 97     } 
1ad6d1 98    
SP 99  
c0ae90 100 //if all the tests are successful, then energy for vtx and neighbours is calculated
1ad6d1 101     for(i=0;i<vtx->neigh_no;i++){
dcd350 102     memcpy((void *)&backupvtx[i+1],(void *)vtx->neigh[i],sizeof(ts_vertex));
1ad6d1 103     }
aec47d 104
1121fa 105     if(vesicle->pswitch == 1 || vesicle->tape->constvolswitch>0){
414b8a 106         for(i=0;i<vtx->tristar_no;i++) dvol-=vtx->tristar[i]->volume;
c0ae90 107     }
SP 108
109     if(vesicle->tape->constareaswitch==2){
110         for(i=0;i<vtx->tristar_no;i++) darea-=vtx->tristar[i]->area;
111     
112     }
a63f17 113
aec47d 114     delta_energy=0;
fe5069 115     
SP 116 //    vesicle_volume(vesicle);
117 //    fprintf(stderr,"Volume in the beginning=%1.16e\n", vesicle->volume);
43c042 118
aec47d 119     //update the normals of triangles that share bead i.
8f6a69 120     for(i=0;i<vtx->tristar_no;i++) triangle_normal_vector(vtx->tristar[i]);
a63f17 121     oenergy=vtx->energy;
aec47d 122     energy_vertex(vtx);
a63f17 123     delta_energy=vtx->xk*(vtx->energy - oenergy);
aec47d 124     //the same is done for neighbouring vertices
8f6a69 125     for(i=0;i<vtx->neigh_no;i++){
SP 126         oenergy=vtx->neigh[i]->energy;
127         energy_vertex(vtx->neigh[i]);
128         delta_energy+=vtx->neigh[i]->xk*(vtx->neigh[i]->energy-oenergy);
aec47d 129     }
414b8a 130
1121fa 131     if(vesicle->pswitch == 1 || vesicle->tape->constvolswitch >0){
414b8a 132         for(i=0;i<vtx->tristar_no;i++) dvol+=vtx->tristar[i]->volume;
fbcbdf 133         if(vesicle->pswitch==1) delta_energy-=vesicle->pressure*dvol;
414b8a 134     };
43c042 135
c0ae90 136     if(vesicle->tape->constareaswitch==2){
SP 137         /* check whether the darea is gt epsarea */
138         for(i=0;i<vtx->tristar_no;i++) darea+=vtx->tristar[i]->area;
139         if(fabs(vesicle->area+darea-A0)>epsarea){
140             //restore old state.
141              vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
142                 for(i=0;i<vtx->neigh_no;i++){
143                     vtx->neigh[i]=memcpy((void *)vtx->neigh[i],(void *)&backupvtx[i+1],sizeof(ts_vertex));
144                 }
145                     for(i=0;i<vtx->tristar_no;i++) triangle_normal_vector(vtx->tristar[i]); 
146                     //fprintf(stderr,"fajlam!\n");
147                     return TS_FAIL;
148         }
149
150
151     }
1121fa 152
SP 153     if(vesicle->tape->constvolswitch==2){
154         /*check whether the dvol is gt than epsvol */
155             //fprintf(stderr,"DVOL=%1.16e\n",dvol);
156         if(fabs(vesicle->volume+dvol-V0)>epsvol){
157             //restore old state.
158              vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
159                 for(i=0;i<vtx->neigh_no;i++){
160                     vtx->neigh[i]=memcpy((void *)vtx->neigh[i],(void *)&backupvtx[i+1],sizeof(ts_vertex));
161                 }
162                     for(i=0;i<vtx->tristar_no;i++) triangle_normal_vector(vtx->tristar[i]); 
163                     //fprintf(stderr,"fajlam!\n");
164                     return TS_FAIL;
165         }
166
167     } else
fe5069 168 //    vesicle_volume(vesicle);
SP 169 //    fprintf(stderr,"Volume before=%1.16e\n", vesicle->volume);
fbcbdf 170    if(vesicle->tape->constvolswitch == 1){
fe5069 171         retval=constvolume(vesicle, vtx, -dvol, &delta_energy_cv, &constvol_vtx_moved,&constvol_vtx_backup);
fbcbdf 172         if(retval==TS_FAIL){ // if we couldn't move the vertex to assure constant volume
SP 173             vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
174             for(i=0;i<vtx->neigh_no;i++){
175                 vtx->neigh[i]=memcpy((void *)vtx->neigh[i],(void *)&backupvtx[i+1],sizeof(ts_vertex));
176             }
177             for(i=0;i<vtx->tristar_no;i++) triangle_normal_vector(vtx->tristar[i]); 
fe5069 178  //           fprintf(stderr,"fajlam!\n");
fbcbdf 179             return TS_FAIL;
SP 180         }
fe5069 181 //    vesicle_volume(vesicle);
SP 182 //    fprintf(stderr,"Volume after=%1.16e\n", vesicle->volume);
183 //    fprintf(stderr,"Volume after-dvol=%1.16e\n", vesicle->volume-dvol);
184 //    fprintf(stderr,"Denergy before=%e\n",delta_energy);
185     
fbcbdf 186     delta_energy+=delta_energy_cv;
fe5069 187 //    fprintf(stderr,"Denergy after=%e\n",delta_energy);
fbcbdf 188     }
304510 189 /* No poly-bond energy for now!
fedf2b 190     if(vtx->grafted_poly!=NULL){
M 191         delta_energy+=
192             (pow(sqrt(vtx_distance_sq(vtx, vtx->grafted_poly->vlist->vtx[0])-1),2)-
193             pow(sqrt(vtx_distance_sq(&backupvtx[0], vtx->grafted_poly->vlist->vtx[0])-1),2)) *vtx->grafted_poly->k;
194     }
304510 195 */
314f2d 196 //   fprintf(stderr, "DE=%f\n",delta_energy);
aec47d 197     //MONTE CARLOOOOOOOO
SP 198     if(delta_energy>=0){
199 #ifdef TS_DOUBLE_DOUBLE
3de289 200         if(exp(-delta_energy)< drand48())
aec47d 201 #endif
SP 202 #ifdef TS_DOUBLE_FLOAT
203         if(expf(-delta_energy)< (ts_float)drand48())
204 #endif
205 #ifdef TS_DOUBLE_LONGDOUBLE
206         if(expl(-delta_energy)< (ts_ldouble)drand48())
207 #endif
208     {
209     //not accepted, reverting changes
fbcbdf 210   //  fprintf(stderr,"MC failed\n");
dcd350 211     vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
1ad6d1 212     for(i=0;i<vtx->neigh_no;i++){
a63f17 213         vtx->neigh[i]=memcpy((void *)vtx->neigh[i],(void *)&backupvtx[i+1],sizeof(ts_vertex));
1ad6d1 214     }
SP 215     
aec47d 216     //update the normals of triangles that share bead i.
dcd350 217    for(i=0;i<vtx->tristar_no;i++) triangle_normal_vector(vtx->tristar[i]);
1ad6d1 218
fe5069 219 //    fprintf(stderr, "before vtx(x,y,z)=%e,%e,%e\n",constvol_vtx_moved->x, constvol_vtx_moved->y, constvol_vtx_moved->z);
43c042 220     if(vesicle->tape->constvolswitch == 1){
958e0e 221         constvolumerestore(constvol_vtx_moved,constvol_vtx_backup);
43c042 222     }
fe5069 223 //    fprintf(stderr, "after vtx(x,y,z)=%e,%e,%e\n",constvol_vtx_moved->x, constvol_vtx_moved->y, constvol_vtx_moved->z);
dd5aca 224 //    vesicle_volume(vesicle);
SP 225 //    fprintf(stderr,"Volume after fail=%1.16e\n", vesicle->volume);
aec47d 226     return TS_FAIL; 
SP 227     }
228 }
2b14da 229     //accepted    
fbcbdf 230  //   fprintf(stderr,"MC accepted\n");
a63f17 231 //    oldcellidx=vertex_self_avoidance(vesicle, &backupvtx[0]);
SP 232     if(vtx->cell!=vesicle->clist->cell[cellidx]){
233         retval=cell_add_vertex(vesicle->clist->cell[cellidx],vtx);
234 //        if(retval==TS_SUCCESS) cell_remove_vertex(vesicle->clist->cell[oldcellidx],vtx);
235         if(retval==TS_SUCCESS) cell_remove_vertex(backupvtx[0].cell,vtx);
236         
237     }
2b14da 238
1121fa 239     if(vesicle->tape->constvolswitch == 2){
SP 240     vesicle->volume+=dvol;
241     } else
43c042 242     if(vesicle->tape->constvolswitch == 1){
fbcbdf 243         constvolumeaccept(vesicle,constvol_vtx_moved,constvol_vtx_backup);
43c042 244     }
c0ae90 245
SP 246     if(vesicle->tape->constareaswitch==2){
247         vesicle->area+=darea;
248     }
a63f17 249 //    if(oldcellidx);
aec47d 250     //END MONTE CARLOOOOOOO
dd5aca 251 //    vesicle_volume(vesicle);
SP 252 //    fprintf(stderr,"Volume after success=%1.16e\n", vesicle->volume);
aec47d 253     return TS_SUCCESS;
SP 254 }
255
fedf2b 256
M 257 ts_bool single_poly_vertex_move(ts_vesicle *vesicle,ts_poly *poly,ts_vertex *vtx,ts_double *rn){
258     ts_uint i;
259     ts_bool retval; 
260     ts_uint cellidx; 
304510 261 //    ts_double delta_energy;
fedf2b 262     ts_double costheta,sintheta,phi,r;
304510 263     ts_double dist;
fedf2b 264     //This will hold all the information of vtx and its neighbours
M 265     ts_vertex backupvtx;
304510 266 //    ts_bond backupbond[2];
fedf2b 267     memcpy((void *)&backupvtx,(void *)vtx,sizeof(ts_vertex));
M 268
269     //random move in a sphere with radius stepsize:
270     r=vesicle->stepsize*rn[0];
271     phi=rn[1]*2*M_PI;
272     costheta=2*rn[2]-1;
273     sintheta=sqrt(1-pow(costheta,2));
274     vtx->x=vtx->x+r*sintheta*cos(phi);
275     vtx->y=vtx->y+r*sintheta*sin(phi);
276     vtx->z=vtx->z+r*costheta;
277
278
279     //distance with neighbours check
304510 280     for(i=0;i<vtx->neigh_no;i++){
M 281         dist=vtx_distance_sq(vtx,vtx->neigh[i]);
282         if(dist<1.0 || dist>vesicle->dmax) {
283             vtx=memcpy((void *)vtx,(void *)&backupvtx,sizeof(ts_vertex));
284             return TS_FAIL;
285         }
286     }
287
288 // Distance with grafted vesicle-vertex check:    
289     if(vtx==poly->vlist->vtx[0]){
290         dist=vtx_distance_sq(vtx,poly->grafted_vtx);
291         if(dist<1.0 || dist>vesicle->dmax) {
292         vtx=memcpy((void *)vtx,(void *)&backupvtx,sizeof(ts_vertex));
293         return TS_FAIL;
294         }
295     }
296
fedf2b 297
M 298     //self avoidance check with distant vertices
299     cellidx=vertex_self_avoidance(vesicle, vtx);
300     //check occupation number
301     retval=cell_occupation_number_and_internal_proximity(vesicle->clist,cellidx,vtx);
302     
303     if(retval==TS_FAIL){
304         vtx=memcpy((void *)vtx,(void *)&backupvtx,sizeof(ts_vertex));
305         return TS_FAIL;
306     } 
307
308
309     //if all the tests are successful, then energy for vtx and neighbours is calculated
304510 310 /* Energy ignored for now!
fedf2b 311     delta_energy=0;
M 312     for(i=0;i<vtx->bond_no;i++){
313         memcpy((void *)&backupbond[i],(void *)vtx->bond[i],sizeof(ts_bond));
314
315         vtx->bond[i]->bond_length=sqrt(vtx_distance_sq(vtx->bond[i]->vtx1,vtx->bond[i]->vtx2));
316         bond_energy(vtx->bond[i],poly);
317         delta_energy+= vtx->bond[i]->energy - backupbond[i].energy;
318     }
319
320     if(vtx==poly->vlist->vtx[0]){
321         delta_energy+=
322             (pow(sqrt(vtx_distance_sq(vtx, poly->grafted_vtx)-1),2)-
323             pow(sqrt(vtx_distance_sq(&backupvtx, poly->grafted_vtx)-1),2)) *poly->k;
324         
325     }
326
327
328     if(delta_energy>=0){
329 #ifdef TS_DOUBLE_DOUBLE
330         if(exp(-delta_energy)< drand48() )
331 #endif
332 #ifdef TS_DOUBLE_FLOAT
333         if(expf(-delta_energy)< (ts_float)drand48())
334 #endif
335 #ifdef TS_DOUBLE_LONGDOUBLE
336         if(expl(-delta_energy)< (ts_ldouble)drand48())
337 #endif
338         {
339     //not accepted, reverting changes
340     vtx=memcpy((void *)vtx,(void *)&backupvtx,sizeof(ts_vertex));
341     for(i=0;i<vtx->bond_no;i++){
342     vtx->bond[i]=memcpy((void *)vtx->bond[i],(void *)&backupbond[i],sizeof(ts_bond));
343     }
344
345     return TS_FAIL; 
346     }
347     }
304510 348 */
fedf2b 349         
M 350 //    oldcellidx=vertex_self_avoidance(vesicle, &backupvtx[0]);
351     if(vtx->cell!=vesicle->clist->cell[cellidx]){
352         retval=cell_add_vertex(vesicle->clist->cell[cellidx],vtx);
353 //        if(retval==TS_SUCCESS) cell_remove_vertex(vesicle->clist->cell[oldcellidx],vtx);
354         if(retval==TS_SUCCESS) cell_remove_vertex(backupvtx.cell,vtx);    
355     }
356 //    if(oldcellidx);
357     //END MONTE CARLOOOOOOO
358     return TS_SUCCESS;
359 }
58230a 360
M 361
362
363
364 ts_bool single_filament_vertex_move(ts_vesicle *vesicle,ts_poly *poly,ts_vertex *vtx,ts_double *rn){
365     ts_uint i;
366     ts_bool retval; 
367     ts_uint cellidx; 
b30f45 368     ts_double delta_energy;
58230a 369     ts_double costheta,sintheta,phi,r;
M 370     ts_double dist[2];
371     //This will hold all the information of vtx and its neighbours
b30f45 372     ts_vertex backupvtx,backupneigh[2];
58230a 373     ts_bond backupbond[2];
b30f45 374
M 375     //backup vertex:        
58230a 376     memcpy((void *)&backupvtx,(void *)vtx,sizeof(ts_vertex));
M 377
378     //random move in a sphere with radius stepsize:
379     r=vesicle->stepsize*rn[0];
380     phi=rn[1]*2*M_PI;
381     costheta=2*rn[2]-1;
382     sintheta=sqrt(1-pow(costheta,2));
383     vtx->x=vtx->x+r*sintheta*cos(phi);
384     vtx->y=vtx->y+r*sintheta*sin(phi);
385     vtx->z=vtx->z+r*costheta;
386
387
388     //distance with neighbours check
389     for(i=0;i<vtx->bond_no;i++){
390         dist[i]=vtx_distance_sq(vtx->bond[i]->vtx1,vtx->bond[i]->vtx2);
391         if(dist[i]<1.0 || dist[i]>vesicle->dmax) {
392             vtx=memcpy((void *)vtx,(void *)&backupvtx,sizeof(ts_vertex));
393             return TS_FAIL;
394         }
395     }
396
fe24d2 397 // TODO: Maybe faster if checks only nucleus-neighboring cells
M 398 // Nucleus penetration check:
399     if (vtx->x*vtx->x + vtx->y*vtx->y + vtx->z*vtx->z < vesicle->R_nucleus){
400         vtx=memcpy((void *)vtx,(void *)&backupvtx,sizeof(ts_vertex));
401         return TS_FAIL;
402     }
403
58230a 404
M 405     //self avoidance check with distant vertices
406     cellidx=vertex_self_avoidance(vesicle, vtx);
407     //check occupation number
408     retval=cell_occupation_number_and_internal_proximity(vesicle->clist,cellidx,vtx);
409     if(retval==TS_FAIL){
410         vtx=memcpy((void *)vtx,(void *)&backupvtx,sizeof(ts_vertex));
411         return TS_FAIL;
412     } 
413
414     //backup bonds
415     for(i=0;i<vtx->bond_no;i++){
416         memcpy(&backupbond[i],vtx->bond[i], sizeof(ts_bond));
417         vtx->bond[i]->bond_length=sqrt(dist[i]);
418         bond_vector(vtx->bond[i]);
b30f45 419     }
M 420
421     //backup neighboring vertices:
422     for(i=0;i<vtx->neigh_no;i++){
423         memcpy(&backupneigh[i],vtx->neigh[i], sizeof(ts_vertex));
58230a 424     }
M 425     
426     //if all the tests are successful, then energy for vtx and neighbours is calculated
b30f45 427     delta_energy=0;
M 428     
429     if(vtx->bond_no == 2){
430         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;
431         delta_energy += vtx->energy - backupvtx.energy;
58230a 432     }
M 433
b30f45 434     for(i=0;i<vtx->neigh_no;i++){
M 435         if(vtx->neigh[i]->bond_no == 2){
436             vtx->neigh[i]->energy = -(vtx->neigh[i]->bond[0]->x*vtx->neigh[i]->bond[1]->x + vtx->neigh[i]->bond[0]->y*vtx->neigh[i]->bond[1]->y + vtx->neigh[i]->bond[0]->z*vtx->neigh[i]->bond[1]->z)/vtx->neigh[i]->bond[0]->bond_length/vtx->neigh[i]->bond[1]->bond_length;
437             delta_energy += vtx->neigh[i]->energy - backupneigh[i].energy;
438         }
58230a 439     }
M 440
b30f45 441     // poly->k is filament persistence length (in units l_min)
M 442     delta_energy *= poly->k;
58230a 443
M 444     if(delta_energy>=0){
445 #ifdef TS_DOUBLE_DOUBLE
446         if(exp(-delta_energy)< drand48() )
447 #endif
448 #ifdef TS_DOUBLE_FLOAT
449         if(expf(-delta_energy)< (ts_float)drand48())
450 #endif
451 #ifdef TS_DOUBLE_LONGDOUBLE
452         if(expl(-delta_energy)< (ts_ldouble)drand48())
453 #endif
454         {
455     //not accepted, reverting changes
456     vtx=memcpy((void *)vtx,(void *)&backupvtx,sizeof(ts_vertex));
b30f45 457     for(i=0;i<vtx->neigh_no;i++){
M 458         memcpy(vtx->neigh[i],&backupneigh[i],sizeof(ts_vertex));
459     }
58230a 460     for(i=0;i<vtx->bond_no;i++){
b30f45 461         vtx->bond[i]=memcpy((void *)vtx->bond[i],(void *)&backupbond[i],sizeof(ts_bond));
58230a 462     }
M 463
464     return TS_FAIL; 
465     }
466     }
467     
b30f45 468     
58230a 469 //    oldcellidx=vertex_self_avoidance(vesicle, &backupvtx[0]);
M 470     if(vtx->cell!=vesicle->clist->cell[cellidx]){
471         retval=cell_add_vertex(vesicle->clist->cell[cellidx],vtx);
472 //        if(retval==TS_SUCCESS) cell_remove_vertex(vesicle->clist->cell[oldcellidx],vtx);
473         if(retval==TS_SUCCESS) cell_remove_vertex(backupvtx.cell,vtx);    
474     }
475 //    if(oldcellidx);
476     //END MONTE CARLOOOOOOO
477     return TS_SUCCESS;
478 }