|
96 | 96 | nlprob_sjac = NonlinearProblem(rn, u0, ps; jac = true, sparse = true)
|
97 | 97 |
|
98 | 98 | # Checks that Jacobians ar identical.
|
| 99 | + # Approx is due to https://github.com/SciML/ModelingToolkit.jl/issues/3554. |
99 | 100 | function eval_jac(prob, sparse)
|
100 | 101 | J = sparse ? deepcopy(prob.f.jac_prototype) : zeros(length(prob.u0), length(prob.u0))
|
101 | 102 | ModelingToolkit.is_time_dependent(prob) ? prob.f.jac(J, prob.u0, prob.p, 0.0) : prob.f.jac(J, prob.u0, prob.p)
|
102 | 103 | return J
|
103 | 104 | end
|
104 | 105 | @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 |
106 | 108 | end
|
107 | 109 | end
|
108 | 110 |
|
|
136 | 138 | jac_sparse = jac_eval(rn, u0, ps, t_val; sparse = true)
|
137 | 139 |
|
138 | 140 | # 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 |
140 | 143 | mat = factor*rand(rng, length(u0), length(u0))
|
141 | 144 | @test jac_sparse * mat ≈ jac * mat
|
142 | 145 | end
|
|
0 commit comments