Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

22 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Ising Model Monte Carlo Simulation

A high-performance C implementation of 1D, 2D, and 3D Ising model simulations using Monte Carlo methods with the Metropolis algorithm.

Overview

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

Key Features

  • ๐Ÿš€ 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

Quick Start

Build

make all

Run Tests

make test

Run Simulations

# 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 20

Detailed Usage

Command Line Interface

All 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 N

Output Format

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

Physics Parameters

  • 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

Random Number Generator

This implementation uses PCG (Permuted Congruential Generator), replacing the original closed-source Mersenne Twister dependency:

Why PCG?

  • โœ… Faster than Mersenne Twister
  • โœ… Better statistical properties
  • โœ… Open source and widely adopted
  • โœ… Default in NumPy (since 2019)
  • โœ… Perfect for Monte Carlo simulations

PCG Interface

The pcg_random.h header provides these functions:

  • init_rnd(seed): Initialize with seed
  • drnd(): Generate random double in [0,1)
  • gus(): Generate seed from current time

Physics Background

The Ising Model

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.

Monte Carlo Method

We use the Metropolis algorithm:

  1. Choose a random spin
  2. Calculate energy change ฮ”E if flipped
  3. Accept flip if:
    • ฮ”E < 0 (energetically favorable), OR
    • Random number < exp(-ฮ”E/T) (thermal fluctuation)

Measured Quantities

  • Magnetization: M = |โŸจฮฃ s_iโŸฉ| / N
  • Energy: E = โŸจHโŸฉ / N
  • Susceptibility: ฯ‡ = (โŸจMยฒโŸฉ - โŸจMโŸฉยฒ) / T
  • Heat Capacity: C = (โŸจEยฒโŸฉ - โŸจEโŸฉยฒ) / Tยฒ

Critical Temperature

  • 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)

Testing and Validation

Run Test Suite

make test

The 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 Tests

# Quick 1D test
make test-1d

# Quick 2D test
make test-2d

# Performance benchmark
make benchmark

Performance Notes

Computational Complexity

  • 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

Recommended System Sizes

  • 1D: N = 100-10000 (fast)
  • 2D: N = 10-100 (N=100 takes ~hours)
  • 3D: N = 10-30 (N=30 takes ~hours)

Optimization Tips

  • 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 -O2 compilation

Finite-Size Scaling and Binder Cumulant Analysis

Overview

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.

What is Binder Cumulant?

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.

Running FSS Analysis

2D FSS Analysis

# 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

3D FSS Analysis

# 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

FSS Parameters

2D FSS Parameters

  • 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

3D FSS Parameters

  • 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

Output Files

2D FSS Plots

The 2D analysis generates two plots:

  1. binder_crossing.png: Binder cumulant crossing plot
    • Shows all system sizes crossing at T_c โ‰ˆ 2.269
    • Includes zoomed view near the critical point

Binder Cumulant Crossing

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

Complete FSS Analysis

3D FSS Plots

The 3D analysis generates two plots:

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

3D Binder Cumulant Crossing

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

3D Complete FSS Analysis

Output Data Format

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

Physical Interpretation

2D Interpretation

  • 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)

3D Interpretation

  • 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

Why This Works

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

File Structure

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

Build System

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

Example Analysis

Phase Transition Study

# 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 temperature

Critical Exponents

Near 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

References

License

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 all

ํ…Œ์ŠคํŠธ ์‹คํ–‰

make 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 (์ˆœ์—ด ํ•ฉ๋™ ์ƒ์„ฑ๊ธฐ)**๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค:

