Backwards compatability support of the new return codes to Symbols will be deprecated

I’m very new to Julia so I might be misinterpreting what’s happening here.

When solving a stiff differential equation I am constantly getting “Backwards compatability support of the new return codes to Symbols will be deprecated with the Julia v1.9 release” (sic)

I just use: (the equation is complicated but I am not using symbols (?) )

ODEProblem(Bloch!,u0_i,tspan,p_i)
solve(prob, alg, saveat=time_save_step, dtmin=dtmin, maxiters=maxiters,reltol=reltol,abstol=abstol,force_dtmin=force_dtmin)

It directs me to: retcodes.jl

then

function Base.convert(::Type{ReturnCode.T}, retcode::Symbol)
    @warn "Backwards compatability support of the new return codes to Symbols will be deprecated with the Julia v1.9 release. Please see https://docs.sciml.ai/SciMLBase/stable/interfaces/Solutions/#retcodes for more information"

How shall I prepare my code to avoid this warning? or How can I avoid these warnings when I run the scripts and the code in REPL?

Thanks

There was a recent change from symbols to enums in return codes, see here: Change return codes to Enum · Issue #867 · SciML/DifferentialEquations.jl · GitHub

Are you checking the return code somewhere? Something like:

sol = solve(…)
if sol.retcode == :success
…
end

The new way of doing that would be:

sol = solve(…)
if sol.retcode == SciMLBase.Success
…
end

Hard to debug further without seeing the code, but the warning is definitely related to this. :slight_smile:

2 Likes

Thank you.

Actually, I am not checking anything, at least not explicitly. I believe DifferentialEquations is doing it. Does that make sense?

A snip of the code showing (a simplified version of ) the differential equations and the solver is shown below

using Plots; gr()
using LinearAlgebra
using Statistics
using DifferentialEquations, ODEInterfaceDiffEq

## SOLVER PARAMETERS [https://diffeq.sciml.ai/stable/basics/common_solver_opts/]
time_save_step=0.50e-9; # interval for saving each flight (unrelated to solver step size)
reltol=1e-10 ; # relative tolerance
abstol=1e-10 ; # absolute tolerance
maxiters=1000000000000 ;
dtmin=1e-23 ; # minimum time step
force_dtmin = true ;
alg = radau() ; # algorithm 


function Bloch!(du,u,p,t)
    # p[1]: v            u[1]: theta_e
    #                    u[2]: theta_n
    #                    u[3]: phi_e
    #                    u[4]: phi_n
  
    du[1] = -gammae*(Bn*sin(u[2])*sin(u[4]-u[3])  )
    du[2] = -gamman*(Be*sin(u[1])*sin(u[3]-u[4]) +) )  
    du[3] = -gammae*(getBzt(t) + Bn*cos(u[2]) - cot(u[1])*(Bn*sin(u[2])*cos(u[4]-u[3])  ) )
    du[4] = -gamman*(getBzt(t) + Be*cos(u[1]) - cot(u[2])*(Be*sin(u[1])*cos(u[3]-u[4]) ) )
  
end

prob = ODEProblem(Bloch!,[the0_list, thn0_list, phe0_list, phn0_list],tspan,[v]);
@time ssol = solve(prob, alg, saveat=time_save_step, dtmin=dtmin, maxiters=maxiters,reltol=reltol,abstol=abstol,force_dtmin=force_dtmin);
sol =  mapreduce(permutedims, vcat, ssol.u);

The warning appears when solve executes

Warning: Backwards compatability support of the new return codes to Symbols will be deprecated with the Julia v1.9 release. Please see SciMLSolutions · SciMLBase.jl for more information

Would be better if I wait for the new version of DifferentialEquations?

The code above doesn’t run. It has syntax errors (brackets in du[3] = …) and when removing those it still doesn’t run, because the definitions of the tspan, v and the initial states are missing.

When I minimize your example and keep all the options and the algorithm, there is no warning thrown:

