/* myprior_starting_values is optional. It is used to synchronize * the values set by glbSetStartingValues with the values used in here. * This function (if it exists) is called by glbSetStartingValues * with the same argument. * * Here we just copy the argument to our local buffer. */ int tmyprior_starting_values(const glb_params in, void *user_data) { if(glbCopyParams(in,tsv)!=NULL) return 0; return -1; }
/* myprior_input_errors is optional. It is used to synchronize * the values set by glbSetInputErrors with the values used in here. * This function (if it exists) is called by glbSetInputErrors * with the same argument. * * Here we just copy the argument to our local buffer. */ int tmyprior_input_errors(const glb_params in, void *user_data) { if(glbCopyParams(in,ter)!=NULL) return 0; return -1; }
int main(int argc, char *argv[]) { /* Initialize libglobes */ glbInit(argv[0]); glbInitExperiment("T2HK.glb",&glb_experiment_list[0],&glb_num_of_exps); glbSelectMinimizer(GLB_MIN_POWELL); // Use experimental minimizer to speed up things double theta12 = asin(sqrt(0.3)); double theta13 = asin(sqrt(0.1))/2.0; double theta23 = M_PI/4.0; double deltacp = 3*M_PI/2.0; double sdm = 8.0e-5; double ldm = 2.5e-3; /* Parameter is output file name; if empty string, write to screen: */ mioInitOutput("tut1.dat"); glb_params central_values = glbAllocParams(); glb_params fit_values = glbAllocParams(); glb_params true_values = glbAllocParams(); glb_params input_errors = glbAllocParams(); glb_params foundmin = glbAllocParams(); glbDefineParams(true_values,theta12,theta13,theta23,deltacp,sdm,ldm); glbSetDensityParams(true_values,1.0,GLB_ALL); glbDefineParams(input_errors,theta12*0.1,0,0,0,sdm*0.1,0); /* 10% external error for solar parameters */ glbSetDensityParams(input_errors,0.05,GLB_ALL); /* 5% matter density uncertainty */ double res; /* scan parameter space as function of true x = log sin^2 2 theta_13 */ double x; double minx = -4.0; double maxx = -1.0; double steps = 12.0; for(x=minx;x<maxx+0.0001;x+=(maxx-minx)/steps) { glbSetOscParams(true_values,asin(sqrt(pow(10,x))/2),GLB_THETA_13); glbSetOscillationParameters(true_values); glbSetRates(); glbCopyParams(true_values,central_values); /* Educated guess: start minimizer at -dm_31 */ glbSetOscParams(central_values,-glbGetOscParams(true_values,GLB_DM_31),GLB_DM_31); glbCopyParams(central_values,fit_values); glbSetCentralValues(central_values); glbSetInputErrors(input_errors); res=glbChiAll(fit_values,foundmin,GLB_ALL); printf("\nx=%g, Minimum found at %g:\n",x,res); glbPrintParams(stdout,foundmin); /* Write to file */ mioAddToOutput(x,res); } /* Close output stream: */ mioCloseOutput(); glbFreeParams(fit_values); glbFreeParams(central_values); glbFreeParams(true_values); glbFreeParams(input_errors); glbFreeParams(foundmin); exit(0); }