์™œ PCG์ธ๊ฐ€?

  • โœ… ๋ฉ”๋ฅด์„ผ ํŠธ์œ„์Šคํ„ฐ๋ณด๋‹ค ๋น ๋ฆ„
  • โœ… ๋” ๋‚˜์€ ํ†ต๊ณ„์  ํŠน์„ฑ
  • โœ… ์˜คํ”ˆ ์†Œ์Šค์ด๋ฉฐ ๋„๋ฆฌ ์ฑ„ํƒ๋จ
  • โœ… NumPy์˜ ๊ธฐ๋ณธ๊ฐ’ (2019๋…„๋ถ€ํ„ฐ)
  • โœ… ๋ชฌํ…Œ์นด๋ฅผ๋กœ ์‹œ๋ฎฌ๋ ˆ์ด์…˜์— ์™„๋ฒฝํ•จ

PCG ์ธํ„ฐํŽ˜์ด์Šค

pcg_random.h ํ—ค๋”๋Š” ๋‹ค์Œ ํ•จ์ˆ˜๋“ค์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค:

  • init_rnd(seed): ์‹œ๋“œ๋กœ ์ดˆ๊ธฐํ™”
  • drnd(): [0,1) ๋ฒ”์œ„์˜ ๋žœ๋ค double ์ƒ์„ฑ
  • gus(): ํ˜„์žฌ ์‹œ๊ฐ„์—์„œ ์‹œ๋“œ ์ƒ์„ฑ

๋ฌผ๋ฆฌํ•™์  ๋ฐฐ๊ฒฝ

์ด์ง• ๋ชจ๋ธ

์ด์ง• ๋ชจ๋ธ์€ ๋‘ ์ƒํƒœ(+1 ๋˜๋Š” -1) ์ค‘ ํ•˜๋‚˜๊ฐ€ ๋  ์ˆ˜ ์žˆ๋Š” ์ด์‚ฐ ๋ณ€์ˆ˜(์Šคํ•€)๋“ค๋กœ ๊ตฌ์„ฑ๋ฉ๋‹ˆ๋‹ค. ํ•ด๋ฐ€ํ† ๋‹ˆ์•ˆ์€:

H = -J ฮฃ s_i s_j

์—ฌ๊ธฐ์„œ ํ•ฉ์€ ์ตœ๊ทผ์ ‘ ์ด์›ƒ์— ๋Œ€ํ•œ ๊ฒƒ์ด๊ณ , J๋Š” ๊ฒฐํ•ฉ ์ƒ์ˆ˜(์šฐ๋ฆฌ ๋‹จ์œ„์—์„œ J=1), s_i๋Š” ์Šคํ•€ ๋ณ€์ˆ˜์ž…๋‹ˆ๋‹ค.

๋ชฌํ…Œ์นด๋ฅผ๋กœ ๋ฐฉ๋ฒ•

๋ฉ”ํŠธ๋กœํด๋ฆฌ์Šค ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค:

  1. ๋žœ๋คํ•œ ์Šคํ•€ ์„ ํƒ
  2. ๋’ค์ง‘ํ˜”์„ ๋•Œ์˜ ์—๋„ˆ์ง€ ๋ณ€ํ™” ฮ”E ๊ณ„์‚ฐ
  3. ๋‹ค์Œ ์กฐ๊ฑด์—์„œ ๋’ค์ง‘๊ธฐ ํ—ˆ์šฉ:
    • ฮ”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 ๋ถ„์„

๊ฐœ์š”

์ด ์ €์žฅ์†Œ๋Š” Binder cumulant ๊ต์ฐจ์  ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•˜์—ฌ 2D ๋ฐ 3D ์ด์ง• ๋ชจ๋ธ์˜ ์ž„๊ณ„ ์˜จ๋„ T_c๋ฅผ ์ •๋ฐ€ํ•˜๊ฒŒ ๊ฒฐ์ •ํ•˜๋Š” ์œ ํ•œ ํฌ๊ธฐ ์Šค์ผ€์ผ๋ง(FSS) ๋ถ„์„ ๋„๊ตฌ๋ฅผ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.

Binder Cumulant๋ž€?

Binder cumulant๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ •์˜๋ฉ๋‹ˆ๋‹ค:

