A python package simulating the quasi-2D pseudospin-1/2 Gross-Pitaevskii equation with NVIDIA GPU acceleration.
spinor-gpe is high-level, object-oriented Python package for numerically solving the quasi-2D, psuedospinor (two component) Gross-Piteavskii equation (GPE), for both ground state solutions and real-time dynamics. This project grew out of a desire to make high-performance simulations of the GPE more accessible to the entering researcher.
While this package is primarily built on NumPy, the main computational heavy-lifting is performed using PyTorch, a deep neural network library commonly used in machine learning applications. PyTorch has a NumPy-like interface, but a backend that can run either on a conventional processor or a CUDA-enabled NVIDIA(R) graphics card. Accessing a CUDA device will provide a significant hardware acceleration of the simulations.
This package has been tested on Windows 10.
- PyTorch >= 1.8.0
- cudatoolkit >= 11.1
- matplotlib (visualizing results)
- tqdm (progress messages)
- scikit-image (matrix signal processing)
- ffmpeg = 4.3.1 (animation generation)
The dependencies for
spinor-gpe can be installed directly into the new
conda virtual environment
spinor using the environment.yml file included with the package:
conda env create --file environment.yml
Note, this installation may take a while.
The dependencies can also be installed manually using
conda into a virtual environment:
conda activate <new_virt_env_name> conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge conda install numpy matplotlib tqdm scikit-image ffmpeg spyder
For more information on installing PyTorch, see its installation instructions page.
To verify that Pytorch was installed correctly, you should be able to import it:
>>>import torch >>>x = torch.rand(5, 3) >>>print(x) tensor([[0.2757, 0.3957, 0.9074], [0.6304, 0.1279, 0.7565], [0.0946, 0.7667, 0.2934], [0.9395, 0.4782, 0.9530], [0.2400, 0.0020, 0.9569]])
Also, if you have an NVIDIA GPU, you can test that it is available for GPU computing:
CUDA is the API that interfaces with the computing resources on NVIDIA graphics cards, and it can be accessed through the PyTorch package. If your computer has an NVIDIA graphics card, start by verifying that it is CUDA-compatible. This page lists out the compute capability of many NVIDIA devices. (Note: yours may still be CUDA-compatible even if it is not listed here.)
Given that your graphics card can run CUDA, the following are the steps to install CUDA on a Windows computer:
Install the NVIDIA CUDA Toolkit. Go to the CUDA download page for the most recent version. Select the operating system options and installer type. Download the installer and install it via the wizard on the screen. This may take a while. For reference, here is the CUDA Toolkit installation guide.
Download the correct drivers for your NVIDIA device. Once the driver is installed, you will have the NVIDIA Control Panel installed on your computer.
(Optional) Download the cuDNN library corresponding to your CUDA installation version. To do this you will need to create an account with NVIDIA and - for ethical purposes - specify for what you will be using the deep neural network library. To install:
- Unzip the download file
- Move all the folders in the unzipped sub-directory
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3directory.
- Clone the repository.
- Navigate to the
spinor_gpe/examples/directory, and start to experiment with the examples there.