def build_models(tag01, tag02, tmin, T): tdata = range(T) tfit = range(tmin, T + 1 - tmin) # all ts tp = T # periodic models = [ Corr2(datatag=tag01, tp=tp, tdata=tdata, tfit=tfit, a=('a1:vec:s', 'ao:vec:s'), b=('a1:vec:s', 'ao:vec:s'), dE=('dE:vec:s', 'dEo:vec:s'), s=(1., -1.)), Corr2(datatag=tag02, tp=tp, tdata=tdata, tfit=tfit, a=('a1:vec:qed:s', 'ao:vec:qed:s'), b=('a1:vec:qed:s', 'ao:vec:qed:s'), dE=('dE:vec:qed:s', 'dEo:vec:qed:s'), s=(1., -1.)), ] return models
def single_fit(tag_, tstar, CHARGED=False): w0 = gv.gvar('0.1715(9)') w0overa = gv.gvar('1.1367(5)') ZV = gv.gvar('0.9837(20)') ZVqed = gv.gvar('0.999544(14)') * ZV hbarc = 0.197326968 a_vcoarse = (w0 / w0overa) / hbarc if CHARGED == True: ZV = ZVqed else: ZV = ZV dataf = dsetavg[tag_] tmin = 2 # replace data after t* with fit # t* can be changed fitter = CorrFitter(models=build_models(tmin, 48, tag_)) svdcut = 1e-6 for nexp in [4]: print('=== nexp =', nexp, ' tmin = ', tmin, ' svdcut = ', svdcut) fit = fitter.lsqfit(data=dsetavg, prior=build_prior(nexp), p0=pfile, maxit=10000, svdcut=svdcut) #,fitter='gsl_multifit') print(fit) newdata = dataf[:tstar] #print("Before append/concatenate") #print(newdata, len(newdata)) fitdata = Corr2(datatag=tag_, tdata=range(48), a=('a:rho', 'a:rhoo'), b=('b:rho', 'b:rhoo'), dE=('dE:rho', 'dE:rhoo'), s=(1, -1)).fitfcn(fit.p) newdata = np.append(np.array(newdata), fitdata[tstar:]) #print(fitdata[tstar:], fitdata[tstar:].size) #print("After append/concatenate") #print(newdata, newdata.size) #sys.exit(0) # use Z_V from appendix of 1909.00756; divided by u_0 to make the 1-link currents used match vpol = g2.fourier_vacpol(newdata, Z=ZV, ainv=1 / a_vcoarse, periodic=False) a_mu = g2.a_mu(vpol, Q=1. / 3.) print('a_mu:', a_mu, "for", tag_, "t* = ", tstar) return a_mu
def build_models(tmin, length, tag): """ build models """ tdata = range(length) tfit = range(tmin, length - tmin) # all ts models = [ Corr2(datatag=tag, tdata=tdata, tfit=tfit, tp=length, a=('a:rho', 'a:rhoo'), b=('b:rho', 'b:rhoo'), dE=('dE:rho', 'dE:rhoo'), s=(1, -1)), ] return models
def main(tstr): dfile = '/home/gray/Desktop/lattice-analysis/data/qed/coarse/rho_coarse_ms.gpl' madedata = make_data( dfile, norm=3.) # factor of 3 for colour (missed in extraction) data = madedata[0] T = data.size / len(madedata[1]) # extent in time dir tag01 = madedata[1][0] tag02 = madedata[1][1] print("time extent is: ", T) print(dfile) suggestedsvdcut = madedata[2] pfile = None #"vector_fit.p" # last fit tmin = 2 svdcut = 1e-10 #suggestedsvdcut fitter = CorrFitter(models=build_models(tag01, tag02, tmin, T)) for nexp in [2, 3, 4, 5]: fit = fitter.lsqfit(data=data, prior=build_prior(nexp), p0=None, maxit=20000, svdcut=svdcut, add_svdnoise=False) print(fit) tdata = range(T) tfit = range(tmin, T + 1 - tmin) # all ts tp = T tstar = tstr tcut = 200 newdata = {} tags = ['nocharge', 'charge'] newdata[tags[0]] = data[tag01][:tstar + 1] newdata[tags[1]] = data[tag02][:tstar + 1] # do replacement of data with fit fitdatauncharged = Corr2(datatag=tags[0], tdata=range(T), a=('a1:vec:s', 'ao:vec:s'), b=('a1:vec:s', 'ao:vec:s'), dE=('dE:vec:s', 'dEo:vec:s'), s=(1., -1.)).fitfcn(fit.p) for index in range(T): if index >= tcut: newdata[tags[0]] = np.append(newdata[tags[0]], 0.) elif index > tstar: newdata[tags[0]] = np.append(newdata[tags[0]], fitdatauncharged[index]) fitdatachargeddown = Corr2(datatag=tags[1], tdata=range(T), a=('a1:vec:qed:s', 'ao:vec:qed:s'), b=('a1:vec:qed:s', 'ao:vec:qed:s'), dE=('dE:vec:qed:s', 'dEo:vec:qed:s'), s=(1., -1.)).fitfcn(fit.p) for index in range(T): if index >= tcut: newdata[tags[1]] = np.append(newdata[tags[1]], 0.) elif index > tstar: newdata[tags[1]] = np.append(newdata[tags[1]], fitdatachargeddown[index]) print('THIS IS THE INFORMATION CENTRE') print(len(newdata[tags[0]]), len(newdata[tags[1]])) print('tmin, tstar', tmin, tstar) vpol = g2.fourier_vacpol(newdata[tags[0]], Z=ZV, ainv=1 / a, periodic=False) unchargedamus = g2.a_mu(vpol, 1 / 3.) vpol = g2.fourier_vacpol(newdata[tags[1]], Z=ZVqed, ainv=1 / a, periodic=False) chargedamus = g2.a_mu(vpol, 1 / 3.) amus_rt = chargedamus / unchargedamus amu_diff = chargedamus - unchargedamus amu_diff_rt = amu_diff / unchargedamus print( '[s] a_mu[QCD+QED]{0:>20}\n|a_mu[QCD+QED]-a_mu[QCD]{1:>20}\n|a_mu/a_mu {2:>20}' .format(chargedamus, amu_diff, amu_diff_rt))
def main(tstr): dfile = '/home/gray/Desktop/lattice-analysis/data/qed/vcoarse/self_b/rho_vcoarse_7ml.gpl' madedata = make_data(dfile,norm=3.) # factor of 3 for colour (missed in extraction) data = madedata[0] T = data.size / len(madedata[1]) # extent in time dir tag01 = madedata[1][0] tag02 = madedata[1][1] tag03 = madedata[1][2] # =tag01 if no isospin breaking print("time extent is: ", T) print(dfile) suggestedsvdcut = madedata[2] pfile = None #"vector_fit.p" # last fit tmin = 2 svdcut = 1e-10 #suggestedsvdcut fitter = CorrFitter(models=build_models(tag01,tag02,tag03,tmin,T)) for nexp in [2,3,4,5]: fit = fitter.lsqfit(data=data,prior=build_prior(nexp),p0=None,maxit=20000,svdcut=svdcut,add_svdnoise=False) print(fit) tdata = range(T) tfit = range(tmin,T+1-tmin) # all ts tp = T tstar = tstr tcut = 200 newdata = {} tags = ['nocharge', 'up_charge', 'down-charge'] newdata[tags[0]] = data[tag01][:tstar+1] newdata[tags[1]] = data[tag02][:tstar+1] newdata[tags[2]] = data[tag03][:tstar+1] # do replacement of data with fit fitdatauncharged = Corr2(datatag=tags[0],tdata=range(T),a=('a1:vec:u','ao:vec:u'),b=('a1:vec:u','ao:vec:u'),dE=('dE:vec:u','dEo:vec:u'),s=(1.,-1.)).fitfcn(fit.p) for index in range(T): if index >= tcut: newdata[tags[0]] = np.append(newdata[tags[0]],0.) elif index > tstar: newdata[tags[0]] = np.append(newdata[tags[0]],fitdatauncharged[index]) fitdatachargedup = Corr2(datatag=tags[1],tdata=range(T),a=('a1:vec:qed:u','ao:vec:qed:u'),b=('a1:vec:qed:u','ao:vec:qed:u'),dE=('dE:vec:qed:u','dEo:vec:qed:u'),s=(1.,-1.)).fitfcn(fit.p) fitdatachargedown = Corr2(datatag=tags[2],tdata=range(T),a=('a1:vec:qed:d','ao:vec:qed:d'),b=('a1:vec:qed:d','ao:vec:qed:d'),dE=('dE:vec:qed:d','dEo:vec:qed:d'),s=(1.,-1.)).fitfcn(fit.p) for index in range(T): if index >= tcut: newdata[tags[1]] = np.append(newdata[tags[1]],0.) newdata[tags[2]] = np.append(newdata[tags[2]],0.) elif index > tstar: newdata[tags[1]] = np.append(newdata[tags[1]],fitdatachargedup[index]) newdata[tags[2]] = np.append(newdata[tags[2]],fitdatachargedown[index]) print('THIS IS THE INFORMATION CENTRE') print(len(newdata[tags[0]]), len(newdata[tags[1]]), len(newdata[tags[2]])) print('tmin, tstar', tmin, tstar) vpol = g2.fourier_vacpol(newdata[tags[0]], Z=ZV, ainv=1/a, periodic=False) unchargedamuu = g2.a_mu(vpol,2/3.) vpol = g2.fourier_vacpol(newdata[tags[1]], Z=ZVqed, ainv=1/a, periodic=False) chargedamuu = g2.a_mu(vpol,2/3.) vpol = g2.fourier_vacpol(newdata[tags[0]], Z=ZV, ainv=1/a, periodic=False) unchargedamud = g2.a_mu(vpol,1/3.) vpol = g2.fourier_vacpol(newdata[tags[2]], Z=ZVqed, ainv=1/a, periodic=False) chargedamud = g2.a_mu(vpol,1/3.) d_rt = chargedamud/unchargedamud u_rt = chargedamuu/unchargedamuu amu_qcd = unchargedamud+unchargedamuu amu_qcdqed = chargedamuu+chargedamud amu_rt = amu_qcdqed/amu_qcd amu_diff = (amu_qcdqed-amu_qcd)/amu_qcd amu_diff2 = amu_qcdqed-amu_qcd print('[d] a_mu[QCD+QED]||a_mu[QCD+QED]/a_mu[QCD]{0:>20}||{1}'.format(chargedamud,d_rt)) print('[u] a_mu[QCD+QED]||a_mu[QCD+QED]/a_mu[QCD]{0:>20}||{1}'.format(chargedamuu,u_rt)) print('\n[u+d] a_mu[QCD+QED]||a_mu[QCD]||ratio||diff\n{0:20}{1:20}{2:20}{3:20}'.format(amu_qcdqed, amu_qcd, amu_rt, amu_diff))
def main(tstr): dfile = '/home/gray/Desktop/lattice-analysis/data/qed/vcoarse/comb/comb_rho_vcoarse_physud.gpl' # tag01 = 'rho_m' + str(mq) # tag02 = 'rho_m' + str(mq) + '_ucav' # tag03 = 'rho_m' + str(mq) # tag04 = 'rho_m' + str(mq) + '_dcav' madedata = make_data( dfile, norm=3.) # factor of 3 for colour (missed in extraction) data = madedata[0] T = data.size / len(madedata[1]) # extent in time dir tag01 = madedata[1][0] tag02 = madedata[1][1] tag03 = madedata[1][2] # =tag01 if no isospin breaking tag04 = madedata[1][3] #sys.exit(0) #ratiodata = {} #ratiodata['up'] = data[tag02]/data[tag01] #ratiodata['down'] = data[tag04]/data[tag03] suggestedsvdcut = madedata[2] pfile = "vector_fit.p" # last fit tmin = 2 svdcut = 1e-10 #suggestedsvdcut fitter = CorrFitter( models=build_models(tag01, tag02, tag03, tag04, tmin, T)) for nexp in [2, 3, 4, 5]: fit = fitter.lsqfit(data=data, prior=build_prior(nexp), p0=None, maxit=20000, svdcut=svdcut, add_svdnoise=False) print(fit) tdata = range(T) tfit = range(tmin, T + 1 - tmin) # all ts tp = T tstar = tstr tcut = 200 newdata = {} tags = ['up', 'up_qed', 'down', 'down_qed'] newdata[tags[0]] = data[tag01][:tstar + 1] newdata[tags[1]] = data[tag02][:tstar + 1] newdata[tags[2]] = data[tag03][:tstar + 1] newdata[tags[3]] = data[tag04][:tstar + 1] # do replacement of data with fit fitdataunchargedup = Corr2(datatag=tags[0], tdata=range(T), a=('a1:vec:u', 'ao:vec:u'), b=('a1:vec:u', 'ao:vec:u'), dE=('dE:vec:u', 'dEo:vec:u'), s=(1., -1.)).fitfcn(fit.p) fitdataunchargeddown = Corr2(datatag=tags[2], tdata=range(T), a=('a1:vec:d', 'ao:vec:d'), b=('a1:vec:d', 'ao:vec:d'), dE=('dE:vec:d', 'dEo:vec:d'), s=(1., -1.)).fitfcn(fit.p) for index in range(48): if index >= tcut: newdata[tags[0]] = np.append(newdata[tags[0]], 0.) newdata[tags[2]] = np.append(newdata[tags[2]], 0.) elif index > tstar: newdata[tags[0]] = np.append(newdata[tags[0]], fitdataunchargedup[index]) newdata[tags[2]] = np.append(newdata[tags[2]], fitdataunchargeddown[index]) fitdatachargedup = Corr2(datatag=tags[1], tdata=range(T), a=('a1:vec:qed:u', 'ao:vec:qed:u'), b=('a1:vec:qed:u', 'ao:vec:qed:u'), dE=('dE:vec:qed:u', 'dEo:vec:qed:u'), s=(1., -1.)).fitfcn(fit.p) fitdatachargedown = Corr2(datatag=tags[3], tdata=range(T), a=('a1:vec:qed:d', 'ao:vec:qed:d'), b=('a1:vec:qed:d', 'ao:vec:qed:d'), dE=('dE:vec:qed:d', 'dEo:vec:qed:d'), s=(1., -1.)).fitfcn(fit.p) for index in range(48): if index >= tcut: newdata[tags[1]] = np.append(newdata[tags[1]], 0.) newdata[tags[3]] = np.append(newdata[tags[3]], 0.) elif index > tstar: newdata[tags[1]] = np.append(newdata[tags[1]], fitdatachargedup[index]) newdata[tags[3]] = np.append(newdata[tags[3]], fitdatachargedown[index]) w0 = gv.gvar('0.1715(9)') w0overa = gv.gvar('1.1367(5)') ZV = gv.gvar('0.9837(20)') ZVqed = gv.gvar('0.999544(14)') * ZV hbarc = 0.197326968 a = (w0 / w0overa) / hbarc print('THIS IS THE INFORMATION CENTRE') print(len(newdata[tags[0]]), len(newdata[tags[1]]), len(newdata[tags[2]]), len(newdata[tags[3]])) print('tmin, tstar', tmin, tstar) #moments = g2.moments(newdata[tags[0]],Z=ZV,ainv=1/a,periodic=False) #vpol = g2.vacpol(moments,order=(2,1)) vpol = g2.fourier_vacpol(newdata[tags[0]], Z=ZV, ainv=1 / a, periodic=False) unchargedamuu = g2.a_mu(vpol, 2 / 3.) #moments = g2.moments(newdata[tags[1]],Z=ZVqed,ainv=1/a,periodic=False) #vpol = g2.vacpol(moments,order=(2,1)) vpol = g2.fourier_vacpol(newdata[tags[1]], Z=ZVqed, ainv=1 / a, periodic=False) chargedamuu = g2.a_mu(vpol, 2 / 3.) #moments = g2.moments(newdata[tags[2]],Z=ZV,ainv=1/a,periodic=False) #vpol = g2.vacpol(moments,order=(2,1)) vpol = g2.fourier_vacpol(newdata[tags[2]], Z=ZV, ainv=1 / a, periodic=False) unchargedamud = g2.a_mu(vpol, 1 / 3.) #moments = g2.moments(newdata[tags[3]],Z=ZVqed,ainv=1/a,periodic=False) #vpol = g2.vacpol(moments,order=(2,1)) vpol = g2.fourier_vacpol(newdata[tags[3]], Z=ZVqed, ainv=1 / a, periodic=False) chargedamud = g2.a_mu(vpol, 1 / 3.) d_rt = chargedamud / unchargedamud u_rt = chargedamuu / unchargedamuu amu_qcd = unchargedamud + unchargedamuu amu_qcdqed = chargedamuu + chargedamud amu_rt = amu_qcdqed / amu_qcd amu_diff = (amu_qcdqed - amu_qcd) / amu_qcd print('[d] a_mu[QCD+QED]||a_mu[QCD+QED]/a_mu[QCD]{0:>20}||{1}'.format( chargedamud, d_rt)) print('[u] a_mu[QCD+QED]||a_mu[QCD+QED]/a_mu[QCD]{0:>20}||{1}'.format( chargedamuu, u_rt)) print( '\n[u+d] a_mu[QCD+QED]||a_mu[QCD]||ratio||diff\n{0:20}{1:20}{2:20}{3:20}' .format(amu_qcdqed, amu_qcd, amu_rt, amu_diff))