U_L = 1 - <Mโด> / (3<Mยฒ>ยฒ)

์ด ๋ฌด์ฐจ์› ์–‘์€ ๋†€๋ผ์šด ํŠน์„ฑ์„ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค: ์ž„๊ณ„ ์˜จ๋„ T_c์—์„œ Binder cumulant๋Š” ์‹œ์Šคํ…œ ํฌ๊ธฐ์™€ ๋ฌด๊ด€ํ•ด์ง‘๋‹ˆ๋‹ค. ์„œ๋กœ ๋‹ค๋ฅธ ์‹œ์Šคํ…œ ํฌ๊ธฐ L์— ๋Œ€ํ•ด ์˜จ๋„์˜ ํ•จ์ˆ˜๋กœ ๊ทธ๋ ค์ง€๋ฉด, ๋ชจ๋“  ๊ณก์„ ์ด ํ•œ ์ โ€”์ž„๊ณ„ ์˜จ๋„โ€”์—์„œ ๊ต์ฐจํ•ฉ๋‹ˆ๋‹ค.

FSS ๋ถ„์„ ์‹คํ–‰

2D FSS ๋ถ„์„

# 2D FSS ๋ฒ„์ „ ์ปดํŒŒ์ผ
gcc -Wall -Wextra -Wpedantic -o ising2d_fss ising2d_fss.c -lm

# ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ์‹คํ–‰ (์ˆ˜ ์‹œ๊ฐ„ ์†Œ์š”)
./ising2d_fss > fss_data.txt

# ํ”Œ๋กฏ ์ƒ์„ฑ
python3 plot_binder.py

3D FSS ๋ถ„์„

# 3D FSS ๋ฒ„์ „ ์ปดํŒŒ์ผ
gcc -Wall -Wextra -Wpedantic -o ising3d_fss ising3d_fss.c -lm

# ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ์‹คํ–‰ (์ˆ˜ ์‹œ๊ฐ„ ์†Œ์š”)
./ising3d_fss > fss_data_3d.txt

# ํ”Œ๋กฏ ์ƒ์„ฑ
python3 plot_binder_3d.py

FSS ๋งค๊ฐœ๋ณ€์ˆ˜

2D FSS ๋งค๊ฐœ๋ณ€์ˆ˜

  • ์‹œ์Šคํ…œ ํฌ๊ธฐ: L = 8, 16, 24, 32, 48, 64
  • ์˜จ๋„ ๋ฒ”์œ„: T = 2.6 โ†’ 1.9 (T_c โ‰ˆ 2.269 ๊ทผ์ฒ˜์— ์ง‘์ค‘)
  • ์˜จ๋„ ํ•ด์ƒ๋„: ฮ”T = 0.005 (๊ธฐ๋ณธ ์‹œ๋ฎฌ๋ ˆ์ด์…˜๋ณด๋‹ค ์„ธ๋ฐ€ํ•จ)
  • ์—ดํ‰ํ˜•ํ™”: ์˜จ๋„๋‹น 200,000 ๋ชฌํ…Œ์นด๋ฅผ๋กœ ๋‹จ๊ณ„
  • ์ธก์ •: ์˜จ๋„๋‹น 200,000 ๋ชฌํ…Œ์นด๋ฅผ๋กœ ๋‹จ๊ณ„

3D FSS ๋งค๊ฐœ๋ณ€์ˆ˜

  • ์‹œ์Šคํ…œ ํฌ๊ธฐ: 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 FSS ํ”Œ๋กฏ

2D ๋ถ„์„์€ ๋‘ ๊ฐœ์˜ ํ”Œ๋กฏ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค:

  1. binder_crossing.png: Binder cumulant ๊ต์ฐจ์  ํ”Œ๋กฏ
    • T_c โ‰ˆ 2.269์—์„œ ๋ชจ๋“  ์‹œ์Šคํ…œ ํฌ๊ธฐ๊ฐ€ ๊ต์ฐจํ•˜๋Š” ๊ฒƒ์„ ๋ณด์—ฌ์คŒ
    • ์ž„๊ณ„์  ๊ทผ์ฒ˜ ํ™•๋Œ€ ๋ทฐ ํฌํ•จ

