Skip to content
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

Fix flavour fields #5

Merged
merged 3 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Matter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ function oscprob(U, H, energy::Vector{T}, path::Vector{Path}; zoa=0.5, anti=fals
end
end
P = map(x -> abs.(x) .^ 2, A)
AxisArray(P; Energy=energy, Path=path, InitFlav=NeutrinoFlavour.(1:3), FinalFlav=NeutrinoFlavour.(1:3))
flavrange = _make_flavour_range(first(size(U)))
AxisArray(P; Energy=energy, Path=path, InitFlav=flavrange, FinalFlav=flavrange)
end

const oscprob(U, H, energy::T, path::Vector{Path}; zoa=0.5, anti=false) where {T <: Real} = oscprob(U, H, [energy], path; zoa=zoa, anti=anti)
Expand Down
12 changes: 11 additions & 1 deletion src/Oscillation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,15 @@ function _oscprobampl(U, H, energy, baseline)
U * exp(-1im * H_diag) * adjoint(U)
end

function _make_flavour_range(size::Integer)
if size <= 3
return NeutrinoFlavour.(1:size)
else
return [NeutrinoFlavour.(1:3)..., 4:size...]
end
end


"""
$(SIGNATURES)

Expand All @@ -289,7 +298,8 @@ function oscprob(U, H, energy::Vector{T}, baseline::Vector{S}) where {T,S <: Rea
tmp = map(x->abs.(_oscprobampl(U, H, first(x), last(x))).^2, combinations)
P = reshape(hcat(collect(Iterators.flatten(tmp))), s...)
P = permutedims(P, (3,4,1,2))
AxisArray(P; Energy=energy, Baseline=baseline, InitFlav=NeutrinoFlavour.(1:3), FinalFlav=NeutrinoFlavour.(1:3))
flavrange = _make_flavour_range(first(size(U)))
AxisArray(P; Energy=energy, Baseline=baseline, InitFlav=flavrange, FinalFlav=flavrange)
end

const oscprob(U, H, energy::T, baseline::Vector{S}) where {S,T <: Real} = oscprob(U, H, [energy], baseline)
Expand Down
20 changes: 20 additions & 0 deletions test/oscillation_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ for i in 3:100
end
end

osc = OscillationParameters(2)
mixingangle!(osc, 1=>2, 0.59)
masssquareddiff!(osc, 1=>2,-7.39e-5)
test_values = Neurthino.oscprob(osc, 1, 10000)[Energy=1, Baseline=1]
@test test_values[1,1] ≈ 0.4454 atol=0.01

osc = OscillationParameters(4)
mixingangle!(osc, 1=>2, 0.59)
mixingangle!(osc, 1=>3, 0.15)
mixingangle!(osc, 2=>3, 0.84)
mixingangle!(osc, 1=>4, 0.2)
mixingangle!(osc, 2=>4, 0.3)
mixingangle!(osc, 3=>4, 0.4)
masssquareddiff!(osc, 2=>3, -2.523e-3)
masssquareddiff!(osc, 1=>2,-7.39e-5)
masssquareddiff!(osc, 3=>4, -1)

test_values = Neurthino.oscprob(osc, 1, 10000)[Energy=1, Baseline=1]
@test test_values[1,1] ≈ 0.3373 atol=0.01

h5open("data/refdata.h5", "r") do file
# Nu-Fit v5.0 Values
osc_nh = OscillationParameters(3);
Expand Down