From 0334070e91966e5bb11b34b462491353a188e128 Mon Sep 17 00:00:00 2001
From: Samo Penic <samo.penic@fe.uni-lj.si>
Date: Tue, 05 Jul 2016 11:48:15 +0000
Subject: [PATCH] Histogram data written to file

---
 src/tape         |    6 +++---
 src/tspoststat.c |   40 ++++++++++++++++++++++++++++++++++------
 2 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/src/tape b/src/tape
index fe611f8..0e4f777 100644
--- a/src/tape
+++ b/src/tape
@@ -1,6 +1,6 @@
 ####### Vesicle definitions ###########
 # nshell is a number of divisions of dipyramid
-nshell=17
+nshell=10
 # dmax is the max. bond length (in units l_min)
 dmax=1.7
 # dmin_interspecies in the min. dist. between different vertex species (in units l_min)
@@ -86,9 +86,9 @@
 
 #NirGov branch only!
 #number of vertices with spontaneous curvature (integer)
-number_of_vertices_with_c0=300
+number_of_vertices_with_c0=30
 #spontaneous curvature (float)
 c0=0.5
 #energy of attraction of vertices with spontaneous curvature (float, positive value for attraction)
-w=10.0
+w=100.0
 
diff --git a/src/tspoststat.c b/src/tspoststat.c
index fdc822b..5ac1c4e 100644
--- a/src/tspoststat.c
+++ b/src/tspoststat.c
@@ -28,7 +28,7 @@
 #include <snapshot.h>
 #include<gsl/gsl_complex.h>
 #include<gsl/gsl_complex_math.h>
-
+#include<stdio.h>
 
 ts_vesicle *restoreVesicle(char *filename){
 	ts_vesicle *vesicle = parseDump(filename);
@@ -63,6 +63,38 @@
 	}
 	return cnt;
 }
+
+
+
+ts_bool write_histogram_data(ts_uint timestep_no, ts_vesicle *vesicle){
+	ts_cluster_list *cstlist=init_cluster_list();
+	clusterize_vesicle(vesicle,cstlist);
+	//printf("No clusters=%d\n",cstlist->n);
+	int k,i,cnt;
+	int max_nvtx=0;
+	char filename[255];
+	sprintf(filename,"histogram_%.6u.csv",timestep_no);
+	FILE *fd=fopen(filename,"w");
+	fprintf(fd,"Number_of_vertices_in cluster Number_of_clusters\n");
+	for(k=0;k<cstlist->n;k++)
+		if(cstlist->cluster[k]->nvtx>max_nvtx) max_nvtx=cstlist->cluster[k]->nvtx;
+	//printf("Max. number of vertices in cluster: %d\n",max_nvtx);
+	for(i=1;i<=max_nvtx;i++){
+		cnt=0;
+		for(k=0;k<cstlist->n;k++)
+			if(cstlist->cluster[k]->nvtx==i) cnt++;
+		fprintf(fd,"%d %d\n",i,cnt);
+	}
+	//for(k=0;k<cstlist->n;k++){
+//		printf("*Cluster %d has %d vertices\n",k,cstlist->cluster[k]->nvtx);
+//	}
+
+	fclose(fd);
+	cluster_list_free(cstlist);
+	
+	return TS_SUCCESS;
+}
+
 
 int main(){
 	ts_vesicle *vesicle;
@@ -103,11 +135,7 @@
 			gyration_eigen(vesicle,&l1,&l2,&l3);
 			fprintf(stdout,"%d %.17e %.17e %.17e %.17e %.17e %.17e\n",atoi(number),vesicle->volume, vesicle->area,l1,l2,l3, (ts_double)count_bonds_with_energy(vesicle->blist)/(ts_double)vesicle->blist->n),
                     	tstep++;
-
-			ts_cluster_list *cstlist=init_cluster_list();
-			clusterize_vesicle(vesicle,cstlist);
-			printf("No clusters=%d\n",cstlist->n);
-			cluster_list_free(cstlist);
+			write_histogram_data(atoi(number), vesicle);
                     free(number);
 			tape_free(vesicle->tape);
 			vesicle_free(vesicle);

--
Gitblit v1.9.3