Binder Cumulant ๊ต์ฐจ์ 

  1. fss_complete_analysis.png: ์™„์ „ํ•œ ์œ ํ•œ ํฌ๊ธฐ ์Šค์ผ€์ผ๋ง ๋ถ„์„
    • ๋ชจ๋“  L์— ๋Œ€ํ•œ ์žํ™”์œจ vs ์˜จ๋„
    • ๋ชจ๋“  L์— ๋Œ€ํ•œ ์—๋„ˆ์ง€ vs ์˜จ๋„
    • ๋ชจ๋“  L์— ๋Œ€ํ•œ ์žํ™” ๊ฐ์ˆ˜์œจ vs ์˜จ๋„
    • ๋ชจ๋“  L์— ๋Œ€ํ•œ ์—ด์šฉ๋Ÿ‰ vs ์˜จ๋„

์™„์ „ํ•œ FSS ๋ถ„์„

3D FSS ํ”Œ๋กฏ

3D ๋ถ„์„์€ ๋‘ ๊ฐœ์˜ ํ”Œ๋กฏ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค:

  1. binder_crossing_3d.png: 3D Binder cumulant ๊ต์ฐจ์  ํ”Œ๋กฏ
    • T_c โ‰ˆ 4.51์—์„œ ๋ชจ๋“  ์‹œ์Šคํ…œ ํฌ๊ธฐ๊ฐ€ ๊ต์ฐจํ•˜๋Š” ๊ฒƒ์„ ๋ณด์—ฌ์คŒ
    • ์ž„๊ณ„์  ๊ทผ์ฒ˜ ํ™•๋Œ€ ๋ทฐ ํฌํ•จ

3D Binder Cumulant ๊ต์ฐจ์ 

  1. fss_complete_analysis_3d.png: ์™„์ „ํ•œ 3D ์œ ํ•œ ํฌ๊ธฐ ์Šค์ผ€์ผ๋ง ๋ถ„์„
    • ๋ชจ๋“  L์— ๋Œ€ํ•œ ๋ชจ๋“  ์—ด์—ญํ•™์  ์–‘ vs ์˜จ๋„
    • ์ž„๊ณ„ ์ง€์ˆ˜๋ฅผ ๋ณด์—ฌ์คŒ: ฮฒ โ‰ˆ 0.326, ฮณ โ‰ˆ 1.237, ฮฝ โ‰ˆ 0.630

3D ์™„์ „ํ•œ FSS ๋ถ„์„

์ถœ๋ ฅ ๋ฐ์ดํ„ฐ ํ˜•์‹

FSS ์‹œ๋ฎฌ๋ ˆ์ด์…˜์€ ํƒญ์œผ๋กœ ๊ตฌ๋ถ„๋œ ๊ฐ’์„ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค:

N  Temperature  Magnetization  Energy  Susceptibility  Heat_Capacity  Binder_Cumulant
8  2.600000     0.123456      -0.987654    1.234567       0.876543      0.456789
...

๋ฌผ๋ฆฌ์  ํ•ด์„

2D ํ•ด์„

  • ๊ต์ฐจ์ : ๋ชจ๋“  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์˜ ์ •ํ™•ํ•ด)

3D ํ•ด์„

  • ๊ต์ฐจ์ : ๋ชจ๋“  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

์ฐธ๊ณ ๋ฌธํ—Œ

๋ผ์ด์„ ์Šค

์ด ์ฝ”๋“œ๋Š” ๊ต์œก ๋ฐ ์—ฐ๊ตฌ ๋ชฉ์ ์œผ๋กœ ์ œ๊ณต๋ฉ๋‹ˆ๋‹ค.

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages