Problem in solve() DifferentialEquations. None algorithm define

Hi,

I am new to Julia. I am trying to integrate an ODE. It works in my colleagues PC but not in mine. It looks like the package has not been loaded but I did it at the beginning of the script. I have tried with many solvers and all gives the same error:
ERROR: UndefVarError: Vern7 not defined

The code is:

# Load pkgs and remove data -----------------------------------------------------
using DifferentialEquations
using DataFrames
using CSV
using Plots
using Shapefile
using PlotShapefiles
import GeoDataFrames as GDF
using LinearAlgebra
using ODE
#using LSODA
#using Interpolations
#using OrdinaryDiffEq

# For after do a separate file
#include("~/albo_mobility/code/Hanski/ode_model.jl") # Code with ODE model

# Set const parameters
# Set constants to estimate to random variables to create fake observed data
e = rand(Float64) * 0.01  # extinction constant (estimate)
c_d = rand(Float64) * 0.00000001  # colonization constant (estimate)
c_h = rand(Float64) * 0.001  # colonization constant (estimate)
xi = rand(Float64)  # dispersal scaling parameter (estimate)

println(e)

# These variables might be estimated in the future
m_c = 0.001 # probability of mosquito in a car
alpha = 1 / 200 # average natural dispersal distance

# Load data input
...

# Set parameters
t0=0
tf=1824
tspan = (t0, tf)
t_vect=1:tf

function fun(du, u, p, t)
  mat = exp.(-alpha*d_1)
  mat[diagind(mat)] .= 0 # Set to zero diagonal of distance
  Cd = c_d.*mat*u # Natural dispersal
  Ch = c_h.*(m_c*eta)*u # Human mobility
  du.= (xi .* Cd + (1 - xi) .* Ch) .* (1 .- u) - e .* u
end

p = 0 # We have to give a value
prob = ODEProblem(fun, pop_init, tspan, p)
rtol=1e-10
sol = DifferentialEquations.solve(prob,Tsits5()) # , maxiters=1e6) #reltol=1e-8) #, #
sol = OrdinaryDiffEq.solve(prob,Tsits5()) # , maxiters=1e6) #reltol=1e-8) #, #
sol = solve(prob,  Vern7()) # , maxiters=1e6) #reltol=1e-8) #, #

What Julia version and how did you install it?

Hi Chris,

I am using Julia 1.10.2. I install following the info in the website:

It says to run in the terminal:

curl -fsSL https://install.julialang.org | sh

and I use Visual code to run it. I am working in Ubuntu 20.04.4.

What is the output of:

using Pkg
Pkg.status()

?

It is solved. Thanks for the help

Do you know how it was solved? This might help others…

I do not know. Now i have the problem that each time I open visual code I have to install DifferentialEquations package. Otherwise I get the error: ERROR: LoadError: UndefVarError: SciMLBasenot defined. And now when i run the ODEProblem(fun, op,…) if give me the error that its not defined aswell…

What could be the reason?

You must be sure that the correct environment is opened. In VSCode,
at the bottom you can see the the active environment like:

Julia env: KiteControllers.jl

if the environment (Project.toml) in the folder KiteControllers.jl is active.

If you click on the name of the environment you get a dialog that allows you to activate a different environment.

If DifferentialEquations.jl is part of your active project, then you can use it.

It says Julia env:v1.10 So where the julia is intalled. Should I create another enviroment? I always using this

Always use a separate environment per project.
Like:

mkdir myproject
cd myproject
julia --project="."

And then in Julia:

using Pkg
pkg"add DifferentialEquations"
# ... and all the other packages you need for this specific project

This avoids conflicts if you need the newest version of a package in project A, but that conflicts with another package that you need in project B…

After you created, start Julia like this:

julia --project

If you open a folder in VSCode it activates the project (Project.toml) that is present in that folder automatically.

Perfect, thanks a lot. I have created a env in the git hub repo.

1 Like

I have used the enviroment as you told me. Today I open visual code in the environment that I have created and yesterday everything works but today I get the same problem with the using DifferentialEquations :

