mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-15 14:27:06 +01:00
Merge branch 'feature/hadrons' into feature/qed-fvol
# Conflicts: # extras/Hadrons/Modules.hpp # extras/Hadrons/Modules/MGauge/StochEm.cc # extras/Hadrons/modules.inc
This commit is contained in:
@ -2,12 +2,13 @@
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MAction/Wilson.hpp
|
||||
Source file: extras/Hadrons/Modules/MAction/WilsonClover.hpp
|
||||
|
||||
Copyright (C) 2015
|
||||
Copyright (C) 2016
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Guido Cossu <guido.cossu@ed.ac.uk>
|
||||
Author: pretidav <david.preti@csic.es>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
143
extras/Hadrons/Modules/MAction/ZMobiusDWF.hpp
Normal file
143
extras/Hadrons/Modules/MAction/ZMobiusDWF.hpp
Normal file
@ -0,0 +1,143 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MAction/ZMobiusDWF.hpp
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
See the full license in the file "LICENSE" in the top level distribution directory
|
||||
*************************************************************************************/
|
||||
/* END LEGAL */
|
||||
#ifndef Hadrons_MAction_ZMobiusDWF_hpp_
|
||||
#define Hadrons_MAction_ZMobiusDWF_hpp_
|
||||
|
||||
#include <Grid/Hadrons/Global.hpp>
|
||||
#include <Grid/Hadrons/Module.hpp>
|
||||
#include <Grid/Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* ZMobiusDWF *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MAction)
|
||||
|
||||
class ZMobiusDWFPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(ZMobiusDWFPar,
|
||||
std::string , gauge,
|
||||
unsigned int , Ls,
|
||||
double , mass,
|
||||
double , M5,
|
||||
double , b,
|
||||
double , c,
|
||||
std::vector<std::complex<double>>, omega,
|
||||
std::string , boundary);
|
||||
};
|
||||
|
||||
template <typename FImpl>
|
||||
class TZMobiusDWF: public Module<ZMobiusDWFPar>
|
||||
{
|
||||
public:
|
||||
FGS_TYPE_ALIASES(FImpl,);
|
||||
public:
|
||||
// constructor
|
||||
TZMobiusDWF(const std::string name);
|
||||
// destructor
|
||||
virtual ~TZMobiusDWF(void) = default;
|
||||
// dependency relation
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
// setup
|
||||
virtual void setup(void);
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
};
|
||||
|
||||
MODULE_REGISTER_NS(ZMobiusDWF, TZMobiusDWF<ZFIMPL>, MAction);
|
||||
|
||||
/******************************************************************************
|
||||
* TZMobiusDWF implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
TZMobiusDWF<FImpl>::TZMobiusDWF(const std::string name)
|
||||
: Module<ZMobiusDWFPar>(name)
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TZMobiusDWF<FImpl>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par().gauge};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
template <typename FImpl>
|
||||
std::vector<std::string> TZMobiusDWF<FImpl>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TZMobiusDWF<FImpl>::setup(void)
|
||||
{
|
||||
LOG(Message) << "Setting up z-Mobius domain wall fermion matrix with m= "
|
||||
<< par().mass << ", M5= " << par().M5 << ", Ls= " << par().Ls
|
||||
<< ", b= " << par().b << ", c= " << par().c
|
||||
<< " using gauge field '" << par().gauge << "'"
|
||||
<< std::endl;
|
||||
LOG(Message) << "Omegas: " << std::endl;
|
||||
for (unsigned int i = 0; i < par().omega.size(); ++i)
|
||||
{
|
||||
LOG(Message) << " omega[" << i << "]= " << par().omega[i] << std::endl;
|
||||
}
|
||||
LOG(Message) << "Fermion boundary conditions: " << par().boundary
|
||||
<< std::endl;
|
||||
|
||||
env().createGrid(par().Ls);
|
||||
auto &U = envGet(LatticeGaugeField, par().gauge);
|
||||
auto &g4 = *env().getGrid();
|
||||
auto &grb4 = *env().getRbGrid();
|
||||
auto &g5 = *env().getGrid(par().Ls);
|
||||
auto &grb5 = *env().getRbGrid(par().Ls);
|
||||
auto omega = par().omega;
|
||||
std::vector<Complex> boundary = strToVec<Complex>(par().boundary);
|
||||
typename ZMobiusFermion<FImpl>::ImplParams implParams(boundary);
|
||||
envCreateDerived(FMat, ZMobiusFermion<FImpl>, getName(), par().Ls, U, g5,
|
||||
grb5, g4, grb4, par().mass, par().M5, omega,
|
||||
par().b, par().c, implParams);
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TZMobiusDWF<FImpl>::execute(void)
|
||||
{}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MAction_ZMobiusDWF_hpp_
|
@ -7,7 +7,9 @@ Source file: extras/Hadrons/Modules/MFermion/GaugeProp.hpp
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Guido Cossu <guido.cossu@ed.ac.uk>
|
||||
Author: Lanny91 <andrew.lawson@gmail.com>
|
||||
Author: pretidav <david.preti@csic.es>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,11 +4,10 @@ Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MGauge/FundtoHirep.hpp
|
||||
|
||||
Copyright (C) 2015
|
||||
Copyright (C) 2016
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: David Preti <david.preti@to.infn.it>
|
||||
Guido Cossu <guido.cossu@ed.ac.uk>
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: pretidav <david.preti@csic.es>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -7,6 +7,7 @@ Source file: extras/Hadrons/Modules/MGauge/StochEm.hpp
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Vera Guelpers <vmg1n14@soton.ac.uk>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -71,6 +71,4 @@ void TLoadNersc::execute(void)
|
||||
|
||||
auto &U = envGet(LatticeGaugeField, getName());
|
||||
NerscIO::readConfiguration(U, header, fileName);
|
||||
LOG(Message) << "NERSC header:" << std::endl;
|
||||
dump_meta_data(header, LOG(Message));
|
||||
}
|
||||
|
@ -31,18 +31,18 @@ See the full license in the file "LICENSE" in the top level distribution directo
|
||||
#include <Grid/Hadrons/Global.hpp>
|
||||
#include <Grid/Hadrons/Module.hpp>
|
||||
#include <Grid/Hadrons/ModuleFactory.hpp>
|
||||
#include <Grid/Hadrons/Modules/MScalarSUN/Utils.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* Div *
|
||||
* Divergence of a vector field *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MScalarSUN)
|
||||
|
||||
class DivPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_ENUM(DiffType, undef, forward, 1, backward, 2, central, 3);
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(DivPar,
|
||||
std::vector<std::string>, op,
|
||||
DiffType, type,
|
||||
@ -59,8 +59,8 @@ public:
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
|
||||
DivPar::DiffType, type,
|
||||
Complex, value);
|
||||
DiffType, type,
|
||||
Complex, value);
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
@ -83,7 +83,7 @@ MODULE_REGISTER_NS(DivSU5, TDiv<ScalarNxNAdjImplR<5>>, MScalarSUN);
|
||||
MODULE_REGISTER_NS(DivSU6, TDiv<ScalarNxNAdjImplR<6>>, MScalarSUN);
|
||||
|
||||
/******************************************************************************
|
||||
* TDiv implementation *
|
||||
* TDiv implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
template <typename SImpl>
|
||||
@ -135,18 +135,7 @@ void TDiv<SImpl>::execute(void)
|
||||
for (unsigned int mu = 0; mu < nd; ++mu)
|
||||
{
|
||||
auto &op = envGet(ComplexField, par().op[mu]);
|
||||
switch(par().type)
|
||||
{
|
||||
case DivPar::DiffType::backward:
|
||||
div += op - Cshift(op, mu, -1);
|
||||
break;
|
||||
case DivPar::DiffType::forward:
|
||||
div += Cshift(op, mu, 1) - op;
|
||||
break;
|
||||
case DivPar::DiffType::central:
|
||||
div += 0.5*(Cshift(op, mu, 1) - Cshift(op, mu, -1));
|
||||
break;
|
||||
}
|
||||
dmuAcc(div, op, mu, par().type);
|
||||
}
|
||||
if (!par().output.empty())
|
||||
{
|
||||
|
181
extras/Hadrons/Modules/MScalarSUN/EMT.hpp
Normal file
181
extras/Hadrons/Modules/MScalarSUN/EMT.hpp
Normal file
@ -0,0 +1,181 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MScalarSUN/EMT.hpp
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
See the full license in the file "LICENSE" in the top level distribution directory
|
||||
*************************************************************************************/
|
||||
/* END LEGAL */
|
||||
#ifndef Hadrons_MScalarSUN_EMT_hpp_
|
||||
#define Hadrons_MScalarSUN_EMT_hpp_
|
||||
|
||||
#include <Grid/Hadrons/Global.hpp>
|
||||
#include <Grid/Hadrons/Module.hpp>
|
||||
#include <Grid/Hadrons/ModuleFactory.hpp>
|
||||
#include <Grid/Hadrons/Modules/MScalarSUN/Utils.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* Energy-momentum tensor *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MScalarSUN)
|
||||
|
||||
class EMTPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(EMTPar,
|
||||
std::string, kinetic,
|
||||
std::string, phiPow,
|
||||
std::string, improvement,
|
||||
double , m2,
|
||||
double , lambda,
|
||||
double , g,
|
||||
double , xi,
|
||||
std::string, output);
|
||||
};
|
||||
|
||||
template <typename SImpl>
|
||||
class TEMT: public Module<EMTPar>
|
||||
{
|
||||
public:
|
||||
typedef typename SImpl::Field Field;
|
||||
typedef typename SImpl::ComplexField ComplexField;
|
||||
public:
|
||||
// constructor
|
||||
TEMT(const std::string name);
|
||||
// destructor
|
||||
virtual ~TEMT(void) = default;
|
||||
// dependency relation
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
// setup
|
||||
virtual void setup(void);
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
};
|
||||
|
||||
MODULE_REGISTER_NS(EMTSU2, TEMT<ScalarNxNAdjImplR<2>>, MScalarSUN);
|
||||
MODULE_REGISTER_NS(EMTSU3, TEMT<ScalarNxNAdjImplR<3>>, MScalarSUN);
|
||||
MODULE_REGISTER_NS(EMTSU4, TEMT<ScalarNxNAdjImplR<4>>, MScalarSUN);
|
||||
MODULE_REGISTER_NS(EMTSU5, TEMT<ScalarNxNAdjImplR<5>>, MScalarSUN);
|
||||
MODULE_REGISTER_NS(EMTSU6, TEMT<ScalarNxNAdjImplR<6>>, MScalarSUN);
|
||||
|
||||
/******************************************************************************
|
||||
* TEMT implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
template <typename SImpl>
|
||||
TEMT<SImpl>::TEMT(const std::string name)
|
||||
: Module<EMTPar>(name)
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
template <typename SImpl>
|
||||
std::vector<std::string> TEMT<SImpl>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in;
|
||||
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
for (unsigned int nu = mu; nu < env().getNd(); ++nu)
|
||||
{
|
||||
in.push_back(varName(par().kinetic, mu, nu));
|
||||
in.push_back(varName(par().improvement, mu, nu));
|
||||
}
|
||||
in.push_back(varName(par().phiPow, 2));
|
||||
in.push_back(varName(par().phiPow, 4));
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
template <typename SImpl>
|
||||
std::vector<std::string> TEMT<SImpl>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out;
|
||||
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
for (unsigned int nu = mu; nu < env().getNd(); ++nu)
|
||||
{
|
||||
out.push_back(varName(getName(), mu, nu));
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
template <typename SImpl>
|
||||
void TEMT<SImpl>::setup(void)
|
||||
{
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
for (unsigned int nu = mu; nu < env().getNd(); ++nu)
|
||||
{
|
||||
envCreateLat(ComplexField, varName(getName(), mu, nu));
|
||||
}
|
||||
envTmpLat(ComplexField, "sumkin");
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename SImpl>
|
||||
void TEMT<SImpl>::execute(void)
|
||||
{
|
||||
LOG(Message) << "Computing energy-momentum tensor" << std::endl;
|
||||
LOG(Message) << " kinetic terms: '" << par().kinetic << "'" << std::endl;
|
||||
LOG(Message) << " tr(phi^n): '" << par().phiPow << "'" << std::endl;
|
||||
LOG(Message) << " improvement: '" << par().improvement << "'" << std::endl;
|
||||
LOG(Message) << " m^2= " << par().m2 << std::endl;
|
||||
LOG(Message) << " lambda= " << par().lambda << std::endl;
|
||||
LOG(Message) << " g= " << par().g << std::endl;
|
||||
LOG(Message) << " xi= " << par().xi << std::endl;
|
||||
|
||||
const unsigned int N = SImpl::Group::Dimension;
|
||||
auto &trphi2 = envGet(ComplexField, varName(par().phiPow, 2));
|
||||
auto &trphi4 = envGet(ComplexField, varName(par().phiPow, 4));
|
||||
|
||||
envGetTmp(ComplexField, sumkin);
|
||||
sumkin = zero;
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
{
|
||||
auto &trkin = envGet(ComplexField, varName(par().kinetic, mu, mu));
|
||||
|
||||
sumkin += trkin;
|
||||
}
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
for (unsigned int nu = mu; nu < env().getNd(); ++nu)
|
||||
{
|
||||
auto &out = envGet(ComplexField, varName(getName(), mu, nu));
|
||||
auto &trkin = envGet(ComplexField, varName(par().kinetic, mu, nu));
|
||||
auto &imp = envGet(ComplexField, varName(par().improvement, mu, nu));
|
||||
|
||||
out = 2.*trkin + par().xi*imp;
|
||||
if (mu == nu)
|
||||
{
|
||||
out -= sumkin + par().m2*trphi2 + par().lambda*trphi4;
|
||||
}
|
||||
out *= N/par().g;
|
||||
}
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MScalarSUN_EMT_hpp_
|
170
extras/Hadrons/Modules/MScalarSUN/TrKinetic.hpp
Normal file
170
extras/Hadrons/Modules/MScalarSUN/TrKinetic.hpp
Normal file
@ -0,0 +1,170 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MScalarSUN/TrKinetic.hpp
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
See the full license in the file "LICENSE" in the top level distribution directory
|
||||
*************************************************************************************/
|
||||
/* END LEGAL */
|
||||
#ifndef Hadrons_MScalarSUN_TrKinetic_hpp_
|
||||
#define Hadrons_MScalarSUN_TrKinetic_hpp_
|
||||
|
||||
#include <Grid/Hadrons/Global.hpp>
|
||||
#include <Grid/Hadrons/Module.hpp>
|
||||
#include <Grid/Hadrons/ModuleFactory.hpp>
|
||||
#include <Grid/Hadrons/Modules/MScalarSUN/Utils.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* Trace of kinetic term *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MScalarSUN)
|
||||
|
||||
class TrKineticPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(TrKineticPar,
|
||||
std::string, field,
|
||||
DiffType, type,
|
||||
std::string, output);
|
||||
};
|
||||
|
||||
template <typename SImpl>
|
||||
class TTrKinetic: public Module<TrKineticPar>
|
||||
{
|
||||
public:
|
||||
typedef typename SImpl::Field Field;
|
||||
typedef typename SImpl::ComplexField ComplexField;
|
||||
class Result: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
|
||||
std::string, op,
|
||||
Complex , value);
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
TTrKinetic(const std::string name);
|
||||
// destructor
|
||||
virtual ~TTrKinetic(void) = default;
|
||||
// dependency relation
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
// setup
|
||||
virtual void setup(void);
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
};
|
||||
|
||||
MODULE_REGISTER_NS(TrKineticSU2, TTrKinetic<ScalarNxNAdjImplR<2>>, MScalarSUN);
|
||||
MODULE_REGISTER_NS(TrKineticSU3, TTrKinetic<ScalarNxNAdjImplR<3>>, MScalarSUN);
|
||||
MODULE_REGISTER_NS(TrKineticSU4, TTrKinetic<ScalarNxNAdjImplR<4>>, MScalarSUN);
|
||||
MODULE_REGISTER_NS(TrKineticSU5, TTrKinetic<ScalarNxNAdjImplR<5>>, MScalarSUN);
|
||||
MODULE_REGISTER_NS(TrKineticSU6, TTrKinetic<ScalarNxNAdjImplR<6>>, MScalarSUN);
|
||||
|
||||
/******************************************************************************
|
||||
* TTrKinetic implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
template <typename SImpl>
|
||||
TTrKinetic<SImpl>::TTrKinetic(const std::string name)
|
||||
: Module<TrKineticPar>(name)
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
template <typename SImpl>
|
||||
std::vector<std::string> TTrKinetic<SImpl>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par().field};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
template <typename SImpl>
|
||||
std::vector<std::string> TTrKinetic<SImpl>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out ;
|
||||
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
for (unsigned int nu = mu; nu < env().getNd(); ++nu)
|
||||
{
|
||||
out.push_back(varName(getName(), mu, nu));
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
template <typename SImpl>
|
||||
void TTrKinetic<SImpl>::setup(void)
|
||||
{
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
for (unsigned int nu = mu; nu < env().getNd(); ++nu)
|
||||
{
|
||||
envCreateLat(ComplexField, varName(getName(), mu, nu));
|
||||
}
|
||||
envTmp(std::vector<Field>, "der", 1, env().getNd(), env().getGrid());
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename SImpl>
|
||||
void TTrKinetic<SImpl>::execute(void)
|
||||
{
|
||||
LOG(Message) << "Computing tr(d_mu phi*d_nu phi) using " << par().type
|
||||
<< " derivative" << std::endl;
|
||||
|
||||
std::vector<Result> result;
|
||||
auto &phi = envGet(Field, par().field);
|
||||
|
||||
envGetTmp(std::vector<Field>, der);
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
{
|
||||
dmu(der[mu], phi, mu, par().type);
|
||||
}
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
for (unsigned int nu = mu; nu < env().getNd(); ++nu)
|
||||
{
|
||||
auto &out = envGet(ComplexField, varName(getName(), mu, nu));
|
||||
|
||||
out = -trace(der[mu]*der[nu]);
|
||||
if (!par().output.empty())
|
||||
{
|
||||
Result r;
|
||||
|
||||
r.op = "tr(d_" + std::to_string(mu) + "phi*d_"
|
||||
+ std::to_string(nu) + "phi)";
|
||||
r.value = TensorRemove(sum(out));
|
||||
result.push_back(r);
|
||||
}
|
||||
}
|
||||
if (result.size() > 0)
|
||||
{
|
||||
saveResult(par().output, "trkinetic", result);
|
||||
}
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MScalarSUN_TrKinetic_hpp_
|
@ -31,11 +31,12 @@ See the full license in the file "LICENSE" in the top level distribution directo
|
||||
#include <Grid/Hadrons/Global.hpp>
|
||||
#include <Grid/Hadrons/Module.hpp>
|
||||
#include <Grid/Hadrons/ModuleFactory.hpp>
|
||||
#include <Grid/Hadrons/Modules/MScalarSUN/Utils.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* Module to compute tr(mag^n) *
|
||||
* Trace of powers of the magnetisation *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MScalarSUN)
|
||||
|
||||
@ -117,7 +118,7 @@ template <typename SImpl>
|
||||
void TTrMag<SImpl>::execute(void)
|
||||
{
|
||||
LOG(Message) << "Computing tr(mag^n) for n even up to " << par().maxPow
|
||||
<< "..." << std::endl;
|
||||
<< std::endl;
|
||||
|
||||
std::vector<Result> result;
|
||||
auto &phi = envGet(Field, par().field);
|
||||
|
@ -31,11 +31,12 @@ See the full license in the file "LICENSE" in the top level distribution directo
|
||||
#include <Grid/Hadrons/Global.hpp>
|
||||
#include <Grid/Hadrons/Module.hpp>
|
||||
#include <Grid/Hadrons/ModuleFactory.hpp>
|
||||
#include <Grid/Hadrons/Modules/MScalarSUN/Utils.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* Module to compute tr(phi^n) *
|
||||
* Trace of powers of a scalar field *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MScalarSUN)
|
||||
|
||||
@ -73,9 +74,6 @@ public:
|
||||
virtual void setup(void);
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
private:
|
||||
// output name generator
|
||||
std::string outName(const unsigned int n);
|
||||
};
|
||||
|
||||
MODULE_REGISTER_NS(TrPhiSU2, TTrPhi<ScalarNxNAdjImplR<2>>, MScalarSUN);
|
||||
@ -109,7 +107,7 @@ std::vector<std::string> TTrPhi<SImpl>::getOutput(void)
|
||||
|
||||
for (unsigned int n = 2; n <= par().maxPow; n += 2)
|
||||
{
|
||||
out.push_back(outName(n));
|
||||
out.push_back(varName(getName(), n));
|
||||
}
|
||||
|
||||
return out;
|
||||
@ -127,7 +125,7 @@ void TTrPhi<SImpl>::setup(void)
|
||||
envTmpLat(Field, "buf");
|
||||
for (unsigned int n = 2; n <= par().maxPow; n += 2)
|
||||
{
|
||||
envCreateLat(ComplexField, outName(n));
|
||||
envCreateLat(ComplexField, varName(getName(), n));
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +134,7 @@ template <typename SImpl>
|
||||
void TTrPhi<SImpl>::execute(void)
|
||||
{
|
||||
LOG(Message) << "Computing tr(phi^n) for n even up to " << par().maxPow
|
||||
<< "..." << std::endl;
|
||||
<< std::endl;
|
||||
|
||||
std::vector<Result> result;
|
||||
auto &phi = envGet(Field, par().field);
|
||||
@ -147,7 +145,7 @@ void TTrPhi<SImpl>::execute(void)
|
||||
phi2 = -phi*phi;
|
||||
for (unsigned int n = 2; n <= par().maxPow; n += 2)
|
||||
{
|
||||
auto &phin = envGet(ComplexField, outName(n));
|
||||
auto &phin = envGet(ComplexField, varName(getName(), n));
|
||||
|
||||
buf = buf*phi2;
|
||||
phin = trace(buf);
|
||||
@ -166,13 +164,6 @@ void TTrPhi<SImpl>::execute(void)
|
||||
}
|
||||
}
|
||||
|
||||
// output name generator ///////////////////////////////////////////////////////
|
||||
template <typename SImpl>
|
||||
std::string TTrPhi<SImpl>::outName(const unsigned int n)
|
||||
{
|
||||
return getName() + "_" + std::to_string(n);
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
185
extras/Hadrons/Modules/MScalarSUN/TransProj.hpp
Normal file
185
extras/Hadrons/Modules/MScalarSUN/TransProj.hpp
Normal file
@ -0,0 +1,185 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MScalarSUN/TransProj.hpp
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
See the full license in the file "LICENSE" in the top level distribution directory
|
||||
*************************************************************************************/
|
||||
/* END LEGAL */
|
||||
#ifndef Hadrons_MScalarSUN_TransProj_hpp_
|
||||
#define Hadrons_MScalarSUN_TransProj_hpp_
|
||||
|
||||
#include <Grid/Hadrons/Global.hpp>
|
||||
#include <Grid/Hadrons/Module.hpp>
|
||||
#include <Grid/Hadrons/ModuleFactory.hpp>
|
||||
#include <Grid/Hadrons/Modules/MScalarSUN/Utils.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* Transverse projection *
|
||||
******************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MScalarSUN)
|
||||
|
||||
class TransProjPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(TransProjPar,
|
||||
std::string, op,
|
||||
DiffType, type,
|
||||
std::string, output);
|
||||
};
|
||||
|
||||
template <typename SImpl>
|
||||
class TTransProj: public Module<TransProjPar>
|
||||
{
|
||||
public:
|
||||
typedef typename SImpl::Field Field;
|
||||
typedef typename SImpl::ComplexField ComplexField;
|
||||
class Result: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
|
||||
std::string, op,
|
||||
Complex , value);
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
TTransProj(const std::string name);
|
||||
// destructor
|
||||
virtual ~TTransProj(void) = default;
|
||||
// dependency relation
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
// setup
|
||||
virtual void setup(void);
|
||||
// execution
|
||||
|
||||
virtual void execute(void);
|
||||
};
|
||||
|
||||
MODULE_REGISTER_NS(TransProjSU2, TTransProj<ScalarNxNAdjImplR<2>>, MScalarSUN);
|
||||
MODULE_REGISTER_NS(TransProjSU3, TTransProj<ScalarNxNAdjImplR<3>>, MScalarSUN);
|
||||
MODULE_REGISTER_NS(TransProjSU4, TTransProj<ScalarNxNAdjImplR<4>>, MScalarSUN);
|
||||
MODULE_REGISTER_NS(TransProjSU5, TTransProj<ScalarNxNAdjImplR<5>>, MScalarSUN);
|
||||
MODULE_REGISTER_NS(TransProjSU6, TTransProj<ScalarNxNAdjImplR<6>>, MScalarSUN);
|
||||
|
||||
/******************************************************************************
|
||||
* TTransProj implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
template <typename SImpl>
|
||||
TTransProj<SImpl>::TTransProj(const std::string name)
|
||||
: Module<TransProjPar>(name)
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
template <typename SImpl>
|
||||
std::vector<std::string> TTransProj<SImpl>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par().op};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
template <typename SImpl>
|
||||
std::vector<std::string> TTransProj<SImpl>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out;
|
||||
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
for (unsigned int nu = mu; nu < env().getNd(); ++nu)
|
||||
{
|
||||
out.push_back(varName(getName(), mu, nu));
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
template <typename SImpl>
|
||||
void TTransProj<SImpl>::setup(void)
|
||||
{
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
for (unsigned int nu = mu; nu < env().getNd(); ++nu)
|
||||
{
|
||||
envCreateLat(ComplexField, varName(getName(), mu, nu));
|
||||
}
|
||||
envTmpLat(ComplexField, "buf1");
|
||||
envTmpLat(ComplexField, "buf2");
|
||||
envTmpLat(ComplexField, "lap");
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename SImpl>
|
||||
void TTransProj<SImpl>::execute(void)
|
||||
{
|
||||
LOG(Message) << "Computing (delta_mu,nu d^2 - d_mu*d_nu)*op using "
|
||||
<< par().type << " derivatives and op= '" << par().op
|
||||
<< "'" << std::endl;
|
||||
|
||||
std::vector<Result> result;
|
||||
auto &op = envGet(ComplexField, par().op);
|
||||
|
||||
envGetTmp(ComplexField, buf1);
|
||||
envGetTmp(ComplexField, buf2);
|
||||
envGetTmp(ComplexField, lap);
|
||||
lap = zero;
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
{
|
||||
dmu(buf1, op, mu, par().type);
|
||||
dmu(buf2, buf1, mu, par().type);
|
||||
lap += buf2;
|
||||
}
|
||||
for (unsigned int mu = 0; mu < env().getNd(); ++mu)
|
||||
for (unsigned int nu = mu; nu < env().getNd(); ++nu)
|
||||
{
|
||||
auto &out = envGet(ComplexField, varName(getName(), mu, nu));
|
||||
dmu(buf1, op, mu, par().type);
|
||||
dmu(buf2, buf1, nu, par().type);
|
||||
out = -buf2;
|
||||
if (mu == nu)
|
||||
{
|
||||
out += lap;
|
||||
}
|
||||
if (!par().output.empty())
|
||||
{
|
||||
Result r;
|
||||
|
||||
r.op = "(delta_" + std::to_string(mu) + "," + std::to_string(nu)
|
||||
+ " d^2 - d_" + std::to_string(mu) + "*d_"
|
||||
+ std::to_string(nu) + ")*op";
|
||||
r.value = TensorRemove(sum(out));
|
||||
result.push_back(r);
|
||||
}
|
||||
}
|
||||
if (result.size() > 0)
|
||||
{
|
||||
saveResult(par().output, "transproj", result);
|
||||
}
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MScalarSUN_TransProj_hpp_
|
@ -31,6 +31,7 @@ See the full license in the file "LICENSE" in the top level distribution directo
|
||||
#include <Grid/Hadrons/Global.hpp>
|
||||
#include <Grid/Hadrons/Module.hpp>
|
||||
#include <Grid/Hadrons/ModuleFactory.hpp>
|
||||
#include <Grid/Hadrons/Modules/MScalarSUN/Utils.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
@ -87,7 +88,7 @@ MODULE_REGISTER_NS(TwoPointSU5, TTwoPoint<ScalarNxNAdjImplR<5>>, MScalarSUN);
|
||||
MODULE_REGISTER_NS(TwoPointSU6, TTwoPoint<ScalarNxNAdjImplR<6>>, MScalarSUN);
|
||||
|
||||
/******************************************************************************
|
||||
* TTwoPoint implementation *
|
||||
* TTwoPoint implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
template <typename SImpl>
|
||||
|
107
extras/Hadrons/Modules/MScalarSUN/Utils.hpp
Normal file
107
extras/Hadrons/Modules/MScalarSUN/Utils.hpp
Normal file
@ -0,0 +1,107 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MScalarSUN/Utils.hpp
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
See the full license in the file "LICENSE" in the top level distribution directory
|
||||
*************************************************************************************/
|
||||
/* END LEGAL */
|
||||
#ifndef Hadrons_MScalarSUN_Utils_hpp_
|
||||
#define Hadrons_MScalarSUN_Utils_hpp_
|
||||
|
||||
#include <Grid/Hadrons/Global.hpp>
|
||||
#include <Grid/Hadrons/Module.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
BEGIN_MODULE_NAMESPACE(MScalarSUN)
|
||||
|
||||
GRID_SERIALIZABLE_ENUM(DiffType, undef, forward, 1, backward, 2, central, 3);
|
||||
|
||||
template <typename Field>
|
||||
inline void dmu(Field &out, const Field &in, const unsigned int mu, const DiffType type)
|
||||
{
|
||||
auto & env = Environment::getInstance();
|
||||
|
||||
if (mu >= env.getNd())
|
||||
{
|
||||
HADRON_ERROR(Range, "Derivative direction out of range");
|
||||
}
|
||||
switch(type)
|
||||
{
|
||||
case DiffType::backward:
|
||||
out = in - Cshift(in, mu, -1);
|
||||
break;
|
||||
case DiffType::forward:
|
||||
out = Cshift(in, mu, 1) - in;
|
||||
break;
|
||||
case DiffType::central:
|
||||
out = 0.5*(Cshift(in, mu, 1) - Cshift(in, mu, -1));
|
||||
break;
|
||||
default:
|
||||
HADRON_ERROR(Argument, "Derivative type invalid");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Field>
|
||||
inline void dmuAcc(Field &out, const Field &in, const unsigned int mu, const DiffType type)
|
||||
{
|
||||
auto & env = Environment::getInstance();
|
||||
|
||||
if (mu >= env.getNd())
|
||||
{
|
||||
HADRON_ERROR(Range, "Derivative direction out of range");
|
||||
}
|
||||
switch(type)
|
||||
{
|
||||
case DiffType::backward:
|
||||
out += in - Cshift(in, mu, -1);
|
||||
break;
|
||||
case DiffType::forward:
|
||||
out += Cshift(in, mu, 1) - in;
|
||||
break;
|
||||
case DiffType::central:
|
||||
out += 0.5*(Cshift(in, mu, 1) - Cshift(in, mu, -1));
|
||||
break;
|
||||
default:
|
||||
HADRON_ERROR(Argument, "Derivative type invalid");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string varName(const std::string name, const unsigned int mu)
|
||||
{
|
||||
return name + "_" + std::to_string(mu);
|
||||
}
|
||||
|
||||
inline std::string varName(const std::string name, const unsigned int mu,
|
||||
const unsigned int nu)
|
||||
{
|
||||
return name + "_" + std::to_string(mu) + "_" + std::to_string(nu);
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MScalarSUN_Utils_hpp_
|
249
extras/Hadrons/Modules/MSolver/LocalCoherenceLanczos.hpp
Normal file
249
extras/Hadrons/Modules/MSolver/LocalCoherenceLanczos.hpp
Normal file
@ -0,0 +1,249 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: extras/Hadrons/Modules/MSolver/LocalCoherenceLanczos.hpp
|
||||
|
||||
Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
See the full license in the file "LICENSE" in the top level distribution directory
|
||||
*************************************************************************************/
|
||||
/* END LEGAL */
|
||||
#ifndef Hadrons_MSolver_LocalCoherenceLanczos_hpp_
|
||||
#define Hadrons_MSolver_LocalCoherenceLanczos_hpp_
|
||||
|
||||
#include <Grid/Hadrons/Global.hpp>
|
||||
#include <Grid/Hadrons/Module.hpp>
|
||||
#include <Grid/Hadrons/ModuleFactory.hpp>
|
||||
#include <Grid/Hadrons/LanczosUtils.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* Local coherence Lanczos eigensolver *
|
||||
*****************************************************************************/
|
||||
BEGIN_MODULE_NAMESPACE(MSolver)
|
||||
|
||||
class LocalCoherenceLanczosPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(LocalCoherenceLanczosPar,
|
||||
std::string, action,
|
||||
int, doFine,
|
||||
int, doCoarse,
|
||||
LanczosParams, fineParams,
|
||||
LanczosParams, coarseParams,
|
||||
ChebyParams, smoother,
|
||||
RealD, coarseRelaxTol,
|
||||
std::string, blockSize,
|
||||
std::string, output);
|
||||
};
|
||||
|
||||
template <typename FImpl, int nBasis>
|
||||
class TLocalCoherenceLanczos: public Module<LocalCoherenceLanczosPar>
|
||||
{
|
||||
public:
|
||||
FERM_TYPE_ALIASES(FImpl,);
|
||||
typedef LocalCoherenceLanczos<typename FImpl::SiteSpinor,
|
||||
typename FImpl::SiteComplex,
|
||||
nBasis> LCL;
|
||||
typedef FineEigenPack<FImpl> FinePack;
|
||||
typedef CoarseEigenPack<FImpl, nBasis> CoarsePack;
|
||||
typedef HADRONS_DEFAULT_SCHUR_OP<FMat, FermionField> SchurFMat;
|
||||
public:
|
||||
// constructor
|
||||
TLocalCoherenceLanczos(const std::string name);
|
||||
// destructor
|
||||
virtual ~TLocalCoherenceLanczos(void) = default;
|
||||
// dependency relation
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
// setup
|
||||
virtual void setup(void);
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
private:
|
||||
void makeCoarseGrid(void);
|
||||
private:
|
||||
std::vector<int> coarseDim_;
|
||||
int Ls_, cLs_{1};
|
||||
std::unique_ptr<GridCartesian> coarseGrid4_{nullptr};
|
||||
std::unique_ptr<GridCartesian> coarseGrid_{nullptr};
|
||||
std::unique_ptr<GridRedBlackCartesian> coarseGrid4Rb_{nullptr};
|
||||
std::unique_ptr<GridRedBlackCartesian> coarseGridRb_{nullptr};
|
||||
std::string fineName_, coarseName_;
|
||||
};
|
||||
|
||||
MODULE_REGISTER_NS(LocalCoherenceLanczos,
|
||||
ARG(TLocalCoherenceLanczos<FIMPL, HADRONS_DEFAULT_LANCZOS_NBASIS>),
|
||||
MSolver);
|
||||
MODULE_REGISTER_NS(ZLocalCoherenceLanczos,
|
||||
ARG(TLocalCoherenceLanczos<ZFIMPL, HADRONS_DEFAULT_LANCZOS_NBASIS>),
|
||||
MSolver);
|
||||
|
||||
/******************************************************************************
|
||||
* TLocalCoherenceLanczos implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl, int nBasis>
|
||||
TLocalCoherenceLanczos<FImpl, nBasis>::TLocalCoherenceLanczos(const std::string name)
|
||||
: Module<LocalCoherenceLanczosPar>(name)
|
||||
{
|
||||
fineName_ = getName() + "_fine";
|
||||
coarseName_ = getName() + "_coarse";
|
||||
}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
template <typename FImpl, int nBasis>
|
||||
std::vector<std::string> TLocalCoherenceLanczos<FImpl, nBasis>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par().action};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
template <typename FImpl, int nBasis>
|
||||
std::vector<std::string> TLocalCoherenceLanczos<FImpl, nBasis>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {fineName_, coarseName_};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl, int nBasis>
|
||||
void TLocalCoherenceLanczos<FImpl, nBasis>::makeCoarseGrid(void)
|
||||
{
|
||||
int nd = env().getNd();
|
||||
std::vector<int> blockSize = strToVec<int>(par().blockSize);
|
||||
auto fineDim = env().getDim();
|
||||
|
||||
Ls_ = env().getObjectLs(par().action);
|
||||
env().createGrid(Ls_);
|
||||
coarseDim_.resize(nd);
|
||||
for (int d = 0; d < coarseDim_.size(); d++)
|
||||
{
|
||||
coarseDim_[d] = fineDim[d]/blockSize[d];
|
||||
if (coarseDim_[d]*blockSize[d] != fineDim[d])
|
||||
{
|
||||
HADRON_ERROR(Size, "Fine dimension " + std::to_string(d)
|
||||
+ " (" + std::to_string(fineDim[d])
|
||||
+ ") not divisible by coarse dimension ("
|
||||
+ std::to_string(coarseDim_[d]) + ")");
|
||||
}
|
||||
}
|
||||
if (blockSize.size() > nd)
|
||||
{
|
||||
cLs_ = Ls_/blockSize[nd];
|
||||
if (cLs_*blockSize[nd] != Ls_)
|
||||
{
|
||||
HADRON_ERROR(Size, "Fine Ls (" + std::to_string(Ls_)
|
||||
+ ") not divisible by coarse Ls ("
|
||||
+ std::to_string(cLs_) + ")");
|
||||
}
|
||||
}
|
||||
if (Ls_ > 1)
|
||||
{
|
||||
coarseGrid4_.reset(SpaceTimeGrid::makeFourDimGrid(
|
||||
coarseDim_, GridDefaultSimd(nd, vComplex::Nsimd()),
|
||||
GridDefaultMpi()));
|
||||
coarseGrid4Rb_.reset(SpaceTimeGrid::makeFourDimRedBlackGrid(coarseGrid4_.get()));
|
||||
coarseGrid_.reset(SpaceTimeGrid::makeFiveDimGrid(cLs_, coarseGrid4_.get()));
|
||||
coarseGridRb_.reset(SpaceTimeGrid::makeFiveDimRedBlackGrid(cLs_, coarseGrid4_.get()));
|
||||
}
|
||||
else
|
||||
{
|
||||
coarseGrid_.reset(SpaceTimeGrid::makeFourDimGrid(
|
||||
coarseDim_, GridDefaultSimd(nd, vComplex::Nsimd()),
|
||||
GridDefaultMpi()));
|
||||
coarseGridRb_.reset(SpaceTimeGrid::makeFourDimRedBlackGrid(coarseGrid_.get()));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename FImpl, int nBasis>
|
||||
void TLocalCoherenceLanczos<FImpl, nBasis>::setup(void)
|
||||
{
|
||||
LOG(Message) << "Setting up local coherence Lanczos eigensolver for"
|
||||
<< " action '" << par().action << "' (" << nBasis
|
||||
<< " eigenvectors)..." << std::endl;
|
||||
|
||||
if (!coarseGrid_)
|
||||
{
|
||||
makeCoarseGrid();
|
||||
}
|
||||
LOG(Message) << "Coarse grid: " << coarseGrid_->GlobalDimensions() << std::endl;
|
||||
envCreate(FinePack, fineName_, Ls_, par().fineParams.Nm, env().getRbGrid(Ls_));
|
||||
envCreate(CoarsePack, coarseName_, Ls_, par().coarseParams.Nm, coarseGridRb_.get());
|
||||
auto &fine = envGet(FinePack, fineName_);
|
||||
auto &coarse = envGet(CoarsePack, coarseName_);
|
||||
envTmp(SchurFMat, "mat", Ls_, envGet(FMat, par().action));
|
||||
envGetTmp(SchurFMat, mat);
|
||||
envTmp(LCL, "solver", Ls_, env().getRbGrid(Ls_), coarseGridRb_.get(), mat,
|
||||
Odd, fine.evec, coarse.evec, fine.eval, coarse.eval);
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl, int nBasis>
|
||||
void TLocalCoherenceLanczos<FImpl, nBasis>::execute(void)
|
||||
{
|
||||
auto &finePar = par().fineParams;
|
||||
auto &coarsePar = par().coarseParams;
|
||||
auto &fine = envGet(FinePack, fineName_);
|
||||
auto &coarse = envGet(CoarsePack, coarseName_);
|
||||
|
||||
envGetTmp(LCL, solver);
|
||||
if (par().doFine)
|
||||
{
|
||||
LOG(Message) << "Performing fine grid IRL -- Nstop= "
|
||||
<< finePar.Nstop << ", Nk= " << finePar.Nk << ", Nm= "
|
||||
<< finePar.Nm << std::endl;
|
||||
solver.calcFine(finePar.Cheby, finePar.Nstop, finePar.Nk, finePar.Nm,
|
||||
finePar.resid,finePar.MaxIt, finePar.betastp,
|
||||
finePar.MinRes);
|
||||
solver.testFine(finePar.resid*100.0);
|
||||
LOG(Message) << "Orthogonalising" << std::endl;
|
||||
solver.Orthogonalise();
|
||||
if (!par().output.empty())
|
||||
{
|
||||
fine.write(par().output + "_fine");
|
||||
}
|
||||
}
|
||||
if (par().doCoarse)
|
||||
{
|
||||
LOG(Message) << "Performing coarse grid IRL -- Nstop= "
|
||||
<< coarsePar.Nstop << ", Nk= " << coarsePar.Nk << ", Nm= "
|
||||
<< coarsePar.Nm << std::endl;
|
||||
solver.calcCoarse(coarsePar.Cheby, par().smoother, par().coarseRelaxTol,
|
||||
coarsePar.Nstop, coarsePar.Nk, coarsePar.Nm,
|
||||
coarsePar.resid, coarsePar.MaxIt, coarsePar.betastp,
|
||||
coarsePar.MinRes);
|
||||
solver.testCoarse(coarsePar.resid*100.0, par().smoother,
|
||||
par().coarseRelaxTol);
|
||||
if (!par().output.empty())
|
||||
{
|
||||
coarse.write(par().output + "_coarse");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_MSolver_LocalCoherenceLanczos_hpp_
|
@ -43,9 +43,10 @@ BEGIN_MODULE_NAMESPACE(MSolver)
|
||||
class RBPrecCGPar: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(RBPrecCGPar,
|
||||
std::string, action,
|
||||
double , residual);
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(RBPrecCGPar ,
|
||||
std::string , action,
|
||||
unsigned int , maxIteration,
|
||||
double , residual);
|
||||
};
|
||||
|
||||
template <typename FImpl>
|
||||
@ -69,7 +70,8 @@ protected:
|
||||
virtual void execute(void);
|
||||
};
|
||||
|
||||
MODULE_REGISTER_NS(RBPrecCG, TRBPrecCG<FIMPL>, MSolver);
|
||||
MODULE_REGISTER_NS(RBPrecCG, TRBPrecCG<FIMPL>, MSolver);
|
||||
MODULE_REGISTER_NS(ZRBPrecCG, TRBPrecCG<ZFIMPL>, MSolver);
|
||||
|
||||
/******************************************************************************
|
||||
* TRBPrecCG template implementation *
|
||||
@ -117,14 +119,16 @@ void TRBPrecCG<FImpl>::setup(void)
|
||||
auto &mat = envGet(FMat, par().action);
|
||||
auto solver = [&mat, this](FermionField &sol, const FermionField &source)
|
||||
{
|
||||
ConjugateGradient<FermionField> cg(par().residual, 10000);
|
||||
SchurRedBlackDiagMooeeSolve<FermionField> schurSolver(cg);
|
||||
ConjugateGradient<FermionField> cg(par().residual,
|
||||
par().maxIteration);
|
||||
HADRONS_DEFAULT_SCHUR_SOLVE<FermionField> schurSolver(cg);
|
||||
|
||||
schurSolver(mat, source, sol);
|
||||
};
|
||||
envCreate(SolverFn, getName(), Ls, solver);
|
||||
}
|
||||
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
template <typename FImpl>
|
||||
void TRBPrecCG<FImpl>::execute(void)
|
||||
|
@ -8,6 +8,7 @@ Copyright (C) 2015-2018
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
Author: Lanny91 <andrew.lawson@gmail.com>
|
||||
Author: Vera Guelpers <vmg1n14@soton.ac.uk>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -38,9 +39,11 @@ BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/*
|
||||
|
||||
Sequential source
|
||||
Sequential source with insertion of conserved current.
|
||||
Additionally optional insertion of a photon field A_\mu(x).
|
||||
-----------------------------
|
||||
* src_x = q_x * theta(x_3 - tA) * theta(tB - x_3) * J_mu * exp(i x.mom)
|
||||
* src_x = sum_{mu=mu_min}^{mu_max}
|
||||
q_x * theta(x_3 - tA) * theta(tB - x_3) * J_mu * exp(i x.mom) (* A_\mu(x))
|
||||
|
||||
* options:
|
||||
- q: input propagator (string)
|
||||
@ -48,8 +51,10 @@ BEGIN_HADRONS_NAMESPACE
|
||||
- tA: begin timeslice (integer)
|
||||
- tB: end timesilce (integer)
|
||||
- curr_type: type of conserved current to insert (Current)
|
||||
- mu: Lorentz index of current to insert (integer)
|
||||
- mu_min: begin Lorentz Index (integer)
|
||||
- mu_max: end Lorentz Index (integer)
|
||||
- mom: momentum insertion, space-separated float sequence (e.g ".1 .2 1. 0.")
|
||||
- photon: optional photon field (string)
|
||||
|
||||
*/
|
||||
|
||||
@ -67,8 +72,10 @@ public:
|
||||
unsigned int, tA,
|
||||
unsigned int, tB,
|
||||
Current, curr_type,
|
||||
unsigned int, mu,
|
||||
std::string, mom);
|
||||
unsigned int, mu_min,
|
||||
unsigned int, mu_max,
|
||||
std::string, mom,
|
||||
std::string, photon);
|
||||
};
|
||||
|
||||
template <typename FImpl>
|
||||
@ -76,6 +83,8 @@ class TSeqConserved: public Module<SeqConservedPar>
|
||||
{
|
||||
public:
|
||||
FERM_TYPE_ALIASES(FImpl,);
|
||||
public:
|
||||
typedef PhotonR::GaugeField EmField;
|
||||
public:
|
||||
// constructor
|
||||
TSeqConserved(const std::string name);
|
||||
@ -89,10 +98,14 @@ protected:
|
||||
virtual void setup(void);
|
||||
// execution
|
||||
virtual void execute(void);
|
||||
private:
|
||||
bool SeqhasPhase_{false};
|
||||
std::string SeqmomphName_;
|
||||
};
|
||||
|
||||
MODULE_REGISTER_NS(SeqConserved, TSeqConserved<FIMPL>, MSource);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* TSeqConserved implementation *
|
||||
******************************************************************************/
|
||||
@ -100,6 +113,7 @@ MODULE_REGISTER_NS(SeqConserved, TSeqConserved<FIMPL>, MSource);
|
||||
template <typename FImpl>
|
||||
TSeqConserved<FImpl>::TSeqConserved(const std::string name)
|
||||
: Module<SeqConservedPar>(name)
|
||||
, SeqmomphName_ (name + "_Seqmomph")
|
||||
{}
|
||||
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
@ -107,7 +121,8 @@ template <typename FImpl>
|
||||
std::vector<std::string> TSeqConserved<FImpl>::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par().q, par().action};
|
||||
|
||||
if (!par().photon.empty()) in.push_back(par().photon);
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
@ -116,7 +131,7 @@ std::vector<std::string> TSeqConserved<FImpl>::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
return out;
|
||||
}
|
||||
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
@ -125,6 +140,10 @@ void TSeqConserved<FImpl>::setup(void)
|
||||
{
|
||||
auto Ls_ = env().getObjectLs(par().action);
|
||||
envCreateLat(PropagatorField, getName(), Ls_);
|
||||
envTmpLat(PropagatorField, "src_tmp");
|
||||
envCacheLat(LatticeComplex, SeqmomphName_);
|
||||
envTmpLat(LatticeComplex, "coor");
|
||||
envTmpLat(LatticeComplex, "latt_compl");
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
@ -134,27 +153,79 @@ void TSeqConserved<FImpl>::execute(void)
|
||||
if (par().tA == par().tB)
|
||||
{
|
||||
LOG(Message) << "Generating sequential source with conserved "
|
||||
<< par().curr_type << " current insertion (mu = "
|
||||
<< par().mu << ") at " << "t = " << par().tA << std::endl;
|
||||
<< par().curr_type << " current at "
|
||||
<< "t = " << par().tA << " summed over the indices "
|
||||
<< par().mu_min << " <= mu <= " << par().mu_max
|
||||
<< std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(Message) << "Generating sequential source with conserved "
|
||||
<< par().curr_type << " current insertion (mu = "
|
||||
<< par().mu << ") for " << par().tA << " <= t <= "
|
||||
<< par().tB << std::endl;
|
||||
<< par().curr_type << " current for "
|
||||
<< par().tA << " <= t <= "
|
||||
<< par().tB << " summed over the indices "
|
||||
<< par().mu_min << " <= mu <= " << par().mu_max
|
||||
<< std::endl;
|
||||
}
|
||||
auto &src = envGet(PropagatorField, getName());
|
||||
envGetTmp(PropagatorField, src_tmp);
|
||||
src_tmp = src;
|
||||
auto &q = envGet(PropagatorField, par().q);
|
||||
auto &mat = envGet(FMat, par().action);
|
||||
envGetTmp(LatticeComplex, latt_compl);
|
||||
|
||||
std::vector<Real> mom = strToVec<Real>(par().mom);
|
||||
mat.SeqConservedCurrent(q, src, par().curr_type, par().mu,
|
||||
mom, par().tA, par().tB);
|
||||
src = zero;
|
||||
|
||||
//exp(ipx)
|
||||
auto &mom_phase = envGet(LatticeComplex, SeqmomphName_);
|
||||
if (!SeqhasPhase_)
|
||||
{
|
||||
std::vector<Real> mom = strToVec<Real>(par().mom);
|
||||
mom_phase = zero;
|
||||
Complex i(0.0,1.0);
|
||||
envGetTmp(LatticeComplex, coor);
|
||||
for(unsigned int mu = 0; mu < env().getNd(); mu++)
|
||||
{
|
||||
LatticeCoordinate(coor, mu);
|
||||
mom_phase = mom_phase + (mom[mu]/env().getGrid()->_fdimensions[mu])*coor;
|
||||
}
|
||||
mom_phase = exp((Real)(2*M_PI)*i*mom_phase);
|
||||
SeqhasPhase_ = true;
|
||||
}
|
||||
LOG(Message) << "Inserting momentum " << strToVec<Real>(par().mom) << std::endl;
|
||||
|
||||
|
||||
|
||||
if (!par().photon.empty())
|
||||
{
|
||||
LOG(Message) << "Inserting the stochastic photon field " << par().photon << std::endl;
|
||||
}
|
||||
|
||||
for(unsigned int mu=par().mu_min;mu<=par().mu_max;mu++)
|
||||
{
|
||||
if (!par().photon.empty())
|
||||
{
|
||||
//Get the stochastic photon field, if required
|
||||
auto &stoch_photon = envGet(EmField, par().photon);
|
||||
latt_compl = PeekIndex<LorentzIndex>(stoch_photon, mu) * mom_phase;
|
||||
}
|
||||
else
|
||||
{
|
||||
latt_compl = mom_phase;
|
||||
}
|
||||
|
||||
mat.SeqConservedCurrent(q, src_tmp, par().curr_type, mu,
|
||||
par().tA, par().tB, latt_compl);
|
||||
src += src_tmp;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
END_MODULE_NAMESPACE
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_SeqConserved_hpp_
|
||||
#endif // Hadrons_MSource_SeqConserved_hpp_
|
||||
|
Reference in New Issue
Block a user