Trisurf Monte Carlo simulator
Samo Penic
2019-02-28 b5cd8cc72380e9ca576ec942753391df85a2a436
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
36
37
38
39
40
41
42
43
44
45
#include "plugins.h"
#include <stdlib.h>
#include "general.h"
#include "vertex.h"
#include "cell.h"
char plugin_name[] = "Default hard constraints for vertex move";
char plugin_description[]= "Checks proximity with neighbors, vertices in neighboring cells and with foreign vertices that may be in vicinity";
char plugin_author[] = "SAMO PENIC";
 
ts_plugin_details *init (){
    ts_plugin_details *details=(ts_plugin_details *)calloc(1,sizeof(ts_plugin_details));
    details->name = plugin_name;
    return details;    
}
 
ts_bool vm_hard_constraint(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *ovtx){
    ts_uint i;
    ts_uint cellidx;
    ts_double dist;
    ts_bool retval;
//distance with neighbours check
    for(i=0;i<vtx->neigh_no;i++){
        dist=vtx_distance_sq(vtx,vtx->neigh[i]);
        if(dist<1.0 || dist>vesicle->dmax) {
            return TS_FAIL;
        }
    }
// Distance with grafted poly-vertex check:    
    if(vtx->grafted_poly!=NULL){
        dist=vtx_distance_sq(vtx,vtx->grafted_poly->vlist->vtx[0]);
        if(dist<1.0 || dist>vesicle->dmax) {
        return TS_FAIL;
        }
    }
 
//self avoidance check with distant vertices
    cellidx=vertex_self_avoidance(vesicle, vtx);
    //check occupation number
    retval=cell_occupation_number_and_internal_proximity(vesicle->clist,cellidx,vtx);
        if(retval==TS_FAIL){
           return TS_FAIL;
        } 
   
    return TS_SUCCESS;
}