From 304510886da7e3969efd6d506e68652b533c0975 Mon Sep 17 00:00:00 2001
From: Miha <mihaf@hapi.(none)>
Date: Fri, 21 Feb 2014 12:22:07 +0000
Subject: [PATCH] Removed harmonic potential between poly-monomers for now. Added min and max distance between neighboring poly-vertices.

---
 src/tape         |    2 +-
 src/energy.c     |    4 +++-
 src/vertexmove.c |   47 ++++++++++++++++++++++++++++++++++-------------
 3 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/src/energy.c b/src/energy.c
index 1e37e08..440f319 100644
--- a/src/energy.c
+++ b/src/energy.c
@@ -21,7 +21,9 @@
 
 
 inline ts_bool bond_energy(ts_bond *bond,ts_poly *poly){
-	bond->energy=poly->k*pow(bond->bond_length-1,2);
+//TODO: This value to be changed and implemented in data structure:
+	ts_double d_relaxed=1.0;
+	bond->energy=poly->k*pow(bond->bond_length-d_relaxed,2);
 	return TS_SUCCESS;
 };
 
diff --git a/src/tape b/src/tape
index 10db609..9a44ef3 100644
--- a/src/tape
+++ b/src/tape
@@ -2,7 +2,7 @@
 # nshell is a number of divisions of dipyramid
 nshell=17
 # dmax is the max. bond length 
-dmax=1.4
+dmax=1.7
 # bending rigidity of the membrane 
 xk0=25.0
 # max step size 
diff --git a/src/vertexmove.c b/src/vertexmove.c
index f78fd61..86b8533 100644
--- a/src/vertexmove.c
+++ b/src/vertexmove.c
@@ -57,6 +57,16 @@
 		return TS_FAIL;
 		}
     }
+
+// Distance with grafted poly-vertex check:	
+	if(vtx->grafted_poly!=NULL){
+		dist=vtx_distance_sq(vtx,vtx->grafted_poly->vlist->vtx[0]);
+        if(dist<1.0 || dist>vesicle->dmax) {
+		vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
+		return TS_FAIL;
+		}
+	}
+
     //self avoidance check with distant vertices
      cellidx=vertex_self_avoidance(vesicle, vtx);
     //check occupation number
@@ -87,15 +97,13 @@
         energy_vertex(vtx->neigh[i]);
         delta_energy+=vtx->neigh[i]->xk*(vtx->neigh[i]->energy-oenergy);
     }
-
+/* No poly-bond energy for now!
 	if(vtx->grafted_poly!=NULL){
 		delta_energy+=
 			(pow(sqrt(vtx_distance_sq(vtx, vtx->grafted_poly->vlist->vtx[0])-1),2)-
 			pow(sqrt(vtx_distance_sq(&backupvtx[0], vtx->grafted_poly->vlist->vtx[0])-1),2)) *vtx->grafted_poly->k;
-		
-	
 	}
-
+*/
 //   fprintf(stderr, "DE=%f\n",delta_energy);
     //MONTE CARLOOOOOOOO
     if(delta_energy>=0){
@@ -139,11 +147,12 @@
 	ts_uint i;
 	ts_bool retval; 
 	ts_uint cellidx; 
-	ts_double delta_energy;
+//	ts_double delta_energy;
 	ts_double costheta,sintheta,phi,r;
+	ts_double dist;
 	//This will hold all the information of vtx and its neighbours
 	ts_vertex backupvtx;
-	ts_bond backupbond[2];
+//	ts_bond backupbond[2];
 	memcpy((void *)&backupvtx,(void *)vtx,sizeof(ts_vertex));
 
 	//random move in a sphere with radius stepsize:
@@ -157,13 +166,23 @@
 
 
 	//distance with neighbours check
-//	for(i=0;i<vtx->neigh_no;i++){
-//	dist=vtx_distance_sq(vtx,vtx->neigh[i]);
-//	if(dist<1.0 || dist>vesicle->dmax) {
-//	vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
-//	return TS_FAIL;
-//		}
-//	}
+	for(i=0;i<vtx->neigh_no;i++){
+		dist=vtx_distance_sq(vtx,vtx->neigh[i]);
+		if(dist<1.0 || dist>vesicle->dmax) {
+			vtx=memcpy((void *)vtx,(void *)&backupvtx,sizeof(ts_vertex));
+			return TS_FAIL;
+		}
+	}
+
+// Distance with grafted vesicle-vertex check:	
+	if(vtx==poly->vlist->vtx[0]){
+		dist=vtx_distance_sq(vtx,poly->grafted_vtx);
+        if(dist<1.0 || dist>vesicle->dmax) {
+		vtx=memcpy((void *)vtx,(void *)&backupvtx,sizeof(ts_vertex));
+		return TS_FAIL;
+		}
+	}
+
 
 	//self avoidance check with distant vertices
 	cellidx=vertex_self_avoidance(vesicle, vtx);
@@ -177,6 +196,7 @@
 
 
 	//if all the tests are successful, then energy for vtx and neighbours is calculated
+/* Energy ignored for now!
 	delta_energy=0;
 	for(i=0;i<vtx->bond_no;i++){
 		memcpy((void *)&backupbond[i],(void *)vtx->bond[i],sizeof(ts_bond));
@@ -214,6 +234,7 @@
     return TS_FAIL; 
 	}
 	}
+*/
 		
 //	oldcellidx=vertex_self_avoidance(vesicle, &backupvtx[0]);
 	if(vtx->cell!=vesicle->clist->cell[cellidx]){

--
Gitblit v1.9.3