From 82a8abcddd62838bfcd06b6081042caf4d385a88 Mon Sep 17 00:00:00 2001 From: Samo Penic <samo.penic@gmail.com> Date: Wed, 13 Jul 2016 21:37:13 +0000 Subject: [PATCH] Seems that the bugs are fixed. Pegs are self avoidant now --- src/poly.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/poly.c b/src/poly.c index 39d0723..b91ff62 100644 --- a/src/poly.c +++ b/src/poly.c @@ -135,7 +135,7 @@ k++; if(k>1000){ //undo changes to the cell - for(l=0;l<j-1;l++){ + for(l=0;l<j;l++){ cellidx=vertex_self_avoidance(vesicle, poly_list->poly[i]->vlist->vtx[l]); cell_remove_vertex(vesicle->clist->cell[cellidx],poly_list->poly[i]->vlist->vtx[l]); } @@ -161,9 +161,9 @@ ts_double dphi,dh; cell_occupation(vesicle); //needed for evading the membrane // Grafting polymers: + int tries=0; if (vlist!=NULL){ if (n_poly > vlist->n){fatal("Number of polymers larger than numbero f vertices on a vesicle.",310);} - while(i<n_poly){ gvtxi = rand() % vlist->n; if (vlist->vtx[gvtxi]->grafted_poly == NULL){ @@ -171,10 +171,16 @@ retval=poly_initial_distribution(poly_list, i, vesicle); if(retval==TS_FAIL){ ts_fprintf(stdout,"Found new potential grafting vertex %d for poly %d\n",gvtxi,i); + poly_free(poly_list->poly[i]); + tries++; } else { + tries=0; i++; } + if(tries>5000){ + fatal("Cannot find space for inner polymeres",1001); + } } } } -- Gitblit v1.9.3