# DAE problem set-up in DiffEq changed?

**URL:** <https://discourse.julialang.org/t/dae-problem-set-up-in-diffeq-changed/30330>\
**Category:** General Usage\
**Created:** [October 26, 2019, 11:56am UTC](https://discourse.julialang.org/t/dae-problem-set-up-in-diffeq-changed/30330 "2019-10-26T11:56:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [October 26, 2019, 11:56am UTC](https://discourse.julialang.org/t/dae-problem-set-up-in-diffeq-changed/30330/1 "2019-10-26T11:56:42Z")

</div>

I used DifferentialEquations.jl to solve a DAE in 2017-2018 or so. I just tried to re-run the Jupyter notebook, and now I get an error message… Here is the essence of my past set-up:

```julia
function seborg_is(err,dxdt,x,par,t)
...
end

```

The model has 45 variables (differential + algebraic). I have defined initial values `dxdt0` and `x0` that used to work. I have defined a parameter vector `par_is`. Then I do:

```julia
# Specifying differential variables
diff_vars = fill(false,45)
diff_vars[1:4] = true
# Time span
tspan = (0.,10.)
# Problem definition
probis = DAEProblem(seborg_is,dxdt0,x0,tspan,par_is,differential_vars=diff_vars)

```

Here, the 5th argument (`par_is`) is the parameter vector meant to be used in function `seborg_is`. The current documentation doesn’t really say whether I’m allowed to specify the parameter vector like this – this used to work, but may have changed??

When I specify the DAE problem `probis`, I get the following error message:

```julia
MethodError: no method matching setindex_shape_check(::Bool, ::Int64)
Closest candidates are:
  setindex_shape_check(!Matched::AbstractArray{#s75,1} where #s75, ::Integer) at indices.jl:218
  setindex_shape_check(!Matched::AbstractArray{#s75,1} where #s75, ::Integer, !Matched::Integer) at indices.jl:221
  setindex_shape_check(!Matched::AbstractArray{#s75,2} where #s75, ::Integer, !Matched::Integer) at indices.jl:225
  ...

Stacktrace:
 [1] macro expansion at .\multidimensional.jl:722 [inlined]
 [2] _unsafe_setindex!(::IndexLinear, ::Array{Bool,1}, ::Bool, ::UnitRange{Int64}) at .\multidimensional.jl:717
 [3] _setindex! at .\multidimensional.jl:712 [inlined]
 [4] setindex!(::Array{Bool,1}, ::Bool, ::UnitRange{Int64}) at .\abstractarray.jl:1074
 [5] top-level scope at In[47]:3

```

Questions:

1. What has changed?
2. How can I modify my code?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [October 26, 2019, 3:39pm UTC](https://discourse.julialang.org/t/dae-problem-set-up-in-diffeq-changed/30330/2 "2019-10-26T15:39:22Z")

</div>

> [@BLI](#):
>
> What has changed?

Nothing on DiffEqs side: the interface stayed the same.

> [@BLI](#):
>
> Here, the 5th argument ( `par_is` ) is the parameter vector meant to be used in function `seborg_is` . The current documentation doesn’t really say whether I’m allowed to specify the parameter vector like this – this used to work, but may have changed??

It can be literally any type: we just pass it through.

> [@BLI](#):
>
> How can I modify my code?

Look at the spot where the error is. Without seeing the code or the stack trace this is impossible for someone to help you with.bmy guess is that it was Julia 0.6 code and now you’re post 1.0, so it’s one of those changes like u[:]=… when it needs a .=

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [October 26, 2019, 8:11pm UTC](https://discourse.julialang.org/t/dae-problem-set-up-in-diffeq-changed/30330/3 "2019-10-26T20:11:57Z")

</div>

Thanks for tip. I’ll check again tomorrow. I thought I had tested the code on Julia v 1.2; the Jupyter notebook opened in v. 1.2. But maybe I didn’t run it.

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [October 27, 2019, 12:04pm UTC](https://discourse.julialang.org/t/dae-problem-set-up-in-diffeq-changed/30330/4 "2019-10-27T12:04:31Z")

</div>

> [@BLI](#):
>
> Then I do:
> 
> ```julia
> # Specifying differential variables
> diff_vars = fill(false,45)
> diff_vars[1:4] = true
> # Time span
> tspan = (0.,10.)
> # Problem definition
> probis = DAEProblem(seborg_is,dxdt0,x0,tspan,par_is,differential_vars=diff_vars)
> 
> ```

Ah. I needed to change `diff_vars[1:4] = true` to `diff_vars[1:4] .= true` – this is what caused the included error message.

[In addition, the `IDA()` solver has been split out into its own package `Sundials`, + I had to change `ones(array)` to `ones(size(array))` in other parts of my code…]
