diff --git a/README.md b/README.md index e8fb99c..605f525 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,12 @@ STSP In and out of transit starspot modeling code +V4.5.1 2015-12-07 + +Refactoring the elapsed time calculation for timed runs. STSP runs can be timed by +setting the MCMC step number to a negative number, which will be interpreted as the +negative of the maximum number of seconds to run the chains. + V4.5 2015-11-30 Added the functionality for analyzing planets on eccentric orbits. diff --git a/stsp.c b/stsp.c index 0ec8063..a1e7972 100644 --- a/stsp.c +++ b/stsp.c @@ -3,8 +3,8 @@ #include #include -#define QUIET 0 //0 -> prints things, 1 -> only prints errors -#define QUIETMCMC 0 //0 -> mcmc prints as it goes, 1-> stays quiet (0 overridden by QUIET) +#define QUIET 1 //0 -> prints things, 1 -> only prints errors +#define QUIETMCMC 1 //0 -> mcmc prints as it goes, 1-> stays quiet (0 overridden by QUIET) #define ALWAYSPRINTVIS 0 #define WHICHPRINTVIS 1 // what sort of visualization file to output (j-1,g-2) #define ANYPRINTVIS 0 //0 for speed, overrides other PRINTVIS preferences @@ -4226,7 +4226,8 @@ void mcmc(stardata *star,planetdata planet[MAXPLANETS],spotdata spot[MAXSPOTS],i { char goodparams,filename[128]; int i,j,k,r,msi,nparam,curstep,potstep,*updated,*naccepted,maxsteps; - long int memused,maxtime,time0,time1,avgtime; + long int memused, run_time_buffer; + double maxtime,time0,time1,avgtime,elapsed_time,elapsed_time_at_next_step; double **param[2],*chisq[2]; //param[0-1][chain number][parameter number] double sqrtascale,oosqrtascale,smooascale,z,alpha,rn; double bestchisq,*bestparam,torig; @@ -4491,17 +4492,17 @@ void mcmc(stardata *star,planetdata planet[MAXPLANETS],spotdata spot[MAXSPOTS],i else { maxsteps=TOOBIG; - maxtime=starttime-maxstepsortime; //time limit is passed as negative + maxtime=-maxstepsortime; //time limit is passed as negative # if !QUIETMCMC && !QUIET printf("start time: %li maxtime: %li (%li)\n",starttime,maxtime,maxstepsortime*(-1)); # endif } - avgtime=0; + if(maxtime||ALWAYSAVERAGETIME) + time0=timecheck(); for(msi=0;msimaxtime) + elapsed_time = time1-time0; + avgtime=elapsed_time/(msi+1); + elapsed_time_at_next_step = avgtime + elapsed_time; + run_time_buffer = 300; + + if(elapsed_time_at_next_step > maxtime - run_time_buffer) maxsteps=0; //make it stop, time is almost up } } //end of main mcmc loop