Menu

OpenMPS from Source

Matthew Jones

Acquire the source

Important Note: we will define OPENMPS_ROOT to be the file location for the OpenMPS source code acquired from either of the following methods

Using git

Clone the source code

git clone git://git.code.sf.net/p/openmps/v3code openmps

Acquire the dependencies

Additional steps for macOS

If you are installing onto a linux-based operating system, you can skip this section.
In recent updates to macOS, Apple has changed the default shell script to zsh. The utility scripts packaged with OpenMPS source do not work under zsh. The simplest solution is to change your default shell to bash by typing this in the macOS Terminal application:

chsh -s /bin/bash

important note: macOS will warn you that zsh is the default shell for macOS (beginning with Catalina), and print a message like the following:

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.

If you change the default shell back to zsh, you will not be able to access your conda environment unless you reinitialize conda by typing

source $CONDA_ROOT/bin/activate && conda init

where $CONDA_ROOT is a user-defined path. It is the root directory for conda where Anaconda is installed (e.g.) the path where the conda binary is located: $CONDA_ROOT/bin/conda

Install Anaconda and create the virtual environment

Install Anaconda by following the posted instructions.
Alternatively, you can install Anaconda by using our utilities scripts:

CONDA_ROOT=/path/to/conda/root
OPENMPS_ROOT=/path/to/openmps
bash $OPENMPS_ROOT/Utilities/install-conda.sh [macOS, linux] $CONDA_ROOT

important note: CONDA_ROOT is a user-defined path ... you must choose where you want conda to be installed
important note: OPENMPS_ROOT is a user-defined path ... it must be the location to the OpenMPS source code
important note: you may choose either macOS or linux ... the script will error if one of these is not supplied
important note: you will need to resource your bash environment: source ~/.bashrc if you're using linux; otherwise, source ~/.bash_profile if you're using macOS.

Use conda to create a virtual environment from the [macos, linux].yml specification and acquire all of the dependencies. For example:

conda env create --name openmps --file conda/environments/linux.yml  # for linux
conda env create --name openmps --file conda/environments/macos.yml  # for macOS

Install OpenMPS

From the OPENMPS_ROOT directory, issue this command

conda activate openmps && \
python setup.py install && \
python BuildOSMPS.py --prefix=$CONDA_PREFIX/bin \
                     --option=FC:$CONDA_PREFIX/bin/gfortran \
                     --option=INCFLAGS:-I$CONDA_PREFIX/include \
                     --option=LIBFLAGS:-L$CONDA_PREFIX/lib

Use OpenMPS

You must activate the virtual environment. This is done via

conda activate openmps

To run the first OpenMPS example (called 01_IsingStatics.py) from the command-line, type

python $OPENMPS_ROOT/Examples/01_IsingStatics.py --PostProcess=False && \
python $OPENMPS_ROOT/Examples/01_IsingStatics.py --PostProcess=True

This will produce a plot called 01_IsingStatics.pdf in $OPENMPS_ROOT directory. To view it, use your file browser, navigate to $OPENMPS_ROOT, and open the file. To view all available examples, type

ls $OPENMPS_ROOT/Examples

The first three examples produce plots:
1. 01_IsingStatics.py
2. 02_BoseHubbardStatics.py
3. 03_BoseHubbardDynamics.py

If you'd like to start an interactive session in your web browser using JupyterLab, run this command

bash $OPENMPS_ROOT/Utilities/start-jupyter.sh

Then navigate to http://localhost:8888/lab


Related

Wiki: Home