diff --git a/Cosmo_c_files/ps.c b/Cosmo_c_files/ps.c index ef949e4..409f26b 100755 --- a/Cosmo_c_files/ps.c +++ b/Cosmo_c_files/ps.c @@ -64,9 +64,7 @@ void initialiseGL_Nion(int n, float M_TURN, float M_Max); void Nion_Spline_density(float Overdensity, float *splined_value); void initialise_Nion_spline(float z, float Mmax, float MassTurnover, float Alpha_star, float Alpha_esc, float Fstar10, float Fesc10, float Mlim_Fstar, float Mlim_Fesc); -float Mass_limit (float logM, float PL, float FRAC); -void bisection(float *x, float xlow, float xup, int *iter); -float Mass_limit_bisection(float Mmin, float Mmax, float PL, float FRAC); +float Mass_limit (float PL, float FRAC); static double z_val[zpp_interp_points],Nion_z_val[zpp_interp_points]; // For Ts.c static double z_X_val[zpp_interp_points],SFRD_val[zpp_interp_points]; @@ -1170,54 +1168,14 @@ void initialiseSplinedSigmaM(float M_Min, float M_Max) /* New in v2 - part 4 of 4 start */ /* - FUNCTION Mass_limit_bisection(M_min, M_max, power-law, normalization) - Compute a threshold of halo mass above/below which f_{\ast}(M)/f_{esc}(M) exceeds unity/zero. + FUNCTION Mass_limit(power-law, normalization) + Compute a threshold of a halo mass at which the stellar mass fraction (the escape fraction) + exceeds unity. If the fraction is larger than unity, set the fraction is unity. */ -float Mass_limit (float logM, float PL, float FRAC) { - return FRAC*pow(pow(10.,logM)/1e10,PL); -} -void bisection(float *x, float xlow, float xup, int *iter){ - *x=(xlow + xup)/2.; - ++(*iter); +float Mass_limit (float PL, float FRAC) { + return 1e10*pow(1./FRAC,1./PL); } -float Mass_limit_bisection(float Mmin, float Mmax, float PL, float FRAC){ - int i, iter, max_iter=200; - float rel_tol=0.001; - float logMlow, logMupper, x, x1; - iter = 0; - logMlow = log10(Mmin); - logMupper = log10(Mmax); - - if (PL < 0.) { - if (Mass_limit(logMlow,PL,FRAC) <= 1.) { - return Mmin; - } - } - else if (PL > 0.) { - if (Mass_limit(logMupper,PL,FRAC) <= 1.) { - return Mmax; - } - } - else - return 0; - bisection(&x, logMlow, logMupper, &iter); - do { - if((Mass_limit(logMlow,PL,FRAC)-1.)*(Mass_limit(x,PL,FRAC)-1.) < 0.) - logMupper = x; - else - logMlow = x; - bisection(&x1, logMlow, logMupper, &iter); - if(fabs(x1-x) < rel_tol) { - return pow(10.,x1); - } - x = x1; - } - while(iter < max_iter); - printf("\n Failed to find a mass limit to regulate stellar fraction/escape fraction is between 0 and 1.\n"); - printf(" The solution does not converge or iterations are not sufficient\n"); - return -1; -} /* FUNCTION Nion_ST(z, Mturn) @@ -1515,8 +1473,8 @@ void initialise_Nion_ST_spline(int Nbin, float zmin, float zmax, float MassTurn, float Mmin = MassTurn/50., Mmax = 1e16; float Mlim_Fstar, Mlim_Fesc; - Mlim_Fstar = Mass_limit_bisection(Mmin, Mmax, Alpha_star, Fstar10); - Mlim_Fesc = Mass_limit_bisection(Mmin, Mmax, Alpha_esc, Fesc10); + Mlim_Fstar = Mass_limit(Alpha_star, Fstar10); + Mlim_Fesc = Mass_limit(Alpha_esc, Fesc10); Nion_z_spline_acc = gsl_interp_accel_alloc (); Nion_z_spline = gsl_spline_alloc (gsl_interp_cspline, Nbin); @@ -1539,7 +1497,7 @@ void initialise_SFRD_ST_spline(int Nbin, float zmin, float zmax, float MassTurn, float Mmin = MassTurn/50., Mmax = 1e16; float Mlim_Fstar; - Mlim_Fstar = Mass_limit_bisection(Mmin, Mmax, Alpha_star, Fstar10); + Mlim_Fstar = Mass_limit(Alpha_star, Fstar10); SFRD_ST_z_spline_acc = gsl_interp_accel_alloc (); SFRD_ST_z_spline = gsl_spline_alloc (gsl_interp_cspline, Nbin); @@ -1568,7 +1526,7 @@ void initialise_SFRD_Conditional_table(int Nsteps_zp, int Nfilter, float z[], do Mmin = MassTurnover/50; Mmax = RtoM(R[Nfilter-1]); - Mlim_Fstar = Mass_limit_bisection(Mmin, Mmax, Alpha_star, Fstar10); + Mlim_Fstar = Mass_limit(Alpha_star, Fstar10); initialiseSplinedSigmaM(Mmin,Mmax); fprintf(stderr, "In initialise_Fcollz_SFR_Conditional_table: Rmin = %6.4f, Rmax = %6.4f, Mmin = %.4e, Mmax = %.4e\n", R[0],R[Nfilter-1],RtoM(R[0]),RtoM(R[Nfilter-1])); @@ -1684,8 +1642,8 @@ void initialise_Q_value_spline(int NoRec, float MassTurn, float Alpha_star, floa z_arr = calloc(Nmax,sizeof(double)); Q_arr = calloc(Nmax,sizeof(double)); - Mlim_Fstar = Mass_limit_bisection(MassTurn/50., 1e16, Alpha_star, Fstar10); - Mlim_Fesc = Mass_limit_bisection(MassTurn/50., 1e16, Alpha_esc, Fesc10); + Mlim_Fstar = Mass_limit(Alpha_star, Fstar10); + Mlim_Fesc = Mass_limit(Alpha_esc, Fesc10); ION_EFF_FACTOR = N_GAMMA_UV * Fstar10 * Fesc10; a = a_start; diff --git a/Parameter_files/ANAL_PARAMS.H b/Parameter_files/ANAL_PARAMS.H index d7a4d4e..6de760c 100755 --- a/Parameter_files/ANAL_PARAMS.H +++ b/Parameter_files/ANAL_PARAMS.H @@ -125,9 +125,10 @@ then find_HII_bubbles just prints a homogeneous xHI field of 1's. - This is a new option in v1.1. Previous versions had a hardcoded value of 1e-15. + Previous versions had a value of 1e-3. In order to avoid discontinuous of redshift evolution in PS, + the threshold is changed to 1e-5, which is a hardcoded value. */ -#define HII_ROUND_ERR (float) (1e-3) +#define HII_ROUND_ERR (float) (1e-5) /* diff --git a/Programs/Ts.c b/Programs/Ts.c index 7f32b46..38bb38e 100755 --- a/Programs/Ts.c +++ b/Programs/Ts.c @@ -739,7 +739,7 @@ double freq_int_heat[NUM_FILTER_STEPS_FOR_Ts], freq_int_ion[NUM_FILTER_STEPS_FOR // However, such densities should always be collapsed, so just set f_coll to unity. // Additionally, the fraction of points in this regime relative to the entire simulation volume is extremely small. //New - splint(Overdense_high_table-1,SFRD_z_high_table[R_ct]-1,second_derivs_Nion_zpp[R_ct]-1,NSFR_high,delNL0[R_ct][box_ct]*growth_zpp,&(fcoll)); + splint(Overdense_high_table-1,SFRD_z_high_table[arr_num+R_ct]-1,second_derivs_Nion_zpp[R_ct]-1,NSFR_high,delNL0[R_ct][box_ct]*growth_zpp,&(fcoll)); } else { fcoll = 1.; @@ -905,7 +905,7 @@ double freq_int_heat[NUM_FILTER_STEPS_FOR_Ts], freq_int_ion[NUM_FILTER_STEPS_FOR } /******** finally compute the redshift derivatives *************/ - evolveInt(zp, curr_delNL0, freq_int_heat, freq_int_ion, freq_int_lya, + evolveInt(zp, arr_num, curr_delNL0, freq_int_heat, freq_int_ion, freq_int_lya, COMPUTE_Ts, ans, dansdz);//, M_TURN,ALPHA_STAR,F_STAR10,T_AST); //update quantities diff --git a/Programs/delta_T.c b/Programs/delta_T.c index ca2f3f8..118e8f7 100755 --- a/Programs/delta_T.c +++ b/Programs/delta_T.c @@ -42,6 +42,11 @@ int main(int argc, char ** argv){ /************ BEGIN INITIALIZATION ****************************/ + if (!T_USE_VELOCITIES & SUBCELL_RSD){ + fprintf(stderr, "'SUBCELL_RSD' uses velocities. You MUST turn on 'T_USE_VELOCITIES' to use 'SUBCELL_RSD'.\nAborting!\n"); + return -1; + } + if (SHARP_CUTOFF) HALO_MASS_DEPENDENT_IONIZING_EFFICIENCY = 1; max = -1e3; min = 1e3; @@ -338,29 +343,53 @@ int main(int argc, char ** argv){ fftwf_execute(plan); fftwf_destroy_plan(plan); fftwf_cleanup(); - if(SUBCELL_RSD) { - + // now add the velocity correction to the delta_T maps min_gradient_component = 1.0; - for (i=0; i max_v_deriv){ + if (dvdx < 0) dvdx = -max_v_deriv; + else dvdx = max_v_deriv; + nonlin_ct++; } + + delta_T[HII_R_INDEX(i,j,k)] /= (dvdx/H + 1.0); + } + } } + } // normalised units of cell length. 0 equals beginning of cell, 1 equals end of cell diff --git a/Programs/find_HII_bubbles.c b/Programs/find_HII_bubbles.c index 4f6b5dd..f531a85 100755 --- a/Programs/find_HII_bubbles.c +++ b/Programs/find_HII_bubbles.c @@ -234,8 +234,8 @@ int main(int argc, char ** argv){ if (INHOMO_RECO) { init_MHR();} if (HALO_MASS_DEPENDENT_IONIZING_EFFICIENCY) { init_21cmMC_arrays(); - Mlim_Fstar = Mass_limit_bisection(M_TURN/50., 1e16, ALPHA_STAR, F_STAR10); - Mlim_Fesc = Mass_limit_bisection(M_TURN/50., 1e16, ALPHA_ESC, F_ESC10); + Mlim_Fstar = Mass_limit(ALPHA_STAR, F_STAR10); + Mlim_Fesc = Mass_limit(ALPHA_ESC, F_ESC10); ION_EFF_FACTOR = N_GAMMA_UV * F_STAR10 * F_ESC10; } else diff --git a/Programs/heating_helper_progs.c b/Programs/heating_helper_progs.c index bb36f02..6dda48d 100755 --- a/Programs/heating_helper_progs.c +++ b/Programs/heating_helper_progs.c @@ -47,7 +47,7 @@ double xion_RECFAST(float z, int flag); double T_RECFAST(float z, int flag); /* Main driver for evolution */ -void evolveInt(float zp, float curr_delNL0[], double freq_int_heat[], +void evolveInt(float zp, int arr_num, float curr_delNL0[], double freq_int_heat[], double freq_int_ion[], double freq_int_lya[], int COMPUTE_Ts, double y[], double deriv[]); //float Mturn, float ALPHA_STAR, float F_STAR10, float T_AST); @@ -293,7 +293,7 @@ double spectral_emissivity(double nu_norm, int flag) ************************** IGM Evolution *************************** This function creates the d/dz' integrands *********************************************************************/ -void evolveInt(float zp, float curr_delNL0[], double freq_int_heat[], +void evolveInt(float zp, int arr_num, float curr_delNL0[], double freq_int_heat[], double freq_int_ion[], double freq_int_lya[], int COMPUTE_Ts, double y[], double deriv[]){ double dfdzp, dadia_dzp, dcomp_dzp, dxheat_dt, ddz, dxion_source_dt, dxion_sink_dt; @@ -345,7 +345,7 @@ void evolveInt(float zp, float curr_delNL0[], double freq_int_heat[], // Usage of 0.99*Deltac arises due to the fact that close to the critical density, the collapsed fraction becomes a little unstable // However, such densities should always be collapsed, so just set f_coll to unity. // Additionally, the fraction of points in this regime relative to the entire simulation volume is extremely small. - splint(Overdense_high_table-1,SFRD_z_high_table[zpp_ct]-1,second_derivs_Nion_zpp[zpp_ct]-1,NSFR_high,curr_delNL0[zpp_ct]*growth_zpp,&(fcoll)); + splint(Overdense_high_table-1,SFRD_z_high_table[arr_num+zpp_ct]-1,second_derivs_Nion_zpp[zpp_ct]-1,NSFR_high,curr_delNL0[zpp_ct]*growth_zpp,&(fcoll)); } else { fcoll = 1.;