I am new to Julia and have started implementing my project in a Jupyter notebook. As this is not great for debugging, I have now implemented the same code in VS Code. For reasons I don’t understand, the program throws an error when I try to specify a solver for my ODE problem:
sol = solve(ode, Tsit5())
There is no error if I change the above line to this:
sol = solve(ode)
The addition of other keyword argument pairs works fine too:
sol = solve(ode, saveat=ts, tstops=ts, dt=1e-2)
What do I need to do in VS Code to be able to specify an ODE solver in the solve function? I am using DifferentialEquations v6.18.0
Thank you for the quick response. I thought that this may be a general problem/ setting I didn’t know about and not specific to my code, so I did not include an example. I now see that this is not the case. Here is a simplified example of my code - it may not make much sense, but it does produce the error in VS Code:
# Load packages
using DifferentialEquations, Plots
#Model a single impulse as input
u = zeros(Int(600.0 / 0.05), 2)
u[6000:6004] .= 1
#Set parameters
A = [-1.1 0.0; 0.0 -1.1]
B = zeros(2,2,2)
C = [0.3 0.0; 0.0 0.3]
# ODE problem
function f!(x, p, t)
A, B, C, u, dt = p
# Get input at time t
idx = max(Int(ceil(t/dt)), 1)
ut = u[idx,:]
J = A
for i in 1:size(B, 3)
J += B[:,:,i]*ut[i]
end
J*x + C*ut
end
# Forward model
function forward_model(params, x0)
ts = range(0.05, step=0.05, stop=600.0) # sample times
tspan = (0.0, 600.0) # time span
ode = ODEProblem(f!, x0, tspan, params)
sol = solve(ode, Tsit5(), saveat=ts, tstops=ts)
return sol.u
end
# Test forward model
parameters = [A, B, C, u, 0.05]
x0 = zeros(2, 1) # initial condition
y = forward_model(parameters, x0)
Your wording here was a bit confusing to me, but this is just the linter being incorrect about the function call – there’s no error being thrown. We just present a speculative info hint (as indicated by “possible” in the message).
So this is a bug, but presumably not related to your code or the package code.
It actually exited with an error earlier, but now it doesn’t and I can’t reproduce it anymore. Maybe there was another issue with my code that I removed when producing my simplified example…
I will close the issue; thank you both for your answers again!