Trisurf Monte Carlo simulator
Samo Penic
2012-06-14 c9d07c3cae70179c3045b92b7dc04f0d2ebcfb89
Lastly before debugging. We calculated the area of each triangle, volume function has been changed and data structure adapted for area calculation
4 files modified
39 ■■■■ changed files
src/general.h 1 ●●●● patch | view | raw | blame | history
src/sh.c 11 ●●●●● patch | view | raw | blame | history
src/triangle.c 12 ●●●●● patch | view | raw | blame | history
src/vesicle.c 15 ●●●● patch | view | raw | blame | history
src/general.h
@@ -187,6 +187,7 @@
    ts_double ynorm;
    ts_double znorm;
    ts_double area; // firstly needed for sh.c
    ts_double volume; // firstly needed for sh.c
};
typedef struct ts_triangle ts_triangle;
src/sh.c
@@ -143,7 +143,16 @@
}
/*Computes Y(l,m,theta,fi) (Miha's definition that is different from common definition for  factor srqt(1/(2*pi)) */
/** @brief: Computes Y(l,m,theta,fi)
 *
 * Function calculates Y^l_m for vertex with given (\theta, \fi) coordinates in
 * spherical coordinate system.
 * @param l is an ts_int argument.
 * @param m is an ts_int argument.
 * @param theta is ts_double argument.
 * @param fi is a ts_double argument.
 *
 * (Miha's definition that is different from common definition for  factor srqt(1/(2*pi)) */
ts_double shY(ts_int l,ts_int m,ts_double theta,ts_double fi){
    ts_double fac1, fac2, K;
    int i;
src/triangle.c
@@ -219,6 +219,18 @@
    tria->xnorm=tria->xnorm/xden;
    tria->ynorm=tria->ynorm/xden;
    tria->znorm=tria->znorm/xden;    
/*  Here it is an excellent point to recalculate volume of the triangle and
 *  store it into datastructure. Volume is required at least by constant volume
 *  calculation of vertex move and bondflip and spherical harmonics. */
    tria->volume=(tria->vertex[0]->x+ tria->vertex[1]->x + tria->vertex[2]->x) * tria->xnorm +
       (tria->vertex[0]->y+ tria->vertex[1]->y + tria->vertex[2]->y) * tria->ynorm +
    (tria->vertex[0]->z+ tria->vertex[1]->z + tria->vertex[2]->z) * tria->znorm;
    tria->volume=-xden*tria->volume/18.0;
/*  Also, area can be calculated in each triangle */
    tria->area=xden/2;
    return TS_SUCCESS;
}
src/vesicle.c
@@ -37,20 +37,21 @@
    return TS_SUCCESS;
}
/* @brief Function makes a sum of partial volumes of each triangle. Volumes of
 *
 * Partial volumes are calculated when we calculate normals of triangles. It is
 * relatively easy to calculate the volume of vesicle if we take into account
 * that the volume of the whole vertex is simply sum of all partial volumes of
 * all the triangles.
 */
ts_bool vesicle_volume(ts_vesicle *vesicle){
    ts_double volume;
    ts_double vol;
    ts_uint i;
    ts_triangle **tria=vesicle->tlist->tria;
    volume=0;
    for(i=0; i<vesicle->tlist->n;i++){
        vol=(tria[i]->vertex[0]->x+ tria[i]->vertex[1]->x + tria[i]->vertex[2]->x) * tria[i]->xnorm +
       (tria[i]->vertex[0]->y+ tria[i]->vertex[1]->y + tria[i]->vertex[2]->y) * tria[i]->ynorm +
    (tria[i]->vertex[0]->z+ tria[i]->vertex[1]->z + tria[i]->vertex[2]->z) *
tria[i]->znorm;
    volume=volume-vol/18.0;
    volume=volume+tria[i]->volume;
    }
    vesicle->volume=volume;
    return TS_SUCCESS;
}