Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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  const string str_vlevel = params.get_string("verbose_level");
22 
23  m_vl = vout.set_verbose_level(str_vlevel);
24 
25  //- fetch and check input parameters
26  int Nnoise;
27 
28  int err = 0;
29  err += params.fetch_int("number_of_noises", Nnoise);
30 
31  if (err) {
32  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
33  exit(EXIT_FAILURE);
34  }
35 
36 
37  set_parameters(Nnoise);
38 }
39 
40 
41 //====================================================================
43 {
44  //- print input parameters
45  vout.general(m_vl, "%s:\n", class_name.c_str());
46  vout.general(m_vl, " Nnoise = %d\n", Nnoise);
47 
48  //- range check
49  int err = 0;
50  err += ParameterCheck::non_negative(Nnoise);
51 
52  if (err) {
53  vout.crucial(m_vl, "Error at %s: parameter range check failed.\n", class_name.c_str());
54  exit(EXIT_FAILURE);
55  }
56 
57  //- store values
58  m_Nnoise = Nnoise;
59 }
60 
61 
62 //====================================================================
64 {
65  // measurement of quark number susceptibility:
66  // tr1 = Tr[D1*Sq]
67  // tr2 = Tr[D2*Sq]
68  // tr3 = Tr[D1*Sq*D1*Sq]
69  // For definition, see the implementation note.
70 
71  vout.general(m_vl, "%s:\n", class_name.c_str());
72  vout.general(m_vl, " Number of noise vector = %d\n", m_Nnoise);
73 
74  const int dir_t = CommonParameters::Ndim() - 1;
75 
76  const int Nex = m_fopr->field_nex();
77  const int Nvol = m_fopr->field_nvol();
78  const int Nin = m_fopr->field_nin();
79 
80  int Nconv = 0;
81  double diff = 1.0;
82 
83  Field xi(Nin, Nvol, Nex);
84  Field v1(Nin, Nvol, Nex), v2(Nin, Nvol, Nex), v3(Nin, Nvol, Nex);
85 
86  dcomplex tr1 = cmplx(0.0, 0.0);
87  dcomplex tr2 = cmplx(0.0, 0.0);
88  dcomplex tr3 = cmplx(0.0, 0.0);
89 
90  for (int i_noise = 0; i_noise < m_Nnoise; ++i_noise) {
91  vout.general(m_vl, " noise vector = %d\n", i_noise);
92 
93  m_nv->set(xi);
94  // noise vector was set.
95 
96  m_fprop->invert_D(v3, xi, Nconv, diff);
97  vout.general(m_vl, " Nconv = %d diff = %.8e\n", Nconv, diff);
98  // now v3 is M^-1 * xi.
99 
100  // mult D_1 and D_2
101  v1.set(0.0);
102  m_fopr->mult_up(dir_t, v1, v3);
103  v2.set(0.0);
104  m_fopr->mult_dn(dir_t, v2, v3);
105 
106  dcomplex tr_c1 = dotc(xi, v1);
107  dcomplex tr_c2 = dotc(xi, v2);
108 
109  dcomplex tr1_c = tr_c1 - tr_c2;
110  dcomplex tr2_c = tr_c1 + tr_c2;
111 
112  v3 = v1;
113  axpy(v3, -1.0, v2);
114  // now v3 is D_1 * M^-1 * xi.
115 
116  v1 = v3;
117  m_fprop->invert_D(v3, v1, Nconv, diff);
118  vout.general(m_vl, " Nconv = %d diff = %.8e\n", Nconv, diff);
119  // now v3 is M^-1 * D_1 * M^-1 * xi.
120 
121  // mult D_1
122  v1.set(0.0);
123  m_fopr->mult_up(dir_t, v1, v3);
124  v2.set(0.0);
125  m_fopr->mult_dn(dir_t, v2, v3);
126  axpy(v1, -1.0, v2);
127  // now v1 is D_1 * M^-1 * D_1 * M^-1 * xi.
128 
129  dcomplex tr3_c = dotc(xi, v1);
130 
131  vout.general(m_vl, " tr1 = (%f,%f)\n", real(tr1_c), imag(tr1_c));
132  vout.general(m_vl, " tr2 = (%f,%f)\n", real(tr2_c), imag(tr2_c));
133  vout.general(m_vl, " tr3 = (%f,%f)\n", real(tr3_c), imag(tr3_c));
134 
135  tr1 += tr1_c;
136  tr2 += tr2_c;
137  tr3 += tr3_c;
138  }
139 
140  tr1 = tr1 / cmplx(double(m_Nnoise), 0.0);
141  tr2 = tr2 / cmplx(double(m_Nnoise), 0.0);
142  tr3 = tr3 / cmplx(double(m_Nnoise), 0.0);
143 
144  vout.general(m_vl, " averaged over noise vector:\n");
145  vout.general(m_vl, " tr1 = (%f,%f)\n", real(tr1), imag(tr1));
146  vout.general(m_vl, " tr2 = (%f,%f)\n", real(tr2), imag(tr2));
147  vout.general(m_vl, " tr3 = (%f,%f)\n", real(tr3), imag(tr3));
148 
149 
150  return real(tr1);
151 }
152 
153 
154 //====================================================================
155 //============================================================END=====
BridgeIO vout
Definition: bridgeIO.cpp:503
void general(const char *format,...)
Definition: bridgeIO.cpp:197
Container of Field-type object.
Definition: field.h:45
Class for parameters.
Definition: parameters.h:46
virtual void set(Field &v)=0
setting a noise vector.
virtual int field_nin()=0
returns the on-site d.o.f. for which the fermion operator is defined.
virtual void invert_D(Field &, const Field &, int &, double &)=0
dcomplex dotc(const Field &y, const Field &x)
Definition: field.cpp:155
int fetch_int(const string &key, int &value) const
Definition: parameters.cpp:346
virtual int field_nex()=0
returns the external d.o.f. for which the fermion operator is defined.
virtual void mult_dn(const int mu, Field &, const Field &)
Definition: fopr.h:90
virtual void mult_up(const int mu, Field &, const Field &)
nearest neighbor hopping term: temporary entry [H.Matsufuru]
Definition: fopr.h:89
double measure()
measure tr1 = Tr[D1*Sq], tr2 = Tr[D2*Sq], tr3 = Tr[D1*Sq*D1*Sq].
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:319
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
int non_negative(const int v)
string get_string(const string &key) const
Definition: parameters.cpp:221
virtual int field_nvol()=0
returns the volume for which the fermion operator is defined.
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131