Skip to main content

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)
  • energy: A float representing the energy of the current lattice configuration.

    • Type: float
  • magnetization: A float representing the net magnetization of the current lattice configuration.

    • Type: float
  • 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.
  • 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.
  • 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.

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

mcising-0.12.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

mcising-0.12-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file mcising-0.12.tar.gz.

File metadata

  • Download URL: mcising-0.12.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for mcising-0.12.tar.gz
Algorithm Hash digest
SHA256 47f4deea1265ac3890b039a13028df8b9b55d614a248464119f1b28be77dfd29
MD5 8c8ce1937fc6e2e34daa777f65f1436a
BLAKE2b-256 f9944bc9dbc07adad2a84f339bc768739c1c9921189ddef2c36b289b849fa261

See more details on using hashes here.

File details

Details for the file mcising-0.12-py3-none-any.whl.

File metadata

  • Download URL: mcising-0.12-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for mcising-0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 ef650fb86cb25b26d0ab73aac8107e34c27b66aff29b1f58db6439919298f03f
MD5 8e4f408581f7f40f44e27fe9e50d048b
BLAKE2b-256 323277160c737c37a69f777f50580059403fcfb197f35e78e9607ecfcbdecf2c

See more details on using hashes here.

Supported by

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