From 58230a2591414fb38b9ec8d3a76439b290cb0a6f Mon Sep 17 00:00:00 2001 From: mihaf <miha.fosnaric@gmail.com> Date: Tue, 18 Mar 2014 13:09:23 +0000 Subject: [PATCH] Adding ending energy to filaments. In progress. Continue in single_filament_vertex_move --- src/poly.c | 91 ++++++++++++++++++++++++++++++--------------- 1 files changed, 60 insertions(+), 31 deletions(-) diff --git a/src/poly.c b/src/poly.c index 1ddcec7..d99d2ad 100644 --- a/src/poly.c +++ b/src/poly.c @@ -20,8 +20,10 @@ ts_poly *poly=(ts_poly *)calloc(1,sizeof(ts_poly)); poly->vlist = init_vertex_list(n); poly->blist = init_bond_list(); - poly->grafted_vtx = grafted_vtx; - grafted_vtx->grafted_poly = poly; + if (grafted_vtx!=NULL){ + poly->grafted_vtx = grafted_vtx; + grafted_vtx->grafted_poly = poly; + } ts_uint i; for(i=0;i<n-1;i++){ @@ -38,50 +40,77 @@ } -ts_poly_list *init_poly_list(ts_uint n_poly, ts_uint n_mono, ts_vertex_list *vlist){ +ts_poly_list *init_poly_list(ts_uint n_poly, ts_uint n_mono, ts_vertex_list *vlist, ts_vesicle *vesicle){ ts_poly_list *poly_list=(ts_poly_list *)calloc(1,sizeof(ts_poly_list)); poly_list->poly = (ts_poly **)calloc(n_poly,sizeof(ts_poly *)); - ts_uint i=0,j=0, idx; + ts_uint i=0,j=0; //idx; ts_uint gvtxi; ts_double xnorm,ynorm,znorm,normlength; + ts_double dphi,dh; + ts_uint ji; - if (n_poly > vlist->n){fatal("Number of polymers larger then numbero f vertices on a vesicle.",310);} + // Grafting polymers: + if (vlist!=NULL){ + if (n_poly > vlist->n){fatal("Number of polymers larger then numbero f vertices on a vesicle.",310);} - while(i<n_poly){ - gvtxi = rand() % vlist->n; - if (vlist->vtx[gvtxi]->grafted_poly == NULL){ - poly_list->poly[i] = init_poly(n_mono, vlist->vtx[gvtxi]); - i++; + while(i<n_poly){ + gvtxi = rand() % vlist->n; + if (vlist->vtx[gvtxi]->grafted_poly == NULL){ + poly_list->poly[i] = init_poly(n_mono, vlist->vtx[gvtxi]); + i++; + } } } - + else + { + for(i=0;i<n_poly;i++){ + poly_list->poly[i] = init_poly(n_mono, NULL); + } + } + poly_list->n = n_poly; -/* Make straight poylmers normal to membrane. Dist. between poly vertices put to 1*/ - for (i=0;i<poly_list->n;i++){ + if (vlist!=NULL){ + /* Make straight grafted poylmers normal to membrane (polymer brush). Dist. between poly vertices put to 1*/ + for (i=0;i<poly_list->n;i++){ + + xnorm=0.0; + ynorm=0.0; + znorm=0.0; + for (j=0;j<poly_list->poly[i]->grafted_vtx->tristar_no;j++){ + xnorm-=poly_list->poly[i]->grafted_vtx->tristar[j]->xnorm; + ynorm-=poly_list->poly[i]->grafted_vtx->tristar[j]->ynorm; + znorm-=poly_list->poly[i]->grafted_vtx->tristar[j]->znorm; + } + normlength=sqrt(xnorm*xnorm+ynorm*ynorm+znorm*znorm); + xnorm=xnorm/normlength; + ynorm=ynorm/normlength; + znorm=znorm/normlength; - xnorm=0.0; - ynorm=0.0; - znorm=0.0; - for (j=0;j<poly_list->poly[i]->grafted_vtx->tristar_no;j++){ - xnorm-=poly_list->poly[i]->grafted_vtx->tristar[j]->xnorm; - ynorm-=poly_list->poly[i]->grafted_vtx->tristar[j]->ynorm; - znorm-=poly_list->poly[i]->grafted_vtx->tristar[j]->znorm; + for (j=0;j<poly_list->poly[i]->vlist->n;j++){ + poly_list->poly[i]->vlist->vtx[j]->x = poly_list->poly[i]->grafted_vtx->x + xnorm*(ts_double)(j+1); + poly_list->poly[i]->vlist->vtx[j]->y = poly_list->poly[i]->grafted_vtx->y + ynorm*(ts_double)(j+1); + poly_list->poly[i]->vlist->vtx[j]->z = poly_list->poly[i]->grafted_vtx->z + znorm*(ts_double)(j+1); + } } - normlength=sqrt(xnorm*xnorm+ynorm*ynorm+znorm*znorm); - xnorm=xnorm/normlength; - ynorm=ynorm/normlength; - znorm=znorm/normlength; - - for (j=0;j<poly_list->poly[i]->vlist->n;j++){ - poly_list->poly[i]->vlist->vtx[j]->x = poly_list->poly[i]->grafted_vtx->x + xnorm*(ts_double)(j+1); - poly_list->poly[i]->vlist->vtx[j]->y = poly_list->poly[i]->grafted_vtx->y + ynorm*(ts_double)(j+1); - poly_list->poly[i]->vlist->vtx[j]->z = poly_list->poly[i]->grafted_vtx->z + znorm*(ts_double)(j+1); + } + else + { + /* Make filaments inside the vesicle. Helix with radius... Dist. between poly vertices put to 1*/ + dphi = 2.0*asin(1.0/2.0/vesicle->R_nucleus)*1.001; + dh = dphi/2.0/M_PI*1.001; + for(i=0;i<poly_list->n;i++){ + for (j=0;j<poly_list->poly[i]->vlist->n;j++){ + ji = j + i*poly_list->poly[i]->vlist->n; + poly_list->poly[i]->vlist->vtx[j]->x = vesicle->R_nucleus*cos(ji*dphi); + poly_list->poly[i]->vlist->vtx[j]->y = vesicle->R_nucleus*sin(ji*dphi); + poly_list->poly[i]->vlist->vtx[j]->z = ji*dh - (dh*poly_list->n*poly_list->poly[i]->vlist->n/2.0); + } } } //index correction for polymeres. Important, since each vtx has to have unique id - idx=vlist->n; +/* idx=vlist->n; for(i=0;i<n_poly;i++){ for(j=0;j<n_mono;j++,idx++){ @@ -89,7 +118,7 @@ } } - +*/ return poly_list; } -- Gitblit v1.9.3