Hi Gianfranco,
it might be a late reply, but I tried to do something similar. In my case I wanted to impose the derivative of the temperature, and I used the extensible reactor class, overwriting the temperature equation with after_eval.
In my case, I wanted to impose a linear temperature increase with a heating rate (HR) in K/min. The python code looks like:
gas = ct.Solution("gas.yaml")
gas_reactor = _RampGasReactor(gas, energy="on", volume=V_gas0, HR=HR)
class _RampGasReactor(ct.ExtensibleIdealGasMoleReactor):
"""IdealGasMoleReactor with energy equation replaced by dT/dt = HR/60."""
def __init__(self, *args, HR=10.0, **kwargs):
super().__init__(*args, **kwargs)
self._dTdt = HR / 60.0 # K/s
self._iT = None
def after_eval(self, t, LHS, RHS):
if self._iT is None:
self._iT = self.component_index("temperature")
LHS[self._iT] = 1.0
RHS[self._iT] = self._dTdt
You have to be careful however with the ideal reactor you are using, for instance the ConstPressure reactor uses the enthalpy as equation rather than the temperature one. I am using cantera 4.0 built from github source code, I think this should work also with your version as it has documentation on the current stable version on the website.
A much simpler approach if your reactive system is not too complex, could be to update manually after each time step the temperature of the phases, but I am not sure if this results in weird behaviours if the manually set time-steps are not sufficiently small.
Hope this helps,
Andrea