Trisurf Monte Carlo simulator
Samo Penic
2019-03-08 5e08f27fac51e8f7261cd4484ab8878befac8fe1
commit | author | age
5e08f2 1 #include <stdlib.h>
SP 2 #include<math.h>
3
4 #include "general.h"
5 #include "vertex.h"
6 #include "cell.h"
7 #include "vesicle.h"
8 #include "frame.h"
9 char plugin_name[] = "Constant area";
10 char plugin_description[]= "Plugin that enables constant area of the vesicle.";
11 char plugin_author[] = "SAMO PENIC";
12
13
14 typedef struct {
15     ts_double darea;
16     ts_double A0;
17     ts_double epsarea;
18 } plugin_data;
19
20
21 ts_plugin_details *init (){
22     ts_plugin_details *details=(ts_plugin_details *)calloc(1,sizeof(ts_plugin_details));
23     details->name = plugin_name;
24     details->data = (plugin_data *)calloc(1,sizeof(plugin_data)); //storing data
25     return details;    
26 }
27
28
29 ts_vesicle *after_vesicle_init(ts_vesicle *vesicle){
30     plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data;
31     ts_fprintf(stdout,"area volume initialized\n");
32     centermass(vesicle);
33     cell_occupation(vesicle);
34     vesicle_area(vesicle);
35     data->A0=vesicle->area;
36     data->epsarea=data->A0/(ts_double)vesicle->tlist->n;
37     return vesicle;
38 }
39
40
41 void vm_energy_before_prepare(ts_vesicle *vesicle, ts_vertex *vtx){    
42     if(vesicle->tape->constareaswitch>0){
43         plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data;
44         data->darea=0;
45         ts_uint i;
46         for(i=0;i<vtx->tristar_no;i++) data->darea-=vtx->tristar[i]->area;
47     
48     }
49 }
50
51 ts_double vm_before_montecarlo_constraint(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *old_vtx){
52     if(vesicle->tape->constareaswitch>0){
53         plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data;
54         ts_uint i;
55         for(i=0;i<vtx->tristar_no;i++) data->darea+=vtx->tristar[i]->area;
56             if(fabs(vesicle->area+data->darea-data->A0)>data->epsarea) return TS_FAIL;
57     }
58     return TS_SUCCESS;
59 }
60
61
62 void vm_new_state_accepted(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *old_vtx){
63     if(vesicle->tape->constareaswitch >0){
64         plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data;
65         vesicle->area+=data->darea;
66     }
67 }