Bridge++  Ver. 2.0.2
quarkNumberSusceptibility_Wilson.cpp
Go to the documentation of this file.
1 
15 
16 const std::string QuarkNumberSusceptibility_Wilson::class_name = "QuarkNumberSusceptibility_Wilson";
17 
18 //====================================================================
20 {
21  std::string vlevel;
22  if (!params.fetch_string("verbose_level", vlevel)) {
23  m_vl = vout.set_verbose_level(vlevel);
24  }
25 
26  //- fetch and check input parameters
27  int Nnoise;
28 
29  int err = 0;
30  err += params.fetch_int("number_of_noises", Nnoise);
31 
32  if (err) {
33  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
34  exit(EXIT_FAILURE);
35  }
36 
37 
38  set_parameters(Nnoise);
39 }
40 
41 
42 //====================================================================
44 {
45  params.set_int("number_of_noises", m_Nnoise);
46 
47  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
48 }
49 
50 
51 //====================================================================
53 {
54  //- print input parameters
55  vout.general(m_vl, "%s:\n", class_name.c_str());
56  vout.general(m_vl, " Nnoise = %d\n", Nnoise);
57 
58  //- range check
59  int err = 0;
60  err += ParameterCheck::non_negative(Nnoise);
61 
62  if (err) {
63  vout.crucial(m_vl, "Error at %s: parameter range check failed.\n", class_name.c_str());
64  exit(EXIT_FAILURE);
65  }
66 
67  //- store values
68  m_Nnoise = Nnoise;
69 }
70 
71 
72 //====================================================================
74 {
75  // measurement of quark number susceptibility:
76  // tr1 = Tr[D1*Sq]
77  // tr2 = Tr[D2*Sq]
78  // tr3 = Tr[D1*Sq*D1*Sq]
79  // For definition, see the implementation note.
80 
81  vout.general(m_vl, "%s:\n", class_name.c_str());
82  vout.general(m_vl, " Number of noise vector = %d\n", m_Nnoise);
83 
84  const int dir_t = CommonParameters::Ndim() - 1;
85 
86  const int Nex = m_fopr->field_nex();
87  const int Nvol = m_fopr->field_nvol();
88  const int Nin = m_fopr->field_nin();
89 
90  int Nconv = 0;
91  double diff = 1.0;
92 
93  Field xi(Nin, Nvol, Nex);
94  Field v1(Nin, Nvol, Nex), v2(Nin, Nvol, Nex), v3(Nin, Nvol, Nex);
95 
96  dcomplex tr1 = cmplx(0.0, 0.0);
97  dcomplex tr2 = cmplx(0.0, 0.0);
98  dcomplex tr3 = cmplx(0.0, 0.0);
99 
100  for (int i_noise = 0; i_noise < m_Nnoise; ++i_noise) {
101  vout.general(m_vl, " noise vector = %d\n", i_noise);
102 
103  m_nv->set(xi);
104  // noise vector was set.
105 
106  m_fprop->invert_D(v3, xi, Nconv, diff);
107  vout.general(m_vl, " Nconv = %d diff = %.8e\n", Nconv, diff);
108  // now v3 is M^-1 * xi.
109 
110  // mult D_1 and D_2
111  v1.set(0.0);
112  m_fopr->mult_up(dir_t, v1, v3);
113  v2.set(0.0);
114  m_fopr->mult_dn(dir_t, v2, v3);
115 
116  dcomplex tr_c1 = dotc(xi, v1);
117  dcomplex tr_c2 = dotc(xi, v2);
118 
119  dcomplex tr1_c = tr_c1 - tr_c2;
120  dcomplex tr2_c = tr_c1 + tr_c2;
121 
122  v3 = v1;
123  axpy(v3, -1.0, v2);
124  // now v3 is D_1 * M^-1 * xi.
125 
126  v1 = v3;
127  m_fprop->invert_D(v3, v1, Nconv, diff);
128  vout.general(m_vl, " Nconv = %d diff = %.8e\n", Nconv, diff);
129  // now v3 is M^-1 * D_1 * M^-1 * xi.
130 
131  // mult D_1
132  v1.set(0.0);
133  m_fopr->mult_up(dir_t, v1, v3);
134  v2.set(0.0);
135  m_fopr->mult_dn(dir_t, v2, v3);
136  axpy(v1, -1.0, v2);
137  // now v1 is D_1 * M^-1 * D_1 * M^-1 * xi.
138 
139  dcomplex tr3_c = dotc(xi, v1);
140 
141  vout.general(m_vl, " tr1 = (%f,%f)\n", real(tr1_c), imag(tr1_c));
142  vout.general(m_vl, " tr2 = (%f,%f)\n", real(tr2_c), imag(tr2_c));
143  vout.general(m_vl, " tr3 = (%f,%f)\n", real(tr3_c), imag(tr3_c));
144 
145  tr1 += tr1_c;
146  tr2 += tr2_c;
147  tr3 += tr3_c;
148  }
149 
150  tr1 = tr1 / cmplx(double(m_Nnoise), 0.0);
151  tr2 = tr2 / cmplx(double(m_Nnoise), 0.0);
152  tr3 = tr3 / cmplx(double(m_Nnoise), 0.0);
153 
154  vout.general(m_vl, " averaged over noise vector:\n");
155  vout.general(m_vl, " tr1 = (%f,%f)\n", real(tr1), imag(tr1));
156  vout.general(m_vl, " tr2 = (%f,%f)\n", real(tr2), imag(tr2));
157  vout.general(m_vl, " tr3 = (%f,%f)\n", real(tr3), imag(tr3));
158 
159 
160  return real(tr1);
161 }
162 
163 
164 //====================================================================
165 //============================================================END=====
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Parameters
Class for parameters.
Definition: parameters.h:46
QuarkNumberSusceptibility_Wilson::m_fprop
Fprop * m_fprop
Definition: quarkNumberSusceptibility_Wilson.h:47
AFopr::field_nex
virtual int field_nex()=0
returns the external degree of freedom of the fermion field.
QuarkNumberSusceptibility_Wilson::m_vl
Bridge::VerboseLevel m_vl
Definition: quarkNumberSusceptibility_Wilson.h:43
QuarkNumberSusceptibility_Wilson::m_Nnoise
int m_Nnoise
Definition: quarkNumberSusceptibility_Wilson.h:50
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
ParameterCheck::non_negative
int non_negative(const int v)
Definition: parameterCheck.cpp:21
QuarkNumberSusceptibility_Wilson::m_fopr
Fopr * m_fopr
Definition: quarkNumberSusceptibility_Wilson.h:46
QuarkNumberSusceptibility_Wilson::measure
double measure()
measure tr1 = Tr[D1*Sq], tr2 = Tr[D2*Sq], tr3 = Tr[D1*Sq*D1*Sq].
Definition: quarkNumberSusceptibility_Wilson.cpp:73
NoiseVector::set
virtual void set(Field &v)=0
setting a noise vector.
Fprop::invert_D
virtual void invert_D(Field &, const Field &, int &, double &)=0
AFopr::field_nvol
virtual int field_nvol()=0
returns the volume of the fermion field.
quarkNumberSusceptibility_Wilson.h
QuarkNumberSusceptibility_Wilson::m_nv
NoiseVector * m_nv
Definition: quarkNumberSusceptibility_Wilson.h:48
dotc
dcomplex dotc(const Field &y, const Field &x)
Definition: field.cpp:712
AFopr::mult_dn
virtual void mult_dn(int mu, AFIELD &, const AFIELD &)
downward nearest neighbor hopping term.
Definition: afopr.h:137
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
Parameters::set_int
void set_int(const string &key, const int value)
Definition: parameters.cpp:36
QuarkNumberSusceptibility_Wilson::class_name
static const std::string class_name
Definition: quarkNumberSusceptibility_Wilson.h:40
Parameters::fetch_string
int fetch_string(const string &key, string &value) const
Definition: parameters.cpp:378
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Field
Container of Field-type object.
Definition: field.h:46
AFopr::field_nin
virtual int field_nin()=0
returns the on-site degree of freedom of the fermion field.
QuarkNumberSusceptibility_Wilson::set_parameters
void set_parameters(const Parameters &params)
Definition: quarkNumberSusceptibility_Wilson.cpp:19
Parameters::fetch_int
int fetch_int(const string &key, int &value) const
Definition: parameters.cpp:346
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
QuarkNumberSusceptibility_Wilson::get_parameters
void get_parameters(Parameters &params) const
Definition: quarkNumberSusceptibility_Wilson.cpp:43
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
AFopr::mult_up
virtual void mult_up(int mu, AFIELD &, const AFIELD &)
upward nearest neighbor hopping term.
Definition: afopr.h:130
Bridge::BridgeIO::get_verbose_level
static std::string get_verbose_level(const VerboseLevel vl)
Definition: bridgeIO.cpp:154