I'm trying to understand what the events
parameter is doing in solve_ivp
and what this function that takes in time and another function as its parameters.
Also, would there be any changes in the number and size of the internal steps at those times when the function is 0?
CodePudding user response:
An event is the combination of a location and an action at that location. The location in most cases can be specified as the root of a function of time and state.
The events
parameter gets a list of root functions (or just the root function if there is only one). In the time loop of the solver, it is checked if there is a sign change in any of the root functions and then the apparent root is refined using the "dense output" interpolation of the stepper method.
The default action is to register the roots found in the t_events
and y_events
fields of the output object. Per decoration the action can be modified to terminate
. There is no provision for other actions, such as state or parameter changes.
No internal nodes and steps get modified, in the case of the terminate
action the event location is appended as final node to the standard output fields t,y
.