@@ -27,6 +27,11 @@ struct NonlinearSystem <: AbstractSystem
27
27
ps:: Vector
28
28
observed:: Vector{Equation}
29
29
"""
30
+ Jacobian matrix. Note: this field will not be defined until
31
+ [`calculate_jacobian`](@ref) is called on the system.
32
+ """
33
+ jac:: RefValue{Any}
34
+ """
30
35
Name: the name of the system
31
36
"""
32
37
name:: Symbol
@@ -61,9 +66,10 @@ function NonlinearSystem(eqs, states, ps;
61
66
if ! (isempty (default_u0) && isempty (default_p))
62
67
Base. depwarn (" `default_u0` and `default_p` are deprecated. Use `defaults` instead." , :NonlinearSystem , force= true )
63
68
end
69
+ jac = RefValue {Any} (Matrix {Num} (undef, 0 , 0 ))
64
70
defaults = todict (defaults)
65
71
defaults = Dict (value (k) => value (v) for (k, v) in pairs (defaults))
66
- NonlinearSystem (eqs, value .(states), value .(ps), observed, name, systems, defaults, nothing , connection_type)
72
+ NonlinearSystem (eqs, value .(states), value .(ps), observed, jac, name, systems, defaults, nothing , connection_type)
67
73
end
68
74
69
75
function calculate_jacobian (sys:: NonlinearSystem ;sparse= false ,simplify= false )
@@ -74,6 +80,7 @@ function calculate_jacobian(sys::NonlinearSystem;sparse=false,simplify=false)
74
80
else
75
81
jac = jacobian (rhs, vals, simplify= simplify)
76
82
end
83
+ get_jac (sys)[] = jac
77
84
return jac
78
85
end
79
86
0 commit comments