#include <stdlib.h>
|
#include<math.h>
|
|
#include "general.h"
|
#include "vertex.h"
|
#include "cell.h"
|
#include "vesicle.h"
|
#include "frame.h"
|
char plugin_name[] = "Constant volume";
|
char plugin_description[]= "Plugin that enables constant volume of the vesicle.";
|
char plugin_author[] = "SAMO PENIC";
|
|
|
typedef struct {
|
ts_double dvol;
|
ts_double V0;
|
ts_double epsvol;
|
} 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;
|
}
|
|
|
ts_vesicle *after_vesicle_init(ts_vesicle *vesicle){
|
plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data;
|
ts_fprintf(stdout,"constant volume initialized\n");
|
|
centermass(vesicle);
|
cell_occupation(vesicle);
|
vesicle_volume(vesicle); //needed for constant volume at this moment
|
|
data->V0=vesicle->volume;
|
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);
|
return vesicle;
|
}
|
|
|
void vm_energy_before_prepare(ts_vesicle *vesicle, ts_vertex *vtx){
|
if(vesicle->tape->constvolswitch>0){
|
plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data;
|
data->dvol=0;
|
ts_uint i;
|
for(i=0;i<vtx->tristar_no;i++) data->dvol-=vtx->tristar[i]->volume;
|
}
|
}
|
|
ts_double vm_before_montecarlo_constraint(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *old_vtx){
|
if(vesicle->tape->constvolswitch >0){
|
plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data;
|
ts_uint i;
|
for(i=0;i<vtx->tristar_no;i++) data->dvol+=vtx->tristar[i]->volume;
|
if(fabs(vesicle->volume+data->dvol-data->V0)>data->epsvol) return TS_FAIL;
|
}
|
return TS_SUCCESS;
|
}
|
|
|
void vm_new_state_accepted(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *old_vtx){
|
if(vesicle->tape->constvolswitch >0){
|
plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data;
|
vesicle->volume+=data->dvol;
|
}
|
}
|