CheMPS2 can be built with CMake and depends on
It is parallelized for shared memory architectures with the Open Multi-Processing (OpenMP) API. In the future, the parallelization of CheMPS2 for shared memory architectures will be extended to a hybrid scheme with both shared (OpenMP) and distributed (MPI) memory parallelization.
It is advised to clone the CheMPS2 git repository from github. In your terminal, run:
$ cd /sourcefolder
$ git clone 'https://github.com/sebwouters/chemps2'
$ cd chemps2
That way, future updates and bug fixes can be easily pulled in:
$ cd /sourcefolder/chemps2
$ git pull
The files
/sourcefolder/chemps2/CMakeLists.txt
/sourcefolder/chemps2/CheMPS2/CMakeLists.txt
/sourcefolder/chemps2/tests/CMakeLists.txt
/sourcefolder/chemps2/sphinx/CMakeLists.txt
provide a minimal compilation. In your terminal, run:
$ cd /sourcefolder/chemps2
$ mkdir build
$ cd build
CMake generates makefiles based on the user’s specifications:
$ CXX=option1 cmake .. -DMKL=option2 -DCMAKE_INSTALL_PREFIX=option3 -DBUILD_DOXYGEN=option4 -DBUILD_SPHINX=option5
If one or more of the required libraries are not found, use the command
$ CMAKE_INCLUDE_PATH=option6 CMAKE_LIBRARY_PATH=option7 CXX=option1 cmake .. -DMKL=option2 -DCMAKE_INSTALL_PREFIX=option3 -DBUILD_DOXYGEN=option4 -DBUILD_SPHINX=option5
instead, where option6 and option7 are respectively the missing colon-separated include and library paths:
CMAKE_INCLUDE_PATH=/my_libs/lib1/include:/my_libs/lib2/include
CMAKE_LIBRARY_PATH=/my_libs/lib1/lib:/my_libs/lib2/lib
To compile, run:
$ make
To install, run:
$ make install
For non-standard installation directories, please remember to append the library path to LD_LIBRARY_PATH in your .bashrc.
To test libchemps2, run:
$ cd /sourcefolder/chemps2/build
$ make test
The tests only require a very limited amount of memory (order 10-120 MB).
PyCheMPS2, a python interface to libchemps2, can be built with Cython. The installation is independent of CMake and assumes that you have installed the CheMPS2 library with make install. For non-standard installation directories of CheMPS2, please remember to append the library path to LD_LIBRARY_PATH in your .bashrc. In addition, the include path should be appended to CPATH:
$ export CPATH=${CPATH}:option3/include
where option3 is the option provided to CMake with -DCMAKE_INSTALL_PREFIX=option3 above. Then the python wrapper can be installed with:
$ cd /sourcefolder/chemps2/PyCheMPS2
$ python setup.py build_ext -L ${LD_LIBRARY_PATH}
$ python setup.py install --prefix=option3
On my machine, the python wrapper is installed to the folder option3/lib/python2.7/site-packages, but the folder lib and the distribution of python can vary.
Compilation of PyCheMPS2 occurs by linking to the c++ library in the installation directory. The installation of PyCheMPS2 will fail if that library is not properly installed. If you have pulled a newer version of CheMPS2, please remember to reinstall the c++ library first, before reinstalling PyCheMPS2!
To test PyCheMPS2 (remember that the python site-packages folder can vary), run:
$ cd /sourcefolder/chemps2/PyCheMPS2/tests
$ export PYTHONPATH=${PYTHONPATH}:option3/lib/python2.7/site-packages
$ python test1.py
$ python test2.py
$ python test3.py
$ python test4.py
$ python test5.py
$ python test6.py
$ python test7.py
$ python test8.py
$ python test9.py
$ python test10.py
If you compiled the c++ library with -DMKL=ON, you might get the error
Intel MKL FATAL ERROR: Cannot load libmkl_avx.so or libmkl_def.so.
This issue of using Intel’s MKL inside python is known and reported. To get the python tests to run, you can set the variable LD_PRELOAD in order to preload libmkl_rt.so. On my system, this is done with
$ export LD_PRELOAD=/opt/intel/mkl/lib/intel64/libmkl_rt.so
The python tests do exactly the same thing as the c++ tests above, and illustrate the usage of the python interface to libchemps2. The tests should end with a line stating whether or not they succeeded. They only require a very limited amount of memory (order 10-120 MB).
To build the doxygen manual, the BUILD_DOXYGEN flag should have been on: -DBUILD_DOXYGEN=ON. In your terminal, run:
$ cd /sourcefolder/chemps2/build
$ make doc
$ cd LaTeX-documents
$ make
$ evince refman.pdf &
$ cd ../html
$ firefox index.html &
The doxygen html output can also be consulted online.
To build the sphinx user manual, the BUILD_SPHINX flag should have been on: -DBUILD_SPHINX=ON. In your terminal, run:
$ cd /sourcefolder/chemps2/build
$ make sphinx
$ cd sphinx/html
$ firefox index.html &
The sphinx user manual can also be consulted online.