Path Integral Quantum Monte Carlo
common.h
Go to the documentation of this file.
1 
12 #ifndef COMMON_H
13 #define COMMON_H
14 
15 #include <iomanip>
16 #include <iostream>
17 #include <string>
18 #include <cmath>
19 #include <cassert>
20 #include <vector>
21 #include <set>
22 #include <map>
23 #include <algorithm>
24 #include <sstream>
25 #include <chrono>
26 #include <functional> // has std::bind
27 
28 #define BZ_HAVE_BOOST_SERIALIZATION
29 #include <blitz/array.h>
30 #include <boost/archive/text_oarchive.hpp>
31 #include <boost/archive/text_iarchive.hpp>
32 #include <boost/archive/binary_oarchive.hpp>
33 #include <boost/archive/binary_iarchive.hpp>
34 
35 #include <boost/format.hpp>
36 #include <boost/ptr_container/ptr_vector.hpp>
37 #include <boost/ptr_container/ptr_map.hpp>
38 
39 #include <boost/property_tree/ptree.hpp>
40 #include <boost/property_tree/xml_parser.hpp>
41 
42 #include <boost/math/tools/minima.hpp> // find minima using Brent's method
43 
44 /* Debugging librarys and definitions. There is only an effect if
45  * the code is compiled with PIMC_DEBUG on.*/
46 #ifdef PIMC_DEBUG
47 
49 #define BZ_DEBUG
50 
52 #define PIMC_DEBUG_MESSAGE(X)\
53 { std::cerr << "[pimc] " << __FILE__ << ": " << __LINE__ << " " << X << std::endl; }
54 
56 #define PIMC_ASSERT(X) assert(X)
57 
58 #else // !PIMC_DEBUG
59 
61 #define PIMC_DEBUG_MESSAGE(X)
62 
64 #define PIMC_ASSERT(X)
65 
66 #endif // ifdef PIMC_DEBUG
67 
68 /* We either specify the number of dimensions of the simulation at compile time,
69  * or it defaults to 1D. */
70 #ifndef NDIM
71 #define NDIM 1
72 #endif
73 
74 /* Determine if we are performing a PIGS (T=0) or PIMC (T>0) simulation */
75 #ifndef PIGS
76 #define PIGS false
77 #endif
78 
79 /* Used for getting the repo version number into the code */
80 #ifndef REPO_VERSION
81 #define REPO_VERSION "none"
82 #endif
83 
84 /* We Default to turning on the NN lookup table. Comment this line out for testing
85  * small systems where the lookup table might actually slow things down. */
86 #define NN_TABLE
87 
88 #include "MersenneTwister.h"
89 
90 #define NPCFSEP 50
91 #define NOBDMSEP 50
92 #define NRADSEP 200
93 #define NGRIDSEP 51
94 #define EPS 1.0E-7
95 #define DBL_EPS std::numeric_limits<double>::epsilon() //< Smallest double
96 #define BIG 1.0E30
97 #define LBIG 69.07755279
98 #define XXX -1
99 
100 using namespace std;
101 using namespace blitz;
102 using boost::format;
103 
105 typedef unsigned long uint32;
106 
108 typedef TinyMatrix<double,NDIM,NDIM> dMat;
109 
111 typedef TinyVector<double,NDIM> dVec;
112 
114 typedef TinyVector<int,NDIM> iVec;
115 
117 typedef TinyVector<int,2> beadLocator;
118 
120 typedef Array<int,1>::iterator intIter;
121 
123 typedef Array<int,1>::const_iterator cintIter;
124 
126 typedef Array<beadLocator,1>::iterator beadIter;
127 
129 enum beadState {HEADTAIL,SPECIAL,NONE};
130 
133 enum ensemble {DIAGONAL, OFFDIAGONAL, ANY};
134 
136 inline int ipow (int base, int power) {
137  return static_cast<int>(floor(pow(1.0*base,1.0*power) + EPS));
138 }
139 
141 template<typename Ttype>
142 inline Ttype& min(Ttype& x, Ttype& y) { return (x < y ? x : y); }
143 
145 template<typename Ttype>
146 inline Ttype& max(Ttype& x, Ttype& y) { return (x > y ? x : y); }
147 
148 #endif
Mersenne Twister random number generator.
Ttype & max(Ttype &x, Ttype &y)
Maximum of two inputs.
Definition: common.h:146
int ipow(int base, int power)
Return the integer value of a number raised to a power.
Definition: common.h:136
Array< beadLocator, 1 >::iterator beadIter
beadLocator array iterator
Definition: common.h:126
unsigned long uint32
Unsigned integer type, at least 32 bits.
Definition: common.h:105
TinyMatrix< double, NDIM, NDIM > dMat
A NDIM x NDIM matrix of type double.
Definition: common.h:108
TinyVector< int, 2 > beadLocator
time-slice,bead-number world line index
Definition: common.h:117
ensemble
Each move can operate on only the digaonal ensemble, only the off-diagonal ensemble,...
Definition: common.h:133
#define EPS
A small number.
Definition: common.h:94
Array< int, 1 >::iterator intIter
Integer array iterator.
Definition: common.h:120
beadState
Each bead can have three possible states.
Definition: common.h:129
Ttype & min(Ttype &x, Ttype &y)
Minimum of two inputs.
Definition: common.h:142
Array< int, 1 >::const_iterator cintIter
Constant integer array iterator.
Definition: common.h:123
TinyVector< double, NDIM > dVec
A NDIM-vector of type double.
Definition: common.h:111
TinyVector< int, NDIM > iVec
A NDIM-vector of type integer.
Definition: common.h:114