/* Just like the halo mass function, we'll set this up such that * you just need to interpolate. * * Now this has been changed to calculate the spatial-scale dependence * of the bias factor. If you don't want the scale dep. b, then just * input r<0. * * If the global flag LINEAR_PSP==0, uses the scale dependence calculated for * for halo bias relative to the non-linear matter \xi_m(r): * * f^2(r) = (1.0+xi*1.17)^1.49/(1.0+xi*0.69)^2.09 --> b(r) = b0*f(r) * * For LINEAR_PSP==1, use scale dependence determined for the linear P(k): * * f(r) = 1 + exp[-(r/A)^0.7] --> where A is a parameter that we're gonna have to * determine in more detail, but now A \approx 1 */ double bias_interp(double m, double r) { static int flag=0,prev_cosmo=0, n; static double *x,*y,*y2, pnorm; int i; double dm,max=16.3,min=9,a,b,m1,m2,dm1,xi,power,rm,sig,b1,b2,mass,rvir,a1; double c1,c2,d1,d2; if(!flag || RESET_COSMOLOGY!=prev_cosmo) { n = 100; if(!ThisTask && OUTPUT) fprintf(stdout,"RESET: resetting bias for %f %f\n",OMEGA_M,SIGMA_8); if(!flag) { x=dvector(1,n); y=dvector(1,n); y2=dvector(1,n); } flag=1; dm=(double)(max-min)/n; for(i=1;i<=n;++i) { x[i]=pow(10.0,min+i*dm); y[i]=log(bias(x[i])); //printf("BIAS %e %e\n",x[i], exp(y[i])); if(isinf(y[i])){ n = i-1; break; } if(isnan(y[i])){ n = 1-1; break; } x[i] = log(x[i]); continue; // no longer need to do this part, since we're taking into account // halo overdensity in the bias formula. /* if(DELTA_HALO!=200) { x[i]=log(halo_mass_conversion2(x[i],halo_c200(x[i]),200.0,DELTA_HALO)); } else { x[i]=log(x[i]); } */ } spline(x,y,n,2.0E+30,2.0E+30,y2); prev_cosmo=RESET_COSMOLOGY; pnorm=SIGMA_8/sigmac(8.0); } m=log(m); splint(x,y,y2,n,m,&a); a = exp(a); // if we're using systematic errors in an MCMC, adjust parameter a1 (amplitude) if(USE_ERRORS) a *= M2N.bias_amp; // if no scale-dependence required, return the large-scale value if(r<0) return a; /* * SCALE DEPENDENT BIAS!!! *---------------------------------------------------------------------- */ /* FOR M/N analysis, use the Tinker etal 2005 result: */ xi = xi_interp(r); if(M2N.scalebias_selfcal) { b = pow(1.0+xi*M2N.bias_amp1,M2N.bias_pow1)*pow(1.0+xi*0.69,-1.045); } else { //Attempting to correct scale-dep bias issue //SCALE-DEP BIAS CORRECTION rvir = pow(3*exp(m)/(4*PI*200*RHO_CRIT*OMEGA_M),THIRD); // if(r<2.4*rvir)r=2.4*rvir; if(r<2.8*rvir)r=2.8*rvir; //rvir = pow(3*exp(m)/(4*PI*DELTA_HALO*RHO_CRIT*OMEGA_M),THIRD); //if(r<2*rvir)r=2*rvir; xi = xi_interp(r); //parameters for scale-dep bias //original values //c1 = 1.17; //c2 = 0.69; //d1 = 1.49; //d2 = -2.09; c1 = HBIAS_C1; c2 = HBIAS_C2; d1 = HBIAS_D1; d2 = (-1.)*HBIAS_D2; /** c1 = 1.52; c2 = 0.84; d1 = 1.49; d2 = -2.09; **/ b = pow(1.0+xi*c1,d1/2.)*pow(1.0+xi*c2,d2/2.0); // if we're using systematic errors in an MCMC, adjust parameter a1 (amplitude) if(USE_ERRORS) { b = (b-1)*M2N.scalebias_amp + 1; if(b<0)b=0; } } return b*a; /* first, calculate the standard Zheng-like, mass-independent scale bias * based on the non-linear correlation function * (re-calibrated using the SO catalogs) */ xi = xi_interp(r); b = pow(1.0+xi*0.92,2.08)*pow(1.0+xi*0.74,-2.37); if(b<0.6)b=0.6; /* Now the mass-dependent term. * Where the mass-dependence comes in the form of the large-scale bias itself */ sig = sigmac_radius_interp(r); //if(a<0) //b *= pow(1 + 0.028*pow(a,1.53)*pow(sig,1.57),2.59)/ //pow(1 + 0.253*pow(a,1.24)*pow(sig,1.71),0.397); // if we're using systematic errors in an MCMC, adjust parameter a1 (amplitude) if(USE_ERRORS) { b = (b-1)*M2N.scalebias_amp + 1; if(b<0)b=0; } return b*a; }
int main(int argc, char **argv) { double s1, delta_vir, omega_m, x; int i, j; FILE *fp; #ifdef PARALLEL printf("STARTING>>>\n"); fflush(stdout); MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &ThisTask); MPI_Comm_size(MPI_COMM_WORLD, &NTask); printf("TASK %d reporting for duty.\n",ThisTask); fflush(stdout); #endif ARGC = argc; ARGV = argv; OUTPUT=0; HOD.fredc = HOD.freds = 1.0; for(i=1; i<=99; ++i) HOD.free[i]=0; wp.esys=0; Work.chi2=0; Work.imodel=1; USE_ERRORS = 0; ITRANS=4; HUBBLE=0.7; BEST_FIT = 0; HOD.M_sat_break = 1.0e14; HOD.alpha1 = 1.0; if(argc==1) endrun("./HOD.x hod.bat_file > output"); read_parameter_file(argv[1]); if(REDSHIFT>0) { SIGMA_8 = SIGMA_8*growthfactor(REDSHIFT); HUBBLEZ = sqrt(OMEGA_M*pow(1+REDSHIFT,3.0)+1-OMEGA_M); OMEGA_Z = OMEGA_M*pow(1+REDSHIFT,3.0)/(OMEGA_M*pow(1+REDSHIFT,3.0)+(1-OMEGA_M)); fprintf(stdout,"SIGMA_8(Z=%.3f)= %.4f\n",REDSHIFT,SIGMA_8); fprintf(stdout,"H(Z=%.3f)/H0= %.4f\n",REDSHIFT,HUBBLEZ); HOD.M_min = 0; RESET_COSMOLOGY++; set_HOD_params(); } /* Output the virial overdensity for reference. */ if(OUTPUT) { omega_m=OMEGA_M*pow(1+REDSHIFT,3.0)/(OMEGA_M*pow(1+REDSHIFT,3.0)+(1-OMEGA_M)); x=omega_m-1; delta_vir=(18*PI*PI+82*x-39*x*x)/(1+x); printf("DELTA_VIR(Omega_m,z) = %f\n",delta_vir); } /* Do some initialization if we're doing SHMR */ if(SHMR_FLAG) { if(SATELLITE_PARAMETERIZATION)SHMR_PARAMS = 14; if(VARIABLE_ALPHA)SHMR_PARAMS += 2; if(VARIABLE_EXCLUSION)wpl.a[SHMR_PARAMS+1] = EXCLUSION_RADIUS; wpl.ncf = SHMR_PARAMS + VARIABLE_EXCLUSION; HOD.pdfs = 100; HOD.pdfc = 101; wpx.calculate_two_halo = 1; input_stellar_mass_bins(); // if we have input from the prompt, take that if(argc>2 && atoi(argv[2])!=999) { fp = openfile(argv[2]); fscanf(fp,"%d %d",&i,&j); for(i=1; i<=wpl.ncf; ++i) fscanf(fp,"%lf",&wpl.a[i]); fclose(fp); } } for(i=1; i<=wpl.ncf; ++i) printf("wpl.a[%d]= %e\n",i,wpl.a[i]); /* LENSING TESTING FOR ALEXIE */ if(argc>2) IDUM_MCMC=atoi(argv[2]); SIGMA_8Z0 = 0.8; if(argc>2) if(atoi(argv[2])==999) test(argc,argv); /* If there's no cross-correlation function, * set the second number density equal to the first */ if(!XCORR) GALAXY_DENSITY2 = GALAXY_DENSITY; /* Initialize the non-linear power spectrum. */ nonlinear_sigmac(8.0); sigmac_interp(1.0E13); sigmac_radius_interp(1.0); /* Skip the HOD stuff if we're SHMR-ing it: */ if(SHMR_FLAG) { if(argc>2 && atoi(argv[2])==999)test(argc, argv); if(argc>3 && atoi(argv[3])==999)test(argc, argv); goto TASKS; } /* Get the galaxy bias factor */ s1=qromo(func_galaxy_bias,log(HOD.M_low),log(HOD.M_max),midpnt); GALAXY_BIAS=s1/GALAXY_DENSITY; if(OUTPUT) fprintf(stdout,"Galaxy Bias bg= %f\n",GALAXY_BIAS); fflush(stdout); /* Get the galaxy satellite fraction */ s1=qromo(func_satellite_density,log(HOD.M_low),log(HOD.M_max),midpnt)/ GALAXY_DENSITY; if(OUTPUT) fprintf(stdout,"fsat %e\n",s1); fflush(stdout); /* Mean halo mass. */ if(OUTPUT) fprintf(stdout,"M_eff %e\n",number_weighted_halo_mass()); fflush(stdout); /* Set up BETA for wp integration. */ BETA = pow(OMEGA_M,0.6)/GALAXY_BIAS; if(OUTPUT) printf("BETA = %f\n",BETA); TASKS: tasks(argc,argv); }