00001
00002
00003
00004
00005
00006 #include "chromabase.h"
00007
00008 #include "meas/sources/source_const_factory.h"
00009 #include "meas/sources/rndz2wall_source_const.h"
00010 #include "util/ferm/transf.h"
00011
00012 namespace Chroma
00013 {
00014
00015 void read(XMLReader& xml, const string& path, RandZ2WallQuarkSourceConstEnv::Params& param)
00016 {
00017 RandZ2WallQuarkSourceConstEnv::Params tmp(xml, path);
00018 param = tmp;
00019 }
00020
00021
00022 void write(XMLWriter& xml, const string& path, const RandZ2WallQuarkSourceConstEnv::Params& param)
00023 {
00024 param.writeXML(xml, path);
00025 }
00026
00027
00028
00029
00030 namespace RandZ2WallQuarkSourceConstEnv
00031 {
00032 namespace
00033 {
00034
00035 QuarkSourceConstruction<LatticePropagator>* createProp(XMLReader& xml_in,
00036 const std::string& path)
00037 {
00038 return new SourceConst<LatticePropagator>(Params(xml_in, path));
00039 }
00040
00041
00042 bool registered = false;
00043
00044
00045 const std::string name("RAND_Z2_WALL_SOURCE");
00046 }
00047
00048
00049 std::string getName() {return name;}
00050
00051
00052 bool registerAll()
00053 {
00054 bool success = true;
00055 if (! registered)
00056 {
00057 success &= Chroma::ThePropSourceConstructionFactory::Instance().registerObject(name, createProp);
00058 registered = true;
00059 }
00060 return success;
00061 }
00062
00063
00064
00065 Params::Params()
00066 {
00067 j_decay = -1;
00068 t_source = -1;
00069 }
00070
00071
00072
00073 Params::Params(XMLReader& xml, const string& path)
00074 {
00075 XMLReader paramtop(xml, path);
00076
00077 int version;
00078 read(paramtop, "version", version);
00079
00080 switch (version)
00081 {
00082 case 1:
00083 break;
00084
00085 default:
00086 QDPIO::cerr << __func__ << ": parameter version " << version
00087 << " unsupported." << endl;
00088 QDP_abort(1);
00089 }
00090
00091 read(paramtop, "ran_seed", ran_seed);
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 read(paramtop, "j_decay", j_decay);
00108 read(paramtop, "t_source", t_source);
00109 }
00110
00111
00112
00113 void Params::writeXML(XMLWriter& xml, const string& path) const
00114 {
00115 push(xml, path);
00116
00117 int version = 1;
00118 write(xml, "version", version);
00119 write(xml, "ran_seed", ran_seed);
00120 write(xml, "j_decay", j_decay);
00121 write(xml, "t_source", t_source);
00122 pop(xml);
00123 }
00124
00125
00126
00127 template<>
00128 LatticePropagator
00129 SourceConst<LatticePropagator>::operator()(const multi1d<LatticeColorMatrix>& u) const
00130 {
00131 QDPIO::cout << "Rand Z2 Wall source" << endl;
00132
00133
00134
00135 Seed ran_seed;
00136 QDP::RNG::savern(ran_seed);
00137
00138
00139 QDP::RNG::setrn(params.ran_seed);
00140
00141
00142
00143
00144 LatticePropagator quark_source;
00145
00146 multi1d<LatticeColorVector> tmp_color_vec(Nc);
00147
00148 LatticeReal rnd;
00149 LatticeReal ar, ai;
00150 LatticeComplex z;
00151
00152 random(rnd);
00153 ar = where( rnd>0.5, LatticeReal(sqrt(0.5)), LatticeReal(-sqrt(0.5)) );
00154 random(rnd);
00155 ai = where( rnd>0.5, LatticeReal(sqrt(0.5)), LatticeReal(-sqrt(0.5)) );
00156 z = cmplx(ar, ai);
00157
00158 for(int i=0; i<Nc; i++) {
00159 tmp_color_vec[i] = zero;
00160 pokeColor(tmp_color_vec[i], z, i);
00161 }
00162
00163 for(int color_source = 0; color_source < Nc; ++color_source)
00164 {
00165 QDPIO::cout << "color = " << color_source << endl;
00166
00167 LatticeColorVector src_color_vec = zero;
00168
00169 int mu = params.j_decay;
00170 int slice = params.t_source;
00171 src_color_vec = where( Layout::latticeCoordinate(mu) == slice,
00172 tmp_color_vec[color_source],
00173 LatticeColorVector(zero));
00174
00175 for(int spin_source = 0; spin_source < Ns; ++spin_source)
00176 {
00177 QDPIO::cout << "spin = " << spin_source << endl;
00178
00179
00180
00181 LatticeFermion chi = zero;
00182
00183 CvToFerm(src_color_vec, chi, spin_source);
00184
00185
00186
00187
00188
00189
00190 FermToProp(chi, quark_source, color_source, spin_source);
00191 }
00192 }
00193
00194
00195
00196 QDP::RNG::setrn(ran_seed);
00197
00198 return quark_source;
00199 }
00200
00201 }
00202
00203 }