mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-13 04:37:05 +01:00
Merge branch 'develop' of https://github.com/paboyle/Grid into develop
This commit is contained in:
382
tests/hadrons/Test_distil.cc
Normal file
382
tests/hadrons/Test_distil.cc
Normal file
@ -0,0 +1,382 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: Tests/Hadrons/Test_hadrons_distil.cc
|
||||
|
||||
Copyright (C) 2015-2019
|
||||
|
||||
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 */
|
||||
|
||||
#include <typeinfo>
|
||||
#include <Hadrons/Application.hpp>
|
||||
#include <Hadrons/Modules.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
|
||||
// Very simple iterators for Eigen tensors
|
||||
// The only way I could get these iterators to work is to put the begin() and end() functions in the Eigen namespace
|
||||
// So if Eigen ever defines these, we'll have a conflict and have to change this
|
||||
namespace Eigen {
|
||||
template <typename ET>
|
||||
inline typename std::enable_if<EigenIO::is_tensor<ET>::value, typename EigenIO::Traits<ET>::scalar_type *>::type
|
||||
begin( ET & et ) { return reinterpret_cast<typename Grid::EigenIO::Traits<ET>::scalar_type *>(et.data()); }
|
||||
template <typename ET>
|
||||
inline typename std::enable_if<EigenIO::is_tensor<ET>::value, typename EigenIO::Traits<ET>::scalar_type *>::type
|
||||
end( ET & et ) { return begin(et) + et.size() * EigenIO::Traits<ET>::count; }
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Test creation of laplacian eigenvectors
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
void test_Global(Application &application)
|
||||
{
|
||||
// global parameters
|
||||
Application::GlobalPar globalPar;
|
||||
globalPar.trajCounter.start = 1100;
|
||||
globalPar.trajCounter.end = 1120;
|
||||
globalPar.trajCounter.step = 20;
|
||||
globalPar.runId = "test";
|
||||
globalPar.graphFile = "";
|
||||
globalPar.scheduleFile = "";
|
||||
globalPar.saveSchedule = "false";
|
||||
globalPar.parallelWriteMaxRetry = -1;
|
||||
application.setPar(globalPar);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Create a random gauge with the correct name
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
std::string test_Gauge(Application &application )
|
||||
{
|
||||
std::string sGaugeName{ "gauge" };
|
||||
application.createModule<MGauge::Random>( sGaugeName );
|
||||
return sGaugeName;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Test creation of laplacian eigenvectors
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
void test_LapEvec(Application &application)
|
||||
{
|
||||
const char szModuleName[] = "LapEvec";
|
||||
test_Gauge( application );
|
||||
MDistil::LapEvecPar p;
|
||||
p.gauge = "gauge";
|
||||
p.Stout.steps = 3;
|
||||
p.Stout.rho = 0.2;
|
||||
p.Cheby.PolyOrder = 11;
|
||||
p.Cheby.alpha = 0.55;
|
||||
p.Cheby.beta = 35.5;
|
||||
p.Lanczos.Nvec = 5;
|
||||
p.Lanczos.Nk = 6;
|
||||
p.Lanczos.Np = 2;
|
||||
p.Lanczos.MaxIt = 1000;
|
||||
p.Lanczos.resid = 1e-2;
|
||||
p.Lanczos.IRLLog = 0;
|
||||
application.createModule<MDistil::LapEvec>(szModuleName,p);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Test creation Solver
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
std::string SolverName( const char * pSuffix = nullptr ) {
|
||||
std::string sSolverName{ "CG" };
|
||||
if( pSuffix && pSuffix[0] ) {
|
||||
sSolverName.append( "_" );
|
||||
sSolverName.append( pSuffix );
|
||||
}
|
||||
return sSolverName;
|
||||
}
|
||||
|
||||
std::string test_Solver(Application &application, const char * pSuffix = nullptr )
|
||||
{
|
||||
std::string sActionName{ "DWF" };
|
||||
if( pSuffix && pSuffix[0] ) {
|
||||
sActionName.append( "_" );
|
||||
sActionName.append( pSuffix );
|
||||
}
|
||||
MAction::DWF::Par actionPar;
|
||||
actionPar.gauge = "gauge";
|
||||
actionPar.Ls = 16;
|
||||
actionPar.M5 = 1.8;
|
||||
actionPar.mass = 0.005;
|
||||
actionPar.boundary = "1 1 1 -1";
|
||||
actionPar.twist = "0. 0. 0. 0.";
|
||||
application.createModule<MAction::DWF>( sActionName, actionPar );
|
||||
MSolver::RBPrecCG::Par solverPar;
|
||||
solverPar.action = sActionName;
|
||||
solverPar.residual = 1.0e-2;
|
||||
solverPar.maxIteration = 10000;
|
||||
std::string sSolverName{ SolverName( pSuffix ) };
|
||||
application.createModule<MSolver::RBPrecCG>( sSolverName, solverPar );
|
||||
return sSolverName;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// DistilParameters
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
std::string test_DPar(Application &application) {
|
||||
MDistil::DistilParameters DPar;
|
||||
DPar.nvec = 5;
|
||||
DPar.nnoise = 1;
|
||||
DPar.tsrc = 0;
|
||||
DPar.LI = 5;
|
||||
DPar.TI = 8;
|
||||
DPar.SI = 4;
|
||||
std::string sDParName{"DPar_l"};
|
||||
application.createModule<MDistil::DistilPar>(sDParName,DPar);
|
||||
return sDParName;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Noises
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
std::string test_Noises(Application &application, const std::string &sNoiseBaseName ) {
|
||||
MDistil::NoisesPar NoisePar;
|
||||
NoisePar.DistilParams = "DPar_l";
|
||||
NoisePar.NoiseFileName = "noise";
|
||||
std::string sNoiseName{"noise"};
|
||||
application.createModule<MDistil::Noises>(sNoiseName,NoisePar);
|
||||
return sNoiseName;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Perambulators
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
std::string PerambulatorName( const char * pszSuffix = nullptr )
|
||||
{
|
||||
std::string sPerambulatorName{ "Peramb" };
|
||||
if( pszSuffix && pszSuffix[0] )
|
||||
sPerambulatorName.append( pszSuffix );
|
||||
return sPerambulatorName;
|
||||
}
|
||||
|
||||
void test_LoadPerambulators( Application &application, const char * pszSuffix = nullptr )
|
||||
{
|
||||
std::string sModuleName{ "Peramb_load" };
|
||||
MIO::LoadPerambulator::Par PerambPar;
|
||||
PerambPar.PerambFileName = "Peramb";
|
||||
PerambPar.DistilParams = "DPar_l";
|
||||
test_Noises(application, sModuleName); // I want these written after solver stuff
|
||||
application.createModule<MIO::LoadPerambulator>( sModuleName, PerambPar );
|
||||
}
|
||||
|
||||
void test_Perambulators( Application &application, const char * pszSuffix = nullptr )
|
||||
{
|
||||
std::string sModuleName{ PerambulatorName( pszSuffix ) };
|
||||
// Perambulator parameters
|
||||
MDistil::Perambulator::Par PerambPar;
|
||||
PerambPar.lapevec = "LapEvec";
|
||||
PerambPar.PerambFileName = sModuleName;
|
||||
PerambPar.solver = test_Solver( application, pszSuffix );
|
||||
PerambPar.DistilParams = "DPar_l";
|
||||
PerambPar.noise = "noise";
|
||||
test_Noises(application, sModuleName); // I want these written after solver stuff
|
||||
application.createModule<MDistil::Perambulator>( sModuleName, PerambPar );
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// DistilVectors
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
void test_DistilVectors(Application &application, const char * pszSuffix = nullptr, const char * pszNvec = nullptr )
|
||||
{
|
||||
std::string sModuleName{"DistilVecs"};
|
||||
if( pszSuffix )
|
||||
sModuleName.append( pszSuffix );
|
||||
std::string sPerambName{"Peramb"};
|
||||
if( pszSuffix )
|
||||
sPerambName.append( pszSuffix );
|
||||
MDistil::DistilVectors::Par DistilVecPar;
|
||||
DistilVecPar.noise = "noise";
|
||||
DistilVecPar.rho = "rho";
|
||||
DistilVecPar.phi = "phi";
|
||||
DistilVecPar.perambulator = sPerambName;
|
||||
DistilVecPar.lapevec = "LapEvec";
|
||||
DistilVecPar.DistilParams = "DPar_l";
|
||||
application.createModule<MDistil::DistilVectors>(sModuleName,DistilVecPar);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// MesonSink
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
void test_MesonSink(Application &application)
|
||||
{
|
||||
// DistilVectors parameters
|
||||
MContraction::A2AMesonField::Par A2AMesonFieldPar;
|
||||
//A2AMesonFieldPar.left="Peramb_unsmeared_sink";
|
||||
A2AMesonFieldPar.left="g5phi";
|
||||
A2AMesonFieldPar.right="Peramb_unsmeared_sink";
|
||||
A2AMesonFieldPar.output="DistilFields";
|
||||
A2AMesonFieldPar.gammas="Identity";
|
||||
A2AMesonFieldPar.mom={"0 0 0"};
|
||||
A2AMesonFieldPar.cacheBlock=2;
|
||||
A2AMesonFieldPar.block=4;
|
||||
application.createModule<MContraction::A2AMesonField>("DistilMesonSink",A2AMesonFieldPar);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////
|
||||
// MesonFields
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
void test_MesonField(Application &application, const char * pszFileSuffix,
|
||||
const char * pszObjectLeft = nullptr, const char * pszObjectRight = nullptr )
|
||||
{
|
||||
// DistilVectors parameters
|
||||
if( pszObjectLeft == nullptr )
|
||||
pszObjectLeft = pszFileSuffix;
|
||||
if( pszObjectRight == nullptr )
|
||||
pszObjectRight = pszObjectLeft;
|
||||
MContraction::A2AMesonField::Par A2AMesonFieldPar;
|
||||
A2AMesonFieldPar.left="";
|
||||
A2AMesonFieldPar.right=A2AMesonFieldPar.left;
|
||||
A2AMesonFieldPar.left.append( pszObjectLeft );
|
||||
A2AMesonFieldPar.right.append( pszObjectRight );
|
||||
A2AMesonFieldPar.output="MesonSinks";
|
||||
A2AMesonFieldPar.output.append( pszFileSuffix );
|
||||
A2AMesonFieldPar.gammas="Identity";
|
||||
A2AMesonFieldPar.mom={"0 0 0"};
|
||||
A2AMesonFieldPar.cacheBlock=2;
|
||||
A2AMesonFieldPar.block=4;
|
||||
std::string sObjectName{"DistilMesonField"};
|
||||
sObjectName.append( pszFileSuffix );
|
||||
application.createModule<MContraction::A2AMesonField>(sObjectName, A2AMesonFieldPar);
|
||||
}
|
||||
|
||||
bool bNumber( int &ri, const char * & pstr, bool bGobbleWhiteSpace = true )
|
||||
{
|
||||
if( bGobbleWhiteSpace )
|
||||
while( std::isspace(static_cast<unsigned char>(*pstr)) )
|
||||
pstr++;
|
||||
const char * p = pstr;
|
||||
bool bMinus = false;
|
||||
char c = * p++;
|
||||
if( c == '+' )
|
||||
c = * p++;
|
||||
else if( c == '-' ) {
|
||||
bMinus = true;
|
||||
c = * p++;
|
||||
}
|
||||
int n = c - '0';
|
||||
if( n < 0 || n > 9 )
|
||||
return false;
|
||||
while( * p >= '0' && * p <= '9' ) {
|
||||
n = n * 10 + ( * p ) - '0';
|
||||
p++;
|
||||
}
|
||||
if( bMinus )
|
||||
n *= -1;
|
||||
ri = n;
|
||||
pstr = p;
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Decode command-line parameters. 1st one is which test to run
|
||||
int iTestNum = -1;
|
||||
|
||||
for(int i = 1 ; i < argc ; i++ ) {
|
||||
std::cout << "argv[" << i << "]=\"" << argv[i] << "\"" << std::endl;
|
||||
const char * p = argv[i];
|
||||
if( * p == '/' || * p == '-' ) {
|
||||
p++;
|
||||
char c = * p++;
|
||||
switch(toupper(c)) {
|
||||
case 'T':
|
||||
if( bNumber( iTestNum, p ) ) {
|
||||
std::cout << "Test " << iTestNum << " requested";
|
||||
if( * p )
|
||||
std::cout << " (ignoring trailer \"" << p << "\")";
|
||||
std::cout << std::endl;
|
||||
}
|
||||
else
|
||||
std::cout << "Invalid test \"" << &argv[i][2] << "\"" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Ignoring switch \"" << &argv[i][1] << "\"" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// initialization //////////////////////////////////////////////////////////
|
||||
Grid_init(&argc, &argv);
|
||||
HadronsLogError.Active(GridLogError.isActive());
|
||||
HadronsLogWarning.Active(GridLogWarning.isActive());
|
||||
HadronsLogMessage.Active(GridLogMessage.isActive());
|
||||
HadronsLogIterative.Active(GridLogIterative.isActive());
|
||||
HadronsLogDebug.Active(GridLogDebug.isActive());
|
||||
LOG(Message) << "Grid initialized" << std::endl;
|
||||
|
||||
// run setup ///////////////////////////////////////////////////////////////
|
||||
Application application;
|
||||
|
||||
// For now perform free propagator test - replace this with distillation test(s)
|
||||
LOG(Message) << "====== Creating xml for test " << iTestNum << " ======" << std::endl;
|
||||
|
||||
switch(iTestNum) {
|
||||
default: // 0
|
||||
LOG(Message) << "Computing Meson 2pt-function" << std::endl;
|
||||
test_Global( application );
|
||||
test_LapEvec( application );
|
||||
test_DPar( application );
|
||||
test_Perambulators( application );
|
||||
test_DistilVectors( application );
|
||||
test_MesonField( application, "Phi", "phi" );
|
||||
test_MesonField( application, "Rho", "rho" );
|
||||
break;
|
||||
case 1:
|
||||
LOG(Message) << "Computing Meson 2pt-function by loading perambulators" << std::endl;
|
||||
test_Global( application );
|
||||
test_LapEvec( application );
|
||||
test_DPar( application );
|
||||
test_LoadPerambulators( application );
|
||||
test_DistilVectors( application, "_load" );
|
||||
test_MesonField( application, "Phi", "phi" );
|
||||
test_MesonField( application, "Rho", "rho" );
|
||||
break;
|
||||
}
|
||||
// execution
|
||||
static const char XmlFileName[] = "test_distil.xml";
|
||||
application.saveParameterFile( XmlFileName );
|
||||
|
||||
const Grid::Coordinate &lat{GridDefaultLatt()};
|
||||
if( lat.size() == 4 && lat[0] == 4 && lat[1] == 4 && lat[2] == 4 && lat[3] == 8 )
|
||||
application.run();
|
||||
else
|
||||
LOG(Warning) << "The parameters in " << XmlFileName << " are designed to run on a laptop usid --grid 4.4.4.8" << std::endl;
|
||||
|
||||
// epilogue
|
||||
LOG(Message) << "Grid is finalizing now" << std::endl;
|
||||
Grid_finalize();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
154
tests/hadrons/Test_sigma_to_nucleon.cc
Normal file
154
tests/hadrons/Test_sigma_to_nucleon.cc
Normal file
@ -0,0 +1,154 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: Tests/Hadrons/Test_hadrons_spectrum.cc
|
||||
|
||||
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 */
|
||||
|
||||
#include <Hadrons/Application.hpp>
|
||||
#include <Hadrons/Modules.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Hadrons;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// initialization //////////////////////////////////////////////////////////
|
||||
Grid_init(&argc, &argv);
|
||||
HadronsLogError.Active(GridLogError.isActive());
|
||||
HadronsLogWarning.Active(GridLogWarning.isActive());
|
||||
HadronsLogMessage.Active(GridLogMessage.isActive());
|
||||
HadronsLogIterative.Active(GridLogIterative.isActive());
|
||||
HadronsLogDebug.Active(GridLogDebug.isActive());
|
||||
LOG(Message) << "Grid initialized" << std::endl;
|
||||
|
||||
// run setup ///////////////////////////////////////////////////////////////
|
||||
Application application;
|
||||
std::vector<std::string> flavour = {"l", "s", "c"};
|
||||
std::vector<double> mass = {.01, .04, .2 };
|
||||
|
||||
// global parameters
|
||||
Application::GlobalPar globalPar;
|
||||
globalPar.trajCounter.start = 1500;
|
||||
globalPar.trajCounter.end = 1520;
|
||||
globalPar.trajCounter.step = 20;
|
||||
globalPar.runId = "test";
|
||||
application.setPar(globalPar);
|
||||
// gauge field
|
||||
application.createModule<MGauge::Unit>("gauge");
|
||||
// sources
|
||||
MSource::Point::Par ptPar;
|
||||
ptPar.position = "0 0 0 0";
|
||||
application.createModule<MSource::Point>("pt_0", ptPar);
|
||||
ptPar.position = "0 0 0 4";
|
||||
application.createModule<MSource::Point>("pt_4", ptPar);
|
||||
// sink
|
||||
MSink::Point::Par sinkPar;
|
||||
sinkPar.mom = "0 0 0";
|
||||
application.createModule<MSink::ScalarPoint>("sink", sinkPar);
|
||||
application.createModule<MSink::Point>("sink_spec", sinkPar);
|
||||
|
||||
// set fermion boundary conditions to be periodic space, antiperiodic time.
|
||||
std::string boundary = "1 1 1 -1";
|
||||
std::string twist = "0. 0. 0. 0.";
|
||||
|
||||
for (unsigned int i = 0; i < flavour.size(); ++i)
|
||||
{
|
||||
// actions
|
||||
MAction::DWF::Par actionPar;
|
||||
actionPar.gauge = "gauge";
|
||||
actionPar.Ls = 12;
|
||||
actionPar.M5 = 1.8;
|
||||
actionPar.mass = mass[i];
|
||||
actionPar.boundary = boundary;
|
||||
actionPar.twist = twist;
|
||||
application.createModule<MAction::DWF>("DWF_" + flavour[i], actionPar);
|
||||
|
||||
// solvers
|
||||
MSolver::RBPrecCG::Par solverPar;
|
||||
solverPar.action = "DWF_" + flavour[i];
|
||||
solverPar.residual = 1.0e-8;
|
||||
solverPar.maxIteration = 10000;
|
||||
application.createModule<MSolver::RBPrecCG>("CG_" + flavour[i],
|
||||
solverPar);
|
||||
|
||||
}
|
||||
|
||||
// propagators
|
||||
MFermion::GaugeProp::Par quarkPar;
|
||||
quarkPar.solver = "CG_l";
|
||||
quarkPar.source = "pt_0";
|
||||
application.createModule<MFermion::GaugeProp>("Qpt_l_0", quarkPar);
|
||||
quarkPar.source = "pt_4";
|
||||
application.createModule<MFermion::GaugeProp>("Qpt_l_4", quarkPar);
|
||||
quarkPar.solver = "CG_s";
|
||||
quarkPar.source = "pt_0";
|
||||
application.createModule<MFermion::GaugeProp>("Qpt_s_0", quarkPar);
|
||||
//This should be a loop - how do I make this?
|
||||
quarkPar.solver = "CG_c";
|
||||
quarkPar.source = "pt_0";
|
||||
application.createModule<MFermion::GaugeProp>("Qpt_c_loop", quarkPar);
|
||||
quarkPar.solver = "CG_l";
|
||||
quarkPar.source = "pt_0";
|
||||
application.createModule<MFermion::GaugeProp>("Qpt_l_loop", quarkPar);
|
||||
|
||||
MSink::Smear::Par smearPar;
|
||||
smearPar.q="Qpt_l_0";
|
||||
smearPar.sink = "sink_spec";
|
||||
application.createModule<MSink::Smear>("Qpt_u_spec",smearPar);
|
||||
|
||||
|
||||
MContraction::SigmaToNucleonEye::Par EyePar;
|
||||
EyePar.output = "SigmaToNucleon/Eye_u";
|
||||
EyePar.qqLoop = "Qpt_l_loop";
|
||||
EyePar.quSpec = "Qpt_u_spec";
|
||||
EyePar.qdTf = "Qpt_l_4";
|
||||
EyePar.qsTi = "Qpt_s_0";
|
||||
EyePar.tf = 4;
|
||||
EyePar.sink = "sink";
|
||||
application.createModule<MContraction::SigmaToNucleonEye>("SigmaToNucleonEye_u", EyePar);
|
||||
EyePar.output = "SigmaToNucleon/Eye_c";
|
||||
EyePar.qqLoop = "Qpt_c_loop";
|
||||
application.createModule<MContraction::SigmaToNucleonEye>("SigmaToNucleonEye_c", EyePar);
|
||||
MContraction::SigmaToNucleonNonEye::Par NonEyePar;
|
||||
NonEyePar.output = "SigmaToNucleon/NonEye";
|
||||
NonEyePar.quTi = "Qpt_l_0";
|
||||
NonEyePar.quTf = "Qpt_l_4";
|
||||
NonEyePar.quSpec = "Qpt_u_spec";
|
||||
NonEyePar.qdTf = "Qpt_l_4";
|
||||
NonEyePar.qsTi = "Qpt_s_0";
|
||||
NonEyePar.tf = 4;
|
||||
NonEyePar.sink = "sink";
|
||||
application.createModule<MContraction::SigmaToNucleonNonEye>("SigmaToNucleonNonEye", NonEyePar);
|
||||
|
||||
// execution
|
||||
application.saveParameterFile("stn.xml");
|
||||
application.run();
|
||||
|
||||
// epilogue
|
||||
LOG(Message) << "Grid is finalizing now" << std::endl;
|
||||
Grid_finalize();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/*************************************************************************************
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
@ -111,11 +111,7 @@ public:
|
||||
}
|
||||
|
||||
void operator()(const FineField &in, FineField & out) {
|
||||
if ( params.domaindecompose ) {
|
||||
operatorSAP(in,out);
|
||||
} else {
|
||||
operatorCheby(in,out);
|
||||
}
|
||||
operatorCheby(in,out);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@ -232,66 +228,6 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
void SAP (const FineField & src,FineField & psi){
|
||||
|
||||
Lattice<iScalar<vInteger> > coor(src.Grid());
|
||||
Lattice<iScalar<vInteger> > subset(src.Grid());
|
||||
|
||||
FineField r(src.Grid());
|
||||
FineField zz(src.Grid()); zz=Zero();
|
||||
FineField vec1(src.Grid());
|
||||
FineField vec2(src.Grid());
|
||||
|
||||
const RealD block=params.domainsize;
|
||||
|
||||
subset=Zero();
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
LatticeCoordinate(coor,mu+1);
|
||||
coor = div(coor,block);
|
||||
subset = subset+coor;
|
||||
}
|
||||
subset = mod(subset,(Integer)2);
|
||||
|
||||
ShiftedMdagMLinearOperator<Matrix,FineField> fMdagMOp(_SmootherMatrix,0.0);
|
||||
Chebyshev<FineField> Cheby (params.lo,params.hi,params.order,InverseApproximation);
|
||||
|
||||
RealD resid;
|
||||
for(int i=0;i<params.steps;i++){
|
||||
|
||||
// Even domain residual
|
||||
_FineOperator.Op(psi,vec1);// this is the G5 herm bit
|
||||
r= src - vec1 ;
|
||||
resid = norm2(r) /norm2(src);
|
||||
std::cout << "SAP "<<i<<" resid "<<resid<<std::endl;
|
||||
|
||||
// Even domain solve
|
||||
r= where(subset==(Integer)0,r,zz);
|
||||
_SmootherOperator.AdjOp(r,vec1);
|
||||
Cheby(fMdagMOp,vec1,vec2); // solves MdagM = g5 M g5M
|
||||
psi = psi + vec2;
|
||||
|
||||
// Odd domain residual
|
||||
_FineOperator.Op(psi,vec1);// this is the G5 herm bit
|
||||
r= src - vec1 ;
|
||||
r= where(subset==(Integer)1,r,zz);
|
||||
|
||||
resid = norm2(r) /norm2(src);
|
||||
std::cout << "SAP "<<i<<" resid "<<resid<<std::endl;
|
||||
|
||||
// Odd domain solve
|
||||
_SmootherOperator.AdjOp(r,vec1);
|
||||
Cheby(fMdagMOp,vec1,vec2); // solves MdagM = g5 M g5M
|
||||
psi = psi + vec2;
|
||||
|
||||
_FineOperator.Op(psi,vec1);// this is the G5 herm bit
|
||||
r= src - vec1 ;
|
||||
resid = norm2(r) /norm2(src);
|
||||
std::cout << "SAP "<<i<<" resid "<<resid<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void SmootherTest (const FineField & in){
|
||||
|
||||
FineField vec1(in.Grid());
|
||||
@ -308,6 +244,8 @@ public:
|
||||
for(int ilo=0;ilo<3;ilo++){
|
||||
for(int ord=5;ord<50;ord*=2){
|
||||
|
||||
std::cout << " lo "<<lo[ilo]<<" order "<<ord<<std::endl;
|
||||
|
||||
_SmootherOperator.AdjOp(in,vec1);
|
||||
|
||||
Chebyshev<FineField> Cheby (lo[ilo],70.0,ord,InverseApproximation);
|
||||
@ -329,7 +267,6 @@ public:
|
||||
CoarseVector Csol(_CoarseOperator.Grid()); Csol=Zero();
|
||||
|
||||
ConjugateGradient<CoarseVector> CG(3.0e-3,100000);
|
||||
// ConjugateGradient<FineField> fCG(3.0e-2,1000);
|
||||
|
||||
HermitianLinearOperator<CoarseOperator,CoarseVector> HermOp(_CoarseOperator);
|
||||
MdagMLinearOperator<CoarseOperator,CoarseVector> MdagMOp(_CoarseOperator);
|
||||
@ -339,14 +276,11 @@ public:
|
||||
FineField vec1(in.Grid());
|
||||
FineField vec2(in.Grid());
|
||||
|
||||
// Chebyshev<FineField> Cheby (0.5,70.0,30,InverseApproximation);
|
||||
// Chebyshev<FineField> ChebyAccu(0.5,70.0,30,InverseApproximation);
|
||||
Chebyshev<FineField> Cheby (params.lo,params.hi,params.order,InverseApproximation);
|
||||
Chebyshev<FineField> ChebyAccu(params.lo,params.hi,params.order,InverseApproximation);
|
||||
// Cheby.JacksonSmooth();
|
||||
// ChebyAccu.JacksonSmooth();
|
||||
|
||||
// _Aggregates.ProjectToSubspace (Csrc,in);
|
||||
_Aggregates.ProjectToSubspace (Csrc,in);
|
||||
|
||||
// _Aggregates.PromoteFromSubspace(Csrc,out);
|
||||
// std::cout<<GridLogMessage<<"Completeness: "<<std::sqrt(norm2(out)/norm2(in))<<std::endl;
|
||||
|
||||
@ -366,8 +300,6 @@ public:
|
||||
_SmootherOperator.AdjOp(in,vec1);// this is the G5 herm bit
|
||||
ChebyAccu(fMdagMOp,vec1,out); // solves MdagM = g5 M g5M
|
||||
|
||||
std::cout<<GridLogMessage << "Smoother norm "<<norm2(out)<<std::endl;
|
||||
|
||||
// Update with residual for out
|
||||
_FineOperator.Op(out,vec1);// this is the G5 herm bit
|
||||
vec1 = in - vec1; // tmp = in - A Min
|
||||
@ -377,10 +309,11 @@ public:
|
||||
std::cout<<GridLogMessage << "Smoother resid "<<std::sqrt(r/Ni)<< " " << r << " " << Ni <<std::endl;
|
||||
|
||||
_Aggregates.ProjectToSubspace (Csrc,vec1);
|
||||
HermOp.AdjOp(Csrc,Ctmp);// Normal equations
|
||||
|
||||
HermOp.AdjOp(Csrc,Ctmp);// Normal equations // This appears to be zero.
|
||||
CG(MdagMOp,Ctmp,Csol);
|
||||
_Aggregates.PromoteFromSubspace(Csol,vec1); // Ass^{-1} [in - A Min]_s
|
||||
// Q = Q[in - A Min]
|
||||
// Q = Q[in - A Min]
|
||||
out = out+vec1;
|
||||
|
||||
// Three preconditioner smoothing -- hermitian if C3 = C1
|
||||
@ -402,69 +335,6 @@ public:
|
||||
|
||||
}
|
||||
|
||||
void operatorSAP(const FineField &in, FineField & out) {
|
||||
|
||||
CoarseVector Csrc(_CoarseOperator.Grid());
|
||||
CoarseVector Ctmp(_CoarseOperator.Grid());
|
||||
CoarseVector Csol(_CoarseOperator.Grid()); Csol=Zero();
|
||||
|
||||
ConjugateGradient<CoarseVector> CG(1.0e-3,100000);
|
||||
|
||||
HermitianLinearOperator<CoarseOperator,CoarseVector> HermOp(_CoarseOperator);
|
||||
MdagMLinearOperator<CoarseOperator,CoarseVector> MdagMOp(_CoarseOperator);
|
||||
|
||||
FineField vec1(in.Grid());
|
||||
FineField vec2(in.Grid());
|
||||
|
||||
_Aggregates.ProjectToSubspace (Csrc,in);
|
||||
_Aggregates.PromoteFromSubspace(Csrc,out);
|
||||
std::cout<<GridLogMessage<<"Completeness: "<<std::sqrt(norm2(out)/norm2(in))<<std::endl;
|
||||
|
||||
|
||||
// To make a working smoother for indefinite operator
|
||||
// must multiply by "Mdag" (ouch loses all low mode content)
|
||||
// and apply to poly approx of (mdagm)^-1.
|
||||
// so that we end up with an odd polynomial.
|
||||
SAP(in,out);
|
||||
|
||||
// Update with residual for out
|
||||
_FineOperator.Op(out,vec1);// this is the G5 herm bit
|
||||
vec1 = in - vec1; // tmp = in - A Min
|
||||
|
||||
RealD r = norm2(vec1);
|
||||
RealD Ni = norm2(in);
|
||||
std::cout<<GridLogMessage << "SAP resid "<<std::sqrt(r/Ni)<< " " << r << " " << Ni <<std::endl;
|
||||
|
||||
_Aggregates.ProjectToSubspace (Csrc,vec1);
|
||||
HermOp.AdjOp(Csrc,Ctmp);// Normal equations
|
||||
CG(MdagMOp,Ctmp,Csol);
|
||||
_Aggregates.PromoteFromSubspace(Csol,vec1); // Ass^{-1} [in - A Min]_s
|
||||
// Q = Q[in - A Min]
|
||||
out = out+vec1;
|
||||
|
||||
// Three preconditioner smoothing -- hermitian if C3 = C1
|
||||
// Recompute error
|
||||
_FineOperator.Op(out,vec1);// this is the G5 herm bit
|
||||
vec1 = in - vec1; // tmp = in - A Min
|
||||
r=norm2(vec1);
|
||||
|
||||
std::cout<<GridLogMessage << "Coarse resid "<<std::sqrt(r/Ni)<<std::endl;
|
||||
|
||||
// Reapply smoother
|
||||
SAP(vec1,vec2);
|
||||
out =out+vec2;
|
||||
|
||||
|
||||
// Update with residual for out
|
||||
_FineOperator.Op(out,vec1);// this is the G5 herm bit
|
||||
vec1 = in - vec1; // tmp = in - A Min
|
||||
|
||||
r = norm2(vec1);
|
||||
Ni = norm2(in);
|
||||
std::cout<<GridLogMessage << "SAP resid(post) "<<std::sqrt(r/Ni)<< " " << r << " " << Ni <<std::endl;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
@ -559,8 +429,9 @@ int main (int argc, char ** argv)
|
||||
assert ( (nbasis & 0x1)==0);
|
||||
int nb=nbasis/2;
|
||||
std::cout<<GridLogMessage << " nbasis/2 = "<<nb<<std::endl;
|
||||
Aggregates.CreateSubspace(RNG5,HermDefOp,nb);
|
||||
// Aggregates.CreateSubspace(RNG5,HermDefOp,nb);
|
||||
// Aggregates.CreateSubspaceLanczos(RNG5,HermDefOp,nb);
|
||||
Aggregates.CreateSubspaceChebyshev(RNG5,HermDefOp,nb);
|
||||
for(int n=0;n<nb;n++){
|
||||
G5R5(Aggregates.subspace[n+nb],Aggregates.subspace[n]);
|
||||
std::cout<<GridLogMessage<<n<<" subspace "<<norm2(Aggregates.subspace[n+nb])<<" "<<norm2(Aggregates.subspace[n]) <<std::endl;
|
||||
@ -580,7 +451,7 @@ int main (int argc, char ** argv)
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
Gamma5R5HermitianLinearOperator<DomainWallFermionR,LatticeFermion> HermIndefOp(Ddwf);
|
||||
Gamma5R5HermitianLinearOperator<DomainWallFermionR,LatticeFermion> HermIndefOpDD(DdwfDD);
|
||||
CoarsenedMatrix<vSpinColourVector,vTComplex,nbasis> LDOp(*Coarse5d);
|
||||
CoarsenedMatrix<vSpinColourVector,vTComplex,nbasis> LDOp(*Coarse5d,1); // Hermitian matrix
|
||||
LDOp.CoarsenOperator(FGrid,HermIndefOp,Aggregates);
|
||||
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
@ -596,14 +467,14 @@ int main (int argc, char ** argv)
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
MdagMLinearOperator<CoarseOperator,CoarseVector> PosdefLdop(LDOp);
|
||||
ConjugateGradient<CoarseVector> CG(1.0e-6,100000);
|
||||
// CG(PosdefLdop,c_src,c_res);
|
||||
CG(PosdefLdop,c_src,c_res);
|
||||
|
||||
// std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
// std::cout<<GridLogMessage << "Solving indef-MCR on coarse space "<< std::endl;
|
||||
// std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
// HermitianLinearOperator<CoarseOperator,CoarseVector> HermIndefLdop(LDOp);
|
||||
// ConjugateResidual<CoarseVector> MCR(1.0e-6,100000);
|
||||
//MCR(HermIndefLdop,c_src,c_res);
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
std::cout<<GridLogMessage << "Solving indef-MCR on coarse space "<< std::endl;
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
// HermitianLinearOperator<CoarseOperator,CoarseVector> HermIndefLdop(LDOp);
|
||||
// ConjugateResidual<CoarseVector> MCR(1.0e-6,100000);
|
||||
// MCR(HermIndefLdop,c_src,c_res);
|
||||
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
std::cout<<GridLogMessage << "Building deflation preconditioner "<< std::endl;
|
||||
@ -613,38 +484,48 @@ int main (int argc, char ** argv)
|
||||
HermIndefOp,Ddwf,
|
||||
HermIndefOp,Ddwf);
|
||||
|
||||
MultiGridPreconditioner <vSpinColourVector,vTComplex,nbasis,DomainWallFermionR> PreconDD(Aggregates, LDOp,
|
||||
HermIndefOp,Ddwf,
|
||||
HermIndefOpDD,DdwfDD);
|
||||
TrivialPrecon<LatticeFermion> simple;
|
||||
// MultiGridPreconditioner <vSpinColourVector,vTComplex,nbasis,DomainWallFermionR> PreconDD(Aggregates, LDOp,
|
||||
// HermIndefOp,Ddwf,
|
||||
// HermIndefOpDD,DdwfDD);
|
||||
// TrivialPrecon<LatticeFermion> simple;
|
||||
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
std::cout<<GridLogMessage << "Testing smoother efficacy"<< std::endl;
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
// Precon.SmootherTest(src);
|
||||
Precon.SmootherTest(src);
|
||||
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
std::cout<<GridLogMessage << "Testing DD smoother efficacy"<< std::endl;
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
// std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
// std::cout<<GridLogMessage << "Testing DD smoother efficacy"<< std::endl;
|
||||
// std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
// PreconDD.SmootherTest(src);
|
||||
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
std::cout<<GridLogMessage << "Testing SAP smoother efficacy"<< std::endl;
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
// std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
// std::cout<<GridLogMessage << "Testing SAP smoother efficacy"<< std::endl;
|
||||
// std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
// PreconDD.SAP(src,result);
|
||||
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
std::cout<<GridLogMessage << "Unprec CG "<< std::endl;
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
// std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
// std::cout<<GridLogMessage << "Unprec CG "<< std::endl;
|
||||
// std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
|
||||
// TrivialPrecon<LatticeFermion> simple;
|
||||
// ConjugateGradient<LatticeFermion> fCG(1.0e-8,100000);
|
||||
// fCG(HermDefOp,src,result);
|
||||
// exit(0);
|
||||
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
std::cout<<GridLogMessage << "Testing GCR on indef matrix "<< std::endl;
|
||||
std::cout<<GridLogMessage << "Red Black Prec CG "<< std::endl;
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
LatticeFermion src_o(FrbGrid);
|
||||
LatticeFermion result_o(FrbGrid);
|
||||
pickCheckerboard(Odd,src_o,src);
|
||||
result_o=Zero();
|
||||
SchurDiagMooeeOperator<DomainWallFermionR,LatticeFermion> HermOpEO(Ddwf);
|
||||
ConjugateGradient<LatticeFermion> pCG(1.0e-8,10000);
|
||||
// pCG(HermOpEO,src_o,result_o);
|
||||
|
||||
// std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
// std::cout<<GridLogMessage << "Testing GCR on indef matrix "<< std::endl;
|
||||
// std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
// PrecGeneralisedConjugateResidual<LatticeFermion> UPGCR(1.0e-8,100000,simple,8,128);
|
||||
// UPGCR(HermIndefOp,src,result);
|
||||
|
||||
@ -656,9 +537,9 @@ int main (int argc, char ** argv)
|
||||
Precon.PowerMethod(src);
|
||||
|
||||
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
std::cout<<GridLogMessage << "Building a two level DDPGCR "<< std::endl;
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
// std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
// std::cout<<GridLogMessage << "Building a two level DDPGCR "<< std::endl;
|
||||
// std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
// PrecGeneralisedConjugateResidual<LatticeFermion> PGCRDD(1.0e-8,100000,PreconDD,8,128);
|
||||
// result=Zero();
|
||||
// std::cout<<GridLogMessage<<"checking norm src "<<norm2(src)<<std::endl;
|
||||
@ -672,20 +553,6 @@ int main (int argc, char ** argv)
|
||||
result=Zero();
|
||||
PGCR(HermIndefOp,src,result);
|
||||
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
std::cout<<GridLogMessage << "Red Black Prec CG "<< std::endl;
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
SchurDiagMooeeOperator<DomainWallFermionR,LatticeFermion> HermOpEO(Ddwf);
|
||||
ConjugateGradient<LatticeFermion> pCG(1.0e-8,10000);
|
||||
|
||||
LatticeFermion src_o(FrbGrid);
|
||||
LatticeFermion result_o(FrbGrid);
|
||||
pickCheckerboard(Odd,src_o,src);
|
||||
result_o=Zero();
|
||||
|
||||
pCG(HermOpEO,src_o,result_o);
|
||||
|
||||
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
std::cout<<GridLogMessage << "Done "<< std::endl;
|
||||
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
||||
|
84
tests/solver/Test_dwf_qmr_unprec.cc
Normal file
84
tests/solver/Test_dwf_qmr_unprec.cc
Normal file
@ -0,0 +1,84 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_dwf_cr_unprec.cc
|
||||
|
||||
Copyright (C) 2019
|
||||
|
||||
Author: Peter Boyle <pboyle@bnl.gov>
|
||||
|
||||
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 */
|
||||
#include <Grid/Grid.h>
|
||||
#include <Grid/algorithms/iterative/QuasiMinimalResidual.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
const int Ls=8;
|
||||
|
||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
||||
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
||||
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
||||
|
||||
|
||||
std::vector<int> seeds4({1,2,3,4});
|
||||
std::vector<int> seeds5({5,6,7,8});
|
||||
GridParallelRNG RNG5(FGrid); RNG5.SeedFixedIntegers(seeds5);
|
||||
GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4);
|
||||
|
||||
LatticeFermion src(FGrid); random(RNG5,src);
|
||||
LatticeFermion result(FGrid); result=Zero();
|
||||
LatticeGaugeField Umu(UGrid); SU3::HotConfiguration(RNG4,Umu);
|
||||
|
||||
std::vector<LatticeColourMatrix> U(4,UGrid);
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
U[mu] = PeekIndex<LorentzIndex>(Umu,mu);
|
||||
}
|
||||
|
||||
RealD tol = 1.0e-8;
|
||||
RealD maxit=2000;
|
||||
QuasiMinimalResidual<LatticeFermion> QMR(tol,maxit);
|
||||
GeneralisedMinimalResidual<LatticeFermion> GMR(tol, maxit, 32,false);
|
||||
|
||||
RealD mass=0.0;
|
||||
RealD M5=-1.8;
|
||||
DomainWallFermionR Ddwf(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5);
|
||||
|
||||
Gamma5R5HermitianLinearOperator<DomainWallFermionR,LatticeFermion> g5HermOp(Ddwf);
|
||||
QMR(g5HermOp,src,result);
|
||||
GMR(g5HermOp,src,result);
|
||||
|
||||
NonHermitianLinearOperator<DomainWallFermionR,LatticeFermion> NonHermOp(Ddwf);
|
||||
QMR(NonHermOp,src,result);
|
||||
GMR(NonHermOp,src,result);
|
||||
|
||||
MdagMLinearOperator<DomainWallFermionR,LatticeFermion> HermOp(Ddwf);
|
||||
ConjugateGradient<LatticeFermion> CG(1.0e-8,10000);
|
||||
CG(HermOp,src,result);
|
||||
|
||||
Grid_finalize();
|
||||
}
|
66
tests/solver/Test_wilson_qmr_unprec.cc
Normal file
66
tests/solver/Test_wilson_qmr_unprec.cc
Normal file
@ -0,0 +1,66 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_dwf_cr_unprec.cc
|
||||
|
||||
Copyright (C) 2019
|
||||
|
||||
Author: Peter Boyle <pboyle@bnl.gov>
|
||||
|
||||
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 */
|
||||
#include <Grid/Grid.h>
|
||||
#include <Grid/algorithms/iterative/QuasiMinimalResidual.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
GridCartesian * Grid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||
GridRedBlackCartesian * rbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(Grid);
|
||||
|
||||
|
||||
std::vector<int> seeds4({1,2,3,4});
|
||||
GridParallelRNG RNG4(Grid); RNG4.SeedFixedIntegers(seeds4);
|
||||
|
||||
LatticeFermion src(Grid); random(RNG4,src);
|
||||
LatticeFermion result(Grid); result=Zero();
|
||||
LatticeGaugeField Umu(Grid); SU3::HotConfiguration(RNG4,Umu);
|
||||
|
||||
std::vector<LatticeColourMatrix> U(4,Grid);
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
U[mu] = PeekIndex<LorentzIndex>(Umu,mu);
|
||||
}
|
||||
|
||||
QuasiMinimalResidual<LatticeFermion> QMR(1.0e-8,10000);
|
||||
|
||||
RealD mass=0.0;
|
||||
RealD M5=1.8;
|
||||
WilsonFermionR Dw(Umu,*Grid,*rbGrid,mass);
|
||||
|
||||
NonHermitianLinearOperator<WilsonFermionR,LatticeFermion> NonHermOp(Dw);
|
||||
QMR(NonHermOp,src,result);
|
||||
|
||||
Grid_finalize();
|
||||
}
|
Reference in New Issue
Block a user