Ising
A pythonic implementation of the Ising model.
Check the example for more.
Lattice
This is the main place of the Ising model, we have to initialize it with a tuple of the lattice shape that can be of any dimension or size. The lattice can be initialized with a random state (you can choose the state ratio up) or all in a state 1 or -1.
arguments:
type: tuple(int)
The shape of the lattice is tested for 1 to 4 dimension. Every values of shape must be > 0
Optionnal:
type: int == 1 or -1
Set the state at all 1 or -1 it overpass the r parrameter.
type: float in [0, ..., 1]
Set a random state with a ratio r of 1 in the lattice (default r = 0.5).
type: numpy.array
A vector of vector: is the representation of the spin interaction.
0 J 0 J # J 0 J 0 Will be written as [[1,0],[-1,0],[0,1],[0,-1]]
As default it's the left right up down direct neighbor matrix will be genereted (whatever this mean in 4 or more dimensions).
type: numpy.array or float
Is the interraction between spins, if J is an array he as to be the same length than adj.
(you can choose to make anisotropic iteractions !!)
type: numpy.array or float
Is the magnetic field imposed on the lattice, if B is an array he as to have the same shape of the lattice
type: float
Beta is 1/(Kb * T) with T the absolute temp, and Kb is the Boltzmann constant.
Methods
randomize(self, ratio=0.5)
Randomize th lattice state with a given ratio of up state.
arguments:
Optionnal:
type: float in [0, ..., 1]
The ratio of up state.
all(self, state)
Set all the lattice to the same state.
arguments:
type: int == -1 or 1
Value of the spin site.
H(self)
Compute the Hamiltonian of the lattice.
returns:
type: float
Hamiltonian of the lattice.
hamiltonian(self)
Compute the Halmitonian of each spin.
returns:
type: numpy array
The Hamiltonian calculated for each spin.
mH(self)
Compute the mean value of the Hamiltonian.
returns:
type: float
Mean value of the Hamiltonian.
mag(self)
Compute the magnetization of the lattice.
returns:
type: float
Magnetization of the lattice.
get_B(self)
Method to get the magnetic field.
returns:
type: numpy array
Return the magnetic field.
get_beta(self)
Method to get beta.
returns:
type: float
Return beta.
get_shape(self)
Method to get the shape of the lattice
returns:
type: tuple(float)
Return the shape of the lattice
get_size(self)
Method to get the size of the lattice
returns:
type: float
Return the size of the lattice
get_state(self)
Method to get the state of the lattice.
returns:
type: numpy array
Return the copy of the state.
set_B(self, B)
Method to set the magnetic field.
arguments:
type: numpy array
The new Magnetic field.
set_beta(self, beta)
Method to set beta.
arguments:
type: float
The new beta.
set_state(self, state)
Method to set the state of the lattice.
arguments:
type: numpy array
The new state.
Metropolis.algorithm
Is the class who solve the Ising model with the Metropolis algorithm
Implementation of the Metropolis algorithm
arguments:
- for the arguments look the lattice class.
Methods
step(self, n=0):
step apply the metropolis algorithm on n spin once
arguments:
Optional:
type: int
n must be strictly positive is the size of the sample
Metadata
Release files for isingm 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| isingm-1.1.2.tar.gz | 16.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| isingm-1.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.3 kB
Release files / isingm-1.1.2.tar.gz
| Download URL | isingm-1.1.2.tar.gz |
|---|---|
| Size | 16.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8eb020e0778254bf9c671784ab01eba2683992057235097b41c26e574b2a06dd
|
|
BLAKE2b-256 checksum How to use checksums |
38906615a7b2b5bb70c63f76b3726d5822cfbe804f731d4f703ccaed198f67a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 24, 2025.
Transparency logRelease files / isingm-1.1.2-py3-none-any.whl
| Download URL | isingm-1.1.2-py3-none-any.whl |
|---|---|
| Size | 18.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e930d5ed98563f263a9f9ac01c9edaa9685bfdb197e338eff432f090f128ea22
|
|
BLAKE2b-256 checksum How to use checksums |
1de614e5ab4dcf68e0c1256f5bfb089c454a554ea84ecb90178e2030e068e718
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 24, 2025.
Transparency log