-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatic tracking of ReactorNet
state
#206
Comments
@speth Here is a draft of the feature discussed. If it's decided that this is a worthwhile contribution, I'd be happy to work on this once the best approach is agreed upon. |
The most important additional variables that come to mind would be the mass and/or volume of each reactor's contents. You could also consider whether there's a reasonable way to store quantities related mass flow controllers / valves / walls etc, although those aren't always uniquely associated with a particular reactor. |
Hi @corykinney ... great to see this popping up! A functionality like this was one of the motivations for porting
There aren't any reasons I can think of. You probably need a dedicated method to pass settings, but that's about it.
Time data should be first column (similar to position being first column in the
I believe user defined names should remain the default. I implemented something similar for |
I can't think of a deterministic approach for where and what to store for MFC/valve/wall quantities, but if Python callbacks are implemented, as @ischoegl suggested, in a streamlined way, perhaps we can leave it up to the user to define if they want to record any of that data and attached to which reactor's state. The user could define a single callback function that returns a dictionary of column names and the value for that timestep. For the IC engine example it could look like: ...
def cylinder_state():
dWv_dt = - (cyl.thermo.P - ambient_air.thermo.P) * A_piston * piston_speed(sim.time)
return {
"mdot_in": inlet_valve.mass_flow_rate,
"mdot_out": outlet_valve.mass_flow_rate,
"dWv_dt": dWv_dt)
} which could be set as the callback for the corresponding reactor's state. It seems like a streamlined way to include desired MFC/valve/wall quantities as well as user-calculated properties. |
@corykinney ... I believe this is mostly workable, with a tweak.
At least for some of the simpler solutions, you will face the limitation that callbacks return scalars (based on the C++ /Python |
I think there's a tradeoff between simplicity and flexibility here. If you need full flexibility, there's always the existing approach of collecting the relevant data as part of the integration loop and adding it to the As far as where to store the properties, I think you can make a pretty simple choice and associate the wall and flow device variables with the first/left reactor specified when creating the the connector. All you need to store for a flow device is the mass flow rate. For walls, I think it's just the velocity and heat transfer rate. If you do want to use a callback to populate user-specified columns, the |
@speth ... agreed on the tradeoff - I believe it makes sense to explore the middle ground. The status quo is clunky, whereas As an aside, doing a 'restart' from a collection of (fwiw, structural information is beyond the scope of |
Fwiw, Cantera/cantera#1765 implements auto-generated unique names for unnamed PS: one roadblock to this enhancement is that |
Abstract
The proposed enhancement is additional functionality for
ReactorNet
objects to automatically construct and updateSolutionArray
s for eachReactor
object in the network and to provide a convenient interface for accessing the state of the network at snapshots in time and the state of each reactor for the duration of the simulation.Motivation
Currently, users wishing to track the state of
Reactor
objects must construct aSolutionArray
object and manually append the reactor's thermodynamic state as desired. This is not too burdensome with a small number of reactor objects and when callingstep
manually; however, this makes it difficult to track network state at each time step when using other routines such asadvance_to_steady_state
that control the timestepping.Possible Solutions
Now that
SolutionArray
is implemented in C++, it is possible to have aReactorNet
object that automatically constructsSolutionArray
objects for eachReactor
object. Here are some considerations about how this could be implemented and what behavior might be desired:ReactorNet
class - an optional flag could be used to enable this functionality with it disabled by default. Are there any reasons why this would need to be separate?t
in eachSolutionArray
objects - are there any use cases that would necessitate support for additional extra variables?SolutionArray
objects could be made accessible through theReactorNet
by index number - would it be worth the additional complexity to support user-assigned names for reactors to make access more intuitive?References
Relevant Users' Group topic
The text was updated successfully, but these errors were encountered: