2019-04-26 07:24:56 +01:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
|
|
|
Source file: Hadrons/Modules/MDistil/PerambFromSolve.hpp
|
|
|
|
|
2019-04-26 07:39:05 +01:00
|
|
|
Copyright (C) 2019
|
2019-04-26 07:24:56 +01:00
|
|
|
|
|
|
|
Author: Felix Erben <ferben@ed.ac.uk>
|
|
|
|
Author: Michael Marshall <Michael.Marshall@ed.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
|
|
|
|
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 */
|
|
|
|
|
2019-03-07 17:36:53 +00:00
|
|
|
#ifndef Hadrons_MDistil_PerambFromSolve_hpp_
|
|
|
|
#define Hadrons_MDistil_PerambFromSolve_hpp_
|
|
|
|
|
2019-11-12 17:31:42 +00:00
|
|
|
#include <Hadrons/Modules/MDistil/Distil.hpp>
|
2019-11-02 14:58:32 +00:00
|
|
|
|
2019-03-07 17:36:53 +00:00
|
|
|
BEGIN_HADRONS_NAMESPACE
|
2019-11-02 14:58:32 +00:00
|
|
|
BEGIN_MODULE_NAMESPACE(MDistil)
|
2019-03-07 17:36:53 +00:00
|
|
|
|
|
|
|
/******************************************************************************
|
2019-11-08 11:15:51 +00:00
|
|
|
* PerambFromSolve
|
|
|
|
|
|
|
|
This module computes a perambulator from an already completed solve.
|
|
|
|
Optionally, the number of eigenvectors used in the perambulator and the
|
|
|
|
parameter LI can be chosen to be lower than the ones in the solve, allowing
|
2019-11-15 11:00:25 +00:00
|
|
|
for a study of the signal with different values of nvec.
|
|
|
|
|
|
|
|
LI_reduced : value of LI actually used in the computation
|
|
|
|
nvec_reduced: value of nvec actually used in the computation
|
|
|
|
LI : value of LI used to compute the 'solve'
|
|
|
|
nvec : value of nvec used to compute the 'solve'
|
|
|
|
|
2019-03-07 17:36:53 +00:00
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class PerambFromSolvePar: Serializable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(PerambFromSolvePar,
|
|
|
|
std::string, eigenPack,
|
|
|
|
std::string, PerambFileName,
|
|
|
|
std::string, solve,
|
2019-11-12 22:12:35 +00:00
|
|
|
std::string, nvec_reduced,
|
|
|
|
std::string, LI_reduced,
|
2019-11-12 21:53:09 +00:00
|
|
|
std::string, DistilParams);
|
2019-03-07 17:36:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename FImpl>
|
|
|
|
class TPerambFromSolve: public Module<PerambFromSolvePar>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FERM_TYPE_ALIASES(FImpl,);
|
|
|
|
// constructor
|
|
|
|
TPerambFromSolve(const std::string name);
|
|
|
|
// destructor
|
2019-11-12 23:18:37 +00:00
|
|
|
virtual ~TPerambFromSolve(void) {};
|
2019-03-07 17:36:53 +00:00
|
|
|
// 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);
|
2019-03-08 12:23:22 +00:00
|
|
|
protected:
|
2019-11-12 21:53:09 +00:00
|
|
|
std::unique_ptr<GridCartesian> grid3d; // Owned by me, so I must delete it
|
2019-03-07 17:36:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_REGISTER_TMP(PerambFromSolve, TPerambFromSolve<FIMPL>, MDistil);
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* TPerambFromSolve implementation *
|
|
|
|
******************************************************************************/
|
|
|
|
// constructor /////////////////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl>
|
2019-11-12 21:53:09 +00:00
|
|
|
TPerambFromSolve<FImpl>::TPerambFromSolve(const std::string name) : Module<PerambFromSolvePar>(name){}
|
2019-03-08 12:23:22 +00:00
|
|
|
|
2019-03-07 17:36:53 +00:00
|
|
|
// dependencies/products ///////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl>
|
|
|
|
std::vector<std::string> TPerambFromSolve<FImpl>::getInput(void)
|
|
|
|
{
|
2019-11-12 21:53:09 +00:00
|
|
|
return {par().solve, par().eigenPack, par().DistilParams};
|
2019-03-07 17:36:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename FImpl>
|
|
|
|
std::vector<std::string> TPerambFromSolve<FImpl>::getOutput(void)
|
|
|
|
{
|
2019-11-12 21:53:09 +00:00
|
|
|
return std::vector<std::string>{getName()};
|
2019-03-07 17:36:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// setup ///////////////////////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl>
|
|
|
|
void TPerambFromSolve<FImpl>::setup(void)
|
|
|
|
{
|
2019-11-12 21:53:09 +00:00
|
|
|
const DistilParameters & dp{envGet(MDistil::DistilParameters, par().DistilParams)};
|
|
|
|
const int Nt{env().getDim(Tdir)};
|
|
|
|
const bool full_tdil{ dp.TI == Nt };
|
|
|
|
const int Nt_inv{ full_tdil ? 1 : dp.TI };
|
|
|
|
grid3d.reset( MakeLowerDimGrid( env().getGrid() ) );
|
2019-11-15 11:00:25 +00:00
|
|
|
const int nvec_reduced{par().nvec_reduced};
|
|
|
|
const int LI_reduced{ par().LI_reduced};
|
2019-11-12 22:12:35 +00:00
|
|
|
envCreate(PerambTensor, getName(), 1, Nt,nvec_reduced,LI_reduced,dp.nnoise,Nt_inv,dp.SI);
|
2019-11-12 21:53:09 +00:00
|
|
|
envCreate(NoiseTensor, getName() + "_noise", 1, dp.nnoise, Nt, dp.nvec, Ns );
|
|
|
|
envTmp(LatticeColourVector, "result3d_nospin",1,LatticeColourVector(grid3d.get()));
|
|
|
|
envTmp(LatticeColourVector, "evec3d",1,LatticeColourVector(grid3d.get()));
|
2019-11-11 17:29:55 +00:00
|
|
|
envTmpLat(LatticeColourVector, "result4d_nospin");
|
2019-03-07 17:36:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// execution ///////////////////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl>
|
|
|
|
void TPerambFromSolve<FImpl>::execute(void)
|
|
|
|
{
|
2019-11-02 16:15:48 +00:00
|
|
|
GridCartesian * grid4d = env().getGrid();
|
|
|
|
const int Ntlocal{grid4d->LocalDimensions()[3]};
|
|
|
|
const int Ntfirst{grid4d->LocalStarts()[3]};
|
2019-11-12 21:53:09 +00:00
|
|
|
const DistilParameters &dp{envGet(DistilParameters, par().DistilParams)};
|
|
|
|
const int Nt{env().getDim(Tdir)};
|
|
|
|
const bool full_tdil{ dp.TI == Nt };
|
|
|
|
const int Nt_inv{ full_tdil ? 1 : dp.TI };
|
2019-11-12 22:12:35 +00:00
|
|
|
const int nvec_reduced{par().nvec_reduced.empty() ? dp.nvec : std::stoi(par().nvec_reduced)};
|
|
|
|
const int LI_reduced{ par().LI_reduced.empty() ? dp.LI : std::stoi(par().LI_reduced)};
|
2019-11-11 17:29:55 +00:00
|
|
|
auto &perambulator = envGet(PerambTensor, getName());
|
|
|
|
auto &solve = envGet(std::vector<FermionField>, par().solve);
|
|
|
|
auto &epack = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, par().eigenPack);
|
2019-11-02 16:15:48 +00:00
|
|
|
|
2019-11-11 17:29:55 +00:00
|
|
|
envGetTmp(LatticeColourVector, result4d_nospin);
|
|
|
|
envGetTmp(LatticeColourVector, result3d_nospin);
|
2019-11-02 16:15:48 +00:00
|
|
|
envGetTmp(LatticeColourVector, evec3d);
|
|
|
|
|
2019-11-12 21:53:09 +00:00
|
|
|
for (int inoise = 0; inoise < dp.nnoise; inoise++)
|
2019-11-11 17:29:55 +00:00
|
|
|
{
|
|
|
|
for (int dk = 0; dk < LI_reduced; dk++)
|
|
|
|
{
|
|
|
|
for (int dt = 0; dt < Nt_inv; dt++)
|
|
|
|
{
|
2019-11-12 21:53:09 +00:00
|
|
|
for (int ds = 0; ds < dp.SI; ds++)
|
2019-11-11 17:29:55 +00:00
|
|
|
{
|
|
|
|
for (int is = 0; is < Ns; is++)
|
|
|
|
{
|
2019-11-12 21:53:09 +00:00
|
|
|
result4d_nospin = peekSpin(solve[inoise+dp.nnoise*(dk+dp.LI*(dt+Nt_inv*ds))],is);
|
2019-11-11 17:29:55 +00:00
|
|
|
for (int t = Ntfirst; t < Ntfirst + Ntlocal; t++)
|
|
|
|
{
|
|
|
|
ExtractSliceLocal(result3d_nospin,result4d_nospin,0,t-Ntfirst,Tdir);
|
|
|
|
for (int ivec = 0; ivec < nvec_reduced; ivec++)
|
|
|
|
{
|
2019-11-02 16:15:48 +00:00
|
|
|
ExtractSliceLocal(evec3d,epack.evec[ivec],0,t-Ntfirst,Tdir);
|
2019-11-11 17:29:55 +00:00
|
|
|
pokeSpin(perambulator.tensor(t, ivec, dk, inoise,dt,ds),static_cast<Complex>(innerProduct(evec3d, result3d_nospin)),is);
|
2019-11-02 16:15:48 +00:00
|
|
|
LOG(Message) << "perambulator(t, ivec, dk, inoise,dt,ds)(is) = (" << t << "," << ivec << "," << dk << "," << inoise << "," << dt << "," << ds << ")(" << is << ") = " << perambulator.tensor(t, ivec, dk, inoise,dt,ds)()(is)() << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-07 17:36:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-02 16:15:48 +00:00
|
|
|
if(grid4d->IsBoss())
|
|
|
|
{
|
|
|
|
std::string sPerambName{par().PerambFileName};
|
|
|
|
sPerambName.append( "." );
|
|
|
|
sPerambName.append( std::to_string(vm().getTrajectory()));
|
|
|
|
perambulator.write(sPerambName.c_str());
|
|
|
|
}
|
2019-03-07 17:36:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
END_MODULE_NAMESPACE
|
|
|
|
END_HADRONS_NAMESPACE
|
|
|
|
#endif // Hadrons_MDistil_PerambFromSolve_hpp_
|