Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zeehio/ising
An Ising Model simulator using the Metropolis algorithm
https://github.com/zeehio/ising
Last synced: 29 days ago
JSON representation
An Ising Model simulator using the Metropolis algorithm
- Host: GitHub
- URL: https://github.com/zeehio/ising
- Owner: zeehio
- License: gpl-3.0
- Created: 2013-01-04T18:12:36.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-04-13T23:16:44.000Z (over 10 years ago)
- Last Synced: 2024-10-09T18:51:38.736Z (about 1 month ago)
- Language: C
- Size: 574 KB
- Stars: 5
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
ISING - An Ising model simulator
=================================## Building the source code
Simply run:./autogen.sh
./configure
make
make installAfter `make install`, the **ising** program will be found in
the `install/bin` directory. If you want to install the ising model simulator
in a global directory you can use the `--prefix` option:./autogen.sh
./configure --prefix=/usr/local
make
sudo make install## Using the Ising model simulator:
### Quick start:
First, obtain the latest version of the source code:
git clone https://github.com/zeehio/ising.git
Then we build the sources. You will need autotools (`autoconf`, `automake`
and `libtool`)../autogen.sh
./configure
make
make installFinally we move to the default install directory:
cd "install/bin"
Now we will perform a simulation and extract some measurements:
ising -d 2 -L 20 -T 4.0 --nmeas 500 --nmcs 10000000 --ieq 5000 --dyn 0 > simulation.txt
This command runs a 20x20 lattice, at a T=4 temperature, performing 10
millions of montecarlo sweeps of the lattice, printing the energy, the
magnetization and a simple estimation of average cluster radius every 500
sweeps to the `simulation.txt`. Before the 10 millions sweeps are performed,
5000 sweeps are done for thermalization. Each sweep is done using a random
glauber dynamic (a simple random spin flip).mycut -f 1 < simulation.txt > simulationenergies.txt
This command takes the first column of "simulation.txt" and saves it into
`simulation_energies.txt`.cat simulationenergies.txt | jackknife > energyinfo.txt
This command returns the jackknife estimations of the energies. Notice how
the quantity ` - ^2` can be used to compute the heat capacity using
the fluctuation-dissipation theorem.### Introduction
To be written. If you are here you should know a bit about the Ising model
and the Metropolis algorithm.#### Program workflow
This is more or less how the program works:1. Parse input parameters.
2. Initialize geometry.
3. Initialize spins values (+1,-1).
4. Compute Energy and Magnetization.
5. Perform `--ieq` Metropolis sweeps to thermalize the state of the system.
6. Perform `--nmcs` sweeps, printing the Energy, the Magnetization and an
estimation of the cluster radius every `--nmeas` measures.### Geometry
The ising model simulator defines an hypercubic lattice, which allows
the following parameters to be set:* Dimension (-d):
- 2: Square lattice
- 3: Cubic lattice
- 4: Hypercubic lattice
- 5: 5-dimesion cube
- ...
* Side length (-L): The number of spins of each dimension.* Print state (--print-state): This option, only enabled if dimension is 2,
will create a "state" subdirectory with several text files that contain
a LxL square matrix with the position of the spins (either UP or DOWN). This
text file can be used later on to plot an image of the system and seeing
the formed clusters.Examples:
* On a "-d 2 -L 20" lattice, we will have 20^2 = 400 spins
* On a "-d 3 -L 8" lattice, we will have 8^3 = 512 spins#### Using non hypercubic geometries:
The Ising model simulator may be used with any given geometry. However, an
initialization routine for any other specific geometry has to be implemented.If you want to use a different geometry, only the `main` function would need
to be changed, preferably by replacing the `InitHypercubicLattice` function
or adding another switch option to the program (i.e. `--geometry`).Patches are welcome.
Generic initialization routines for reading geometries from files would also
be very welcome.### Metropolis parameters
We consider a "MonteCarlo sample" a loop over all sites of the system
(this is "full sweep of the lattice"). This means that a single sample
on a lattice of 400 spins, consists of 400 update proposals.Using this convention, it is easier to compare Metropolis convergence
on different system sizes. Bear in mind that the larger the system is,
the longer will take a single "MonteCarlo sample" as more updates will
be necessary to do a single sweep.The Metropolis algorithm allows the following parameters:
* Thermalization iterations (--ieq): Just after the system initialization,
it may be convenient to discard a number of samples in order to allow
the system to reach an equilibrium state. Set this parameter to 0 if
you want to see the thermalization.
* Number of MonteCarlo samples (--nmcs): The total number of MonteCarlo
samples to perform after thermalization.
* Number of samples between each measurement (--nmeas): The number of
samples to perform between each system printing. For instance, if
we want to do 100000 sweeps, but only print 1000 values of the energy
and magnetization, we would use an `--nmeas 100`.### Dynamics
The Metropolis algorithm does not impose a particular dynamic of the system.
A dynamic describes "how the updates should be performed". The available
dynamics are:* Glauber: A spin is chosen randomly and flipped.
* Glauber sequential: Spins are flipped sequentially, following on every
sweep the same order.
* Kawasaki random: Two opposite spins are chosen randomly and and exchanged.
* Kawasaki neighbours: Two opposite neighbouring spins are chosen randomly
and exchanged. TODO: The implementation of this dynamic is biased for
geometries where some spins have more neighbours than others (not the
hypercubic case).
* Wolff: This is a clustering dynamic:
1. A spin S1 is chosen randomly.
2. Check the spin of each of the S1 neighbours. If the neighbour's spin is
the opposite of S1, then that neighbour is not added to the cluster but
if spins are the same, then the neighbour is added to the cluster with
an acceptance rate which depends on the temperature.
3. Move to the added neighbours and repeat until a cluster is formed.
4. Flip the cluster.