Hello all!
I want to do some tests with GPU Parallel Ensemble Simulation using DifferentialEquations.jl. As a starting point, I was looking into the example in the DiffEqGPU.jl page. Regarding Stiff ODEs, it’s said that:
Stiff ODEs require the analytical solution of every derivative function it requires. For example, Rosenbrock methods require the Jacobian and the gradient with respect to time, and so these two functions are required to be given. Note that they can be generated by the modelingtoolkitize approach.
Since my model is stiff (I use CVODE_BDF from Sundials.jl) and analytical Jacobians/gradients are impractical for this model, I wanted to use ModelingToolkit.jl to generate these for me.
However, when trying to generate the Jacobian and the time gradient for the Lorenz system from the example, I’m getting an error:
function lorenz(du,u,p,t)
du[1] = p[1]*(u[2]-u[1])
du[2] = u[1]*(p[2]-u[3]) - u[2]
du[3] = u[1]*u[2] - p[3]*u[3]
end
u0 = Float32[1.0;0.0;0.0]
tspan = (0.0f0,100.0f0)
p = [10.0f0,28.0f0,8/3f0]
prob = ODEProblem(lorenz,u0,tspan,p)
sys = modelingtoolkitize(prob)
sys_jac = eval(generate_jacobian(sys)[2])
sys_tgrad = eval(generate_tgrad(sys)[2])
func = ODEFunction(sys,jac=sys_jac,tgrad=sys_tgrad)
ERROR: TypeError: non-boolean (var"#126#127") used in boolean context
Stacktrace:
[1] (ODEFunction{true})(sys::ODESystem, dvs::Vector{Term{Real, Base.ImmutableDict{DataType, Any}}}, ps::Vector{Sym{Real, Base.ImmutableDict{DataType, Any}}}, u0::Nothing; version::Nothing, tgrad::Function, jac::Function, eval_expression::Bool, sparse::Bool, simplify::Bool, eval_module::Module, steady_state::Bool, checkbounds::Bool, sparsity::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ ModelingToolkit C:\Users\Ricardo\.julia\packages\ModelingToolkit\tMgaW\src\systems\diffeqs\abstractodesystem.jl:272
[2] #ODEFunction#387
@ C:\Users\Ricardo\.julia\packages\ModelingToolkit\tMgaW\src\systems\diffeqs\abstractodesystem.jl:235 [inlined]
Am I using the wrong ModelingToolkit function? Maybe I’m not passing the correct part of the functions? I’m very unfamiliar with ModelingToolkit, so any help is appreciated!