Path Integral Quantum Monte Carlo
Public Member Functions | Static Public Member Functions | Protected Member Functions
ConstantParameters Class Reference

Constant simulation parameters. More...

#include <constants.h>

Public Member Functions

void initConstants (po::variables_map &)
 Initialize all constants from command line, XMl and defaults. More...
 
double T () const
 Get temperature.
 
double imagTimeLength () const
 Get the extent in imaginary time.
 
double mu () const
 Get chemical potential.
 
double tau () const
 Get imaginary time step.
 
double m () const
 Get mass.
 
double lambda () const
 Get lambda = hbar^2/(2mk_B)
 
double rc () const
 Get potential cutoff.
 
double rc2 () const
 Get potential cutoff squared.
 
double C0 () const
 Get worm factor C0.
 
double C () const
 Get full worm constant.
 
double V () const
 Get cell volume.
 
double L () const
 Get maximum side length.
 
double comDelta () const
 Get center of mass shift.
 
double displaceDelta () const
 Get center of mass shift.
 
int virialWindow () const
 Get centroid virial window size.
 
double dBWavelength () const
 Get deBroglie wavelength. More...
 
double rho0Norm (int M, int d) const
 Get density matrix normalization factor.
 
double fourLambdaTauInv () const
 Get (4lambda/tau)^{-1}.
 
double attemptProb (string type)
 
void setAttemptProb (string type, double prob)
 
bool restart () const
 Get restart state.
 
bool wallClockOn () const
 Get wallclockOn.
 
uint32 wallClock () const
 Get wallclock limit.
 
bool canonical () const
 Get ensemble.
 
bool window () const
 Get window on/off.
 
bool startWithState () const
 Are we starting from a state?
 
int windowWidth () const
 Get window 1/2 width.
 
bool gaussianEnsemble () const
 Get enesemble weight on/off.
 
double gaussianEnsembleSD () const
 Get enesemble weight standard dev.
 
bool varUpdates () const
 Fixed or variable length diagonal updates.
 
int Mbar ()
 Get Mbar.
 
int b ()
 Get bisection level.
 
int numTimeSlices ()
 Get number of time slices.
 
int initialNumParticles ()
 Get initial number of particles.
 
int maxWind ()
 Get the maximum winding number sampled.
 
string id ()
 Get simulation UUID.
 
uint32 numEqSteps ()
 Get the number of equilibration steps.
 
int numBroken ()
 
double spatialSubregion ()
 
bool spatialSubregionOn ()
 
int Npaths ()
 
string intPotentialType () const
 Get interaction potential type.
 
string extPotentialType () const
 Get external potential type.
 
string waveFunctionType () const
 Get wave function type.
 
double endFactor () const
 Get end factor.
 
string actionType () const
 Get wave action type.
 
string graphenelut3d_file_prefix () const
 Get GrapheneLUT3D file prefix <prefix>_serialized.{dat|txt}.
 
double R_LL_wfn () const
 Get Lieb-Liniger length scale.
 
double k_LL_wfn () const
 Get Lieb-Liniger wave number.
 
void setmu (double _mu)
 Set the value of the chemical potential.
 
void setCoMDelta (double _comDelta)
 Set the CoM move size.
 
void setDisplaceDelta (double _displaceDelta)
 Set the displace move size.
 
void shiftC0 (double frac)
 Shift the value of C0.
 
void setC0 (double _C0)
 Set the value of C0.
 
void getC ()
 Get the value of the worm constant.
 
void shiftCoMDelta (double frac)
 Shift the CoM move size.
 
void shiftDisplaceDelta (double frac)
 Shift the displace move size.
 
void shiftmu (double frac)
 Shift the chemical potential.
 
bool saveStateFiles ()
 Are we saving states every MC bin?
 

Static Public Member Functions

static ConstantParametersgetInstance ()
 This public method returns an instance of the constant object, Only one can ever exist at a time.
 

Protected Member Functions

 ConstantParameters ()
 An empty constructor which simply sets all constants to null.
 
 ConstantParameters (const ConstantParameters &)
 Protected constructor.
 
ConstantParametersoperator= (const ConstantParameters &)
 Overload Singleton equals.
 

Detailed Description

Constant simulation parameters.

Holds a number of parameters that will need to be accessed throughout the simulation and allows their access via the singleton design pattern.

See also
http://en.wikipedia.org/wiki/Singleton_pattern

Definition at line 33 of file constants.h.

Member Function Documentation

◆ dBWavelength()

