Skip to content

Commit 11bf60e

Browse files
committed
WIP AbstractTimeseriesSolution plot recipe
modified: Project.toml modified: src/MechGlueDiffEqBase.jl new file: test/Manifest.toml new file: test/Project.toml modified: test/runtests.jl
1 parent 1cdd9f7 commit 11bf60e

File tree

5 files changed

+1431
-4
lines changed

5 files changed

+1431
-4
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
name = "MechGlueDiffEqBase"
22
uuid = "2532746b-52b5-4539-9431-8bb183ab067f"
33
authors = ["hustf <[email protected]> and contributors"]
4-
version = "0.1.2"
4+
version = "0.1.3"
55

66
[deps]
77
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
88
MechanicalUnits = "e6be9192-89dc-11e9-36e6-5dbcb28f419e"
9+
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
910
Unitfu = "5ee08b94-2369-4f4a-b8c7-99333ba35fb0"
1011

1112
[compat]

src/MechGlueDiffEqBase.jl

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
module MechGlueDiffEqBase
2-
import MechanicalUnits.Unitfu.AbstractQuantity
2+
import Unitfu: AbstractQuantity, Quantity
33
import DiffEqBase: value, ODE_DEFAULT_NORM, UNITLESS_ABS2
4+
import SciMLBase
5+
import SciMLBase: AbstractTimeseriesSolution, RecipesBase
6+
import SciMLBase: AbstractDiscreteProblem, AbstractRODESolution, SensitivityInterpolation
7+
import RecipesBase.@recipe
48
export value, ODE_DEFAULT_NORM, UNITLESS_ABS2, Unitfu
59

610
function value(x::Type{AbstractQuantity{T,D,U}}) where {T,D,U}
@@ -23,4 +27,27 @@ end
2327
end
2428

2529

30+
@recipe function f(sol::AbstractTimeseriesSolution{T, N, A};
31+
plot_analytic=false,
32+
denseplot = (sol.dense ||
33+
typeof(sol.prob) <: AbstractDiscreteProblem) &&
34+
!(typeof(sol) <: AbstractRODESolution) &&
35+
!(hasfield(typeof(sol),:interp) &&
36+
typeof(sol.interp) <: SensitivityInterpolation),
37+
plotdensity = min(Int(1e5),sol.tslocation==0 ?
38+
(typeof(sol.prob) <: AbstractDiscreteProblem ?
39+
max(1000,100*length(sol)) :
40+
max(1000,10*length(sol))) :
41+
1000*sol.tslocation),
42+
tspan = nothing, axis_safety = 0.1,
43+
vars=nothing) where {T<:Quantity, N, A<:Array{<:Quantity}}
44+
45+
print("----------------------------------MechGlueDiffEqBase")
46+
return Unifu.ustrip(sol.u), Unifu.ustrip(sol.t)
47+
end
48+
# T = Quantity{Float64, ᴸ∙ ᴹ∙ ᵀ⁻², Unitfu.FreeUnits{(N,), ᴸ∙ ᴹ∙ ᵀ⁻², nothing}}
49+
# N = 1
50+
# A = Vector{Quantity{Float64, ᴸ∙ ᴹ∙ ᵀ⁻², Unitfu.FreeUnits{(N,), ᴸ∙ ᴹ∙ ᵀ⁻², nothing}}}
51+
52+
2653
end

0 commit comments

Comments
 (0)