using DifferentialEquations, ODEInterfaceDiffEq

## SOLVER PARAMETERS [https://diffeq.sciml.ai/stable/basics/common_solver_opts/]
time_save_step=0.50e-9; # interval for saving each flight (unrelated to solver step size)
reltol=1e-10 ; # relative tolerance
abstol=1e-10 ; # absolute tolerance
maxiters=1000000000000 ;
dtmin=1e-23 ; # minimum time step
force_dtmin = true ;
alg = radau() ; # algorithm 

u0 = rand(4)
tspan = (0.0, 1e-8)

function Bloch!(du,u,p,t)
    du .= -u
end

prob = ODEProblem(Bloch!,u0,tspan,nothing);
@time ssol = solve(prob, alg, saveat = time_save_step, dtmin = dtmin, maxiters = maxiters, reltol = reltol, abstol = abstol, force_dtmin = force_dtmin);

So, I guess the MWE above does either not hit the correct parts of the code or the warning isn’t triggered with the most current versions of DifferentialEquations.jl and ODEInterfaceDiffEq.jl; I used 7.6.0 and 3.12.0 in an otherwise clean environment.

Can you provide a working MWE that shows the above warning?

1 Like

I’m having a similar problem involving this warning message. I’m using a package that calls solve thousands of times during an operation, and seems to print the warning message to the console for every solve call. I can replicate the warning message using a simple example from DifferentialEquations.jl:

using DifferentialEquations

#Half-life of Carbon-14 is 5,730 years.
C₁ = 5.730

#Setup
u₀ = 1.0
tspan = (0.0, 1.0)

#Define the problem
radioactivedecay(u,p,t) = -C₁*u

#Pass to solver
prob = ODEProblem(radioactivedecay,u₀,tspan)
sol = solve(prob,Tsit5());

julia> 

┌ Warning: Backwards compatability support of the new return codes to Symbols will be deprecated with the Julia v1.9 release. 
Please see https://docs.sciml.ai/SciMLBase/stable/interfaces/Solutions/#retcodes for more information
└ @ SciMLBase C:\Users\ander\.julia\packages\SciMLBase\QqtZA\src\retcodes.jl:355

and my actual use case, an example from LongwaveModePropagator.jl:

using LongwaveModePropagator
using LongwaveModePropagator: QE, ME

# vertical dipole transmitter at 24 kHz
tx = Transmitter(2.4e4)

# sample vertical electric field every 5 km out to 2000 km from tx
rx = GroundSampler(0:5e3:2000e3, Fields.Ez)

# vertical magnetic field
bfield = BField(50e-6, π/2, 0)

# daytime ionosphere
h = 75      # km
β = 0.35    # km⁻¹

electrons = Species(QE, ME, z->waitprofile(z, h, β), electroncollisionfrequency)

# "typical" earth ground 
ground = Ground(10,1e-4)

waveguide = HomogeneousWaveguide(bfield, electrons, ground)

# return the complex electric field, amplitude, and phase
E, a, p = propagate(waveguide, tx, rx);

(large number of warning messages omitted).

Since I’m not developing this package, I don’t want to spend too much time messing around with the internals. It looks like printing the warning messages to the console is severely impacting performance, however. Will using something like Suppressor.jl to prevent these warning messages from being printed help speed up the code, or do I need to find and alter whatever part of the code is checking the retcode?

I’m in the same situation and a StackOverflowException is raised.

For the carbon example I don’t get any warnings. I’m on the latest OrdinaryDiffEq: 6.44.0.

Have you tried updating your version of DifferentialEquations to the latest version?

1 Like

Hmm, I thought I had updated DifferentialEquations, but looks like my OrdinaryDiffEq was out of date (6.27.2). I updated both (to 7.7.0 and 6.44.0, respectively) and that solved it.

For anyone interested, Suppressor reduced runtime pre-update to about the same as post-update runtime. Just prepend @suppress to the line calling solve().