commit | author | age
|
4df6ed
|
1 |
#include <stdlib.h> |
SP |
2 |
#include<math.h> |
|
3 |
#include "general.h" |
2c4278
|
4 |
#include "energy.h" |
SP |
5 |
|
4df6ed
|
6 |
char plugin_name[] = "Stretching energy"; |
SP |
7 |
char plugin_description[]= "Plugin adds stretching energy to Monte Carlo steps"; |
|
8 |
char plugin_author[] = "SAMO PENIC"; |
|
9 |
|
|
10 |
typedef struct { |
|
11 |
ts_double dstretchenergy; |
|
12 |
} plugin_data; |
|
13 |
|
|
14 |
ts_plugin_details *init (){ |
|
15 |
ts_plugin_details *details=(ts_plugin_details *)calloc(1,sizeof(ts_plugin_details)); |
|
16 |
details->name = plugin_name; |
|
17 |
details->data = (plugin_data *)calloc(1,sizeof(plugin_data)); //storing data |
|
18 |
return details; |
|
19 |
} |
|
20 |
|
|
21 |
void vm_energy_before_prepare(ts_vesicle *vesicle, ts_vertex *vtx){ |
|
22 |
if(vesicle->tape->stretchswitch==1){ |
|
23 |
plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data; |
|
24 |
ts_uint i; |
|
25 |
data->dstretchenergy=0.0; |
|
26 |
for(i=0;i<vtx->tristar_no;i++) data->dstretchenergy-=vtx->tristar[i]->energy; |
|
27 |
} |
|
28 |
} |
|
29 |
|
|
30 |
ts_double vm_energy_after_execute(ts_vesicle *vesicle, ts_vertex *vtx){ |
|
31 |
//stretching energy 2 of 3 |
|
32 |
if(vesicle->tape->stretchswitch==1){ |
|
33 |
plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data; |
|
34 |
ts_uint i; |
|
35 |
for(i=0;i<vtx->tristar_no;i++){ |
|
36 |
stretchenergy(vesicle, vtx->tristar[i]); |
|
37 |
data->dstretchenergy+=vtx->tristar[i]->energy; |
|
38 |
} |
2c4278
|
39 |
return data->dstretchenergy; |
4df6ed
|
40 |
} |
2c4278
|
41 |
return 0.0; |
4df6ed
|
42 |
} |
SP |
43 |
|
|
44 |
void vm_new_state_rejected(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *old_vtx){ |
|
45 |
//stretching energy 3 of 3 |
|
46 |
if(vesicle->tape->stretchswitch==1){ |
|
47 |
ts_uint i; |
|
48 |
for(i=0;i<vtx->tristar_no;i++){ |
|
49 |
stretchenergy(vesicle,vtx->tristar[i]); |
|
50 |
} |
|
51 |
} |
|
52 |
} |