I’m using odeint to simulate a system wherein there are several variables which should not go less than zero.
Is there an appropriate way to bound a variable in odeint to a particular range?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no such possibility in odeint. And I guess there are no algorithms which could do that. You must somehow encode the bound in your ODE.
If you only want to find a bound during the evolution of your system use a loop like
Two side nodes, maybe this is the case for your problem:
There are special algorithms for ODEs with have conservation laws where the algorithm ensures that the conservation law holds, see the symplectic solvers for example.
If you bound is already encode in some way in your ODE and the bound is anyhow reached you must shorten the stepsize of the solver.