Skip to content

Overview and Structure

Andrea Rucci edited this page Jan 31, 2018 · 29 revisions

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 struct PIMCParams which is a container of all the parameters needed by the program which are read from the init 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 class Path. 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 geometry

    first 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 function get_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 as get_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 the init 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 the init file in the struct PIMCParams. Then, it creates the Path which will be used in the simulation and initialize it as specified; it binds the potentials selected from potential.* 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 function update_path() which implements the Metropolis step repeated over all the configuration and modifies the Path 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 the PIMCClass 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 the init file and will print the outputs. For starters, it reads the parameters and check their integrity, defining a PIMCparams structure, and hence a PIMCClass is created and initialized. Then, the simulation starts: a loop with MCsteps iterations will update the initial configuration, while each MCeach steps the configuration, the action and the acceptance are printed, respectively, to the outfiles confs, meas and accpt.

Clone this wiki locally