GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ZhangYanTJU/fitData_Cantera: fit thermo file to a uniform common T for OpenFOAM

BranchesTags
Open more actions menu

Latest commit

 

History

11 Commits
11 Commits

Folders and files

NameName
Last commit message
Last commit date
LICENSE
LICENSE
 
 
N2.png
N2.png
 
 
OH.png
OH.png
 
 
README.md
README.md
 
 
badTcommon.py
badTcommon.py
 
 
chem.inp
chem.inp
 
 
fitData_Cantera.py
fitData_Cantera.py
 
 
mech.cti
mech.cti
 
 
thermo.dat
thermo.dat
 
 
thermoCorrected.dat
thermoCorrected.dat
 
 

Repository files navigation

fitData_cantera: fit thermo file to a uniform common T

As we know, OpenFOAM combines all species to a mixture by the mass fraction weighted average. But for thermo.dat, we have Tlow_ Thigh_ Tcommon_. During the average procedure, operator+= is called. You will find that the final mixture_ will get the lowest Tlow_, highest Thigh_. However, Tcommon_ is never changed, which means mixture_ will be that of the first species. Usually, Tcommon_ is 1000 K, but it's a different story for some species, such as 1400 K. If you, unfortunately, list the species 1400 K as the first one, as I warned here, you will face this problem after the Tmax of your CFD simulation reaches 1400 K:

Maximum number of iterations exceeded

It is because the Newton iterations failed when calculating temperature from enthalpy, and the discontinuous cp is the key to the problem. And this exactly attributes to the wrong Tcommon. The simplest but not perfect solution is to put the 1000 K species as the first one (in chem.inp, where OpenFOAM reads species list). Also, you can use fitData utility in Chemkin, which can only fit one species at a time.

This script is developed to completely solve this problem. Only need to run once this script, you'll get a fresh new thermo.dat, with a uniform Tcommon, which will give you continuous cp.

  • install Cantera
conda create --name spam --channel cantera cantera ipython matplotlib
  • activate Cantera
conda activate spam
  • transform your chemkin format mechanism to *.cti format
ck2cti --input=chem.inp --thermo=thermo.dat --output=mech.cti
  • run the script
python fitData_Cantera.py
  • you will get thermoCorrected.dat

Here is an example of the plotted figure. OH For OH, we fit the Tcommon from 1357 to 1000 K. cp_org is calculated by Cantera using the original mechanism file, which is set as the correct answer. cp_fit is calculated using the newly fitted coeffs with new Tcommon. And if you just manually change 1357 to 1000 in thermo.dat. You'll get the purple cp_bad, with a discontinuous cp. However, this is not the worst condition! And your case may still run normally, but with little error introduced.

If you mistakenly set a species with 'Tcommon = 1400 K' as the first species in 'chem.inp' (used in OpenFOAM), you will most likely get a wrong answer if the original Tcommon of N2 is 1000 K (here we assume N2 is the majority species). N2

About

fit thermo file to a uniform common T for OpenFOAM

Topics

canteraopenfoam

Resources

Readme
MIT license
Activity

Stars

20 stars

Watchers

1 watching

Forks

3 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.