Skip to content

Commit 5aa510d

Browse files
committed
make fpi normalization consistent with fk; more useful error info in effectiveMass and Fitter
1 parent 8ed3f68 commit 5aa510d

6 files changed

Lines changed: 37 additions & 32 deletions

File tree

examples/main_autoDiff.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def evaluate_and_derive(self, variable):
6767
x_partial = z.evaluate_and_derive(x).partial
6868
y_partial = z.evaluate_and_derive(y).partial
6969

70+
logger.info('z = x(x+y)+y^2 at x=2, y=3')
7071
logger.info(f"(auto) ∂z/∂x = {x_partial}, ∂z/∂y = {y_partial}")
7172

7273
# Example implemented using numerical differentiation of the Toolbox.

latqcdtools/physics/constants.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,10 +500,12 @@ def M_neutron_phys(year=2024,units="MeV",returnErr=False,world="nature"):
500500
# ------------------------------------------------------------------------------------------------------ DECAY CONSTANTS
501501

502502

503-
503+
# As a note for these decay constants: I haven't figured out exactly what definitions
504+
# lead to inclusion of sqrt(2.). I will only mention that this convention for fpi seems
505+
# to match Peskin and Schroeder, at least.
504506
def fk_phys(year=2019,units="MeV",returnErr=False,world="nature"):
505507
"""
506-
Physical value of Kaon decay constant, f_K+/-. scale by sqrt(2.).
508+
Physical value of Kaon decay constant, f_K+/-. Scale by sqrt(2.).
507509
"""
508510
_fkerrs2012 = np.array([0.2 ,0.8 ,0.2 ])
509511
_fkerrs2018 = np.array([0.17 ,0.45 ,0.16 ])
@@ -527,7 +529,7 @@ def fk_phys(year=2019,units="MeV",returnErr=False,world="nature"):
527529

528530
def fpi_phys(year=2018,units="MeV",returnErr=False,world="nature"):
529531
"""
530-
Physical value of the pion decay constant, f_pi+/-.
532+
Physical value of the pion decay constant, f_pi+/-. Scale by sqrt(2.)
531533
"""
532534
_fpierrs2018 = np.array([0.01 ,0.03 ,0.13 ])
533535
scale = {
@@ -538,13 +540,14 @@ def fpi_phys(year=2018,units="MeV",returnErr=False,world="nature"):
538540
2018: (130.50, quadrature(_fpierrs2018)), # PDG 2018. DOI: 10.1103/PhysRevD.98.030001. Section 84.5.1.
539541
}
540542
}
541-
return physicalConstant("f_pi+/-",scale,"MeV").getValue(world,year,units,returnErr)
543+
return physicalConstant("f_pi+/-",scale,"MeV").getValue(world,year,units,returnErr,normalize=np.sqrt(2.))
542544

543545

