Can't get the preconditioners to work for ode problem

I have been trying to learn how to use preconditioners while solving an ode but I get an error, and I don’t understand what I am doing wrong. I followed the tutorial on Solving Large Stiff Equations · DifferentialEquations.jl and tried to implement it in a minimal working example. The code is pasted below:


using DifferentialEquations
using LinearSolve
using LinearAlgebra
#using SparseArrays
using DelimitedFiles
using IncompleteLU
using Plots

function incompletelu(W,du,u,p,t,newW,Plprev,Prprev,solverdata)
  if newW === nothing || newW
    Pl = ilu(convert(AbstractMatrix,W), τ = 50.0)
  else
    Pl = Plprev
  end
  Pl,nothing
end

Base.eltype(::IncompleteLU.ILUFactorization{Tv,Ti}) where {Tv,Ti} = Tv

function eoms!(du,u,p,t)
    for i in 1:3
        du[i]=-p[i]*u[i]
    end
end
u0=ones(Float64,3)
tol=1e-8
reltolp=tol
abstolp=tol
tspan=(0,1)
p=[1,2,3]
prob=ODEProblem(eoms!,u0,tspan,p)
@time sol=solve(prob,KenCarp4(linsolve=KrylovJL_GMRES(),precs=incompletelu,concrete_jac=true),abstol=abstolp,reltol=reltolp,saveat=0.1)


#plot(sol,vars=(1))
#plot!(sol,vars=(2))
#plot!(sol,vars=(3))

However, when I run the code I get an error:

ERROR: LoadError: MethodError: no method matching ilu(::Matrix{Float64}; τ=50.0)
Closest candidates are:
  ilu(::SparseArrays.SparseMatrixCSC{ATv, Ti}; τ) where {ATv, Ti} at ~/.julia/packages/IncompleteLU/UBpTh/src/crout_ilu.jl:9

Has anyone who has encountered this problem or used preconditioners please help me?

You cannot apply iLU to a dense Jacobian. Define a sparse Jacobian like is done in the tutorial.