Commit 838f8293 authored by Alessandro 's avatar Alessandro

major update on the structure of the analysis code

parent c9fca371
......@@ -31,6 +31,22 @@ ylbl_db = Dict(
"hh" => [L"$m_etac \sqrt{8t_0}$", L"$m_{J/ψ} \sqrt{8t_0}$", L"$f_{η_c} \sqrt{8t_0}$", L"$f_{J/ψ} \sqrt{8t_0}$"]
)
muh_val =Dict(
#"ens_id"=>[L, beta, is_deg?, m_pi]
"H105" => [],
"H102r001" => [],
"H102r002" => [ 0.2403, 0.228285, 0.252315],
"H101" => [ 0.2505, 0.237975, 0.263025],
"H400" => [ 0.2149, 0.204155, 0.225645],
"N200" => [ 0.18190, 0.172805, 0.190995],
"N202" => [ 0.17590, 0.167105, 0.184695],
"N203" => [ 0.1825, 0.173375, 0.191625],
"N300" => [0.1378, 0.13091, 0.14469],
"J303" => [0.14000, 0.13300, 0.14700]
)
#=
#PDG
const hc = 197.3269804 #MeV fm
const M_values = [1869.65, 2010.26, 1968.34, 2112.2, 2980.3, 3096.916] #MD, MD*, MDs, MDs*, \eta_c, J/\psi (MeV)
......@@ -80,4 +96,5 @@ zm(beta::Float64) = ZM[b_values .== beta][1]
zm_tm(beta::Float64) = ZM_tm[b_values .== beta][1]
t0(beta::Float64) = t0_[b_values2 .== beta][1]
a(beta::Float64) = a_[b_values2 .== beta][1]
za(beta::Float64) = Za[b_values .== beta][1]
\ No newline at end of file
za(beta::Float64) = Za[b_values .== beta][1]
=#
\ No newline at end of file
This diff is collapsed.
# FUNCTIONS
#=
basemodel(x,p) = p[1] .+ p[2] .* x[:,2] .+ p[3] .* x[:,3] .+ p[4] .* x[:,1]
a2phi2(x) = x[:,1] .* x[:,2] # phi2*a^2/8t0
a2phih2(x) = x[:,1] .* x[:,3].^2 # phih^2*a^2/8t0
a4phih4(x) = x[:,1].^(2) .* x[:,3].^4 #phih^4*(a^2/8t0)^2
a4phih4_2(x) = x[:,1].^(2) .* x[:,3].^2 #(a^2/8t0)^2*phih^2
a4cutoff(x) = x[:,1].^(2) #(a^2/8t0)^2
func_list = [a2phi2, a2phih2, a4phih4, a4phih4_2, a4cutoff]
# COMBINATIONS (LINEAR)
func_map = [Bool.([i,j,k,m,n]) for i=0:1 for j=0:1 for k=0:1 for m=0:1 for n=0:1]
npar = length(func_list) # number of extra parameters
n_param = Vector(4:npar+4)
n_param_charm = Vector{Int64}(undef,0)
push!(n_param_charm, 4)
#f_lin definition
f_lin = Vector{Vector{Function}}(undef, npar+1) #f[i][j]-> i: number of extra parameters, j: combinations
f_lin[1] = Vector{Function}(undef, 1)
f_lin[1][1] = (x,p) -> basemodel(x,p)
#f_aux definition -> similar to f_lin but without vectorized opeartors -> useful for plots
f_aux = Vector{Vector{Function}}(undef, npar+1)
f_aux[1] = Vector{Function}(undef, 1)
f_aux[1][1] = (x,p) -> p[1] + p[2] * x[:,2] + p[3] * x[:,3] + p[4] * x[:,1]
#loop over combinations
for n = 2:npar+1
aux = filter(x->sum(x) == n-1, func_map)
println(n_param[n])
f_lin[n] = Vector{Function}(undef, length(aux))
f_aux[n] = Vector{Function}(undef, length(aux))
k = 1
for a in aux
push!(n_param_charm, n_param[n])
#vectorized function
f_lin[n][k] = (x,p) -> basemodel(x,p) .+ sum([p[i+4] for i=1:(n-1)] .* (fill(x,n-1) .|> func_list[a]))
f_aux[n][k] = (x,p) -> f_aux[1][1](x, p) + sum([p[i+4] for i=1:(n-1)] .* (fill(x,n-1) .|> func_list[a]))
k = k + 1
end
end
# COMBINATIONS (NONLINEAR)
f_non_lin = Vector{Vector{Function}}(undef, npar) #f[i][j]-> i: number of extra parameters, j: combinations
f_non_lin_aux = Vector{Vector{Function}}(undef, npar)
n_non_lin_param = Vector(5:npar+4) #param for each non-linear functions
for n = 1:npar
aux = filter(x->sum(x) == n, func_map)
f_non_lin[n] = Vector{Function}(undef, length(aux))
f_non_lin_aux[n] = Vector{Function}(undef, length(aux))
k = 1
for a in aux
#vectorized function
push!(n_param_charm, n_param[n]+1)
f_non_lin[n][k] = (x,p) -> basemodel(x,p) .* (1 .+ sum([p[i+4] for i=1:(n)] .* (fill(x,n) .|> func_list[a])))
f_non_lin_aux[n][k] = (x,p) -> p[1] + p[2] * x[:,2] + p[3] * x[:,3] + p[4] * x[:,1] +
(p[1] + p[2] * x[:,2] + p[3] * x[:,3] + p[4] * x[:,1]) .* sum([p[i+4] for i=1:(n)] .* (fill(x,n) .|> func_list[a]))
k = k + 1
end
end
# APPEND LIN + NONLIN
f = f_lin
append!(f, f_non_lin)
append!(f_aux, f_non_lin_aux)
model_charm = vcat(f...)
model_charm_aux = vcat(f_aux...)
n_param2 = vcat(n_param, n_non_lin_param)
=#
# #=
import Base.+
import Base.*
+(f::Function, g::Function) = (x...) -> f(x...) + g(x...)
+(f::Function, g::Function) = (x...) -> f(x...) .+ g(x...)
*(f::Function, g::Function) = (x...) -> f(x...) * g(x...)
*(f::Function, g::Function) = (x...) -> f(x...) .* g(x...)
# testing model with BDIO parameters to plot automatically the shaded band
function basemodel(x,p)
n=size(x,1)
aux = [p[1] for i in 1:n] .+ [p[2] for i in 1:n].*x[:,2] .+ [p[3] for i in 1:n].*x[:,3] .+ [p[4] for i in 1:n].*x[:,1]
return aux
end
#a^2 cutoff effects
iden(x) = 1
a2phi2(x) = x[:,1] .* x[:,2] #a^2/8t0*phi2
a2phih(x) = x[:,1] .* x[:,3].^2 #a^2/8t0*phih2
#a^4 cutoff effects
a4(x) = x[:,1].^2 #(a^2/8t0)^2
a4phih2(x) = x[:,1].^2 .*x[:,3].^2 #(a^2/8t0)^2*phih^2
a4phih4(x) = x[:,1].^2 .*x[:,3].^4 #(a^2/8t0)^2*phih^4
func_comb_charm = collect(combinations([ a2phi2, a2phih, a4, a4phih2, a4phih4]))
model_charm = Vector{Function}(undef, 0)
push!(model_charm, basemodel)
n_param_charm = Vector{Int64}(undef,0)
push!(n_param_charm, 4)
for i in 1:length(func_comb_charm)
tmp_farr = Vector{Function}(undef,0)
#push!(tmp_farr, basemodel)
for k in 1:length(func_comb_charm[i])
tmp_f = (x,p) -> [p[n_param_charm[1]+k] for n in 1:size(x,1)] .* func_comb_charm[i][k](x)
push!(tmp_farr, tmp_f)
end
push!(model_charm, basemodel + sum(tmp_farr))
push!(n_param_charm, 4+length(func_comb_charm[i]))
push!(n_param_charm, 4+length(func_comb_charm[i]))
fff(x,p) = 1.
aux_non_lin = (x,p) -> basemodel(x,p) .+ [p[1] for l in 1:length(x[:,1])] .+ [p[2] for l in 1:length(x[:,1])].*x[:,2] .+ [p[3] for l in 1:length(x[:,1])].*x[:,3] .+ [p[4] for l in 1:length(x[:,1])].*x[:,1] #.* [ ([p[n_param_charm[1]+k] for n in 1:size(x,1)] .* func_comb_charm[i][k](x)) for k in 1:length(func_comb_charm[i])]
push!(model_charm, basemodel * (fff + sum(tmp_farr)))
end
# =#
#=
# OLD MODELS
basemodel(x,p) = p[1] .+ p[2].*x[:,2] .+ p[3].*x[:,3] .+ p[4].*x[:,1]
#a^2 cutoff effects
a2phi2(x) = x[:,1] .* x[:,2] #a^2/8t0*phi2
a2phih(x) = x[:,1] .* x[:,3].^2 #a^2/8t0*phih2
#a^4 cutoff effects
a4(x) = x[:,1].^2 #(a^2/8t0)^2
a4phih2(x) = x[:,1].^2 .*x[:,3].^2 #(a^2/8t0)^2*phih^2
a4phih4(x) = x[:,1].^2 .*x[:,3].^4 #(a^2/8t0)^2*phih^4
func_comb_charm = collect(combinations([ a2phi2, a2phih, a4, a4phih2, a4phih4]))
# charm functions
model_charm = Vector{Function}(undef, 0)
push!(model_charm, basemodel)
n_param_charm = Vector{Int64}(undef,0)
push!(n_param_charm, 4)
#linear combinations
for i in 1:length(func_comb_charm)
aux_f = (x,p) -> basemodel(x,p) .+ sum([p[4+k] for k in 1:length(func_comb_charm[i])] .* (fill(x,length(func_comb_charm[i])) .|>func_comb_charm[i]))
push!(model_charm, aux_f)
push!(n_param_charm, 4+length(func_comb_charm[i]))
end
#non-linear combinations
for i in 1:length(func_comb_charm)
aux_f = (x,p) -> basemodel(x,p) .* (1 .+ sum([p[4+k] for k in 1:length(func_comb_charm[i])] .* (fill(x,length(func_comb_charm[i])) .|>func_comb_charm[i])))
push!(model_charm, aux_f)
push!(n_param_charm, 4+length(func_comb_charm[i]))
end
# models for decay constants
basemodel_dec(x,p) = p[1] .+ p[2].*x[:,2] .+ p[3]./ sqrt.(x[:,3]) .+ p[4].*x[:,1]
model_decays = Vector{Function}(undef, 0)
push!(model_decays, basemodel_dec)
n_param_decays = Vector{Int64}(undef,0)
push!(n_param_decays, 4)
#linear combinations
for i in 1:length(func_comb_charm)
aux_f = (x,p) -> basemodel_dec(x,p) .+ sum([p[4+k] for k in 1:length(func_comb_charm[i])] .* (fill(x,length(func_comb_charm[i])) .|>func_comb_charm[i]))
push!(model_decays, aux_f)
push!(n_param_decays, 4+length(func_comb_charm[i]))
end
#non-linear combinations
for i in 1:length(func_comb_charm)
aux_f = (x,p) -> basemodel_dec(x,p) .* (1 .+ sum([p[4+k] for k in 1:length(func_comb_charm[i])] .* (fill(x,length(func_comb_charm[i])) .|>func_comb_charm[i])))
push!(model_decays, aux_f)
push!(n_param_decays, 4+length(func_comb_charm[i]))
end
=#
\ No newline at end of file
using Revise, ADerrors, BDIO, juobs, PyPlot, LaTeXStrings, DelimitedFiles, Combinatorics
using LsqFit, juobs.LeastSquaresOptim
include("gevp_types.jl")
include("gevp_reader.jl")
include("gevp_tools.jl")
include("const.jl")
include("gevp_func_comb.jl")
#============= INPUT PAR ===========#
# desktop parameters
#include("/home/alessandro/juobs/constants/juobs_const.jl")
#path_data ="/home/alessandro/Desktop/data/heavy_3pt/3pt"
#path_rw = "/media/alessandro/4277fef2-edc5-4e0d-89cb-f5d1d44fbc8c/data/rwf"
#path_plot = "/home/alessandro/google-drive/phd/secondment/3pf test/analysis/plots"
# macbook parameters
include("/Users/ale/juobs/constants/juobs_const.jl")
path_plot = "/Users/ale/Il mio Drive/phd/analysis/charm_gevp_2022/plots"
path_results = "/Users/ale/Il mio Drive/phd/analysis/charm_gevp_2022/bdio"
# latex-style labels
PyPlot.rc("font", family="sans serif", size=13)
rcParams = PyPlot.PyDict(PyPlot.matplotlib."rcParams")
rcParams["text.usetex"] = false
rcParams["mathtext.fontset"] = "cm"
#rcParams["font.size"] =11
rcParams["axes.labelsize"] =16
const ens_list = ["H101", "H102r002", "H400", "N202", "N203", "N200", "J303", "N300"]
const sector = Dict("pseudo"=>true, "vector"=>true)
# loading ensemble information
ensinfo = Vector{EnsInfo}(undef, length(ens_list))
for i in 1:length(ens_list)
ens = ens_list[i]
try
ensinfo[i] = EnsInfo(ens, ens_db[ens] )
catch
error("The ensemble id ", ens, " was not found in the const.jl ens_db database. Please check the ensemble id or update the database")
end
end
path_dm = "/Users/ale/Desktop/data"
dm = read_BDIO(path_dm, "delta")
t0_shifted = read_BDIO(path_dm, "t0")
#test = read_BDIO(joinpath(path_results,"ps_masses"), "H101" )
#uwerr.(test)
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
@doc raw"""
read_data(ens::String, g1::String="G5", g2::String="G5")
Given the ensemble id and the Dirac structure, this method reads the data in path_data and
returns a CData object. Replicas are automatically detected and loaded if present.
"""
function read_data(ens::String, g1::String="G5", g2::String="G5"; legacy::Bool=false)
path = joinpath(path_data, ens)
rep = filter(x->occursin("mesons.dat", x), readdir(path, join=true))
if length(rep)!=0
length(rep)==1 ? (return read_mesons(rep[1], g1, g2, id=ens, legacy=legacy)) : (return read_mesons(rep, g1, g2, id=ens, legacy=legacy))
else
error("mesons.dat file not found for ensemble ", ens, " in path ", path)
end
end
function read_rw(ens::String)
rep = filter(x->occursin(ens, x), readdir(path_rw, join=true))
if length(rep)!=0
try
length(rep) == 1 ? (return read_ms1(rep[1])) : (return read_ms1.(rep))
catch
length(rep) == 1 && length(rep)!=0 ? (return read_ms1(rep[1], v="1.4")) : (return read_ms1.(rep, v="1.4"))
end
else
error("ms1.dat file not found for ensemble ", ens, " in path ", path_rw)
end
end
function read_mass_dev(ens::String)
rep = filter(x->occursin(ens,x), readdir(path_md, join=true))
try
if length(rep) == 1
return [read_md(rep[1])]
else
return [read_md(rep[1]), read_md(rep[2])]
end
catch
error("pbp.dat file not found for ensemble ", ens, " in path ", path_md)
end
end
function read_t0(ens::String)
path = joinpath(path_data, ens)
rep = filter(x->occursin("ms.dat", x), readdir(path, join=true))
if length(rep)!=0
length(rep) == 1 ? (return read_ms(rep[1])) : (return read_ms.(rep))
else
error("ms.dat file not found for ensemble ", ens, " in path ", path)
end
end
function read_BDIO(path::String, ens_id::String)
file = filter(x->occursin(ens_id, x), readdir(path, join=true))
r = Vector{uwreal}(undef, 0)
fb = BDIO_open(file[1], "r")
BDIO_seek!(fb)
push!(r, read_uwreal(fb))
while BDIO_seek!(fb, 2)
push!(r, read_uwreal(fb))
end
BDIO_close!(fb)
return r
end
function save_bdio_obs(obs::Vector{uwreal}, final_path::String, ens::EnsInfo)
cd(joinpath(path_results,"$(final_path)"))
t = joinpath(pwd(),"$(ens.id)"*"_$(final_path).bdio")
uinfo=0
fb = BDIO_open(t,"w")
for val in obs
write_uwreal(val, fb, uinfo)
uinfo +=1
end
BDIO_close!(fb)
end
\ No newline at end of file
This diff is collapsed.
mutable struct EnsInfo
id::String
L::Int64
beta::Float64
deg::Bool
mpi::Float64
function EnsInfo(ens_id::String, info::Vector{Float64})
id = ens_id
L = info[1]
beta = info[2]
deg = info[3]
mpi = info[4]
return new(id, L, beta, deg, mpi)
end
end
mutable struct MatInfo
ensinfo::EnsInfo
mu::Vector{Float64}
mat_list::Vector{Matrix{uwreal}}
y0::Int64
function MatInfo(_ensinfo::EnsInfo, _mat_list::Array{Array{T,2} where T,1}, _mu::Vector{Float64}, _y0::Int64)
a = new()
a.ensinfo = _ensinfo
a.mu = _mu
a.mat_list = _mat_list
a.y0 = _y0
return a
end
end
mutable struct Cat
obs::Vector{uwreal}
phih::Vector{uwreal}
phih_ph::uwreal
#models::Vector{Vector{Function}}
x_tofit::Array{uwreal}
info::String
fit_param::Vector{Vector{uwreal}} #store all fit parameters
fit_res::Vector{uwreal} # store all fit results
chi2_corr::Vector{Float64} # store all chi2 corrected
n_param::Vector{Int64} # store the number of parameters. Maybe this is redundant
aic::Vector{Float64} # store the AIC value
dof::Vector{Int64}
function Cat(_obs::Vector{uwreal}, _xtofit::Array{uwreal}, _phi_ph::uwreal, _info::String)
a = new()
a.obs = _obs
a.info = _info
a.x_tofit = _xtofit
a.phih_ph = _phi_ph
a.fit_param = Vector{Vector{uwreal}}(undef, 0)
a.fit_res = Vector{uwreal}(undef, 0)
a.chi2_corr = Vector{Float64}(undef, 0)
a.n_param = Vector{Int64}(undef, 0)
a.aic = Vector{Float64}(undef, 0)
a.dof = Vector{Int64}(undef, 0)
return a
end
end
\ No newline at end of file
#H101
ll 58 75
lh 58 70
hh 60 72
t0 20 70
#H102r001
ll 60 85
ls 60 85
lh 60 85
ss 60 85
sh 60 85
hh 60 85
t0 20 80
#H102r002
ll 58 73
ls 60 75
lh 62 80
ss 60 80
sh 62 80
hh 63 80
t0 20 80
#H400
ll 60 75
lh 61 75
hh 66 78
t0 20 80
#N300
ll 80 110
lh 85 115
hh 90 112
t0 20 105
#N200
ll 85 102
ls 82 105
lh 82 99
ss 82 105
sh 83 105
hh 87 100
t0 20 105
#N202
ll 76 105
lh 80 98
hh 90 110
t0 20 110
#N203
ll 85 105
ls 85 105
lh 82 105
ss 85 105
sh 83 110
hh 90 104
t0 20 110
#J303
ll 120 140
ls 123 140
lh 120 140
ss 123 140
sh 123 140
hh 133 170
t0 25 170
#end
#H101
ll 56 70
lh 59 68
hh 68 75
t0 20 70
#H102r001
ll 60 80
ls 60 85
lh 57 70
ss 57 67
sh 60 70
hh 63 79
t0 20 80
#H102r002
ll 60 80
ls 60 85
lh 57 70
ss 57 67
sh 60 70
hh 65 79
t0 20 80
#H400
ll 56 68
lh 60 73
hh 65 78
t0 20 80
#N300
ll 80 110
lh 83 98
hh 90 108
t0 20 105
#N200
ll 75 90
ls 79 95
lh 78 95
ss 79 95
sh 79 95
hh 89 105
t0 20 105
#N202
ll 78 95
lh 78 98
hh 88 110
t0 20 110
#N203
ll 77 95
ls 76 95
lh 78 95
ss 76 95
sh 80 100
hh 89 102
t0 20 110
#J303
ll 116 130
ls 118 135
lh 120 135
ss 118 140
sh 123 140
hh 130 155
t0 25 170
#end
#H101
ll 66 76
lh 66 80
hh 64 85
t0 20 80
#H102r001
ll 60 85
ls 60 85
lh 60 85
ss 60 85
sh 60 85
hh 68 85
t0 20 80
#H102r002
ll 65 72
ls 67 74
lh 67 75
ss 67 74
sh 68 81
hh 68 85
t0 20 80
#H400
ll 65 88
lh 67 80
hh 67 85
t0 20 80
#N300
ll 80 110
lh 92 115
hh 92 115
t0 20 105
#N200
ll 85 105
ls 85 105
lh 88 99
ss 85 105
sh 89 105
hh 87 115
t0 20 105
#N202
ll 80 110
lh 87 100
hh 90 115
t0 20 110
#N203
ll 85 105
ls 85 105
lh 88 100
ss 85 105
sh 88 110
hh 88 110
t0 20 110
#J303
ll 120 140
ls 123 140
lh 125 145
ss 123 140
sh 130 145
hh 133 175
t0 25 170
#end
#H101
ll 66 73
lh 66 71
hh 68 80
t0 20 80
#H102r001
ll 60 85
ls 60 85
lh 60 85
ss 60 85
sh 60 85
hh 60 85
t0 20 80
#H102r002
ll 60 69
ls 60 68
lh 63 68
ss 60 67
sh 68 73
hh 70 85
t0 20 80
#H400
ll 60 68
lh 68 74
hh 68 80
t0 20 80
#N300
ll 80 110
lh 88 100
hh 95 115
t0 20 105
#N200
ll 82 95
ls 85 95
lh 85 99
ss 85 95
sh 86 95
hh 92 110
t0 20 105
#N202
ll 84 95
lh 87 97
hh 92 110
t0 20 110
#N203
ll 85 95
ls 85 95
lh 85 95
ss 85 95
sh 86 100
hh 89 110
t0 20 110
#J303
ll 120 140
ls 123 140
lh 123 140
ss 123 140
sh 123 145
hh 133 165
t0 25 170
#end
......@@ -135,7 +135,6 @@ function get_hh(mu_list, obs::Vector{uwreal}, deg::Bool)
return obs_hh
end
function comp_mat(ensinfo::EnsInfo, tot_obs::Vector{juobs.Corr}, tau::Int64)
#wanted_corr = relevant_corr(ensinfo, tot_obs)
mat_info = Vector{MatInfo}(undef, length(tot_obs))
for i = 1:length(tot_obs)
a11 = tot_obs[i].obs[1:end-1-2*tau]
......@@ -146,6 +145,21 @@ function comp_mat(ensinfo::EnsInfo, tot_obs::Vector{juobs.Corr}, tau::Int64)
end
return mat_info
end
function comp_mat_multigamma(ensinfo::EnsInfo,tot11::Vector{juobs.Corr}, tot12::Vector{juobs.Corr}, tot22::Vector{juobs.Corr})
mu = getfield.(tot11,:mu)
y0 = getfield.(tot11,:y0) .+1
mat_info = Vector{MatInfo}(undef, length(mu))
for i = 1:length(mu)
a11 = tot11[i].obs[y0[i]:end-1]
a12 = tot12[i].obs[y0[i]:end-1]
a22 = tot22[i].obs[y0[i]:end-1]
#res[i] = infoMatt(a11, a12, a22)
aux = juobs.get_matrix([a11, a22], [a12])
mat_info[i] = MatInfo(ensinfo, aux, mu[i], y0[i])
end
return mat_info
end
function comp_mat_lukas(ensinfo::EnsInfo, tot_obs::Vector{juobs.Corr}, dim::Int64)
mat_info = Vector{MatInfo}(undef, length(tot_obs))
for i in 1:length(tot_obs)
......@@ -160,8 +174,35 @@ function comp_mat_lukas(ensinfo::EnsInfo, tot_obs::Vector{juobs.Corr}, dim::Int6
end
return mat_info
end
function gevp_mass(mat_obs::Vector{MatInfo}; t0::Int64=2, delta_t_in::Array{Int64}=[2,5], wpm::Union{Nothing, Dict{Int64,Vector{Float64}}}=nothing)
y0s = getfield.(mat_obs, :y0)
function gevp_mass(mat_obs::Vector{MatInfo}; t0::Int64=2,pl::Bool=true, wpm::Union{Nothing, Dict{Int64,Vector{Float64}}}=nothing)
y0s = getfield.(mat_obs, :y0)
mu_list = getfield.(mat_obs, :mu)
plat_en0 = Vector{uwreal}(undef, length(mat_obs))
plat_en1 = Vector{uwreal}(undef, length(mat_obs))
for i in 1:length(mat_obs)
mat = getfield(mat_obs[i], :mat_list)[y0s[i]+1:end-1] #matrices to diagonalise for a given sector [i]
evals = getall_eigvals(mat, t0)
en = energies(evals, wpm=wpm) #ground and excited state energy
plat = select_plateau(mat_obs[i].ensinfo, mu_list, path_plat_meff)[i] .- y0s[i]
println(plat)
plat_en0[i] = plat_av(en[1], plat)
if pl
uwerr(plat_en0[i])
xx = collect(1:length(en[1]))
v = value(plat_en0[i])
e = err(plat_en0[i])
errorbar(xx, value.(en[1]), err.(en[1]), fmt="s")
fill_between(plat[1]:plat[2], v-e, v+e )
ylim(v*0.95, v*1.05)
display(gcf())
close()
end
end
return plat_en0
end
# function used in lattice conf 2021 with fits to the effective energies
function gevp_mass_old(mat_obs::Vector{MatInfo}; t0::Int64=2, delta_t_in::Array{Int64}=[2,5], wpm::Union{Nothing, Dict{Int64,Vector{Float64}}}=nothing)
y0s = getfield.(mat_obs, :y0)
mu_list = getfield.(mat_obs, :mu)
plat_en0 = Vector{uwreal}(undef, length(mat_obs))
plat_en1 = Vector{uwreal}(undef, length(mat_obs))
......@@ -175,7 +216,7 @@ function gevp_mass(mat_obs::Vector{MatInfo}; t0::Int64=2, delta_t_in::Array{Int6
temp = fit_mass(en[1],t_in=t, wpm=wpm)
push!(aux_mass, temp)
catch
plat = select_plateau(mat_obs[i].ensinfo, mu_list)[end-2] .- y0s[i]
plat = select_plateau(mat_obs[i].ensinfo, mu_list, path_plat_meff)[end-2] .- y0s[i]
println(plat)
temp = plat_av(en[1], plat)
uwerr(temp)
......@@ -204,12 +245,12 @@ function gevp_dec(mat_obs::Vector{MatInfo}, mass::Vector{uwreal}; t0::Int64=2, w
mat = getfield(mat_obs[i], :mat_list)[y0s[i]+2:end-1] #matrices to diagonalise for a given sector [i]
evecs = getall_eig(mat, t0)
elem = mat_elem(evecs, mat, mass[i], n) #ground and excited state energy
plat = select_plateau(mat_obs[i].ensinfo, mu_list)[end] .- y0s[i]
plat = select_plateau(mat_obs[i].ensinfo, mu_list, path_plat_dec)[i] .- y0s[i]
try
if pseudo
plat_dec0[i] = -dec(elem, plat, mass[i], mu_list[i], pl=pl, wilson=wilson)
plat_dec0[i] = dec(elem, plat, mass[i], mu_list[i], pl=pl, wilson=wilson)
else
plat_dec0[i] = -vec_dec(elem, plat, mass[i], pl=pl)
plat_dec0[i] = vec_dec(elem, plat, mass[i], pl=pl)
end
catch
println("Decay constant for the ensemble ", mat_obs[i].ensinfo.id, " failed in the sector ", mu_list[i], " pseudo sector?", pseudo)
......@@ -277,6 +318,7 @@ function dec(mat_elem::Vector{uwreal}, plat::Array{Int64}, mass::uwreal, mu::Vec
if !wilson
return sqrt(2/ (mass)^3) * sum(mu)* aux
else
println("ciao its wilson")
return sqrt(2/mass) * aux
end
end
......@@ -328,7 +370,7 @@ function select_plateau(ensinfo::EnsInfo)
plat[2] = plat_[n,2]
return plat
end
function select_plateau(ensinf::EnsInfo, mu_list)
function select_plateau(ensinf::EnsInfo, mu_list, path_plat)
ens =ensinf.id
deg = ensinf.deg
mul, mus, muh = get_mu(mu_list, deg)
......@@ -425,4 +467,16 @@ function syst_av(syst_err::Vector{Float64})
aux = sum(syst_err.^2)
return sqrt(aux)
end
function read_BDIO(path::String, ens_id::String)
file = filter(x->occursin(ens_id, x), readdir(path, join=true))
println(file)
r = Vector{uwreal}(undef, 0)
fb = BDIO_open(file[1], "r")
BDIO_seek!(fb)
push!(r, read_uwreal(fb))
while BDIO_seek!(fb, 2)
push!(r, read_uwreal(fb))
end
BDIO_close!(fb)
return r
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment