All Projects → Chengcheng-Xiao → mpiPyMC

Chengcheng-Xiao / mpiPyMC

Licence: MIT license
A python based, MPI enabled, Monte-Carlo calculation of 2D system using Metropolis algorithm.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to mpiPyMC

UQpy
UQpy (Uncertainty Quantification with python) is a general purpose Python toolbox for modeling uncertainty in physical and mathematical systems.
Stars: ✭ 117 (+485%)
Mutual labels:  monte-carlo-simulation
mathematics-statistics-for-data-science
Mathematical & Statistical topics to perform statistical analysis and tests; Linear Regression, Probability Theory, Monte Carlo Simulation, Statistical Sampling, Bootstrapping, Dimensionality reduction techniques (PCA, FA, CCA), Imputation techniques, Statistical Tests (Kolmogorov Smirnov), Robust Estimators (FastMCD) and more in Python and R.
Stars: ✭ 56 (+180%)
Mutual labels:  monte-carlo-simulation
lattice mc
Lattice gas Monte Carlo simulation code
Stars: ✭ 24 (+20%)
Mutual labels:  monte-carlo-simulation
option-pricing-models
Simple python/streamlit web app for European option pricing using Black-Scholes model, Monte Carlo simulation and Binomial model. Spot prices for the underlying are fetched from Yahoo Finance API.
Stars: ✭ 16 (-20%)
Mutual labels:  monte-carlo-simulation
xmimsim
Monte Carlo simulation of energy-dispersive X-ray fluorescence spectrometers
Stars: ✭ 29 (+45%)
Mutual labels:  monte-carlo-simulation
Cassandra
Cassandra is a Monte Carlo package to conduct atomistic simulations.
Stars: ✭ 26 (+30%)
Mutual labels:  monte-carlo-simulation
CRPropa3
CRPropa is a public astrophysical simulation framework for propagating extraterrestrial ultra-high energy particles. https://crpropa.github.io/CRPropa3/
Stars: ✭ 44 (+120%)
Mutual labels:  monte-carlo-simulation
IsingMonteCarlo
A program implementing Metropolis Monte Carlo for the 2D square-lattice Ising model and the spin block renormalization
Stars: ✭ 20 (+0%)
Mutual labels:  metropolis-monte-carlo
w2dynamics
A continuous-time hybridization-expansion Monte Carlo code for calculating n-particle Green's functions of the Anderson impurity model and within dynamical mean-field theory.
Stars: ✭ 41 (+105%)
Mutual labels:  monte-carlo-simulation
evoplex
Evoplex is a fast, robust and extensible platform for developing agent-based models and multi-agent systems on networks. It's available for Windows, Linux and macOS.
Stars: ✭ 98 (+390%)
Mutual labels:  monte-carlo-simulation
sqaod
Solvers/annealers for simulated quantum annealing on CPU and CUDA(NVIDIA GPU).
Stars: ✭ 66 (+230%)
Mutual labels:  monte-carlo-simulation
FlowViz
A Power BI template that provides easy to understand, actionable flow metrics and predictive analytics for your agile teams using Azure DevOps, Azure DevOps Server and/or TFS.
Stars: ✭ 150 (+650%)
Mutual labels:  monte-carlo-simulation
TAA-PG
Usage of policy gradient reinforcement learning to solve portfolio optimization problems (Tactical Asset Allocation).
Stars: ✭ 26 (+30%)
Mutual labels:  monte-carlo-simulation
hoomd-examples
HOOMD-blue example scripts.
Stars: ✭ 15 (-25%)
Mutual labels:  monte-carlo-simulation
AdaptivePELE
AdaptivePELE is a Python package aimed at enhancing the sampling of molecular simulations
Stars: ✭ 14 (-30%)
Mutual labels:  monte-carlo-simulation
Credit
An example project that predicts risk of credit card default using a Logistic Regression classifier and a 30,000 sample dataset.
Stars: ✭ 18 (-10%)
Mutual labels:  monte-carlo-simulation
antaresViz
ANTARES Visualizations
Stars: ✭ 19 (-5%)
Mutual labels:  monte-carlo-simulation
PySDM
Pythonic particle-based (super-droplet) warm-rain/aqueous-chemistry cloud microphysics package with box, parcel & 1D/2D prescribed-flow examples in Python, Julia and Matlab
Stars: ✭ 26 (+30%)
Mutual labels:  monte-carlo-simulation
GOMC
GOMC - GPU Optimized Monte Carlo is a parallel molecular simulation code designed for high-performance simulation of large systems
Stars: ✭ 41 (+105%)
Mutual labels:  monte-carlo-simulation
OpenCossan
OpenCossan is an open and free toolbox for uncertainty quantification and management.
Stars: ✭ 40 (+100%)
Mutual labels:  monte-carlo-simulation

mpiPyMC

A python based, MPI enabled, Monte-Carlo calculation of 2D Ising system using Metropolis algorithm.

Before getting into things, you might want to check out these papers:

  1. Phys. Rev. Lett. 117, 097601 (2016)
  2. Phys. Rev. B 97, 144104 (2018)
  3. Appl. Phys. Lett. 111, 132904 (2017)

Getting Started

These instructions will get you a copy of the project up and running on your machine.

Prerequisites

For the script to work, you need to have an valid installation of python (2.7.x or 3.x both work), and a MPI installation:

openmpi:https://www.open-mpi.org/
MPICH:https://www.mpich.org/
intelmpi:https://software.intel.com/en-us/mpi-library

Also, numpy, matplotlib, tqdm and mpi4py package are needed, you can install them by pip:

pip install matplotlib numpy mpi4py tqdm

or by conda

conda install matplotlib numpy mpi4py tqdm

if you use a supercomputer and don't have enough privilege:

  1. install anaconda by downloading from here and upload it to your directory.
  2. using queue system to install anaconda by chmod 755 anaconda*.sh && ./anaconda*.sh
  3. install numpy, h5py and mpi4py by download them from here upload them as well.
  4. manually install package by conda install *package_name*.tar.bz2

Version of dependencies tested:

  • python = 3.8
  • matplotlib = 3.5.0
  • numpy = 1.21.2
  • mpi4py = 3.0.3
  • tqdm = 4.62.3

Installing

Python script does not need manual compilation, so the installation is very easy.

  1. Download the script:
wget https://github.com/Chengcheng-Xiao/mpiPyMC/blob/master/MC_MPI*.py
  1. give correct permission:
chmod 755 MC_MPI*.py
  1. change parameters inside the code and run it by:
mpirun -np XX MC_MPI*.py

XX is for number of processes (please keep XX <= the number of temperature points+1).

Adjustable spin (polarization vector)

This project provide two different script for two different tasks:

  1. MC_MPI.py: for adjustable spin. Utilize Sigma^4 Model:
E=∑[(A/2)*P_i^2+(B/4)*P_i^4+(C/6)*P_i^6]+∑[(D/2)*(P_i-<P_j>)^2]

where i and j are nearest neighbor.

  1. MC_MPI_Ising.py: for spin = +1 or -1. Utilize Heisenberg Model:
E=∑[(D)*P_i*P_j]

where i and j are nearest neighbor.

Input File

All adjustable variables should be written in input.MC file.

FOR MC_MPI.py:

NAME DEFAULT MEANING
nt 18 [number of Temperature point, should be integer number of the CPU used]
N 16 [number of cell in onedirection, total number of cell =N*N]
eqSteps 2000 [number of MC steps to get to equilibrium]
mcSteps 2000 [number of MC steps to use for average]
A_data -8.021 [model data]
B_data 0.620 [model data]
C_data 0.441 [model data]
D_data 4.5 [model data]
ps 1.867 [spontaneous polarization value]
T_low 0.01 [temperature range]
T_high 300 [temperature range]

FOR MC_MPI_Ising.py:

NAME DEFAULT MEANING
nt 18 [number of Temperature point, should be integer number of the CPU used]
N 16 [number of cell in onedirection, total number of cell =N*N]
eqSteps 8000 [number of MC steps to get to equilibrium]
mcSteps 4000 [number of MC steps to use for average]
D_data 1.0 [model data]
T_low 1.53 [temperature range] assuming K_b=1
T_high 3.28 [temperature range] assuming K_b=1

Output

MC_MPI.py will output picture MC.png and data Polarization.txt, containing Polarization vs Temperature plot and the raw data to generate the plot, respectively.

MC_MPI_Ising.py will output picture MC.png containing total energy plot, specific heat plot, susceptibility plot and Polarization vs Temperature plot. as well as their raw data Energy.txt, Polarization.txt, Specific_Heat.txt, Susceptibility.txt

Example

MC_MPI example

In the example folder, I have included three examples for mentioned reference papers. The systems are: SnSe, ß-GeSe, SnTe and GeTe.

I was not able to reproduce the result for SnSe and ß-GeSe. The calculated results forSnTe and GeTe agree with said paper.

Analysis of possible errors are presented inside each folder separately. In short, the definition of nearest neighbor is very important. However, no explanations were made in these referenced paper. The coupling coefficient D should be calculated via changing one cell's polarization in a supercell configuration. The coupling plot should be calculated by subtracting the site energy from the total energy.

MC_MPI_Ising example

In the example_Ising folder, I have included three calculations of Ising model. each with different cell size: 16X16, 30X30 and 50X50.

Note

This code is based on rajeshrinet's work: 🔗LINK

Future development plan

  1. Add total energy plot, specific heat plot and susceptibility plot function for MC_MPI.py.
  2. Better MPI implementation with respect to CPU number, or use OpenMP?
  3. Snap shot of specified one (or several) MC step(s).
  4. Hysteresis.

License

This project is licensed under the MIT License - see the LICENSE.md for details

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].