Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to WilsonGaugeAction deriv function #16

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Grid/qcd/action/gauge/PlaqPlusRectangleAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,30 +71,30 @@ class PlaqPlusRectangleAction : public Action<typename Gimpl::GaugeField> {
return action;
};

virtual void deriv(const GaugeField &Umu,GaugeField & dSdU) {
//extend Ta to include Lorentz indexes
RealD factor_p = c_plaq/RealD(Nc)*0.5;
RealD factor_r = c_rect/RealD(Nc)*0.5;
virtual void deriv(const GaugeField &U, GaugeField &dSdU) {
// extend Ta to include Lorentz indexes
RealD factor_p = c_plaq / RealD(Nc) * 0.5;
RealD factor_r = c_rect / RealD(Nc) * 0.5;

GridBase *grid = Umu.Grid();
GridBase *grid = U.Grid();

std::vector<GaugeLinkField> U (Nd,grid);
for(int mu=0;mu<Nd;mu++){
U[mu] = PeekIndex<LorentzIndex>(Umu,mu);
std::vector<GaugeLinkField> Umu(Nd, grid);
for (int mu = 0; mu < Nd; mu++) {
Umu[mu] = PeekIndex<LorentzIndex>(U, mu);
}
std::vector<GaugeLinkField> RectStaple(Nd,grid), Staple(Nd,grid);
WilsonLoops<Gimpl>::StapleAndRectStapleAll(Staple, RectStaple, U, workspace);
std::vector<GaugeLinkField> RectStaple(Nd, grid), Staple(Nd, grid);
WilsonLoops<Gimpl>::StapleAndRectStapleAll(Staple, RectStaple, Umu,
workspace);

GaugeLinkField dSdU_mu(grid);
GaugeLinkField staple(grid);

for (int mu=0; mu < Nd; mu++){
dSdU_mu = Ta(U[mu]*Staple[mu])*factor_p;
dSdU_mu = dSdU_mu + Ta(U[mu]*RectStaple[mu])*factor_r;
for (int mu = 0; mu < Nd; mu++) {
dSdU_mu = Ta(Umu[mu] * Staple[mu]) * factor_p;
dSdU_mu = dSdU_mu + Ta(Umu[mu] * RectStaple[mu]) * factor_r;

PokeIndex<LorentzIndex>(dSdU, dSdU_mu, mu);
}

};

};
Expand Down
17 changes: 10 additions & 7 deletions Grid/qcd/action/gauge/WilsonGaugeAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,23 @@ class WilsonGaugeAction : public Action<typename Gimpl::GaugeField> {
// extend Ta to include Lorentz indexes

RealD factor = 0.5 * beta / RealD(Nc);
GridBase *grid = U.Grid();

GaugeLinkField Umu(U.Grid());
GaugeLinkField dSdU_mu(U.Grid());
GaugeLinkField dSdU_mu(grid);
std::vector<GaugeLinkField> Umu(Nd, grid);
for (int mu = 0; mu < Nd; mu++) {
Umu[mu] = PeekIndex<LorentzIndex>(U, mu);
}

Umu = PeekIndex<LorentzIndex>(U, mu);

for (int mu = 0; mu < Nd; mu++) {
// Staple in direction mu
WilsonLoops<Gimpl>::Staple(dSdU_mu, U, mu);
dSdU_mu = Ta(Umu * dSdU_mu) * factor;
WilsonLoops<Gimpl>::Staple(dSdU_mu, Umu, mu);
dSdU_mu = Ta(Umu[mu] * dSdU_mu) * factor;

PokeIndex<LorentzIndex>(dSdU, dSdU_mu, mu);
}
}

private:
RealD beta;
};
Expand Down
25 changes: 10 additions & 15 deletions Grid/qcd/utils/WilsonLoops.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,18 +292,16 @@ template <class Gimpl> class WilsonLoops : public Gimpl {
//////////////////////////////////////////////////
// the sum over all nu-oriented staples for nu != mu on each site
//////////////////////////////////////////////////
static void Staple(GaugeMat &staple, const GaugeLorentz &Umu, int mu) {
static void Staple(GaugeMat &staple, const GaugeLorentz &U, int mu) {

GridBase *grid = Umu.Grid();

std::vector<GaugeMat> U(Nd, grid);
std::vector<GaugeMat> Umu(Nd, U.grid());
for (int d = 0; d < Nd; d++) {
U[d] = PeekIndex<LorentzIndex>(Umu, d);
Umu[d] = PeekIndex<LorentzIndex>(U, d);
}
Staple(staple, U, mu);
Staple(staple, Umu, mu);
}

static void Staple(GaugeMat &staple, const std::vector<GaugeMat> &U, int mu) {
static void Staple(GaugeMat &staple, const std::vector<GaugeMat> &Umu, int mu) {
staple = Zero();

for (int nu = 0; nu < Nd; nu++) {
Expand All @@ -318,13 +316,10 @@ template <class Gimpl> class WilsonLoops : public Gimpl {
// |
// __|
//

staple += Gimpl::ShiftStaple(
Gimpl::CovShiftForward(
U[nu], nu,
Gimpl::CovShiftBackward(
U[mu], mu, Gimpl::CovShiftIdentityBackward(U[nu], nu))),
mu);
Gimpl::CovShiftForward(Umu[nu], nu,
Gimpl::CovShiftBackward(Umu[mu], mu, Gimpl::CovShiftIdentityBackward(Umu[nu], nu))), mu);

// __
// |
Expand All @@ -333,8 +328,8 @@ template <class Gimpl> class WilsonLoops : public Gimpl {
//

staple += Gimpl::ShiftStaple(
Gimpl::CovShiftBackward(U[nu], nu,
Gimpl::CovShiftBackward(U[mu], mu, U[nu])), mu);
Gimpl::CovShiftBackward(Umu[nu], nu,
Gimpl::CovShiftBackward(Umu[mu], mu, Umu[nu])), mu);
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions HMC/FTHMC2p1f.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,20 @@ directory
*************************************************************************************/
/* END LEGAL */
#include <Grid/Grid.h>

#if Nc == 3
#include <Grid/qcd/smearing/GaugeConfigurationMasked.h>
#include <Grid/qcd/smearing/JacobianAction.h>
#endif

using namespace Grid;

int main(int argc, char **argv)
{
#if Nc != 3
#warning FTHMC2p1f will not work for Nc != 3
std::cout << "This program will currently only work for Nc == 3." << std::endl;
#else
std::cout << std::setprecision(12);

Grid_init(&argc, &argv);
Expand Down Expand Up @@ -220,7 +227,6 @@ int main(int argc, char **argv)
TheHMC.Run(SmearingPolicy); // for smearing

Grid_finalize();
#endif
} // main



9 changes: 9 additions & 0 deletions HMC/FTHMC2p1f_3GeV.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,22 @@ See the full license in the file "LICENSE" in the top level distribution
directory
*************************************************************************************/
/* END LEGAL */

#include <Grid/Grid.h>

#if Nc == 3
#include <Grid/qcd/smearing/GaugeConfigurationMasked.h>
#include <Grid/qcd/smearing/JacobianAction.h>
#endif

using namespace Grid;

int main(int argc, char **argv)
{
#if Nc != 3
#warning FTHMC2p1f_3GeV will not work for Nc != 3
std::cout << "This program will currently only work for Nc == 3." << std::endl;
#else
std::cout << std::setprecision(12);

Grid_init(&argc, &argv);
Expand Down Expand Up @@ -220,6 +228,7 @@ int main(int argc, char **argv)
TheHMC.Run(SmearingPolicy); // for smearing

Grid_finalize();
#endif
} // main


Expand Down
8 changes: 8 additions & 0 deletions HMC/HMC2p1f_3GeV.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,20 @@ directory
*************************************************************************************/
/* END LEGAL */
#include <Grid/Grid.h>

#if Nc == 3
#include <Grid/qcd/smearing/GaugeConfigurationMasked.h>
#include <Grid/qcd/smearing/JacobianAction.h>
#endif

using namespace Grid;

int main(int argc, char **argv)
{
#if Nc != 3
#warning HMC2p1f_3GeV will not work for Nc != 3
std::cout << "This program will currently only work for Nc == 3." << std::endl;
#else
std::cout << std::setprecision(12);

Grid_init(&argc, &argv);
Expand Down Expand Up @@ -220,6 +227,7 @@ int main(int argc, char **argv)
TheHMC.Run(SmearingPolicy); // for smearing

Grid_finalize();
#endif
} // main


Expand Down