Skip to content

Commit 2b81431

Browse files
test: test solving ODEProblem with eval_expression = true
1 parent aa84f5e commit 2b81431

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

test/precompile_test.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Test
22
using ModelingToolkit
3+
using OrdinaryDiffEqDefault
34

45
using Distributed
56

@@ -38,3 +39,5 @@ ODEPrecompileTest.f_eval_bad(u, p, 0.1)
3839
@test parentmodule(typeof(ODEPrecompileTest.f_eval_good.f.f_oop)) ==
3940
ODEPrecompileTest
4041
@test ODEPrecompileTest.f_eval_good(u, p, 0.1) == [4, 0, -16]
42+
43+
@test_nowarn solve(ODEPrecompileTest.prob_eval)

test/precompile_test/ODEPrecompileTest.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,24 @@ const f_eval_bad = system(; eval_expression = true, eval_module = @__MODULE__)
3636
# Change the module the eval'd function is eval'd into to be the containing module,
3737
# which should make it be in the package image
3838
const f_eval_good = system(; eval_expression = true, eval_module = @__MODULE__)
39+
40+
function problem(; kwargs...)
41+
# Define some variables
42+
@independent_variables t
43+
@parameters σ ρ β
44+
@variables x(t) y(t) z(t)
45+
D = Differential(t)
46+
47+
# Define a differential equation
48+
eqs = [D(x) ~ σ * (y - x),
49+
D(y) ~ x *- z) - y,
50+
D(z) ~ x * y - β * z]
51+
52+
@named de = System(eqs, t)
53+
de = complete(de)
54+
return ODEProblem(de, [x => 1, y => 0, z => 0, σ => 10, ρ => 28, β => 8/3], (0.0, 5.0); kwargs...)
55+
end
56+
57+
const prob_eval = problem(; eval_expression = true, eval_module = @__MODULE__)
58+
3959
end

0 commit comments

Comments
 (0)