Installation
Requirements
Python (>=3.8)
PyTorch (>=1.9)
PyTorchLightning (>=1.9.0)
Hydra (>=1.1.0)
ASE (>=3.21)
SHARC with pysharc (>=3.0)
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:
Open your terminal or command prompt.
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
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)
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
Activate the conda environment:
(base) $ conda activate spainn
3 Clone the SHARC repository:
(spainn) $ git clone https://github.com/sharc-md/sharc.git
Edit the
Makefilein thesharc/sourcefolder. In SPaiNN some computations are performed using pysharc. Therefore, you need to setUSE_PYSHARCtotruein thesource/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
Compile and install pysharc:
(spainn) $ cd ../pysharc/
(spainn) $ make install
Compile and install SHARC:
(spainn) $ cd ../source/
(spainn) $ make install
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/.
Set up the environment:
(spainn) $ cd ../../bin/
(spainn) $ source sharcvars.sh
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
Install SchNetPack
(spainn) $ pip install --upgrade schnetpack
SPaiNN
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