@@ -32,14 +32,15 @@ https://docs.sciml.ai/DiffEqDocs/stable/basics/solution/
32
32
exited due to an error. For more details, see
33
33
[the return code documentation](https://docs.sciml.ai/SciMLBase/stable/interfaces/Solutions/#retcodes).
34
34
"""
35
- struct RODESolution{T, N, uType, uType2, DType, tType, randType, P, A, IType, S,
35
+ struct RODESolution{T, N, uType, uType2, DType, tType, randType, discType, P, A, IType, S,
36
36
AC <: Union{Nothing, Vector{Int}} , V} < :
37
37
AbstractRODESolution{T, N, uType}
38
38
u:: uType
39
39
u_analytic:: uType2
40
40
errors:: DType
41
41
t:: tType
42
42
W:: randType
43
+ discretes:: discType
43
44
prob:: P
44
45
alg:: A
45
46
interp:: IType
@@ -63,9 +64,10 @@ function ConstructionBase.setproperties(sol::RODESolution, patch::NamedTuple)
63
64
patch = merge (getproperties (sol), patch)
64
65
return RODESolution{
65
66
T, N, typeof (patch. u), typeof (patch. u_analytic), typeof (patch. errors),
66
- typeof (patch. t), typeof (patch. W), typeof (patch. prob), typeof (patch. alg), typeof (patch. interp),
67
+ typeof (patch. t), typeof (patch. W), typeof (patch. discretes),
68
+ typeof (patch. prob), typeof (patch. alg), typeof (patch. interp),
67
69
typeof (patch. stats), typeof (patch. alg_choice), typeof (patch. saved_subsystem)}(
68
- patch. u, patch. u_analytic, patch. errors, patch. t, patch. W,
70
+ patch. u, patch. u_analytic, patch. errors, patch. t, patch. W, patch . discretes,
69
71
patch. prob, patch. alg, patch. interp, patch. dense, patch. tslocation, patch. stats,
70
72
patch. alg_choice, patch. retcode, patch. seed, patch. saved_subsystem)
71
73
end
@@ -120,16 +122,28 @@ function build_solution(prob::Union{AbstractRODEProblem, AbstractSDDEProblem},
120
122
Base. depwarn (msg, :build_solution )
121
123
end
122
124
125
+ ps = parameter_values (prob)
126
+ if has_sys (prob. f)
127
+ sswf = if saved_subsystem === nothing
128
+ prob. f. sys
129
+ else
130
+ SavedSubsystemWithFallback (saved_subsystem, prob. f. sys)
131
+ end
132
+ discretes = create_parameter_timeseries_collection (sswf, ps, prob. tspan)
133
+ else
134
+ discretes = nothing
135
+ end
123
136
if has_analytic (f)
124
137
u_analytic = Vector {typeof(prob.u0)} ()
125
138
errors = Dict {Symbol, real(eltype(prob.u0))} ()
126
139
sol = RODESolution{T, N, typeof (u), typeof (u_analytic), typeof (errors), typeof (t),
127
- typeof (W),
140
+ typeof (W), typeof (discretes),
128
141
typeof (prob), typeof (alg), typeof (interp), typeof (stats),
129
142
typeof (alg_choice), typeof (saved_subsystem)}(u,
130
143
u_analytic,
131
144
errors,
132
145
t, W,
146
+ discretes,
133
147
prob,
134
148
alg,
135
149
interp,
@@ -149,15 +163,37 @@ function build_solution(prob::Union{AbstractRODEProblem, AbstractSDDEProblem},
149
163
return sol
150
164
else
151
165
return RODESolution{T, N, typeof (u), Nothing, Nothing, typeof (t),
152
- typeof (W), typeof (prob), typeof (alg), typeof (interp),
166
+ typeof (W), typeof (discretes), typeof ( prob), typeof (alg), typeof (interp),
153
167
typeof (stats), typeof (alg_choice), typeof (saved_subsystem)}(
154
- u, nothing , nothing , t, W,
168
+ u, nothing , nothing , t, W, discretes,
155
169
prob, alg, interp,
156
170
dense, 0 , stats,
157
171
alg_choice, retcode, seed, saved_subsystem)
158
172
end
159
173
end
160
174
175
+ function save_discretes! (sol:: AbstractRODESolution , t, vals, timeseries_idx)
176
+ RecursiveArrayTools. has_discretes (sol) || return
177
+ disc = RecursiveArrayTools. get_discretes (sol)
178
+ _save_discretes_internal! (disc[timeseries_idx], t, vals)
179
+ end
180
+
181
+ function get_interpolated_discretes (sol:: AbstractRODESolution , t, deriv, continuity)
182
+ is_parameter_timeseries (sol) == Timeseries () || return nothing
183
+
184
+ discs:: ParameterTimeseriesCollection = RecursiveArrayTools. get_discretes (sol)
185
+ interp_discs = map (discs) do partition
186
+ hold_discrete (partition. u, partition. t, t)
187
+ end
188
+ return ParameterTimeseriesCollection (interp_discs, parameter_values (discs))
189
+ end
190
+
191
+ function SymbolicIndexingInterface. is_parameter_timeseries (:: Type{S} ) where {
192
+ T1, T2, T3, T4, T5, T6, T7,
193
+ S <: RODESolution{T1, T2, T3, T4, T5, T6, T7, <:ParameterTimeseriesCollection} }
194
+ Timeseries ()
195
+ end
196
+
161
197
function calculate_solution_errors! (sol:: AbstractRODESolution ; fill_uanalytic = true ,
162
198
timeseries_errors = true , dense_errors = true )
163
199
if sol. prob. f isa Tuple
0 commit comments