#include #include #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;itristar_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;itristar_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;itristar_no;i++){ stretchenergy(vesicle,vtx->tristar[i]); } } }