Trisurf Monte Carlo simulator
Samo Penic
2019-03-09 4df6ed05246cf8bc9fe0cb0c8766ebc368d2f512
src/plugins/plane_confinement.c
@@ -2,6 +2,7 @@
#include "general.h"
#include "vertex.h"
#include "cell.h"
#include <math.h>
char plugin_name[] = "Plane confimenent";
char plugin_description[]= "Confines vesicle between two planes d/2 above z=0 and d/2 below z=0. The plates squeeze vesicle with some predefined force.";
char plugin_author[] = "SAMO PENIC";
@@ -9,6 +10,7 @@
ts_plugin_details *init (){
   ts_plugin_details *details=(ts_plugin_details *)calloc(1,sizeof(ts_plugin_details));
   details->name = plugin_name;
//   details->data = (void *)calloc(1,sizeof(ts_double));
   return details;   
}
@@ -20,7 +22,26 @@
      return TS_FAIL;
      }
   }
   return TS_SUCCESS;
}
ts_double vm_energy_after_execute(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *backupvtx){
// plane confinement energy due to compressing force
   ts_double delta_energy=0;
   if(vesicle->tape->plane_confinement_switch){
      if(vesicle->confinement_plane.force_switch){
         //substract old energy
         if(abs(vesicle->tape->plane_d/2.0-vesicle->confinement_plane.z_max)>1e-10) {
            delta_energy-=vesicle->tape->plane_F / pow(vesicle->confinement_plane.z_max-backupvtx[0].z,2);
            delta_energy+=vesicle->tape->plane_F / pow(vesicle->confinement_plane.z_max-vtx->z,2);
         }
         if(abs(-vesicle->tape->plane_d/2.0-vesicle->confinement_plane.z_min)>1e-10) {
            delta_energy-=vesicle->tape->plane_F / pow(vesicle->confinement_plane.z_min-backupvtx[0].z,2);
            delta_energy+=vesicle->tape->plane_F / pow(vesicle->confinement_plane.z_min-vtx->z,2);
         }
      }
   }
   return delta_energy;
}