Path Integral Quantum Monte Carlo
This program implements the Worm Algorithm Path Integral Quantum Monte Carlo (WA-PIMC) technique introduced in M. Boninsegni, N. V. Prokofiev, and B. Svistunov, Phys. Rev. E 74, 036701 (2006). It can be used to simulate indistinguishable bosons with various types of realistic interactions in one, two and three spatial dimensions. As written, it takes a large number of command line options and allows for the measurement of essentially any physical observable of interest.
The design philosophy included the goal of abstracting the actual implementation of the WA-PIMC method to a kernel that will never need to be touched by the end user. The code can be easily extended to study a wide variety of situations by including new types of containers, potentials estimators and communicators.
If you have questions, bug reports or plan to use this code for scientific research, please contact me at Adria.email@example.com.De.firstname.lastname@example.orgMaes.email@example.com@.firstname.lastname@example.org@m.du.
This program has been successfully compiled and run on both Intel and AMD systems using g++, pathscale and icpc. Before installing, one needs to ensure that all dependencies are met. We recommend that the required libraries (boost and blitz) are installed in a
local folder inside your home directory:
We use many of the boost header-only libraries, but two libraries will need to be compiled: boost_program_options and boost_filesystem libraries. Let us assume that you will be installing both blitz and boost in the folder
$HOME/local using the GNU C++ compiler. For icpc or clang, the changes should be obvious, and in particular for the Intel compiler you will need to use
intel-linux as the toolset.
If you don't have a
$HOME/local you should create this directory now via
Unless you need to use the blitz++'s internal debug functionality initiated through #
define BZ_DEBUG which is set by including
debug=1 when compiling the path integral code, blitz can be used as a 'header only' library and does not need to be compiled. This is the most common use case. However, as it doesn't take very long to compile one can proceed as follows:
INSTALLfile to determine if there is anything special you need to do on your system.
./configure cxx=g++ --prefix=PREFIX make lib make install
PREFIXis the location you want to install the libraries, we suggest
$HOMEis your expanded home directory.
Note: If attempting to compile the old version of blitz-0.9 with gcc version 4.3 or later you may encounter errors when attempting to build blitz++. To fix this, before issuing
make lib and/or
make install one needs to add headers to a couple of files. Move to
$HOME/local/src/blitz-0.9/blitz (or similarly,
PREFIX/src/blitz-0.9/blitz) and add the line
to the top of the files
mathfunc.h and save.
For detailed instructions on installing boost with compiled libraries please see Section 5.2 of the official Boost documentation.
tools/build/inside the boost source directory
tools/build/v2/b2 install --prefix=PREFIX --toolset=gcc cxxflags=-std=c++11 linkflags=-std=c++11 --with-program_options --with-filesystem
b2executable may also be in
tools/build/bin/depending on your machine's configuration. If you would like to compile boost with different compilers on your machine and would like to enforce a detailed labelling scheme for the libraries include
b2above. See here for more detail. You may also need to add
-stdlib=libc++to the linkflags when compiling for clang.
PREFIX/includedirectory containing the header files for
PREFIX/libdirectory will contain the following files (the
.dylibfiles will only appear on Mac OS X)
libblitz.a libboost_filesystem.a libboost_program_options.a libboost_system.a libblitz.la libboost_filesystem.dylib libboost_program_options.dylib libboost_system.dylib
DYLD_LIBRARY_PATHon Mac OS X) variable inside your
After successfully installing blitz and boost you are now ready to compile the main pimc program on your system. There are currently four makefiles available:
Makefile.path. We only include details of compiling with
g++ here. For other machines, clusters or architectures, please read the details in the makefiles.
In order to compile with g++:
Makefile.g++, find the comment:
Edit below to include details on your specific host
ifdef target OPT = -Wall -O3 -fno-math-errno BOOSTVER = CODEDIR = $$HOME/local CFLAGS = $(OPT) $(DIM) $(DEBUG) -I$(CODEDIR)/include LDFLAGS = -L$(CODEDIR)/lib $(LDEBUG) -lboost_program_options$(BOOSTVER) -lboost_filesystem$(BOOSTVER) -lboost_system$(BOOSTVER) endif
targetis replaced with a unique identifier for your machine. If you want to run blitz in debug mode you will need to explicitly link to the blitz library with
CODEDIRvariable to point to the location where you have installed blitz and boost above. We suggest
OPTvariable to reflect yoru local compile options.
--layout=versionedcommand above and you have multiple versions installed on your machine, you may need to append the particular version you want to link to in the names of the boost libraries. This is most easily done by updating the
BOOSTVARvariable in your Makefile:
BOOSTVER = -gcc42-mt-1_49where here we have compiled boost v1.49 with gcc v4.2. This will need to be updated for your particular configuration.
debug=1turn on debugging options
ndim=1,2,3the number of spatial dimensions
target=1compile for host
make -f Makefile.g++ ndim=3 target=1
If you run into problems, failures with linking etc., common errors may include not properly setting your
LD_LIBRARY_PATH or not starting from a clean build directory (issue
make -f Makefile.g++ clean).
In order to get a quick idea of the options which the code accepts type:
The code requires various combinations of these options to run, and the help message should give you an idea about which ones are mandatory.
If you want to perform a quick test-run for bulk helium you could try something like:
./pimc.e -T 5 -N 16 -n 0.02198 -t 0.01 -M 8 -C 1.0 -I aziz -X free -E 10000 -S 20 -l 7 -u 0.02 --relax
In order for this to work, you will need a folder named
OUTPUT in the directory where you type the command as it will produce output files in
OUTPUT that contain all the results of the code. Each run of the code is associated with a unique identifying integer: the
PIMCID. The options used in this demo include a subset of all the possible options:
|temperature in kelvin|
|number of particles|
|density in Å-ndim (ndim=spatial dimension)|
|the imaginary time step tau|
|number of time slices involved in a bisection move|
|worm prefactor constant|
|number of equilibration steps|
|number of production bins to output|
|potential cutoff length in Å|
|chemical potential in kelvin|
|adjust the worm constant to ensure we are in the diagonal ensemble ~75% of the simulation|
|the number of configurations to be stored to disk|
|process or cpu number|
|restart the simulation with a PIMCID|
|the wall clock run limit in hours|
|supply a gce-state-* file to start the simulation from|
|number of imaginary time slices|
|size of the center of mass move in Å|
|size of the single slice displace move in Å|
|mass of the particles in AMU|
|the type of simulation cell|
|linear system size in Å|
|scattering length in Å|
|strength of the integrated delta function interaction|
|linear system size in the x-direction Å|
|linear system size in the y-direction in Å|
|linear system size in the z-direction in Å|
|the type of effective action used in the simulation|
|restrict to the canonical ensemble|
|the particle number window for restricting number fluctuations in the canonical ensemble|
|the imaginary time extent in K-1|
|the type of trial wavefunction|
|output the spatial dimension that the code was compiled with|
|perform a simulation at T = 0 K|
|The maximum winding sector to be sampled. Default=1|
|Use staging instead of bisection for diagonal updates.|
All options, including lists of possible values and default values can be seen by using the
The output of the above command should yield:
[PIMCID: XXXXXXXXX] - Equilibration Stage. 0.66 1.00000 0.95000 16 0.021980 0.53 0.95000 0.85500 12 0.016485 0.56 0.85500 0.76950 14 0.019233 0.69 0.76950 0.73102 15 0.020606 0.63 0.73102 0.69447 15 0.020606 0.69 0.69447 0.65975 17 0.023354 0.82 0.65975 0.65975 18 0.024728 0.85 0.65975 0.69274 18 0.024728 0.75 0.69274 0.65810 16 0.021980 0.65 0.65810 0.62520 16 0.021980 0.62 0.62520 0.59394 15 0.020606 0.63 0.59394 0.56424 14 0.019233 0.70 0.56424 0.53603 17 0.023354 0.76 0.53603 0.53603 18 0.024728 0.75 0.53603 0.50923 16 0.021980 0.78 0.50923 0.50923 18 0.024728 [PIMCID: XXXXXXXXX] - Measurement Stage. [PIMCID: XXXXXXXXX] - Bin # 1 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 2 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 3 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 4 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 5 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 6 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 7 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 8 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 9 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 10 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 11 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 12 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 13 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 14 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 15 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 16 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 17 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 18 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 19 stored to disk. [PIMCID: XXXXXXXXX] - Bin # 20 stored to disk. [PIMCID: XXXXXXXXX] - Measurement complete.
during the relaxation process where
PIMCID will be replaced with an integer and 20 measurements will be output to disk. To analyze the results the code, you will need to obtain a number of python programs located in a
SCRIPTS directory which can be obtained via:
svn checkout --username=SVNID http://svn.delmaestro.org/projects/SCRIPTS/ $HOME/local/pimcscripts
Which will place them in a folder
pimcscripts in your
$HOME/local/ directory. Many of these depend on some general utility modules that should be added to this directory on your local machine.
svnIDwith your svn username)
svn export --username=svnID http://svn.delmaestro.org/pyutils/pyutils.py svn export --username=svnID http://svn.delmaestro.org/pyutils/loadgmt.py svn export --username=svnID http://svn.delmaestro.org/pyutils/kevent.py
.bashrcas you will use these scripts extensively. In order to take advantage of many of the plotting options you will need to have various python libraries installed such as Matplotlib. For the extra color options you will need to download and install the gradient files from CPT-City
After this has been completed, you can analyze the results of your run via
python $HOME/local/pimcsripts/pimcave.py OUTPUT/gce-estimator-05.000-008.996-+000.020-0.01000-XXXXXXXXX.dat
XXXXXXXXX needs to be replaced with the unique identifier generated on your machine. The results should yield something like:
# PIMCID: XXXXXXXXX # Number Samples 20 K 332.92686 15.77642 V -438.56116 19.73930 E -105.63430 14.58256 E_mu -105.97187 14.58693 K/N 19.65034 0.70454 V/N -25.71091 0.67103 E/N -6.06056 0.80983 N 16.87850 0.34935 N^2 287.46950 11.62243 density 0.02319 0.00048 diagonal 0.77904 0.01467
The basic idea of running the program is that one needs to setup the simulation cell, by defining either its specific geometry via the size (
L) flag, or by a combination of density (
n) and number of particles (
N). At present, two types of simulation cells are possible, a hypercube in 1,2 or 3 dimensions with periodic boundary conditions and a cylinder in 3 dimensions, that is obtained by defining a radius (
r). One then needs to setup the details of the simulation, including the temperature (
T), chemical potential (
u), interaction (
I) and external (
X) potential. The simulation details are then set via the imaginary time step (
t), worm parameter (
C) and number of equilibration (
E) steps and production output bins (
S). A more detailed grasp of all possible program options can be obtained by reading the main driver file
The results of running the code are a number of data, state and log files that reside in the
OUTPUT directory. If the code is run for the cylinder geometry, there will be an additional copy of the files in
OUTPUT/CYLINDER which contain measurements that have been restricted to some cutoff radius indicated by including the
w flag when running. The generic output files are:
|The main estimator file. Includes binned averages of various non-vector estimators like the energy and density of particles.|
|The log file, which includes all the details of the simulation (including the command needed to restart it) and details on acceptance and output.|
|The number probability distribution|
|The one body density matrix|
|The pair correlation function|
|The permutation cycle distribution|
|The radial density|
|The state file (used to restart the simulation)|
|Contains all superfluid estimators|
|Contains details on the worm|
Each line in either the scalar or vector estimator files contains a bin which is the average of some measurement over a certain number of Monte Carlo steps. By averaging bins, one can get the final result along with its uncertainty via the variance.
A full understanding of this path integral Monte Carlo code requires an understanding of the WA-PIMC algorithm alluded to in the introduction. In this section, we describe the large building blocks of the code. The actual specific details of the implementation can be understood by reading the doxygen documentation included here as well as reading the actual source code.
Any Monte Carlo simulation whether quantum or classical shares a number of features in common. Some type of simulation cell is created with a set of parameters that describe its physical environment. The initial state of the system is guessed, and a series of Moves are performed on the constituents of the system in such a way that detailed balance is maintained. After some suitable equilibration period, measurements are made and their results are stored to disk.
As discussed above, the driver file for this PIMC program is called pdrive.cpp. It takes a series of command line options, which are used by the Setup class to initialize ConstantParameters, Container, LookupTable and Communicator objects. Next, a Potential object is created which describes the potential environment (any walls etc.) and the interactions between bosons. A Path object is then instantiated which holds all the details of the actual world lines of the quantum particles. An Action object is created based on the Potential which holds an approximation of the action to be discretized in the path integral decomposition of the partition function. Finally, the main operating object of the program, of type PathIntegralMonteCarlo is created, which requires both the Path and the Action. This object performs the actual simulation via a series of Moves, all of which generate trial world line configurations that exactly sample the kinetic part of the density matrix. All measurements are made via specific Estimators with the results being output to disk.
The main kernel of this program should remain relatively untouched, as it has been extensively tested and optimized. Generality can come from modifying just a few things. For example, in order to implement a new type of measurement, one would need to write a derived Estimator class along with modifying the Communicator class to define an output path. New types of particles and external environments can be added by adding new Potential then updating Setup to allow for their specification at the command line. Finally, radically different systems can be studied by modifying the Container class.