cantera with octave

459 views
Skip to first unread message

C W

unread,
Sep 4, 2015, 8:17:34 AM9/4/15
to Cantera Users' Group
   I'm trying to run Cantera on windows with octave but not getting far.

        Here's my configuration:
        windows 10
        octave 3.6.4
        cantera install with Cantera-2.2.0-x86.msi
        
        
        I followed the installation instructions here:
        http://cantera.github.io/dev-docs/sphinx/html/install.html#sec-install-win
        to the letter:
        1) added the PYTHON_CMD environment variable
        2) added all the toolbox folder with subfolders to the matlab (octave) path.

        When I run different post-install tests I run into trouble:

        octave-3.6.4.exe:36> gas1=GRI30
        error: 'ctmethods' undefined near line 20 column 8
        error: called from:
        error:   c:\Program Files\Cantera\matlab\toolbox\@XML_Node\XML_Node.m at line 20, column 6
        error:   c:\Program Files\Cantera\matlab\toolbox\@Solution\Solution.m at line 47, column 5
        error:   c:\Program Files\Cantera\matlab\toolbox\GRI30.m at line 33, column 7
        octave-3.6.4.exe:36> gas = IdealGasMix('gri30.cti')
        error: 'ctmethods' undefined near line 20 column 8
        error: called from:
        error:   c:\Program Files\Cantera\matlab\toolbox\@XML_Node\XML_Node.m at line 20, column 6
        error:   c:\Program Files\Cantera\matlab\toolbox\@Solution\Solution.m at line 47, column 5
        error:   c:\Program Files\Cantera\matlab\toolbox\IdealGasMix.m at line 55, column 15
       
 

        The closest I see to ctmethods in the matlab toolbox  folder is ctmethods.mexw32

        Could you share some guidance as to how I might get this to work?

        Thanks very much in advance

Bryan W. Weber

unread,
Sep 4, 2015, 8:41:28 AM9/4/15
to Cantera Users' Group
Hello,

Welcome to Cantera! The first thing to check is that you're using the right bitness of the library - either 64-bit or 32-bit, depending on your version of Octave. You didn't specify in your post, so can you check that the version of Cantera and the version of Octave have the same bitness?

The ctmethods file is a compiled library that is specific to how MATLAB calls C/C++ functions. It seems like (from some very brief research) the linking steps between MATLAB and Octave are a little bit convoluted: https://hgomersall.wordpress.com/2013/02/19/squishing-matlab-mex-files-into-octave/ That post is about Linux, where such fixing such problems tends to be easier than on Windows. If you're running everything with the same bitness and it still doesn't work, you might have to compile Cantera from source and replace the MATLAB building commands with similar commands specific to Octave: https://www.gnu.org/software/octave/doc/interpreter/Mex_002dFiles.html I'm not really sure, as I have no experience with Octave, but please let us know how the bitness check turns out, and we'll be happy to help with whatever else comes up.

Best,
Bryan

Bryan W. Weber

unread,
Sep 4, 2015, 8:42:12 AM9/4/15
to Cantera Users' Group
By the way, x86 stands for 32-bit and x64 stands for 64-bit.

Bryan

C W

unread,
Sep 4, 2015, 11:14:23 AM9/4/15
to Cantera Users' Group
Hi, thanks for your reply.

  All the programs are installed as 32 bit.

  I should add that I also installed the python-only version of the program using
  Cantera-Python-2.2.0-x86-py2.7.msi
  and the startup tests ran fine from the python command line.

  I could in principle run with python, I have to admit that I feel more comfortable with octave and thought I'd ask about octave since it is a reasonably popular free alternative to matlab, and if nobody asked before this could be useful to others. I realized that the mex dll, having been compiled to talk with matlab, might not quite work with octave. I should add that this is the "standalone" version of octave, not the one embedded in cygwin.  I also  have cygwin installed, so in principle I could try any modifications you can suggest for running from cygwin with octave. But I am far from proficient, I can handle some c but c++ is still on my to-learn list.

  Since there are so many potential threads to this discussion I might as well add two more :-)

  First I am wondering how the mex interface is set up, since python appears to be required still with the matlab installation (as suggested by the use of a windows environment flag for the python path). If mex is used to speak with the c++ routines directly, what is the role of python? This is more out of curiosity.

 I want to apply cantera to a set of chemical equilibrium problems of the type  n*a + m*b <--> c, and am finding with my scripts using Newton-Raphson (such as octave's standard routine fsolve) don't converge. I think the problem is that some of the concentrations become negligible and the computation become unstable. I've tried a lot of freely available alternative matlab/octave routines and also minimizing the quadratic version of the problem but not much helps. I figured cantera might do the trick. Any comments on this specific application would be welcome.

Finally, I am also wondering how much numerical accuracy improves with the 64 bit versions.

Thanks again,

Christoph

Ray Speth

unread,
Sep 4, 2015, 11:41:24 AM9/4/15
to Cantera Users' Group
Christoph,

This thread on the Octave mailing list suggests that mex extensions are source compatible, but not binary compatible. In principle, if you compile Cantera yourself, you should be able to point it at the Octave header files instead of the Matlab header files and generate an extension that is compatible with Octave, but I've never tried this.

Whichever interface you use Cantera from, Python is needed for translating CTI input files into an internally-used (XML) format.

Regards,
Ray

C W

unread,
Sep 4, 2015, 1:23:19 PM9/4/15
to Cantera Users' Group
Thanks for your leads on how to fix this, looks promising. It's dawning on me that python is an easier route but if I have some time I'll dig into this. Thanks again, Christoph

Hassan Bahramian

unread,
Feb 16, 2016, 10:43:42 AM2/16/16
to Cantera Users' Group
Hello Christoph,
I came across the same error, you mentioned above. I wanted to ask you If you could solve this issue or not. Could you please help me?

best,
Hassan

emil

unread,
Feb 19, 2016, 3:19:32 AM2/19/16
to Cantera Users' Group


Hi,
long time ago I made Cantera (version 1.7)  work with Octave. To do so I had to hack the init scripts, it was not straightforward but still doable.
The report is here
https://groups.google.com/forum/#!topic/cantera-users/bYkxmg7FR8U

kind regards
emil

Hassan Bahramian

unread,
Feb 19, 2016, 6:39:00 AM2/19/16
to Cantera Users' Group
Dear Emil,

As I noticed you did it in Linux, while I am trying to do so in Windows 7.
Can you guide me to solve this issue in Windows as well?
Best,
Hassan

emil

unread,
Feb 19, 2016, 8:41:32 AM2/19/16
to Cantera Users' Group


Am Freitag, 19. Februar 2016 12:39:00 UTC+1 schrieb Hassan Bahramian:
Dear Emil,

As I noticed you did it in Linux, while I am trying to do so in Windows 7.
Can you guide me to solve this issue in Windows as well?
Best,
Hassan
On Friday, 19 February 2016 09:19:32 UTC+1, emil wrote:

Dear Hassan,

I am sorry, I don't have the time to look into that further right at the moment. If it is not straightforward to use octave I would suggest to use the python interface. The whole python scientific stack has evolved into somthing pretty powerful, and you might use an interface like the jupyter notebook.
With kind regards 
Emil Widmann
Reply all
Reply to author
Forward
0 new messages