double ConstantParameters::dBWavelength ( ) const
inline

Get deBroglie wavelength.

Get deBroglie wavelength

Definition at line 58 of file constants.h.

◆ initConstants()

void ConstantParameters::initConstants ( po::variables_map &  params)

Initialize all constants from command line, XMl and defaults.

We initialize all constant parameters used in the simulation. The value of lambda = hbar^2/2 m k_B is computed in units where lenghts are measured in angstroms and energies in kelvin.

Definition at line 32 of file constants.cpp.

32  {
33 
34  /* We use boost to generate a UUID for the simulation */
35  if (params["restart"].empty()) {
36 
37  id_ = boost::uuids::to_string(boost::uuids::random_generator()());
38 
39  /* Add a possible user specified label */
40  string label_ = params["label"].as<string>();
41  if (label_.length() > 12)
42  label_ = label_.substr(0,12);
43 
44  id_.replace(id_.end()-label_.length(),id_.end(),label_);
45  restart_ = false;
46  }
47  else {
48  id_ = params["restart"].as<string>();
49  restart_ = true;
50  }
51 
52  /* Are we starting from a supplied state file? */
53  startWithState_ = !params["start_with_state"].as<string>().empty();
54 
55  /* Set the wall clock state */
56  if (params["wall_clock"].empty()) {
57  wallClockOn_ = false;
58  wallClock_ = 0;
59  }
60  else {
61  wallClockOn_ = true;
62  /* Set wallClock_ in seconds*/
63  wallClock_ = uint32( floor(params["wall_clock"].as<double>()*3600));
64  }
65 
66  /* Are we working in the grand canonical ensemble? */
67  canonical_ = !params["canonical"].empty();
68 
69  /* Are we saving a state file every bin? */
70  saveStateFiles_ = params["no_save_state"].empty();
71 
72  /* Do we want variable length diagonal updates? */
73  varUpdates_ = params["var_updates"].empty();
74 
75  /* Set the particle number window */
76  window_ = canonical_ && !params["window"].empty();
77  if (window_)
78  windowWidth_ = params["window"].as<int>();
79  else
80  windowWidth_ = 0;
81 
82  /* Set the ensemble weight */
83  gaussianEnsemble_ = canonical_ && !params["gaussian_window_width"].empty();
84  if (gaussianEnsemble_)
85  gaussianEnsembleSD_ = params["gaussian_window_width"].as<double>();
86  else
87  gaussianEnsembleSD_ = 0.0;
88 
89  /* The maximum winding number sampled */
90  maxWind_ = params["max_winding"].as<int>();
91 
92  /* Assigned values */
93  b_ = int (ceil(log(1.0*params["update_length"].as<int>()) / log(2.0)-EPS));
94 
95  /* We need to make sure b_ < numTimeSlices */
96  while (ipow(2,b_) >= params["number_time_slices"].as<int>())
97  b_--;
98 
99  /* Assigned values */
100  Mbar_ = params["update_length"].as<int>();
101  T_ = params["temperature"].as<double>();
102  imagTimeLength_ = params["imaginary_time_length"].as<double>();
103  mu_ = params["chemical_potential"].as<double>();
104  m_ = params["mass"].as<double>();
105  lambda_ = 24.24 / m_;
106  rc_ = params["potential_cutoff"].as<double>();
107  rc2_ = rc_*rc_;
108  C0_ = params["worm_constant"].as<double>();
109  numTimeSlices_ = params["number_time_slices"].as<int>();
110  if (PIGS)
111  tau_ = 1.0/((numTimeSlices_-1)*T_);
112  else
113  tau_ = 1.0/(numTimeSlices_*T_);
114  V_ = params["volume"].as<double>();
115  L_ = params["side"].as<dVec>()[NDIM-1];
116  numEqSteps_ = params["number_eq_steps"].as<uint32>();
117 
118  graphenelut3d_file_prefix_ = params["graphenelut3d_file_prefix"].as<string>();
119  virialWindow_ = params["virial_window"].as<int>();
120 
121  initialNumParticles_ = params["number_particles"].as<int>();
122  numBroken_ = params["number_broken"].as<int>();
123 
124  spatialSubregionOn_ = !params["spatial_subregion"].empty();
125  if (spatialSubregionOn_)
126  spatialSubregion_ = params["spatial_subregion"].as<double>();
127 
128  endFactor_ = params["end_factor"].as<double>();
129  Npaths_ = params["number_paths"].as<int>();
130 
131  intPotentialType_ = params["interaction"].as<string>();
132  extPotentialType_ = params["external"].as<string>();
133  waveFunctionType_ = params["wavefunction"].as<string>();
134  actionType_ = params["action"].as<string>();
135 
136  /* Computed values */
137  dBWavelength_ = 2.0*sqrt(M_PI * lambda_ / T_);
138  comDelta_ = 0.04*dBWavelength_;
139  displaceDelta_ = 0.04*dBWavelength_;
140  getC();
141 
142  /* Set the move probabilities */
143 
144  /* At present, the pigs code has only diagonal moves */
145  if (PIGS) {
146  attemptProb_["open"] = 0.0;
147  attemptProb_["insert"] = 0.0;
148  attemptProb_["close"] = 0.0;
149  attemptProb_["advance head"] = 0.0;
150  attemptProb_["recede head"] = 0.0;
151  attemptProb_["advance tail"] = 0.0;
152  attemptProb_["recede tail"] = 0.0;
153  attemptProb_["remove"] = 0.0;
154  attemptProb_["swap head"] = 0.0;
155  attemptProb_["swap tail"] = 0.0;
156  attemptProb_["diagonal"] = 0.6;
157  attemptProb_["center of mass"] = 0.1;
158  attemptProb_["displace"] = 0.0;
159  attemptProb_["end staging"] = 0.3;
160  attemptProb_["mid staging"] = 0.0;
161  attemptProb_["swap break"] = 0.0;
162  }
163  else {
164  attemptProb_["open"] = 0.4;
165  attemptProb_["insert"] = 0.4;
166  attemptProb_["close"] = 0.15;
167  attemptProb_["advance head"] = 0.075;
168  attemptProb_["recede head"] = 0.075;
169  attemptProb_["advance tail"] = 0.075;
170  attemptProb_["recede tail"] = 0.075;
171  attemptProb_["remove"] = 0.15;
172  attemptProb_["swap head"] = 0.10;
173  attemptProb_["swap tail"] = 0.10;
174  attemptProb_["diagonal"] = 0.19;
175  attemptProb_["center of mass"] = 0.01;
176  attemptProb_["displace"] = 0.0;
177  attemptProb_["end staging"] = 0.0;
178  attemptProb_["swap break"] = 0.0;
179  attemptProb_["mid staging"] = 0.0;
180  }
181 
182  double totProb = attemptProb_["close"] + attemptProb_["advance head"] + attemptProb_["recede head"]
183  + attemptProb_["advance tail"] + attemptProb_["recede tail"] + attemptProb_["remove"]
184  + attemptProb_["swap head"] + attemptProb_["swap tail"] + attemptProb_["diagonal"]
185  + attemptProb_["center of mass"] + attemptProb_["displace"] + attemptProb_["end staging"]
186  + attemptProb_["mid staging"]+attemptProb_["swap break"];
187 
188  if (abs(totProb - 1.0) > EPS) {
189  cout << "Close + AdvanceHead + RecedeHead + AdvanceTail + RecedeTail + Remove + SwapHead "
190  << "+ SwapTail + Diagonal + CoM Probability != 1" << endl;
191  cout << totProb << endl;
192  exit(EXIT_FAILURE);
193  }
194  PIMC_ASSERT(totProb-1.0 < EPS);
195 
196  totProb = attemptProb_["open"] + attemptProb_["insert"] + attemptProb_["diagonal"]
197  + attemptProb_["center of mass"] + attemptProb_["displace"] + attemptProb_["swap break"]
198  + attemptProb_["end staging"] + attemptProb_["mid staging"];
199 
200  if (abs(totProb - 1.0) > EPS) {
201  cout << "Open + Insert + Diagonal + CoM Probability != 1" << endl;
202  cout << totProb << endl;
203  exit(EXIT_FAILURE);
204  }
205  PIMC_ASSERT(totProb-1.0 < EPS);
206 }
void getC()
Get the value of the worm constant.
Definition: constants.h:128
#define NDIM
Number of spatial dimnsions.
Definition: common.h:71
int ipow(int base, int power)
Return the integer value of a number raised to a power.
Definition: common.h:136
unsigned long uint32
Unsigned integer type, at least 32 bits.
Definition: common.h:105
#define EPS
A small number.
Definition: common.h:94
TinyVector< double, NDIM > dVec
A NDIM-vector of type double.
Definition: common.h:111
#define PIMC_ASSERT(X)
Rename assert method.
Definition: common.h:64
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: