C++ implementation of the Creutz demon algorithm applied to the 2D Ising spin lattice.
The project studies the thermodynamic behavior of a 2D Ising system using a microcanonical Monte Carlo simulation and analyzes energy histograms, magnetization, and temperature dependence.
📄 Note: The full report (sprawozdanie) is written in Polish and available in the file Sprawozdanie.pdf.
This project implements the Creutz demon algorithm for the two-dimensional Ising model.
It allows simulation of spin interactions on a lattice and analysis of phase transition behavior near the critical temperature.
The algorithm introduces an auxiliary variable — the demon — that exchanges energy with the system while keeping total energy constant, enabling a microcanonical ensemble simulation.
- Language: C++17
- Environment: CLion 2024.3.4 (JetBrains)
- Compiler: GCC
- Key libraries:
<vector>,<map>,<random>,<cmath>,<fstream>,<iostream>,<filesystem>
The program reads input parameters from stdin or a file and generates:
histogram/– energy distribution of the demon (E_demon,N(E),ln(N))magnetization/– time evolution of magnetization during Monte Carlo sweepsmT.txt– summary file containing demon energy, temperature, average magnetization ⟨m⟩, and slope of the energy distribution
Example input format: Lx Ly numSweeps numEnergies E_demon_1 E_demon_2 ... E_demon_N
37 37 10000 10 56 128 256 512 768 960 1112 1280 1400 1520
After the simulation, the program generates:
| File | Description |
|---|---|
mT.txt |
Table of results: demon energy, temperature, ⟨m⟩, slope |
histogram/histogram_E=...txt |
Histogram of demon energy |
magnetization/magnetization_E=...txt |
Magnetization as a function of Monte Carlo steps |
- The simulation reproduces the expected phase transition in the 2D Ising model.
- The computed critical temperature was T_c^(sim) ≈ 2.3237 J/kB
- The magnetization ⟨m⟩ decreases sharply near the critical point, showing a clear transition from the ferromagnetic to the paramagnetic phase.
The complete analysis, theoretical background, methodology, and discussion of results are presented in the Polish-language report:
📘 DemonCreutz.pdf
CreutzIsing2D/
├── main.cpp # Source code
├── Sprawozdanie.pdf # Full Polish report
├── mT.txt # Summary results file
├── histogram/ # Energy distribution data
├── magnetization/ # Magnetization over MC sweeps
├── report_latex/ # LaTeX source files
│ ├── main.tex
│ ├── bibliography.bib
│ ├── histogramLin.png
│ ├── HistogramLog.png
│ ├── magnetization1000.png
│ ├── magnetyzacjaALL.png
│ └── mT.png
└── README.md
The full Polish report was written in LaTeX and is available in the /report_latex directory.
Created for educational purposes by Avui.