Skip to content

Commit

Permalink
Only modify optical depth if we have baryons
Browse files Browse the repository at this point in the history
  • Loading branch information
hersle committed Nov 28, 2024
1 parent a4421bb commit 3c5a383
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ function solve(M::CosmologyModel, pars; aini = 1e-7, solver = Rodas5P(), reltol
check_solution(th_sol.retcode)

# Offset optical depth, so it's 0 today
idx_τ = variable_index(M.th, M.b.rec.τ)
for i in 1:length(th_sol.u)
th_sol.u[i][idx_τ] -= th_sol.u[end][idx_τ]
if have(M.sys, :b)
idx_τ = variable_index(M.th, M.b.rec.τ)
for i in 1:length(th_sol.u)
th_sol.u[i][idx_τ] -= th_sol.u[end][idx_τ]
end
end
else
th_sol = bg_sol
Expand Down
1 change: 1 addition & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function taylor(sys::ODESystem, ϵ, orders)
return ODESystem(eqs, t, vars, pars; initialization_eqs=ieqs, defaults=defs, guesses=guesses, name=sys.name, description=sys.description)
end

have(sys, s) = s in nameof.(ModelingToolkit.get_systems(sys))
have(s) = !isnothing(s) # shorthand for checking if we have a given species

function spline(y, x)
Expand Down

0 comments on commit 3c5a383

Please sign in to comment.