Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

196 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HMC for the Schwinger model

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 $(DD^\dagger)^{-1}$. For an OpenMP implementation check the OpenMP branch.

The code generates gauge configurations in a binary format, with the following structure:

$$ (x, t, \mu, \mathrm{Re}(U_\mu(t,x)), \mathrm{Im}(U_\mu(t,x))) $$

Here $\mu=0$ denotes the time direction and $\mu=1$ denotes the spatial direction. Check HMC_doc.pdf for details of the HMC formulation in this model.


Requirements

  • CMake
  • C++ compiler
  • MPI implementation (OpenMPI, MPICH, etc.)
  • Linux or Windows with a compatible toolchain

Build the project

Create a build directory:

mkdir build
cd build

Then 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.


Run the simulation

Execute the program with MPI:

mpirun -n <number_of_cores> ./SM_NSxNT

The 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

Parameter descriptions

  • ranks_x and ranks_t: number of MPI ranks in the $x$ and $t$ directions. The total number of processes is ranks_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 to 1 to write configurations to disk, or 0 to skip writing them.

Notes on tuning

The molecular dynamics steps and trajectory length must be tuned to achieve a good acceptance rate, typically between $0.6$ and $0.8$. This indicates a reasonable level of decorrelation between configurations.

For many simulations, a reasonable starting point is:

  • MD steps = 10
  • trajectory 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.


Critical mass values

The bare mass parameter must remain above the critical mass to avoid unphysical configurations. The critical values for various $\beta$ are:

$\beta$ $-m_{\mathrm{crit}}$
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).


Output files

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.sh

This script shows how the program can be compiled and executed in practice.


Converting binary configurations to text

The repository includes a helper script and a C++ converter:

  • readBinConf.cpp
  • readBin.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.


Windows

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.exe

The exact compiler and generator flags may vary depending on your setup.


Repository structure

.
├── 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

Troubleshooting

MPI errors

If CMake or the runtime reports missing MPI libraries, check that MPI is installed and that your compiler environment is configured properly.

Wrong lattice dimensions

If the simulation or conversion code does not match the configuration files, verify the lattice dimensions in CMakeLists.txt and in readBinConf.cpp.

Acceptance rate is too low

If the acceptance rate is poor, reduce the trajectory length or increase the number of molecular dynamics integration steps.

Missing or corrupted output

Check the save flag in the simulation input and confirm that the process has write permissions in the working directory.


References

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.

About

Two-flavor Schwinger model simulated with HMC. C++ implementation. Documentation explaining the Hybrid Monte Carlo included.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages