3131 isnegative(sol::ODESolution)
3232
3333Returns `true` if `sol.u` contains negative elements.
34-
34+
3535Please note that negative values may occur when plotting the solution, depending on the interpolation used.
3636
3737See also [`isnonnegative`](@ref).
4343"""
4444 isnonnegative(u)
4545
46- Negation of [`isnegative`](@ref).
46+ Negation of [`isnegative`](@ref).
4747"""
4848isnonnegative (args... ) = ! isnegative (args... )
4949
5050# ## Errors #########################################################################
5151"""
5252 rel_max_error_tend(sol, ref_sol)
5353
54- Returns the relative maximum error between `sol` and `ref_sol` at time `sol.t[end]`.
54+ Returns the relative maximum error between `sol` and `ref_sol` at time `sol.t[end]`.
5555"""
56- function rel_max_error_tend (sol, ref_sol)
56+ function rel_max_error_tend (sol:: AbstractVector , ref_sol:: AbstractVector )
5757 return maximum (abs .((sol[end ] .- ref_sol[end ]) ./ ref_sol[end ]))
5858end
5959
60+ rel_max_error_tend (sol, ref_sol) = rel_max_error_tend (sol. u, ref_sol. u)
61+
6062"""
6163 rel_max_error_overall(sol, ref_sol)
6264
63- Returns the maximum of the relative maximum errors between `sol` and `ref_sol` over all time steps.
65+ Returns the maximum of the relative maximum errors between `sol` and `ref_sol` over all time steps.
6466"""
65- function rel_max_error_overall (sol, ref_sol)
67+ function rel_max_error_overall (sol:: AbstractVector , ref_sol:: AbstractVector )
6668 err = zero (eltype (eltype (sol)))
6769 for i in eachindex (sol)
6870 max_err_i = maximum (abs .((abs .(sol[i]) .- abs .(ref_sol[i])) ./ ref_sol[i]))
@@ -73,26 +75,32 @@ function rel_max_error_overall(sol, ref_sol)
7375 return err
7476end
7577
78+ rel_max_error_overall (sol, ref_sol) = rel_max_error_overall (sol. u, ref_sol. u)
79+
7680"""
7781 rel_l1_error_tend(sol, ref_sol)
7882
79- Returns the relative l1 error between `sol` and `ref_sol` at time `sol.t[end]`.
83+ Returns the relative l1 error between `sol` and `ref_sol` at time `sol.t[end]`.
8084"""
81- function rel_l1_error_tend (sol, ref_sol)
85+ function rel_l1_error_tend (sol:: AbstractVector , ref_sol:: AbstractVector )
8286 return sum (abs .((sol[end ] .- ref_sol[end ]) ./ ref_sol[end ])) / length (ref_sol[end ])
8387end
8488
89+ rel_l1_error_tend (sol, ref_sol) = rel_l1_error_tend (sol. u, ref_sol. u)
90+
8591"""
8692 rel_l2_error_tend(sol, ref_sol)
8793
88- Returns the relative l2 error between `sol` and `ref_sol` at time `sol.t[end]`.
94+ Returns the relative l2 error between `sol` and `ref_sol` at time `sol.t[end]`.
8995"""
90- function rel_l2_error_tend (sol, ref_sol)
96+ function rel_l2_error_tend (sol:: AbstractVector , ref_sol:: AbstractVector )
9197 return sqrt (sum (abs2 .((sol[end ] .- ref_sol[end ]) ./ ref_sol[end ])) /
9298 length (ref_sol[end ]))
9399end
94100
95- # ## Functions to compute work-precision diagrams ##########################################
101+ rel_l2_error_tend (sol, ref_sol) = rel_l2_error_tend (sol. u, ref_sol. u)
102+
103+ # ## Functions to compute work-precision diagrams ##########################################
96104function _compute_time (benchmark_f, seconds, numruns)
97105 benchmark_f () # pre-compile
98106
127135
128136"""
129137 work_precision_fixed!(dict, prob, algs, labels, dts, alg_ref;
130- compute_error = rel_max_error_tend,
138+ compute_error = rel_max_error_tend,
131139 seconds = 2,
132140 numruns = 20)
133141 )
@@ -170,14 +178,14 @@ end
170178"""
171179 work_precision_fixed(prob, algs, labels, dts, alg_ref;
172180 compute_error = rel_max_error_tend,
173- seconds = 2,
181+ seconds = 2,
174182 numruns = 20)
175183
176- Returns a dictionary to create work-precision diagrams.
177- The problem `prob` is solved by each algorithm in `algs` for all the step sizes defined in `dts`.
178- For each step size the error and computing time are stored in the dictionary.
184+ Returns a dictionary to create work-precision diagrams.
185+ The problem `prob` is solved by each algorithm in `algs` for all the step sizes defined in `dts`.
186+ For each step size the error and computing time are stored in the dictionary.
179187If the solve is not successful for a given step size, then `(Inf, Inf)` is stored in the dictionary.
180- The strings in the array `labels` are used as keys of the dictionary.
188+ The strings in the array `labels` are used as keys of the dictionary.
181189The reference solution used for error computations is computed with the algorithm `alg_ref`.
182190
183191### Keyword arguments: ###
@@ -198,10 +206,10 @@ end
198206"""
199207 work_precision_adaptive(prob, algs, labels, abstols, reltols, alg_ref;
200208 adaptive_ref = false,
201- abstol_ref = 1e-14,
209+ abstol_ref = 1e-14,
202210 reltol_ref = 1e-13,
203211 compute_error = rel_max_error_tend,
204- seconds = 2,
212+ seconds = 2,
205213 numruns = 20,
206214 kwargs...)
207215
@@ -251,18 +259,18 @@ end
251259"""
252260 work_precision_adaptive(prob, algs, labels, abstols, reltols, alg_ref;
253261 adaptive_ref = false,
254- abstol_ref = 1e-14,
262+ abstol_ref = 1e-14,
255263 reltol_ref = 1e-13,
256264 compute_error = rel_max_error_tend,
257- seconds = 2,
258- numruns = 20,
265+ seconds = 2,
266+ numruns = 20,
259267 kwargs...)
260268
261- Returns a dictionary to create work-precision diagrams.
262- The problem `prob` is solved by each algorithm in `algs` for all tolerances defined in `abstols` and `reltols`.
263- For the respective tolerances the error and computing time are stored in the dictionary.
269+ Returns a dictionary to create work-precision diagrams.
270+ The problem `prob` is solved by each algorithm in `algs` for all tolerances defined in `abstols` and `reltols`.
271+ For the respective tolerances the error and computing time are stored in the dictionary.
264272If the solve is not successful for the given tolerances, then `(Inf, Inf)` is stored in the dictionary.
265- The strings in the array `labels` are used as keys of the dictionary.
273+ The strings in the array `labels` are used as keys of the dictionary.
266274The reference solution used for error computations is computed with the algorithm `alg_ref`.
267275Additional keyword arguments are passed on to `solve`.
268276
0 commit comments