Compiling libFluid

From Kraken Wiki
Revision as of 19:24, 5 February 2024 by Ville Valtavirta (talk | contribs) (Prerequisite)
Jump to: navigation, search

libFluid is a library of water properties, which provides steam table data for Kraken.

libFluid is used in Kraken by compiling its Python bindings and adding those to the Python path.

Prerequisite

  • Compilation of libFluid uses cmake, which can be installed with
    • sudo apt install cmake
  • Also needs boost, which could be installed on Ubuntu 23.10 with
    • sudo apt install libboost-dev
  • Python bindings require the developer libraries of whichever version of Python you are using
    • E.g. sudo apt install python3.8-dev
  • Python bindings require pybind11:

You can install pybind11 to your kraken virtual environment with

workon kraken
python -m pip install pybind11

You will also need to add the path of the pybind11 module to your environment e.g. by adding an export command to the postactivate file of your kraken virtual environment (see: Setting up environment variables):

export pybind11_DIR=/home/<username>/Envs/kraken/lib/python3.<version>/site-packages/pybind11

After adding this to your environment you will need to reload it. Either by starting a new terminal window, or simply by doing a deactivate followed by workon kraken. NB: Of course, if your pybind11 was installed in some other location use that directory path on the aforementioned line.

Compiling

  • If CMake on your computer is older than version 3.15, you can try changing version number in cmake_minimum_required(VERSION 3.15). find_package(Python) requires CMake version 3.12 or newer.
  • Switch on the building of the Python bindings in the libFluid/CMakeLists.txt:
option(LIBFLUID_PYTHON "Build the Python interface library" ON)
  • Configure and build:
mkdir build
cd build
cmake ..
make

If this process leads to CMake partially finding the wrong Python version, you can add the following lines to libFluid/CMakeLists.txt inside if(LIBFLUID_PYTHON) for e.g. Python 3.8

find_package(PythonInterp 3.8 REQUIRED)
find_package(PythonLibs 3.8 REQUIRED)

Final setup

In order to use libFluid with KrakenTools add the libFluid/build/bindings/Python folder to your Python path (see Adding folders to the Python path).