# Is there a way to impose positive domain on a selection of variables in odesolver

**URL:** https://discourse.julialang.org/t/is-there-a-way-to-impose-positive-domain-on-a-selection-of-variables-in-odesolver/74424
**Category:** New to Julia
**Tags:** question
**Created:** [January 11, 2022, 7:49pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-impose-positive-domain-on-a-selection-of-variables-in-odesolver/74424 "2022-01-11T19:49:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Shashank](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shashank/32/12323_2.png) [@Shashank](https://discourse.julialang.org/u/Shashank)
#### Post date: [January 11, 2022, 7:49pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-impose-positive-domain-on-a-selection-of-variables-in-odesolver/74424/1 "2022-01-11T19:49:58Z")

</div>

I am trying to solve 4 coupled differential equations the first two of them should always be positive while the 3rd and 4th can be positive or negative. I found that I can impose a positive domain on all four variables using

`sol = solve(prob,AutoVern7(Rodas5()),callback=PositiveDomain(),reltol=1e-8,abstol=1e-8)`

But is there a way to restrict the positive domain to a list of variables? Ideally, my plan is to work with a huge system where every third and fourth variable out of a few hundred has to be positive while others can be negative.

---

<div class="post-metadata">

### Author: ![contradict](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@contradict](https://discourse.julialang.org/u/contradict)
#### Post date: [January 11, 2022, 8:11pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-impose-positive-domain-on-a-selection-of-variables-in-odesolver/74424/2 "2022-01-11T20:11:55Z")

</div>

I think you should be able to use [`isoutofdomain`](https://diffeq.sciml.ai/stable/basics/common_solver_opts/#Miscellaneous). Something like

```
outofdomain(u, p, t) = u[1] < 0.0 || u[2] < 0.0

soln = solve(prob, ..etc; isoutofdomain=outofdomain)

```
