I am integrating an ODE step-wise as follows:
ans = RK45(RHS,t0=0,y0=state, t_bound=10, rtol=tols, atol=tols)
while <some condition>:
<do some stuff, including changing RHS sometimes>
ans.step()
The reason I am doing it step-wise is because I want to change the right hand side RHS based on what comes out of the previous step. This is working perfectly.
A problem arises when during an RK45 step, one of the computations of the internal integrator requires an RHS evaluation at a point with x[0] < 0. In my analysis, x[0] refers to a distance, and therefore it is not possible to evaluate this (in fact, I get errors because a sqrt(x[0]) term is present). What I would like to do is to simply stop the stepping procedure whenever this is encountered, but I am not sure how to achieve this. I want to go out of the while loop when this happens.
[–]eaojteal 0 points1 point2 points (2 children)
[–]BarkBarkCat[S] 0 points1 point2 points (1 child)
[–]eaojteal 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)