Rare, seemingly random segmentation fault and read only memory error: Why? How do I fix?

358 Views Asked by At

I'm trying to solve a system of DAE's in julia using sundials.jl. The original code works fine, but a monte carlo simulation for uncertainty quantification sometimes causes a segmentation fault.

`struct s_base
    s1::Float64
    s2::Float64
end


#DAE Tests
using DifferentialEquations
using Sundials

function f(out,du,u,p,t)
  out[1] = - p.s1*u[1]              + p.s2*u[2]*u[3] - du[1]
  out[2] = + p.s1*u[1] - 3e7*u[2]^2 - p.s2*u[2]*u[3] - du[2]
  out[3] = u[1] + u[2] + u[3] - 1.0
end

u₀ = [1.0, 0, 0]
du₀ = [-0.04, 0.04, 0.0]
tspan = (0.0,100000.0)


differential_vars = [true,true,false]


for n=1:1000000
    s=s_base(.04,1e4)
    prob = DAEProblem(f,du₀,u₀,tspan,s,differential_vars=differential_vars)
    sol = solve(prob,IDA())
end
`

I created the above toy example by modifying the dae example in the julia documentation to show the problem, but the incidence of error in the toy is lower than in the actual code (Though it still occurs).

Thanks for any help anyone might have!

0

There are 0 best solutions below