DifferentialEquations
Info Given DifferentialEquations was explicitly requested, output will be shown live
WARNING: Method definition (::Type{Base.MPFR.BigFloat})(Base.Irrational{:invsqrt2Ο€}) in module IrrationalConstants at irrationals.jl:223 overwritten in module StatsFuns on the same line (check for duplicate calls to include).
ERROR: Method overwriting is not permitted during Module precompilation. Use __precompile__(false) to opt-out of precompilation.
βœ— Adapt β†’ AdaptStaticArraysExt
? Distributions
? DiffEqNoiseProcess
βœ— SteadyStateDiffEq
? DiffEqFinancial
? StochasticDiffEq
? MultiScaleArrays
? DifferentialEquations
0 dependencies successfully precompiled in 34 seconds. 131 already precompiled.
6 dependencies failed but may be precompilable after restarting julia
6 dependencies had output during precompilation:
β”Œ StochasticDiffEq
β”‚ ERROR: LoadError: ArgumentError: Package AdaptStaticArraysCoreExt does not have Adapt in its dependencies:
β”‚ - You may have a partially installed environment. Try Pkg.instantiate()
β”‚ to ensure all packages in the environment are installed.
β”‚ - Or, if you have AdaptStaticArraysCoreExt checked out for development and have
β”‚ added Adapt as a dependency but haven’t updated your primary
β”‚ environment’s manifest file, try Pkg.resolve().
β”‚ - Otherwise you may need to report an issue with AdaptStaticArraysCoreExt
β”‚ Stacktrace:
β”‚ [1] macro expansion
β”‚ @ ./loading.jl:1776 [inlined]
β”‚ [2] macro expansion
β”‚ @ ./lock.jl:267 [inlined]
β”‚ [3] __require(into::Module, mod::Symbol)
β”‚ @ Base ./loading.jl:1753
β”‚ [4] #invoke_in_world#3
β”‚ @ ./essentials.jl:926 [inlined]
β”‚ [5] invoke_in_world
β”‚ @ ./essentials.jl:923 [inlined]
β”‚ [6] require(into::Module, mod::Symbol)
β”‚ @ Base ./loading.jl:1746
β”‚ [7] include
β”‚ @ ./Base.jl:495 [inlined]
β”‚ [8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
β”‚ @ Base ./loading.jl:2222
β”‚ [9] top-level scope
β”‚ @ stdin:3
β”‚ in expression starting at /home/marta/.julia/packages/Adapt/Ur60R/ext/AdaptStaticArraysExt.jl:1
β”‚ in expression starting at stdin:3
β”‚ β”Œ Error: Error during loading of extension AdaptStaticArraysExt of Adapt, use Base.retry_load_extensions() to retry.
β”‚ β”‚ exception =
β”‚ β”‚ 1-element ExceptionStack:
β”‚ β”‚ Failed to precompile AdaptStaticArraysExt [e1699a77-9e31-5da8-bb3e-0a796f95f0a0] to β€œ/home/marta/.julia/compiled/v1.10/AdaptStaticArraysExt/jl_oqeB7G”.
β”‚ β”‚ Stacktrace:
β”‚ β”‚ [1] error(s::String)
β”‚ β”‚ @ Base ./error.jl:35
β”‚ β”‚ [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
β”‚ β”‚ @ Base ./loading.jl:2468
β”‚ β”‚ [3] compilecache
β”‚ β”‚ @ ./loading.jl:2340 [inlined]
β”‚ β”‚ [4] (::Base.var"#968#969"{Base.PkgId})()
β”‚ β”‚ @ Base ./loading.jl:1974
β”‚ β”‚ [5] mkpidlock(f::Base.var"#968#969"{Base.PkgId}, at::String, pid::Int32; kwopts::@Kwargs{stale_age::Int64, wait::Bool})
β”‚ β”‚ @ FileWatching.Pidfile ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:93
β”‚ β”‚ [6] #mkpidlock#6
β”‚ β”‚ @ ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:88 [inlined]
β”‚ β”‚ [7] trymkpidlock(::Function, ::Vararg{Any}; kwargs::@Kwargs{stale_age::Int64})
β”‚ β”‚ @ FileWatching.Pidfile ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:111
β”‚ β”‚ [8] #invokelatest#2
β”‚ β”‚ @ ./essentials.jl:894 [inlined]
β”‚ β”‚ [9] invokelatest
β”‚ β”‚ @ ./essentials.jl:889 [inlined]
β”‚ β”‚ [10] maybe_cachefile_lock(f::Base.var"#968#969"{Base.PkgId}, pkg::Base.PkgId, srcpath::String; stale_age::Int64)
β”‚ β”‚ @ Base ./loading.jl:2983
β”‚ β”‚ [11] maybe_cachefile_lock
β”‚ β”‚ @ ./loading.jl:2980 [inlined]
β”‚ β”‚ [12] _require(pkg::Base.PkgId, env::Nothing)
β”‚ β”‚ @ Base ./loading.jl:1970
β”‚ β”‚ [13] __require_prelocked(uuidkey::Base.PkgId, env::Nothing)
β”‚ β”‚ @ Base ./loading.jl:1812
β”‚ β”‚ [14] #invoke_in_world#3
β”‚ β”‚ @ ./essentials.jl:926 [inlined]
β”‚ β”‚ [15] invoke_in_world
β”‚ β”‚ @ ./essentials.jl:923 [inlined]
β”‚ β”‚ [16] _require_prelocked
β”‚ β”‚ @ ./loading.jl:1803 [inlined]
β”‚ β”‚ [17] _require_prelocked
β”‚ β”‚ @ ./loading.jl:1802 [inlined]
β”‚ β”‚ [18] run_extension_callbacks(extid::Base.ExtensionId)
β”‚ β”‚ @ Base ./loading.jl:1295
β”‚ β”‚ [19] run_extension_callbacks(pkgid::Base.PkgId)
β”‚ β”‚ @ Base ./loading.jl:1330
β”‚ β”‚ [20] run_package_callbacks(modkey::Base.PkgId)
β”‚ β”‚ @ Base ./loading.jl:1164
β”‚ β”‚ [21] _tryrequire_from_serialized(modkey::Base.PkgId, path::String, ocachepath::String, sourcepath::String, depmods::Vector{Any})
β”‚ β”‚ @ Base ./loading.jl:1487
β”‚ β”‚ [22] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)

I do not know why this is happening. I have check that I am in the environment that I have created yesterday.
If I rerun the using DifferentialEquations after the error it works. But there is another issue with the function ODEProblem
ERROR: UndefVarError: ODEProblem not defined

Do you know what its the problem?