2. Install

2.1. Download

You can download the source code for TeNeS from the GitHub page . If you have git installed on your machine, type the following command to start downloading:

$ git clone https://github.com/issp-center-dev/TeNeS

2.2. Prerequisites

The following tools are required for building TeNeS.

  1. C++17 compiler

    • For Intel compilers, use the newer icpx; the classic icpc cannot compile mptensor. Note that icpx enables -fp-model=fast by default, which breaks Inf/NaN handling; the TeNeS build automatically adds -fp-model=precise to avoid this.

  2. CMake (>=3.8.0)

  3. BLAS and LAPACK

TeNeS depends on the following libraries, but these are downloaded automatically through the build process.

  1. mptensor (>= v0.5.0)

  2. toml11 (>= v4.0.0)

TeNeS can use MPI and ScaLAPACK for parallel operations of tensors. MPI and ScaLAPACK must be installed by yourself. For example, if you use Debian GNU/Linux (or Debian based system such as Ubuntu) and have root priviledges, you can easily install them by the following:

sudo apt install openmpi-bin libopenmpi-dev libscalapack-mpi-dev

For others, see the official instruction of some MPI implementation and ScaLAPACK.

TeNeS can also use ARPACK-NG as an optional dependency. When it is installed, CMake detects and links it automatically, and it is used as the eigensolver for the transfer matrices in the correlation-length measurement (see the eigensolver parameter of the correlation_length section of the input file). TeNeS builds and runs fine without it (the builtin solver is used instead). On Debian GNU/Linux (or Debian based systems such as Ubuntu), it can be installed by

sudo apt install libarpack2-dev

and on macOS (Homebrew) by

brew install arpack

Python3 is required for the input file generators, tenes_simple and tenes_std . Additionary, the following python packages are also required.

  1. numpy

  2. scipy

  3. toml

2.3. Install

  1. Build TeNeS by typing the following commands (Some environment such as CentOS provides CMake3 as cmake3):

$ mkdir build
$ cd build
$ cmake  -DCMAKE_INSTALL_PREFIX=<path to install to> ..
$ make

The default value of the <path to install to> is /usr/local.

Parallel Build

The make command accepts -j <num> options and then uses <num> processes for a parallel building. This reduces the time to build TeNeS drastically.

The executable file tenes will be generated in build/src directory. By typing the following command, tests for tenes can be done.

$ make tests
  1. Install TeNeS by typing the following commands:

$ make install

In this case, tenes, tenes_std and tenes_simple are installed into the <path to install to>/bin .

Disable MPI/ScaLAPACK parallelization

If you want to disable MPI/ScaLAPACK parallelization, pass -DENABLE_MPI=OFF option to cmake command. On macOS, some functions of ScaLAPACK can be incompatible with the system’s BLAS and LAPACK and make TeNeS end in error, so ENABLE_MPI defaults to OFF there. With open-mpi and scalapack installed from Homebrew, -DENABLE_MPI=ON is known to work, because that ScaLAPACK links against OpenBLAS rather than Accelerate.

OpenMP on macOS

Apple clang ships without an OpenMP runtime, so libomp has to be installed separately.

$ brew install libomp

CMake queries brew --prefix libomp and then falls back to Homebrew’s usual locations. If the search fails, point it at libomp explicitly.

$ cmake -DOpenMP_ROOT=$(brew --prefix libomp) ../

Note that Homebrew’s mpicxx wraps Apple clang, so -DCMAKE_CXX_COMPILER=mpicxx takes this path as well. Apple clang builds require CMake 3.12 or later, which is when OpenMP_ROOT started to steer the library search.

Number of OpenMP threads

On macOS an OpenMP barrier costs a system call, so fine-grained threading within a node adds far more overhead than it saves. Set OMP_NUM_THREADS=1 at run time and parallelize with MPI instead.

$ OMP_NUM_THREADS=1 mpiexec -np 4 tenes input.toml

Specify compiler

CMake detects your compiler automatically but sometimes this does not work. In this case, you can specify the compiler in the following way,

$ cmake -DCMAKE_CXX_COMPILER=<path to your compiler> ../

Specify ScaLAPACK

CMake detects your ScaLAPACK library automatically but may fail. In this case, you can specify the ScaLAPACK library (<path>/lib/libscalapack.so) in the following way,

$ cmake -DSCALAPACK_ROOT=<path> ../

Control the detection of ARPACK-NG

CMake detects ARPACK-NG automatically (when it is not found, TeNeS is built with the builtin solver only). The behavior can be controlled by -DENABLE_ARPACK=AUTO/ON/OFF (default AUTO; ON raises an error when ARPACK-NG is not found, and OFF disables the detection). If you want to use ARPACK-NG installed in a specific location (<path>/lib/libarpack.so), add the following option:

$ cmake -DARPACK_ROOT=<path> ../

Use the pre-built mptensor

TeNeS is based on the parallelized tensor library mptensor. The build system of TeNeS installs this automatically, but if you want to use the specific version of the mptensor (<path>/lib/libmptensor.a), please add the following option in cmake.

$ cmake -DMPTENSOR_ROOT=<path> ../

Specify Python interpreter

TeNeS tools (tenes_simple and tenes_std) use python3 interpreter which is found in PATH via /usr/bin/env python3. Please make sure that python3 command invokes the interpreter which you want to use, for example, by using type python3.

If you want to fix the interpreter (or /usr/bin/env does not exist), you can specify the interpreter in the following way,

$ cmake -DTENES_PYTHON_EXECUTABLE=<path to your interpreter> ../