I want to know what would be the best (computationally efficient, good-looking code) way to handle discontinuity using odeint. Is there any example code?
I am simulating something like a feedback controlled motor whose angle is measured digitally by a rotary encoder. Rotary encoder output, y, can be modeled like y=floor(angle) where angle is a real number.
I know, conceptually, what to do. During the simulation, I have to find the time when angle crosses integer values, then go back to the previous step, integrate up to that time of crossing, adjust the state, y, according to discontinuity, and restart integration from the same point of time.
After some googling, I found the code below. But I do not see the function, make_const_step_time_range, available in the library.
In page 18 of http://meetingcpp.com/tl_files/mcpp/slides/12/odeint.pdf:
auto iter = boost::find_if(
make_const_step_time_range(rk4,ode, x, t1, t2, dt),
[](const std::pair< state_type &, double> &x) {
return ( x.first[0] < 0.0 ); } );
I'm using boost_1_54_0.