Trisurf Monte Carlo simulator
Samo Penic
2019-03-08 85898e259e6e2075a7f755583690024a63e9bb2b
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
46
47
#include <stdlib.h>
#include "general.h"
#include "vertex.h"
#include "cell.h"
#include <math.h>
char plugin_name[] = "Plane confimenent";
char plugin_description[]= "Confines vesicle between two planes d/2 above z=0 and d/2 below z=0. The plates squeeze vesicle with some predefined force.";
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;
//    details->data = (void *)calloc(1,sizeof(ts_double));
    return details;    
}
 
ts_bool vm_hard_constraint(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *ovtx){
 
// plane confinement check whether the new position of vertex will be out of bounds
    if(vesicle->tape->plane_confinement_switch){
        if(vtx->z>vesicle->confinement_plane.z_max || vtx->z<vesicle->confinement_plane.z_min){
        return TS_FAIL;
        }
    }
    return TS_SUCCESS;
}
 
 
ts_double vm_energy_after_execute(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *backupvtx){
// plane confinement energy due to compressing force
    ts_double delta_energy=0;
    if(vesicle->tape->plane_confinement_switch){
        if(vesicle->confinement_plane.force_switch){
            //substract old energy
            if(abs(vesicle->tape->plane_d/2.0-vesicle->confinement_plane.z_max)>1e-10) {
                delta_energy-=vesicle->tape->plane_F / pow(vesicle->confinement_plane.z_max-backupvtx[0].z,2);
                delta_energy+=vesicle->tape->plane_F / pow(vesicle->confinement_plane.z_max-vtx->z,2);
            }
            if(abs(-vesicle->tape->plane_d/2.0-vesicle->confinement_plane.z_min)>1e-10) {
                delta_energy-=vesicle->tape->plane_F / pow(vesicle->confinement_plane.z_min-backupvtx[0].z,2);
                delta_energy+=vesicle->tape->plane_F / pow(vesicle->confinement_plane.z_min-vtx->z,2);
            }
        }
    }
    return delta_energy;
 
}