This project implements an MPI-parallel Monte Carlo simulation of the two-flavor Schwinger model using a Hybrid Monte Carlo (HMC) algorithm. The simulation uses Wilson fermions, pseudofermions, and a conjugate-gradient solver to invert
The code generates gauge configurations in a binary format, with the following structure:
Here
- CMake
- C++ compiler
- MPI implementation (OpenMPI, MPICH, etc.)
- Linux or Windows with a compatible toolchain
Create a build directory:
mkdir build
cd buildThen configure and build:
cmake ..
cmake --build .This produces an executable named SM_NSxNT (or a name defined in CMakeLists.txt). The lattice dimensions are fixed in CMakeLists.txt, so you should edit them there before building.
Execute the program with MPI:
mpirun -n <number_of_cores> ./SM_NSxNTThe program will prompt for the simulation parameters. A typical example is:
----------------------------
| Two-flavor Schwinger model |
| Hybrid Monte Carlo simulation |
----------------------------
Nx NS Nt NT
ranks_x: number of processes on the x direction
ranks_t: number of processes on the t direction
m0: 0
Molecular dynamics steps: 10
Trajectory length: 1
beta: 2
Thermalization: 1000
Measurements: 1000
Step (sweeps between measurements): 10
Save configurations yes/no (1 or 0): 1
-
ranks_xandranks_t: number of MPI ranks in the$x$ and$t$ directions. The total number of processes isranks_x * ranks_t. - The lattice dimensions must be divisible by the corresponding rank count, so the workload is balanced across processes.
-
m0: bare mass parameter. -
Molecular dynamics steps: number of leapfrog integration steps. -
Trajectory length: integration length in lattice units. -
beta: inverse gauge coupling. -
Thermalization: number of configurations discarded before measurements begin. -
Measurements: number of configurations used for measurements. -
Step: number of sweeps discarded between saved measurements. -
Save configurations: set to1to write configurations to disk, or0to skip writing them.
The molecular dynamics steps and trajectory length must be tuned to achieve a good acceptance rate, typically between
For many simulations, a reasonable starting point is:
MD steps = 10trajectory length = 1.0
Close to the critical mass, longer runs and careful tuning are often required. Increasing the MD steps typically increases the cost of each trajectory.
The bare mass parameter must remain above the critical mass to avoid unphysical configurations. The critical values for various
| 1 | 0.3204(7) |
| 2 | 0.1968(9) |
| 3 | 0.1351(2) |
| 4 | 0.1033(1) |
| 5 | 0.0840(1) |
| 6 | 0.0719(1) |
These values are from the literature and are useful as a guide when choosing a physical mass parameter. See N. Christian, K. Jansen, K. Nagai and B. Pollakowski. “Scaling test of the fermion actions in the Schwinger Model”, Nucl. Phys. B, 739, (2006).
Configurations are stored in binary format. After a successful run, the simulation produces gauge configurations and a summary file such as _SimData.txt.
To convert the binary gauge configurations to a human-readable text format, compile and run readBinConf.cpp. You may need to update the lattice dimensions inside that source file before conversion.
A simple convenience script is provided:
./run.shThis script shows how the program can be compiled and executed in practice.
The repository includes a helper script and a C++ converter:
readBinConf.cppreadBin.sh
The script compiles the converter and reads a binary configuration file. The output is written in the form:
x, t, mu, Re(U_mu), Im(U_mu)
This is useful for inspecting or post-processing saved gauge configurations.
The build steps are similar on Windows. The main difference is that the CMake configuration must point to the correct C and C++ compiler paths.
For example, with MinGW:
cmake -G "MinGW Makefiles" \
-DCMAKE_CXX_COMPILER=C:\msys64\ucrt64\bin\g++ \
-DCMAKE_C_COMPILER=C:\msys64\ucrt64\bin\gcc \
..Then build the project and run the generated executable:
SM_NSxNT.exeThe exact compiler and generator flags may vary depending on your setup.
.
├── CMakeLists.txt
├── README.md
├── run.sh
├── readBin.sh
├── readBinConf.cpp
├── include/
│ ├── config.h
│ ├── conjugate_gradient.h
│ ├── dirac_operator.h
│ ├── gauge_conf.h
│ ├── hmc.h
│ ├── mpi_setup.h
│ ├── statistics.h
│ └── variables.h
├── src/
│ ├── conjugate_gradient.cpp
│ ├── dirac_operator.cpp
│ ├── gauge_conf.cpp
│ ├── hmc.cpp
│ ├── main.cpp
│ ├── statistics.cpp
│ └── variables.cpp
├── build/
└── data files and output logs
If CMake or the runtime reports missing MPI libraries, check that MPI is installed and that your compiler environment is configured properly.
If the simulation or conversion code does not match the configuration files, verify the lattice dimensions in CMakeLists.txt and in readBinConf.cpp.
If the acceptance rate is poor, reduce the trajectory length or increase the number of molecular dynamics integration steps.
Check the save flag in the simulation input and confirm that the process has write permissions in the working directory.
For more background on the physics and the algorithm, see the project documentation and the cited work on scaling tests of fermion actions in the Schwinger model.