From ae99e99da235ebf5d9a149ef4a7ad0b93d1f7474 Mon Sep 17 00:00:00 2001 From: James Harrison Date: Mon, 23 Jan 2017 17:27:50 +0000 Subject: [PATCH 1/2] Fixed bug in ChargedProp --- extras/Hadrons/Modules/MScalar/ChargedProp.cc | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/extras/Hadrons/Modules/MScalar/ChargedProp.cc b/extras/Hadrons/Modules/MScalar/ChargedProp.cc index f8323705..d88fdc45 100644 --- a/extras/Hadrons/Modules/MScalar/ChargedProp.cc +++ b/extras/Hadrons/Modules/MScalar/ChargedProp.cc @@ -123,18 +123,22 @@ void TChargedProp::execute(void) // G*F*Src prop = GFSrc; + // - q*G*momD1*G*F*Src (momD1 = F*D1*Finv) buf = GFSrc; momD1(buf, fft); buf = G*buf; prop = prop - q*buf; + // + q^2*G*momD1*G*momD1*G*F*Src (here buf = G*momD1*G*F*Src) momD1(buf, fft); prop = prop + q*q*G*buf; - // + q^2*G*momD2*G*F*Src (momD1 = F*D2*Finv) + + // - q^2*G*momD2*G*F*Src (momD2 = F*D2*Finv) buf = GFSrc; momD2(buf, fft); - prop = prop + q*q*G*buf; + prop = prop - q*q*G*buf; + // final FT fft.FFT_all_dim(prop, prop, FFT::backward); @@ -164,16 +168,18 @@ void TChargedProp::execute(void) void TChargedProp::momD1(ScalarField &s, FFT &fft) { EmField &A = *env().getObject(par().emField); - ScalarField buf(env().getGrid()), Amu(env().getGrid()); + ScalarField buf(env().getGrid()), fs(env().getGrid()), result(env().getGrid()), Amu(env().getGrid()); Complex ci(0.0,1.0); - + + result = zero; + + fft.FFT_all_dim(fs, s, FFT::backward); for (unsigned int mu = 0; mu < env().getNd(); ++mu) { Amu = peekLorentz(A, mu); - fft.FFT_all_dim(buf, s, FFT::backward); - buf = Amu*buf; + buf = Amu*fs; fft.FFT_all_dim(buf, buf, FFT::forward); - s = s + ci*adj(*phase_[mu])*buf; + result = result + ci*adj(*phase_[mu])*buf; } for (unsigned int mu = 0; mu < env().getNd(); ++mu) { @@ -182,22 +188,26 @@ void TChargedProp::momD1(ScalarField &s, FFT &fft) fft.FFT_all_dim(buf, buf, FFT::backward); buf = Amu*buf; fft.FFT_all_dim(buf, buf, FFT::forward); - s = s - ci*buf; + result = result - ci*buf; } + + s = result; } void TChargedProp::momD2(ScalarField &s, FFT &fft) { EmField &A = *env().getObject(par().emField); - ScalarField buf(env().getGrid()), Amu(env().getGrid()); + ScalarField buf(env().getGrid()), fs(env().getGrid()), result(env().getGrid()), Amu(env().getGrid()); + + result = zero; + fft.FFT_all_dim(fs, s, FFT::backward); for (unsigned int mu = 0; mu < env().getNd(); ++mu) { - Amu = peekLorentz(A, mu); - fft.FFT_all_dim(buf, s, FFT::backward); - buf = Amu*Amu*buf; + Amu = peekLorentz(A, mu); + buf = Amu*Amu*fs; fft.FFT_all_dim(buf, buf, FFT::forward); - s = s + .5*adj(*phase_[mu])*buf; + result = result + .5*adj(*phase_[mu])*buf; } for (unsigned int mu = 0; mu < env().getNd(); ++mu) { @@ -206,6 +216,8 @@ void TChargedProp::momD2(ScalarField &s, FFT &fft) fft.FFT_all_dim(buf, buf, FFT::backward); buf = Amu*Amu*buf; fft.FFT_all_dim(buf, buf, FFT::forward); - s = s + .5*buf; + result = result + .5*buf; } + + s = result; } From f65a585236f420d7ed966b8f9e0b7cbfb0857d8c Mon Sep 17 00:00:00 2001 From: James Harrison Date: Thu, 26 Jan 2017 15:02:30 +0000 Subject: [PATCH 2/2] ChargedProp: Switch to HDF5 output --- extras/Hadrons/Modules/MScalar/ChargedProp.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extras/Hadrons/Modules/MScalar/ChargedProp.cc b/extras/Hadrons/Modules/MScalar/ChargedProp.cc index d88fdc45..f2890b2a 100644 --- a/extras/Hadrons/Modules/MScalar/ChargedProp.cc +++ b/extras/Hadrons/Modules/MScalar/ChargedProp.cc @@ -151,7 +151,7 @@ void TChargedProp::execute(void) LOG(Message) << "Saving zero-momentum projection to '" << filename << "'..." << std::endl; - TextWriter writer(filename); + Hdf5Writer writer(filename); std::vector vecBuf; std::vector result; @@ -161,6 +161,7 @@ void TChargedProp::execute(void) { result[t] = TensorRemove(vecBuf[t]); } + write(writer, "charge", q); write(writer, "prop", result); } }