A package for generating Ising model data using Metropolis algorithm on a square lattice for nearest neighbor and next nearest neighbor interactions.
Project description
mcising
mcising is a Python package for generating Ising model data using Metropolis algorithm. It works for square lattices, and for nearest neighbor and next nearest neighbor interactions. The Monte-Carlo method it uses, has the cool-down approach to avoid semi stable states.
Installation
You can install the package using pip:
pip install mcising
Usage
You can generate Ising model data from the command line:
generate_ising_data <seed> <lattice_size> <num_configs> <j1> <j2> [--T_init <T_init>] [--T_final <T_final>] [--T_step <T_step>] [--sweep_steps <sweep_steps>] [--thermalization_scans <thermalization_scans>] [--calculate_correlation]
seed
: the random seed for reproducibility
lattice_size
: the system size L of the square lattice LxL
num_configs
: number of configurations to be saved per temperature
j1
and j2
: the interaction strengths, j1
for nearest neighbor and j2
for next nearest neighbor
T_init
and T_final
: initial and final temperatures, initial being higher
T_step
: the step in between each temperature point
sweep_steps
: number of Monte-Carlo sweeps per step
thermalization_scans
: number of sweeps on each temperature step to ensure thermalization
calculate_correlation
: option to select if correlation function and correlation length should be calculated, since they are time consuming.
An example usage:
generate_ising_data 42 10 100 1.0 0.5 --T_init 4.0 --T_final 0.1 --T_step 0.05 --sweep_steps 10 --thermalization_scans 5 --calculate_correlation
An example of the output console:
..1 / 11 samples saved.
2 / 11 samples saved.
3 / 11 samples saved.
4 / 11 samples saved.
5 / 11 samples saved.
6 / 11 samples saved.
7 / 11 samples saved.
8 / 11 samples saved.
9 / 11 samples saved.
10 / 11 samples saved.
11 / 11 samples saved.
For temperature= 1.0, MC simulation executed in: 0.43 seconds
.1 / 11 samples saved.
2 / 11 samples saved.
3 / 11 samples saved.
4 / 11 samples saved.
5 / 11 samples saved.
6 / 11 samples saved.
7 / 11 samples saved.
8 / 11 samples saved.
9 / 11 samples saved.
10 / 11 samples saved.
11 / 11 samples saved.
For temperature= 1.0, MC simulation executed in: 0.18 seconds
Example output png files:
Structure of the saved pickle files:
data_sample = {
'configuration': np.ndarray, # The lattice configuration (2D array of spins)
'energy': float, # The energy of the configuration
'magnetization': float, # The magnetization of the configuration
'correlation_length': float, # The correlation length (if calculated)
'correlation_function': np.ndarray, # The correlation function values (if calculated)
'distances': np.ndarray # The distances corresponding to the correlation function values (if calculated)
}
Detailed Description of Each Key
-
configuration: A 2D NumPy array representing the lattice configuration, where each element is a spin (-1 or 1).
- Type:
np.ndarray
- Shape:
(lattice_size, lattice_size)
- Type:
-
energy: A float representing the energy of the current lattice configuration.
- Type:
float
- Type:
-
magnetization: A float representing the net magnetization of the current lattice configuration.
- Type:
float
- Type:
-
correlation_length: A float representing the correlation length of the lattice. This is only present if correlation calculations are enabled.
- Type:
float
- Note: This key is
None
if correlation calculations are not performed.
- Type:
-
correlation_function: A 1D NumPy array representing the values of the correlation function. This is only present if correlation calculations are enabled.
- Type:
np.ndarray
- Shape:
(num_distances,)
- Note: This key is
None
if correlation calculations are not performed.
- Type:
-
distances: A 1D NumPy array representing the distances corresponding to the correlation function values. This is only present if correlation calculations are enabled.
- Type:
np.ndarray
- Shape:
(num_distances,)
- Note: This key is
None
if correlation calculations are not performed.
- Type:
Licence
This project is licensed under the MIT License.
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
Built Distribution
File details
Details for the file mcising-0.11.tar.gz
.
File metadata
- Download URL: mcising-0.11.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1c44eac1170837b36ca9d1026fc094a42575953bc359112fa6f803048654804 |
|
MD5 | 46a5931927f41b8d3308de255d831cdb |
|
BLAKE2b-256 | 698f8f311ba5c27f1c75feadd990228359c18c70632e2ed69e9c1bab9798b927 |
File details
Details for the file mcising-0.11-py3-none-any.whl
.
File metadata
- Download URL: mcising-0.11-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a594e31e4c03f656479a2acfc7c5d7fd55a65c83ca36b8909c646d12ea1512af |
|
MD5 | ad85a459d1fbab2301e5ad6cd52f5a9b |
|
BLAKE2b-256 | 512f9e4a2fc818c98bec6244ce73c127bf3c05efd07dd5107323e815d9d2d1da |