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.13.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

mcising-0.13-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcising-0.13.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.13.tar.gz
Algorithm Hash digest
SHA256 84a392307798d8034baf8fcfc64aaaaadf46e619c5e3189ae8fff5a09c7254ab
MD5 804a9868764d96aae414be30d6db77da
BLAKE2b-256 56a68e1268a149af1319ccee522151b19ed216d969d38de78967e86c773457a5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mcising-0.13-py3-none-any.whl
  • Upload date:
  • Size: 10.7 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.13-py3-none-any.whl
Algorithm Hash digest
SHA256 b6b3e11f9549e097be4b5aac741232a680d9f600b1a00844e6818c1e092b70ac
MD5 47aa808689f093da94b9feb41c776137
BLAKE2b-256 40dfb35ca4b984c29435c15867a90510996b0862cbf47f4c847c8ff37d723bda

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