From 250de4d124ea8dc4929a9c334d94fc51018fa53c Mon Sep 17 00:00:00 2001
From: Samo Penic <samo.penic@fe.uni-lj.si>
Date: Wed, 06 Jul 2016 08:25:54 +0000
Subject: [PATCH] Finished spontaneous force

---
 src/io.c         |    1 +
 src/tape         |    7 ++++---
 src/energy.c     |   27 +++++++++++++++++++++++++++
 src/general.h    |    1 +
 src/energy.h     |    2 +-
 src/vertexmove.c |    2 ++
 6 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/src/energy.c b/src/energy.c
index 0e57e71..7c29c0b 100644
--- a/src/energy.c
+++ b/src/energy.c
@@ -207,3 +207,30 @@
 	}
 	return TS_SUCCESS;
 }
+
+ts_double direct_force_energy(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *vtx_old){
+	if(fabs(vtx->c)<1e-15) return 0.0;
+//	printf("was here");
+	if(fabs(vesicle->tape->F)<1e-15) return 0.0;
+
+	ts_double norml,ddp=0.0;
+	ts_uint i;
+	ts_double xnorm=0.0,ynorm=0.0,znorm=0.0;
+	/*find normal of the vertex as average normal of all the triangles surrounding it. */
+	for(i=0;i<vtx->tristar_no;i++){
+			xnorm=vtx->tristar[i]->xnorm;
+			ynorm=vtx->tristar[i]->ynorm;
+			znorm=vtx->tristar[i]->znorm;
+	}
+	/*normalize*/
+	norml=sqrt(xnorm*xnorm+ynorm*ynorm+znorm*znorm);
+	xnorm/=norml;
+	ynorm/=norml;
+	znorm/=norml;
+	/*calculate ddp, perpendicular displacement*/
+	ddp=xnorm*(vtx->x-vtx_old->x)+xnorm*(vtx->y-vtx_old->y)+znorm*(vtx->z-vtx_old->z);
+	/*calculate dE*/
+//	printf("ddp=%e",ddp);
+	return vesicle->tape->F*ddp;		
+	
+}
diff --git a/src/energy.h b/src/energy.h
index 4d51b24..1b97fa9 100644
--- a/src/energy.h
+++ b/src/energy.h
@@ -7,5 +7,5 @@
 
 ts_bool sweep_attraction_bond_energy(ts_vesicle *vesicle);
 inline ts_bool attraction_bond_energy(ts_bond *bond, ts_double w);
-
+ts_double direct_force_energy(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *vtx_old);
 #endif
diff --git a/src/general.h b/src/general.h
index 9fefc5b..fa1e669 100644
--- a/src/general.h
+++ b/src/general.h
@@ -287,6 +287,7 @@
 	long int number_of_vertices_with_c0;
 	ts_double c0;
 	ts_double w;
+	ts_double F;
 } ts_tape;
 
 
diff --git a/src/io.c b/src/io.c
index f82aa7a..57d1ced 100644
--- a/src/io.c
+++ b/src/io.c
@@ -1182,6 +1182,7 @@
 	CFG_SIMPLE_INT("number_of_vertices_with_c0", &tape->number_of_vertices_with_c0),
 	CFG_SIMPLE_FLOAT("c0",&tape->c0),
 	CFG_SIMPLE_FLOAT("w",&tape->w),
+	CFG_SIMPLE_FLOAT("F",&tape->F),
         CFG_END()
     };
     cfg_t *cfg;    
diff --git a/src/tape b/src/tape
index 0e4f777..16a5480 100644
--- a/src/tape
+++ b/src/tape
@@ -86,9 +86,10 @@
 
 #NirGov branch only!
 #number of vertices with spontaneous curvature (integer)
-number_of_vertices_with_c0=30
+number_of_vertices_with_c0=100
 #spontaneous curvature (float)
 c0=0.5
 #energy of attraction of vertices with spontaneous curvature (float, positive value for attraction)
-w=100.0
-
+w=10.0
+#direct force on vesicles with spontaneous curvature (float)
+F=2.0
diff --git a/src/vertexmove.c b/src/vertexmove.c
index 0b6f50a..2517f69 100644
--- a/src/vertexmove.c
+++ b/src/vertexmove.c
@@ -189,6 +189,8 @@
     delta_energy+=delta_energy_cv;
 //    fprintf(stderr,"Denergy after=%e\n",delta_energy);
     }
+/* Vertices with spontaneous curvature may have spontaneous force perpendicular to the surface of the vesicle. additional delta energy is calculated in this function */
+	delta_energy+=direct_force_energy(vesicle,vtx,backupvtx);
 /* No poly-bond energy for now!
 	if(vtx->grafted_poly!=NULL){
 		delta_energy+=

--
Gitblit v1.9.3