-
Notifications
You must be signed in to change notification settings - Fork 0
Overview and Structure
The code is structured so that it should be (I hope) very easy to see what's going on. In the directory src/
there is the main code 1d_pimc.cc
and the needed *.cc
libraries, while the required corresponding headers are placed in the include
directory. Final executable file will compiled by the makefile
and put into the bin
folder. The data
directory is intended to contain both the init
file needed by the simulation program as well the outputs that will be produced. Here the structure:
├── 1d_pimc
├── LICENSE.txt
├── makefile
├── README.md
├── bin
│ └── 1d_pimc
├── src
│ ├── 1d_pimc.cc
│ ├── iostruct.cc
│ ├── pathclass.cc
│ ├── pimcclass.cc
│ └── potentials.cc
├── include
│ ├── iostruct.h
│ ├── pathclass.h
│ ├── pimcclass.h
│ └── potentials.h
└── data
└── init
Now lets comment briefly the single parts of the code, so that at the end it will be clear how the main program works and uses all the ingredients.
-
iostruct.*
files contain the definition of the structPIMCParams
which is a container of all the parameters needed by the program which are read from theinit
file. The program provides also some simple routines allowing to manage the parameters, check the integrity and correctness of its values or print on screen. -
pathclass.*
defines the actual path of the system, represented by a classPath
. The core member is the configuration path which is essentially a one-dimensional array of dimension Np*Nt where Np is the number of particles and Nt the number of imaginary time slices. Elements of the path, e.g. the position x_i^j of a certain particle j in the time slice i, are accessed or modified by using a superindex n that unpacks the configuration array which have the following geometryfirst particle second last particle | | | [x_0^0, x_1^0, ..., x_(Nt-1)^0, x_0^1, ..., x_0^(Np-1), ..., x_(Nt-1)^(Np-1)]
i.e. the single particle paths are appendend one ofter the other. The class
PIMCParams
contains also useful functions allowing to access and modify the path values. For example, the member functionget_next_timeslice(int n)
returns the timeslice next to that corresponding to the n position, using periodic boundary conditions as required by the PIMC. In the same way one can ask the distance between a particles and its right or left neighbor, or the index of it, using member function such asget_right_distance(int n)
and so on. -
potentials.*
contain the definitions of the potentials of the actions, one-particle (trap or external fields) or two-particle (interaction terms). Potentials added here are selected by theinit
file and the functions are binded through two wrappers which return the actual potential used in the simulation as a function of one variable (the particle position in the one-particle term) or two (the interaction term that needs the position of the two interacting particles). More details on this and how to add new potential are reported in the Setting Potentials section of this Wiki. -
pimcclass.*
is the core of the MC simulation code. It is a class which takes as argument the parameters read from theinit
file in the structPIMCParams
. Then, it creates thePath
which will be used in the simulation and initialize it as specified; it binds the potentials selected frompotential.*
and prepare the random number generator that will be used in the MC. The class contains member functions that compute the contributes the action summing the kinetic term contribution and the potentials. Once the system is prepared, the MC simulation can be performed via the member functionupdate_path()
which implements the Metropolis step repeated over all the configuration and modifies thePath
with the new values. The update is performed by splitting the even and odd time-slices so that it is possible to parallelize it in a thread-safe way (see the Running the Simulation section of this Wiki). With thePIMCClass
it is also possible to get the value of the action of a configuration and the local acceptance of the MC step, in order to check and control the simulation. -
1d_pimc.cc
is the main code. It takes as command-line argument the working directory in which the program must read theinit
file and will print the outputs. For starters, it reads the parameters and check their integrity, defining aPIMCparams
structure, and hence aPIMCClass
is created and initialized. Then, the simulation starts: a loop withMCsteps
iterations will update the initial configuration, while eachMCeach
steps the configuration, the action and the acceptance are printed, respectively, to the outfilesconfs
,meas
andaccpt
.