Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "MATLABDiffEq"
uuid = "e2752cbe-bcf4-5895-8727-84ebc14a76bd"
version = "1.5.0"
version = "1.5.1"

[deps]
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
Expand All @@ -11,7 +11,7 @@ Reexport = "189a3867-3050-52da-a836-e630ba90ab69"

[compat]
DiffEqBase = "6.122, 7"
MATLAB = "0.8, 0.9, 0.10"
MATLAB = "0.8.1, 0.9, 0.10"
ModelingToolkit = "8, 9, 10, 11"
ParameterizedFunctions = "5"
PrecompileTools = "1.1"
Expand Down
91 changes: 59 additions & 32 deletions test/matlab_runtime_tests.jl
Original file line number Diff line number Diff line change
@@ -1,37 +1,64 @@
# These tests require MATLAB runtime to be available.
# They test the actual ODE solving functionality.
using DiffEqBase, MATLABDiffEq, ParameterizedFunctions
# These tests exercise the actual ODE solving functionality, which requires a
# usable MATLAB engine. They are gated on the engine being startable: on CI
# runners (and any machine without a licensed/working MATLAB) starting an
# MSession is impossible, so the engine-dependent smoke tests are skipped with a
# notice rather than failing. Where a working MATLAB engine is present the full
# solve path runs and must succeed.
using DiffEqBase, MATLABDiffEq, ParameterizedFunctions, MATLAB, Test

f = @ode_def_bare LotkaVolterra begin
dx = a * x - b * x * y
dy = -c * y + d * x * y
end a b c d
p = [1.5, 1, 3, 1]
tspan = (0.0, 10.0)
u0 = [1.0, 1.0]
prob = ODEProblem(f, u0, tspan, p)
sol = solve(prob, MATLABDiffEq.ode45())

function lorenz(du, u, p, t)
du[1] = 10.0(u[2] - u[1])
du[2] = u[1] * (28.0 - u[3]) - u[2]
return du[3] = u[1] * u[2] - (8 / 3) * u[3]
# `libmx_size == 0` means MATLAB.jl was built without a MATLAB installation
# (the build-time CI fallback), so the engine libraries were never loaded.
# Even when libraries are present, starting an MSession can still fail (no
# license, no display), so probe an actual session before running the solves.
function matlab_engine_available()
MATLAB.libmx_size > 0 || return false
return try
MATLAB.MSession(0)
true
catch
false
end
end
u0 = [1.0; 0.0; 0.0]
tspan = (0.0, 100.0)
prob = ODEProblem(lorenz, u0, tspan)
sol = solve(prob, MATLABDiffEq.ode45())

algs = [
MATLABDiffEq.ode23
MATLABDiffEq.ode45
MATLABDiffEq.ode113
MATLABDiffEq.ode23s
MATLABDiffEq.ode23t
MATLABDiffEq.ode23tb
MATLABDiffEq.ode15s
]
@testset "MATLAB runtime solve" begin
if !matlab_engine_available()
@info "MATLAB engine not available on this machine; skipping engine-dependent solve tests."
else
f = @ode_def_bare LotkaVolterra begin
dx = a * x - b * x * y
dy = -c * y + d * x * y
end a b c d
p = [1.5, 1, 3, 1]
tspan = (0.0, 10.0)
u0 = [1.0, 1.0]
prob = ODEProblem(f, u0, tspan, p)
sol = solve(prob, MATLABDiffEq.ode45())
@test length(sol.t) > 0

function lorenz(du, u, p, t)
du[1] = 10.0(u[2] - u[1])
du[2] = u[1] * (28.0 - u[3]) - u[2]
return du[3] = u[1] * u[2] - (8 / 3) * u[3]
end
u0 = [1.0; 0.0; 0.0]
tspan = (0.0, 100.0)
prob = ODEProblem(lorenz, u0, tspan)
sol = solve(prob, MATLABDiffEq.ode45())
@test length(sol.t) > 0

algs = [
MATLABDiffEq.ode23
MATLABDiffEq.ode45
MATLABDiffEq.ode113
MATLABDiffEq.ode23s
MATLABDiffEq.ode23t
MATLABDiffEq.ode23tb
MATLABDiffEq.ode15s
]

for alg in algs
sol = solve(prob, alg())
for alg in algs
sol = solve(prob, alg())
@test length(sol.t) > 0
end
end
end
Loading