11function calculate_tgrad (sys:: AbstractODESystem ;
22 simplify= false )
3- isempty (sys. tgrad []) || return sys. tgrad [] # use cached tgrad, if possible
3+ isempty (get_tgrad ( sys) []) || return get_tgrad ( sys) [] # use cached tgrad, if possible
44
55 # We need to remove explicit time dependence on the state because when we
66 # have `u(t) * t` we want to have the tgrad to be `u(t)` instead of `u'(t) *
@@ -13,13 +13,13 @@ function calculate_tgrad(sys::AbstractODESystem;
1313 tgrad = [expand_derivatives (ModelingToolkit. Differential (iv)(r), simplify) for r in rhs]
1414 reverse_rule = Dict (map ((x, xt) -> x=> xt, detime_dvs .(xs), xs))
1515 tgrad = Num .(substitute .(tgrad, Ref (reverse_rule)))
16- sys. tgrad [] = tgrad
16+ get_tgrad ( sys) [] = tgrad
1717 return tgrad
1818end
1919
2020function calculate_jacobian (sys:: AbstractODESystem ;
2121 sparse= false , simplify= false )
22- isempty (sys. jac []) || return sys. jac [] # use cached Jacobian, if possible
22+ isempty (get_jac ( sys) []) || return get_jac ( sys) [] # use cached Jacobian, if possible
2323 rhs = [eq. rhs for eq ∈ equations (sys)]
2424
2525 iv = get_iv (sys)
@@ -31,7 +31,7 @@ function calculate_jacobian(sys::AbstractODESystem;
3131 jac = jacobian (rhs, dvs, simplify= simplify)
3232 end
3333
34- sys. jac [] = jac # cache Jacobian
34+ get_jac ( sys) [] = jac # cache Jacobian
3535 return jac
3636end
3737
@@ -162,7 +162,7 @@ function DiffEqBase.ODEFunction{iip}(sys::AbstractODESystem, dvs = states(sys),
162162 jac = _jac === nothing ? nothing : _jac,
163163 tgrad = _tgrad === nothing ? nothing : _tgrad,
164164 mass_matrix = _M,
165- jac_prototype = sparse ? similar (sys. jac [],Float64) : nothing ,
165+ jac_prototype = sparse ? similar (get_jac ( sys) [],Float64) : nothing ,
166166 syms = Symbol .(states (sys)),
167167 indepsym = Symbol (independent_variable (sys)),
168168 )
@@ -214,7 +214,7 @@ function ODEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys),
214214
215215 _M = (u0 === nothing || M == I) ? M : ArrayInterface. restructure (u0 .* u0' ,M)
216216
217- jp_expr = sparse ? :(similar ($ (sys. jac []),Float64)) : :nothing
217+ jp_expr = sparse ? :(similar ($ (get_jac ( sys) []),Float64)) : :nothing
218218
219219 ex = quote
220220 f = $ f
0 commit comments