Hi Unni,
Using the sim.reinitialize()
function frequently prevents the Sundials integrator from operating efficiently, which it can only do when it is running uninterrupted. I would recommend implementing your imposed temperature distribution using the ExtensibleReactor class. This way, you can set the energy_enabled
option on the Reactor
object to False
, eliminating the energy equation from the system, and then implementing a modification to update_state
that will set the temperature according to your input. This way, the temperature will be updated as part of the internal calculations initiated by Sundials, and the solver will be to run with reasonable time steps.
Regards,
Ray
Hi Unni,
Sorry, I maybe should have clarified, the update_state
method is not a place to modify the state vector y
that is provided by the ODE solver. There’s actually no point at which you should modify the function inputs that come from Sundials, as I believe it risks messing up the internal state of the solver.
I looked at this a bit more, and I unfortunately don’t see a consistent way to achieve this right now, without having to fully reimplement the eval
method as well. The difficulty is that the update_state
is responsible for several things, including updating the ThermoPhase
object, saving that state, and setting consistent values for the mass and volume of the reactor based on that, but methods for all of those pieces are not currently exposed in Python. In particular, following the C++ implementation, I think what you would want to do (in theory) is use an after_update_state
method that would look something like:
def after_update_state(self, y):
# composition and pressure will be set by base method
self.gas.TP = some_function_of_t(self.net.time), None
self.volume = self.mass / self.gas.density
self.update_connected(false) # saves the current thermo state
However, there’s currently no way to call the base update_connected
method from the Python delegate class, and I’m not sure of a good workaround.
Regards,
Ray
Ray,
Thanks for the very helpful information, I will consider other options then.
Sincerely,
Unni
--
You received this message because you are subscribed to a topic in the Google Groups "Cantera Users' Group" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/cantera-users/0IeoYgEr-Ng/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
cantera-user...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/cantera-users/4a7678c6-c25d-4f95-8342-e8f573cab4e6n%40googlegroups.com.