Trisurf Monte Carlo simulator
mihaf
2013-12-03 2bdec5571ad2582dcc492d03148620b1b0c618ce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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;
}