Commit b62250a8 authored by Javier's avatar Javier

Merge branch 'alessandro'

parents 3b6a197c 47f84fe6
using ADerrors
#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)
const M_error = [0.05, 0.05, 0.07, 0.4, 1.2, 0.011]
const M_values = [1869.65, 2010.26, 1968.34, 2112.2, 2980.3, 3096.916, 5279.65] #MD, MD*, MDs, MDs*, \eta_c, J/\psi , MB (MeV)
const M_error = [0.05, 0.05, 0.07, 0.4, 1.2, 0.011, 0.12]
#1802.05243
const b_values = [3.40, 3.46, 3.55, 3.70, 3.85]
const ZM_data = [1.9684, 1.9935, 2.0253, 2.0630, 2.0814]
......@@ -12,6 +12,11 @@ const ZM_tm_error = [42, 33, 42, 48, 55] .* 1e-4
# 1808.09236
const ZA_data = [0.75642, 0.76169, 0.76979, 0.78378, 0.79667]
const ZA_err = [72, 93, 43, 47, 47] .*1e-5
const ZV_data = [0.72259, 0.72845, 0.73886, 0.75574, 0.77074]
const ZV_err = [74, 89, 46, 48, 49] .* 1e-5
#2005.01352
const ZS_over_ZP_data = [1.3497, 1.2914, 1.2317, 1.1709, 1.1343]
const ZS_over_ZP_err = [83, 64, 48, 23, 25 ] .* 1e-4
#1608.08900
const b_values2 = [3.40, 3.46, 3.55, 3.70]
const t0_data = [2.86, 3.659, 5.164, 8.595]
......@@ -19,18 +24,31 @@ const t0_error = [11, 16, 18, 29] .* 1e-3
const t0_ph_value = [0.413]
const t0_ph_error = ones(1,1) .* 5e-3
## taking into account correlations in zm_tm
C = [[0.375369e-6, 0.429197e-6, -0.186896e-5] [0.429197e-6, 0.268393e-4, 0.686776e-4] [-0.186896e-5, 0.686776e-4, 0.212386e-3]]
z = cobs([0.348629, 0.020921, 0.070613], C, "z")
ZP(b) = z[1] + z[2] * (b - 3.79) + z[3] * (b - 3.79)^2
Mrat = uwreal([.9148, 0.0088], "M/mhad")
zm_tm_covar(b) = Mrat / ZP(b)
##
#Cov matrices
const C1 = zeros(5, 5)
const C2 = zeros(5, 5)
const C3 = zeros(4, 4)
const C4 = zeros(6, 6)
const C4 = zeros(7, 7)
const C5 = zeros(5, 5)
for i = 1:6
const C6 = zeros(5, 5)
const C7 = zeros(5, 5)
for i = 1:7
C4[i, i] = M_error[i] ^ 2
if i<=5
C1[i, i] = ZM_error[i] ^ 2
C2[i, i] = ZM_tm_error[i] ^ 2
C5[i, i] = ZA_err[i]^2
C5[i, i] = ZA_err[i] ^ 2
C6[i, i] = ZS_over_ZP_err[i] ^ 2
C7[i, i] = ZV_err[i] ^ 2
if i <= 4
C3[i, i] = t0_error[i] ^ 2
end
......@@ -44,9 +62,13 @@ const t0_ph = cobs(t0_ph_value, t0_ph_error .^ 2, "sqrt(8 t0) (fm)")
const a_ = t0_ph ./ sqrt.(8 .* t0_)
const M = cobs(M_values, C4, "charmed meson masses")
const Za = cobs(ZA_data, C5, "ZA")
const Zv = cobs(ZV_data, C7, "ZV")
const ZS_over_ZP = cobs(ZS_over_ZP_data, C6, "ZS over ZP")
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]
zv(beta::Float64) = Zv[b_values .== beta][1]
zs_over_zp(beta::Float64) = ZS_over_ZP[b_values .== beta][1]
\ No newline at end of file
......@@ -138,11 +138,11 @@ function comp_energy(tot11::Array{Array{juobs.Corr}}, tot12::Array{Array{juobs.C
evec = Array{Array{}}(undef, length(aux_mat))
for i = 1:length(aux_mat)
mat_obs = getfield(aux_mat[i], :mat)[y0+1:end-1]
evalues, eigvec = uwgevp_tot(mat_obs, tnot, evec=true, iter=50)
res_en[i] = infoEn(energies(evalues), aux_mat[i])
eigvec = uwgevp_tot(mat_obs, delta_t=3)
#res_en[i] = infoEn(energies(evalues), aux_mat[i])
evec[i] = eigvec
end
return res_en, evec
return evec
end
end
function comp_energy(tot11::Array{Array{juobs.Corr}}, tot12::Array{Array{juobs.Corr}}, tot13::Array{Array{juobs.Corr}}, tot22::Array{Array{juobs.Corr}}, tot33::Array{Array{juobs.Corr}}, tot23::Array{Array{juobs.Corr}}, evec::Bool=false; tnot::Int64=2)
......@@ -160,12 +160,12 @@ function comp_energy(tot11::Array{Array{juobs.Corr}}, tot12::Array{Array{juobs.C
evec = Array{Array{}}(undef, length(aux_mat))
for i = 1:length(aux_mat)
mat_obs = getfield(aux_mat[i], :mat)[y0+1:end-1]
evalues, eigvec = uwgevp_tot(mat_obs, tnot, evec=true)
eigvec = uwgevp_tot(mat_obs, delta_t=3)
println("in comp_energy, i is = ", i)
res_en[i] = infoEn(energies(evalues), aux_mat[i])
#res_en[i] = infoEn(energies(evalues), aux_mat[i])
evec[i] = eigvec
end
return res_en, evec
return evec
end
end
mutable struct infoEn
......@@ -180,13 +180,22 @@ mutable struct infoEn
end
end
function pseudo_mat_elem(evec::Array{Array{T,2} where T,1}, mass::uwreal, mu::Array{Float64})
Rn = [exp(mass * (t)/2) * evec[t][1] for t =2:length(evec)]
Rn = [exp(mass * (t)/2) * evec[t][1] for t =1:length(evec)]
aux = sqrt(2)*sum(mu) / mass^1.5
return uwdot(aux,Rn)
end
function vec_mat_elem(evec::Array{Array{T,2} where T,1}, mass::uwreal)
Rn = [exp(mass * t/2) * evec[t][1] for t =1:length(evec)]
return uwdot(Rn , 1/ mass)
function vec_mat_elem(evec::Array{Array{T,2} where T,1}, mass::uwreal, deg::Bool)
if !deg
Rn = [exp(mass * t/2) * evec[t][1] for t =1:length(evec)]
return uwdot(Rn , za(beta[iens]) * sqrt(2/ mass))
else
Rn = [exp(mass * t/2) * evec[t][4] for t =1:length(evec)]
println(za(beta[iens]))
println(mass)
return uwdot(Rn , za(beta[iens]) * sqrt(2/ mass))
#return uwdot(Rn , 1/mass)# * sqrt(2/ mass))
end
end
function extract_dec_const(mat_elem::uwreal, mass::uwreal, mu::Array{Float64})
return sqrt(2)*sum(mu)*mat_elem / mass^1.5
......
{}
\ No newline at end of file
module juobs
using Base: Float64
using ADerrors, PyPlot, LaTeXStrings, LinearAlgebra, LsqFit, LeastSquaresOptim
import Statistics: mean
......@@ -9,8 +10,8 @@ include("juobs_tools.jl")
include("juobs_obs.jl")
export read_mesons, read_ms1, read_ms, read_md, truncate_data!
export get_matrix, energies, uwdot, uweigvals, uweigvecs, uweigen, invert, getall_eigvals, getall_eigvecs
export corr_obs, corr_sym, md_sea, md_val, plat_av, lin_fit, x_lin_fit, y_lin_fit, fit_routine
export get_matrix, energies, uwdot, uweigvals, uweigvecs, uweigen, invert, getall_eigvals, getall_eigvecs, hess_reduce, uwcholesky, transpose, tridiag_reduction, make_positive_def, invert_covar_matrix
export corr_obs, corr_sym, md_sea, md_val, plat_av, lin_fit, x_lin_fit, y_lin_fit, fit_routine, global_fit_routine
export meff, mpcac, dec_const, dec_const_pcvc, comp_t0
end # module
......@@ -126,7 +126,8 @@ function energies(evals::Union{Vector{Vector{uwreal}},Array{Array{uwreal}} }; wp
ratio = evals[t][i] / evals[t+1][i]
aux_en[t] = 0.5*log(ratio * ratio)
end
isnothing(wpm) ? uwerr.(aux_en) : uwerr.(aux_en, wpm)
#uwerr.(aux_en)
#isnothing(wpm) ? uwerr.(aux_en) : [uwerr(a, wpm) for a in aux_en]
eff_en[i] = copy(aux_en)
end
return eff_en
......@@ -173,7 +174,7 @@ corr_upper = [corr_pa[1]]
matrices = [corr_diag, corr_upper]
## solve the GEVP
evals = getall_eigvals(matrices, 5) #where t_0=5
#evals = getall_eigvals(matrices, 5) #where t_0=5
Julia>
......@@ -213,23 +214,46 @@ res = uweigvals(a) ##eigenvalues
res1 = uweigvals(a,b) ## generalised eigenvalues
```
"""
function uweigvals(a::Matrix{uwreal}; iter = 30)
function uweigvals(a::Matrix{uwreal}; iter::Int64=5, diag::Bool=true)
n = size(a,1)
for k in 1:iter
q_k, r_k = qr(a)
a = uwdot(r_k, q_k)
if n == 2
return uweigvals_dim_geq3(a, iter=iter, diag=diag) #uweigvals_dim2(a)
else
return uweigvals_dim_geq3(a, iter=iter, diag=diag)
end
return get_diag(a)
end
function uweigvals(a::Matrix{uwreal}, b::Matrix{uwreal}; iter = 30)
function uweigvals(a::Matrix{uwreal}, b::Matrix{uwreal}; iter = 5, diag::Bool=true)
c = uwdot(invert(b),a)
n = size(c,1)
if n == 2
return uweigvals_dim_geq3(c, iter=iter, diag=diag) #uweigvals_dim2(c)
else
return uweigvals_dim_geq3(c, iter=iter, diag=diag)
end
#for k in 1:iter
# q_k, r_k = qr(c)
# c = uwdot(r_k, q_k)
#end
end
function uweigvals_dim_geq3(a::Matrix{uwreal}; iter = 5, diag::Bool=true)
n = size(a,1)
a = tridiag_reduction(a)
for k in 1:iter
q_k, r_k = qr(c)
c = uwdot(r_k, q_k)
q_k, r_k = qr(a)
a = uwdot(r_k, q_k)
end
return get_diag(c)
diag == true ? (return get_diag(a)) : (return a)
end
function uweigvals_dim2(a::Matrix{uwreal})
res = Vector{uwreal}(undef,2)
aux_sum = a[1,1] + a[2,2]
delta = ADerrors.sqrt((aux_sum)^2 - 4*(a[1,1]*a[2,2]- a[1,2]*a[2,1]))
res[1] = (aux_sum + delta) / 2
res[2] = (aux_sum - delta) / 2
return res
end
@doc raw"""
getall_eigvecs(a::Vector{Matrix}, delta_t; iter=30 )
......@@ -257,7 +281,7 @@ mat_array = get_matrix(diag, upper_diag)
evecs = getall_eigvecs(mat_array, 5)
```
"""
function getall_eigvecs(a::Vector{Matrix{uwreal}}, delta_t; iter=30)
function getall_eigvecs(a::Vector{Matrix}, delta_t; iter=5)
n = length(a)-delta_t
res = Vector{Matrix{uwreal}}(undef, n)
[res[i] = uweigvecs(a[i+delta_t], a[i]) for i=1:n]
......@@ -291,18 +315,22 @@ res = uweigvecs(a) ##eigenvectors in column
res1 = uweigvecs(a,b) ## generalised eigenvectors in column
```
"""
function uweigvecs(a::Matrix{uwreal}; iter = 30)
function uweigvecs(a::Matrix{uwreal}; iter = 5)
n = size(a,1)
if n > 2
a, q = tridiag_reduction(a, q_mat=true)
end
u = idty(n)
for k in 1:iter
q_k, r_k = qr(a)
a = uwdot(r_k, q_k)
u = uwdot(u, q_k)
end
return u
n > 2 ? (return uwdot(q,u)) : (return u)
end
function uweigvecs(a::Matrix{uwreal}, b::Matrix{uwreal}; iter = 30)
function uweigvecs(a::Matrix{uwreal}, b::Matrix{uwreal}; iter = 5)
c = uwdot(invert(b), a)
#return uweigvecs(c, iter=iter)
n = size(c,1)
u = idty(n)
for k in 1:iter
......@@ -342,12 +370,12 @@ b = Matrix{uwreal}(nothing, n,n) ## n*n matrix of uwreal with nothing entries
eval, evec = uweigen(a)
eval1, evec1 = uweigvecs(a,b)
```
"""
function uweigen(a::Matrix{uwreal}; iter = 30)
return uweigvals(a, iter=iter), uweigvecs(a, iter=iter)
"""
function uweigen(a::Matrix{uwreal}; iter = 5, diag::Bool=true)
return uweigvals(a, iter=iter,diag=diag), uweigvecs(a, iter=iter)
end
function uweigen(a::Matrix{uwreal}, b::Matrix{uwreal}; iter = 30)
return uweigvals(a, b, iter=iter), uweigvecs(a, b, iter=iter)
function uweigen(a::Matrix{uwreal}, b::Matrix{uwreal}; iter = 5, diag::Bool=true)
return uweigvals(a, b, iter=iter, diag=diag), uweigvecs(a, b, iter=iter)
end
function norm_evec(evec::Matrix{uwreal}, ctnot::Matrix{uwreal})
......@@ -379,13 +407,32 @@ Given an input matrix of uwreals, this function returns the inverse of that matr
backward substitution.
"""
function invert(a::Matrix{uwreal})
#q,r = qr(hess_red(a))
q,r = qr(a)
r_inv = upper_inversion(r)
return uwdot(r_inv, transpose(q))
end
"""
Performs a Cholesky decomposition of A, which must
be a symmetric and positive definite matrix. The function
returns the lower variant triangular matrix, L.
"""
function uwcholesky(A::Matrix{uwreal})
n = size(A,1)
L = fill(uwreal(0), n, n)
for i in 1:n
for k in 1:i
tmp_sum = sum(L[i,j] * L[k,j] for j in 1:k)
if i==k
L[i,k] = sqrt(((A[i,i] - tmp_sum)))
else
L[i,k] = (1.0 / L[k,k] * (A[i,k]-tmp_sum))
end
end
end
return L
end
"""
qr(A::Matrix{uwreal})
......@@ -441,13 +488,6 @@ function make_householder(a::Vector{uwreal})
v[1] = uwreal(1.0)
H = idty(n)
H = H - (2.0 / uwdot(v,v)) * uwdot(reshape(v, :,1), transpose(v)) #this last term is a vector product
for i in 1:n
for j in 1:n
if H[i,j]!= 0 && H[i,j]!=1
end
end
end
return H
end
......@@ -462,28 +502,99 @@ function make_householder(a::Vector{Float64})
H = H .- (2.0 / dot(v,v)) * mul!(y, v, transpose(v))
return H
end
"""
This function computes a vector u that generates a Householder reflection H = I - uu* satisfying Ha=nu*e1.
Accumulating this transformations any matrix can
be reduced to upper Hessenberg form.
"""
function house_gen(a::Vector{uwreal})
u = deepcopy(a)
nu = uwnorm(a)
if nu == 0
u[1] = sqrt(2)
end
if u[1] != 0
rho = u[1] / sqrt(u[1]*u[1])
else
rho = 1
end
u = uwdot(rho/nu, u)
u[1] += 1
u = uwdot(u , 1/sqrt(u[1]))
nu = -(rho) * nu
return u, nu
end
"""
hess_red(a::Matrix{uwreal})
Given a matrix of uwreal variables, this function returns the Hessenberg form of the matrix.
Given a matrix of uwreal variables, this function returns the Hessenberg form of the matrix by applying householder transformations.
"""
function hess_red(a::Matrix{uwreal})
n = size(a, 1)
res = Matrix{uwreal}(undef, n, n)
res = a
for j in 1:n-2
mi = idty(n)
mi_inv = idty(n)
for k in j+2:n
mi[k,j+1] = res[k,j] / res[j+1, j]
mi_inv[k,j+1] = -mi[k,j+1]
function hess_reduce(a::Matrix{uwreal}; q_mat::Bool=false)
n = size(a,1)
H = deepcopy(a)
Q = idty(n)
for k in 1:n-2
u, H[k+1,k] = house_gen(H[k+1:n,k])
Q[k+1:n,k] = u
v = uwdot(u,H[k+1:n, k+1:n])
H[k+1:n, k+1:n] .= H[k+1:n, k+1:n] .- uwdot(reshape(u,length(u),1),v)
H[k+2:n,k] .= 0.0
v = uwdot(H[1:n,k+1:n], u)
H[1:n,k+1:n] .= H[1:n,k+1:n] .- uwdot(v,reshape(u,1,length(u)))
end
if q_mat
Id = idty(n)
for k in reverse(1:n-2)
u = Q[k+1:n, k]
v = uwdot(u, Q[k+1:n,k+1:n])
Q[k+1:n,k+1:n] .= Q[k+1:n,k+1:n] .- uwdot(reshape(u,length(u),1),v)
Q[:,k] = Id[:,k]
end
res = uwdot(mi_inv, uwdot(res, mi) )
return H,Q
else
return H
end
return res
end
"""
"""
function tridiag_reduction(a::Matrix{uwreal}; q_mat::Bool=false)
n = size(a,1)
H = deepcopy(a)
Q = idty(n)
for k in 1:n-2
u, H[k+1,k] = house_gen(H[k+1:n,k])
Q[k+1:n,k] = u
v = uwdot(u,H[k+1:n, k+1:n])
H[k+1:n, k+1:n] .= H[k+1:n, k+1:n] .- uwdot(reshape(u,length(u),1),v)
H[k+2:n,k] .= 0.0
v = uwdot(H[1:n,k+1:n], u)
H[1:n,k+1:n] .= H[1:n,k+1:n] .- uwdot(v,reshape(u,1,length(u)))
H[k,k+2:n] .= 0.0
end
if q_mat
Id = idty(n)
for k in reverse(1:n-2)
u = Q[k+1:n, k]
v = uwdot(u, Q[k+1:n,k+1:n])
Q[k+1:n,k+1:n] .= Q[k+1:n,k+1:n] .- uwdot(reshape(u,length(u),1),v)
Q[:,k] = Id[:,k]
end
return H,Q
else
return H
end
end
"""
upper_inversion(u::Matrix{uwreal})
......@@ -556,7 +667,7 @@ function uwdot(a::Matrix{uwreal}, b::Matrix{uwreal})
k,p = size(b)
c = Matrix{uwreal}(undef, n, p)
if m != k
error("Error uwdot")
error("Error uwdot: in a*b the size of a is ", size(a), " while the size of b is ", size(b) )
end
for i = 1:n
for j = 1:p
......@@ -573,7 +684,7 @@ It returns the norm of a vector of uwreal
"""
function uwnorm(a::Vector{uwreal}; wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing)
norm = sqrt(uwdot(a,a))
isnothing(wpm) ? uwerr(norm) : uwerr(norm, wpm)
#isnothing(wpm) ? uwerr(norm) : uwerr(norm, wpm)
return norm
end
......@@ -630,8 +741,34 @@ function idty(n::Int64)
return res
end
function make_positive_def(A::Matrix)
B = 0.5 * (A + A')
U, S, V = svd(B)
H = V * Diagonal(S) * V'
A_hat = 0.5 * (B + H)
A_hat = 0.5 * ( A_hat + A_hat')
k = 0
while !isposdef(A_hat)
mineig = minimum(eigvals(A_hat))
eps = 2.220446049250313e-16
A_hat = A_hat + (-mineig*k^2 .+ eps*Matrix(I, size(A)))
k+=1
end
return A_hat
end
function invert_covar_matrix(A::Matrix)
F = svd(A)
cov_inv = F.V * Diagonal(1 ./F.S) * F.U'
return cov_inv
end
function more_penrose_inv(A::Matrix)
F = svd(A)
end
# operator overloading
"""
Base.:*(x::uwreal, y::Matrix{uwreal})
......
......@@ -33,6 +33,7 @@ function meff(corr::Vector{uwreal}, plat::Vector{Int64}; pl::Bool=true, data::Bo
errorbar(x, y, dy, fmt="x", color="black")
ylabel(L"$m_\mathrm{eff}$")
xlabel(L"$x_0$")
ylim(v-100*e, v+100*e)
if !isnothing(kappa)
title(string(L"$\kappa_1 = $", kappa[1], L" $\kappa_2 = $", kappa[2]))
......@@ -88,16 +89,22 @@ function mpcac(a0p::Vector{uwreal}, pp::Vector{uwreal}, plat::Vector{Int64}; ca:
kappa::Union{Vector{Float64}, Nothing}=nothing, mu::Union{Vector{Float64}, Nothing}=nothing,
wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing)
corr_a0p = -a0p[2:end-1]
corr_pp = pp[2:end-1]
corr_a0p = -a0p[1:end]
corr_pp = pp[1:end]
der_a0p = (corr_a0p[3:end] .- corr_a0p[1:end-2]) / 2
if ca != 0.0
der2_pp = corr_pp[1:end-2] + corr_pp[3:end] - 2 * corr_pp[2:end-1]
der_a0p = der_a0p + ca * der2_pp
der2_pp = (corr_pp[1:end-4] - 2*corr_pp[3:end-2] + corr_pp[5:end])/4
der_a0p = der_a0p[2:end-1] + ca * der2_pp
end
aux = der_a0p ./ (2 .* corr_pp[2:end-1])
#der_a0p = (corr_a0p[3:end] .- corr_a0p[1:end-2]) / 2
#if ca != 0.0
# der2_pp = corr_pp[1:end-2] + corr_pp[3:end] - 2 * corr_pp[2:end-1]
# der_a0p = der_a0p + ca * der2_pp
#end
aux = der_a0p ./ ( corr_pp[3:end-2])
mass = plat_av(aux, plat, wpm)
if pl
isnothing(wpm) ? uwerr(mass) : uwerr(mass, wpm)
......@@ -112,6 +119,7 @@ function mpcac(a0p::Vector{uwreal}, pp::Vector{uwreal}, plat::Vector{Int64}; ca:
errorbar(x, y, dy, fmt="x", color="black")
ylabel(L"$m_\mathrm{PCAC}$")
xlabel(L"$x_0$")
ylim(v-100*e, v+100*e)
if !isnothing(kappa)
title(string(L"$\kappa_1 = $", kappa[1], L" $\kappa_2 = $", kappa[2]))
......@@ -203,7 +211,7 @@ function dec_const(a0p::Vector{uwreal}, pp::Vector{uwreal}, plat::Vector{Int64},
aux = exp.((collect(0:T-1) .- T/2) .* [m for k = 1:T])
end
R = corr_a0p .* aux ./ [sqrt(corr_pp[T-y0]) for k = 1:length(corr_a0p)]
R = corr_a0p .* aux ./ [((corr_pp[T-y0])^2)^(1/4) for k = 1:length(corr_a0p)]
R_av = plat_av(R, plat, wpm)
f = sqrt(2) * sqrt(R_av^2) / sqrt(m)
......@@ -221,6 +229,7 @@ function dec_const(a0p::Vector{uwreal}, pp::Vector{uwreal}, plat::Vector{Int64},
fill_between(plat[1]:plat[2], v-e, v+e, color="green", alpha=0.75, label=L"$R$")
errorbar(x, y, dy, fmt="x", color="black", label=lbl)
legend()
ylim(v-10*e, v+10*e)
ylabel(L"$R_\mathrm{av}$")
xlabel(L"$x_0$")
......@@ -228,6 +237,7 @@ function dec_const(a0p::Vector{uwreal}, pp::Vector{uwreal}, plat::Vector{Int64},
title(string(L"$\kappa_1 = $", kappa[1], L" $\kappa_2 = $", kappa[2]))
end
display(gcf())
close()
end
if !data
return f
......@@ -308,23 +318,86 @@ function dec_const(a0pL::Corr, a0pR::Corr, ppL::Corr, ppR::Corr, plat::Vector{In
error("y0 or kappa values does not match")
end
end
## ADD DOCUMENTATION FOR VECTOR DECAY
function dec_const(vv::Vector{uwreal}, plat::Vector{Int64}, m::uwreal, y0::Int64; pl::Bool=true, data::Bool=false,
kappa::Union{Vector{Float64}, Nothing}=nothing, wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing)
corr_vv = vv[2:end-1]
T = length(corr_vv)
aux = exp.((collect(1:T) .- y0 ) .* fill(m, T))
R = ((aux .* corr_vv).^2).^0.25
R_av = plat_av(R, plat, wpm)
f = sqrt(2 / m) * R_av
if pl
R .*= sqrt.(2 ./ [m for i in 1:length(R)])
uwerr.(R)
R_av *= sqrt(2/m)
isnothing(wpm) ? uwerr(R_av) : uwerr(R_av, wpm)
isnothing(wpm) ? uwerr(f) : uwerr(f, wpm)
x = 1:length(R)
y = value.(R)
dy = err.(R)
v = value(R_av)
e = err(R_av)
figure()
lbl = string(L"$af = $", sprint(show, f))
fill_between(plat[1]:plat[2], v-e, v+e, color="green", alpha=0.75, label=L"$R$")
errorbar(x, y, dy, fmt="x", color="black", label=lbl)
legend()
xlim(y0, y0 +plat[2] +15)
ylim(v-10*e, v+10*e)
ylabel(L"$af_{B}$")
#ylabel(L"$R_\mathrm{av}$")
xlabel(L"$x_0$")
#title(L"$f_{B^*}$")
if !isnothing(kappa)
title(string( L"$\kappa_1 = $", kappa[1], L" $\kappa_2 = $", kappa[2]))
end
display(gcf())
#t = "ps_decay_$(kappa[1])_$(kappa[2]).pdf"
#savefig(joinpath("/Users/ale/Il mio Drive/phd/secondment/3pf test/analysis/plots",t))
end
if !data
return f
else
return f, R
end
end
function dec_const(vv::Corr, plat::Vector{Int64}, m::uwreal; pl::Bool=true, data::Bool=false,
wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing)
return dec_const(vv.obs, plat, m, vv.y0+1, kappa=vv.kappa, pl=pl, data=data, wpm=wpm)
end
@doc raw"""
dec_const_pcvc(corr::Vector{uwreal}, plat::Vector{Int64}, m::uwreal, mu::Vector{Float64}, y0::Int64 ; pl::Bool=true, data::Bool=false, wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing)
dec_const_pcvc(corr::Corr, plat::Vector{Int64}, m::uwreal; pl::Bool=true, data::Bool=false, wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing)
dec_const_pcvc(ppL::Vector{uwreal}, ppR::Vector{uwreal}, plat::Vector{Int64}, m::uwreal, mu::Vector{Float64}, y0::Int64 ; pl::Bool=true, data::Bool=false, wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing)
dec_const_pcvc(corrL::Corr, corrR::Corr, plat::Vector{Int64}, m::uwreal; pl::Bool=true, data::Bool=false, wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing)
Computes decay constant using the PCVC relation for twisted mass fermions. The decay constant is computed in the plateau `plat`.
Correlator can be passed as an `Corr` struct or `Vector{uwreal}`. If it is passed as a uwreal vector, vector of twisted masses `mu` and source position `y0`
must be specified.
The flags `pl` and `data` allow to show the plots and return data as an extra result.
**The method assumes that the source is in the bulk.**
**The method extract the matrix element assuming that the source is in the bulk. **
**If left and right correlators are included in the input. The result is computed with a ratio that cancels boundary effects:**
`` R = \sqrt{f_P(x_0, y_0) * f_P(x_0, T - 1 - y_0) / f_P(T - 1 - y_0, y_0)}``
```@example
data = read_mesons(path, "G5", "G5")
corr_pp = corr_obs.(data, L=32)
m = meff(corr_pp[1], [50, 60], pl=false)
f = dec_const_pcvc(corr_pp[1], [50, 60], m, pl=false)
#left and right correlators
f_ratio = dec_const_pcvc(ppL, ppR, [50, 60], m)
```
"""
function dec_const_pcvc(corr::Vector{uwreal}, plat::Vector{Int64}, m::uwreal, mu::Vector{Float64}, y0::Int64 ; pl::Bool=true, data::Bool=false,
......@@ -340,23 +413,18 @@ function dec_const_pcvc(corr::Vector{uwreal}, plat::Vector{Int64}, m::uwreal, mu
R_av = plat_av(R, plat, wpm)
f = sqrt(2) * (mu[1] + mu[2]) *R_av / m^1.5
if pl
if isnothing(wpm)
uwerr(f)
uwerr(R_av)
uwerr.(R)
else
uwerr(f, wpm)
uwerr(R_av, wpm)
uwerr.(R, wpm)
end
isnothing(wpm) ? uwerr(f) : uwerr(f, wpm)
isnothing(wpm) ? uwerr(R_av) : uwerr(R_av, wpm)
v = value(R_av)
e = err(R_av)
e = err(R_av)
figure()
fill_between(plat[1]:plat[2], v-e, v+e, color="green", alpha=0.75)
errorbar(1:length(R), value.(R), err.(R), fmt="x", color="black")
lbl = string(L"$af = $", sprint(show, f))
fill_between(plat[1]:plat[2], v-e, v+e, color="green", alpha=0.75, label=L"$R$")
errorbar(1:length(R), value.(R), err.(R), fmt="x", color="black", label=lbl)
ylabel(L"$R$")
xlabel(L"$x_0$")
legend()
title(string(L"$\mu_1 = $", mu[1], L" $\mu_2 = $", mu[2]))
display(gcf())
end
......@@ -373,6 +441,50 @@ function dec_const_pcvc(corr::Corr, plat::Vector{Int64}, m::uwreal; pl::Bool=tru
return dec_const_pcvc(corr.obs, plat, m, corr.mu, corr.y0, pl=pl, data=data, wpm=wpm)
end
function dec_const_pcvc(ppL::Vector{uwreal}, ppR::Vector{uwreal}, plat::Vector{Int64}, m::uwreal, mu::Vector{Float64}, y0::Int64 ; pl::Bool=true, data::Bool=false,
wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing)
T = length(ppL)
f1 = [ppL[T - y0] for k = 1:T]
R = ((ppL .* ppR ./ f1).^2).^(1/4)
R = R[2:end-1]
R_av = plat_av(R, plat, wpm)
f = sqrt(2) * (mu[1] + mu[2]) * R_av / m^1.5
if pl
isnothing(wpm) ? uwerr(f) : uwerr(f, wpm)
isnothing(wpm) ? uwerr(R_av) : uwerr(R_av, wpm)
v = value(R_av)
e = err(R_av)