diff --git a/scripts/dev_fd_quadrature.jl b/scripts/dev_fd_quadrature.jl index 40c9d44..f2d0902 100644 --- a/scripts/dev_fd_quadrature.jl +++ b/scripts/dev_fd_quadrature.jl @@ -125,8 +125,8 @@ function ρPold(a,par::AbstractCosmoParams) m = par.Σm_ν qmin=1e-18 qmax=1e1 - ρ = 4π * a^(-4) * quadgk(q -> q^2 * √( q^2 + (a*m)^2 ) * f0(q,par) ,qmin, qmax,rtol=1e-6)[1] - P = 4π/3 * a^(-4) * quadgk(q -> q^2 * q^2 /√( q^2 + (a*m)^2) * f0(q,par), qmin, qmax,rtol=1e-6)[1] + ρ = 4π * a^(-4) * quadgk(q -> q^2 * √( q^2 + (a*m)^2 ) * f0(q) ,qmin, qmax,rtol=1e-6)[1] + P = 4π/3 * a^(-4) * quadgk(q -> q^2 * q^2 /√( q^2 + (a*m)^2) * f0(q), qmin, qmax,rtol=1e-6)[1] return ρ,P#,norm end H₀(par::AbstractCosmoParams) = par.h * km_s_Mpc_100 diff --git a/src/perturbations.jl b/src/perturbations.jl index ee1d12e..50de5b9 100644 --- a/src/perturbations.jl +++ b/src/perturbations.jl @@ -89,7 +89,7 @@ function boltsolve_rsa(hierarchy::Hierarchy{T}, ode_alg=KenCarp4(); reltol=1e-6, x_grid = hierarchy.bg.x_grid pertlen = 2(hierarchy.ℓᵧ+1)+(hierarchy.ℓ_ν+1)+(hierarchy.ℓ_mν+1)*hierarchy.nq+5 results=zeros(pertlen,length(x_grid)) - for i in 1:length(x_grid) results[:,i] = perturb(x_grid[i]) end + for i in eachindex(x_grid) results[:,i] = perturb(x_grid[i]) end #replace the late-time perts with RSA approx (assuming we don't change rsa switch) #this_rsa_switch = x_grid[argmin(abs.(hierarchy.k .* hierarchy.bg.η.(x_grid) .- 45))] @@ -102,7 +102,7 @@ function boltsolve_rsa(hierarchy::Hierarchy{T}, ode_alg=KenCarp4(); reltol=1e-6, x_grid_rsa = x_grid[x_grid.>this_rsa_switch] results_rsa = results[:,x_grid.>this_rsa_switch] #(re)-compute the RSA perts so we can write them to the output vector - for i in 1:length(x_grid_rsa) + for i in eachindex(x_grid_rsa) rsa_perts!(view(results_rsa,:,i),hierarchy,x_grid_rsa[i]) #to mutate need to use view... end results[:,x_grid.>this_rsa_switch] = results_rsa diff --git a/test/runtests.jl b/test/runtests.jl index 85a9817..e4899b1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -140,10 +140,10 @@ end class_eta = bg.η.(class_x) - TOL = 1e-3 - @test all(abs.(itphibolt.(class_x) ./ itpphiclass.(class_x) .- 1) .< TOL) - @test all(abs.(-itdeltbbolt.(class_x) ./ itdeltbclass.(class_x) .- 1) .< TOL) - @test all(abs.(itpgambolt.(class_x) ./ itpgambolt.(class_x) .- 1) .< TOL) + reltol = 1e-3 + @test all(abs.(itphibolt.(class_x) ./ itpphiclass.(class_x) .- 1) .< reltol) + @test all(abs.(-itdeltbbolt.(class_x) ./ itdeltbclass.(class_x) .- 1) .< reltol) + @test all(abs.(itpgambolt.(class_x) ./ itpgambolt.(class_x) .- 1) .< reltol) end @testset "cell_camb_1e-1" begin @@ -177,9 +177,9 @@ end itpee_b = LinearInterpolation(ℓs, @.(ℓfac * Cℓee)) #test line - TOL = 1.1e-1 + reltol = 1.1e-1 #FIXME should really do this on the finer of the two grids but need to rerun... - @test all(abs.(itptt_b.(ℓs) ./ itptt.(ℓs) .- 1) .< TOL) + @test all(abs.(itptt_b.(ℓs) ./ itptt.(ℓs) .- 1) .< reltol) # all(abs.(itpte_b.(ℓs) .- itpte.(ℓs) .- 1) .< TOL) # zero-crossing will be an issue here, do diff check - @test all(abs.(itpee_b.(ℓs) ./ itpee.(ℓs) .- 1) .< TOL) + @test all(abs.(itpee_b.(ℓs) ./ itpee.(ℓs) .- 1) .< reltol) end