How to implement a stopping condition for scipy.solve_ivp (rather than integrating for a set time)?

Viewed 25

Currently my solve_ivp call requires a temperature range, i.e.

sol = solve_ivp(df, t, x0, args=system_constants, method='Radau')

where t is the time range solve_ivp should integrate across, df is the differential equation (the right hand side), and x0 is the initial condition.

However I would like to integrate until the solution of the differential equation being integrated reaches a certain value.

One thought I had on doing this was using a for loop with small time intervals, and checking the solution after each integration time interval, with the condition that integration should stop if the solution exceeds a certain value.

The system in question is actually a solid heating up. I want to heat until the solid reaches a certain temperature. I could manually check the solution array for this but I need it in code format also

Is there a standard way to implement a stopping condition like this?

0 Answers
Related