From 85898e259e6e2075a7f755583690024a63e9bb2b Mon Sep 17 00:00:00 2001 From: Samo Penic <samo.penic@gmail.com> Date: Fri, 08 Mar 2019 20:37:07 +0000 Subject: [PATCH] Plane confinement plugin almost done :) --- src/plugins/plane_confinement.c | 23 ++++++++++++++++++++++- src/plugins/pressure.c | 2 +- src/general.h | 2 +- src/vertexmove.c | 17 +---------------- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/general.h b/src/general.h index 90cf29c..ab0c257 100644 --- a/src/general.h +++ b/src/general.h @@ -312,7 +312,7 @@ void (*vm_energy_before_prepare)(void *vesicle, ts_vertex *vtx); ts_double (*vm_energy_before_execute)(void *vesicle, ts_vertex *vtx); ts_double (*vm_energy_after_prepare)(void *vesicle, ts_vertex *vtx); - ts_double (*vm_energy_after_execute)(void *vesicle, ts_vertex *vtx); + ts_double (*vm_energy_after_execute)(void *vesicle, ts_vertex *vtx, ts_vertex *backup_vertices); ts_double (*vm_before_montecarlo_constraint)(void *vesicle, ts_vertex *vtx, ts_vertex *old_vtx); ts_double (*vm_new_state_accepted)(void *vesicle, ts_vertex *vtx, ts_vertex *old_vtx); ts_double (*vm_new_state_rejected)(void *vesicle, ts_vertex *vtx, ts_vertex *old_vtx); diff --git a/src/plugins/plane_confinement.c b/src/plugins/plane_confinement.c index 6cf052c..b290052 100644 --- a/src/plugins/plane_confinement.c +++ b/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; + +} diff --git a/src/plugins/pressure.c b/src/plugins/pressure.c index fdcd919..39676db 100644 --- a/src/plugins/pressure.c +++ b/src/plugins/pressure.c @@ -22,7 +22,7 @@ } } -ts_double vm_energy_after_execute(ts_vesicle *vesicle, ts_vertex *vtx){ +ts_double vm_energy_after_execute(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *backup_vertices){ ts_double delta_energy=0; if(vesicle->pswitch == 1){ ts_double *dvol=(ts_double *)vesicle->plist->pointer->plugin->details->data; diff --git a/src/vertexmove.c b/src/vertexmove.c index 462959d..2b08dc8 100644 --- a/src/vertexmove.c +++ b/src/vertexmove.c @@ -85,7 +85,7 @@ vesicle->plist->pointer=vesicle->plist->chain->vm_energy_after_execute; while(vesicle->plist->pointer!=NULL){ - delta_energy+=vesicle->plist->pointer->plugin->function->vm_energy_after_execute(vesicle, vtx); + delta_energy+=vesicle->plist->pointer->plugin->function->vm_energy_after_execute(vesicle, vtx, backupvtx); vesicle->plist->pointer=vesicle->plist->pointer->next; } @@ -110,21 +110,6 @@ pow(sqrt(vtx_distance_sq(&backupvtx[0], vtx->grafted_poly->vlist->vtx[0])-1),2)) *vtx->grafted_poly->k; } */ - -// plane confinement energy due to compressing force - 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); - } - } - } /* Entry point for plugin vm_before_montecarlo_constraint() function */ -- Gitblit v1.9.3