From charlesreid1

Adding Python Class via C plus plus

Two Approaches

There are two ways to add new Python classes within Cantera. The first is the easy but less flexible Python method, and the second is the more difficult but more flexible C++ method.

Python Approach

The first, and easiest, is to extend the existing Cantera Python classes using inheritance. This does not modify any of Cantera's underlying behavior, but allows you to wrap it and extend it. This is the right approach if you're happy with how Cantera works, and you want to make creating Reactors and Reactor Networks easier.

I illustrate this approach by creating a residence time reactor, which extends the Cantera Reactor class. The residence time reactor takes a residence time as a constructor argument, does some calculations, then initializes the Cantera Reacotr (i.e., itself) with the right parameters: Cantera/ResidenceTimeReactor

C++ Approach

The second, more difficult, but much more flexible, way to add new Python classes to Cantera is to add new classes to Cantera's C++ interface, then add extra code to allow Python to call the C++ object. This allows you to really dig into Cantera and provides you with much more flexibility, at the cost of more "infrastructure" code written around the new C++ code.