Skip to content

Commit cb5ee42

Browse files
committed
approx in jac evaluations
1 parent de4506e commit cb5ee42

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/simulation_and_solving/jacobian_construction.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,15 @@ let
9696
nlprob_sjac = NonlinearProblem(rn, u0, ps; jac = true, sparse = true)
9797

9898
# Checks that Jacobians ar identical.
99+
# Approx is due to https://github.com/SciML/ModelingToolkit.jl/issues/3554.
99100
function eval_jac(prob, sparse)
100101
J = sparse ? deepcopy(prob.f.jac_prototype) : zeros(length(prob.u0), length(prob.u0))
101102
ModelingToolkit.is_time_dependent(prob) ? prob.f.jac(J, prob.u0, prob.p, 0.0) : prob.f.jac(J, prob.u0, prob.p)
102103
return J
103104
end
104105
@test eval_jac(oprob_jac, false) == eval_jac(sprob_jac, false) == eval_jac(nlprob_jac, false)
105-
@test eval_jac(oprob_sjac, true) == eval_jac(sprob_sjac, true) == eval_jac(nlprob_sjac, true)
106+
@test eval_jac(oprob_sjac, true) eval_jac(sprob_sjac, true) atol = 1e-14 rtol = 1e-14
107+
@test eval_jac(oprob_sjac, true) eval_jac(nlprob_sjac, true) atol = 1e-14 rtol = 1e-14
106108
end
107109
end
108110

@@ -136,7 +138,8 @@ let
136138
jac_sparse = jac_eval(rn, u0, ps, t_val; sparse = true)
137139

138140
# Check correctness (both by converting to sparse jac to dense, and through multiplication with other matrix).
139-
@test Matrix(jac_sparse) == jac
141+
# Approx is due to https://github.com/SciML/ModelingToolkit.jl/issues/3554.
142+
@test Matrix(jac_sparse) jac atol = 1e-14 rtol = 1e-14
140143
mat = factor*rand(rng, length(u0), length(u0))
141144
@test jac_sparse * mat jac * mat
142145
end

0 commit comments

Comments
 (0)