Bridge++  Ver. 1.2.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
action_F_Ratio.cpp
Go to the documentation of this file.
1 
14 #include "action_F_Ratio.h"
15 
16 const std::string Action_F_Ratio::class_name = "Action_F_Ratio";
17 
18 //====================================================================
20 {
22 
24 }
25 
26 
27 //====================================================================
29 {
30  int Nc = CommonParameters::Nc();
31  int Nvol = CommonParameters::Nvol();
32  int Ndim = CommonParameters::Ndim();
33  int NinG = 2 * Nc * Nc;
34 
35  vout.general(m_vl, "%s:\n", class_name.c_str());
36 
37  m_force.reset(NinG, Nvol, Ndim);
38 
39  int Niter = 2000;
40  double Stop_cond_MD = 1.0e-24;
41  double Stop_cond_H = 1.0e-24;
42 
43  string str_solver_type = "CG";
44  m_solver_H_prec = Solver::New(str_solver_type, m_fopr_prec);
45  m_solver_MD = Solver::New(str_solver_type, m_fopr);
46  m_solver_H = Solver::New(str_solver_type, m_fopr);
47 
48  m_solver_H_prec->set_parameters(Niter, Stop_cond_H);
49  m_solver_MD->set_parameters(Niter, Stop_cond_MD);
50  m_solver_H->set_parameters(Niter, Stop_cond_H);
51 
52  //- link variable update flag
53  m_status_linkv = 0;
54 }
55 
56 
57 //====================================================================
59 {
60  int Nvol = CommonParameters::Nvol();
61  int Ndim = CommonParameters::Ndim();
62 
63  int NinF = m_fopr_prec->field_nin();
64  int NvolF = m_fopr_prec->field_nvol();
65  int NexF = m_fopr_prec->field_nex();
66  int size_psf = NinF * NvolF * NexF * CommonParameters::NPE();
67 
68  assert(NvolF == Nvol);
69  m_psf.reset(NinF, NvolF, NexF);
70 
71  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
72 
73  Field xi(NinF, NvolF, NexF);
74  rand->gauss_lex_global(xi);
75 
78 
79  Field v1(NinF, NvolF, NexF), v2(NinF, NvolF, NexF);
80 
81  /*
82  m_fopr->set_mode("H");
83  v1 = m_fopr->mult(xi);
84 
85  int Nconv;
86  double diff;
87  m_fopr_prec->set_mode("DdagD");
88  m_solver_H_prec->solve(v2,v1,Nconv,diff);
89  vout.general(m_vl, " Nconv = %d diff = %.8e\n",Nconv,diff);
90 
91  m_fopr_prec->set_mode("H");
92  m_psf = m_fopr_prec->mult(v2);
93  */
94 
95  m_fopr->set_mode("H");
96  v2 = m_fopr->mult_dag(xi);
97 
98  m_fopr_prec->set_mode("H");
99  v1 = m_fopr_prec->mult_dag(v2);
100 
101  int Nconv;
102  double diff;
103  m_fopr_prec->set_mode("DdagD");
104  m_solver_H_prec->solve(m_psf, v1, Nconv, diff);
105  vout.general(m_vl, " Nconv = %d diff = %.8e\n", Nconv, diff);
106 
107  double xi2 = xi.norm();
108  double H_psf = xi2 * xi2;
109 
110  vout.general(m_vl, " H_Fratio = %18.8f\n", H_psf);
111  vout.general(m_vl, " H_F/dof = %18.8f\n", H_psf / size_psf);
112 
113  return H_psf;
114 }
115 
116 
117 //====================================================================
119 {
120  int Nvol = CommonParameters::Nvol();
121  int Ndim = CommonParameters::Ndim();
122 
123  int NinF = m_fopr_prec->field_nin();
124  int NvolF = m_fopr_prec->field_nvol();
125  int NexF = m_fopr_prec->field_nex();
126  int size_psf = NinF * NvolF * NexF * CommonParameters::NPE();
127 
128  Field v1(NinF, NvolF, NexF), v2(NinF, NvolF, NexF);
129 
130  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
131 
134 
135  m_fopr_prec->set_mode("H");
136  v1 = m_fopr_prec->mult(m_psf);
137 
138  int Nconv;
139  double diff;
140  m_fopr->set_mode("DdagD");
141  m_solver_H->solve(v2, v1, Nconv, diff);
142  vout.general(m_vl, " Nconv = %d diff = %.8e\n", Nconv, diff);
143 
144  double H_psf = v1 * v2;
145 
146  vout.general(m_vl, " H_Fratio = %18.8f\n", H_psf);
147  vout.general(m_vl, " H_F/dof = %18.8f\n", H_psf / size_psf);
148 
149  return H_psf;
150 }
151 
152 
153 //====================================================================
155 {
156  if (m_status_linkv == 0) {
157  int Nin = m_U->nin();
158  int Nvol = m_U->nvol();
159  int Nex = m_U->nex();
160  int Nc = CommonParameters::Nc();
161  int Ndim = CommonParameters::Ndim();
162 
163  int NinF = m_fopr_prec->field_nin();
164  int NvolF = m_fopr_prec->field_nvol();
165  int NexF = m_fopr_prec->field_nex();
166  Field eta(NinF, NvolF, NexF);
167 
168  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
169 
174 
175  Field v1(NinF, NvolF, NexF), v2(NinF, NvolF, NexF);
176 
177  m_fopr_prec->set_mode("H");
178  v1 = m_fopr_prec->mult(m_psf);
179 
180  int Nconv;
181  double diff;
182  m_fopr->set_mode("DdagD");
183  m_solver_MD->solve(v2, v1, Nconv, diff);
184  vout.general(m_vl, " Solver: Nconv = %6d diff = %12.6e\n", Nconv, diff);
185 
186  Field force(Nin, Nvol, Nex);
187  Field force1(Nin, Nvol, Nex);
188 
189  force = m_fopr_force->force_core(v2);
190 
192  force -= m_fopr_prec_force->force_core1(v2, m_psf);
193 
194  m_fopr_prec_force->set_mode("Hdag");
195  force -= m_fopr_prec_force->force_core1(m_psf, v2);
196 
197  m_force = force;
198  ++m_status_linkv;
199 
200  double Fave, Fmax, Fdev;
201  m_force.stat(Fave, Fmax, Fdev);
202  vout.general(m_vl, " Fratio_ave = %12.6f Fratio_max = %12.6f Fratio_dev = %12.6f\n",
203  Fave, Fmax, Fdev);
204 
205  return m_force;
206  } else {
207  vout.general(m_vl, " %s returns previous force.\n", class_name.c_str());
208  return m_force;
209  }
210 }
211 
212 
213 //====================================================================
214 //============================================================END=====
Solver * m_solver_MD
BridgeIO vout
Definition: bridgeIO.cpp:207
virtual const Field mult_dag(const Field &)
hermitian conjugate of mult(const Field&).
Definition: fopr.h:60
virtual const Field mult(const Field &)=0
multiplies fermion operator to a given field and returns the resultant field.
double langevin(RandomNumbers *)
Langevis step.
void general(const char *format,...)
Definition: bridgeIO.cpp:38
virtual void set_config(Field *)=0
setting pointer to the gauge configuration.
Container of Field-type object.
Definition: field.h:37
virtual void set_config(Field *)=0
int nvol() const
Definition: field.h:101
Class for parameters.
Definition: parameters.h:40
virtual void force_core1(Field &, const Field &, const Field &)
Definition: force.cpp:74
static const std::string class_name
virtual void gauss_lex_global(Field &)
gaussian random number defined on global lattice.
virtual int field_nin()=0
returns the on-site d.o.f. for which the fermion operator is defined.
Force * m_fopr_prec_force
void set_parameter_verboselevel(const Bridge::VerboseLevel vl)
Definition: action.h:46
virtual void set_parameters(const Parameters &params)=0
int nin() const
Definition: field.h:100
Solver * m_solver_H_prec
virtual void set_mode(const std::string &mode)
in Force, setting the mode is optional when H is nonhermitian.
Definition: force.h:51
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=COMPLEX)
Definition: field.h:82
double norm() const
Definition: field.h:210
virtual int field_nex()=0
returns the external d.o.f. for which the fermion operator is defined.
int nex() const
Definition: field.h:102
virtual void force_core(Field &, const Field &)
Definition: force.cpp:58
Bridge::VerboseLevel get_VerboseLevel() const
Definition: parameters.cpp:116
std::string m_label
Bridge::VerboseLevel m_vl
Definition: action.h:64
Base class of random number generators.
Definition: randomNumbers.h:40
Bridge::VerboseLevel vl
Definition: checker.cpp:18
VerboseLevel
Definition: bridgeIO.h:25
virtual void set_mode(std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Definition: fopr.h:75
void stat(double &Fave, double &Fmax, double &Fdev) const
determines the statistics of the field. average, maximum value, and deviation is determined over glob...
Definition: field.cpp:544
const Field force()
returns force for molcular dynamical update of conjugate momenta.
virtual int field_nvol()=0
returns the volume for which the fermion operator is defined.
Solver * m_solver_H
virtual void solve(Field &solution, const Field &source, int &Nconv, double &diff)=0
static int NPE()
double calcH()
calculate Hamiltonian of this action term.
Force * m_fopr_force