From 4adb8379bb3a11706e35a03ac596b76a0ace3000 Mon Sep 17 00:00:00 2001 From: GianlucaFuwa Date: Fri, 7 Jun 2024 21:27:54 +0200 Subject: [PATCH] Enable eigenvalue measurement for even-odd staggered (DdaggerD only) --- src/diracoperators/DiracOperators.jl | 16 ++++++++++++++-- src/gaugefields/fermionfields.jl | 13 ++++++++++++- src/measurements/measure_eigenvalues.jl | 2 ++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/diracoperators/DiracOperators.jl b/src/diracoperators/DiracOperators.jl index 3c5e1592..3e26a755 100644 --- a/src/diracoperators/DiracOperators.jl +++ b/src/diracoperators/DiracOperators.jl @@ -133,25 +133,37 @@ end function construct_diracmatrix(D, U) n = checksquare(D) - Du = D(U) + Du = DdaggerD(D(U)) M = spzeros(ComplexF64, n, n) temp1 = similar(get_temp(D)) temp2 = similar(get_temp(D)) ND = num_dirac(temp1) + fdims = dims(U) + NV = U.NV @assert n < 5000 + is_evenodd = temp1 isa EvenOdd ii = 1 for isite in eachindex(U) + if is_evenodd + iseven(isite) || continue + end for α in 1:ND for a in 1:3 set_source!(temp1, isite, a, α) mul!(temp2, Du, temp1) jj = 1 for jsite in eachindex(U) + if is_evenodd + iseven(jsite) || continue + _jsite = eo_site(jsite, fdims..., NV) + else + _jsite = jsite + end for β in 1:ND for b in 1:3 ind = (β - 1) * 3 + b - M[jj, ii] = temp2[jsite][ind] + M[jj, ii] = temp2[_jsite][ind] jj += 1 end end diff --git a/src/gaugefields/fermionfields.jl b/src/gaugefields/fermionfields.jl index f40be32c..9aa02f31 100644 --- a/src/gaugefields/fermionfields.jl +++ b/src/gaugefields/fermionfields.jl @@ -171,10 +171,21 @@ end Base.size(f::EvenOdd) = size(f.parent) Base.similar(f::EvenOdd) = even_odd(Fermionfield(f.parent)) Base.eltype(::EvenOdd{B,T}) where {B,T} = Complex{T} -LinearAlgebra.checksquare(f::EvenOdd) = LinearAlgebra.checksquare(f.parent) +LinearAlgebra.checksquare(f::EvenOdd) = LinearAlgebra.checksquare(f.parent) ÷ 2 num_colors(::EvenOdd{B,T,A,ND}) where {B,T,A,ND} = 3 num_dirac(::EvenOdd{B,T,A,ND}) where {B,T,A,ND} = ND +Base.@propagate_inbounds Base.getindex(f::EvenOdd, i::Integer) = f.parent.U[i] +Base.@propagate_inbounds Base.getindex(f::EvenOdd, x, y, z, t) = f.parent.U[x, y, z, t] +Base.@propagate_inbounds Base.getindex(f::EvenOdd, site::SiteCoords) = f.parent.U[site] +Base.@propagate_inbounds Base.setindex!(f::EvenOdd, v, i::Integer) = + setindex!(f.parent.U, v, i) +Base.@propagate_inbounds Base.setindex!(f::EvenOdd, v, x, y, z, t) = + setindex!(f.parent.U, v, x, y, z, t) +Base.@propagate_inbounds Base.setindex!(f::EvenOdd, v, site::SiteCoords) = + setindex!(f.parent.U, v, site) + + clear!(ϕ_eo::EvenOdd) = clear!(ϕ_eo.parent) ones!(ϕ_eo::EvenOdd) = ones!(ϕ_eo.parent) diff --git a/src/measurements/measure_eigenvalues.jl b/src/measurements/measure_eigenvalues.jl index 33dd306f..aeec4d46 100644 --- a/src/measurements/measure_eigenvalues.jl +++ b/src/measurements/measure_eigenvalues.jl @@ -34,6 +34,8 @@ struct EigenvaluesMeasurement{T,TA,TD} <: AbstractMeasurement dirac_operator = StaggeredEOPreDiracOperator( U, mass; anti_periodic=anti_periodic ) + @level1("@Warn Eigenvalues with \"eo_precon=true\" defaults to DdaggerD") + ddaggerd = true else dirac_operator = StaggeredDiracOperator( U, mass; anti_periodic=anti_periodic