From 1d5dff5a3576a028f691608ef9369844efdfe82b Mon Sep 17 00:00:00 2001 From: mihaf <miha.fosnaric@gmail.com> Date: Fri, 29 Nov 2013 14:43:30 +0000 Subject: [PATCH] Structures for grafted polymers (Samo&Miha) --- src/poly.c | 36 ++++++++++++++++++++++++++++++++++++ src/general.h | 21 +++++++++++++++++++-- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/general.h b/src/general.h index 063e124..5194460 100644 --- a/src/general.h +++ b/src/general.h @@ -126,8 +126,6 @@ ts_uint coord_type; } ts_coord; - - /** @brief Data structure of all data connected to a vertex * * ts_vertex holds the data for one single point (bead, vertex). To understand how to use it @@ -155,6 +153,7 @@ ts_double projArea; ts_double relR; ts_double solAngle; + struct ts_poly *grafted_poly; }; typedef struct ts_vertex ts_vertex; @@ -227,6 +226,23 @@ +struct ts_poly { + ts_vertex_list *vlist; + ts_bond_list *blist; + ts_vertex *grafted_vtx; +}; +typedef struct ts_poly ts_poly; + + +struct ts_poly_list { + ts_uint n; + ts_poly **poly; +}; +typedef struct ts_poly_list ts_poly_list; + + + + typedef struct { ts_vertex_list *vlist; ts_bond_list *blist; @@ -239,6 +255,7 @@ ts_double cm[3]; ts_double volume; ts_spharm *sphHarmonics; + ts_poly_list *poly_list; } ts_vesicle; diff --git a/src/poly.c b/src/poly.c new file mode 100644 index 0000000..f362dd0 --- /dev/null +++ b/src/poly.c @@ -0,0 +1,36 @@ +ts_poly *init_poly(ts_uint n, ts_vertex *grafted_vtx){ + 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; + + ts_uint i; + for(i=0,i<n-1,i++){ + vtx_add_cneighbour(poly->blist, poly->vlist->vtx[i], poly->vlist->vtx[i+1]); + } + + return poly; +} + + +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)); + + if (n_poly > vlist->n){fatal("Number of polymers larger then numbero f vertices on a vesicle.",310);} + + ts_uint i=0; + ts_uint gvtxi; + while(i<n_poly){ + gvtxi = rand() % vlist->n + if (vlist->vtx[gvtxi]->grafted_poly == NULL){ + poly_list->poly = init_poly(n_mono, vlist->vtx[gvtxi]); + i++; + } + } + + poly_list->n = n_poly; + + return poly_list; +} + -- Gitblit v1.9.3