Bridge++  Ver. 2.0.2
action_F_Standard_lex_alt-tmpl.h
Go to the documentation of this file.
1 
11 
12 #include "lib/Tools/timer.h"
13 
14 #include "Field/index_lex_alt.h"
15 #include "Field/afield-inc.h"
16 
17 template<typename AFIELD>
19  = "Action_F_Standard_lex_alt";
20 
21 //====================================================================
22 template<typename AFIELD>
24 {
25  m_vl = CommonParameters::Vlevel();
26 }
27 
28 
29 //====================================================================
30 template<typename AFIELD>
32 {
33  // do nothing.
34 }
35 
36 
37 //====================================================================
38 template<typename AFIELD>
40 {
41  const string str_vlevel = params.get_string("verbose_level");
42  m_vl = vout.set_verbose_level(str_vlevel);
43 }
44 
45 
46 //====================================================================
47 template<typename AFIELD>
49 {
50  m_U = U;
51 
52  m_fopr->set_config(U);
53  m_fopr_force->set_config(U);
54 }
55 
56 
57 //====================================================================
58 template<typename AFIELD>
60 {
61  int Nvol = CommonParameters::Nvol();
62  int Ndim = CommonParameters::Ndim();
63 
64  int NinF = m_fopr->field_nin();
65  int NvolF = m_fopr->field_nvol();
66  int NexF = m_fopr->field_nex();
67  int size_psf = NinF * NvolF * NexF * CommonParameters::NPE();
68 
69  assert(NvolF == Nvol);
70  m_psf.reset(NinF, NvolF, NexF);
71 
72  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
73 
74  Field xi(NinF, NvolF, NexF);
75  rand->gauss_lex_global(xi);
76 
77  AFIELD xiA(NinF, NvolF, NexF);
78 
79  Index_lex_alt<real_t> index_alt;
80 
81 #pragma omp parallel
82  {
83  if (m_fopr->needs_convert()) {
84  m_fopr->convert(xiA, xi);
85  } else {
86  convert_spinor(index_alt, xiA, xi);
87  }
88  }
89 
90  m_fopr->set_config(m_U);
91  m_fopr->set_mode("Ddag");
92 
93  m_fopr->mult(m_psf, xiA);
94 
95  double xi2 = xi.norm();
96  double H_psf = xi2 * xi2;
97 
98  vout.general(m_vl, " H_Fstandard = %18.8f\n", H_psf);
99  vout.general(m_vl, " H_F/dof = %18.8f\n", H_psf / size_psf);
100 
101  return H_psf;
102 }
103 
104 
105 //====================================================================
106 template<typename AFIELD>
108 {
109  int Nvol = CommonParameters::Nvol();
110  int Ndim = CommonParameters::Ndim();
111 
112  int NinF = m_fopr->field_nin();
113  int NvolF = m_fopr->field_nvol();
114  int NexF = m_fopr->field_nex();
115  int size_psf = NinF * NvolF * NexF * CommonParameters::NPE();
116 
117  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
118 
119  AFIELD v1(NinF, NvolF, NexF);
120  int Nconv;
121  double diff;
122 
123  m_fprop_H->set_config(m_U);
124  m_fprop_H->set_mode("DdagD");
125  m_fprop_H->invert(v1, m_psf, Nconv, diff);
126 
127  vout.general(m_vl, " Fprop_H: %6d %18.15e\n", Nconv, diff);
128 
129  const double H_psf = dot(v1, m_psf);
130 
131  vout.general(m_vl, " H_Fstandard = %18.8f\n", H_psf);
132  vout.general(m_vl, " H_F/dof = %18.8f\n", H_psf / size_psf);
133 
134  return H_psf;
135 }
136 
137 
138 //====================================================================
139 template<typename AFIELD>
141 {
142  const int Nin = m_U->nin();
143  const int Nvol = m_U->nvol();
144  const int Nex = m_U->nex();
145  const int Nc = CommonParameters::Nc();
146  const int Ndim = CommonParameters::Ndim();
147 
148  assert(force.nin() == Nin);
149  assert(force.nvol() == Nvol);
150  assert(force.nex() == Nex);
151 
152  AFIELD force1(Nin, Nvol, Nex);
153 
154  const int NinF = m_fopr->field_nin();
155  const int NvolF = m_fopr->field_nvol();
156  const int NexF = m_fopr->field_nex();
157 
158  Timer timer;
159  double elapsed_time;
160  timer.start();
161 
162  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
163 
164  AFIELD eta(NinF, NvolF, NexF);
165  int Nconv;
166  double diff;
167 
168  m_fprop_MD->set_config(m_U);
169  m_fprop_MD->set_mode("DdagD");
170  m_fprop_MD->invert(eta, m_psf, Nconv, diff);
171 
172  vout.general(m_vl, " Fprop_MD: %6d %18.15e\n", Nconv, diff);
173 
174  m_fopr->set_config(m_U);
175  m_fopr_force->set_config(m_U);
176 
177  m_fopr_force->force_core(force1, eta);
178 
179  Index_lex_alt<real_t> index_lex;
180 #pragma omp parallel
181  {
182  reverse_gauge(index_lex, force, force1);
183  }
184 
185  double Fave, Fmax, Fdev;
186  force.stat(Fave, Fmax, Fdev);
187  vout.general(m_vl, " Fave = %12.6f Fmax = %12.6f Fdev = %12.6f\n",
188  Fave, Fmax, Fdev);
189 
190  timer.stop();
191  elapsed_time = timer.elapsed_sec();
192  vout.general(m_vl, " elapsed time: %12.6f [sec]\n", elapsed_time);
193 }
194 
195 
196 //============================================================END=====
Action_F_Standard_lex_alt::langevin
double langevin(RandomNumbers *)
Langevis step.
Definition: action_F_Standard_lex_alt-tmpl.h:59
afield-inc.h
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Parameters
Class for parameters.
Definition: parameters.h:46
Action_F_Standard_lex_alt::set_parameters
void set_parameters(const Parameters &)
Definition: action_F_Standard_lex_alt-tmpl.h:39
Action_F_Standard_lex_alt::set_config
void set_config(Field *U)
setting pointer to the gauge configuration.
Definition: action_F_Standard_lex_alt-tmpl.h:48
Field::nex
int nex() const
Definition: field.h:128
action_F_Standard_lex_alt.h
RandomNumbers
Base class of random number generators.
Definition: randomNumbers.h:43
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Field::stat
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:169
reverse_gauge
void reverse_gauge(INDEX &index, Field &v, FIELD &w)
Definition: afield-inc.h:417
dot
double dot(const Field &y, const Field &x)
Definition: field.cpp:576
Field::nin
int nin() const
Definition: field.h:126
Timer
Definition: timer.h:31
Action_F_Standard_lex_alt::force
void force(Field &)
returns force for molcular dynamical update of conjugate momenta.
Definition: action_F_Standard_lex_alt-tmpl.h:140
Timer::start
void start()
Definition: timer.cpp:44
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
timer.h
Action_F_Standard_lex_alt::init
void init()
Definition: action_F_Standard_lex_alt-tmpl.h:23
Field::norm
double norm() const
Definition: field.h:226
Field::nvol
int nvol() const
Definition: field.h:127
CommonParameters::NPE
static int NPE()
Definition: commonParameters.h:101
Action_F_Standard_lex_alt::tidyup
void tidyup()
Definition: action_F_Standard_lex_alt-tmpl.h:31
CommonParameters::Vlevel
static Bridge::VerboseLevel Vlevel()
Definition: commonParameters.h:122
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
Action_F_Standard_lex_alt
Standard fermion action for HMC.
Definition: action_F_Standard_lex_alt.h:32
Parameters::get_string
string get_string(const string &key) const
Definition: parameters.cpp:221
Action_F_Standard_lex_alt::calcH
double calcH()
calculate Hamiltonian of this action term.
Definition: action_F_Standard_lex_alt-tmpl.h:107
Field
Container of Field-type object.
Definition: field.h:46
RandomNumbers::gauss_lex_global
virtual void gauss_lex_global(Field &)
gaussian random number defined on global lattice.
Definition: randomNumbers.cpp:95
Timer::elapsed_sec
double elapsed_sec() const
Definition: timer.cpp:107
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Timer::stop
void stop()
Definition: timer.cpp:69
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
convert_spinor
void convert_spinor(INDEX &index, FIELD &v, const Field &w)
Definition: afield-inc.h:187