This is an open source implementation of the COSMO-RS model that uses multiple descriptor sigma profiles in c++. But it also offers python bindings, so you can call it directly from python. It is orders of magnitude faster than the pure python version and it includes newer features and parameterizations earlier. The corresponding publication to this repository is:
git clone --recursive --shallow-submodules https://github.com/TUHH-TVT/openCOSMO-RS_cpp.git
Build on Windows with Visual Studio (tested with vs community 2019).
- Please check if you have set the correct directories for the openCOSMORS project. Right now it assumes standard Anaconda installation on Windows.
- Python include directory
- Properties > Configuration Properties > C/C++ > Additional Include Directories
- Python library directory
- Properties > Configuration Properties > Linker > Additional Library Directories
- More information here
- Please check whether the specified instruction set matches your target hardware
- Properties > Configuration Properties > C/C++ > Code Generation > Enable Enhanced Instruction Set
- Supported are SSE3, AVX, AVX2/FMA, defaults to SSE3.
- If this is not set correctly, in the best case it will run slower than it could, in the worsed cased it will crash.
- A small python project is also included in the bindings folder showing how to use it from within visual studio. To test, build and execute run_example.py.
Build on Windows with cmake (tested with vs community 2019).
- To run with a specific conda environment, activate the environment before running the commands to build.
- Please check whether the specified instruction set matches your target hardware
- you can change this in CMakeLists.txt by setting the appropriate compilation flag.
- Supported are SSE3, AVX, AVX2/FMA, defaults to SSE3.
- If this is not set correctly, in the best case it will run slower than it could, in the worsed cased it will crash.
- Commands to build
- cd openCOSMO-RS_cpp
- mkdir build
- cd build
- cmake ..
- cmake --build .
- the build will default to a debug build. For a release build, use the following:
- cmake --build . --config Release
- A small python project is also included in the bindings folder showing how to use it from within visual studio. To test, build, move the *.pyd file into the bindings folder and execute run_example.py.
Build on Linux with gcc (tested with gcc version 9.2.0 and python 3.6):
- Execute the following command within the bindings folder after adding the corrects paths. (pybind11_include_folder, eigen_include_folder, python_include_folder)
- Specify the parallelization_flag [-msse3, -mavx, -mfma]:
- g++ -fopenmp parallelization_flag -O3 -Wall -shared -std=c++14 -fPIC `python3 -m pybind11 --includes` bindings_forPython.cpp -o openCOSMORS`python3-config --extension-suffix` -I pybind11_include_folder -I eigen_include_folder -I python_include_folder
- Example:
g++ -fopenmp -mavx -O3 -Wall -shared -std=c++14 -fPIC `python3 -m pybind11 --includes` ../code/bindings_forPython.cpp -o openCOSMORS` python3-config --extension-suffix` -I ../pybind11/include -I ../eigen -I /usr/include/python3.6m
Build on Windows and Linux (tested only on windows with vs community 2019 and MATLAB 2019a):
- Ensure your matlab include folder is set correctly in the file code/bindings_forMATLAB.cpp:
- #include "matlabroot\extern\include\mex.hpp"
- #include "matlabroot\extern\include\mexAdapter.hpp"
- matlabroot can be found by executing said command in MATLAB
- Execute the following file within the bindings folder: compile_mex.m
Build on Windows with cmake (tested with vs community 2019).
- Please check whether the specified instruction set matches your target hardware
- you can change this in CMakeLists.txt by setting the appropriate compilation flag.
- Supported are SSE3, AVX, AVX2/FMA, defaults to SSE3.
- If this is not set correctly, in the best case it will run slower than it could, in the worst cased it will crash.
- Commands to build
- cd openCOSMO-RS_cpp
- mkdir build
- cd build
- cmake .. -DBINARY=
- cmake --build .
- the build will default to a debug build. For a release build, use the following:
- cmake --build . --config Release
Build on Linux with gcc (tested with gcc version 9.2.0):
- Commands to build
- cd bindings
- Specify the parallelization_flag [-msse3, -mavx, -mfma]:
- g++ -fopenmp parallelization_flag -O3 -Wall -std=c++14 ../code/bindings_forCLI.cpp -o openCOSMORS -I ../eigen -I ../nlohmann
An exemplary file to run the model on python and matlab is included in the bindings folder.
The reader might be also interested in the following related projects: