A high-performance C implementation of 1D, 2D, and 3D Ising model simulations using Monte Carlo methods with the Metropolis algorithm.
The Ising model is a mathematical model of ferromagnetism in statistical mechanics, used to study phase transitions and critical phenomena. This implementation provides:
- 1D Ising Model (
ising1d.c): One-dimensional chain with periodic boundary conditions - 2D Ising Model (
ising2d.c): Two-dimensional square lattice with periodic boundary conditions - 3D Ising Model (
ising3d.c): Three-dimensional cubic lattice with periodic boundary conditions - Finite-Size Scaling Analysis: FSS tools with Binder cumulant for 2D and 3D critical temperature determination
- Modern PCG Random Number Generator: Fast, high-quality random numbers for Monte Carlo sampling
- Comprehensive Test Suite: Validates random number generation and physics
- ๐ High Performance: Optimized C code with modern PCG random number generator
- ๐ฌ Physics Accurate: Proper Metropolis algorithm implementation
- ๐ Complete Analysis: Calculates magnetization, energy, susceptibility, and heat capacity
- โ Well Tested: Comprehensive test suite for reliability
- ๐ Temperature Sweeps: Automatic temperature sweeping from T=3.01 to T=0.01
make allmake test# 1D Ising model with 100 spins
./ising1d 100
# 2D Ising model with 50ร50 lattice
./ising2d 50
# 3D Ising model with 20ร20ร20 lattice
./ising3d 20All programs take the system size as a command line argument:
# 1D: N spins
./ising1d N
# 2D: NรN lattice
./ising2d N
# 3D: NรNรN lattice
./ising3d NBoth programs output tab-separated values for each temperature point:
Temperature Magnetization Energy Susceptibility Heat_Capacity
3.010000 0.355721 -0.642628 0.227735 0.396727
3.000000 0.356154 -0.644540 0.228632 0.397261
...
- Temperature Range: T = 3.01 โ 0.01 (step = 0.01)
- Thermalization: 200,000 Monte Carlo steps
- Measurement: 200,000 Monte Carlo steps
- Units: Natural units (J = 1, k_B = 1)
- Boundary Conditions: Periodic
This implementation uses PCG (Permuted Congruential Generator), replacing the original closed-source Mersenne Twister dependency:
- โ Faster than Mersenne Twister
- โ Better statistical properties
- โ Open source and widely adopted
- โ Default in NumPy (since 2019)
- โ Perfect for Monte Carlo simulations
The pcg_random.h header provides these functions:
init_rnd(seed): Initialize with seeddrnd(): Generate random double in [0,1)gus(): Generate seed from current time
The Ising model consists of discrete variables (spins) that can be in one of two states (+1 or -1). The Hamiltonian is:
H = -J ฮฃ s_i s_j
Where the sum is over nearest neighbors, J is the coupling constant (J=1 in our units), and s_i are the spin variables.
We use the Metropolis algorithm:
- Choose a random spin
- Calculate energy change ฮE if flipped
- Accept flip if:
- ฮE < 0 (energetically favorable), OR
- Random number < exp(-ฮE/T) (thermal fluctuation)
- Magnetization: M = |โจฮฃ s_iโฉ| / N
- Energy: E = โจHโฉ / N
- Susceptibility: ฯ = (โจMยฒโฉ - โจMโฉยฒ) / T
- Heat Capacity: C = (โจEยฒโฉ - โจEโฉยฒ) / Tยฒ
- 1D Ising: No finite-temperature phase transition (T_c = 0)
- 2D Ising: Critical temperature T_c โ 2.269 (exact: 2/ln(1+โ2))
- 3D Ising: Critical temperature T_c โ 4.51 (from high-precision simulations)
make testThe test suite validates:
- PCG random number generator quality and reproducibility
- Physics correctness (high-T โ low magnetization, low-T โ high magnetization)
- 1D, 2D, and 3D model functionality
- Binder cumulant calculation accuracy
# Quick 1D test
make test-1d
# Quick 2D test
make test-2d
# Performance benchmark
make benchmark- 1D: O(N) per Monte Carlo step
- 2D: O(Nยฒ) per Monte Carlo step
- 3D: O(Nยณ) per Monte Carlo step
- Memory: O(N) for 1D, O(Nยฒ) for 2D, O(Nยณ) for 3D
- 1D: N = 100-10000 (fast)
- 2D: N = 10-100 (N=100 takes ~hours)
- 3D: N = 10-30 (N=30 takes ~hours)
- Use smaller systems (N < 50) for 2D when testing
- Use even smaller systems (N < 20) for 3D when testing
- For production runs, consider running overnight for large 2D/3D systems
- The code is already optimized with
-O2compilation
The repository includes finite-size scaling (FSS) analysis tools to precisely determine the critical temperature T_c of the 2D and 3D Ising models using the Binder cumulant crossing method.
The Binder cumulant is defined as:
U_L = 1 - <Mโด> / (3<Mยฒ>ยฒ)
This dimensionless quantity has a remarkable property: at the critical temperature T_c, the Binder cumulant becomes independent of system size. When plotted against temperature for different system sizes L, all curves cross at a single pointโthe critical temperature.
# Compile the 2D FSS version
gcc -Wall -Wextra -Wpedantic -o ising2d_fss ising2d_fss.c -lm
# Run simulation (this will take several hours)
./ising2d_fss > fss_data.txt
# Generate plots
python3 plot_binder.py# Compile the 3D FSS version
gcc -Wall -Wextra -Wpedantic -o ising3d_fss ising3d_fss.c -lm
# Run simulation (this will take several hours)
./ising3d_fss > fss_data_3d.txt
# Generate plots
python3 plot_binder_3d.py- System Sizes: L = 8, 16, 24, 32, 48, 64
- Temperature Range: T = 2.6 โ 1.9 (focused near T_c โ 2.269)
- Temperature Resolution: ฮT = 0.005 (finer than basic simulation)
- Thermalization: 200,000 Monte Carlo steps per temperature
- Measurement: 200,000 Monte Carlo steps per temperature
- System Sizes: L = 4, 6, 8, 10, 12, 16
- Temperature Range: T = 5.5 โ 3.5 (focused near T_c โ 4.51)
- Temperature Resolution: ฮT = 0.02
- Thermalization: 200,000 Monte Carlo steps per temperature
- Measurement: 200,000 Monte Carlo steps per temperature
- Note: Smaller system sizes due to O(Nยณ) scaling
The 2D analysis generates two plots:
- binder_crossing.png: Binder cumulant crossing plot
- Shows all system sizes crossing at T_c โ 2.269
- Includes zoomed view near the critical point
- fss_complete_analysis.png: Complete finite-size scaling analysis
- Magnetization vs temperature for all L
- Energy vs temperature for all L
- Susceptibility vs temperature for all L
- Heat capacity vs temperature for all L
The 3D analysis generates two plots:
- binder_crossing_3d.png: Binder cumulant crossing plot for 3D
- Shows all system sizes crossing at T_c โ 4.51
- Includes zoomed view near the critical point
- fss_complete_analysis_3d.png: Complete 3D finite-size scaling analysis
- All thermodynamic quantities vs temperature for all L
- Shows critical exponents: ฮฒ โ 0.326, ฮณ โ 1.237, ฮฝ โ 0.630
The FSS simulation outputs tab-separated values:
N Temperature Magnetization Energy Susceptibility Heat_Capacity Binder_Cumulant
8 2.600000 0.123456 -0.987654 1.234567 0.876543 0.456789
...
- Crossing Point: The temperature where all Binder cumulant curves intersect is the critical temperature T_c
- Finite-Size Effects: Larger systems show sharper transitions near T_c
- Critical Value: The Binder cumulant at T_c approaches U* โ 0.610 (universal value for 2D Ising)
- Exact T_c: The 2D Ising model has T_c = 2/ln(1+โ2) โ 2.269185... (Onsager's exact solution)
- Crossing Point: All Binder cumulant curves intersect at T_c โ 4.51
- Different Universality Class: 3D Ising belongs to a different universality class than 2D
- Critical Exponents: ฮฒ โ 0.326, ฮณ โ 1.237, ฮฝ โ 0.630 (different from 2D values)
- Real Systems: 3D Ising model describes real ferromagnetic materials and liquid-gas transitions
The Binder cumulant method is powerful because:
- โ Size-independent at T_c: Eliminates finite-size ambiguity
- โ High precision: Crossing point can be determined to many decimal places
- โ Standard method: Widely used in computational statistical physics
- โ No fitting required: Direct visual identification of T_c
isingmodel/
โโโ README.md # This file
โโโ CLAUDE.md # Developer documentation
โโโ Makefile # Build system
โโโ pcg_random.h # PCG random number generator
โโโ ising1d.c # 1D Ising model implementation
โโโ ising2d.c # 2D Ising model implementation
โโโ ising2d_fss.c # 2D FSS analysis with Binder cumulant
โโโ ising3d.c # 3D Ising model implementation
โโโ ising3d_fss.c # 3D FSS analysis with Binder cumulant
โโโ plot_binder.py # Python plotting script for 2D FSS analysis
โโโ plot_binder_3d.py # Python plotting script for 3D FSS analysis
โโโ test_suite.c # Comprehensive test suite
โโโ (executables) # Generated by make
The included Makefile provides:
make all # Build all programs
make test # Run test suite
make test-1d # Quick 1D test
make test-2d # Quick 2D test
make benchmark # Performance test
make clean # Remove executables
make help # Show all options# Generate data
./ising2d 20 > results_2d.dat
# Plot with your favorite tool (gnuplot, matplotlib, etc.)
# Look for:
# - Magnetization drop near T โ 2.27
# - Susceptibility peak at critical temperature
# - Heat capacity peak at critical temperatureNear the critical temperature T_c, physical quantities follow power laws:
- Magnetization: M โ (T_c - T)^ฮฒ
- Susceptibility: ฯ โ |T - T_c|^(-ฮณ)
- Heat capacity: C โ |T - T_c|^(-ฮฑ)
For 2D Ising: ฮฒ = 1/8, ฮณ = 7/4, ฮฑ = 0 (logarithmic) For 3D Ising: ฮฒ โ 0.326, ฮณ โ 1.237, ฮฑ โ 0.110, ฮฝ โ 0.630
- Ising Model - Wikipedia
- Monte Carlo Methods in Statistical Physics
- PCG Random Number Generator
- Onsager, L. (1944). "Crystal statistics. I. A two-dimensional model with an order-disorder transition"
This code is provided for educational and research purposes.
๋ฉํธ๋กํด๋ฆฌ์ค ์๊ณ ๋ฆฌ์ฆ์ ์ฌ์ฉํ ๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ์ผ๋ก ๊ตฌํ๋ ๊ณ ์ฑ๋ฅ C ๊ธฐ๋ฐ 1D, 2D, 3D ์ด์ง ๋ชจ๋ธ ์๋ฎฌ๋ ์ด์ ์ ๋๋ค.
์ด์ง ๋ชจ๋ธ์ ํต๊ณ์ญํ์์ ๊ฐ์์ฑ์ ๋ํ๋ด๋ ์ํ์ ๋ชจ๋ธ๋ก, ์์ ์ด์ ์๊ณ ํ์์ ์ฐ๊ตฌํ๋๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. ์ด ๊ตฌํ์ ๋ค์์ ์ ๊ณตํฉ๋๋ค:
- 1D ์ด์ง ๋ชจ๋ธ (
ising1d.c): ์ฃผ๊ธฐ์ ๊ฒฝ๊ณ ์กฐ๊ฑด์ ๊ฐ์ง ์ผ์ฐจ์ ์ฒด์ธ - 2D ์ด์ง ๋ชจ๋ธ (
ising2d.c): ์ฃผ๊ธฐ์ ๊ฒฝ๊ณ ์กฐ๊ฑด์ ๊ฐ์ง ์ด์ฐจ์ ์ ์ฌ๊ฐ ๊ฒฉ์ - 3D ์ด์ง ๋ชจ๋ธ (
ising3d.c): ์ฃผ๊ธฐ์ ๊ฒฝ๊ณ ์กฐ๊ฑด์ ๊ฐ์ง ์ผ์ฐจ์ ํ๋น ๊ฒฉ์ - ์ ํ ํฌ๊ธฐ ์ค์ผ์ผ๋ง ๋ถ์: 2D ๋ฐ 3D ์๊ณ ์จ๋ ๊ฒฐ์ ์ ์ํ Binder cumulant๋ฅผ ์ฌ์ฉํ FSS ๋๊ตฌ
- ํ๋์ PCG ๋์ ์์ฑ๊ธฐ: ๋ชฌํ ์นด๋ฅผ๋ก ์ํ๋ง์ ์ํ ๋น ๋ฅด๊ณ ๊ณ ํ์ง์ ๋์
- ํฌ๊ด์ ํ ์คํธ ์ค์ํธ: ๋์ ์์ฑ ๋ฐ ๋ฌผ๋ฆฌํ ๊ฒ์ฆ
- ๐ ๊ณ ์ฑ๋ฅ: ํ๋์ PCG ๋์ ์์ฑ๊ธฐ๋ฅผ ์ฌ์ฉํ ์ต์ ํ๋ C ์ฝ๋
- ๐ฌ ๋ฌผ๋ฆฌํ์ ์ ํ์ฑ: ์ฌ๋ฐ๋ฅธ ๋ฉํธ๋กํด๋ฆฌ์ค ์๊ณ ๋ฆฌ์ฆ ๊ตฌํ
- ๐ ์์ ํ ๋ถ์: ์ํ์จ, ์๋์ง, ์ํ ๊ฐ์์จ, ์ด์ฉ๋ ๊ณ์ฐ
- โ ์ ํ ์คํธ๋จ: ์ ๋ขฐ์ฑ์ ์ํ ํฌ๊ด์ ํ ์คํธ ์ค์ํธ
- ๐ ์จ๋ ์ค์ํ: T=3.01์์ T=0.01๊น์ง ์๋ ์จ๋ ์ค์ํ
make allmake test# 100๊ฐ ์คํ์ ๊ฐ์ง 1D ์ด์ง ๋ชจ๋ธ
./ising1d 100
# 50ร50 ๊ฒฉ์๋ฅผ ๊ฐ์ง 2D ์ด์ง ๋ชจ๋ธ
./ising2d 50
# 20ร20ร20 ๊ฒฉ์๋ฅผ ๊ฐ์ง 3D ์ด์ง ๋ชจ๋ธ
./ising3d 20๋ชจ๋ ํ๋ก๊ทธ๋จ์ด ์์คํ ํฌ๊ธฐ๋ฅผ ๋ช ๋ น์ค ์ธ์๋ก ๋ฐ์ต๋๋ค:
# 1D: N๊ฐ ์คํ
./ising1d N
# 2D: NรN ๊ฒฉ์
./ising2d N
# 3D: NรNรN ๊ฒฉ์
./ising3d N๋ ํ๋ก๊ทธ๋จ ๋ชจ๋ ๊ฐ ์จ๋์ ์ ๋ํด ํญ์ผ๋ก ๊ตฌ๋ถ๋ ๊ฐ์ ์ถ๋ ฅํฉ๋๋ค:
Temperature Magnetization Energy Susceptibility Heat_Capacity
3.010000 0.355721 -0.642628 0.227735 0.396727
3.000000 0.356154 -0.644540 0.228632 0.397261
...
- ์จ๋ ๋ฒ์: T = 3.01 โ 0.01 (๋จ๊ณ = 0.01)
- ์ดํํํ: 200,000 ๋ชฌํ ์นด๋ฅผ๋ก ๋จ๊ณ
- ์ธก์ : 200,000 ๋ชฌํ ์นด๋ฅผ๋ก ๋จ๊ณ
- ๋จ์: ์์ฐ ๋จ์ (J = 1, k_B = 1)
- ๊ฒฝ๊ณ ์กฐ๊ฑด: ์ฃผ๊ธฐ์
์ด ๊ตฌํ์ ์๋์ ํด๋ก์ฆ๋ ์์ค ๋ฉ๋ฅด์ผ ํธ์์คํฐ ์์กด์ฑ์ ๋์ฒดํ์ฌ **PCG (์์ด ํฉ๋ ์์ฑ๊ธฐ)**๋ฅผ ์ฌ์ฉํฉ๋๋ค:
- โ ๋ฉ๋ฅด์ผ ํธ์์คํฐ๋ณด๋ค ๋น ๋ฆ
- โ ๋ ๋์ ํต๊ณ์ ํน์ฑ
- โ ์คํ ์์ค์ด๋ฉฐ ๋๋ฆฌ ์ฑํ๋จ
- โ NumPy์ ๊ธฐ๋ณธ๊ฐ (2019๋ ๋ถํฐ)
- โ ๋ชฌํ ์นด๋ฅผ๋ก ์๋ฎฌ๋ ์ด์ ์ ์๋ฒฝํจ
pcg_random.h ํค๋๋ ๋ค์ ํจ์๋ค์ ์ ๊ณตํฉ๋๋ค:
init_rnd(seed): ์๋๋ก ์ด๊ธฐํdrnd(): [0,1) ๋ฒ์์ ๋๋ค double ์์ฑgus(): ํ์ฌ ์๊ฐ์์ ์๋ ์์ฑ
์ด์ง ๋ชจ๋ธ์ ๋ ์ํ(+1 ๋๋ -1) ์ค ํ๋๊ฐ ๋ ์ ์๋ ์ด์ฐ ๋ณ์(์คํ)๋ค๋ก ๊ตฌ์ฑ๋ฉ๋๋ค. ํด๋ฐํ ๋์์:
H = -J ฮฃ s_i s_j
์ฌ๊ธฐ์ ํฉ์ ์ต๊ทผ์ ์ด์์ ๋ํ ๊ฒ์ด๊ณ , J๋ ๊ฒฐํฉ ์์(์ฐ๋ฆฌ ๋จ์์์ J=1), s_i๋ ์คํ ๋ณ์์ ๋๋ค.
๋ฉํธ๋กํด๋ฆฌ์ค ์๊ณ ๋ฆฌ์ฆ์ ์ฌ์ฉํฉ๋๋ค:
- ๋๋คํ ์คํ ์ ํ
- ๋ค์งํ์ ๋์ ์๋์ง ๋ณํ ฮE ๊ณ์ฐ
- ๋ค์ ์กฐ๊ฑด์์ ๋ค์ง๊ธฐ ํ์ฉ:
- ฮE < 0 (์๋์ง์ ์ผ๋ก ์ ๋ฆฌ), ๋๋
- ๋๋ค ์ < exp(-ฮE/T) (์ด์ ์๋)
- ์ํ์จ: M = |โจฮฃ s_iโฉ| / N
- ์๋์ง: E = โจHโฉ / N
- ์ํ ๊ฐ์์จ: ฯ = (โจMยฒโฉ - โจMโฉยฒ) / T
- ์ด์ฉ๋: C = (โจEยฒโฉ - โจEโฉยฒ) / Tยฒ
- 1D ์ด์ง: ์ ํ ์จ๋ ์์ ์ด ์์ (T_c = 0)
- 2D ์ด์ง: ์๊ณ ์จ๋ T_c โ 2.269 (์ ํ๊ฐ: 2/ln(1+โ2))
- 3D ์ด์ง: ์๊ณ ์จ๋ T_c โ 4.51 (๊ณ ์ ๋ฐ๋ ์๋ฎฌ๋ ์ด์ ๊ฒฐ๊ณผ)
make testํ ์คํธ ์ค์ํธ๋ ๋ค์์ ๊ฒ์ฆํฉ๋๋ค:
- PCG ๋์ ์์ฑ๊ธฐ ํ์ง ๋ฐ ์ฌํ์ฑ
- ๋ฌผ๋ฆฌํ์ ์ ํ์ฑ (๊ณ ์จ โ ๋ฎ์ ์ํ์จ, ์ ์จ โ ๋์ ์ํ์จ)
- 1D, 2D, 3D ๋ชจ๋ธ ๊ธฐ๋ฅ
- Binder cumulant ๊ณ์ฐ ์ ํ์ฑ
# ๋น ๋ฅธ 1D ํ
์คํธ
make test-1d
# ๋น ๋ฅธ 2D ํ
์คํธ
make test-2d
# ์ฑ๋ฅ ๋ฒค์น๋งํฌ
make benchmark- 1D: ๋ชฌํ ์นด๋ฅผ๋ก ๋จ๊ณ๋น O(N)
- 2D: ๋ชฌํ ์นด๋ฅผ๋ก ๋จ๊ณ๋น O(Nยฒ)
- 3D: ๋ชฌํ ์นด๋ฅผ๋ก ๋จ๊ณ๋น O(Nยณ)
- ๋ฉ๋ชจ๋ฆฌ: 1D๋ O(N), 2D๋ O(Nยฒ), 3D๋ O(Nยณ)
- 1D: N = 100-10000 (๋น ๋ฆ)
- 2D: N = 10-100 (N=100์ ์ ์๊ฐ ์์)
- 3D: N = 10-30 (N=30์ ์ ์๊ฐ ์์)
- ํ ์คํธ ์ 2D๋ ์์ ์์คํ (N < 50) ์ฌ์ฉ
- ํ ์คํธ ์ 3D๋ ๋ ์์ ์์คํ (N < 20) ์ฌ์ฉ
- ์ค์ ์ฐ๊ตฌ์ฉ์ผ๋ก๋ ํฐ 2D/3D ์์คํ ์ ๋ฐค์ ์คํ ๊ณ ๋ ค
- ์ฝ๋๋ ์ด๋ฏธ
-O2์ปดํ์ผ ์ต์ ํ๋จ
์ด ์ ์ฅ์๋ Binder cumulant ๊ต์ฐจ์ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ์ฌ 2D ๋ฐ 3D ์ด์ง ๋ชจ๋ธ์ ์๊ณ ์จ๋ T_c๋ฅผ ์ ๋ฐํ๊ฒ ๊ฒฐ์ ํ๋ ์ ํ ํฌ๊ธฐ ์ค์ผ์ผ๋ง(FSS) ๋ถ์ ๋๊ตฌ๋ฅผ ํฌํจํฉ๋๋ค.
Binder cumulant๋ ๋ค์๊ณผ ๊ฐ์ด ์ ์๋ฉ๋๋ค:
U_L = 1 - <Mโด> / (3<Mยฒ>ยฒ)
์ด ๋ฌด์ฐจ์ ์์ ๋๋ผ์ด ํน์ฑ์ ๊ฐ์ง๊ณ ์์ต๋๋ค: ์๊ณ ์จ๋ T_c์์ Binder cumulant๋ ์์คํ ํฌ๊ธฐ์ ๋ฌด๊ดํด์ง๋๋ค. ์๋ก ๋ค๋ฅธ ์์คํ ํฌ๊ธฐ L์ ๋ํด ์จ๋์ ํจ์๋ก ๊ทธ๋ ค์ง๋ฉด, ๋ชจ๋ ๊ณก์ ์ด ํ ์ โ์๊ณ ์จ๋โ์์ ๊ต์ฐจํฉ๋๋ค.
# 2D FSS ๋ฒ์ ์ปดํ์ผ
gcc -Wall -Wextra -Wpedantic -o ising2d_fss ising2d_fss.c -lm
# ์๋ฎฌ๋ ์ด์
์คํ (์ ์๊ฐ ์์)
./ising2d_fss > fss_data.txt
# ํ๋กฏ ์์ฑ
python3 plot_binder.py# 3D FSS ๋ฒ์ ์ปดํ์ผ
gcc -Wall -Wextra -Wpedantic -o ising3d_fss ising3d_fss.c -lm
# ์๋ฎฌ๋ ์ด์
์คํ (์ ์๊ฐ ์์)
./ising3d_fss > fss_data_3d.txt
# ํ๋กฏ ์์ฑ
python3 plot_binder_3d.py- ์์คํ ํฌ๊ธฐ: L = 8, 16, 24, 32, 48, 64
- ์จ๋ ๋ฒ์: T = 2.6 โ 1.9 (T_c โ 2.269 ๊ทผ์ฒ์ ์ง์ค)
- ์จ๋ ํด์๋: ฮT = 0.005 (๊ธฐ๋ณธ ์๋ฎฌ๋ ์ด์ ๋ณด๋ค ์ธ๋ฐํจ)
- ์ดํํํ: ์จ๋๋น 200,000 ๋ชฌํ ์นด๋ฅผ๋ก ๋จ๊ณ
- ์ธก์ : ์จ๋๋น 200,000 ๋ชฌํ ์นด๋ฅผ๋ก ๋จ๊ณ
- ์์คํ ํฌ๊ธฐ: L = 4, 6, 8, 10, 12, 16
- ์จ๋ ๋ฒ์: T = 5.5 โ 3.5 (T_c โ 4.51 ๊ทผ์ฒ์ ์ง์ค)
- ์จ๋ ํด์๋: ฮT = 0.02
- ์ดํํํ: ์จ๋๋น 200,000 ๋ชฌํ ์นด๋ฅผ๋ก ๋จ๊ณ
- ์ธก์ : ์จ๋๋น 200,000 ๋ชฌํ ์นด๋ฅผ๋ก ๋จ๊ณ
- ์ฐธ๊ณ : O(Nยณ) ์ค์ผ์ผ๋ง์ผ๋ก ์ธํ ์์ ์์คํ ํฌ๊ธฐ
2D ๋ถ์์ ๋ ๊ฐ์ ํ๋กฏ์ ์์ฑํฉ๋๋ค:
- binder_crossing.png: Binder cumulant ๊ต์ฐจ์ ํ๋กฏ
- T_c โ 2.269์์ ๋ชจ๋ ์์คํ ํฌ๊ธฐ๊ฐ ๊ต์ฐจํ๋ ๊ฒ์ ๋ณด์ฌ์ค
- ์๊ณ์ ๊ทผ์ฒ ํ๋ ๋ทฐ ํฌํจ
- fss_complete_analysis.png: ์์ ํ ์ ํ ํฌ๊ธฐ ์ค์ผ์ผ๋ง ๋ถ์
- ๋ชจ๋ L์ ๋ํ ์ํ์จ vs ์จ๋
- ๋ชจ๋ L์ ๋ํ ์๋์ง vs ์จ๋
- ๋ชจ๋ L์ ๋ํ ์ํ ๊ฐ์์จ vs ์จ๋
- ๋ชจ๋ L์ ๋ํ ์ด์ฉ๋ vs ์จ๋
3D ๋ถ์์ ๋ ๊ฐ์ ํ๋กฏ์ ์์ฑํฉ๋๋ค:
- binder_crossing_3d.png: 3D Binder cumulant ๊ต์ฐจ์ ํ๋กฏ
- T_c โ 4.51์์ ๋ชจ๋ ์์คํ ํฌ๊ธฐ๊ฐ ๊ต์ฐจํ๋ ๊ฒ์ ๋ณด์ฌ์ค
- ์๊ณ์ ๊ทผ์ฒ ํ๋ ๋ทฐ ํฌํจ
- fss_complete_analysis_3d.png: ์์ ํ 3D ์ ํ ํฌ๊ธฐ ์ค์ผ์ผ๋ง ๋ถ์
- ๋ชจ๋ L์ ๋ํ ๋ชจ๋ ์ด์ญํ์ ์ vs ์จ๋
- ์๊ณ ์ง์๋ฅผ ๋ณด์ฌ์ค: ฮฒ โ 0.326, ฮณ โ 1.237, ฮฝ โ 0.630
FSS ์๋ฎฌ๋ ์ด์ ์ ํญ์ผ๋ก ๊ตฌ๋ถ๋ ๊ฐ์ ์ถ๋ ฅํฉ๋๋ค:
N Temperature Magnetization Energy Susceptibility Heat_Capacity Binder_Cumulant
8 2.600000 0.123456 -0.987654 1.234567 0.876543 0.456789
...
- ๊ต์ฐจ์ : ๋ชจ๋ Binder cumulant ๊ณก์ ์ด ๊ต์ฐจํ๋ ์จ๋๊ฐ ์๊ณ ์จ๋ T_c์ ๋๋ค
- ์ ํ ํฌ๊ธฐ ํจ๊ณผ: ๋ ํฐ ์์คํ ์ T_c ๊ทผ์ฒ์์ ๋ ๋ ์นด๋ก์ด ์ ์ด๋ฅผ ๋ณด์ ๋๋ค
- ์๊ณ๊ฐ: T_c์์ Binder cumulant๋ U* โ 0.610์ ์ ๊ทผํฉ๋๋ค (2D ์ด์ง์ ๋ณดํธ์ ๊ฐ)
- ์ ํํ T_c: 2D ์ด์ง ๋ชจ๋ธ์ T_c = 2/ln(1+โ2) โ 2.269185... (Onsager์ ์ ํํด)
- ๊ต์ฐจ์ : ๋ชจ๋ Binder cumulant ๊ณก์ ์ด T_c โ 4.51์์ ๊ต์ฐจํฉ๋๋ค
- ๋ค๋ฅธ ๋ณดํธ์ฑ ํด๋์ค: 3D ์ด์ง์ 2D์ ๋ค๋ฅธ ๋ณดํธ์ฑ ํด๋์ค์ ์ํฉ๋๋ค
- ์๊ณ ์ง์: ฮฒ โ 0.326, ฮณ โ 1.237, ฮฝ โ 0.630 (2D ๊ฐ๊ณผ ๋ค๋ฆ)
- ์ค์ ์์คํ : 3D ์ด์ง ๋ชจ๋ธ์ ์ค์ ๊ฐ์์ฑ ๋ฌผ์ง๊ณผ ์ก์ฒด-๊ธฐ์ฒด ์ ์ด๋ฅผ ์ค๋ช ํฉ๋๋ค
Binder cumulant ๋ฐฉ๋ฒ์ด ๊ฐ๋ ฅํ ์ด์ :
- โ T_c์์ ํฌ๊ธฐ ๋ ๋ฆฝ: ์ ํ ํฌ๊ธฐ ๋ชจํธ์ฑ ์ ๊ฑฐ
- โ ๊ณ ์ ๋ฐ๋: ๊ต์ฐจ์ ์ ์์์ ์ฌ๋ฌ ์๋ฆฌ๊น์ง ๊ฒฐ์ ๊ฐ๋ฅ
- โ ํ์ค ๋ฐฉ๋ฒ: ๊ณ์ฐ ํต๊ณ๋ฌผ๋ฆฌํ์์ ๋๋ฆฌ ์ฌ์ฉ๋จ
- โ ํผํ ๋ถํ์: T_c์ ์ง์ ์ ์ธ ์๊ฐ์ ์๋ณ
isingmodel/
โโโ README.md # ์ด ํ์ผ
โโโ CLAUDE.md # ๊ฐ๋ฐ์ ๋ฌธ์
โโโ Makefile # ๋น๋ ์์คํ
โโโ pcg_random.h # PCG ๋์ ์์ฑ๊ธฐ
โโโ ising1d.c # 1D ์ด์ง ๋ชจ๋ธ ๊ตฌํ
โโโ ising2d.c # 2D ์ด์ง ๋ชจ๋ธ ๊ตฌํ
โโโ ising2d_fss.c # Binder cumulant๋ฅผ ์ฌ์ฉํ 2D FSS ๋ถ์
โโโ ising3d.c # 3D ์ด์ง ๋ชจ๋ธ ๊ตฌํ
โโโ ising3d_fss.c # Binder cumulant๋ฅผ ์ฌ์ฉํ 3D FSS ๋ถ์
โโโ plot_binder.py # 2D FSS ๋ถ์์ ์ํ Python ํ๋กํ
์คํฌ๋ฆฝํธ
โโโ plot_binder_3d.py # 3D FSS ๋ถ์์ ์ํ Python ํ๋กํ
์คํฌ๋ฆฝํธ
โโโ test_suite.c # ํฌ๊ด์ ํ
์คํธ ์ค์ํธ
โโโ (์คํํ์ผ๋ค) # make๋ก ์์ฑ๋จ
ํฌํจ๋ Makefile์ ๋ค์์ ์ ๊ณตํฉ๋๋ค:
make all # ๋ชจ๋ ํ๋ก๊ทธ๋จ ๋น๋
make test # ํ
์คํธ ์ค์ํธ ์คํ
make test-1d # ๋น ๋ฅธ 1D ํ
์คํธ
make test-2d # ๋น ๋ฅธ 2D ํ
์คํธ
make benchmark # ์ฑ๋ฅ ํ
์คํธ
make clean # ์คํํ์ผ ์ ๊ฑฐ
make help # ๋ชจ๋ ์ต์
ํ์# ๋ฐ์ดํฐ ์์ฑ
./ising2d 20 > results_2d.dat
# ์ข์ํ๋ ๋๊ตฌ๋ก ํ๋กฏ (gnuplot, matplotlib ๋ฑ)
# ๋ค์์ ์ฐพ์๋ณด์ธ์:
# - T โ 2.27 ๊ทผ์ฒ์์ ์ํ์จ ๊ฐ์
# - ์๊ณ ์จ๋์์ ์ํ ๊ฐ์์จ ํผํฌ
# - ์๊ณ ์จ๋์์ ์ด์ฉ๋ ํผํฌ์๊ณ ์จ๋ T_c ๊ทผ์ฒ์์ ๋ฌผ๋ฆฌ๋๋ค์ ๋ฉฑ๋ฒ์น์ ๋ฐ๋ฆ ๋๋ค:
- ์ํ์จ: M โ (T_c - T)^ฮฒ
- ์ํ ๊ฐ์์จ: ฯ โ |T - T_c|^(-ฮณ)
- ์ด์ฉ๋: C โ |T - T_c|^(-ฮฑ)
2D ์ด์ง์ ๊ฒฝ์ฐ: ฮฒ = 1/8, ฮณ = 7/4, ฮฑ = 0 (๋ก๊ทธ์ ) 3D ์ด์ง์ ๊ฒฝ์ฐ: ฮฒ โ 0.326, ฮณ โ 1.237, ฮฑ โ 0.110, ฮฝ โ 0.630
- ์ด์ง ๋ชจ๋ธ - ์ํค๋ฐฑ๊ณผ
- ํต๊ณ๋ฌผ๋ฆฌํ์ ๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ
- PCG ๋์ ์์ฑ๊ธฐ
- Onsager, L. (1944). "Crystal statistics. I. A two-dimensional model with an order-disorder transition"
์ด ์ฝ๋๋ ๊ต์ก ๋ฐ ์ฐ๊ตฌ ๋ชฉ์ ์ผ๋ก ์ ๊ณต๋ฉ๋๋ค.



