Bridge++  Ver. 2.0.2
action_F_Rational_alt-tmpl.h
Go to the documentation of this file.
1 
10 //#include "Action/Fermion/action_F_Rational_alt.h"
11 //#include "Field/index_lex_alt.h"
12 //#include "Field/afield-inc.h"
13 
14 template<typename AFIELD>
16  = "Action_F_Rational_alt";
17 
18 //====================================================================
19 template<typename AFIELD>
21 {
22  m_vl = CommonParameters::Vlevel();
23 }
24 
25 
26 //====================================================================
27 template<typename AFIELD>
29 {
30  // do nothing.
31 }
32 
33 
34 //====================================================================
35 template<typename AFIELD>
37 {
38  const string str_vlevel = params.get_string("verbose_level");
39  m_vl = vout.set_verbose_level(str_vlevel);
40 }
41 
42 
43 //====================================================================
44 template<typename AFIELD>
46 {
47  m_U = U;
48  m_fopr_langev->set_config(U);
49  m_fopr_H->set_config(U);
50  m_fopr_force_MD->set_config(U);
51 }
52 
53 
54 //====================================================================
55 template<typename AFIELD>
57 {
58  const int NinF = m_fopr_langev->field_nin();
59  const int NvolF = m_fopr_langev->field_nvol();
60  const int NexF = m_fopr_langev->field_nex();
61  const int size_psf = NinF * NvolF * NexF * CommonParameters::NPE();
62 
63  m_psf.reset(NinF, NvolF, NexF);
64 
65  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
66 
67  Field xi(NinF, NvolF, NexF);
68  rand->gauss_lex_global(xi);
69 
70  AFIELD xiA(NinF, NvolF, NexF);
71 
72  Index_lex_alt<real_t, AFIELD::IMPL> index_alt;
73 
74 #pragma omp parallel
75  {
76  if (m_fopr_langev->needs_convert()) {
77  m_fopr_langev->convert(xiA, xi);
78  } else {
79  convert(index_alt, xiA, xi);
80  }
81  }
82 
83  m_fopr_langev->set_config(m_U);
84  m_fopr_langev->mult(m_psf, xiA);
85 
86  double xi2 = xi.norm();
87  double H_psf = xi2 * xi2;
88 
89  vout.general(m_vl, " H_Frational = %18.8f\n", H_psf);
90  vout.general(m_vl, " H_F/dof = %18.8f\n", H_psf / size_psf);
91 
92  return H_psf;
93 }
94 
95 
96 //====================================================================
97 template<typename AFIELD>
99 {
100  const int NinF = m_fopr_H->field_nin();
101  const int NvolF = m_fopr_H->field_nvol();
102  const int NexF = m_fopr_H->field_nex();
103  const int size_psf = NinF * NvolF * NexF * CommonParameters::NPE();
104 
105  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
106 
107  AFIELD v1(NinF, NvolF, NexF);
108  m_fopr_H->set_config(m_U);
109  m_fopr_H->mult(v1, m_psf);
110 
111  double H_psf = dot(v1, m_psf);
112 
113  vout.general(m_vl, " H_Frational = %18.8f\n", H_psf);
114  vout.general(m_vl, " H_F/dof = %18.8f\n", H_psf / size_psf);
115 
116  return H_psf;
117 }
118 
119 
120 //====================================================================
121 template<typename AFIELD>
123 {
124  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
125 
126  Timer timer;
127  double elapsed_time;
128  timer.start();
129 
130  const int Nin = m_U->nin();
131  const int Nvol = m_U->nvol();
132  const int Nex = m_U->nex();
133 
134  assert(force.nin() == Nin);
135  assert(force.nvol() == Nvol);
136  assert(force.nex() == Nex);
137 
138  AFIELD force1(Nin, Nvol, Nex);
139 
140  m_fopr_force_MD->set_config(m_U);
141  m_fopr_force_MD->force_core(force1, m_psf);
142 
143  Index_lex_alt<real_t, AFIELD::IMPL> index_lex;
144 #pragma omp parallel
145  {
146  reverse_gauge(index_lex, force, force1);
147  }
148 
149  double Fave, Fmax, Fdev;
150  force.stat(Fave, Fmax, Fdev);
151  vout.general(m_vl, " Fave = %12.6f Fmax = %12.6f Fdev = %12.6f\n",
152  Fave, Fmax, Fdev);
153 
154  timer.stop();
155  elapsed_time = timer.elapsed_sec();
156  vout.general(m_vl, " elapsed time: %12.6f [sec]\n", elapsed_time);
157 }
158 
159 
160 //====================================================================
161 //============================================================END=====
Parameters
Class for parameters.
Definition: parameters.h:46
Action_F_Rational_alt::init
void init()
Definition: action_F_Rational_alt-tmpl.h:20
convert
void convert(INDEX &index, AFIELD &v, const Field &w)
Definition: afield-inc.h:129
Field::nex
int nex() const
Definition: field.h:128
RandomNumbers
Base class of random number generators.
Definition: randomNumbers.h:43
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_Rational_alt::set_config
void set_config(Field *U)
setting gauge configuration.
Definition: action_F_Rational_alt-tmpl.h:45
Timer::start
void start()
Definition: timer.cpp:44
Action_F_Rational_alt
action class for RHMC, with externally constructed AFopr_Rational.
Definition: action_F_Rational_alt.h:34
Action_F_Rational_alt::calcH
double calcH()
calculation of Hamiltonian.
Definition: action_F_Rational_alt-tmpl.h:98
Field::norm
double norm() const
Definition: field.h:226
Action_F_Rational_alt::tidyup
void tidyup()
Definition: action_F_Rational_alt-tmpl.h:28
Field::nvol
int nvol() const
Definition: field.h:127
Action_F_Rational_alt::set_parameters
void set_parameters(const Parameters &params)
Definition: action_F_Rational_alt-tmpl.h:36
CommonParameters::NPE
static int NPE()
Definition: commonParameters.h:101
CommonParameters::Vlevel
static Bridge::VerboseLevel Vlevel()
Definition: commonParameters.h:122
Action_F_Rational_alt::langevin
double langevin(RandomNumbers *)
Langevin step called at the beginning of HMC.
Definition: action_F_Rational_alt-tmpl.h:56
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
Action_F_Rational_alt::force
void force(Field &)
returns the force for updating conjugate momentum.
Definition: action_F_Rational_alt-tmpl.h:122
Parameters::get_string
string get_string(const string &key) const
Definition: parameters.cpp:221
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