From d7a113d890064e18aa9f4267c33ac71348c6ba98 Mon Sep 17 00:00:00 2001
From: Samo Penic <samo.penic@gmail.com>
Date: Mon, 04 Nov 2013 21:54:22 +0000
Subject: [PATCH] Changes in main loop. It allows setting inner, outer loop and initial mc sweeps to be discarded

---
 src/main.c     |   22 +---------
 src/timestep.c |   20 ++++++++++
 src/io.c       |   11 ++++-
 src/tape       |    9 +++-
 src/timestep.h |    1 
 src/io.h       |    3 -
 6 files changed, 40 insertions(+), 26 deletions(-)

diff --git a/src/io.c b/src/io.c
index 2127796..9e278ec 100644
--- a/src/io.c
+++ b/src/io.c
@@ -294,14 +294,14 @@
 
 
 
-ts_vesicle *parsetape(ts_uint *iterations){
+ts_vesicle *parsetape(ts_uint *mcsweeps, ts_uint *inititer, ts_uint *iterations){
     long int nshell=17,ncxmax=60, ncymax=60, nczmax=60;  // THIS IS DUE TO CONFUSE BUG!
     char *buf=malloc(255*sizeof(char));
     long int brezveze0=1;
     long int brezveze1=1;
     long int brezveze2=1;
     ts_double xk0=25.0, dmax=1.67,stepsize=0.15;
-    *iterations=1000;
+	long int iter=1000, init=1000, mcsw=1000;
     cfg_opt_t opts[] = {
         CFG_SIMPLE_INT("nshell", &nshell),
         CFG_SIMPLE_FLOAT("dmax", &dmax),
@@ -310,7 +310,9 @@
         CFG_SIMPLE_INT("nxmax", &ncxmax),
         CFG_SIMPLE_INT("nymax", &ncymax),
         CFG_SIMPLE_INT("nzmax", &nczmax),
-        CFG_SIMPLE_INT("iterations",iterations),
+        CFG_SIMPLE_INT("iterations",&iter),
+	CFG_SIMPLE_INT("mcsweeps",&mcsw),
+	CFG_SIMPLE_INT("inititer", &init),
         CFG_SIMPLE_BOOL("quiet",&quiet),
         CFG_SIMPLE_STR("multiprocessing",buf),
         CFG_SIMPLE_INT("smp_cores",&brezveze0),
@@ -329,6 +331,9 @@
 	fatal("Invalid tape!",100);
 	}
 	ts_vesicle *vesicle;
+    	*iterations=iter;
+	*inititer=init;
+	*mcsweeps=mcsw;
 	vesicle=initial_distribution_dipyramid(nshell,ncxmax,ncymax,nczmax,stepsize);
     vesicle->nshell=nshell;
     vesicle->dmax=dmax*dmax;
diff --git a/src/io.h b/src/io.h
index 2f3f19a..20eab38 100644
--- a/src/io.h
+++ b/src/io.h
@@ -48,7 +48,6 @@
 ts_bool write_vertex_vtk_file(ts_vesicle *vesicle,ts_char *filename, ts_char *text);
 ts_bool write_vertex_xml_file(ts_vesicle *vesicle, ts_uint timestepno);
 ts_bool write_master_xml_file(ts_char *filename);
-ts_vesicle *parsetape(ts_uint *iterations);
-
+ts_vesicle *parsetape(ts_uint *mcsweeps, ts_uint *inititer, ts_uint *iterations);
 
 #endif
diff --git a/src/main.c b/src/main.c
index c651382..7e12c1c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -18,7 +18,7 @@
 */
 
 int main(int argv, char *argc[]){
-ts_uint i,n;
+ts_uint inititer,mcsweeps, iterations;
 ts_vesicle *vesicle;
 /* THIS SHOULD GO INTO UNIT TEST
 ts_bool retval;
@@ -63,25 +63,9 @@
 vtx_list_free(vlist1);
 printf("Tests complete.\n");
 */
-vesicle=parsetape(&n);
+vesicle=parsetape(&mcsweeps, &inititer, &iterations);
+run_simulation(vesicle, mcsweeps, inititer, iterations);
 
-//these four must come from parsetype!
-/*
-vesicle->dmax=1.67*1.67;
-vesicle->stepsize=0.15;
-vesicle->clist->max_occupancy=8;
-vesicle->bending_rigidity=25.0;
-*/
-// fprintf(stderr,"xk=%f\n",vesicle->bending_rigidity);
-
-centermass(vesicle);
-cell_occupation(vesicle);
-for(i=0;i<n;i++){
-single_timestep(vesicle);
-if(i%100==0){
-write_vertex_xml_file(vesicle,i/100);
-}
-}
 write_master_xml_file("test.pvd");
 write_dout_fcompat_file(vesicle,"dout");
 vesicle_free(vesicle);
diff --git a/src/tape b/src/tape
index 38518d3..0351c83 100644
--- a/src/tape
+++ b/src/tape
@@ -16,8 +16,13 @@
 
 
 ####### Program Control ############
-#how many iteration are there in a run?
-iterations=20000
+#how many MC sweeps between subsequent records of states to disk
+mcsweeps=100
+#how many initial mcsweeps*inititer MC sweeps before recording to disk?
+inititer=100
+#how many records do you want on the disk iteration are there in a run?
+iterations=1000
+
 
 #shut up if we are using cluster!!!
 quiet=false
diff --git a/src/timestep.c b/src/timestep.c
index 01cf777..4c9fa67 100644
--- a/src/timestep.c
+++ b/src/timestep.c
@@ -6,6 +6,26 @@
 #include "timestep.h"
 #include "vertexmove.h"
 #include "bondflip.h"
+#include "frame.h"
+#include "io.h"
+ts_bool run_simulation(ts_vesicle *vesicle, ts_uint mcsweeps, ts_uint inititer, ts_uint iterations){
+	ts_uint i, j;
+
+	centermass(vesicle);
+	cell_occupation(vesicle);
+	ts_fprintf(stdout, "Starting simulation (first %d x %d MC sweeps will not be recorded on disk)\n", inititer, mcsweeps);
+	for(i=0;i<inititer+iterations;i++){
+		for(j=0;j<mcsweeps;j++){
+			single_timestep(vesicle);
+		}
+		centermass(vesicle);
+		cell_occupation(vesicle);
+		if(i>inititer){
+			write_vertex_xml_file(vesicle,i-inititer);
+		}
+	}
+	return TS_SUCCESS;
+}
 
 ts_bool single_timestep(ts_vesicle *vesicle){
     ts_bool retval;
diff --git a/src/timestep.h b/src/timestep.h
index c4015ae..e25234d 100644
--- a/src/timestep.h
+++ b/src/timestep.h
@@ -1,4 +1,5 @@
 #ifndef _TIMESTEP_H
 #define _TIMESTEP_H
 ts_bool single_timestep(ts_vesicle *vesicle);
+ts_bool run_simulation(ts_vesicle *vesicle, ts_uint mcsweeps, ts_uint inititer, ts_uint iterations);
 #endif

--
Gitblit v1.9.3