Published/scientific-latex-templates/computational-physics / code / __pycache__ / statistical_mechanics.cpython-312.pyc
289 viewsubuntu2404
�
�8�h`* � �� � d Z ddlZddlmZ ddlmZ ej j d� G d� d� Z
G d� d� Zd � Zdd
�Z
d� Zd� Zd
� Zedk( r� e
dd�� \ ZZZeD � cg c] } | d �� c} ZeD � cg c] } | d �� c} ZeD � cg c] } | d �� c} Z ed� eded d��� eded d��� eeee� e� e� yyc c} w c c} w c c} w )a
Statistical Mechanics Monte Carlo Simulations
==============================================
This module implements Monte Carlo simulations for statistical mechanics systems:
- 2D Ising model with Metropolis algorithm
- Exact 1D Ising model solutions
- Thermodynamic property calculations
- Phase transition analysis
Keywords: ising model monte carlo, statistical mechanics python, metropolis algorithm,
phase transition simulation, partition function calculation, magnetic susceptibility
Author: CoCalc Scientific Templates
License: MIT
� N)�jit�* c � � e Zd ZdZd
d�Ze ed�� d� � � Ze ed�� d� � � Ze ed�� d� � � Z dd�Z
y )�IsingModel2Du�
2D Ising model Monte Carlo simulation using Metropolis algorithm.
Hamiltonian: H = -J Σ_{<i,j>} S_i S_j - h Σ_i S_i
where S_i = ±1 are spin variables.
c � � || _ || _ || _ t j j ddg||f�� | _ y)u�
Parameters:
-----------
N : int
Linear lattice size (N×N total spins)
J : float
Nearest-neighbor coupling constant
h : float
External magnetic field
������ )�sizeN)�N�J�h�np�random�choice�spins)�selfr r r
s �code/statistical_mechanics.py�__init__zIsingModel2D.__init__"