Skip to content

This repository includes all necessary scripts and compilation instructions required to run user-given chemical mechanisms with DLBFoam.

Notifications You must be signed in to change notification settings

kahilah/ct2foam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ct2foam -- Convert Cantera based thermophysical data To OpenFoam format

ct2foam enables user to generate OpenFoam dictionary entries for NASA-polynomials, Sutherland and other transport models required in thermophysicalProperties file. This python package utilises Cantera to generate such entries for all species in a given chemical mechanism or for gaseous mixtures defined by the user. With the general functions provided in this package, it is also possible to create NASA-polynomial, Sutherland and other polynomial type fits for thermophysical data based on experiments.

Furthermore, this package supports the users of DLBFoam and pyJac by introducing an automated pyjac2foam script which builds a compilation environment for pyjac routines as well as utilises ct2foam to generate consistent thermodynamics dictionaries with pyJac. See pyjac2foam module instructions below for further information.

Installation

Package relies on Cantera installation, for which the recommended installation principle is via conda. Hence, the recommended and easiest installation path is via conda as well. In particular, we recommend using the Miniconda package manager for this.

For users interested to use the pyjac2foam module, python version must be set python<=3.6. Otherwise, the latest releases can be utilised (tested up to python 3.8.8).

  • To install in conda environment:
conda create --name ct2foam_env --channel cantera cantera python=3.6 numpy scipy matplotlib cvxopt
cd my/installation/path
git clone [email protected]:kahilah/ct2foam.git
cd ct2foam
conda activate ct2foam_env
pip install .
  • To install on ubuntu without conda:

  • To install in other environments:

  • Dependencies are installed automatically:

    • cantera, numpy, scipy, cvxopt, matplotlib
    • Distribution is tested with Cantera 2.5.1
    • setup.py lists the dependencies.

Run tests:

cd ct2foam
python -m unittest discover
  • Note that ct2foam/test_data/OF_reference includes C++ code requiring OpenFoam based compilation. However, this is mainly included here for development / testing purposes and standard user is not required to compile anything here.

Running ct2foam:

  • Installation generates two global executables: ct2foam and ctmix2foam which can be run as follows:

  • ct2foam --input h2o2.cti --output test_output --Tmid 1000.0 --plot

    • outputs OpenFoam compatible thermodynamical and transport dictionary entries under output directory such that NASA-polynomials have a middle temperature of 1000 K. Thermodynamical fits with error larger than user given (or here default) tolerances, will be plotted under output/Figures directory. Supports input arguments --Tlow and --Thigh for low and high temperature limits of the NASA-polynomials, respectively.
  • ctmix2foam --input h2o2.cti --output test_output --name air --mixture "O2:1,AR:4" --Tmid 1000.0 --plot

    • outputs data for a mixture, defines similar to standard input format in Cantera.
  • See ct2foam -h for help.

  • Can be executed as a python modules:

    • python -m ct2foam.scripts.mech2foam
    • python -m ct2foam.scripts.mix2foam
  • Outputs log.txt including all the relevant information related to the particular execution.

  • Note that if you want plots for all species, you need to provide strict tolerance values for transport_fit_quality and nasa7_fit_quality

pyjac2foam

  • pyjac2foam module provides a consistent input of thermochemical data for users utilising DLBFoam and pyJac in OpenFoam environment. In particular, pyjac2foam.sh executable generates:

    • shared libray *.so, compiled with cmake.
    • consistent species ordering between OpenFOAM and pyjac inputs.
    • consistent thermophysicalProperties, chemistsryProperties and controlDict entries for an OpenFOAM case setup.
  • Note that pyJac is not set as a requirement for this python package. To install, ensure that you have python=3.6 installed. Then,

    • conda install -c slackha pyjac (or)
    • pip install pyjac
  • Furthermore, you need cmake to use the automatic library compilation.

  • For a simple test:

cd pyjac2foam/test_data
./run_test.sh
  • How-to:

    • Generate pyjac C-files (requires pyjac):
      • python -m pyjac --lang c --last_species N2 --input my_mechanism.cti
    • Compile + generate *.foam files under the same directory where pyjac output files are located.
      • pyjac2foam -m my_mechanism.cti -i pyjac/path -c
      • Example dictionary entries with correct absolute paths are printed after execution + written into file foam/include_example.txt
  • Notes:

    • note that compilation to a shared library is now with rather standard flags --> depending on the architecture, you may want to optimise CMakeLists
    • you can use pyjac2foam for library compilation with -c / --compile flag, or copy pyjac2foam/cmake_directives directory, modify them and run ./runCmake.sh

Notes

  • See TODO.txt for development to be considered in the future.

Acknowledgements

About

This repository includes all necessary scripts and compilation instructions required to run user-given chemical mechanisms with DLBFoam.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published