Skip to content

Commit f74cbcc

Browse files
authored
Merge pull request #1479 from SciML/uncache_jac
Invalidate system cache
2 parents 3f201b7 + 47dfccf commit f74cbcc

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/systems/abstractsystem.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,7 @@ function structural_simplify(sys::AbstractSystem; simplify=false)
929929
sys = tearing_reassemble(state, tearing(state), simplify=simplify)
930930
fullstates = [map(eq->eq.lhs, observed(sys)); states(sys)]
931931
@set! sys.observed = topsort_equations(observed(sys), fullstates)
932+
invalidate_cache!(sys)
932933
return sys
933934
end
934935

test/structural_transformation/tearing.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,18 @@ ms_eqs = []
212212
@named ms_model = compose(_ms_model,
213213
[mass])
214214

215+
calculate_jacobian(ms_model)
216+
calculate_tgrad(ms_model)
217+
215218
# Mass starts with velocity = 1
216219
u0 = [
217220
mass.s => 0.0
218221
mass.v => 1.0
219222
]
220223

221224
sys = structural_simplify(ms_model)
225+
@test sys.jac[] === ModelingToolkit.EMPTY_JAC
226+
@test sys.tgrad[] === ModelingToolkit.EMPTY_TGRAD
222227
prob_complex = ODAEProblem(sys, u0, (0, 1.0))
223228
sol = solve(prob_complex, Tsit5())
224229
@test all(sol[mass.v] .== 1)

0 commit comments

Comments
 (0)