Commit 6c956856 authored by Alessandro 's avatar Alessandro

General updated of the analysis code used for the 2022 Lattice Conference

parent 838f8293
Software for automated data analysis of Wilson_tm fermions with GEVP techniques.
Software for general purpose analysis of charm physics data from a tmQCD mixed action, from mass shift to gevp extraction of the observables to continuum limit fits.
-> src
|----> aux obs computation
| |------> md.jl : main routine for the computation of delta m and t0 shifted
| |------> tools.jl, types.jl, const.jl : auxiliary files to md.jl
|
|-----> gevp analysis: obs. analysis once md.jl has been executed
|-----> gevp_tm.jl : extract observable ensemble by ensemble using gevp and store in BDIO
|-----> gevp_fit.jl : read BDIO from previous file and perform chiral-continumm extrapolations
|-----> func_comb.jl : contains all the functional forms for the chiral-continuum fits
|-----> gevp_plotter.jl : useful routines for plotting complicated chiral-continuum fits and more
|-----> read_bdio.jl : reading BDIO routines ( the order is hardcoded but consistent within the whole files)
|-----> const.jl, tools.jl, types.jl : auxiliary routines for the analysis
The GEVP is solved as outlined in 1010.0202, i.e., given a correlator f(t) the following matrix is constructed: The GEVP is solved as outlined in 1010.0202, i.e., given a correlator f(t) the following matrix is constructed:
```math ```math
...@@ -16,57 +32,27 @@ The effective energy spectrum is determined from: ...@@ -16,57 +32,27 @@ The effective energy spectrum is determined from:
```math ```math
E_n^{eff}(t, t_0, \tau) = \log( \frac{\lambda_n(t, t_0, \tau)}{\lambda_n(t+a, t_0, \tau)}) = E_n + O(e^{-(E_m-e_n)t}) E_n^{eff}(t, t_0, \tau) = \log( \frac{\lambda_n(t, t_0, \tau)}{\lambda_n(t+a, t_0, \tau)}) = E_n + O(e^{-(E_m-e_n)t})
``` ```
Finally the energy levels are determined by fitting the effective energy with the functional form Go to SET UP VARIABLES section in md.jl, gevp_tm.jl and gevp_fit.jl files to properly configure before running.
```math Several plauteau and data paths have to be set before running.
E_n^{eff}(t, t_0, \tau) = E_n + p_1*e^{-\Delta E * t}
```
The fit is performed in the time extent
[range_t_fit[1]:range_t_fit[2], end-5]
where range_t_fit is an array of integers set by default to [2,5], but this can be changed by the user.
Final results for the energy spectrum is given by the weighthed average of the fit parameters determined by the above outlined procedure.
N.B. at the moment the code does not extract matrix element, hence decay constants, from the gevp.
To run the code in the juliaREPL type:
julia> include("/path_to/gevp.jl")
Go to SET UP VARIABLES section in the gevp.jl file to properly configure before running.
You have to up set the following variables:
- path_data where data are stored
- path_plat where a plat.txt file is stored with plateaus for all ensembles
- path_result where you want to save results.txt and plots
- ensembles to analyse
- sector you are interested in: light-light, light-heavy, heavy-heavy...
- tau value to use for matrix construction
- _t0 value to use for solving the GEVP
- range_t_fit array of integers with the fit range value for the extractions of the energies
- rwf set to true if you want to include reweighting factors
- compute_t0 set to true if you want to extract t0 from ms.dat file. Otherwise, t0 is taken from 1608.08900 in const.jl
- mass_shift set to true if you want to include the mass shift
go to line 484 to modify continuum limit + chiral extrapolatio fit model
Data in path_data need to be stored as follow: Data in the various path_data need to be stored as follow:
../data_folder: path_data_md : contains pbp.dat files for action derivatives
------> path_data_md/ens_i/*pbp.dat
path_data_w: contains wilson light correlators for mass shift and ms.dat files for t0
------> path_data_w/ens_i/*ms.dat
------> path_data_w/ens_i/*mesons.dat
../data_folder/ens_id_1_folder: path_data_rw: contains reweighting factors ms1.dat files
- mesons.dat -------> path_data_rw/ens_i/*ms1.dat
- ms.dat
- ms1.dat
- pbp.dat
path_data_tm: contains twisted mass (heavy) correlators
--------> path_data_tm/ens_i/*mesons.dat
../data_folder/ens_id_2_folder: Replicas are automatically taken into account for each ensembles.
- r0_mesons.dat N.B.
- r1_mesons.dat In the gamma method the number of configurations of different observables but with same ensemble HAS to match. There might be runs where i.e. ms.dat files contains more cnfgs than mesons.dat files and this generates errors. To avoid it, set in const.jl/trunc_db (database for each ensembles) the number of configurations at which you want to cut all the observables with that ensembe id.
- r0_ms.dat
- r1_ms.dat
- r0_ms1.dat
- r1_ms1.dat
- r0_pbp.dat
- r1_pbp.dat
and so on
\ No newline at end of file
#H101 #H101
ll 58 75 ll 58 75
lh 58 70 lh 63 76
hh 60 72 hh 65 74
t0 20 70 t0 20 70
#H102r001 #H102r001
ll 60 85 ll 60 85
ls 60 85 ls 60 85
lh 60 85 lh 62 80
ss 60 85 ss 60 85
sh 60 85 sh 62 80
hh 60 85 hh 65 81
t0 20 80 t0 20 80
#H102r002 #H102r002
ll 58 73 ll 58 73
ls 60 75 ls 60 75
lh 62 80 lh 65 75
ss 60 80 ss 60 80
sh 62 80 sh 65 75
hh 63 80 hh 66 78
t0 20 80
#H105
ll 58 73
ls 60 75
lh 63 72
ss 60 80
sh 65 80
hh 66 80
t0 20 80 t0 20 80
#H400 #H400
ll 60 75 ll 60 75
...@@ -50,6 +58,14 @@ ss 85 105 ...@@ -50,6 +58,14 @@ ss 85 105
sh 83 110 sh 83 110
hh 90 104 hh 90 104
t0 20 110 t0 20 110
#D200
ll 85 105
ls 82 100
lh 80 88
ss 85 100
sh 82 88
hh 87 93
t0 20 110
#J303 #J303
ll 120 140 ll 120 140
ls 123 140 ls 123 140
......
#H101 #H101
ll 56 70 ll 60 70
lh 59 68 lh 63 72
hh 68 75 hh 68 75
t0 20 70 t0 20 70
#H102r001 #H102r001
ll 60 80 ll 60 80
ls 60 85 ls 60 85
lh 57 70 lh 57 70
ss 57 67 ss 57 67
sh 60 70 sh 60 70
hh 63 79 hh 63 79
t0 20 80 t0 20 80
#H102r002 #H102r002
ll 60 80 ll 58 65
ls 60 85 ls 58 65
lh 57 70 lh 60 67
ss 57 67 ss 57 62
sh 60 70 sh 60 66
hh 65 79 hh 65 79
t0 20 80 t0 20 80
#H105
ll 56 62
ls 56 65
lh 60 70
ss 57 63
sh 61 70
hh 69 80
t0 20 80
#H400 #H400
ll 56 68 ll 56 68
lh 60 73 lh 60 73
hh 65 78 hh 65 78
t0 20 80 t0 20 80
#N300 #N300
ll 80 110 ll 78 82
lh 83 98 lh 84 95
hh 90 108 hh 92 110
t0 20 105 t0 20 105
#N200 #N200
ll 75 90 ll 75 90
...@@ -45,11 +53,19 @@ t0 20 110 ...@@ -45,11 +53,19 @@ t0 20 110
#N203 #N203
ll 77 95 ll 77 95
ls 76 95 ls 76 95
lh 78 95 lh 85 98
ss 76 95 ss 76 95
sh 80 100 sh 80 100
hh 89 102 hh 89 102
t0 20 110 t0 20 110
#D200
ll 76 92
ls 78 88
lh 82 95
ss 82 90
sh 85 95
hh 88 93
t0 20 110
#J303 #J303
ll 116 130 ll 116 130
ls 118 135 ls 118 135
......
...@@ -12,25 +12,33 @@ sh 60 85 ...@@ -12,25 +12,33 @@ sh 60 85
hh 68 85 hh 68 85
t0 20 80 t0 20 80
#H102r002 #H102r002
ll 65 72 ll 65 76
ls 67 74 ls 65 74
lh 67 75 lh 68 73
ss 67 74
sh 68 81
hh 68 85
t0 20 80
#H105
ll 60 68
ls 65 74
lh 65 75
ss 67 74 ss 67 74
sh 68 81 sh 68 81
hh 68 85 hh 68 85
t0 20 80 t0 20 80
#H400 #H400
ll 65 88 ll 65 80
lh 67 80 lh 67 80
hh 67 85 hh 67 85
t0 20 80 t0 20 80
#N300 #N300
ll 80 110 ll 78 105
lh 92 115 lh 92 108
hh 92 115 hh 92 115
t0 20 105 t0 20 105
#N200 #N200
ll 85 105 ll 80 92
ls 85 105 ls 85 105
lh 88 99 lh 88 99
ss 85 105 ss 85 105
...@@ -43,15 +51,23 @@ lh 87 100 ...@@ -43,15 +51,23 @@ lh 87 100
hh 90 115 hh 90 115
t0 20 110 t0 20 110
#N203 #N203
ll 85 105 ll 87 103
ls 85 105 ls 85 105
lh 88 100 lh 88 100
ss 85 105 ss 85 105
sh 88 110 sh 88 110
hh 88 110 hh 88 110
t0 20 110 t0 20 110
#D200
ll 79 86
ls 85 105
lh 84 87
ss 85 105
sh 85 87
hh 90 93
t0 25 100
#J303 #J303
ll 120 140 ll 120 148
ls 123 140 ls 123 140
lh 125 145 lh 125 145
ss 123 140 ss 123 140
......
...@@ -7,7 +7,7 @@ t0 20 80 ...@@ -7,7 +7,7 @@ t0 20 80
ll 60 85 ll 60 85
ls 60 85 ls 60 85
lh 60 85 lh 60 85
ss 60 85 ss 60 85
sh 60 85 sh 60 85
hh 60 85 hh 60 85
t0 20 80 t0 20 80
...@@ -16,7 +16,15 @@ ll 60 69 ...@@ -16,7 +16,15 @@ ll 60 69
ls 60 68 ls 60 68
lh 63 68 lh 63 68
ss 60 67 ss 60 67
sh 68 73 sh 62 68
hh 70 85
t0 20 80
#H105
ll 60 69
ls 60 68
lh 63 68
ss 60 67
sh 64 68
hh 70 85 hh 70 85
t0 20 80 t0 20 80
#H400 #H400
...@@ -25,8 +33,8 @@ lh 68 74 ...@@ -25,8 +33,8 @@ lh 68 74
hh 68 80 hh 68 80
t0 20 80 t0 20 80
#N300 #N300
ll 80 110 ll 80 90
lh 88 100 lh 88 95
hh 95 115 hh 95 115
t0 20 105 t0 20 105
#N200 #N200
...@@ -39,23 +47,31 @@ hh 92 110 ...@@ -39,23 +47,31 @@ hh 92 110
t0 20 105 t0 20 105
#N202 #N202
ll 84 95 ll 84 95
lh 87 97 lh 82 88
hh 92 110 hh 92 110
t0 20 110 t0 20 110
#N203 #N203
ll 85 95 ll 85 95
ls 85 95 ls 85 95
lh 85 95 lh 90 100
ss 85 95 ss 85 95
sh 86 100 sh 90 100
hh 89 110 hh 89 110
t0 20 110 t0 20 110
#D200
ll 78 85
ls 80 90
lh 88 95
ss 85 95
sh 88 94
hh 88 98
t0 20 110
#J303 #J303
ll 120 140 ll 120 140
ls 123 140 ls 123 140
lh 123 140 lh 128 140
ss 123 140 ss 123 140
sh 123 145 sh 128 140
hh 133 165 hh 133 165
t0 25 170 t0 25 170
#end #end
Data analysis results
#================================#
Setup:
Ensembles analysed: ["J303", "N300", "H400"]
Data storage: /Users/ale/Desktop/data
Plateaux file: /Users/ale/automation/plat.txt
Results storage: /Users/ale/Desktop/results_gevp
Sector analysed: ["sh", "hh", "lh"]
Reweighting factor: false
Mass shift: false
t0 values: extracted from const.jl
Phi2 = 8t0m_pi^2: m_pi extracted from ens_db in const.jl
#================================#
Results at finite lattice spacings
Ensemble J303
$Z^{tm}_M \mu_c \sqrt{8t_0}$ = 3.089038311419621 +/- 0.06368579322874132
$m_{D_s} \sqrt{8t_0}$ = 4.0767724442326205 +/- 0.006996133249689365
$m_{D_s^*} \sqrt{8t_0}$ = 4.358985941909339 +/- 0.011323225630393369
$m_etac \sqrt{8t_0}$ = 6.198961563442169 +/- 0.010631637001414646
$m_{J/ψ} \sqrt{8t_0}$ = 6.438575482495065 +/- 0.011974541830682067
$m_D \sqrt{8t_0}$ = 3.9345824989703133 +/- 0.00788650891221943
$m_{D^*} \sqrt{8t_0}$ = 4.202091508641248 +/- 0.03026831950893543
Ensemble N300
$Z^{tm}_M \mu_c \sqrt{8t_0}$ = 3.0534116918858816 +/- 0.06423563962756408
$m_{D_s} \sqrt{8t_0}$ = 3.9819783981924606 +/- 0.008771802807377663
$m_{D_s^*} \sqrt{8t_0}$ = 4.307408596257999 +/- 0.023636314382326967
$m_etac \sqrt{8t_0}$ = 6.153439293650704 +/- 0.01079032654593637
$m_{J/ψ} \sqrt{8t_0}$ = 6.395244247561371 +/- 0.015177663706514
$m_D \sqrt{8t_0}$ = 3.9819783981924606 +/- 0.008771802807377663
$m_{D^*} \sqrt{8t_0}$ = 4.307408596257999 +/- 0.023636314382326967
Ensemble H400
$Z^{tm}_M \mu_c \sqrt{8t_0}$ = 3.082565030768681 +/- 0.07238415767395359
$m_{D_s} \sqrt{8t_0}$ = 3.981978398192199 +/- 0.020054878479507945
$m_{D_s^*} \sqrt{8t_0}$ = -1048.4099785502206 +/- 2.292257001461028
$m_etac \sqrt{8t_0}$ = 6.161662152741498 +/- 0.04555911269588078
$m_{J/ψ} \sqrt{8t_0}$ = 6.407190978248098 +/- 0.0779209000164276
$m_D \sqrt{8t_0}$ = 3.981978398192199 +/- 0.020054878479507945
$m_{D^*} \sqrt{8t_0}$ = -1048.4099785502206 +/- 2.292257001461028
#================================#
Results in the continuum limit
$Z^{tm}_M \mu_c \sqrt{8t_0}$ = 3.082309275644263 +/- 0.06438222973160301
mu_c(MeV) = 1472.6943874619703 +/- 15.576870185223473
$m_{D_s} \sqrt{8t_0}$ = 4.116369939134062 +/- 0.019235286187268108
m_Ds(MeV) = 1966.7575067764074 +/- 25.70202455882141
$m_{D_s^*} \sqrt{8t_0}$ = 784.7478160631761 +/- 1.699331215580599
m_Ds_star(MeV) = 374944.10876329575 +/- 4611.4192288057875
$m_etac \sqrt{8t_0}$ = 6.211881675661275 +/- 0.0384654831143396
m_etac(MeV) = 2967.97058997659 +/- 40.44155105716508
$m_{J/ψ} \sqrt{8t_0}$ = 6.4478198895589305 +/- 0.061288707527612424
m_jpsi(MeV) = 3080.6993437523615 +/- 47.48802002562802
$m_D \sqrt{8t_0}$ = 3.914784220954249 +/- 0.01987534965036722
m_D(MeV) = 1870.442007841328 +/- 24.46605658005924
$m_{D^*} \sqrt{8t_0}$ = 784.5253834787122 +/- 1.6997966664873079
m_D_star(MeV) = 374837.8328547369 +/- 4609.877645087271
#========= ENSEMBLE DATABASE ========#
ens_db = Dict(
#"ens_id"=>[L, beta, is_deg?, m_pi, dtr]
"H102r002" => [32, 3.4, false, 0.15306, 2],
#"H102r001" => [32, 3.4, false, 0.15306, 2],
"H105" => [32, 3.4, false, 0.12151, 2],
"H101" => [32, 3.4, true, 0.17979, 2],
"H400" => [32, 3.46, true, 0.16345, 1],
"N200" => [48, 3.55, false, 0.09222, 1],
"N202" => [48, 3.55, true, 0.13407, 2],
"N203" => [48, 3.55, false, 0.11224, 1],
"D200" => [64, 3.55, false, 0.06611, 2],
"N300" => [48, 3.70, true, 0.10630, 1],
"J303" => [64, 3.70, false, 0.06514, 2]
)
trunc_db = Dict(
"H102r002" => nothing,
#"H102r001" => nothing,
"H105" => nothing,
"H101" => nothing,
"H400" => nothing,
"N200" => nothing,
"N202" => nothing,
"N203" => nothing,
"D200" => 1000,
"N300" => nothing,
"J303" => nothing
)
#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]
#1802.05243
const b_values = [3.40, 3.46, 3.55, 3.70, 3.85]
const b_values2 = [3.40, 3.46, 3.55, 3.70]
const ZM_data = [1.9684, 1.9935, 2.0253, 2.0630, 2.0814]
const ZM_error = [35, 27, 33, 38, 45] .* 1e-4
const ZM_tm_data = [2.6047, 2.6181, 2.6312, 2.6339, 2.6127]
const ZM_tm_error = [42, 33, 42, 48, 55] .* 1e-4
#1608.08900
const t0_data = [2.86, 3.659, 5.164, 8.595]
const t0_error = [11, 16, 18, 29] .* 1e-3
const t0_ph_value = #=[0.415] =# [0.4137]
const t0_ph_error = ones(1,1) .* #=4e-3 =# 3.6e-3
# 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
#Covariance matrices (Uncorrelated)
const C1 = zeros(5, 5)
const C2 = zeros(5, 5)
const C3 = zeros(4, 4)
const C4 = zeros(6,6)
const C5 = zeros(5, 5)
for i = 1:6
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
if i<=4
C3[i,i] = t0_error[i] ^ 2
end
end
end
#Definitions uwreal variables
const ZM = cobs(ZM_data, C1, "ZM values")
const ZM_tm = cobs(ZM_tm_data, C2, "ZM_tm values")
const M = cobs(M_values, C4, "charmed meson masses")
const mpi_ph = uwreal([134.8, 0.3], "mpi phys")
const t0_ph = uwreal([t0_ph_value[1], t0_ph_error[1]], "sqrt(8 t0) (fm)")
const t0_ = cobs(t0_data, C3, "t0")
const a_ = fill(t0_ph, length(t0_)) ./ sqrt.(8 .* t0_)
const Za = cobs(ZA_data, C5, "ZA")
#1802.05243
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::Float64) = z[1] + z[2] * (b - 3.79) + z[3] * (b - 3.79)^2
Mrat = uwreal([0.9148, 0.0088], "M/mhad")
#Mrat = 0.9148
# Renormalization constants, t0 and a as functions (f(beta))
zm(beta::Float64) = ZM[b_values .== beta][1]
zm_tm(beta::Float64) = Mrat / ZP(beta)
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
#=
# The code produces BDIO files for md_info (see OrderedDict md_info) and Wilson observables (see OrderedDict obs_w)
# The BDIO files are saved in path_bdio_md and path_bdio_w respectivily. Each BDIO file contains information about a given ensemble.
# Plateaux for different ensembles are defined in txt files (path_plat_w)
# The dat files must be located in the following way
path_data_w/ensemble -> *mesons.dat (Wilson)
path_data_w/ensemble -> *ms.dat
path_rw/ensemble -> *.ms1.dat
path_md/ensemble -> *.pbp.dat
# Example: path_rw/H400 contains H400r001.ms1.dat and H400r002.ms1.dat
# The target value of phi4 can be modified
# Masses and decay constants are in terms of the reference scale t0
# See read_bdio.jl for more information
=#
using Base: String
using LaTeXStrings: length
using OrderedCollections
using juobs, BDIO, DelimitedFiles, ADerrors, LaTeXStrings
#================== PATHS + INFO ==================#
const path_data_w = "/Users/alessandroconigli/Lattice/data/aux_obs_data/wilson"
const path_plat_w = "/Users/alessandroconigli/Lattice/data/aux_obs_data/plat_wilson.txt"
const path_rw = "/Users/alessandroconigli/Lattice/data/aux_obs_data/rwf"
const path_md = "/Users/alessandroconigli/Lattice/data/aux_obs_data/md"
const ens_list = ["D200"] # ["H101", "H102r002", "H400", "N202", "N200", "N203", "N300", "J303"]
const path_bdio_md = "/Users/alessandroconigli/Lattice/data/bdio_charm/md"
const path_bdio_w = "/Users/alessandroconigli/Lattice/data/bdio_charm/wilson"
const phi4_target = uwreal([1.117, 0.012], "phi4_target")
const rwf = true
#========= INCLUDES ==========#
include("./types.jl")
include("./tools.jl")
include("./const.jl")
#======== GET ENSEMBLE INFORMATION FROM DATABASE ==========#
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], trunc_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
#t0 [2.86, 3.659, 5.164, 8.595]
wpmm = Dict{String, Vector{Float64}}()
wpmm["H101"] = [-1.0, 4.0, -1.0, 14.0*2.86]
wpmm["H102r002"] = [-1.0, 4.0, -1.0, 14.0*2.86]
wpmm["H105"] = [-1.0, 4.0, -1.0, 14.0*2.86]
wpmm["H400"] = [-1.0, 4.0, -1.0, 14.0*3.659]
wpmm["N202"] = [-1.0, 4.0, -1.0, 14.0*5.164]
wpmm["N200"] = [-1.0, 4.0, -1.0, 14.0*5.164]
wpmm["N203"] = [-1.0, 4.0, -1.0, 14.0*5.164]
wpmm["N300"] = [-1.0, 4.0, -1.0, 14.0*8.595]
wpmm["J303"] = [-1.0, 4.0, -1.0, 14.0*8.595]
##
#======== ANALYSIS ==========#
gen_mulist = Vector{Vector{Vector{Float64}}}(undef, length(ens_list))
md_info = Vector(undef, length(ensinfo))
obs_tm_shifted = Vector(undef, length(ensinfo))
#obs
obs_w = Vector(undef, length(ensinfo))
for (k, ens) in enumerate(ensinfo)
# t0
t0_ens, YW, W = get_t0(path_data_w, ens, rw=rwf, path_rw=path_rw, pl=true)
# WILSON correlators
pp_w, pp_wW, _ = get_corr(path_data_w, ens, "G5", "G5", rw=rwf, path_rw=path_rw, legacy=true)
pp_w_d1, _, _ = get_corr(path_data_w, ens, "G5_d1", "G5_d1", rw=rwf, path_rw=path_rw, legacy=true)
pp_w_d2, _, _ = get_corr(path_data_w, ens, "G5_d2", "G5_d2", rw=rwf, path_rw=path_rw, legacy=true)
# WILSON masses
m_w = get_meff_w(pp_w, ens, pl=true)
kappa_list = getfield.(pp_w, :kappa)
mll_w = get_ll_w(kappa_list, m_w, ens.deg)
mls_w = ens.deg ? mll_w : get_ls_w(kappa_list, m_w, ens.deg)
phi2 = 8 * t0_ens * mll_w^2
phi4 = ens.deg ? 8 * t0_ens * 1.5 * mll_w^2 : 8 * t0_ens * (0.5 * mll_w^2 + mls_w^2)
# MASS SHIFTS
dSdm = read_pbp(path_md, ens.id)
ppll = get_ll_w(kappa_list, pp_w, ens.deg)
ppllW = get_ll_w(kappa_list, pp_wW, ens.deg)
ppll_d1 = get_ll_w(kappa_list, pp_w_d1, ens.deg)
ppll_d2 = get_ll_w(kappa_list, pp_w_d2, ens.deg)
dphi4_s1, dphi4_s2 = md_sea(phi4, dSdm, YW, W) .+ md_sea(phi4, dSdm, ppllW, W)
dphi2_s1, dphi2_s2 = md_sea(phi2, dSdm, YW, W) .+ md_sea(phi2, dSdm, ppllW, W)
dphi4_v1, dphi4_v2 = md_val(phi4, ppll, [ppll_d1, ppll_d2])
dphi2_v1, dphi2_v2 = md_val(phi2, ppll, [ppll_d1, ppll_d2])
if !ens.deg
ppls = get_ls_w(kappa_list, pp_w, ens.deg)
pplsW = get_ls_w(kappa_list, pp_wW, ens.deg)
ppls_d1 = get_ls_w(kappa_list, pp_w_d1, ens.deg)
ppls_d2 = get_ls_w(kappa_list, pp_w_d2, ens.deg)
aux1, aux2 = md_val(phi4, ppls, [ppls_d1, ppls_d2])
dphi4_v1 = dphi4_v1 + aux1
dphi4_v2 = dphi4_v2 + aux2
dphi4_s1, dphi4_s2 = (dphi4_s1, dphi4_s2) .+ md_sea(phi4, dSdm, pplsW, W)
end
# Dict: Deltam, phi2, phi4, t0 (shifted)
deltam = (phi4_target - phi4) / (2*dphi4_s1 + dphi4_s2 + dphi4_v1 + dphi4_v2)
dt0_s1, dt0_s2 = md_sea(t0_ens, dSdm, YW, W)
t0_ens_shifted = t0_ens + deltam * (2 * dt0_s1 + dt0_s2)
phi2_shifted = phi2 + deltam * (2*dphi2_s1 + dphi2_s2 + dphi2_v1 + dphi2_v2)
phi4_shifted = phi4 + deltam * (2*dphi4_s1 + dphi4_s2 + dphi4_v1 + dphi4_v2)
md_info[k] = OrderedDict(
"deltam" => deltam,
"t0_shifted" => t0_ens_shifted,
"phi2_shifted" => phi2_shifted,
"phi4_shifted" => phi4_shifted
)
obs_w[k] = OrderedDict(
"mll" => sqrt(8 * t0_ens) * mll_w,
"mls" => sqrt(8 * t0_ens) * mls_w,
"t0" => t0_ens,
"phi2" => phi2,
"phi4" => phi4
)
end
## WRITE BDIO
# MD INFO
for (k, obs) in enumerate(md_info) #loop over ensembles
ens = ensinfo[k].id
p = joinpath(path_bdio_md, string(ens, ".bdio"))
fb = BDIO_open(p, "w", ens)
uinfo = 0
for (key, value) in obs #loop over observables
write_uwreal(value, fb, uinfo)
uinfo += 1
end
BDIO_close!(fb)
end
# WILSON
for (k, obs) in enumerate(obs_w) #loop over ensembles
ens = ensinfo[k].id
p = joinpath(path_bdio_w, string(ens, ".bdio"))
fb = BDIO_open(p, "w", ens)
uinfo = 0
for (key, value) in obs #loop over observables
write_uwreal(value, 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
dtr::Int64
trunc::Union{Int64, Vector{Int64}, Nothing}
function EnsInfo(ens_id::String, info::Vector{Float64})
id = ens_id
L = info[1]
beta = info[2]
deg = info[3]
mpi = info[4]
dtr = info[5]
return new(id, L, beta, deg, mpi, dtr, nothing)
end
function EnsInfo(ens_id::String, info::Vector{Float64}, trunc::Union{Nothing, Int64, Vector{Int64}})
id = ens_id
L = info[1]
beta = info[2]
deg = info[3]
mpi = info[4]
dtr = info[5]
return new(id, L, beta, deg, mpi, dtr, trunc)
end
end
mutable struct EnsObs
ensinfo::EnsInfo
mu_list:: Vector{Vector{Float64}}
is_pseudo::Bool
m_ll::Union{Nothing,uwreal}
m_ls::Union{Nothing,uwreal}
m_lh::Union{Nothing,Vector{uwreal}}
m_ss::Union{Nothing,uwreal}
m_sh::Union{Nothing,Vector{uwreal}}
m_hh::Union{Nothing,Vector{uwreal}}
f_ll::Union{Nothing,uwreal}
f_ls::Union{Nothing,uwreal}
f_lh::Union{Nothing,Vector{uwreal}}
f_ss::Union{Nothing,uwreal}
f_sh::Union{Nothing,Vector{uwreal}}
f_hh::Union{Nothing,Vector{uwreal}}
m_ll_vec::Union{Nothing,uwreal}
m_ls_vec::Union{Nothing,uwreal}
m_lh_vec::Union{Nothing,Vector{uwreal}}
m_ss_vec::Union{Nothing,uwreal}
m_sh_vec::Union{Nothing,Vector{uwreal}}
m_hh_vec::Union{Nothing,Vector{uwreal}}
f_ll_vec::Union{Nothing,uwreal}
f_ls_vec::Union{Nothing,uwreal}
f_lh_vec::Union{Nothing,Vector{uwreal}}
f_ss_vec::Union{Nothing,uwreal}
f_sh_vec::Union{Nothing,Vector{uwreal}}
f_hh_vec::Union{Nothing,Vector{uwreal}}
m_lh_match::Union{Nothing,uwreal}
m_sh_match::Union{Nothing,uwreal}
m_hh_match::Union{Nothing,uwreal}
f_lh_match::Union{Nothing,uwreal}
f_sh_match::Union{Nothing,uwreal}
f_hh_match::Union{Nothing,uwreal}
m_lh_vec_match::Union{Nothing,uwreal}
m_sh_vec_match::Union{Nothing,uwreal}
m_hh_vec_match::Union{Nothing,uwreal}
f_lh_vec_match::Union{Nothing,uwreal}
f_sh_vec_match::Union{Nothing,uwreal}
f_hh_vec_match::Union{Nothing,uwreal}
muh_target::Union{Nothing,uwreal}
a::Union{Nothing,uwreal}
t0::Union{Nothing,uwreal}
deltam::Union{Nothing, uwreal}
function EnsObs(ens::EnsInfo, mu::Vector{Vector{Float64}}, m_ps::Vector{uwreal}, f_ps::Vector{uwreal}, m_vec::Vector{uwreal}, f_vec::Vector{uwreal})
a = new()
a.ensinfo = ens
a.mu_list = mu
a.is_pseudo = true
a.m_ll = get_ll(a.mu_list, m_ps,a.ensinfo.deg)
a.ensinfo.deg ? a.m_ls = a.m_ll : a.m_ls = get_ls(a.mu_list, m_ps, a.ensinfo.deg)
a.ensinfo.deg ? a.m_ss = a.m_ll : a.m_ss = get_ss(a.mu_list, m_ps, a.ensinfo.deg)
a.m_lh = get_lh(a.mu_list, m_ps,a.ensinfo.deg)
a.ensinfo.deg ? a.m_sh = a.m_lh : a.m_sh = get_sh(a.mu_list, m_ps, a.ensinfo.deg)
a.m_hh = get_hh(a.mu_list, m_ps,a.ensinfo.deg)
a.f_ll = get_ll(a.mu_list, f_ps, a.ensinfo.deg)
a.ensinfo.deg ? a.f_ls = a.f_ll : a.f_ls = get_ls(a.mu_list, f_ps, a.ensinfo.deg)
a.ensinfo.deg ? a.f_ss = a.f_ll : a.f_ss = get_ss(a.mu_list, f_ps, a.ensinfo.deg)
a.f_lh = get_lh(a.mu_list, f_ps,a.ensinfo.deg)
a.ensinfo.deg ? a.f_sh = a.f_lh : a.f_sh = get_sh(a.mu_list, f_ps, a.ensinfo.deg)
a.f_hh = get_hh(a.mu_list, f_ps,a.ensinfo.deg)
a.m_ll_vec = get_ll(a.mu_list, m_vec,a.ensinfo.deg)
a.ensinfo.deg ? a.m_ls_vec = a.m_ll_vec : a.m_ls_vec = get_ls(a.mu_list, m_vec, a.ensinfo.deg)
a.ensinfo.deg ? a.m_ss_vec = a.m_ll_vec : a.m_ss_vec = get_ss(a.mu_list, m_vec, a.ensinfo.deg)
a.m_lh_vec = get_lh(a.mu_list, m_vec, a.ensinfo.deg)
a.ensinfo.deg ? a.m_sh_vec = a.m_lh_vec : a.m_sh_vec = get_sh(a.mu_list, m_vec, a.ensinfo.deg)
a.m_hh_vec = get_hh(a.mu_list, m_vec, a.ensinfo.deg)
a.f_ll_vec = get_ll(a.mu_list, f_vec, a.ensinfo.deg)
a.ensinfo.deg ? a.f_ls_vec = a.f_ll_vec : a.f_ls_vec = get_ls(a.mu_list, f_vec, a.ensinfo.deg)
a.ensinfo.deg ? a.f_ss_vec = a.f_ll_vec : a.f_ss_vec = get_ss(a.mu_list, f_vec, a.ensinfo.deg)
a.f_lh_vec = get_lh(a.mu_list, f_vec,a.ensinfo.deg)
a.ensinfo.deg ? a.f_sh_vec = a.f_lh_vec : a.f_sh_vec = get_sh(a.mu_list, f_vec, a.ensinfo.deg)
a.f_hh_vec = get_hh(a.mu_list, f_vec, a.ensinfo.deg)
a.m_lh_match = nothing
a.m_sh_match = nothing
a.m_hh_match = nothing
a.f_lh_match = nothing
a.f_sh_match = nothing
a.f_hh_match = nothing
a.m_lh_vec_match = nothing
a.m_sh_vec_match = nothing
a.m_hh_vec_match = nothing
a.f_lh_vec_match = nothing
a.f_sh_vec_match = nothing
a.f_hh_vec_match = nothing
a.muh_target = nothing
a.a = nothing
a.t0 = nothing
a.deltam = nothing
return a
end
function EnsObs(ens::EnsInfo, mu::Vector{Vector{Float64}}, m_ps::Vector{uwreal}, m_vec::Vector{uwreal})
a = new()
a.ensinfo = ens
a.mu_list = mu
a.is_pseudo = true
a.m_ll = get_ll(a.mu_list, m_ps,a.ensinfo.deg)
a.ensinfo.deg ? a.m_ls = a.m_ll : a.m_ls = get_ls(a.mu_list, m_ps, a.ensinfo.deg)
a.ensinfo.deg ? a.m_ss = a.m_ll : a.m_ss = get_ss(a.mu_list, m_ps, a.ensinfo.deg)
a.m_lh = get_lh(a.mu_list, m_ps,a.ensinfo.deg)
a.ensinfo.deg ? a.m_sh = a.m_lh : a.m_sh = get_sh(a.mu_list, m_ps, a.ensinfo.deg)
a.m_hh = get_hh(a.mu_list, m_ps,a.ensinfo.deg)
a.m_ll_vec = get_ll(a.mu_list, m_vec,a.ensinfo.deg)
a.ensinfo.deg ? a.m_ls_vec = a.m_ll_vec : a.m_ls_vec = get_ls(a.mu_list, m_vec, a.ensinfo.deg)
a.ensinfo.deg ? a.m_ss_vec = a.m_ll_vec : a.m_ss_vec = get_ss(a.mu_list, m_vec, a.ensinfo.deg)
a.m_lh_vec = get_lh(a.mu_list, m_vec, a.ensinfo.deg)
a.ensinfo.deg ? a.m_sh_vec = a.m_lh_vec : a.m_sh_vec = get_sh(a.mu_list, m_vec, a.ensinfo.deg)
a.m_hh_vec = get_hh(a.mu_list, m_vec, a.ensinfo.deg)
a.m_lh_match = nothing
a.m_sh_match = nothing
a.m_hh_match = nothing
a.m_lh_vec_match = nothing
a.m_sh_vec_match = nothing
a.m_hh_vec_match = nothing
a.muh_target = nothing
a.a = nothing
a.t0 = nothing
return a
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
function Cat(_obs::Vector{uwreal}, _xtofit::Array{uwreal}, _phi_ph::uwreal, _info::String)
a = new()
a.obs = _obs
#a.models = _models
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)
return a
end
end
\ No newline at end of file
#========= ENSEMBLE DATABASE ========#
ens_db = Dict(
#"ens_id"=>[L, beta, is_deg?, m_pi, dtr]
"H102r002" => [32, 3.4, false, 0.15306, 2],
#"H102r001" => [32, 3.4, false, 0.15306, 2],
"H105" => [32, 3.4, false, 0.12151, 2],
"H101" => [32, 3.4, true, 0.17979, 2],
"H400" => [32, 3.46, true, 0.16345, 1],
"N200" => [48, 3.55, false, 0.09222, 1],
"N202" => [48, 3.55, true, 0.13407, 2],
"N203" => [48, 3.55, false, 0.11224, 1],
"D200" => [64, 3.55, false, 0.06611, 2],
"N300" => [48, 3.70, true, 0.10630, 1],
"J303" => [64, 3.70, false, 0.06514, 2]
)
trunc_db = Dict(
"H102r002" => nothing,
#"H102r001" => nothing,
"H105" => nothing,
"H101" => nothing,
"H400" => nothing,
"N200" => nothing,
"N202" => nothing,
"N203" => nothing,
"D200" => 1000,
"N300" => nothing,
"J303" => nothing
)
#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]
#1802.05243
const b_values = [3.40, 3.46, 3.55, 3.70, 3.85]
const b_values2 = [3.40, 3.46, 3.55, 3.70]
const ZM_data = [1.9684, 1.9935, 2.0253, 2.0630, 2.0814]
const ZM_error = [35, 27, 33, 38, 45] .* 1e-4
const ZM_tm_data = [2.6047, 2.6181, 2.6312, 2.6339, 2.6127]
const ZM_tm_error = [42, 33, 42, 48, 55] .* 1e-4
#1608.08900
const t0_data = [2.86, 3.659, 5.164, 8.595]
const t0_error = [11, 16, 18, 29] .* 1e-3
const t0_ph_value = #=[0.415] =# [0.4137]
const t0_ph_error = ones(1,1) .* #=4e-3 =# 3.6e-3
# 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
#Covariance matrices (Uncorrelated)
const C1 = zeros(5, 5)
const C2 = zeros(5, 5)
const C3 = zeros(4, 4)
const C4 = zeros(6,6)
const C5 = zeros(5, 5)
for i = 1:6
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
if i<=4
C3[i,i] = t0_error[i] ^ 2
end
end
end
#Definitions uwreal variables
const ZM = cobs(ZM_data, C1, "ZM values")
const ZM_tm = cobs(ZM_tm_data, C2, "ZM_tm values")
const M = cobs(M_values, C4, "charmed meson masses")
const mpi_ph = uwreal([134.8, 0.3], "mpi phys")
const t0_ph = uwreal([t0_ph_value[1], t0_ph_error[1]], "sqrt(8 t0) (fm)")
const t0_ = cobs(t0_data, C3, "t0")
const a_ = fill(t0_ph, length(t0_)) ./ sqrt.(8 .* t0_)
const Za = cobs(ZA_data, C5, "ZA")
#1802.05243
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::Float64) = z[1] + z[2] * (b - 3.79) + z[3] * (b - 3.79)^2
Mrat = uwreal([0.9148, 0.0088], "M/mhad")
#Mrat = 0.9148
# Renormalization constants, t0 and a as functions (f(beta))
zm(beta::Float64) = ZM[b_values .== beta][1]
zm_tm(beta::Float64) = Mrat / ZP(beta)
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
###################################
########## MASSS ##########
###################################
##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
a2loga(x) = x[:,1] .* log.(x[:,1]) # (a^2/8t0)^2 * log(a^2/8t0)
phih2loga(x) = x[:,3].^2 .* log.(x[:,1]) # phih^2*a^2/8t0
# full list
func_list = [a2phi2, a2phih2, a4phih4, a4phih4_2, a4cutoff]
label_list = ["a2l", "a2h2", "a4h4", "a4h2", "a4"]
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]
# a^2log(a) and phih^2log(a)
# func_list = [ a2phih2, a2loga, phih2loga]
# label_list = [ "a2h2", "a2loga", "h2loga"]
# func_map = [Bool.([i,j,k]) for i=0:1 for j=0:1 for k=0:1 ]
# no a2l
# func_list = [ a2phih2, a4phih4, a4phih4_2, a4cutoff]
# label_list = [ "a2h2", "a4h4", "a4h2", "a4"]
# func_map = [Bool.([i,j,k,m]) for i=0:1 for j=0:1 for k=0:1 for m=0:1]
##COMBINATIONS (LINEAR)
npar = length(func_list) # number of extra parameters
n_param = Vector(4:4)
label_cutoff = Vector{Vector{String}}(undef, 0)
push!(label_cutoff, ["a2"])
#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)
f_lin[n] = Vector{Function}(undef, length(aux))
f_aux[n] = Vector{Function}(undef, length(aux))
k = 1
for a in aux
#vectorized function
push!(n_param, 4+n-1)
push!(label_cutoff, label_list[a])
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, 4+n)
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)
#n_param2 = vcat(n_param, n_non_lin_param)
########################################
########## DEC. CONST. ##########
########################################
phi2_sym = 0.744666
##FUNCTIONS
f_a2phi2(x) = x[:,1] .* x[:,2] # phi2*a^2/8t0
f_a2phih2(x) = x[:,1] .* (x[:,3]).^2 # phih^2*a^2/8t0
f_a4phih4(x) = x[:,1].^(2) .* x[:,3].^4 # phih^4*(a^2/8t0)^2
f_a4phih2(x) = x[:,1].^(2) .* x[:,3].^2 # phih^2*(a^2/8t0)^2
f_a4cutoff(x) = x[:,1].^(2) # (a^2/8t0)^2
f_a2loga(x) = x[:,1] .* log.(x[:,1]) # (a^2/8t0)^2 * log(a^2/8t0)
f_phih2loga(x) = x[:,3].^2 .* log.(x[:,1]) # phih^2*a^2/8t0
##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]
f_basemodel1(x,p) = p[1] .+ p[2] .* x[:,2] .+ p[3] .* (1.0 ./ sqrt.(x[:,3])) .+ p[4] .* x[:,1]
f_basemodel2(x,p) = p[1] .+ p[2] .* (3 .* phi2_sym - 2 .* x[:,2]) .+ p[3] .* (1.0 ./ sqrt.(x[:,3])) .+ p[5] .* x[:,1]
#CHIRAL LOGS
f_basemodel1_clog(x,p) = p[1] .+ p[2] .* x[:,2] .+ p[3] .* (1.0 ./ sqrt.(x[:,3])) .+ p[5] .* x[:,1] .+ p[4] .* (3 .* x[:,2] .*log.(x[:,2]) .+
(3 .*phi2_sym .- x[:,2]) .* log.(1.5 .*phi2_sym .- 0.5*x[:,2]) .+ (2 .* phi2_sym .- x[:,2]) ./ 3 .* log.(2 .*phi2_sym .- x[:,2]))
f_basemodel2_clog(x,p) = p[1] .+ p[2] .* (3 .* phi2_sym - 2 .* x[:,2]) .+ p[3] .* (1.0 ./ sqrt.(x[:,3])) .+ p[6] .* x[:,1] .+ 4 .* p[4] .*(
(1.5 .* phi2_sym .- 0.5.*x[:, 2]) .* log.(1.5 .* phi2_sym .- 0.5.*x[:, 2]) .+ (2 .* phi2_sym .- x[:,2]) ./ 3 .* log.((2 .* phi2_sym .- x[:,2])))
f_func_list = [f_a2phi2, f_a2phih2, f_a4phih4, f_a4phih2, f_a4cutoff]
#f_func_list = [f_a2loga, f_a2phih2, f_a4phih4, f_a4phih2, f_a4cutoff]
f_npar = length(f_func_list) # number of extra parameters
## FLIN + FAUX
f_f_lin1 = Vector{Vector{Function}}(undef, f_npar+1) #f[i][j]-> i: number of extra parameters, j: combinations
f_f_lin2 = Vector{Vector{Function}}(undef, f_npar+1) #f[i][j]-> i: number of extra parameters, j: combinations
f_f_aux1 = Vector{Vector{Function}}(undef, f_npar+1)
f_f_aux2 = Vector{Vector{Function}}(undef, f_npar+1)
f_f_lin1[1] = Vector{Function}(undef, 1)
f_f_lin2[1] = Vector{Function}(undef, 1)
f_f_aux1[1] = Vector{Function}(undef, 1)
f_f_aux2[1] = Vector{Function}(undef, 1)
f_f_lin1[1][1] = (x,p) -> f_basemodel1(x, p)
f_f_lin2[1][1] = (x,p) -> f_basemodel2(x, p)
f_f_aux1[1][1] = (x,p) -> p[1] + p[2] * x[:,2] + p[3] * (1.0 ./ sqrt.(x[:,3])) + p[4] * x[:,1]
f_f_aux2[1][1] = (x,p) -> p[1] + p[2] * (3*phi2_sym - 2*x[:,2]) + p[3] * (1.0 ./ sqrt.(x[:,3])) + p[4] * x[:,1]
# FLIN + FAUX (CLOGS) [hep-ph/9206230]
f_f_lin1_clog = Vector{Vector{Function}}(undef, f_npar+1) #f[i][j]-> i: number of extra parameters, j: combinations
f_f_lin2_clog = Vector{Vector{Function}}(undef, f_npar+1) #f[i][j]-> i: number of extra parameters, j: combinations
f_f_aux1_clog = Vector{Vector{Function}}(undef, f_npar+1)
f_f_aux2_clog = Vector{Vector{Function}}(undef, f_npar+1)
f_f_lin1_clog[1] = Vector{Function}(undef, 1)
f_f_lin2_clog[1] = Vector{Function}(undef, 1)
f_f_aux1_clog[1] = Vector{Function}(undef, 1)
f_f_aux2_clog[1] = Vector{Function}(undef, 1)
f_f_lin1_clog[1][1] = (x,p) -> f_basemodel1_clog(x, p)
f_f_lin2_clog[1][1] = (x,p) -> f_basemodel2_clog(x, p)
f_f_aux1_clog[1][1] = (x,p) -> p[1] + p[2] * x[:,2] + p[3] * (1.0 ./ sqrt.(x[:,3])) + p[5] * x[:,1] + p[4] * (3 * x[:,2] .*log.(x[:,2]) +
(3 *phi2_sym - x[:,2]) .* log.(1.5 *phi2_sym - 0.5*x[:,2]) + (2 * phi2_sym - x[:,2]) / 3 .* log.(2 *phi2_sym - x[:,2]))
f_f_aux2_clog[1][1] = (x,p) -> p[1] + p[2] * (3 * phi2_sym - 2 * x[:,2]) + p[3] * (1.0 ./ sqrt.(x[:,3])) + p[6] * x[:,1] + 4 * p[4] *(
(1.5 * phi2_sym - 0.5*x[:, 2]) .* log.(1.5 * phi2_sym - 0.5*x[:, 2]) + (2 * phi2_sym - x[:,2]) / 3 .* log.((2 * phi2_sym - x[:,2])))
## loop over combinations
for n = 2:f_npar+1
aux = filter(x->sum(x) == n-1, func_map)
f_f_lin1[n] = Vector{Function}(undef, length(aux))
f_f_lin2[n] = Vector{Function}(undef, length(aux))
f_f_aux1[n] = Vector{Function}(undef, length(aux))
f_f_aux2[n] = Vector{Function}(undef, length(aux))
f_f_lin1_clog[n] = Vector{Function}(undef, length(aux))
f_f_lin2_clog[n] = Vector{Function}(undef, length(aux))
f_f_aux1_clog[n] = Vector{Function}(undef, length(aux))
f_f_aux2_clog[n] = Vector{Function}(undef, length(aux))
k=1
for a in aux
#vectorized function
f_f_lin1[n][k] = (x,p) -> f_basemodel1(x,p) .+ sum([p[i+5] for i=1:2:2*(n-1)] .* (fill(x,n-1) .|> f_func_list[a]))
f_f_aux1[n][k] = (x,p) -> f_f_aux1[1][1](x, p) +
sum([p[i+5] for i=1:2:2*(n-1)] .* (fill(x,n-1) .|> f_func_list[a]))
f_f_lin2[n][k] = (x,p) -> f_basemodel2(x,p) .+ sum([p[i+6] for i=1:2:2*(n-1)] .* (fill(x,n-1) .|> f_func_list[a]))
f_f_aux2[n][k] = (x,p) -> f_f_aux2[1][1](x, p) +
sum([p[i+6] for i=1:2:2*(n-1)] .* (fill(x,n-1) .|> f_func_list[a]))
f_f_lin1_clog[n][k] = (x,p) -> f_basemodel1_clog(x,p) .+ sum([p[i+6] for i=1:2:2*(n-1)] .* (fill(x,n-1) .|> f_func_list[a]))
f_f_aux1_clog[n][k] = (x,p) -> f_f_aux1_clog[1][1](x,p) +
sum([p[i+6] for i=1:2:2*(n-1)] .* (fill(x,n-1) .|> f_func_list[a]))
f_f_lin2_clog[n][k] = (x,p) -> f_basemodel2_clog(x,p) .+ sum([p[i+7] for i=1:2:2*(n-1)] .* (fill(x,n-1) .|> f_func_list[a]))
f_f_aux2_clog[n][k] = (x,p) -> f_f_aux2_clog[1][1](x,p) +
sum([p[i+7] for i=1:2:2*(n-1)] .* (fill(x,n-1) .|> f_func_list[a]))
k = k+1
end
end
f_npar_comb = 2 * f_npar
f_n_param_comb = collect(5:2:f_npar_comb+5)
f_n_param_comb_clog = collect(6:2:f_npar_comb+6)
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
using BDIO, ADerrors
function read_BDIO(path::String, uinfo::Int64)
r = Vector{uwreal}(undef, 0)
fb = BDIO_open(path, "r")
BDIO_seek!(fb)
if BDIO_get_uinfo(fb) == uinfo
push!(r, read_uwreal(fb))
end
while BDIO_seek!(fb, 2)
if BDIO_get_uinfo(fb) == uinfo
push!(r, read_uwreal(fb))
end
end
BDIO_close!(fb)
return r
end
function read_BDIO(path::String, type::String, obs::String)
dict_w = Dict(
"mll" => 0,
"mls" => 1,
"t0" => 2,
"phi2" => 3,
"phi4" => 4
)
dict_tm = Dict(
"mll" => 0,
"mls" => 1,
"mlh" => 2,
"msh" => 3,
"mhh" => 4,
"flh" => 5,
"fsh" => 6,
"fhh" => 7,
"mlh_star" => 8,
"msh_star" => 9,
"mhh_star" => 10,
"flh_star" => 11,
"fsh_star" => 12,
"fhh_star" => 13,
"muh" => 14
)
dict_md = Dict(
"deltam" => 0,
"t0_shifted" => 1,
"phi2_shifted" => 2,
"phi4_shifted" => 3
)
dict2dict = Dict("w" => dict_w, "tm" => dict_tm, "md" => dict_md)
if !(type in keys(dict2dict))
error("Incorrect type.\ntype = $(keys(dict2dict))")
end
if !(obs in keys(dict2dict[type]))
error("Incorrect obs.\nobs = $(keys(dict2dict[type]))")
end
return read_BDIO(path, dict2dict[type][obs])
end
This diff is collapsed.
mutable struct EnsInfo
id::String
L::Int64
beta::Float64
deg::Bool
mpi::Float64
dtr::Int64
trunc::Union{Int64, Vector{Int64}, Nothing}
function EnsInfo(ens_id::String, info::Vector{Float64})
id = ens_id
L = info[1]
beta = info[2]
deg = info[3]
mpi = info[4]
dtr = info[5]
return new(id, L, beta, deg, mpi, dtr, nothing)
end
function EnsInfo(ens_id::String, info::Vector{Float64}, trunc::Union{Nothing, Int64, Vector{Int64}})
id = ens_id
L = info[1]
beta = info[2]
deg = info[3]
mpi = info[4]
dtr = info[5]
return new(id, L, beta, deg, mpi, dtr, trunc)
end
end
mutable struct EnsObs
ensinfo::EnsInfo
mu_list:: Vector{Vector{Float64}}
is_pseudo::Bool
m_ll::Union{Nothing,uwreal}
m_ls::Union{Nothing,uwreal}
m_lh::Union{Nothing,Vector{uwreal}}
m_ss::Union{Nothing,uwreal}
m_sh::Union{Nothing,Vector{uwreal}}
m_hh::Union{Nothing,Vector{uwreal}}
f_ll::Union{Nothing,uwreal}
f_ls::Union{Nothing,uwreal}
f_lh::Union{Nothing,Vector{uwreal}}
f_ss::Union{Nothing,uwreal}
f_sh::Union{Nothing,Vector{uwreal}}
f_hh::Union{Nothing,Vector{uwreal}}
m_ll_vec::Union{Nothing,uwreal}
m_ls_vec::Union{Nothing,uwreal}
m_lh_vec::Union{Nothing,Vector{uwreal}}
m_ss_vec::Union{Nothing,uwreal}
m_sh_vec::Union{Nothing,Vector{uwreal}}
m_hh_vec::Union{Nothing,Vector{uwreal}}
f_ll_vec::Union{Nothing,uwreal}
f_ls_vec::Union{Nothing,uwreal}
f_lh_vec::Union{Nothing,Vector{uwreal}}
f_ss_vec::Union{Nothing,uwreal}
f_sh_vec::Union{Nothing,Vector{uwreal}}
f_hh_vec::Union{Nothing,Vector{uwreal}}
m_lh_match::Union{Nothing,uwreal}
m_sh_match::Union{Nothing,uwreal}
m_hh_match::Union{Nothing,uwreal}
f_lh_match::Union{Nothing,uwreal}
f_sh_match::Union{Nothing,uwreal}
f_hh_match::Union{Nothing,uwreal}
m_lh_vec_match::Union{Nothing,uwreal}
m_sh_vec_match::Union{Nothing,uwreal}
m_hh_vec_match::Union{Nothing,uwreal}
f_lh_vec_match::Union{Nothing,uwreal}
f_sh_vec_match::Union{Nothing,uwreal}
f_hh_vec_match::Union{Nothing,uwreal}
muh_target::Union{Nothing,uwreal}
a::Union{Nothing,uwreal}
t0::Union{Nothing,uwreal}
deltam::Union{Nothing, uwreal}
function EnsObs(ens::EnsInfo, mu::Vector{Vector{Float64}}, m_ps::Vector{uwreal}, f_ps::Vector{uwreal}, m_vec::Vector{uwreal}, f_vec::Vector{uwreal})
a = new()
a.ensinfo = ens
a.mu_list = mu
a.is_pseudo = true
a.m_ll = get_ll(a.mu_list, m_ps,a.ensinfo.deg)
a.ensinfo.deg ? a.m_ls = a.m_ll : a.m_ls = get_ls(a.mu_list, m_ps, a.ensinfo.deg)
a.ensinfo.deg ? a.m_ss = a.m_ll : a.m_ss = get_ss(a.mu_list, m_ps, a.ensinfo.deg)
a.m_lh = get_lh(a.mu_list, m_ps,a.ensinfo.deg)
a.ensinfo.deg ? a.m_sh = a.m_lh : a.m_sh = get_sh(a.mu_list, m_ps, a.ensinfo.deg)
a.m_hh = get_hh(a.mu_list, m_ps,a.ensinfo.deg)
a.f_ll = get_ll(a.mu_list, f_ps, a.ensinfo.deg)
a.ensinfo.deg ? a.f_ls = a.f_ll : a.f_ls = get_ls(a.mu_list, f_ps, a.ensinfo.deg)
a.ensinfo.deg ? a.f_ss = a.f_ll : a.f_ss = get_ss(a.mu_list, f_ps, a.ensinfo.deg)
a.f_lh = get_lh(a.mu_list, f_ps,a.ensinfo.deg)
a.ensinfo.deg ? a.f_sh = a.f_lh : a.f_sh = get_sh(a.mu_list, f_ps, a.ensinfo.deg)
a.f_hh = get_hh(a.mu_list, f_ps,a.ensinfo.deg)
a.m_ll_vec = get_ll(a.mu_list, m_vec,a.ensinfo.deg)
a.ensinfo.deg ? a.m_ls_vec = a.m_ll_vec : a.m_ls_vec = get_ls(a.mu_list, m_vec, a.ensinfo.deg)
a.ensinfo.deg ? a.m_ss_vec = a.m_ll_vec : a.m_ss_vec = get_ss(a.mu_list, m_vec, a.ensinfo.deg)
a.m_lh_vec = get_lh(a.mu_list, m_vec, a.ensinfo.deg)
a.ensinfo.deg ? a.m_sh_vec = a.m_lh_vec : a.m_sh_vec = get_sh(a.mu_list, m_vec, a.ensinfo.deg)
a.m_hh_vec = get_hh(a.mu_list, m_vec, a.ensinfo.deg)
a.f_ll_vec = get_ll(a.mu_list, f_vec, a.ensinfo.deg)
a.ensinfo.deg ? a.f_ls_vec = a.f_ll_vec : a.f_ls_vec = get_ls(a.mu_list, f_vec, a.ensinfo.deg)
a.ensinfo.deg ? a.f_ss_vec = a.f_ll_vec : a.f_ss_vec = get_ss(a.mu_list, f_vec, a.ensinfo.deg)
a.f_lh_vec = get_lh(a.mu_list, f_vec,a.ensinfo.deg)
a.ensinfo.deg ? a.f_sh_vec = a.f_lh_vec : a.f_sh_vec = get_sh(a.mu_list, f_vec, a.ensinfo.deg)
a.f_hh_vec = get_hh(a.mu_list, f_vec, a.ensinfo.deg)
a.m_lh_match = nothing
a.m_sh_match = nothing
a.m_hh_match = nothing
a.f_lh_match = nothing
a.f_sh_match = nothing
a.f_hh_match = nothing
a.m_lh_vec_match = nothing
a.m_sh_vec_match = nothing
a.m_hh_vec_match = nothing
a.f_lh_vec_match = nothing
a.f_sh_vec_match = nothing
a.f_hh_vec_match = nothing
a.muh_target = nothing
a.a = nothing
a.t0 = nothing
a.deltam = nothing
return a
end
function EnsObs(ens::EnsInfo, mu::Vector{Vector{Float64}}, m_ps::Vector{uwreal}, m_vec::Vector{uwreal})
a = new()
a.ensinfo = ens
a.mu_list = mu
a.is_pseudo = true
a.m_ll = get_ll(a.mu_list, m_ps,a.ensinfo.deg)
a.ensinfo.deg ? a.m_ls = a.m_ll : a.m_ls = get_ls(a.mu_list, m_ps, a.ensinfo.deg)
a.ensinfo.deg ? a.m_ss = a.m_ll : a.m_ss = get_ss(a.mu_list, m_ps, a.ensinfo.deg)
a.m_lh = get_lh(a.mu_list, m_ps,a.ensinfo.deg)
a.ensinfo.deg ? a.m_sh = a.m_lh : a.m_sh = get_sh(a.mu_list, m_ps, a.ensinfo.deg)
a.m_hh = get_hh(a.mu_list, m_ps,a.ensinfo.deg)
a.m_ll_vec = get_ll(a.mu_list, m_vec,a.ensinfo.deg)
a.ensinfo.deg ? a.m_ls_vec = a.m_ll_vec : a.m_ls_vec = get_ls(a.mu_list, m_vec, a.ensinfo.deg)
a.ensinfo.deg ? a.m_ss_vec = a.m_ll_vec : a.m_ss_vec = get_ss(a.mu_list, m_vec, a.ensinfo.deg)
a.m_lh_vec = get_lh(a.mu_list, m_vec, a.ensinfo.deg)
a.ensinfo.deg ? a.m_sh_vec = a.m_lh_vec : a.m_sh_vec = get_sh(a.mu_list, m_vec, a.ensinfo.deg)
a.m_hh_vec = get_hh(a.mu_list, m_vec, a.ensinfo.deg)
a.m_lh_match = nothing
a.m_sh_match = nothing
a.m_hh_match = nothing
a.m_lh_vec_match = nothing
a.m_sh_vec_match = nothing
a.m_hh_vec_match = nothing
a.muh_target = nothing
a.a = nothing
a.t0 = nothing
return a
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_vs_exp::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_vs_exp = 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
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
# FUNCTIONS ##FUNCTIONS
#=
basemodel(x,p) = p[1] .+ p[2] .* x[:,2] .+ p[3] .* x[:,3] .+ p[4] .* x[:,1] 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 a2phi2(x) = x[:,1] .* x[:,2] # phi2*a^2/8t0
a2phih2(x) = x[:,1] .* x[:,3].^2 # phih^2*a^2/8t0 a2phih2(x) = x[:,1] .* x[:,3].^2 # phih^2*a^2/8t0
...@@ -8,14 +7,14 @@ a4phih4_2(x) = x[:,1].^(2) .* x[:,3].^2 #(a^2/8t0)^2*phih^2 ...@@ -8,14 +7,14 @@ a4phih4_2(x) = x[:,1].^(2) .* x[:,3].^2 #(a^2/8t0)^2*phih^2
a4cutoff(x) = x[:,1].^(2) #(a^2/8t0)^2 a4cutoff(x) = x[:,1].^(2) #(a^2/8t0)^2
func_list = [a2phi2, a2phih2, a4phih4, a4phih4_2, a4cutoff] func_list = [a2phi2, a2phih2, a4phih4, a4phih4_2, a4cutoff]
label_list = ["a2l", "a2h2", "a4h4", "a4h2", "a4"]
# COMBINATIONS (LINEAR) ##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] 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 npar = length(func_list) # number of extra parameters
n_param = Vector(4:npar+4) n_param_j = Vector(4:4)
n_param_charm = Vector{Int64}(undef,0) label_cutoff = Vector{Vector{String}}(undef, 0)
push!(n_param_charm, 4) push!(label_cutoff, ["a2"])
#f_lin definition #f_lin definition
f_lin = Vector{Vector{Function}}(undef, npar+1) #f[i][j]-> i: number of extra parameters, j: combinations 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] = Vector{Function}(undef, 1)
...@@ -29,13 +28,13 @@ f_aux[1][1] = (x,p) -> p[1] + p[2] * x[:,2] + p[3] * x[:,3] + p[4] * x[:,1] ...@@ -29,13 +28,13 @@ f_aux[1][1] = (x,p) -> p[1] + p[2] * x[:,2] + p[3] * x[:,3] + p[4] * x[:,1]
#loop over combinations #loop over combinations
for n = 2:npar+1 for n = 2:npar+1
aux = filter(x->sum(x) == n-1, func_map) aux = filter(x->sum(x) == n-1, func_map)
println(n_param[n])
f_lin[n] = Vector{Function}(undef, length(aux)) f_lin[n] = Vector{Function}(undef, length(aux))
f_aux[n] = Vector{Function}(undef, length(aux)) f_aux[n] = Vector{Function}(undef, length(aux))
k = 1 k = 1
for a in aux for a in aux
push!(n_param_charm, n_param[n])
#vectorized function #vectorized function
push!(n_param_j, 4+n-1)
push!(label_cutoff, label_list[a])
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_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])) 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 k = k + 1
...@@ -43,7 +42,7 @@ for n = 2:npar+1 ...@@ -43,7 +42,7 @@ for n = 2:npar+1
end end
# COMBINATIONS (NONLINEAR) ##COMBINATIONS (NONLINEAR)
f_non_lin = Vector{Vector{Function}}(undef, npar) #f[i][j]-> i: number of extra parameters, j: combinations 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) f_non_lin_aux = Vector{Vector{Function}}(undef, npar)
n_non_lin_param = Vector(5:npar+4) #param for each non-linear functions n_non_lin_param = Vector(5:npar+4) #param for each non-linear functions
...@@ -54,26 +53,26 @@ for n = 1:npar ...@@ -54,26 +53,26 @@ for n = 1:npar
k = 1 k = 1
for a in aux for a in aux
#vectorized function #vectorized function
push!(n_param_charm, n_param[n]+1) push!(n_param_j, 4+n)
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[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] + 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])) (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 k = k + 1
end end
end end
# APPEND LIN + NONLIN ##APPEND LIN + NONLIN
f = f_lin f = f_lin
append!(f, f_non_lin) model_charm = append!(f, f_non_lin)
append!(f_aux, f_non_lin_aux) model_charm_aux = 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.+
import Base.* import Base.*
...@@ -82,10 +81,10 @@ import Base.* ...@@ -82,10 +81,10 @@ 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 # charm quark fits
function basemodel(x,p) function basemodel(x,p)
n=size(x,1) 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] 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 return aux
end end
#a^2 cutoff effects #a^2 cutoff effects
...@@ -117,6 +116,36 @@ for i in 1:length(func_comb_charm) ...@@ -117,6 +116,36 @@ for i in 1:length(func_comb_charm)
push!(model_charm, basemodel * (fff + sum(tmp_farr))) push!(model_charm, basemodel * (fff + sum(tmp_farr)))
end end
# decay constansts
function basemodel_dec(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
func_comb_decay = collect(combinations([ a2phi2, a2phih, a4, a4phih2, a4phih4]))
model_decay = Vector{Function}(undef, 0)
push!(model_decay, basemodel_dec)
n_param_decay = Vector{Int64}(undef,0)
push!(n_param_decay, 4)
for i in 1:length(func_comb_decay)
tmp_farr = Vector{Function}(undef,0)
for k in 1:length(func_comb_decay[i])
tmp_f = (x,p) -> [p[n_param_decay[1]+k] for n in 1:size(x,1)] .* func_comb_decay[i][k](x)
push!(tmp_farr, tmp_f)
end
push!(model_decay, basemodel_dec + sum(tmp_farr))
push!(n_param_decay, 4+length(func_comb_decay[i]))
#push!(n_param_decay, 4+length(func_comb_decay[i]))
#fff(x,p) = 1.
#aux_non_lin = (x,p) -> basemodel_dec(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_decay, basemodel_dec * (fff + sum(tmp_farr)))
end
=#
##
# =# # =#
#= #=
......
################################# #################################
# DEPRECATED
# This file was created by Alessandro Conigli - 2022 # This file was created by Alessandro Conigli - 2022
# The pourpose of this code is to compute twisted mass # The pourpose of this code is to compute twisted mass
# observables from raw correlators stored in mesons.dat files. # observables from raw correlators stored in mesons.dat files.
...@@ -103,11 +104,11 @@ if sector["decays"] ...@@ -103,11 +104,11 @@ if sector["decays"]
errorbar(xx, value.(aux_data_ps), err.(aux_data_ps), fmt="s", mfc="none", label="pseudoscalar") errorbar(xx, value.(aux_data_ps), err.(aux_data_ps), fmt="s", mfc="none", label="pseudoscalar")
errorbar(xx, value.(aux_data_vec), err.(aux_data_vec), fmt="s", mfc="none", label="vector") errorbar(xx, value.(aux_data_vec), err.(aux_data_vec), fmt="s", mfc="none", label="vector")
fill_between(plat_ps[1]:plat_ps[2], v-e, v+e, alpha=0.6 ) fill_between(plat_ps[1]+62:plat_ps[2+62], v-e, v+e, alpha=0.6 )
fill_between(plat_vec[1]:plat_vec[2], v_vec-e_vec, v_vec+e_vec, alpha=0.6 ) fill_between(plat_vec[1]+62:plat_vec[2]+62, v_vec-e_vec, v_vec+e_vec, alpha=0.6 )
xlabel(L"$x_0/a$", size=18) xlabel(L"$x_0/a$", size=18)
ylabel(L"$af$", size=18) ylabel(L"$af$", size=18)
title("$(ensembles(dec0_ps[i])[1]) " * L"\mu_1="*"$(mu_list[i][1]) " *L" \mu_2="*"$(mu_list[i][2]) " ) title("$(ensembles(dec0_ps[i])[1]) " * L"\mu_1="*"$(mu_list[i][1]) " *L" \mu_2="*"$(mu_list[i][2]) " , fontsize=18)
ylim(v*0.95, v_vec*1.1) ylim(v*0.95, v_vec*1.1)
legend() legend()
display(gcf()) display(gcf())
......
...@@ -412,3 +412,38 @@ function syst_av(syst_err::Vector{Float64}) ...@@ -412,3 +412,38 @@ function syst_av(syst_err::Vector{Float64})
return sqrt(aux) return sqrt(aux)
end end
function fit_over_cat!(cat_tot::Vector{Cat}, models::Vector{Vector{Function}}, phi2_phys::uwreal, model_param::Vector{Int64} ; decay::Bool=false, weight_dof::Int64=2, xycovar::Bool=false, wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing)
models = vcat(models...)
function continuum_dependece(params, phi2, phih; decay_phih_dep::Bool=decay)
if !decay_phih_dep
return Mrat * (params[1] + params[2]*phi2 + params[3]*phih)
else
return params[1] + params[2]*phi2 + params[3]/ sqrt(phih)
end
end
for cat in cat_tot
println("\n", cat.info, "\n")
for (i, mod) in enumerate(models)
if !xycovar
fit_params, chi2_vs_chi2exp = juobs.fit_routine(mod, value.(cat.x_tofit), cat.obs, model_param[i], wpm=wpm)
else
fit_params, chi2_vs_chi2exp = juobs.fit_routine(mod, cat.x_tofit, cat.obs, model_param[i], covar=true, wpm=wpm)
end
println(fit_params, "\n")
println(phi2_phys, "\n")
println(cat.phih_ph, "\n")
val_mod_i = continuum_dependece(fit_params, phi2_phys, cat.phih_ph)
push!(cat.dof, length(cat.obs)-model_param[i] )
AIC = chi2_vs_chi2exp * cat.dof[i] + weight_dof * model_param[i]
tmp = [val_mod_i, fit_params, chi2_vs_chi2exp, model_param[i], AIC]
symb = [:fit_res, :fit_param, :chi2_vs_exp, :n_param, :aic]
for (k,ss) in enumerate(symb)
push!(getfield(cat, ss), tmp[k] )
end
end
end
end
\ No newline at end of file
...@@ -35,24 +35,24 @@ mutable struct Cat ...@@ -35,24 +35,24 @@ mutable struct Cat
#models::Vector{Vector{Function}} #models::Vector{Vector{Function}}
x_tofit::Array{uwreal} x_tofit::Array{uwreal}
info::String info::String
fit_param::Vector{Vector{uwreal}} #store all fit parameters fit_param::Vector{Vector{uwreal}} # store all fit parameters
fit_res::Vector{uwreal} # store all fit results fit_res::Vector{uwreal} # store all fit results
chi2_corr::Vector{Float64} # store all chi2 corrected chi2_vs_exp::Vector{Float64} # store all chi2 corrected
n_param::Vector{Int64} # store the number of parameters. Maybe this is redundant n_param::Vector{Int64} # store the number of parameters. Maybe this is redundant
aic::Vector{Float64} # store the AIC value aic::Vector{Float64} # store the AIC value
dof::Vector{Int64} dof::Vector{Int64}
function Cat(_obs::Vector{uwreal}, _xtofit::Array{uwreal}, _phi_ph::uwreal, _info::String) function Cat(_obs::Vector{uwreal}, _xtofit::Array{uwreal}, _phi_ph::uwreal, _info::String)
a = new() a = new()
a.obs = _obs a.obs = _obs
a.info = _info a.info = _info
a.x_tofit = _xtofit a.x_tofit = _xtofit
a.phih_ph = _phi_ph a.phih_ph = _phi_ph
a.fit_param = Vector{Vector{uwreal}}(undef, 0) a.fit_param = Vector{Vector{uwreal}}(undef, 0)
a.fit_res = Vector{uwreal}(undef, 0) a.fit_res = Vector{uwreal}(undef, 0)
a.chi2_corr = Vector{Float64}(undef, 0) a.chi2_vs_exp = Vector{Float64}(undef, 0)
a.n_param = Vector{Int64}(undef, 0) a.n_param = Vector{Int64}(undef, 0)
a.aic = Vector{Float64}(undef, 0) a.aic = Vector{Float64}(undef, 0)
a.dof = Vector{Int64}(undef, 0) a.dof = Vector{Int64}(undef, 0)
return a return a
end end
end end
\ No newline at end of file
function plot_chi(c::Cat, ff::Vector{Vector{Function}}, ylab::LaTeXString, phi2_ph::uwreal, ensinfo::Vector{EnsInfo}; p::Union{String, Nothing}=nothing,
wpm::Union{Dict{String,Vector{Float64}}, Nothing}=nothing, n::Union{Nothing, Int64}=nothing)
phi2_sym = 0.744666
color = ["orange", "green", "blue", "darkviolet"]
fmt = ["^", "v", "<", ">"]
if isnothing(n)
aic, n = findmin(getfield(c, :aic))
end
par_n = getfield(c, :n_param)[n]
upar = getfield(c, :fit_param)[n]
res = getfield(c, :fit_res)[n]
func = vcat(ff...)[n]
xx = [fill(0.0, 100) Float64.(range(0.01, phi2_sym, length=100)) fill(c.phih_ph,100)]
yy = func(xx, upar)
p2 = unique(c.x_tofit[:,2])
idx_a2 = findfirst.(isequal.(unique(value.(c.x_tofit[:,1]))), [value.(c.x_tofit[:,1])])
a2 = c.x_tofit[:,1][idx_a2]
println(a2)
println("\n")
println(p2)
x = [a2 p2 fill(c.phih_ph, length(p2))]
x = [a2 p2 c.x_tofit[1:8, 3]]
x2 = [a2 p2 fill(c.phih_ph, 8)]
y = c.obs[1:8] - func(x, upar) + func(x2, upar)
if isnothing(wpm)
uwerr.(yy)
uwerr(res)
uwerr.(y)
else
[uwerr(yy_aux, wpm) for yy_aux in yy]
uwerr(res, wpm)
[uwerr(y_aux, wpm) for y_aux in y]
end
figure()
fill_between(xx[:,2], value.(yy)+ err.(yy), value.(yy)-err.(yy), alpha=0.3, color="red")
errorbar(value(phi2_ph), value(res), err(res), fmt="s", color="red", label=L"$\phi_2 = \phi^\mathrm{phys}_2$")
for (k,b) in enumerate(sort(unique(getfield.(ensinfo, :beta))))
n_ = findall(x->x.beta == b, ensinfo)
a2_aux = mean(value.(a2[n_]))
errorbar(value.(x[n_,2]), value.(y[n_]), err.(y[n_]), fmt=fmt[k], label=string(L"$\beta =$", b), color=color[k])
xxx = [fill(a2_aux, 100) Float64.(range(0.0, phi2_sym, length=100)) fill(value(c.phih_ph), 100)]
yyy = func(xxx, upar)
plot(xxx[:,2], value.(yyy), ls="--", color=color[k])
end
ylabel(ylab)
xlabel(L"$\phi_2$")
legend()
tight_layout()
if !isnothing(p)
aux1, aux2 = split(c.info, ", ")
t = string("chi_", aux1, "_", aux2, ".pdf")
savefig(joinpath(p, t))
close()
else
display(gcf())
end
end
function plot_cont(c::Cat, ff::Vector{Vector{Function}}, ylab::LaTeXString, phi2_ph::uwreal, ensinfo::Vector{EnsInfo}; p::Union{String, Nothing}=nothing,
wpm::Union{Dict{String,Vector{Float64}}, Nothing}=nothing, n::Union{Nothing, Int64}=nothing)
if isnothing(n)
aic, n = findmin(getfield(c, :aic))
end
par_n = getfield(c, :n_param)[n]
upar = getfield(c, :fit_param)[n]
res = getfield(c, :fit_res)[n]
func = vcat(ff...)[n]
xx = [Float64.(range(0, 0.05, length=100)) fill(phi2_ph, 100) fill(c.phih_ph,100)]
yy = func(xx, upar)
if isnothing(wpm)
uwerr(res)
uwerr.(yy)
else
[uwerr(yy_aux, wpm) for yy_aux in yy]
uwerr(res, wpm)
end
v = value.(yy)
e = err.(yy)
figure()
xlabel(L"$\frac{a^2}{8t_0}$")
ylabel(ylab)
fill_between(xx[:, 1], v+e, v-e, color="red", alpha=0.3)
errorbar(0.0, value(res), err(res), fmt="s", color="red", label="Continuum")
for b in unique(getfield.(ensinfo, :beta))
n_ = findall(x->x.beta == b, ensinfo)
a2 = c.x_tofit[n_, 1]
pc = c.x_tofit[n_, 3]
a2 = fill(mean(a2), length(pc))
x = [a2 fill(phi2_ph, length(a2)) pc]
x2 = [a2 fill(phi2_ph, length(a2)) fill(c.phih_ph, length(a2))]
y = c.obs[n_] - func(x, upar) + func(x2, upar)
#y = func(x,upar)
isnothing(wpm) ? uwerr.(y) : [uwerr(y_, wpm) for y_ in y]
errorbar(value.(a2), value.(y), err.(y), fmt="x", color="black")
end
legend()
tight_layout()
#errorbar(value.(x[:,1]), value.(y), err.(y), fmt="x", color="black")
if !isnothing(p)
aux1, aux2 = split(c.info, ", ")
t = string("sca_", aux1, "_", aux2, ".pdf")
savefig(joinpath(p, t))
close()
else
display(gcf())
end
end
import Base: +,*,/
#uwreal +
function +(uw::uwreal, vec::Vector{uwreal})
n = size(vec,1)
return fill(uw, n) .+ vec
end
function +(vec::Vector{uwreal}, uw::uwreal ) uw+vec end
#uwreal *
function *(uw::uwreal, vec::Vector{uwreal})
n = size(vec,1)
return fill(uw, n) .* vec
end
function *(vec::Vector{uwreal}, uw::uwreal ) uw*vec end
#any +
function +(uw::uwreal, vec::Vector{Any})
n = size(vec,1)
return fill(uw, n) .+ vec
end
function +(vec::Vector{Any}, uw::uwreal ) uw+vec end
#any *
function *(uw::uwreal, vec::Vector{Any})
n = size(vec,1)
return fill(uw, n) .* vec
end
function *(vec::Vector{Any}, uw::uwreal ) uw*vec end
#float +
function +(uw::uwreal, vec::Vector{Float64})
n = size(vec,1)
return fill(uw, n) .+ vec
end
function +(vec::Vector{Float64}, uw::uwreal ) uw+vec end
#float *
function *(uw::uwreal, vec::Vector{Float64})
n = size(vec,1)
return fill(uw, n) .* vec
end
function *(vec::Vector{Float64}, uw::uwreal ) uw*vec 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