From bcf4557ddd61890f130247430267feac5b05c5b7 Mon Sep 17 00:00:00 2001 From: mihaf <miha.fosnaric@gmail.com> Date: Fri, 21 Mar 2014 09:39:35 +0000 Subject: [PATCH] Filament inside the vesicle added and debugged. Testing time... --- src/main.c | 1 src/poly.c | 15 ++++ src/io.c | 97 ++++++++++++++++++++++++++++++++ src/tape | 6 +- src/bond.c | 6 +- src/initial_distribution.c | 25 +++++++- src/poly.h | 3 + 7 files changed, 141 insertions(+), 12 deletions(-) diff --git a/src/bond.c b/src/bond.c index 4d11c97..ce255ca 100644 --- a/src/bond.c +++ b/src/bond.c @@ -38,9 +38,9 @@ ts_bool bond_vector(ts_bond *bond){ - bond->x=bond->vtx1->x-bond->vtx2->x; - bond->y=bond->vtx1->y-bond->vtx2->y; - bond->z=bond->vtx1->z-bond->vtx2->z; + bond->x = bond->vtx1->x - bond->vtx2->x; + bond->y = bond->vtx1->y - bond->vtx2->y; + bond->z = bond->vtx1->z - bond->vtx2->z; return TS_SUCCESS; } diff --git a/src/initial_distribution.c b/src/initial_distribution.c index c7eed90..3c27e55 100644 --- a/src/initial_distribution.c +++ b/src/initial_distribution.c @@ -37,22 +37,39 @@ ts_vesicle *create_vesicle_from_tape(ts_tape *tape){ ts_vesicle *vesicle; + ts_vertex *vtx; + vesicle=initial_distribution_dipyramid(tape->nshell,tape->ncxmax,tape->ncymax,tape->nczmax,tape->stepsize); // Nucleus: vesicle->R_nucleus=tape->R_nucleus; + //Initialize grafted polymers (brush): vesicle->poly_list=init_poly_list(tape->npoly,tape->nmono, vesicle->vlist, vesicle); vesicle->spring_constant=tape->kspring; poly_assign_spring_const(vesicle); + //Initialize filaments (polymers inside the vesicle): vesicle->filament_list=init_poly_list(tape->nfil,tape->nfono, NULL, vesicle); -ts_uint i,j; - for(i=0;i<vesicle->filament_list->n;i++){ - for(j=0;j<vesicle->filament_list->poly[i]->vlist->n;j++){ + poly_assign_filament_xi(vesicle,tape); - fprintf(stderr,"%e %e %e\n", vesicle->filament_list->poly[i]->vlist->vtx[j]->x,vesicle->filament_list->poly[i]->vlist->vtx[j]->y, vesicle->filament_list->poly[i]->vlist->vtx[j]->z ); + ts_uint i,j; + for(i=0;i<vesicle->filament_list->n;i++){ + for(j=0;j<vesicle->filament_list->poly[i]->blist->n;j++){ + bond_vector(vesicle->filament_list->poly[i]->blist->bond[j]); + vesicle->filament_list->poly[i]->blist->bond[j]->bond_length = sqrt(vtx_distance_sq(vesicle->filament_list->poly[i]->blist->bond[j]->vtx1,vesicle->filament_list->poly[i]->blist->bond[j]->vtx2)); + } } + + for(i=0;i<vesicle->filament_list->n;i++){ + for(j=0;j<vesicle->filament_list->poly[i]->vlist->n;j++){ + vtx = vesicle->filament_list->poly[i]->vlist->vtx[j]; + if(vtx->bond_no == 2){ + vtx->energy = -(vtx->bond[0]->x*vtx->bond[1]->x + vtx->bond[0]->y*vtx->bond[1]->y + vtx->bond[0]->z*vtx->bond[1]->z)/vtx->bond[0]->bond_length/vtx->bond[1]->bond_length; + } + } } + + // vesicle->spring_constant=tape->kspring; // poly_assign_spring_const(vesicle); diff --git a/src/io.c b/src/io.c index a47bd9a..b222081 100644 --- a/src/io.c +++ b/src/io.c @@ -36,6 +36,8 @@ fwrite(vesicle->clist, sizeof(ts_cell_list),1,fh); /* dump poly list */ fwrite(vesicle->poly_list, sizeof(ts_poly_list),1,fh); + /* dump filament list */ + fwrite(vesicle->filament_list, sizeof(ts_poly_list),1,fh); /* level 1 complete */ /*dump vertices*/ @@ -118,6 +120,43 @@ } } + + /*dump filamentes grandes svinjas */ + for(i=0;i<vesicle->filament_list->n;i++){ + fwrite(vesicle->filament_list->poly[i],sizeof(ts_poly),1,fh); + fwrite(vesicle->filament_list->poly[i]->vlist,sizeof(ts_vertex_list),1,fh); + fwrite(vesicle->filament_list->poly[i]->blist,sizeof(ts_bond_list),1,fh); + } + + /* dump filamentes vertex(monomer) list*/ + for(i=0;i<vesicle->filament_list->n;i++){ + for(j=0;j<vesicle->filament_list->poly[i]->vlist->n;j++){ + fwrite(vesicle->filament_list->poly[i]->vlist->vtx[j],sizeof(ts_vertex),1,fh); + /* dump offset for neigh and bond */ + for(k=0;k<vesicle->filament_list->poly[i]->vlist->vtx[j]->neigh_no;k++){ + // off=(ts_ulong)(vesicle->poly_list->poly[i]->vlist->vtx[j]->neigh[k]-vesicle->poly_list->poly[i]->vlist->vtx[0]); + fwrite(&vesicle->filament_list->poly[i]->vlist->vtx[j]->neigh[k]->idx,sizeof(ts_uint),1,fh); + } + for(k=0;k<vesicle->filament_list->poly[i]->vlist->vtx[j]->bond_no;k++){ + //off=(ts_ulong)(vesicle->poly_list->poly[i]->vlist->vtx[j]->bond[k]-vesicle->poly_list->poly[i]->blist->bond[0]); + fwrite(&vesicle->filament_list->poly[i]->vlist->vtx[j]->bond[k]->idx,sizeof(ts_uint),1,fh); + } + } + } + /* dump poly bonds between monomers list*/ + for(i=0;i<vesicle->filament_list->n;i++){ + for(j=0;j<vesicle->filament_list->poly[i]->blist->n;j++){ + fwrite(vesicle->filament_list->poly[i]->blist->bond[j],sizeof(ts_bond),1,fh); + /* dump vtx1 and vtx2 offsets */ + //off=(ts_ulong)(vesicle->poly_list->poly[i]->blist->bond[j]->vtx1-vesicle->poly_list->poly[i]->vlist->vtx[0]); + fwrite(&vesicle->filament_list->poly[i]->blist->bond[j]->vtx1->idx,sizeof(ts_uint),1,fh); +// off=(ts_ulong)(vesicle->poly_list->poly[i]->blist->bond[j]->vtx2-vesicle->poly_list->poly[i]->vlist->vtx[0]); + fwrite(&vesicle->filament_list->poly[i]->blist->bond[j]->vtx2->idx,sizeof(ts_uint),1,fh); + } + } + + + /* pointer offsets for fixing the restored pointers */ /* need pointers for vlist->vtx @@ -180,6 +219,9 @@ /* restore poly list */ vesicle->poly_list=(ts_poly_list *)calloc(1,sizeof(ts_poly_list)); retval=fread(vesicle->poly_list, sizeof(ts_poly_list),1,fh); + /* restore filament list */ + vesicle->filament_list=(ts_poly_list *)calloc(1,sizeof(ts_poly_list)); + retval=fread(vesicle->filament_list, sizeof(ts_poly_list),1,fh); /* level 1 complete */ /* prerequisity. Bonds must be malloced before vertexes are recreated */ @@ -322,6 +364,61 @@ } } + /*restore filaments */ + vesicle->filament_list->poly = (ts_poly **)calloc(vesicle->filament_list->n,sizeof(ts_poly *)); + for(i=0;i<vesicle->filament_list->n;i++){ + vesicle->filament_list->poly[i]=(ts_poly *)calloc(1,sizeof(ts_poly)); + retval=fread(vesicle->filament_list->poly[i],sizeof(ts_poly),1,fh); + vesicle->filament_list->poly[i]->vlist=(ts_vertex_list *)calloc(1,sizeof(ts_vertex_list)); + retval=fread(vesicle->filament_list->poly[i]->vlist,sizeof(ts_vertex_list),1,fh); + vesicle->filament_list->poly[i]->blist=(ts_bond_list *)calloc(1,sizeof(ts_bond_list)); + retval=fread(vesicle->filament_list->poly[i]->blist,sizeof(ts_bond_list),1,fh); + /* initialize adress space for pointers that will hold specific vertices (monomers) and bonds */ + vesicle->filament_list->poly[i]->vlist->vtx=(ts_vertex **)calloc(vesicle->filament_list->poly[i]->vlist->n,sizeof(ts_vertex *)); + vesicle->filament_list->poly[i]->blist->bond=(ts_bond **)calloc(vesicle->filament_list->poly[i]->blist->n,sizeof(ts_bond *)); + for(j=0;j<vesicle->filament_list->poly[i]->vlist->n;j++){ + vesicle->filament_list->poly[i]->vlist->vtx[j]=(ts_vertex *)malloc(sizeof(ts_vertex)); + } + for(j=0;j<vesicle->filament_list->poly[i]->blist->n;j++){ + vesicle->filament_list->poly[i]->blist->bond[j]=(ts_bond *)malloc(sizeof(ts_bond)); + } + + } + + + /* restore poly vertex(monomer) list*/ + for(i=0;i<vesicle->filament_list->n;i++){ + for(j=0;j<vesicle->filament_list->poly[i]->vlist->n;j++){ + retval=fread(vesicle->filament_list->poly[i]->vlist->vtx[j],sizeof(ts_vertex),1,fh); + + /* restore neigh and bonds */ + vesicle->filament_list->poly[i]->vlist->vtx[j]->neigh=(ts_vertex **)calloc(vesicle->filament_list->poly[i]->vlist->vtx[j]->neigh_no, sizeof(ts_vertex *)); + for(k=0;k<vesicle->filament_list->poly[i]->vlist->vtx[j]->neigh_no;k++){ + retval=fread(&idx,sizeof(ts_uint),1,fh); + vesicle->filament_list->poly[i]->vlist->vtx[j]->neigh[k]=vesicle->filament_list->poly[i]->vlist->vtx[idx]; + } + vesicle->filament_list->poly[i]->vlist->vtx[j]->bond=(ts_bond **)calloc(vesicle->filament_list->poly[i]->vlist->vtx[j]->bond_no, sizeof(ts_bond *)); + for(k=0;k<vesicle->filament_list->poly[i]->vlist->vtx[j]->bond_no;k++){ + retval=fread(&idx,sizeof(ts_uint),1,fh); + vesicle->filament_list->poly[i]->vlist->vtx[j]->bond[k]=vesicle->filament_list->poly[i]->blist->bond[idx]; + } + + } + } + + /* restore poly bonds between monomers list*/ + for(i=0;i<vesicle->filament_list->n;i++){ + for(j=0;j<vesicle->filament_list->poly[i]->blist->n;j++){ + // vesicle->poly_list->poly[i]->blist->bond[j]=(ts_bond *)malloc(sizeof(ts_bond)); + retval=fread(vesicle->filament_list->poly[i]->blist->bond[j],sizeof(ts_bond),1,fh); + /* restore vtx1 and vtx2 */ + retval=fread(&idx,sizeof(ts_uint),1,fh); + vesicle->filament_list->poly[i]->blist->bond[j]->vtx1=vesicle->filament_list->poly[i]->vlist->vtx[idx]; + retval=fread(&idx,sizeof(ts_uint),1,fh); + vesicle->filament_list->poly[i]->blist->bond[j]->vtx2=vesicle->filament_list->poly[i]->vlist->vtx[idx]; + } + } + // recreating space for cells // vesicle->clist=(ts_cell_list *)malloc(sizeof(ts_cell_list)); retval=fread(vesicle->clist, sizeof(ts_cell_list), 1,fh); diff --git a/src/main.c b/src/main.c index 1b97f10..290142e 100644 --- a/src/main.c +++ b/src/main.c @@ -47,6 +47,7 @@ vtx_set_global_values(vesicle); vesicle->pressure=tape->pressure; vesicle->dmax=tape->dmax*tape->dmax; + poly_assign_filament_xi(vesicle,tape); if(command_line_args.reset_iteration_count) start_iteration=tape->inititer+1; else start_iteration++; diff --git a/src/poly.c b/src/poly.c index d99d2ad..c1dc0f6 100644 --- a/src/poly.c +++ b/src/poly.c @@ -6,6 +6,17 @@ #include<math.h> #include"energy.h" +ts_bool poly_assign_filament_xi(ts_vesicle *vesicle, ts_tape *tape){ + ts_uint i; + + for(i=0;i<vesicle->filament_list->n;i++){ + vesicle->filament_list->poly[i]->k = tape->xi; + } + + return TS_SUCCESS; +} + + ts_bool poly_assign_spring_const(ts_vesicle *vesicle){ ts_uint i; @@ -97,8 +108,8 @@ 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; + dphi = 2.0*asin(1.0/2.0/vesicle->R_nucleus)*1.01; + dh = dphi/2.0/M_PI*1.01; 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; diff --git a/src/poly.h b/src/poly.h index 68c83c1..26dd444 100644 --- a/src/poly.h +++ b/src/poly.h @@ -1,5 +1,6 @@ #ifndef _POLY_H #define _POLY_H +#include"io.h" #include"general.h" @@ -13,4 +14,6 @@ ts_bool poly_assign_spring_const(ts_vesicle *vesicle); +ts_bool poly_assign_filament_xi(ts_vesicle *vesicle, ts_tape *tape); + #endif diff --git a/src/tape b/src/tape index 751b9e6..5d93639 100644 --- a/src/tape +++ b/src/tape @@ -26,9 +26,9 @@ # nfil is a number of filaments inside the vesicle nfil=1 # nfono is a number of monomers in each filament -nfono=300 +nfono=30 # Persistence lenght of the filaments (in units l_min) -xi=10 +xi=0 ####### Nucleus (inside the vesicle) ########### # Radius of an impenetrable hard sphere inside the vesicle @@ -46,7 +46,7 @@ #how many initial mcsweeps*inititer MC sweeps before recording to disk? inititer=0 #how many records do you want on the disk iteration are there in a run? -iterations=300 +iterations=30 #shut up if we are using cluster!!! -- Gitblit v1.9.3