1
1
function calculate_tgrad (sys:: AbstractODESystem ;
2
2
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
4
4
5
5
# We need to remove explicit time dependence on the state because when we
6
6
# 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;
13
13
tgrad = [expand_derivatives (ModelingToolkit. Differential (iv)(r), simplify) for r in rhs]
14
14
reverse_rule = Dict (map ((x, xt) -> x=> xt, detime_dvs .(xs), xs))
15
15
tgrad = Num .(substitute .(tgrad, Ref (reverse_rule)))
16
- sys. tgrad [] = tgrad
16
+ get_tgrad ( sys) [] = tgrad
17
17
return tgrad
18
18
end
19
19
20
20
function calculate_jacobian (sys:: AbstractODESystem ;
21
21
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
23
23
rhs = [eq. rhs for eq ∈ equations (sys)]
24
24
25
25
iv = get_iv (sys)
@@ -31,7 +31,7 @@ function calculate_jacobian(sys::AbstractODESystem;
31
31
jac = jacobian (rhs, dvs, simplify= simplify)
32
32
end
33
33
34
- sys. jac [] = jac # cache Jacobian
34
+ get_jac ( sys) [] = jac # cache Jacobian
35
35
return jac
36
36
end
37
37
@@ -162,7 +162,7 @@ function DiffEqBase.ODEFunction{iip}(sys::AbstractODESystem, dvs = states(sys),
162
162
jac = _jac === nothing ? nothing : _jac,
163
163
tgrad = _tgrad === nothing ? nothing : _tgrad,
164
164
mass_matrix = _M,
165
- jac_prototype = sparse ? similar (sys. jac [],Float64) : nothing ,
165
+ jac_prototype = sparse ? similar (get_jac ( sys) [],Float64) : nothing ,
166
166
syms = Symbol .(states (sys)),
167
167
indepsym = Symbol (independent_variable (sys)),
168
168
)
@@ -214,7 +214,7 @@ function ODEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys),
214
214
215
215
_M = (u0 === nothing || M == I) ? M : ArrayInterface. restructure (u0 .* u0' ,M)
216
216
217
- jp_expr = sparse ? :(similar ($ (sys. jac []),Float64)) : :nothing
217
+ jp_expr = sparse ? :(similar ($ (get_jac ( sys) []),Float64)) : :nothing
218
218
219
219
ex = quote
220
220
f = $ f
0 commit comments