# # background_phi_scf = fig2.add_subplot(111) background_phi_scf.plot(background_rho_scf / background_rho_tot, background_tau, linewidth=2, label=r'$f_{\rm EDE}$') background_phi_scf.set_ylim(tau[0], tau[-1]) background_phi_scf.set_yscale('log') background_phi_scf.set_xlabel(r'$f_{\rm EDE}(\tau)$') background_phi_scf.set_xticks([0.0, 0.05, 0.1]) background_phi_scf.set_ylabel(r'$\tau \,\,\, \mathrm{[Mpc]}$', labelpad=-20) background_phi_scf.invert_yaxis() # fig_delta_phi_scf = ax_delta_phi_scf.pcolormesh(K,T,np.log10(delta_phi_scf*delta_phi_scf*K*K*K/2/np.pi/np.pi*A_s*(K/K_star)**(n_s-1)),cmap='coolwarm',vmin=np.log10(delta_phi_scf.min()*delta_phi_scf.min()*K.min()*K.min()*K.min()/2/np.pi*A_s*(K.min()/K_star)**(n_s-1)), vmax=np.log10(delta_phi_scf.max()*delta_phi_scf.max()*K.max()*K.max()*K.max()/2/np.pi*A_s*(K.max()/K_star)**(n_s-1))) #,shading='gouraud') # fig_delta_phi_scf = ax_delta_phi_scf.pcolormesh(K,T,np.log10(delta_phi_scf*delta_phi_scf*A_s*(K/K_star)**(n_s-1)),cmap='coolwarm',vmin=np.log10(delta_phi_scf.min()*delta_phi_scf.min()*A_s*(K.min()/K_star)**(n_s-1)), vmax=np.log10(delta_phi_scf.max()*delta_phi_scf.max()*A_s*(K.max()/K_star)**(n_s-1))) #,shading='gouraud') # ##delta_phi power spectrum phi_enveloppe = Theta_initial * 10**M.log10_f_axion() * ( 1.7 / (10**log10_axion_ac * background_z_at_tau(T)))**(-3. * (1 + wn) / 2 / n_axion) print 10**M.log10_f_axion(), 10**M.log10_m_axion( ), Theta_initial * 10**M.log10_f_axion() * 2**(-3. * (1 + wn) / 2 / n_axion) background_phi_scf_v2 = background_phi_scf.twiny() background_phi_scf_v2.set_ylim(tau[0], tau[-1]) # background_phi_scf_v2.set_xlim(phi_enveloppe[0],2*phi_enveloppe[-1]) background_phi_scf_v2.plot(phi_enveloppe / (10**M.log10_f_axion()), tau, 'r--', linewidth=2) background_phi_scf_v2.set_xlabel(r'$\Theta=\phi/f_a$', fontsize=18)
cosmo.compute() # solve physics m_axion = 10**cosmo.log10_m_axion()*h*100/_c_ print "m_axion %f"%(m_axion) # k_res_analytical = 0.79*m_axion*Theta_initial[j]*(10**ac[i]) k_res_analytical = 0.79*m_axion*Theta_initial[j]*(10**ac[i]) one_time = cosmo.get_transfer(0) # transfer functions at each time tau k = one_time['k (h/Mpc)'] delta_phi_scf = np.abs(one_time['delta_phi_scf']) ##evaluated today k_of_delta = interp1d(delta_phi_scf,k) background = cosmo.get_background() # load background table background_tau = background['conf. time [Mpc]'] # read conformal times in background table background_z = background['z'] # read redshift background_Om_scf = background['(.)Omega_scf'] # read redshift background_z_at_tau = interp1d(background_tau,background_z) phi_enveloppe = Theta_initial[j]*10**cosmo.log10_f_axion()*(2/(10**ac[i]))**(-3.*(1+wn)/2/n_axion) ##evaluated today delta_max = np.sqrt(delta_phi_scf*delta_phi_scf*A_s*(k/K_star)**(n_s-1))/(phi_enveloppe) print max(delta_max), np.where(delta_max==max(delta_max)) k_res_numerical = k[np.where(delta_max==max(delta_max))]*h ##evaluated today print "k_res analytical %f Mpc-1, k_res numerical %f Mpc-1"%(k_res_analytical,k_res_numerical) except CosmoComputationError: # this happens when CLASS fails print "bug!" k_res_numerical = 0 k_nl_scf[i][j] = 100 #arbitrary large number: bug z_nl_scf[i][j] = 0 #arbitrary large number: bug Omega_nl_scf[i][j] = 1e-30 #arbitrary small number ##2em iteration: find z_nl at which k_res becomes non linear cosmo.empty() cosmo.struct_cleanup() if k_res_numerical != 0:
for j in range(N): print i, j # going over a_c and Om_fld values params['log10_fraction_axion_ac'] = fEDE[j] cosmo.empty() cosmo.struct_cleanup() # ensuring memory isn't being eaten up # try to solve with a certain cosmology, no worries if it cannot try: cosmo.set( params) # Set the parameters to the cosmological code cosmo.compute() # solve physics alpha[i][j] = (cosmo.log10_f_axion()) mu[i][j] = (cosmo.log10_m_axion()) # zc[i][j] = np.log10(cosmo.zc()) except CosmoComputationError: # this happens when CLASS fails pass # eh, don't do anything print('fEDE = %e \t ac = %e \t alpha = %.5f \t mu = %.5f\n' % (fEDE[i], ac[j], alpha[i][j], mu[i][j])) # print('fEDE = %e \t mu = %e \t alpha = %.5f \t zc = %.5f\n' %(fEDE[i], mu[j], alpha[i][j], zc[i][j])) # # test that stuff is working by plotting the fluid energy density # bg = cosmo.get_background() # plt.loglog( bg['z'], bg['(.)rho_fld[0]']) # plt.show()