ct2foam enables user to generate OpenFOAM dictionary entries for NASA-polynomials, Sutherland and other transport models required by compressible multi-species solvers. Conversion and re-fitting procedures ensure NASA-polynomials will share the same common temperature between low and high temperature range coefficients, which is required in OpenFOAM.
This python package utilises Cantera to generate such entries for all species in a given chemical mechanism or for a gaseous mixture defined by the user. With the general functions provided in this package, it is also possible to create fits for thermophysical data based on experiments.
See up-to-date Cantera installation documentation.
Install ct2foam with uv:
git clone git@github.com:kahilah/ct2foam.git
cd ct2foam
uv syncActivate the uv-managed virtual environment:
source .venv/bin/activate
ct2foam --helpcd ct2foam
pip install .python -m unittest discoverNote that openfoam_reference/Test-thermoMixture.C can be used for advanced testing and debugging how data, units and fit evaluations are handled on OpenFOAM side.
ct2foam --input h2o2.yaml --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 are plotted under test_output/Figures directory.
ct2foam --input h2o2.yaml --mixture "O2:1, N2:3.67" --mixture-name test_output --output test
- The constrained least-squares fitting procedure in
ct2foam/thermo_transport/lsqlin.pyis based on the work by Valeriy Vishnevskiy and Michael Hirsch, originally published in http://maggotroot.blogspot.ch/2013/11/constrained-linear-least-squares-in.html