CounterflowDiffusionFlame - set_initial_guess()

293 views
Skip to first unread message

Scott Shaw

unread,
Feb 18, 2018, 5:43:20 AM2/18/18
to Cantera Users' Group

Hi,

I recently updated my Cantera version to use the latest 2.4.0 development release.
I have a script that runs a CounterFlowDiffusionFlame reaction, which has stopped working since the upgrade.

The problem is setting the initial guess

f.set_initial_guess(fuel="CH4") 

This returns the error message 'set_initial_guess() got an unexpected keyword argument 'fuel'
Looking at the documentation the function has been changed from version 2.3 from taking parameters


set_initial_guess(fuel=Noneoxidizer=Nonestoich=None
Set the initial guess for the solution. The initial guess is generated by assuming infinitely-fast chemistry.

http://www.cantera.org/docs/sphinx/html/cython/onedim.html?highlight=set_initial_guess#cantera.CounterflowDiffusionFlame.set_initial_guess



To not taking parameters in version 2.4, but if no parameters are supplied I get a "float division by zero" error.


set_initial_guess()

Set the initial guess for the solution. The initial guess is generated by assuming infinitely-fast chemistry.

http://cantera.github.io/dev-docs/sphinx/html/cython/onedim.html?highlight=counterflowdiffusionflame#counterflowdiffusionflame


I'm guessing there is a bug in the code since it has been updated. Could somebody investigate, please? (Or point me in the right direction and I can locate where the bug is occurring). Thanks 

Ray Speth

unread,
Feb 18, 2018, 8:40:30 AM2/18/18
to Cantera Users' Group
Scott,

Can you please post a complete example demonstrating the problem, including the CTI file if it's one of the built-in ones? This certainly isn't broken in all cases, as the code currently passes the test suite, which does cover this function. Please also let us know what operating system / compiler / etc. you are using, in case that could be a factor.

Regards,
Ray

Scott Shaw

unread,
Feb 19, 2018, 3:49:07 AM2/19/18
to Cantera Users' Group
Morning Ray,

Thanks for getting back to me, I appreciate it.

I've created a simple example of the problem and I've attached the files in a zip. I've just noticed that I get the same error from the solver if I comment out the set_initial_guess() (See included screenshots).

I have compiled the cantera master branch using the intel MKL compiler because I need to be able to run multiple simulations at the same time. I followed these instructions to do the installation: 

GCC++ version: 4.8.4
MKL 2018.1.163
Anaconda 3-5.0.1
Python 3.6.3

The server has Ubuntu installed, the system information is below
Linux 3.13.0-135-generic #184-Ubuntu SMP Wed Oct 18 11:55:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux 

I have a couple of other scripts, that use "IdealGasReactor" and "FreeFlame" which are currently working OK, so it doesn't seem to be a system-wide issue if that information is useful.

Regards
Scott
Counterflow - example.zip

Bryan W. Weber

unread,
Feb 19, 2018, 5:47:54 AM2/19/18
to Cantera Users' Group
Hi Scott,

If you're planning to use Anaconda, we do have a conda package that's about 6 months out of date, but still based on master at that time: https://anaconda.org/Cantera/cantera/files You can install it with

conda install -c cantera/label/dev cantera

If you need a more recent commit, I might suggest using the MKL that can be installed by conda, and skipping using the Intel compilers. The reason is that in my experience, the speedup from using MKL (which has parallel solvers for matrices) is way more important than the tiny speed boost you might get by using the Intel compilers themselves. If you want to go that route, I'd suggest the following:

1) Create an environment to store the build dependencies:

conda create -n canterabuild scons cython numpy mkl python=3.6 boost

and activate it

conda activate canterabuild

2) In cantera.conf, add the lines

blas_lapack_libs = 'mkl_rt,dl'
blas_lapack_dir
= '/path/to/anaconda/envs/canterabuild/lib'
boost_inc_dir
= '/path/to/anaconda/envs/canterabuild/include'
python2_package
= 'none'
python3_package
= 'full'
f90_interface
= 'n'
python3_prefix
= 'USER'
prefix
= '/home/username/.local'

3) Build, test, and install the package:

scons build -j4
PYTHONPATH
=/path/to/cantera/build/python3 python -m unittest -v cantera.test
scons install

I'm not sure if this will fix your issue (and thanks for providing the input files and details). If it doesn't fix the problem, can you provide the output of

scons build VERBOSE=True dump

By the way, if you monitor your processes with top while the test is running, you should see the CPU usage of the Python process jump over 100% for some (not all) of the Python-specific tests. That tells you that MKL is solving the problem in parallel. Finally, the reason I didn't suggest using scons test here was that on my Mac I had some test failures of the C++ interface that shouldn't affect the Python module, but it might be macOS specific. Nonetheless, all the Python tests passed, so the Python module should work for you.

Best,
Bryan

Ray Speth

unread,
Feb 19, 2018, 9:56:29 PM2/19/18
to Cantera Users' Group
Scott,

The error message is a bit unhelpful, but the underlying problem is the fact that in your script, you have the fuel and oxidizer compositions being identical. The method for determining the initial profile assumes that there should be a point somewhere where the equivalence ratio is 1.0, but this can't happen in this case, hence the error.

As you note, the error occurs whether or not you call `f.set_initial_guess()`. In fact, part of the point of the revisions to this function were so that you would not normally need to call this function explicitly.

Regards,
Ray

Scott Shaw

unread,
Feb 21, 2018, 8:55:04 AM2/21/18
to Cantera Users' Group
Hi Ray & Bryan,

OK, thank-you for all the information. I really appreciate the help.
I am going to work through the problem now, I should have enough information to go off :-)

Regards
Scott
Reply all
Reply to author
Forward
0 new messages