Bridge++  Version 1.4.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
integrator_Omelyan.cpp
Go to the documentation of this file.
1 
14 #include "integrator_Omelyan.h"
15 
16 
17 using Bridge::vout;
18 
19 
20 
21 const std::string Integrator_Omelyan::class_name = "Integrator_Omelyan";
22 
23 //====================================================================
25 {
26  const string str_vlevel = params.get_string("verbose_level");
27 
28  m_vl = vout.set_verbose_level(str_vlevel);
29 
30  //- fetch and check input parameters
31  int level;
32  int Nstep;
33  double lambda_Omelyan;
34 
35  int err = 0;
36  err += params.fetch_int("level", level);
37  err += params.fetch_int("number_of_steps", Nstep);
38  err += params.fetch_double("lambda_Omelyan", lambda_Omelyan);
39 
40  if (err) {
41  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
42  exit(EXIT_FAILURE);
43  }
44 
45  set_parameters(level, Nstep, lambda_Omelyan);
46 }
47 
48 
49 //====================================================================
50 void Integrator_Omelyan::set_parameters(int level, int Nstep, double lambda_Omelyan)
51 {
52  //- print input parameters
53  vout.general(m_vl, "%s:\n", class_name.c_str());
54  vout.general(m_vl, " Level: %4d\n", level);
55  vout.general(m_vl, " Nstep = %4d\n", Nstep);
56  vout.general(m_vl, " lambda_Omelyan = %10.6f\n", lambda_Omelyan);
57 
58  //- range check
59  // NB. level,Estep,Nstep,lambda_Omelyan == 0 is allowed.
60 
61  //- store values
62  m_Nstep = Nstep;
63  m_level = level;
64  m_lambda = lambda_Omelyan;
65 }
66 
67 
68 //====================================================================
70 {
71  m_level = level;
72 }
73 
74 
75 //====================================================================
77 {
78  m_Nstep = Nstep;
79 }
80 
81 
82 //====================================================================
83 void Integrator_Omelyan::set_parameter_Nsteps(const std::vector<int>& Nsteps)
84 {
85  if (Nsteps.size() > 0) {
86  set_parameter_Nstep(Nsteps[0]);
87 
88  // transfer to lower levels
89  if (m_update_U && (Nsteps.size() > 1)) {
90  std::vector<int> next_steps(Nsteps.begin() + 1, Nsteps.end());
91  m_update_U->set_parameter_Nsteps(next_steps);
92  }
93  }
94 }
95 
96 
97 //====================================================================
98 void Integrator_Omelyan::set_parameter_lambda(const double lambda_omelyan)
99 {
100  m_lambda = lambda_omelyan;
101 }
102 
103 
104 //====================================================================
105 void Integrator_Omelyan::evolve(const double step_size, Field_G& iP, Field_G& U)
106 {
107  int Nin = U.nin();
108  int Nvol = U.nvol();
109  int Nex = U.nex();
110  int Nc = CommonParameters::Nc();
111 
112  vout.detailed(m_vl, "%s: level %d: Nstep = %d, step_size = %8.6f\n", class_name.c_str(), m_level, m_Nstep, step_size);
113 
114  vout.general(m_vl, "Integration level-%d start.\n", m_level);
115 
116  if (m_Nstep > 0) {
117  double estep = step_size / m_Nstep;
118 
119  // initial lambda step
120  m_update_p->evolve(estep * m_lambda, iP, U);
121 
122  // molecular dynamics steps
123  for (int istep = 1; istep <= m_Nstep; ++istep) {
124  m_update_U->evolve(estep * 0.5, iP, U);
125 
126  m_update_p->evolve(estep * (1.0 - 2.0 * m_lambda), iP, U);
127 
128  m_update_U->evolve(estep * 0.5, iP, U);
129 
130  if (istep < m_Nstep) {
131  m_update_p->evolve(estep * m_lambda * 2.0, iP, U);
132  }
133  }
134 
135  // last lambda step
136  m_update_p->evolve(estep * m_lambda, iP, U);
137  } else {
138  vout.general(m_vl, "Nstep is zero. skip.\n");
139  }
140 
141  vout.general(m_vl, "Integration level-%d finished.\n", m_level);
142 }
143 
144 
145 //====================================================================
146 //============================================================END=====
BridgeIO vout
Definition: bridgeIO.cpp:495
void detailed(const char *format,...)
Definition: bridgeIO.cpp:212
void general(const char *format,...)
Definition: bridgeIO.cpp:195
void set_parameter_Nsteps(const std::vector< int > &Nsteps)
void set_parameter_Nstep(const int Nstep)
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:211
int nvol() const
Definition: field.h:116
virtual void set_parameter_Nsteps(const std::vector< int > &Nsteps)
Definition: integrator.h:47
void set_parameters(const Parameters &params)
Class for parameters.
Definition: parameters.h:46
int nin() const
Definition: field.h:115
SU(N) gauge field.
Definition: field_G.h:38
void set_parameter_lambda(const double lambda_omelyan)
int fetch_int(const string &key, int &value) const
Definition: parameters.cpp:230
int nex() const
Definition: field.h:117
virtual void evolve(const double step_size, Field_G &iP, Field_G &U)=0
Bridge::VerboseLevel m_vl
Definition: integrator.h:60
static const std::string class_name
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
void evolve(const double step_size, Field_G &iP, Field_G &U)
string get_string(const string &key) const
Definition: parameters.cpp:116
void set_parameter_level(const int level)
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131