Hi Ray,
thank you for your suggestion. I have tested multiple configurations following your suggestion but I am still currently failing.
I have built cantera from source in a conda environment both with the base configuration and with the additional optional C++ libraries (eigen, sundials, hdf, highfive, yaml-cpp, fmt). I do not see any noticeable difference in computational speed between the two configurations, the second one might be even slightly slower for my case.
With respect to my case, my goal is to simulate a system with a liquid phase whose volume changes due to gas formation from reactions. As a simple test setup, I used a closed batch reactor with a gas volume 1000 times larger than the liquid one, to reduce pressure overshoots. I have tested two mechanisms formulations:
- Define a fake surface phase with a species "FAKE(S)" and call all liquid reactions from there as suggested in https://groups.google.com/g/cantera-users/c/MtAvcMooNwo/m/ClnYbmLJAAAJ.
- Define an interface-phase with the missing species added as "(aq)". Following the previous example and your suggestion, this means the liquid-phase reaction is now C(L)=>A(aq) and then on the interface phase occurs the reaction A(aq)=>A.
To solve the mechanisms, I have tried two reactor setups:
- Define a scipy system of equation with the reaction rates being computed through cantera (custom-made function "rhs" being passed to scipy.solve_ivp())
- Define an extensible cantera reactor where the volume (or reactive surface) varies with the volume computed from the species densities. I then have two reactors, one with liquid reactions and one with gas reactions that are joined into a reactor net
In both cases, the mechanisms are defined starting from surf = ct.Interface() and then the bulk phase arre called with surf.adjacent[]. For a small test mechanism (2 liquid species, 10 unimolecular liquid reactions), after tuning, I get results with scipy in 0.1 seconds and with cantera in about 20 seconds.
The issues appear when I try using a real radical mechanism with 50 liquid species and 4000 reactions. In this case, neither solver is able to return any result and they usually crash after one hour without reaching even 1% of conversion. To check if the mechanism itself was problematic, I run an homogeneous single phase pfr, which gave results within less than a minute (although wrong as the "aq" species accumulate diluting the system).
Are these difficulties expected for this type of multiphase stiff system?
I am considering a different extensible-reactor strategy: explicitly mapping/transferring (aq) source terms into corresponding gas-phase species source terms, so I can avoid explicit surface/interface phases and possibly reduce stiffness. Can this approach be beneficial?
Since I have a source build, I could also implement a custom reactor class in C++. Would that require changes to YAML interpretation/parsing, or can this be done mostly at the reactor-equation level while keeping standard YAML kinetics definitions?
Kind regards,
Andrea