Running Cantera in matlab unix

139 views
Skip to first unread message

jnlhtcsync

unread,
Oct 7, 2018, 7:20:08 PM10/7/18
to Cantera Users' Group
Hello,
I succesfully instaled cantera 2.4 in Debian 9 with conda, but I would like to run the cantera toolbox on matlab under linux.
No matlab toolbox or folder was installed on linux environment.

It is possible to run cantera toolbox on unix matlab, or just it is possible under Windows.

Best regards,

P.S.: the installation instructions are very unclear and  fuzzy  

Bryan W. Weber

unread,
Oct 7, 2018, 7:29:01 PM10/7/18
to Cantera Users' Group
Hi,

Which installation instructions are you following? As it says on the "Other Linux Distributions" page, to compile and use the Matlab toolbox, you have to compile from source. Please follow the instructions here: https://cantera.org/install/other-linux-install.html#other-linux-distributions and add

matlab_path = /path/to/matlab/install

to your cantera.conf file. You'll need an installed copy of Matlab to compile and use the Matlab interface.

Please clarify which portion of the installation instructions aren't clear, I would very much like to fix that.

Best,
Bryan

jnlhtcsync

unread,
Oct 13, 2018, 9:52:08 AM10/13/18
to Cantera Users' Group
Hi Bryan,
Thank you for your answer. I finally installed and compiled Cantera in Debian for matlab.
When I said that the install instructions are no clear, I mean for the newbies in Cantera's like me. When the first time you open the installation instructions for Cantera, you find that the Conda Installation is the "Highly Recommended" and you follow the instructions to install it. Once done, you realize that is not the right one to work in matlab. When I read first about Cantera, one of the advantages of the suite was the possibility of using matlab instead use python. In my opinion "Highly Recommended" depends if you want just work on Conda environment.

Also, on the "Compile Cantera from Source", which is the best option in my opinion to install Cantera, there is a lack of requirements for its installation. There is a huge variety of linux distributions and, among them, not always the right packages are installed. For instance, in my raw Debian 9 installation, there wasn't installed g++ or gcc...
So I suggest to include a list of requirements to check before the compilation in the linux distribution. Here is mine:

* git
* scons
* gfortran
* gcc
* g++
* libboost_dev (C++ headers)
* Anaconda3 ( just for python and environment libraries)
* matlab (for use this interface)

Once you can follow the instructions as in "Compile Cantera from Source", just modifying the cantera.conf file with:

python_package='y'
python_cmd='$HOME/anaconda3/bin/python'
matlab_path='$HOME/MATLAB/RXXXXb'          # where RXXXXb is the release of the matlab version; if you plan use matlab

Then run 'scons help' to check all the rest of the compiling options
Then, as su :
Run 'scons build' for the compilation
Run 'scons test' to check that the compilation was right
Run 'scons install' to install the compilation in your system.

Finally in matlab, set the path '/usr/local/lib/cantera/matlab' as default.

Maybe in the installation instructions are assumed some aspects of the distribution, for instance, the default packages, but is just my opinion. I really don't like spending too much time looking what I need, or I have or I haven't in my linux distribution just looking where the commands crashes...
Thank you any way for you help. I hope my comments help in some way the Cantera community.
Best regards,

Javier

Bryan W. Weber

unread,
Oct 13, 2018, 10:20:51 AM10/13/18
to Cantera Users' Group
Hi Javier,

Thanks for your feedback! I just want to point out a few places where we have much of this information, and get your feedback on how it might be improved. (I just want to say, these questions may come across as sarcastic, but I mean them sincerely. We are always trying to improve!)

First, on the Conda installation instructions, it says in the paragraph at the top of the page: "Note that installing Cantera using Conda will only provide the Cantera Python module. If you want to use the other Cantera interfaces, see the OS-specific installation options." And on the main "Install" page, it specifically says that the Cantera Python interface can be installed with Conda: "Install the Cantera Python interface with Conda." Is there a way we can make it more clear that you can only install the Python module using conda? (Incidentally, we're working to be able to install all the interfaces with conda, but its not ready yet).

Second, the reason we highly recommend using the Conda installation is because the Python interface has more features and works better than the Matlab interface. Is there a particular reason you would prefer to use Matlab, why you cited that as a big advantage for Cantera?

Third, the installation requirements are linked from the bottom of the "Compilation" landing page. On the "Installation Requirements" page, there is a link at the top for both using Conda as the Python install for building, as well as the default package manager on your platform (e.g., here is for Debian). In the list for Debian, there is listed g++, python, scons, and libboost-dev, all the Python dependencies, and the fact that you have to install Matlab to be able to build the Matlab interface. I think the only one missing from your list is git, which we could certainly add. Can you think of more ways to make this information more accessible/easier to find?

Fourth, we don't recommend that you do the build and test steps as the super user, because then the build directory is owned by root and you cannot delete it as a normal user. We recommend building in a folder where the regular user has write access, so that the only time the super user is necessary is if you want to install to a folder where you don't have write access, e.g., /usr/local. The printout that shows after the build step finishes mentions that you may need sudo to install, depending on the location.

Finally, looking at it now, we don't actually say what to do for the install step, so that is something we will definitely improve.

Unfortunately, due to the number of possible platforms we support, it would be very difficult for us to try to install system-level dependencies from the build script. This is why we offer many alternative methods to install various interfaces without requiring the compile to be done on your machine. Unfortunately, the Matlab interface is very difficult for us to distribute a compiled copy, because you need a copy of the proprietary headers that Mathworks distributes with Matlab.

Hope that helps somewhat, and please do respond with your feedback, if you have some more!
Thanks again,
Bryan

jnlhtcsync

unread,
Oct 13, 2018, 12:31:29 PM10/13/18
to Cantera Users' Group
Dear Bryan,

Thanks for your comments. Once installed Cantera, I realized that all the information I missed the first time I tried the installation, it was on the web, but probably not in the better place. In my opinion, before the 'Quickstart' in the "Compiling Cantera from Source" should be preferable to find the "Compilation Requirements" just to check if we have all the needs...

I said that matlab has advantages for using Cantera because I use to program in matlab, and then, it is easier to combine my own codes with Cantera. But after what you said, maybe I will consider the python way.

Thank you to ask me again about how to improve the information.  Cantera is a very well reputed software in the scientific community and your efforts to maintain the suite are admirable. I would like to use this software because of this reputation.

I'm feeling a little silly after all asking you about stupid aspects on the installation of the code, the very first step before using it. It's annoying. I hope in the future my contributions will be more constructive.

(Sarcasm mode on)
Maybe is my opportunity to initiate the thread 'Cantera for Dummies'...
(Sarcasm mode off)

Best Regards
Javier

Bryan W. Weber

unread,
Oct 13, 2018, 8:45:47 PM10/13/18
to Cantera Users' Group
Hi Javier,

There are no silly questions here, it is very hard to write installation instructions that a new user can read, because I haven't been a new user is like 5 years. So I really want to make sure to get the right perspective. Thanks again for your feedback!

As for Matlab, I would personally really strongly recommend that you switch to Python. Aside from the Cantera interface being better supported, I find the ecosystem of tools to be much nicer and easier to use. Plus, since everything is open-source, you can use the tools from anywhere, no need to worry about connecting to a license server for Matlab. Finally, the syntax is close enough that making the transition is not that difficult (e.g., see here and many other places for a primer on switching).

Anyways, good luck, and please keep the questions (even the "silly" ones) coming!

Best,
Bryan
Reply all
Reply to author
Forward
0 new messages