From 620ba72765eda244ca3f3806b8ad709929e74b3c Mon Sep 17 00:00:00 2001
From: Samo Penic <samo.penic@gmail.com>
Date: Thu, 21 Jun 2018 10:50:23 +0000
Subject: [PATCH] Isak's proposal for stretching energy calculation,  take 1

---
 src/bondflip.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/bondflip.c b/src/bondflip.c
index 13ec263..d48413f 100644
--- a/src/bondflip.c
+++ b/src/bondflip.c
@@ -40,6 +40,7 @@
     ts_double delta_energy_cv;
     ts_vertex *constvol_vtx_moved, *constvol_vtx_backup;
     ts_bool retval;
+	ts_double temp_area=0.0;
 
     if(it->neigh_no< 3) return TS_FAIL;
     if(k->neigh_no< 3) return TS_FAIL;
@@ -176,6 +177,9 @@
 /*    vesicle_volume(vesicle);
     fprintf(stderr,"Volume in the beginning=%1.16e\n", vesicle->volume);
 */
+	if(vesicle->tape->stretchswitch==1){
+		temp_area=vesicle->area-lm->area-lp->area;
+	}
 /* fix data structure for flipped bond */
     ts_flip_bond(k,it,km,kp, bond,lm, lp, lm2, lp1, vesicle->tape->w);
 
@@ -189,10 +193,13 @@
   delta_energy+=bond->energy; /* attraction with neighboring vertices, that have spontaneous curvature */
   //Neigbours of k, it, km, kp don't change its energy.
 	if(vesicle->tape->stretchswitch==1){
-		oldenergy+=lm->energy+lp->energy;
+/*		oldenergy+=lm->energy+lp->energy;
 		stretchenergy(vesicle,lm);
 		stretchenergy(vesicle,lp);
 		delta_energy+=lm->energy+lp->energy;
+	*/
+		temp_area=temp_area+lm->area+lp->area;
+		delta_energy+=stretchenergy2(temp_area,vesicle->tlist->a0*vesicle->tlist->n)-stretchenergy2(vesicle->area,vesicle->tlist->a0*vesicle->tlist->n);
 	}
 
     delta_energy-=oldenergy;
@@ -339,11 +346,11 @@
 //		fprintf(stderr,"Restoration complete!!!\n");
 //    vesicle_volume(vesicle);
 //    fprintf(stderr,"Volume after fail=%1.16e\n", vesicle->volume);
-	if(vesicle->tape->stretchswitch==1){
+/*	if(vesicle->tape->stretchswitch==1){
 		stretchenergy(vesicle,lm);
 		stretchenergy(vesicle,lp);
 	}
-
+*/
 		return TS_FAIL;
         }
     }
@@ -358,6 +365,10 @@
     if(vesicle->tape->constareaswitch==2){
         vesicle->area+=darea;
     }
+	if(vesicle->tape->stretchswitch==1){
+		vesicle->area=temp_area;
+	}
+
 	// delete all backups
 	for(i=0;i<4;i++){
 	free(bck_vtx[i]->neigh);

--
Gitblit v1.9.3