544546
def fphi_phys(year=2021,units="MeV",returnErr=False,world="Nf21"):
545547
"""
546548
Physical value of the phi decay constant.
547549
"""
550+
logger.TBError('CHECK NORMALIZATION')
548551
scale = {
549552
'Nf21' : {
550553
2021: (241 , 9), # DOI: 10.1088/1674-1137/abcd8f
@@ -557,6 +560,7 @@ def frho_phys(year=2017,units="GeV",returnErr=False,world="nature"):
557560
"""
558561
Physical value of the rho decay constant.
559562
"""
563+
logger.TBError('CHECK NORMALIZATION')
560564
logger.warn("David lost track of where the 2017 value came from.")
561565
scale = {
562566
'nature' : {

latqcdtools/physics/correlators.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Some tools useful when analyzing correlators
77
#
88
import numpy as np
9-
from latqcdtools.base.check import checkType
9+
from latqcdtools.base.check import checkType, InvalidValueError
1010
from latqcdtools.math.optimize import persistentSolve
1111
import latqcdtools.base.logger as logger
1212

@@ -71,8 +71,11 @@ def effectiveMass(corr,algorithm='simple',guess=None) -> np.ndarray:
7171
Nt = len(corr)
7272
meff = []
7373
if algorithm=='simple':
74-
for it in range(Nt-1):
75-
meff.append( np.log(corr[it]/corr[it+1]) )
74+
try:
75+
for it in range(Nt-1):
76+
meff.append( np.log(corr[it]/corr[it+1]) )
77+
except InvalidValueError:
78+
logger.TBRaise('corr=',corr,exception=InvalidValueError)
7679
elif algorithm=='periodic':
7780
mit = guess
7881
for it in range(Nt-1):

latqcdtools/statistics/fitting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ def pcov_error_prop(self, params, algorithm):
483483
if abs(np.sum(test) - np.sum(np.diag(test))) > self._test_tol:
484484
if not self._nowarn:
485485
logger.warn(algorithm,"pcov @ jej not close to id")
486-
logger.warn(np.diag(test))
486+
logger.warn(test)
487487

488488
if np.min(np.diag(pcov)) < 0:
489489
logger.TBFail(algorithm + ": Negative entries for the variance!")

tests/physics/test_Scales.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
from latqcdtools.base.logger import ToolboxException
1414
from latqcdtools.base.printErrorBars import get_err_str
1515
from latqcdtools.physics.constants import M_mu_phys, M_K0_phys, M_Kpm_phys, M_pi0_phys, M_pipm_phys,\
16-
M_rho_phys, frho_phys, fk_phys, fpi_phys, w0_phys, r0_phys, r1_phys, alpha_e, lambda_MSbar_phys,\
17-
Rproton_phys, Tpc_chiral, sqrtt0_phys, worlds
16+
M_rho_phys, frho_phys, fk_phys, fpi_phys, fphi_phys, w0_phys, r0_phys, r1_phys, alpha_e, lambda_MSbar_phys,\
17+
Rproton_phys, sqrtt0_phys, Tpc_chiral, worlds
1818
import latqcdtools.base.logger as logger
1919

2020

@@ -71,22 +71,22 @@ def testScales():
7171
lpass *= print_results( sqrtt0_div_a(6.800) , 5.524714874614185 , text="sqrt(t0)/a", prec=EPSILON )
7272

7373
# Test some physical scales for particular worlds and years.
74-
lpass *= print_results( 105.6583755 , M_mu_phys(year=2022,units="MeV") , text="muon mass 2022" )
75-
lpass *= print_results( 134.9768 , M_pi0_phys(year=2022,units="MeV") , text="pi0 mass 2022" )
76-
lpass *= print_results( 139.57039 , M_pipm_phys(year=2022,units="MeV") , text="pi+/- mass 2022" )
77-
lpass *= print_results( 497.611 , M_K0_phys(year=2022,units="MeV") , text="K0 mass 2022" )
78-
lpass *= print_results( 493.677 , M_Kpm_phys(year=2022,units="MeV") , text="K+/- mass 2022" )
79-
lpass *= print_results( 775.26 , M_rho_phys(year=2022,units="MeV") , text="rho mass 2022" )
80-
lpass *= print_results( 0.21 , frho_phys(year=2017,units="GeV") , text="f_rho 2017" )
81-
lpass *= print_results( 155.7/np.sqrt(2.), fk_phys(year=2019,units="MeV",world="Nf21"), text="f_K 2019" )
82-
lpass *= print_results( 130.50 , fpi_phys(year=2018,units="MeV") , text="f_pi 2018" )
83-
lpass *= print_results( 0.1715 , w0_phys(year=2013,units="fm") , text="w0 2018" )
84-
lpass *= print_results( 0.3106 , r1_phys(year=2010,units="fm") , text="r1 2010" )
85-
lpass *= print_results( 0.46875752 , r0_phys(year=2014,units="fm") , text="r0 2014" )
86-
lpass *= print_results( 7.2973525693e-3, alpha_e(year=2018) , text="alpha_e 2018" )
87-
lpass *= print_results( 339 , lambda_MSbar_phys(year=2021,units="MeV") , text="lambda_MSbar 2021" )
88-
lpass *= print_results( 0.8414 , Rproton_phys(year=2018,units="fm") , text="R_proton 2021" )
89-
lpass *= print_results( 157.2555509 , Tpc_chiral(year=2020,units="MeV") , text="Tpc_chiral 2020" )
74+
lpass *= print_results( 105.6583755 , M_mu_phys(year=2022,units="MeV") , text="muon mass 2022" )
75+
lpass *= print_results( 134.9768 , M_pi0_phys(year=2022,units="MeV") , text="pi0 mass 2022" )
76+
lpass *= print_results( 139.57039 , M_pipm_phys(year=2022,units="MeV") , text="pi+/- mass 2022" )
77+
lpass *= print_results( 497.611 , M_K0_phys(year=2022,units="MeV") , text="K0 mass 2022" )
78+
lpass *= print_results( 493.677 , M_Kpm_phys(year=2022,units="MeV") , text="K+/- mass 2022" )
79+
lpass *= print_results( 775.26 , M_rho_phys(year=2022,units="MeV") , text="rho mass 2022" )
80+
# lpass *= print_results( 0.21 , frho_phys(year=2017,units="GeV") , text="f_rho 2017" )
81+
lpass *= print_results( 155.7/np.sqrt(2.) , fk_phys(year=2019,units="MeV",world="Nf21"), text="f_K 2019" )
82+
lpass *= print_results( 130.50/np.sqrt(2.), fpi_phys(year=2018,units="MeV") , text="f_pi 2018" )
83+
lpass *= print_results( 0.1715 , w0_phys(year=2013,units="fm") , text="w0 2018" )
84+
lpass *= print_results( 0.3106 , r1_phys(year=2010,units="fm") , text="r1 2010" )
85+
lpass *= print_results( 0.46875752 , r0_phys(year=2014,units="fm") , text="r0 2014" )
86+
lpass *= print_results( 7.2973525693e-3 , alpha_e(year=2018) , text="alpha_e 2018" )
87+
lpass *= print_results( 339 , lambda_MSbar_phys(year=2021,units="MeV") , text="lambda_MSbar 2021" )
88+
lpass *= print_results( 0.8414 , Rproton_phys(year=2018,units="fm") , text="R_proton 2021" )
89+
lpass *= print_results( 157.2555509 , Tpc_chiral(year=2020,units="MeV") , text="Tpc_chiral 2020" )
9090

9191
# Test physical scales from different years against each other to check they are statistically compatible
9292
lpass *= checkStatisticalCompatability(M_mu_phys ,"M_mu")
@@ -95,13 +95,13 @@ def testScales():
9595
lpass *= checkStatisticalCompatability(M_K0_phys ,"M_K0")
9696
lpass *= checkStatisticalCompatability(M_Kpm_phys ,"M_K+/-")
9797
lpass *= checkStatisticalCompatability(M_rho_phys ,"M_rho")
98-
lpass *= checkStatisticalCompatability(frho_phys ,"f_rho")
98+
# lpass *= checkStatisticalCompatability(frho_phys ,"f_rho")
9999
lpass *= checkStatisticalCompatability(fk_phys ,"f_k")
100100
lpass *= checkStatisticalCompatability(fpi_phys ,"f_pi")
101101
lpass *= checkStatisticalCompatability(w0_phys ,"w0")
102102
lpass *= checkStatisticalCompatability(r1_phys ,"r1")
103103
lpass *= checkStatisticalCompatability(r0_phys ,"r0")
104-
# lpass *= checkStatisticalCompatability(sqrtt0_phys ,"t0") # need to understand why this doesn't work
104+
lpass *= checkStatisticalCompatability(sqrtt0_phys ,"t0") # need to understand why this doesn't work
105105
lpass *= checkStatisticalCompatability(lambda_MSbar_phys,"lambda_MSbar")
106106
lpass *= checkStatisticalCompatability(Rproton_phys ,"R_proton")
107107
lpass *= checkStatisticalCompatability(Tpc_chiral ,"chiral T_pc")

tests/physics/test_Units.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import latqcdtools.base.logger as logger
1010
from latqcdtools.physics.constants import convert, fm_to_MeVinv, MeVinv_to_fm, fm_to_GeVinv, GeVinv_to_fm, \
11-
M_mu_phys, M_pi0_phys, M_pipm_phys, fk_phys, frho_phys, lambda_MSbar_phys, cms, sqrtG, M_e_phys, M_proton_phys
11+
M_mu_phys, M_pi0_phys, M_pipm_phys, lambda_MSbar_phys, cms, sqrtG, M_e_phys, M_proton_phys
1212
from latqcdtools.testing import print_results, concludeTest
1313

1414
logger.set_log_level('INFO')
@@ -63,9 +63,6 @@ def testUnits():
6363
lpass *= print_results(M_pi0_phys(2022,"fminv"), 0.6840260810804044, text="m_pi0 [1/fm]")
6464
lpass *= print_results(M_pipm_phys(2022,"MeV"), 139.57039,text="m_pipm [MeV]")
6565
lpass *= print_results(M_pipm_phys(2022,"GeV"), 0.13957039000000002, text="m_pipm [GeV]")
66-
lpass *= print_results(frho_phys(2017,"GeV"), 0.21,text="frho [GeV]")
67-
lpass *= print_results(frho_phys(2017,"MeV"), 210.0,text="frho [MeV]")
68-
lpass *= print_results(frho_phys(2017,"fminv"), 1.06422345934179,text="frho [1/fm]")
6966
lpass *= print_results(lambda_MSbar_phys(2021,"GeV"), 0.339,text="lambda_MSbar [GeV]")
7067
lpass *= print_results(lambda_MSbar_phys(2021,"MeV"), 339,text="lambda_MSbar [MeV]")
7168
lpass *= print_results(lambda_MSbar_phys(2021,"fminv"), 1.7179607272231752,text="lambda_MSbar [1/fm]")

0 commit comments

Comments
 (0)