Git Product home page Git Product logo

reactingcanterafoam's Introduction

reactingCanteraFoam

OpenFOAM version Cantera version

This solver calls Cantera to update T psi mu alpha D in OpenFOAM

I have run test cases in Cantera-2.4 Cantera 2.5.1 with OpenFOAM. And the flame structures are better than that from reactingFoam. Since I have no time to test the performance thoroughly, I hope someone can do this if interested.

The tool to convert Cantera results to OpenFOAM fields is from JSqueo299 in GitHub.

The correct of transport equation is copied from ZSHtju in GitHub.

How to compile

You can compile Cantera source code, to generate c++ library and headers, which is used in this OpenFOAM solver.

Or using libcantera installed by conda:

conda install -c cantera libcantera-devel

in this way, you should change Make/options to :

-I/path_to_anaconda3/envs/yourEnvName/include

/path_to_anaconda3/envs/yourEnvName/lib/libcantera_shared.so

PS: if you want to use Cantera Python module, you have to install it individually:

conda install -c cantera cantera

If you just want to run this solver for a try, you can use my pre-compiled Cantera-2.5.2 library and headers in cantera_build:

cd cantera_build/lib
tar -zxvf libcantera_shared2.5.2.so.tar.gz
ln -s libcantera_shared2.5.2.so libcantera_shared.so.2
cd ../..
wmake

How to use

You can run the testCase:

cd testCase
export LD_LIBRARY_PATH=../cantera_build/lib:$LD_LIBRARY_PATH
export CANTERA_DATA=../cantera_build/data
reactingCanteraFoam

Or you can build your flame in OpenFOAM by these steps:

  • python adiabatic_flame.py, to generate a premixed flame, you will get adiabatic_flame.csv
  • matlab Ctr2OF.m, which will convert adiabatic_flame.csv to OpenFOAM 0 folder
  • rebuild mesh according to the output of MATLAB (domain length and grid number, uniform mesh)
  • run reactingCanteraFoam with following settup in constant/thermophysicalProperties
Sct 0.7;// ignore it if laminar
mechanismFile "h2_konnov_2008.xml"; // put the cantera mech file (*.cti or *.xml) in $FOAM_CASE or $CANTERA_DATA
transportModel "Mix"; // you can also try other transport models from Cantera: Multi, UnityLewis, Ion, water, HighP

reactingcanterafoam's People

Contributors

zhangyantju avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

reactingcanterafoam's Issues

Some minor issues with the installation

  1. If you don't use the pre-compiled Cantera 2.5.2 library and installed your own Cantera instead. During compilation, you might meet errors like missing or couldn't find 'newTransportMgr' and 'newSolution'. It is all about how Cantera is installed. Try the following installation after git clone Cantera:

git checkout tags/v2.5.1
git submodule update

python3 /usr/bin/scons build prefix= system_fmt=n system_eigen=n system_sundials=n
python3 /usr/bin/scons test
python3 /usr/bin/scons install #sudo might required

  1. The warning of missing header during compilation can be ignored. If anyone wants to avoid this, in the Make/options, we need many -I options for EXE_INC = (e.g.):
    -I$(LIB_SRC)/../../../DNS/solver/reactingCanteraFoam/cantera/include/cantera/transport \

  2. The solver is for OF7 at the time of this post. These are what I did to port it to OF6:
    createFieldRefs.H

a. scalar nSpecies= composition.species().size(); //new line 17
b. if (gas->nSpecies() != nSpecies) //line 19 -> use nSpecies to avoid warning
c const word Yname = "diff_" + Y[i].name(); //new line 44
d. dimensionedScalar(Yname, dimDensitydimVelocitydimLength, 0.0) // line 59: Yname is used here
e. dimensionedScalar("diffsh", dimEnergy/dimTime/dimVolume, 0.0) //line 102: add "diffsh"
f. dimensionedVector("vk", dimensionSet(1,0,-3,0,0,0,0), Foam::vector(0,0,0)) //line 115: add "vk"
g. dimensionedScalar("Hsi", dimEnergy/dimMass, 0.0 //line 128: add "Hsi"

YEqn.H
//line 1, 2, and 3 initialize with dimensionedVector, replace zero
h. vk = dimensionedVector("vk", dimensionSet(1,0,-3,0,0,0,0), Foam::vector(0,0,0));
i. diffsh = dimensionedScalar("diffsh", dimEnergy/dimTime/dimVolume, 0.0);
j. DiffError = dimensionedVector("DiffError", dimDynamicViscosity/dimLength, Foam::vector(0,0,0));
k. X[i][cellI] = Y[i][cellI]*MW[cellI]/composition.W(i); // replace composition.Wi(i)
l. YiEqn.solve(mesh.solver("Yi")); // replace "Yi" in ()
(make sure units are consistent by yourself....and check new commits...)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.