Skip to content

LoKI-Suite/LoKI-B-cpp

Repository files navigation

LoKI-B++

action codecov

LoKI-B++ is a numerical Boltzmann solver for the two-term approximation of the Boltzmann equation for electrons. It is based on the equivalent matlab version LoKI-B MATLAB. The relevant documentation can be found here.

Clang format

A Clang format style file is present at the root of this repository (.clang-format). To format all the source files, you can issue the following command from the repository root.

clang-format -i -style=file source/*.cpp LoKI-B/*.h app/*.cpp tests/*.cpp ideas/*.cpp web/bindings.cpp

Compilation instructions:

  1. Make sure Git and CMake are installed on your system as well as a suitable C/C++ compiler (i.e. gcc/g++ on Linux, MSVC on Windows and Apple Clang on Mac OS).
  2. LoKI-B relies on two dependencies, Eigen for linear algebra, and nlohmann-json for JSON handling.
  3. Open a terminal and navigate to the folder where you want to save the LoKI-B++ project folder.
  4. Clone the LoKI-B-cpp repository: git clone [email protected]:LoKI-Suite/LoKI-B-cpp.git and cd into the newly created LoKI-B-cpp folder.

Linux

  1. run: cmake -DCMAKE_BUILD_TYPE=Release -D<BACKEND_FLAG>=ON -B build
    • Where <BACKEND_FLAG>=LOKIB_USE_MKL/LOKIB_USE_OPENBLAS, is a flag to set the backend to supply to Eigen, OpenBLAS or Intel MKL. This flag can also be omitted to build with pure Eigen.
  2. run: cmake --build build -j <NUM_JOBS>
    • Where <NUM_JOBS> is the maximum number of jobs to run simultaneously when compiling; just use the number of physical cores in your system. Omit this flag to use the default settings.

Linux using Nix

  1. Setting up the LoKI-B development environment.

    To launch a development shell use

    nix develop

    in the root of the repository. This shell will contain all necessary dependencies to build LoKI-B. Additionally, all binaries can be built using

    nix build

    Alternatively, a Cobertura coverage report can be generated using

    nix build .#coverage

    The resulting output will be available in <repo_root>/result.

  2. Installing LoKI-B without manually cloning the repository.

    The LoKI-B binary can be built and run anywhere by issuing

    nix run github:loki-suite/loki-b-cpp <input_file>

    Similarly, a shell can be launched with access to the loki binary using

    nix shell github:loki-suite/loki-b-cpp

    Note: the web version available in this repository is outdated, for an updated version see LoKI-Web. The web version (using WebAssembly) can be built using the loki-web package.

    nix build github:loki-suite/loki-b-cpp#loki-web

    To serve the pages you can then e.g. use the python http server.

    python -m http.server -d result/share/loki-web

Windows

  1. run: cmake -D<BACKEND_FLAG>=ON -B build
    • where <BACKEND_FLAG>=LOKIB_USE_MKL/LOKIB_USE_OPENBLAS, specifying the backend to supply to Eigen
    • this flag can also be omitted to build with pure Eigen
  2. run: cmake --build build --config Release -j <NUM_JOBS>
    • where <NUM_JOBS> is the maximum number of jobs to run simultaneously when compiling; just use the number of physical cores in your system. Omit this flag to use the default settings.

Running and Plotting

As of yet, LoKI-B++ is locally run from the command line. To plot the computed eedf you can install gnuplot. The execution on different operating systems is very similar.

Linux

  1. Make sure gnuplot is available on your system.
  2. After compiling the loki executable, run the following command in the root of the repository: ./build/app/loki <INPUT_FILE> | gnuplot --persist.
    • Where <INPUT_FILE> is the path to the input file relative to the current working directory.
    • The output from LoKI-B++ is then piped into gnuplot, where the --persist flag avoids gnuplot from immediately closing after plotting.

Windows

  1. Make sure gnuplot is available on your system.
  2. Run the following command: .\build\app\loki.exe <INPUT_FILE> | gnuplot --persist.
    • Where <INPUT_FILE> is the path to the input file relative to the current working directory.
    • The output from LoKI-B++ is then piped into gnuplot, where the --persist flag avoids gnuplot from immediately closing after plotting.

Web

Alternatively, LoKI-B++ runs natively in a web browser through compilation to WebAssembly. The web deployment of LoKI-B++ is available at https://loki-suite.github.io/LoKI-Web/. The source code for the web app can be found in LoKI-Web.

About

Numerical Boltzmann solver for the two-term approximation of the electron Boltzmann equation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

Languages