Skip to main content

A pythonic Ising model simulation

Project description

wheel implementation python downloads

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:

  • shape:

type: tuple(int)

The shape of the lattice is tested for 1 to 4 dimension. Every values of shape must be > 0

Optionnal:

  • all:

type: int == 1 or -1

Set the state at all 1 or -1 it overpass the r parrameter.

  • r:

type: float in [0, ..., 1]

Set a random state with a ratio r of 1 in the lattice (default r = 0.5).

  • adj:

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

  • J:

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

  • B:

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

  • beta:

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:

- ##### ratio:

>   type: **float** in [0, ..., 1]
>
>   The ratio of up state.

all(self, state)

Set all the lattice to the same state.

### arguments:

- ##### state:

>   type: **int** == -1 or 1
>
>   Value of the spin site.

H(self)

Compute the Hamiltonian of the lattice.

### returns:

- ##### Hamiltonian

>   type: **float** 
>
>   Hamiltonian of the lattice.

hamiltonian(self)

Compute the Halmitonian of each spin.

### returns:

- ##### local_Hamiltonian:

>   type: **numpy array** 
>
>   The Hamiltonian calculated for each spin.

mH(self)

Compute the mean value of the Hamiltonian.

### returns:

- ##### <H>

>   type: **float** 
>
>   Mean value of the Hamiltonian.

mag(self)

Compute the magnetization of the lattice.

### returns:

- ##### Magnetization

>   type: **float** 
>
>   Magnetization of the lattice.

get_B(self)

Method to get the magnetic field.

### returns:

- ##### B:

>   type: **numpy array** 
>
>   Return the magnetic field.

get_beta(self)

Method to get beta.

### returns:

- ##### beta:

>   type: **float** 
>
>   Return beta.

get_shape(self)

Method to get the shape of the lattice

### returns:

- ##### shape:

>   type: **tuple(float)**
> 
>   Return the shape of the lattice

get_size(self)

Method to get the size of the lattice

### returns:

- ##### size:

>   type: **float**
> 
>   Return the size of the lattice

get_state(self)

Method to get the state of the lattice.

### returns:

- ##### state:

>   type: **numpy array** 
>
>   Return the copy of the state.

set_B(self, B)

Method to set the magnetic field.

### arguments:

- ##### B:

>   type: **numpy array**
>
>   The new Magnetic field.

set_beta(self, beta)

Method to set beta.

### arguments:

- ##### beta:

>   type: **float** 
>
>   The new beta.

set_state(self, state)

Method to set the state of the lattice.

### arguments:

- ##### state:

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

  • n:

type: int

n must be strictly positive is the size of the sample

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

isingm-1.1.0.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

isingm-1.1.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file isingm-1.1.0.tar.gz.

File metadata

  • Download URL: isingm-1.1.0.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.5 Linux/5.3.0-46-generic

File hashes

Hashes for isingm-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2941c8b35eb5af318c3278d775e1d08f36534d8625bc1b2e4162f8ebadc660a1
MD5 9b64e0bf6d8d10e751f19b322ae929b2
BLAKE2b-256 cdebfcda077c09273bce4204265a970ce0b5eaeda64f0adc372724ed0c5e3551

See more details on using hashes here.

File details

Details for the file isingm-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: isingm-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.5 Linux/5.3.0-46-generic

File hashes

Hashes for isingm-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac98fa6b65abf392b7bfefcc9b0734f13d3ba070d8594217bad5977252ed3417
MD5 9490c60e873ee9696d4612c1df1d3b4b
BLAKE2b-256 f67eaca7b2714dd449580f141397d6e6c3e639a34e277adec6c3519eaf975806

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page