|
38 | 38 | return errors, wp.times
|
39 | 39 | end
|
40 | 40 |
|
41 |
| -@recipe function f(wp_set::WorkPrecisionSet; view = :benchmark, color = nothing) |
| 41 | +function get_val_from_wp(wp::WorkPrecision, key::Symbol) |
| 42 | + if key == :abstols |
| 43 | + return wp.abstols |
| 44 | + elseif key == :reltols |
| 45 | + return wp.reltols |
| 46 | + elseif key == :times |
| 47 | + return wp.times |
| 48 | + elseif key == :dts |
| 49 | + return wp.dts |
| 50 | + elseif !isnothing(wp.stats) && key in propertynames(wp.stats[1]) |
| 51 | + return [getproperty(s, key) for s in wp.stats] |
| 52 | + elseif key in propertynames(wp.errors) |
| 53 | + return getproperty(wp.errors, key) |
| 54 | + else |
| 55 | + throw(ArgumentError("Key $key does not specify a valid property of WorkPrecision")) |
| 56 | + end |
| 57 | +end |
| 58 | + |
| 59 | +function key_to_label(key::Symbol) |
| 60 | + if key == :abstols |
| 61 | + return "Absolute tolerance" |
| 62 | + elseif key == :reltols |
| 63 | + return "Relative tolerance" |
| 64 | + elseif key == :times |
| 65 | + return "Time (s)" |
| 66 | + elseif key == :dts |
| 67 | + return "Δt" |
| 68 | + elseif key in ALL_ERRORS |
| 69 | + return "Error ($key)" |
| 70 | + # Some DEStats cases copied from SciMLBase: src/solutions/ode_solutions.jl#L43-L56 |
| 71 | + elseif key == :nf |
| 72 | + return "Number of function evaluations" |
| 73 | + elseif key == :nf2 |
| 74 | + return "Number of function 2 evaluations" |
| 75 | + elseif key == :nw |
| 76 | + return "Number of W matrix evaluations" |
| 77 | + elseif key == :nsolve |
| 78 | + return "Number of linear solves" |
| 79 | + elseif key == :njacs |
| 80 | + return "Number of Jacobians created" |
| 81 | + elseif key == :nnonliniter |
| 82 | + return "Number of nonlinear solver iterations" |
| 83 | + elseif key == :nnonlinconvfail |
| 84 | + return "Number of nonlinear solver convergence failures" |
| 85 | + elseif key == :ncondition |
| 86 | + return "Number of rootfind condition calls" |
| 87 | + elseif key == :naccept |
| 88 | + return "Number of accepted steps" |
| 89 | + elseif key == :nreject |
| 90 | + return "Number of rejected steps" |
| 91 | + elseif key == :maxeig |
| 92 | + return "Maximum eigenvalue recorded" |
| 93 | + else |
| 94 | + return key |
| 95 | + end |
| 96 | +end |
| 97 | + |
| 98 | +@recipe function f(wp_set::WorkPrecisionSet; |
| 99 | + x::Symbol = wp_set.error_estimate, |
| 100 | + y::Symbol = :times, |
| 101 | + view = :benchmark, |
| 102 | + color = nothing) |
42 | 103 | if view == :benchmark
|
43 | 104 | seriestype --> :path
|
44 | 105 | linewidth --> 3
|
45 |
| - yguide --> "Time (s)" |
46 |
| - xguide --> "Error ($(wp_set.error_estimate))" |
47 | 106 | xscale --> :log10
|
48 | 107 | yscale --> :log10
|
49 | 108 | markershape --> :auto
|
50 |
| - errors = Vector{Any}(undef, 0) |
51 |
| - times = Vector{Any}(undef, 0) |
52 |
| - for i in 1:length(wp_set) |
53 |
| - push!(errors, getproperty(wp_set[i].errors, wp_set.error_estimate)) |
54 |
| - push!(times, wp_set[i].times) |
55 |
| - end |
| 109 | + xs = [get_val_from_wp(wp, x) for wp in wp_set.wps] |
| 110 | + ys = [get_val_from_wp(wp, y) for wp in wp_set.wps] |
| 111 | + xguide --> key_to_label(x) |
| 112 | + yguide --> key_to_label(y) |
56 | 113 | label --> reshape(wp_set.names, 1, length(wp_set))
|
57 |
| - return errors, times |
| 114 | + return xs, ys |
58 | 115 | elseif view == :dt_convergence
|
59 | 116 | idts = filter(i -> haskey(wp_set.setups[i], :dts), 1:length(wp_set))
|
60 | 117 | length(idts) > 0 ||
|
|
90 | 147 | seriestype --> :path
|
91 | 148 | linewidth --> 3
|
92 | 149 | color --> color
|
93 |
| - yguide --> "Error" |
| 150 | + yguide --> "Error ($(wp_set.error_estimate))" |
94 | 151 | xguide --> "Δt"
|
95 | 152 | xscale --> :log10
|
96 | 153 | yscale --> :log10
|
|
0 commit comments