Is there a way to set Non Negativity, with CVODE_BDF()~ Sundials Pkg, as isoutofdomain() was ignored-Thanks?

Hello there,

Earlier I had asked a question about prevent Domain errors , and non-negativity,

Related to this, I want to apply this to CVODE_BDF, but I believe is not compatible with Sundials, it raises the error it will ignore. I have seen some threads you have recommended also Positive Domain, but the links did not work, and I cannot find any information about this method. On a side note, I will like to find one about isoutofdomain also, as I know how to apply it to all states by the “Any” method, but not so much by specific one’s.

This is the link I found helpful , but some of the links linked to the respective information did not work for me. Once more thank you!

Christian

Related to this, I want to apply this to CVODE_BDF, but I believe is not compatible with Sundials, it raises the error it will ignore.

Yes, and I don’t know if we can make it compatible.

I have seen some threads you have recommended also Positive Domain, but the links did not work, and I cannot find any information about this method.

https://diffeq.sciml.ai/latest/features/callback_library/#PositiveDomain-1

On a side note, I will like to find one about isoutofdomain also, as I know how to apply it to all states by the “Any” method, but not so much by specific one’s.

What do you mean?

1 Like

Thank you Chris, the positive domain link was not working for me before, but now it is, but Positive domain, will not be an option to explore for CVODE_BDF, right? As it seems to be applicable for call backs, which applies to the julia solvers within your DifferentialEquations solvers, right? Thank you once more, for answering the question about this option applied to CVODE_BDF.

Thank you.

Christian,

Yes, in principle it should work. If it doesn’t, open an issue.

1 Like

Thank you Chris! I will try it.

C

Hi Chris, please, let me know if I should open a new issue for all of this, I would gladly do it, but here is some questions- Thanks… have you written an example on positive domain? I cannot seem to find any , example, and I am experiencing problems downloading DiffEqCallbacks , I am using julia version 1.2.0, thank you. Also, the github for the library mentioned this is for julia solvers, thus would this work for CVODE_BDF() just checking, I am going in the right track ( with version, etc). I have seen one example were they pass cb into the solver, and then do positivedomain(1.0) , but I am not getting what it is doing. On the other hand ,Is outofdomain work for me , using like yo suggest Kencarp4(autodiff= off), isoutofdomain=(u,p,t) → any(x → (x < 0), u) is the option I apply, what I meant to ask earlier better , to choose what state I want to only have this non negative on like if I want x1 → (x1 <0) , u1). Again thank you!

The latest versions of the library require v1.4. I would highly recommend upgrading to v1.4 unless you really need v1.2 for some reason.

What do you mean?

It’s a Julia function, so make that functino true only when specific values are negative, like: isoutofdomain=(u,p,t)-> any(x -> x<0,u[[1,5,9,10]])

1 Like

Thank you so much for your response Chris. Your comments about isoutofdomain and the notion of passing the indecing to the function made it very clear, thank you. For the call back gotcha, I will upgrade and test again and report, thank you. Lastly, the post I was refering to about positive domain was this one, Domain Troubles with Differential Equations Solver (with non-auto-differentiable function inside the ODE def), here I saw positive domain potentially being used and passed as option, positive domain( 1.0 ) , I really did not quite get how to use positive domain from the that, or even the main definition , I will take another look soon, and especially once I have the call back library. - Thank you so much for your quick response and help. !!