Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
Set up a tutorial case Use ISAT-CK7
A tutorial of how to use ISAT-CK7 in OpenFOAMfor the course
CFD with OpenSource Software
Daniel Moell
Siemens Industrial Turbomachinery AB/Fluid Mechanics Lund University,
2015-12-08
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 1 / 29
Set up a tutorial case Use ISAT-CK7
Outline
Set up tutorial case
Set up ISAT-CK7 for tutorial case
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 2 / 29
Set up a tutorial case Use ISAT-CK7
Prepare the case
Copy an existing tutorial for reactingFoam to your run directory:
cp -r
$FOAM_TUTORIALS/combustion/reactingFoam/
ras/counterFlowFlame2D $WM_PROJECT_USER_DIR/run
Create a chemkin directory in counterFlowFlame2D:
cd $WM_PROJECT_USER_DIR/run/counterFlowFlame2D
mkdir chemkin
Download the DRM19.dat file along with the thermodynamic filethermo30.dat from GRI 3.0 to the chemkin directory:
http://www.me.berkeley.edu/drm/
http://www.me.berkeley.edu/gri_mech/
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 3 / 29
Set up a tutorial case Use ISAT-CK7
Prepare the case
Edit the constant/thermophysicalProperties file by changing the followinglines:
chemistryReader foamChemistryReader;
foamChemistryFile "$FOAM_CASE/constant/reactions";
foamChemistryThermoFile "$FOAM_CASE/constant/thermo.compressibleGas";
to
chemistryReader chemkinReader;
CHEMKINFile "$FOAM_CASE/chemkin/drm19.dat";
CHEMKINThermoFile "$FOAM_CASE/chemkin/thermo30.dat";
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 4 / 29
Set up a tutorial case Use ISAT-CK7
Prepare the case
I have noticed that the chemkinReader in OpenFOAM can be a bit pickywith how the thermo file is prepared so a small modification to thethermo30.dat file is required. Change the first 5 lines in thermo.dat to:
! GRI-Mech Version 3.0 Thermodynamics released 7/30/99
! NASA Polynomial format for CHEMKIN-II
! see README file for disclaimer
THERMO ALL
300.000 1000.000 5000.000
and make sure that there are three spaces before 300.000 and two spacesbetween 300.000 and 1000.000 and 1000.000 and 5000.000 respectively.
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 5 / 29
Set up a tutorial case Use ISAT-CK7
Prepare the case
To change the flow configuration from a opposed diffusion flame to anopposed pre-mixed flame the boundary conditions of U, T, CH4, O2 andN2 needs to be updated. The case is converted to two stoichiometricpre-mixed streams of 305 K instead of the previous fuel and air stream.The laminar flame speed in this case is in the order of ∼ 0.45 so thevelocity is set to 0.8m/s to ensure that the flame is staying within thedomain. The case will be initialized with a zero velocity and hightemperature, 1800 K, zone in the middle of the domain where the twoopposed streams have their stagnation plane. To achieve this I have alsoprepared a setFieldsDict file.
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 6 / 29
Set up a tutorial case Use ISAT-CK7
Update BC 0/U
boundaryField
{
fuel
{
type fixedValue;
value uniform (0.80 0 0);
}
air
{
type fixedValue;
value uniform (-0.80 0 0);
}
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 7 / 29
Set up a tutorial case Use ISAT-CK7
Update BC 0/T
internalField uniform 305;
boundaryField
{
fuel
{
type fixedValue;
value uniform 305;
}
air
{
type fixedValue;
value uniform 305;
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 8 / 29
Set up a tutorial case Use ISAT-CK7
Update BC 0/T
outlet
{
type inletOutlet;
inletValue uniform 305;
value uniform 305;
}
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 9 / 29
Set up a tutorial case Use ISAT-CK7
Update BC 0/CH4
internalField uniform 0.055;
boundaryField
{
fuel
{
type fixedValue;
value uniform 0.055;
}
air
{
type fixedValue;
value uniform 0.055;
}
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 10 / 29
Set up a tutorial case Use ISAT-CK7
Update BC 0/O2
internalField uniform 0.220185;
boundaryField
{
fuel
{
type fixedValue;
value uniform 0.220185;
}
air
{
type fixedValue;
value uniform 0.220185;
}
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 11 / 29
Set up a tutorial case Use ISAT-CK7
Update BC 0/O2
outlet
{
type inletOutlet;
inletValue uniform 0.233;
value uniform 0.233;
}
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 12 / 29
Set up a tutorial case Use ISAT-CK7
Update BC 0/N2
internalField uniform 0.724815;
boundaryField
{
fuel
{
type fixedValue;
value uniform 0.724815;
}
air
{
type fixedValue;
value uniform 0.724815;
}
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 13 / 29
Set up a tutorial case Use ISAT-CK7
Update BC 0/N2
outlet
{
type inletOutlet;
inletValue uniform 0.767;
value uniform 0.767;
}
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 14 / 29
Set up a tutorial case Use ISAT-CK7
Running the case
To initialize the case a setFieldsDict file is included in the files. copy thesetFieldsDict file to system/. To finally run the case type:
blockMesh
setFields
ReactingFoam
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 15 / 29
Set up a tutorial case Use ISAT-CK7
Chemistry Speed up using ISAT-CK7
To speed up the chemistry the ISAT-CK7 may be used. In this case theopen source chemistry solver Cantera 2.2.0 is used for solving thechemistry. Download the cantera 2.2.0 files and put them under someappropriate location, for example user/Cantera:
http://sourceforge.net/projects/cantera/
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 16 / 29
Set up a tutorial case Use ISAT-CK7
Chemistry Speed up using ISAT-CK7, Cantera install
Before we compile Cantera the following needs to be installed:
g++
python
scons
libboost-all-dev
libsundials-serial-dev
For the Python module to work the following is required:
cython
python-dev
python-numpy
python-numpy-dev
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 17 / 29
Set up a tutorial case Use ISAT-CK7
Chemistry Speed up using ISAT-CK7, Cantera install
To make Cantera work along with ISAT the -fPIC (Position IndependentCode) flag needs to be added to the SConstruct file in the Cantera buildlibrary at the following lines:
L234: defaults.ccFlags = ’ ’ --> defaults.ccFlags = ’-fPIC’
L385: ’-03’), --> ’-fPIC -03’),
L560: ’-03’), --> ’-fPIC -03’),
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 18 / 29
Set up a tutorial case Use ISAT-CK7
Chemistry Speed up using ISAT-CK7, Cantera install
Compile Cantera by typing
scons build
scons install
When Cantera is compiled make sure that the fortran interface file forCantera exists:
/usr/local/lib/libcantera_fortran.a
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 19 / 29
Set up a tutorial case Use ISAT-CK7
Chemistry Speed up using ISAT-CK7
Download the ISAT-CK7 cantera fortran code and put it in some userspecified location, for example user/ISAT/:
https://github.com/nogenmyr/ISAT-CK7-Cantera
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 20 / 29
Set up a tutorial case Use ISAT-CK7
Chemistry Speed up using ISAT-CK7
Before building the ISAT CK7 Cantera package change the Cantera filepaths in /ISAT-CK7-Cantera-Master/ISAT/build-files/vars.mk to your ownCantera installation paths
CANTERA_LIBPATH=/usr/local/lib
CANTERA_INCPATH=/usr/local/include/cantera
CANTERA_SRC=/YOUR_CANTERA_SOURCE/cantera-2.2.0/src
Also make sure that the soft link to libcantera fortran.a (that washopefully created during the Cantera installation) inside/ISAT-CK7-Cantera-Master/ISAT dependencies/lib/ is working. If it isnot working make a new link to the appropriate location. Go to/CK7-Cantera-Master/ISAT/ and type:make
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 21 / 29
Set up a tutorial case Use ISAT-CK7
Chemistry Speed up using ISAT-CK7
The last part is to compile the OpenFOAM interface towards ISAT-CK7.Download the interface from:
https://github.com/nogenmyr/ISATChemistrySolver
and put it in /OpenFOAM/user/src/. To compile the code go to thedirectory where the Make directory is located:
cd /user/src/ISATChemistrySolver/lib/
And type:wmake
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 22 / 29
Set up a tutorial case Use ISAT-CK7
Chemistry Speed up using ISAT-CK7
In ISATChemistrySolver there’s a file called cti2xml.py, copy this file to$FOAM USER APPBINFinally a few soft links need to be set-up in $FOAM USER LIBBIN:
cd \$FOAM\_USER\_LIBBIN
ln -s .../ISAT-CK7-Cantera/ISAT/lib/libadifor.so
libadifor.so
ln -s .../ISAT-CK7-Cantera/ISAT/lib/libisat7_ser.so
libisat7_ser.so
ln -s .../ISAT-CK7-Cantera/ISAT/lib/libceq.so
libceq.so
ln -s .../ISAT-CK7-Cantera/ISAT/lib/libck_ext.so
libck_ext.so
ln -s .../ISAT-CK7-Cantera/ISAT/lib/libisatab_ser.so
libisatab_ser.so
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 23 / 29
Set up a tutorial case Use ISAT-CK7
Chemistry Speed up using ISAT-CK7
ln -s .../ISAT-CK7-Cantera/ISAT/lib/libct.so
libct.so
ln -s .../ISAT-CK7-Cantera/ISAT/lib/libisatck_ext.so
libisatck_ext.so
ln -s .../ISAT-CK7-Cantera/ISAT/lib/libell.so
libell.so
ln -s .../ISAT-CK7-Cantera/ISAT/lib/libisatck.so
libisatck.so
ln -s .../ISAT-CK7-Cantera/ISAT/lib/libice_pic.so
libice_pic.so
ln -s .../ISAT-CK7-Cantera/ISAT/lib/libisat_rnu.so
libisat_rnu.so
ln -s .../ISAT-CK7-Cantera/ISAT/lib/libsell.so
libsell.so
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 24 / 29
Set up a tutorial case Use ISAT-CK7
Chemistry Speed up using ISAT-CK7
Where ... is the full path to your Cantera installation. One way to do thisis through a text editor. Now ISAT-CK7 should be installed and linked toOpenFOAM. Copy the previous tutorial:
run
cp -r counterFlowFlame2D counterFlowFlame2DISAT
Change the chemistry solver in constant/chemistryProperties to ISAT:
chemistryType
{
chemistrySolver ISAT;
chemistryThermo psi;
}
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 25 / 29
Set up a tutorial case Use ISAT-CK7
Chemistry Speed up using ISAT-CK7
To give some input to the ISAT package, add the following ISATcoefficients:
ISATCoeffs
{
saveISATtree off;
externalCKWYP off;
constantPressure of;
}
The report will show how to add more additional features available withinthe ISAT-CK7-Cantera fortran module.
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 26 / 29
Set up a tutorial case Use ISAT-CK7
Chemistry Speed up using ISAT-CK7
To make OpenFOAM aware of that ISAT, and its sub-modules, exists thefollowing libraries must be included, preferably at the end, in yoursystem/controlDict file:
libs
(
"libISATChemistrySolver.so"
"libadifor.so"
"libceq.so"
"libct.so"
"libell.se"
"libisat7_ser.so"
"libisatab_ser.so"
"libisatck_ext.so"
"libisatck.so"
"libice_pic.so"
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 27 / 29
Set up a tutorial case Use ISAT-CK7
Chemistry Speed up using ISAT-CK7
"libisat_rnu.so"
"libck\_ext.so"
"liblapack.se.3"
"libmyCombustionModels.se"
"libsell.so"
)
Finally go to the chemkin directory where the drm19.dat file is stored.Convert the drm19.dat Chemkin format file to a Cantera mechanism andchange the name to chem.cti:
ck2cti --input drm19.dat --thermo thermo30.dat
mv drm19.cti chem.cti
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 28 / 29
Set up a tutorial case Use ISAT-CK7
Chemistry Speed up using ISAT-CK7
Run the python script cti2xml.py that should be placed in$FOAM USER APPBIN simply by typing cti2xml. This script generates achem.xml file. rename the chem.xml file to mech.xml and move one levelup:
mv chem.xml ../mech.xml
The case should now be prepared to run using ISAT. The chemistry willnow be solved within Cantera instead of within the build in OpenFOAMODE solvers. Run the case by typing:
blockMesh
setFields
reactingFoam
Daniel Moell ISAT-CK7 within OpenFoam 2015-12-08 29 / 29