Sundials.jl --> LoadError: TypeError: in cfunction, expected Union{}, got Int32

Hello guys,
I am trying to solve a ODE using the CVODE_BDF() solver of the Sundials package. Here is a snippet of my code:

Defining the function

function f(dX, X, p, t)
#A, B, D, E, Inh = p
#dX = -A*X + (B - X)*E - (D + X)*Inh
dX[1] = -p[1]*X[1] + (p[2] - X[1])*p[4] - (p[3] + X[1])*p[5]

# in case there are more than one output neuron
#for i = 1:length(X)
#    dX[i] = -A*X[i] + (B - X[i])*E - (D + X[i])*Inh
#end
return dX[1]

end

ODE

x0 = Array{Float64}(undef, 1)
fill!(x0, X0) # fill array with initial values
#x0 = X0
p = [2.0, 253.0, 16.0, Ex, Inh]
tspan = (0.0,0.5)
prob = ODEProblem(f,x0,tspan,p)
sol = solve(prob,CVODE_BDF(linear_solver=:Dense))
plot(sol)

#Unfortunately, I am getting this Error:

LoadError: TypeError: in cfunction, expected Union{}, got Int32

in expression starting at /Users/Boris/Documents/adaptive_CS.jl:70

__CVode at cvodes.jl:312 [inlined]

CVode(::Sundials.Handle{Sundials.CVODEMem}, ::Float64, ::Array{Float64,1}, ::Array{Float64,1}, ::Int32) at cvodes.jl:317

#I don’t understand what is going on. Can someone help with this? I will appreciate it.

1 Like

Can you do ]st and post your package versions? Do you happen to be using a 32-bit OS?

Hey Chris,
Thanks for the reply. For some reason the code [sol = solve(prob,CVODE_BDF(linear_solver=:Dense))] works perfectly fine now. I just restarted Atom I guess. For the record I am using Julia version 1.1.1 on a MacBook air 64-bit.

2 Likes