-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New RECFAST doesn't like dual-numbers #88
Comments
Thanks Jaime! @xzackli I can fix this if I switch the types of the recfast struct arguments to ::Float64 for all the things not involving CosmoPararms. Is there a reason e.g. m_H is of type ::T in your new version? |
cf this version of the file (which works) |
I think the issue is that the new RECFAST wants the background as a non-kwarg, 𝕣 = Bolt.RECFAST(bg; Yp=𝕡.Y_p, OmegaB=𝕡.Ω_b,OmegaG=𝕡.Ω_r) |
We need to fix this, something here is not right. Let's chat more about this, I'll get Uros to get me onto BCCP slack. |
Just taking derivatives wrt Here is a plot and gist comparing these things: https://gist.github.com/jmsull/d00eebca111eccaa6f93349cca9b35d5 For the Julia code I just minimially modified the plot_deriv_pk.jl examples/ file: using Bolt,ForwardDiff,DelimitedFiles
function pkc(Ω_c::DT,k_grid) where DT
𝕡 = CosmoParams{DT}(Ω_c=Ω_c)
bg = Background(𝕡; x_grid=-20.0:0.01:0.0, nq=15)
𝕣 = Bolt.RECFAST(bg; Yp=𝕡.Y_p, OmegaB=𝕡.Ω_b, OmegaG=𝕡.Ω_r)
ih = IonizationHistory(𝕣, 𝕡, bg)
nk=length(k_grid)
a=zeros(DT,nk)
for i = 1:nk
a[i] = plin(k_grid[i],𝕡,bg,ih)[1] #not sure why this is returning a vector and not a T...
end
return a
end
Ωc0 = 0.27-0.046
𝕡 = CosmoParams(Ω_c=Ωc0,
h = 0.7 ,
Ω_r = 5.042e-5 ,
Ω_b = 0.046 ,
A = 2.097e-9 ,
n = 1.0 ,
Y_p = 0.24,
N_ν = 3.046 ,
Σm_ν = 0.0
)
bg = Background(𝕡; x_grid=-20.0:0.01:0.0, nq=15)
kmin,kmax= 0.1bg.H₀*100,5000bg.H₀
k_grid = log10_k(kmin,kmax,33)
k_grid_hMpc = k_grid/(bg.H₀*3e5/100)
fc(Ω_c) = pkc(Ω_c,k_grid)
pk = fc(Ωc0)
∂pk = ForwardDiff.derivative(fc, Ωc0)
Δ = 1e-2
finitediff_∂pk = (fc(Ωc0 + Δ) .- fc(Ωc0 - Δ)) ./ 2Δ
writedlm("/Users/jsull/Documents/berkeley/bolt/compare/bolt_camb_class_bolt_dOmegac.dat",
[k_grid_hMpc, pk, ∂pk, finitediff_∂pk]) |
Gonna close this given my test here - there may be a problem with the Limberjack implementation that causes the discrepancy above |
Dear Jamie and Zack
After the latest update I get the following error when I try to ForwardDiff.jl through RECFAST:
Code to replicate the error:
(not exactly what I am running but should the trick)
The speed up is amazing though!!!
Thanks a lot,
Jaime
The text was updated successfully, but these errors were encountered: