From 3a018d380395889059bf582015fb2935a9a20fb0 Mon Sep 17 00:00:00 2001 From: mihaf <miha.fosnaric@gmail.com> Date: Thu, 27 Feb 2014 14:55:13 +0000 Subject: [PATCH] Bug found and removed: polys now also translated when origin moves to the center of mass. All seems OK after firt testing. :) --- src/poly.c | 34 ++++++++++++++++++++++++++++++---- 1 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/poly.c b/src/poly.c index 20529e2..1ddcec7 100644 --- a/src/poly.c +++ b/src/poly.c @@ -4,7 +4,17 @@ #include"vertex.h" #include"bond.h" #include<math.h> +#include"energy.h" +ts_bool poly_assign_spring_const(ts_vesicle *vesicle){ + ts_uint i; + + for(i=0;i<vesicle->poly_list->n;i++){ + vesicle->poly_list->poly[i]->k = vesicle->spring_constant; + } + + return TS_SUCCESS; +} ts_poly *init_poly(ts_uint n, ts_vertex *grafted_vtx){ ts_poly *poly=(ts_poly *)calloc(1,sizeof(ts_poly)); @@ -19,6 +29,11 @@ vtx_add_neighbour(poly->vlist->vtx[i+1], poly->vlist->vtx[i]); } + for(i=0;i<poly->blist->n;i++){ + poly->blist->bond[i]->bond_length=sqrt(vtx_distance_sq(poly->blist->bond[i]->vtx1,poly->blist->bond[i]->vtx2)); + bond_energy(poly->blist->bond[i],poly); + } + return poly; } @@ -26,7 +41,7 @@ ts_poly_list *init_poly_list(ts_uint n_poly, ts_uint n_mono, ts_vertex_list *vlist){ 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; + ts_uint i=0,j=0, idx; ts_uint gvtxi; ts_double xnorm,ynorm,znorm,normlength; @@ -49,9 +64,9 @@ 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; + 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; @@ -65,6 +80,17 @@ } } + //index correction for polymeres. Important, since each vtx has to have unique id + idx=vlist->n; + for(i=0;i<n_poly;i++){ + for(j=0;j<n_mono;j++,idx++){ + + poly_list->poly[i]->vlist->vtx[j]->idx=idx; + + } + } + + return poly_list; } -- Gitblit v1.9.3