commit | author | age
|
77a2c7
|
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 volume"; |
|
10 |
char plugin_description[]= "Plugin that enables constant volume of the vesicle."; |
|
11 |
char plugin_author[] = "SAMO PENIC"; |
|
12 |
|
|
13 |
|
|
14 |
typedef struct { |
|
15 |
ts_double dvol; |
|
16 |
ts_double V0; |
|
17 |
ts_double epsvol; |
|
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,"constant volume initialized\n"); |
|
32 |
|
|
33 |
centermass(vesicle); |
|
34 |
cell_occupation(vesicle); |
|
35 |
vesicle_volume(vesicle); //needed for constant volume at this moment |
|
36 |
|
|
37 |
data->V0=vesicle->volume; |
|
38 |
data->epsvol=4.0*sqrt(2.0*M_PI)/pow(3.0,3.0/4.0)*data->V0/pow(vesicle->tlist->n,3.0/2.0); |
|
39 |
return vesicle; |
|
40 |
} |
|
41 |
|
|
42 |
|
|
43 |
void vm_energy_before_prepare(ts_vesicle *vesicle, ts_vertex *vtx){ |
|
44 |
if(vesicle->tape->constvolswitch>0){ |
|
45 |
plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data; |
|
46 |
data->dvol=0; |
|
47 |
ts_uint i; |
|
48 |
for(i=0;i<vtx->tristar_no;i++) data->dvol-=vtx->tristar[i]->volume; |
|
49 |
} |
|
50 |
} |
|
51 |
|
|
52 |
ts_double vm_before_montecarlo_constraint(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *old_vtx){ |
|
53 |
if(vesicle->tape->constvolswitch >0){ |
|
54 |
plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data; |
|
55 |
ts_uint i; |
|
56 |
for(i=0;i<vtx->tristar_no;i++) data->dvol+=vtx->tristar[i]->volume; |
|
57 |
if(fabs(vesicle->volume+data->dvol-data->V0)>data->epsvol) return TS_FAIL; |
|
58 |
} |
|
59 |
return TS_SUCCESS; |
2afc2f
|
60 |
} |
77a2c7
|
61 |
|
SP |
62 |
|
2afc2f
|
63 |
void vm_new_state_accepted(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *old_vtx){ |
SP |
64 |
if(vesicle->tape->constvolswitch >0){ |
|
65 |
plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data; |
|
66 |
vesicle->volume+=data->dvol; |
|
67 |
} |
77a2c7
|
68 |
} |