commit | author | age
|
8db569
|
1 |
#include"general.h" |
M |
2 |
#include"poly.h" |
|
3 |
#include<stdlib.h> |
|
4 |
#include"vertex.h" |
|
5 |
#include"bond.h" |
|
6 |
#include<math.h> |
fedf2b
|
7 |
#include"energy.h" |
8db569
|
8 |
|
bcf455
|
9 |
ts_bool poly_assign_filament_xi(ts_vesicle *vesicle, ts_tape *tape){ |
M |
10 |
ts_uint i; |
|
11 |
|
|
12 |
for(i=0;i<vesicle->filament_list->n;i++){ |
|
13 |
vesicle->filament_list->poly[i]->k = tape->xi; |
|
14 |
} |
|
15 |
|
|
16 |
return TS_SUCCESS; |
|
17 |
} |
|
18 |
|
|
19 |
|
48bb92
|
20 |
ts_bool poly_assign_spring_const(ts_vesicle *vesicle){ |
M |
21 |
ts_uint i; |
|
22 |
|
|
23 |
for(i=0;i<vesicle->poly_list->n;i++){ |
|
24 |
vesicle->poly_list->poly[i]->k = vesicle->spring_constant; |
|
25 |
} |
|
26 |
|
|
27 |
return TS_SUCCESS; |
|
28 |
} |
8db569
|
29 |
|
1d5dff
|
30 |
ts_poly *init_poly(ts_uint n, ts_vertex *grafted_vtx){ |
M |
31 |
ts_poly *poly=(ts_poly *)calloc(1,sizeof(ts_poly)); |
|
32 |
poly->vlist = init_vertex_list(n); |
|
33 |
poly->blist = init_bond_list(); |
624f81
|
34 |
if (grafted_vtx!=NULL){ |
M |
35 |
poly->grafted_vtx = grafted_vtx; |
|
36 |
grafted_vtx->grafted_poly = poly; |
|
37 |
} |
1d5dff
|
38 |
|
M |
39 |
ts_uint i; |
8db569
|
40 |
for(i=0;i<n-1;i++){ |
1d5dff
|
41 |
vtx_add_cneighbour(poly->blist, poly->vlist->vtx[i], poly->vlist->vtx[i+1]); |
8db569
|
42 |
vtx_add_neighbour(poly->vlist->vtx[i+1], poly->vlist->vtx[i]); |
1d5dff
|
43 |
} |
M |
44 |
|
48bb92
|
45 |
for(i=0;i<poly->blist->n;i++){ |
M |
46 |
poly->blist->bond[i]->bond_length=sqrt(vtx_distance_sq(poly->blist->bond[i]->vtx1,poly->blist->bond[i]->vtx2)); |
fedf2b
|
47 |
bond_energy(poly->blist->bond[i],poly); |
48bb92
|
48 |
} |
M |
49 |
|
1d5dff
|
50 |
return poly; |
M |
51 |
} |
|
52 |
|
|
53 |
|
624f81
|
54 |
ts_poly_list *init_poly_list(ts_uint n_poly, ts_uint n_mono, ts_vertex_list *vlist, ts_vesicle *vesicle){ |
1d5dff
|
55 |
ts_poly_list *poly_list=(ts_poly_list *)calloc(1,sizeof(ts_poly_list)); |
8db569
|
56 |
poly_list->poly = (ts_poly **)calloc(n_poly,sizeof(ts_poly *)); |
3c1ac1
|
57 |
ts_uint i=0,j=0; //idx; |
8db569
|
58 |
ts_uint gvtxi; |
M |
59 |
ts_double xnorm,ynorm,znorm,normlength; |
624f81
|
60 |
ts_double dphi,dh; |
1d5dff
|
61 |
|
624f81
|
62 |
// Grafting polymers: |
M |
63 |
if (vlist!=NULL){ |
|
64 |
if (n_poly > vlist->n){fatal("Number of polymers larger then numbero f vertices on a vesicle.",310);} |
1d5dff
|
65 |
|
624f81
|
66 |
while(i<n_poly){ |
M |
67 |
gvtxi = rand() % vlist->n; |
|
68 |
if (vlist->vtx[gvtxi]->grafted_poly == NULL){ |
|
69 |
poly_list->poly[i] = init_poly(n_mono, vlist->vtx[gvtxi]); |
|
70 |
i++; |
|
71 |
} |
1d5dff
|
72 |
} |
M |
73 |
} |
624f81
|
74 |
else |
M |
75 |
{ |
|
76 |
for(i=0;i<n_poly;i++){ |
|
77 |
poly_list->poly[i] = init_poly(n_mono, NULL); |
|
78 |
} |
|
79 |
} |
|
80 |
|
1d5dff
|
81 |
poly_list->n = n_poly; |
M |
82 |
|
624f81
|
83 |
if (vlist!=NULL){ |
M |
84 |
/* Make straight grafted poylmers normal to membrane (polymer brush). Dist. between poly vertices put to 1*/ |
|
85 |
for (i=0;i<poly_list->n;i++){ |
|
86 |
|
|
87 |
xnorm=0.0; |
|
88 |
ynorm=0.0; |
|
89 |
znorm=0.0; |
|
90 |
for (j=0;j<poly_list->poly[i]->grafted_vtx->tristar_no;j++){ |
|
91 |
xnorm-=poly_list->poly[i]->grafted_vtx->tristar[j]->xnorm; |
|
92 |
ynorm-=poly_list->poly[i]->grafted_vtx->tristar[j]->ynorm; |
|
93 |
znorm-=poly_list->poly[i]->grafted_vtx->tristar[j]->znorm; |
|
94 |
} |
|
95 |
normlength=sqrt(xnorm*xnorm+ynorm*ynorm+znorm*znorm); |
|
96 |
xnorm=xnorm/normlength; |
|
97 |
ynorm=ynorm/normlength; |
|
98 |
znorm=znorm/normlength; |
8db569
|
99 |
|
624f81
|
100 |
for (j=0;j<poly_list->poly[i]->vlist->n;j++){ |
M |
101 |
poly_list->poly[i]->vlist->vtx[j]->x = poly_list->poly[i]->grafted_vtx->x + xnorm*(ts_double)(j+1); |
|
102 |
poly_list->poly[i]->vlist->vtx[j]->y = poly_list->poly[i]->grafted_vtx->y + ynorm*(ts_double)(j+1); |
|
103 |
poly_list->poly[i]->vlist->vtx[j]->z = poly_list->poly[i]->grafted_vtx->z + znorm*(ts_double)(j+1); |
|
104 |
} |
8db569
|
105 |
} |
624f81
|
106 |
} |
M |
107 |
else |
|
108 |
{ |
|
109 |
/* Make filaments inside the vesicle. Helix with radius... Dist. between poly vertices put to 1*/ |
fe24d2
|
110 |
ts_double a,R,H,tantheta,h,r,phi,A0=1.2; |
M |
111 |
|
|
112 |
a = A0*(ts_double)vesicle->nshell; |
|
113 |
R = A0*((ts_double)vesicle->nshell)/(2.0*sin(M_PI/5.0)); |
|
114 |
H = sqrt(a*a - R*R); |
|
115 |
tantheta = sqrt(R*R - a*a/4.0)/H; |
|
116 |
|
|
117 |
h = -H + sqrt(vesicle->clist->dmin_interspecies)*1.5; |
|
118 |
r = (H-fabs(h))*tantheta - sqrt(vesicle->clist->dmin_interspecies)*1.5; |
|
119 |
dphi = 2.0*asin(1.0/2.0/r)*1.001; |
402e8f
|
120 |
dh = dphi/2.0/M_PI*1.001; |
fe24d2
|
121 |
phi=0.0; |
624f81
|
122 |
for(i=0;i<poly_list->n;i++){ |
M |
123 |
for (j=0;j<poly_list->poly[i]->vlist->n;j++){ |
fe24d2
|
124 |
h = h + dh; |
M |
125 |
r = (H-fabs(h))*tantheta - sqrt(vesicle->clist->dmin_interspecies)*1.5; |
|
126 |
dphi = 2.0*asin(1.0/2.0/r)*1.001; |
|
127 |
dh = dphi/2.0/M_PI*1.001; |
|
128 |
phi+=dphi; |
|
129 |
//ji = j + i*poly_list->poly[i]->vlist->n; |
|
130 |
poly_list->poly[i]->vlist->vtx[j]->x = r*cos(phi); |
|
131 |
poly_list->poly[i]->vlist->vtx[j]->y = r*sin(phi); |
|
132 |
poly_list->poly[i]->vlist->vtx[j]->z = h;// ji*dh - (dh*poly_list->n*poly_list->poly[i]->vlist->n/2.0); |
624f81
|
133 |
} |
8db569
|
134 |
} |
M |
135 |
} |
|
136 |
|
40aa5b
|
137 |
//index correction for polymeres. Important, since each vtx has to have unique id |
3c1ac1
|
138 |
/* idx=vlist->n; |
40aa5b
|
139 |
for(i=0;i<n_poly;i++){ |
SP |
140 |
for(j=0;j<n_mono;j++,idx++){ |
|
141 |
|
|
142 |
poly_list->poly[i]->vlist->vtx[j]->idx=idx; |
|
143 |
|
|
144 |
} |
|
145 |
} |
3c1ac1
|
146 |
*/ |
40aa5b
|
147 |
|
1d5dff
|
148 |
return poly_list; |
M |
149 |
} |
|
150 |
|
8db569
|
151 |
|
M |
152 |
ts_bool poly_free(ts_poly *poly){ |
|
153 |
|
|
154 |
if (poly->grafted_vtx!=NULL){ |
|
155 |
poly->grafted_vtx->grafted_poly=NULL; |
|
156 |
} |
|
157 |
vtx_list_free(poly->vlist); |
|
158 |
bond_list_free(poly->blist); |
|
159 |
free(poly); |
|
160 |
|
|
161 |
return TS_SUCCESS; |
|
162 |
} |
|
163 |
|
|
164 |
ts_bool poly_list_free(ts_poly_list *poly_list){ |
|
165 |
ts_uint i; |
|
166 |
|
|
167 |
for(i=0;i<poly_list->n;i++){ |
|
168 |
poly_free(poly_list->poly[i]); |
|
169 |
} |
|
170 |
free(poly_list->poly); |
|
171 |
free(poly_list); |
|
172 |
|
|
173 |
return TS_SUCCESS; |
|
174 |
} |