Trisurf Monte Carlo simulator
Samo Penic
2019-03-09 60c2b879f26c5f008af0df7d7f159d33077225ac
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
48
49
50
51
52
#include <stdlib.h>
#include<math.h>
#include "general.h"
#include "energy.h"
 
char plugin_name[] = "Stretching energy";
char plugin_description[]= "Plugin adds stretching energy to Monte Carlo steps";
char plugin_author[] = "SAMO PENIC";
 
typedef struct {
    ts_double dstretchenergy;
} plugin_data;
 
ts_plugin_details *init (){
    ts_plugin_details *details=(ts_plugin_details *)calloc(1,sizeof(ts_plugin_details));
    details->name = plugin_name;
    details->data = (plugin_data *)calloc(1,sizeof(plugin_data)); //storing data
    return details;    
}
 
void vm_energy_before_prepare(ts_vesicle *vesicle, ts_vertex *vtx){        
    if(vesicle->tape->stretchswitch==1){
        plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data;
        ts_uint i;
        data->dstretchenergy=0.0;
        for(i=0;i<vtx->tristar_no;i++) data->dstretchenergy-=vtx->tristar[i]->energy;
    }
}
 
ts_double vm_energy_after_execute(ts_vesicle *vesicle, ts_vertex *vtx){
    //stretching energy 2 of 3
    if(vesicle->tape->stretchswitch==1){
        plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data;
        ts_uint i;
        for(i=0;i<vtx->tristar_no;i++){ 
            stretchenergy(vesicle, vtx->tristar[i]);
            data->dstretchenergy+=vtx->tristar[i]->energy;
            }
        return data->dstretchenergy;
    }
    return 0.0;
}
 
void vm_new_state_rejected(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *old_vtx){
    //stretching energy 3 of 3
    if(vesicle->tape->stretchswitch==1){
        ts_uint i;
        for(i=0;i<vtx->tristar_no;i++){ 
            stretchenergy(vesicle,vtx->tristar[i]);
            }
    }
}