Trisurf Monte Carlo simulator
Samo Penic
2019-02-28 b5cd8cc72380e9ca576ec942753391df85a2a436
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"
9166cb 12 #include "io.h"
aec47d 13 #include<stdio.h>
SP 14 #include "vertexmove.h"
1ad6d1 15 #include <string.h>
43c042 16 #include "constvol.h"
51b4f0 17 #include "plugins.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_bool retval; 
22     ts_uint cellidx; 
7ec6fb 23     ts_double delta_energy, delta_energy_cv,oenergy,dvol=0.0, darea=0.0, dstretchenergy=0.0;
ed31fe 24     ts_double costheta,sintheta,phi,r;
1ad6d1 25     //This will hold all the information of vtx and its neighbours
b5cd8c 26     ts_vertex backupvtx[20], *constvol_vtx_moved=NULL, *constvol_vtx_backup=NULL;
SP 27     memcpy((void *)&backupvtx[0],(void *)vtx,sizeof(ts_vertex));
672ae4 28
b5cd8c 29     //random move in a sphere with radius stepsize:
SP 30     r=vesicle->stepsize*rn[0];
31     phi=rn[1]*2*M_PI;
32     costheta=2*rn[2]-1;
33     sintheta=sqrt(1-pow(costheta,2));
34     vtx->x=vtx->x+r*sintheta*cos(phi);
35     vtx->y=vtx->y+r*sintheta*sin(phi);
36     vtx->z=vtx->z+r*costheta;
672ae4 37
b5cd8c 38 // plane confinement check whether the new position of vertex will be out of bounds
88bdd7 39     if(vesicle->tape->plane_confinement_switch){
SP 40         if(vtx->z>vesicle->confinement_plane.z_max || vtx->z<vesicle->confinement_plane.z_min){
41         vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
42         return TS_FAIL;
43         }
44     }
fe24d2 45
51b4f0 46 /* Entry point for plugin vm_hard_constraint() function */
b5cd8c 47     ts_plugin_chain *ptr=vesicle->plist->chain->vm_hard_constraint;
SP 48     while(ptr!=NULL){
49         retval = ptr->plugin->function->vm_hard_constraint(vesicle,vtx, &backupvtx[0]);
51b4f0 50         if(retval==TS_FAIL){
SP 51             vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
52             return TS_FAIL;
53         }
b5cd8c 54         ptr=ptr->next;
51b4f0 55     }
SP 56
b5cd8c 57
1ad6d1 58  
c0ae90 59 //if all the tests are successful, then energy for vtx and neighbours is calculated
1ad6d1 60     for(i=0;i<vtx->neigh_no;i++){
dcd350 61     memcpy((void *)&backupvtx[i+1],(void *)vtx->neigh[i],sizeof(ts_vertex));
1ad6d1 62     }
aec47d 63
1121fa 64     if(vesicle->pswitch == 1 || vesicle->tape->constvolswitch>0){
414b8a 65         for(i=0;i<vtx->tristar_no;i++) dvol-=vtx->tristar[i]->volume;
c0ae90 66     }
SP 67
68     if(vesicle->tape->constareaswitch==2){
69         for(i=0;i<vtx->tristar_no;i++) darea-=vtx->tristar[i]->area;
70     
71     }
7ec6fb 72     //stretching energy 1 of 3
SP 73     if(vesicle->tape->stretchswitch==1){
699ac4 74         for(i=0;i<vtx->tristar_no;i++) dstretchenergy-=vtx->tristar[i]->energy;
7ec6fb 75     }
aec47d 76     delta_energy=0;
0dd5ba 77
SP 78
fe5069 79 //    vesicle_volume(vesicle);
SP 80 //    fprintf(stderr,"Volume in the beginning=%1.16e\n", vesicle->volume);
43c042 81
aec47d 82     //update the normals of triangles that share bead i.
8f6a69 83     for(i=0;i<vtx->tristar_no;i++) triangle_normal_vector(vtx->tristar[i]);
a63f17 84     oenergy=vtx->energy;
aec47d 85     energy_vertex(vtx);
a63f17 86     delta_energy=vtx->xk*(vtx->energy - oenergy);
aec47d 87     //the same is done for neighbouring vertices
8f6a69 88     for(i=0;i<vtx->neigh_no;i++){
SP 89         oenergy=vtx->neigh[i]->energy;
90         energy_vertex(vtx->neigh[i]);
91         delta_energy+=vtx->neigh[i]->xk*(vtx->neigh[i]->energy-oenergy);
aec47d 92     }
414b8a 93
1121fa 94     if(vesicle->pswitch == 1 || vesicle->tape->constvolswitch >0){
414b8a 95         for(i=0;i<vtx->tristar_no;i++) dvol+=vtx->tristar[i]->volume;
fbcbdf 96         if(vesicle->pswitch==1) delta_energy-=vesicle->pressure*dvol;
414b8a 97     };
43c042 98
c0ae90 99     if(vesicle->tape->constareaswitch==2){
SP 100         /* check whether the darea is gt epsarea */
101         for(i=0;i<vtx->tristar_no;i++) darea+=vtx->tristar[i]->area;
102         if(fabs(vesicle->area+darea-A0)>epsarea){
103             //restore old state.
104              vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
105                 for(i=0;i<vtx->neigh_no;i++){
106                     vtx->neigh[i]=memcpy((void *)vtx->neigh[i],(void *)&backupvtx[i+1],sizeof(ts_vertex));
107                 }
108                     for(i=0;i<vtx->tristar_no;i++) triangle_normal_vector(vtx->tristar[i]); 
109                     //fprintf(stderr,"fajlam!\n");
110                     return TS_FAIL;
111         }
112
113
114     }
1121fa 115
SP 116     if(vesicle->tape->constvolswitch==2){
117         /*check whether the dvol is gt than epsvol */
118             //fprintf(stderr,"DVOL=%1.16e\n",dvol);
119         if(fabs(vesicle->volume+dvol-V0)>epsvol){
120             //restore old state.
121              vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
122                 for(i=0;i<vtx->neigh_no;i++){
123                     vtx->neigh[i]=memcpy((void *)vtx->neigh[i],(void *)&backupvtx[i+1],sizeof(ts_vertex));
124                 }
125                     for(i=0;i<vtx->tristar_no;i++) triangle_normal_vector(vtx->tristar[i]); 
126                     //fprintf(stderr,"fajlam!\n");
127                     return TS_FAIL;
128         }
129
130     } else
fe5069 131 //    vesicle_volume(vesicle);
SP 132 //    fprintf(stderr,"Volume before=%1.16e\n", vesicle->volume);
fbcbdf 133    if(vesicle->tape->constvolswitch == 1){
fe5069 134         retval=constvolume(vesicle, vtx, -dvol, &delta_energy_cv, &constvol_vtx_moved,&constvol_vtx_backup);
fbcbdf 135         if(retval==TS_FAIL){ // if we couldn't move the vertex to assure constant volume
SP 136             vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
137             for(i=0;i<vtx->neigh_no;i++){
138                 vtx->neigh[i]=memcpy((void *)vtx->neigh[i],(void *)&backupvtx[i+1],sizeof(ts_vertex));
139             }
140             for(i=0;i<vtx->tristar_no;i++) triangle_normal_vector(vtx->tristar[i]); 
fe5069 141  //           fprintf(stderr,"fajlam!\n");
fbcbdf 142             return TS_FAIL;
SP 143         }
fe5069 144 //    vesicle_volume(vesicle);
SP 145 //    fprintf(stderr,"Volume after=%1.16e\n", vesicle->volume);
146 //    fprintf(stderr,"Volume after-dvol=%1.16e\n", vesicle->volume-dvol);
147 //    fprintf(stderr,"Denergy before=%e\n",delta_energy);
148     
fbcbdf 149     delta_energy+=delta_energy_cv;
fe5069 150 //    fprintf(stderr,"Denergy after=%e\n",delta_energy);
fbcbdf 151     }
250de4 152 /* Vertices with spontaneous curvature may have spontaneous force perpendicular to the surface of the vesicle. additional delta energy is calculated in this function */
SP 153     delta_energy+=direct_force_energy(vesicle,vtx,backupvtx);
7ec6fb 154
SP 155     //stretching energy 2 of 3
156     if(vesicle->tape->stretchswitch==1){
157         for(i=0;i<vtx->tristar_no;i++){ 
158             stretchenergy(vesicle, vtx->tristar[i]);
699ac4 159             dstretchenergy+=vtx->tristar[i]->energy;
7ec6fb 160             }
SP 161     }
162
163     delta_energy+=dstretchenergy;    
164         
304510 165 /* No poly-bond energy for now!
fedf2b 166     if(vtx->grafted_poly!=NULL){
M 167         delta_energy+=
168             (pow(sqrt(vtx_distance_sq(vtx, vtx->grafted_poly->vlist->vtx[0])-1),2)-
169             pow(sqrt(vtx_distance_sq(&backupvtx[0], vtx->grafted_poly->vlist->vtx[0])-1),2)) *vtx->grafted_poly->k;
170     }
304510 171 */
0dd5ba 172
SP 173 // plane confinement energy due to compressing force
174     if(vesicle->tape->plane_confinement_switch){
175         if(vesicle->confinement_plane.force_switch){
176             //substract old energy
177             if(abs(vesicle->tape->plane_d/2.0-vesicle->confinement_plane.z_max)>1e-10) {
178                 delta_energy-=vesicle->tape->plane_F / pow(vesicle->confinement_plane.z_max-backupvtx[0].z,2);
179                 delta_energy+=vesicle->tape->plane_F / pow(vesicle->confinement_plane.z_max-vtx->z,2);
180             }
181             if(abs(-vesicle->tape->plane_d/2.0-vesicle->confinement_plane.z_min)>1e-10) {
182                 delta_energy-=vesicle->tape->plane_F / pow(vesicle->confinement_plane.z_min-backupvtx[0].z,2);
183                 delta_energy+=vesicle->tape->plane_F / pow(vesicle->confinement_plane.z_min-vtx->z,2);
184             }
185         }
186     }
187
314f2d 188 //   fprintf(stderr, "DE=%f\n",delta_energy);
aec47d 189     //MONTE CARLOOOOOOOO
e5858f 190 //    if(vtx->c!=0.0) printf("DE=%f\n",delta_energy);
aec47d 191     if(delta_energy>=0){
SP 192 #ifdef TS_DOUBLE_DOUBLE
3de289 193         if(exp(-delta_energy)< drand48())
aec47d 194 #endif
SP 195 #ifdef TS_DOUBLE_FLOAT
196         if(expf(-delta_energy)< (ts_float)drand48())
197 #endif
198 #ifdef TS_DOUBLE_LONGDOUBLE
199         if(expl(-delta_energy)< (ts_ldouble)drand48())
200 #endif
201     {
202     //not accepted, reverting changes
fbcbdf 203   //  fprintf(stderr,"MC failed\n");
dcd350 204     vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
1ad6d1 205     for(i=0;i<vtx->neigh_no;i++){
a63f17 206         vtx->neigh[i]=memcpy((void *)vtx->neigh[i],(void *)&backupvtx[i+1],sizeof(ts_vertex));
1ad6d1 207     }
SP 208     
aec47d 209     //update the normals of triangles that share bead i.
dcd350 210    for(i=0;i<vtx->tristar_no;i++) triangle_normal_vector(vtx->tristar[i]);
7ec6fb 211     //stretching energy 3 of 3
SP 212     if(vesicle->tape->stretchswitch==1){
213         for(i=0;i<vtx->tristar_no;i++){ 
214             stretchenergy(vesicle,vtx->tristar[i]);
215             }
216     }
1ad6d1 217
fe5069 218 //    fprintf(stderr, "before vtx(x,y,z)=%e,%e,%e\n",constvol_vtx_moved->x, constvol_vtx_moved->y, constvol_vtx_moved->z);
43c042 219     if(vesicle->tape->constvolswitch == 1){
958e0e 220         constvolumerestore(constvol_vtx_moved,constvol_vtx_backup);
43c042 221     }
fe5069 222 //    fprintf(stderr, "after vtx(x,y,z)=%e,%e,%e\n",constvol_vtx_moved->x, constvol_vtx_moved->y, constvol_vtx_moved->z);
dd5aca 223 //    vesicle_volume(vesicle);
SP 224 //    fprintf(stderr,"Volume after fail=%1.16e\n", vesicle->volume);
aec47d 225     return TS_FAIL; 
SP 226     }
227 }
2b14da 228     //accepted    
fbcbdf 229  //   fprintf(stderr,"MC accepted\n");
a63f17 230 //    oldcellidx=vertex_self_avoidance(vesicle, &backupvtx[0]);
51b4f0 231     cellidx=vertex_self_avoidance(vesicle, vtx);
a63f17 232     if(vtx->cell!=vesicle->clist->cell[cellidx]){
SP 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 }