Installation

Requirements

Installing using pip

The most straightforward method to install SpaiNN is by using pip, which will automatically fetch the source code from PyPI. To do this, follow these steps:

  1. Open your terminal or command prompt.

  2. If you prefer, create and activate a virtual environment (recommended) by executing the following commands:

$ python -m venv .venv
$ source .venv/bin/activate   # On Windows, use: .venv\Scripts\activate
  1. Install SpaiNN using pip:

(.venv) $ pip install spainn

When you install SpaiNN using this method, only the core components necessary for model training and usage with SchNetPack will be included.

If you intend to utilize the interface to SHARC for molecular dynamics simulations, an additional installation of SHARC, including pysharc, is required. Refer to the SHARC documentation for detailed instructions on installing SHARC and pysharc. Alternatively, you can follow the following steps (Building from source).

Building from source

If you prefer to build SpaiNN, SchNetPack, and SHARC/pysharc from source, follow these steps:

SHARC 3.0 (including pysharc)

  1. Set up a conda environment with the required dependencies:

(base) $ conda create -n spainn -c conda-forge python=3.9 numpy scipy h5py six matplotlib python-dateutil pyyaml pyparsing kiwisolver cycler netcdf4 hdf5 h5utils gfortran gcc fftw
  1. Activate the conda environment:

(base) $ conda activate spainn

3 Clone the SHARC repository:

(spainn) $ git clone https://github.com/sharc-md/sharc.git
  1. Edit the Makefile in the sharc/source folder. In SPaiNN some computations are performed using pysharc. Therefore, you need to set USE_PYSHARC to true in the source/Makefile.

(spainn) $ cd sharc/source
(spainn) $ vim Makefile
USE_PYSHARC := true

Moreover, you have to change line 96 in the file source/input_list.f90 from read(nunit,'(A)', iostat=io) to read(nunit,'(A)', iostat=stat).

(spainn) $ vim input_list.f90
  1. Compile and install pysharc:

(spainn) $ cd ../pysharc/
(spainn) $ make install
  1. Compile and install SHARC:

(spainn) $ cd ../source/
(spainn) $ make install
  1. Copy the required files to the conda environment:

(spainn) $ cd ../pysharc/sharc/
(spainn) $ cp sharc.cpython-39-x86_64-linux-gnu.so ~/anaconda3/envs/spainn/lib/sharc.so
(spainn) $ cp ../lib/lib*.so ~/anaconda3/envs/spainn/lib/.
  1. Set up the environment:

(spainn) $ cd ../../bin/
(spainn) $ source sharcvars.sh
  1. Optionally, add the path to SHARC as an environment variable to your .bashrc:

(spainn) $ vi ~/.bashrc # Add the line: export SHARC=/<path>/sharc/bin/
(spainn) $ source ~/.bashrc

SchNetPack

  1. Install SchNetPack

(spainn) $ pip install --upgrade schnetpack

SPaiNN

  1. Install SPaiNN:

(spainn) $ git clone https://github.com/ExcitedStateML/SPaiNN.git
(spainn) $ cd SPaiNN
(spainn) $ pip install .

Note: You can replace steps 10 and 11 by simply installing SpaiNN through pip, which will automatically get the source code of SpaiNN and SchNetPack from PyPI:

(spainn) $ pip install --upgrade spainn