Skip to content

Commit

Permalink
improve hisqsmear tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jcosborn committed Dec 19, 2024
1 parent 9a90b21 commit b9e6156
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
50 changes: 32 additions & 18 deletions src/gauge/hisqsmear.nim
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ when isMainModule:
ll2 = lo.newGauge()
fc = lo.newGauge()
lc = lo.newGauge()
ch = lo.newGauge()
chl = lo.newGauge()
gc = GaugeActionCoeffs(plaq:1.0)
eps = floatParam("eps", 1e-6)
#warm = floatParam("warm", 1e-5)
Expand All @@ -76,6 +78,8 @@ when isMainModule:
#g.warm warm, r
g.stagPhase
dg.gaussian r
ch.gaussian r
chl.gaussian r
for mu in 0..<g.len:
for e in g[mu]:
dg[mu][e] *= eps
Expand All @@ -91,30 +95,40 @@ when isMainModule:
echo &"> ERROR rel error |{r}| > {tol*eps}"

proc checkG =
echo "Checking GaugeDeriv"
#echo "Checking GaugeDeriv"
#for mu in 0..<fd.len:
# fd[mu] := 0
#let a = gc.gaugeAction2(g)
#let a2 = gc.gaugeAction2(g2)
#gc.gaugeDeriv2(g, fd)
echo "Checking redot deriv"
var a, a2 = 0.0
for mu in 0..<fd.len:
fd[mu] := 0
let a = gc.gaugeAction2(g)
let a2 = gc.gaugeAction2(g2)
gc.gaugeDeriv2(g, fd)
check(a2-a, 10)
a += redot(ch[mu], g[mu])
a2 += redot(ch[mu], g2[mu])
fd[mu] := ch[mu]
check(a2-a, 1)
checkG()

proc checkL(name: string, tol: float) =
echo "Checking ", name
for mu in 0..<fd.len:
fd[mu] := 0
fc[mu] := 0
lc[mu] := 0
resetTimers()
let f = hisq.smearGetForce(g, fl, ll)
let f2 = hisq.smearGetForce(g2, fl2, ll2)
gc.gaugeDeriv2(fl, fc)
gc.gaugeDeriv2(ll, lc)
var a, a2 = 0.0
for mu in 0..<fd.len:
a += redot(ch[mu], fl[mu]) + redot(chl[mu], ll[mu])
a2 += redot(ch[mu], fl2[mu]) + redot(chl[mu], ll2[mu])
fd[mu] := 0
fc[mu] := ch[mu]
lc[mu] := chl[mu]
#gc.gaugeDeriv2(fl, fc)
#gc.gaugeDeriv2(ll, lc)
#let a = gc.gaugeAction2(fl) + gc.gaugeAction2(ll)
#let a2 = gc.gaugeAction2(fl2) + gc.gaugeAction2(ll2)
f(fd, fc, lc)
let a = gc.gaugeAction2(fl) + gc.gaugeAction2(ll)
let a2 = gc.gaugeAction2(fl2) + gc.gaugeAction2(ll2)
check(a2-a, tol)
f2(fd, fc, lc) # combine forces for better accuracy
check(2.0*(a2-a), tol) # 2.0 due to combined forces

hisq.fat7first.oneLink = 1.0
hisq.fat7first.threeStaple = 0.0
Expand All @@ -127,15 +141,15 @@ when isMainModule:
hisq.fat7second.sevenStaple = 0.0
hisq.fat7second.lepage = 0.0
hisq.naik = 0.0
checkL("oneLink", 10)
checkL("oneLink", 1)

hisq.fat7first.setHisqFat7(0.0, 0.0)
hisq.fat7second.setHisqFat7(0.0, 0.0)
hisq.naik = 0.0
checkL("all", 300)
checkL("all", 1)

hisq = newHisq()
checkL("all", 700)
checkL("all", 1)

echoProf()
qexFinalize()
2 changes: 1 addition & 1 deletion src/maths/complexType.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import macros
import base/basicOps
import base/[basicOps, wrapperTypes]
import complexProxy
export complexProxy

Expand Down

0 comments on commit b9e6156

Please sign in to comment.