From 3a251dd1b80da53e0c1d63a414b30f6d366f4876 Mon Sep 17 00:00:00 2001 From: "Fernando P. Panadero" Date: Wed, 20 Nov 2024 12:43:11 +0100 Subject: [PATCH] Updated tests --- test/dirac/test_backflow.jl | 26 ++++++++++++-------------- test/dirac/test_backflow_tl.jl | 17 ++++++++--------- test/dirac/test_flow_tl.jl | 15 ++++++++------- test/dirac/test_fp_fa.jl | 4 +++- test/dirac/test_solver_plw.jl | 10 ++++++---- test/dirac/test_solver_rand.jl | 5 ++++- test/runtests.jl | 6 +++++- 7 files changed, 46 insertions(+), 37 deletions(-) diff --git a/test/dirac/test_backflow.jl b/test/dirac/test_backflow.jl index 601c276..0700b0e 100644 --- a/test/dirac/test_backflow.jl +++ b/test/dirac/test_backflow.jl @@ -1,13 +1,8 @@ -using CUDA +using CUDA, LatticeGPU -using Pkg - -Pkg.activate("/home/fperez/Git/LGPU_fork_ferflow") - -using LatticeGPU - -lp = SpaceParm{4}((4,4,4,4),(2,2,2,2),0,(0,0,0,0,0,0)); +println(" # Consistency condition for backflow") +lp = SpaceParm{4}((16,16,16,16), (4,4,4,4), BC_PERIODIC, (0,0,0,0,0,0)) pso = scalar_field(Spinor{4,SU3fund{Float64}},lp); psi = scalar_field(Spinor{4,SU3fund{Float64}},lp); psi2 = scalar_field(Spinor{4,SU3fund{Float64}},lp); @@ -19,24 +14,27 @@ int = wfl_rk3(Float64, 0.01, 1.0) gp = GaugeParm{Float64}(SU3{Float64},6.0,1.0,(1.0,0.0),(0.0,0.0),lp.iL) -dpar = DiracParam{Float64}(SU3fund,1.3,0.9,(1.0,1.0,1.0,1.0),0.0) +dpar = DiracParam{Float64}(SU3fund,1.3,0.9,(1.0,1.0,1.0,1.0),0.0,0.0) randomize!(ymws.mom, lp, ymws) U = exp.(ymws.mom); pfrandomize!(psi,lp) -for L in 4:19 +for L in 10:20:210 pso .= psi V = Array(U) - a,b = flw_adapt(U, psi, int, L*int.eps, gp,dpar, lp, ymws,dws) + #a,b = flw_adapt(U, psi, int, L*int.eps, gp,dpar, lp, ymws,dws) + flw(U, psi, int, L,int.eps, gp,dpar, lp, ymws,dws) # for i in 1:a # flw(U, psi, int, 1 ,b[i], gp, dpar, lp, ymws, dws) # end pfrandomize!(psi2,lp) - foo = sum(dot.(psi,psi2))# field_dot(psi,psi2,sumf,lp) + foo = sum(dot.(psi,psi2)) copyto!(U,V); - backflow(psi2,U,L*int.eps,7,gp,dpar,lp, ymws,dws) - println("Error:",(sum(dot.(pso,psi2))-foo)/foo) + backflow(psi2,U,L*int.eps,20,gp,dpar,lp, ymws,dws) + println("# Consistency backflow test for t=",L*int.eps) + println("Relative error:",abs((sum(dot.(pso,psi2))-foo)/foo)) psi .= pso end + diff --git a/test/dirac/test_backflow_tl.jl b/test/dirac/test_backflow_tl.jl index 2bf0d18..9330147 100644 --- a/test/dirac/test_backflow_tl.jl +++ b/test/dirac/test_backflow_tl.jl @@ -3,13 +3,14 @@ using LatticeGPU, CUDA, TimerOutputs #Test for the relation K(t,y;0,n)^+ Dw(n|m)^{-1} e^(ipm) = D(p)^{-1} exp(4t sin^2(p/2)) e^{ipn} with a given momenta (if p=0 its randomized), spin and color #Kernel en 1207.2096 +println(" # Free fermion propagator for backflow") @timeit "Plw backflow test" begin function Dwpw_test(;p=0,s=1,c=1) lp = SpaceParm{4}((16,16,16,16), (4,4,4,4), 0, (0,0,0,0,0,0)) gp = GaugeParm{Float64}(SU3{Float64}, 6.0, 1.0) - dpar = DiracParam{Float64}(SU3fund,1.3,0.0,(1.0,1.0,1.0,1.0),0.0) + dpar = DiracParam{Float64}(SU3fund,1.3,0.0,(1.0,1.0,1.0,1.0),0.0,0.0) dws = DiracWorkspace(SU3fund,Float64,lp); ymws = YMworkspace(SU3,Float64,lp); @@ -89,9 +90,7 @@ using LatticeGPU, CUDA, TimerOutputs g5Dw!(prop,U,pwave,dpar,dws,lp) CG!(prop,U,DwdagDw!,dpar,lp,dws,10000,1.0e-14) - for _ in 1:Nsteps - backflow(U,prop,1,int.eps,gp,dpar,lp, ymws,dws) - end + backflow(prop,U,Nsteps*int.eps,20,gp,dpar,lp, ymws,dws) end @@ -103,15 +102,15 @@ using LatticeGPU, CUDA, TimerOutputs begin - dif = 0.0 + global diff = 0.0 for i in 1:3 for j in 1:4 - dif += Dwpw_test(c=i,s=j) + global diff += Dwpw_test(c=i,s=j) end end - if dif < 1.0e-5 - print("Backflow_tl test passed with average error ", dif/12,"!\n") + if diff < 1.0e-5 + print("Backflow_tl test passed with average error ", diff/12,"\n") else - error("Backflow_tl test failed with difference: ",dif,"\n") + error("Backflow_tl test failed with difference: ",diff,"\n") end diff --git a/test/dirac/test_flow_tl.jl b/test/dirac/test_flow_tl.jl index 65ed678..b73be6b 100644 --- a/test/dirac/test_flow_tl.jl +++ b/test/dirac/test_flow_tl.jl @@ -1,15 +1,16 @@ using LatticeGPU, CUDA, TimerOutputs #Test for the relation K(t,y;0,n) Dw(n|m)^{-1} e^(ipm) = D(p)^{-1} exp(-4t sin^2(p/2)) e^{ipn} with a given momenta (if p=0 its randomized), spin and color -#Kernel en 1207.2096 +#Kernel from 1207.2096 +println(" # Free fermion propagator for frontflow") @timeit "Plw flow test" begin function Dwpw_test(;p=0,s=1,c=1) lp = SpaceParm{4}((16,16,16,16), (4,4,4,4), 0, (0,0,0,0,0,0)) gp = GaugeParm{Float64}(SU3{Float64}, 6.0, 1.0) - dpar = DiracParam{Float64}(SU3fund,1.3,0.0,(1.0,1.0,1.0,1.0),0.0) + dpar = DiracParam{Float64}(SU3fund,1.3,0.0,(1.0,1.0,1.0,1.0),0.0,0.0) dws = DiracWorkspace(SU3fund,Float64,lp); ymws = YMworkspace(SU3,Float64,lp); @@ -103,15 +104,15 @@ using LatticeGPU, CUDA, TimerOutputs begin - dif = 0.0 + global diff = 0.0 for i in 1:3 for j in 1:4 - dif += Dwpw_test(c=i,s=j) + global diff += Dwpw_test(c=i,s=j) end end - if dif < 1.0e-4 - print("Flow_tl test passed with average error ", dif/12,"!\n") + if diff < 1.0e-4 + print("Flow_tl test passed with average error ", diff/12,"\n") else - error("Flow_tl test failed with difference: ",dif,"\n") + error("Flow_tl test failed with difference: ",diff,"\n") end diff --git a/test/dirac/test_fp_fa.jl b/test/dirac/test_fp_fa.jl index 5551da5..a7fa00c 100644 --- a/test/dirac/test_fp_fa.jl +++ b/test/dirac/test_fp_fa.jl @@ -2,6 +2,8 @@ using LatticeGPU using CUDA using TimerOutputs +println(" # Free solution for SF correlation functions") + @timeit "fA_fP test" begin @@ -115,7 +117,7 @@ using TimerOutputs elseif difP > 1.0e-15 error("fP test failed with error ", difP) else - print("fA & fP tests passed with errors: ", difA," and ",difP,"!\n") + print("fA & fP tests passed with errors: ", difA," and ",difP,"\n") end end diff --git a/test/dirac/test_solver_plw.jl b/test/dirac/test_solver_plw.jl index a4de0c7..7abc62a 100644 --- a/test/dirac/test_solver_plw.jl +++ b/test/dirac/test_solver_plw.jl @@ -2,6 +2,8 @@ using LatticeGPU, CUDA, TimerOutputs #Test for the relation Dw(n|m)^{-1} e^(ipm) = D(p)^{-1} e^{ipn} with a given momenta (if p=0 its randomized), spin and color +println(" # Test for free fermion propagator") + @timeit "Plw test" begin function Dwpw_test(;p=0,s=1,c=1) @@ -84,12 +86,12 @@ end dif = sum(norm2.(prop - prop_th)) -if dif > 1.0e-15 +if dif > 1.0e-7 error("Dwpl test for s=",s,", c=",c," failed with difference: ",dif,"\n") end -return dif +return sqrt(dif) end @@ -101,8 +103,8 @@ for i in 1:3 for j in 1:4 global diff += Dwpw_test(c=i,s=j) end end -if diff < 1.0e-15 - print("Dwpl test passed with average error ", diff/12,"!\n") +if diff < 1.0e-7 + print("Dwpl test passed with average error ", diff/12,"\n") else error("Dwpl test failed with difference: ",diff,"\n") end diff --git a/test/dirac/test_solver_rand.jl b/test/dirac/test_solver_rand.jl index 0714d8f..3370e67 100644 --- a/test/dirac/test_solver_rand.jl +++ b/test/dirac/test_solver_rand.jl @@ -2,6 +2,9 @@ using CUDA, LatticeGPU, TimerOutputs #Check that Dw ( (DwdagDw)^{-1} g5 Dw g5 ) psi = psi for random fields +println(" # Test for the consistency of the solver") + + @timeit "Rand solver test" begin @timeit "Generate random fields" begin @@ -46,7 +49,7 @@ res = sum(norm2.(rpsi-dws.sp)) if res < 1.0e-6 - print("Drand test passed with ",res,"% error!\n") + print("Drand test passed with ",res,"% error\n") else error("Drand test failed with difference: ",res,"\n") diff --git a/test/runtests.jl b/test/runtests.jl index 2f68f70..31fea0b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,10 @@ -include("SAD/test_sad.jl") +#include("SAD/test_sad.jl") include("flow/test_adapt.jl") include("dirac/test_fp_fa.jl") include("dirac/test_solver_plw.jl") include("dirac/test_solver_rand.jl") +include("dirac/test_flow_tl.jl") +include("dirac/test_backflow_tl.jl") +include("dirac/test_backflow.jl") +