Hi there
I have the following code, which, if necessary I might strip down.
using Parameters
using Unitful
@with_kw struct EosConst{T<:Real}
w_0::T = -1.0
end
@with_kw struct EosCPL{T<:Real}
w_0::T = -1
w_a::T = 0
end
Eos = Union{EosConst, EosCPL}
@with_kw struct CosmoModel{T1<:Real,T2<:Unitful.Quantity,T3<:Eos}
h_Hubble::T1 = 0.69
Ω_m0::T1 = 0.3
T_γ0::T2 = 2.75u"K"
Ω_γ0::T1 = 0.0
Ω_ν0::T1 = 0.0
Ω_r0::T1 = Ω_γ0 + Ω_ν0; @assert Ω_r0 == Ω_γ0 + Ω_ν0
Ω_n0::T1 = Ω_m0 + Ω_r0; @assert Ω_n0 == Ω_m0 + Ω_r0
Ω_exo0::T1 = 0.7
Ω_tot0::T1 = Ω_n0 + Ω_exo0; @assert Ω_tot0 == Ω_n0 + Ω_exo0
Ω_K0::T1 = 0.0; @assert Ω_K0 == 1 - Ω_tot0
eos::T3 = EosConst()
end
function E_Hubble(z; cosmo::CosmoModel)
@unpack Ω_m0, Ω_r0, Ω_exo0, Ω_K0, eos = cosmo
return sqrt(Ω_m0*(1 + z)^3 + Ω_r0*(1 + z)^4 + Ω_K0*(1 + z)^2 + Ω_exo0*(1 + z)^(3*(1 + eos.w_0)))
end
When I issue the commands:
c = CosmoModel()
E_Hubble(0.0, c)
the first one works ok, but the second one spits the following:
ERROR: MethodError: no method matching E_Hubble(::Float64, ::CosmoModel{Float64,Quantity{Float64,𝚯,Unitful.FreeUnits{(K,),𝚯,nothing}},EosConst{Float64}})
Closest candidates are:
E_Hubble(::Any; cosmo) at /home/orca/Dropbox/research/modified_gravity/programs/mocalvao/julia/cosmo/src/background.jl:32
Stacktrace:
[1] top-level scope at REPL[7]:1
What am I doing wrong?
4 posts - 2 participants