Compiling Qbics

To compile Qbics, please follow the instructions step-by-step.

One-key Build

Fundamental Components

The following fundamental components are needed:

  • gcc, version >= 8.0;

  • make, version >= 3.8;

  • OpenMPI, version >= 3.0, if OpenMPI is enabled;

  • nvcc, version >= 11.0, if CUDA is enabled;

Third-party Libraries

Boost and Eigen

Boost and Eigen are two header-only libraries that do not need compilation. They can be obtained from:

After you download the source files, decompress them. You will find directories called boost and Eigen, respectively. Copy boost and Eigen to a suitable path, say /home/zhang/libs. This will be the value for $INCBOOST and $INCEIGEN in the corresponding Makefile.

Of course, if your system has already installed Boost and Eigen somewhere, just use those then.

libxc

libxc is a density functional library. It can be obtained from https://libxc.gitlab.io/download/. You can compile it using the following instructions:

$ bzip2 -d libxc-x.x.x.tar.bz2
$ tar -xvf libxc-x.x.x.tar
$ cd libxc-x.x.x
$ autoreconf -i
$ ./configure --prefix=/home/zhang/libs/libxc
$ make -CFLAGS="-std=c99 -O2"
$ make install

Now, all libxc files are available in /home/zhang/libs/libxc.

Of course, if your system has already installed libxc somewhere, just use it then.

libfftw3

libfftw3 is an efficient library for fast Fourier transformation. It can be obtained from https://www.fftw.org/download.html. You can compile it using the following instructions:

$ tar -xzf fftw-x.x.x.tar.gz
$ cd fftw-x.x.x
$ ./configure --prefix=/home/zhang/libs/fftw --enable-openmp
$ make
$ make install

Now, all libfftw3 files are available in /home/zhang/libs/fftw.

Of course, if your system has already installed libfftw3 somewhere, just use it then.

plumed

plumed is a library for enhanced sampling algorithms. It can be obtained from https://github.com/plumed/plumed2/releases/. You can compile it using the following instructions:

$ unzip plumed2-x.x.x.zip
$ cd plumed2-x.x.x
$ ./configure --prefix=/home/zhang/libs/plumed2 --disable-mpi --disable-external-lapack --disable-external-blas
$ make
$ make install

Of course, if your system has already installed plumed somewhere, just use it then.

dftd3-lib

dftd3-lib is a library for carrying out DFT-D3 calculations. It can be obtained from https://github.com/dftbplus/dftd3-lib. You can compile it using the following instructions:

$ unzip dftd3-lib-master.zip
$ cd dftd3-lib-master
$ make lib
$ cp lib /home/zhang/libs/dftd3-lib -r

Of course, if your system has already installed dftd3-lib somewhere, just use it then.

Edit Makefile

After decompressing the source file archive, you can find several Makefiles:

Makefile-win-cpu

Native Windows version, OpenMP parallelized.

Makefile-linux-cpu

Linux version, OpenMP parallelized.

Makefile-linux-gpu

Linux version, OpenMP parallelized, GPU enabled.

Open the suitable one, say Makefile-linux-cpu, you can find the following:

Makefile-linux-cpu
 1CODEINFO = -DCodeCommit="\"`git rev-parse HEAD`\"" \
 2-DCodeFlag="\"official version\"" \
 3-DCodeMajorVer=0 \
 4-DCodeMinorVer=1 \
 5-DCodeUser="\"`whoami | sed 's/\\\\/\\\\\\\\/g'`\"" \
 6-DCodeMachine="\"`hostname`\"" \
 7-DCodeCompiler="\"`$(CXX) --version | head -n 1`"\" \
 8-DCodeCompFlags="\"$(CXXFLAG)"\" \
 9-DCodeLibs="\"$(LIBS)"\" \
10-DOSLinux \
11-DNDEBUG
12
13CXX     = g++
14CXXFLAG = -O2 -fno-exceptions --std=c++17 -fopenmp -ffast-math -fno-finite-math-only -fexpensive-optimizations -Wall -mavx2 -mfma
15CC      = gcc
16CCFLAG  = -O2 -fopenmp -Wall
17FC      = gfortran
18FCFLAG  = -O2 -fopenmp -Wall
19NCC     = nvcc
20NCCFLAG = -O2 -use_fast_math -arch=compute_75 -code=sm_75
21
22# Third-party library
23LIBGNU    = -lgfortran -lquadmath -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive
24LIBXC     = /opt/libxc-5.2.3/lib/libxc.a
25LIBFFTW3  = /opt/fftw-3.3.10/lib/libfftw3.a /opt/fftw-3.3.10/lib/libfftw3_omp.a
26LIBDFTD   = /opt/dftd3-3.2/dftd3-lib-0.9/lib/libdftd3.a
27LIBJSON   = /opt/jsoncpp/lib/libjsoncpp.a
28LIBLEPTON = /opt/lepton/liblepton.a
29LIBCUDA   =
30LIBSPONGE =
31LIBS      = $(LIBXC) $(LIBFFTW3) $(LIBDFTD) $(LIBJSON) $(LIBLEPTON) $(LIBGNU)
32
33# Third-party include
34INCBOOST  = -I/opt/include/boost_1_78_0
35INCEIGEN  = -I/opt/include/eigen-3.4.0
36INCLIBXC  = -I/opt/libxc-5.2.3/include
37INCFFTW3  = -I/opt/fftw-3.3.10/include
38INCDFTD   = -I/opt/dftd3-3.2/dftd3-lib-0.9/lib
39INCJSON   = -I/opt/jsoncpp/include
40INCLEPTON = -I/opt/lepton
41INCCUDA   = -I/usr/local/cuda-11.4/targets/x86_64-linux/include
42INCS      = $(INCBOOST) $(INCEIGEN) $(INCLIBXC) $(INCFFTW3) $(INCDFTD) $(INCJSON) $(INCLEPTON)
  • You can modify the macro CodeFlag to give the code a unique identifier.

  • You can change CXXFLAG, FCFLAG or NCCFLAG to add suitable optimization options according to your systems.

  • You should change LIBXC, INCBOOST, etc. to provide the correct paths of libraries and header files.

Compile

After editing your Makefile, say Makefile-linux-cpu, just run the following command:

$ make -f Makefile-linux-cpu -j

After a long time, everything is ready in bin. You can copy bin to anywhere you like.