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