Skip to content

Commit

Permalink
Fix solution indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
hersle committed Dec 6, 2024
1 parent 259a549 commit 4201a56
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
5 changes: 0 additions & 5 deletions docs/src/spectra.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ Pk_halofit(k) = MatterPower.halofit(Pk, halofit_params, Ωm0, ustrip(k))
plot!(log10.(ks*u"Mpc"), log10.(Pk_halofit.(ustrip(ks))); label = "non-linear (halofit / MatterPower.jl)", legend_position = :bottomleft)
```

### Non-linear

```@example
```

## CMB power spectra

```@docs
Expand Down
11 changes: 3 additions & 8 deletions src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,8 @@ function Base.getindex(sol::CosmologySolution, i::SymbolicIndex)
return sol.th[i]
end
end
# TODO: unite above and below!
function Base.getindex(sol::CosmologySolution, i::SymbolicIndex, j = :)
if ModelingToolkit.isparameter(i) && i !== t && (j == :) # don't catch independent variable as parameter
return sol.th.ps[i] # assume all parameters are in background/thermodynamics # TODO: index sol directly?
else
return stack(sol.th[i, j])
end
function Base.getindex(sol::CosmologySolution, i::SymbolicIndex, j)
return stack(sol.th[i, j])
end
Base.getindex(sol::CosmologySolution, i::Int, j::SymbolicIndex, k = :) = sol.pts[i][j, k]
Base.getindex(sol::CosmologySolution, i, j::SymbolicIndex, k = :) = [stack(sol[_i, j, k]) for _i in i]
Expand Down Expand Up @@ -327,7 +322,7 @@ function shoot(M::CosmologyModel, pars_fixed, pars_varying, conditions; solver =
function f(vals_varying, _)
pars = merge(pars_fixed, Dict(keys(pars_varying) .=> vals_varying))
sol = solve(M, pars; kwargs...) # solve cosmology
return sol[funcs][:, end] # evaluate all expressions at final time (e.g. today)
return sol[funcs, :][:, end] # evaluate all expressions at final time (e.g. today)
end

guess = collect(values(pars_varying))
Expand Down

0 comments on commit 4201a56

Please sign in to comment.