Skip to content

Commit

Permalink
Fix plotting for codim2
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Jun 23, 2018
1 parent aa84e08 commit ef74b51
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/codim1/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ module PointTypes
end # module
using .PointTypes: PointType

const Codim1Sweep{tkind, ptType <: PointType} = BifurcationSweep{tkind, ptType}
const Codim1Sweep{tkind <: TimeKind, ptType <: PointType} =
BifurcationSweep{tkind, ptType}
const Codim1Solution{S, W <: Codim1Sweep} = BifurcationSolution{S, W}

BifurcationsBase.point_type_type(::Codim1Problem) = PointType
Expand Down
24 changes: 19 additions & 5 deletions src/plotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ using RecipesBase

using .Continuations: as, ContinuationSweep,
ContinuationSolution, sweeps_as_vectors
using .BifurcationsBase: special_points
using .BifurcationsBase: BifurcationSweep, BifurcationSolution, special_points
using .Codim1: Codim1Sweep, Codim1Solution, Codim1Solver,
stabilities, curves_by_stability,
SpecialPoint, SpecialPointInterval, resolved_points

const AbstractSweep = Union{ContinuationSweep, Codim1Sweep}
const AbstractSweep = Union{ContinuationSweep, BifurcationSweep}

domain_prototype(sweep::AbstractSweep) = as(sweep, ContinuationSweep).u[1]
domain_prototype(point::SpecialPoint) = point.u
Expand Down Expand Up @@ -40,6 +40,20 @@ const STYLE = Dict(
),
)

@recipe function plot(
wrapper::AbstractSweep;
vars = (0, 1),
# To be compatible with Codim1Sweep plotter. They are ignored:
resolve_points = nothing,
include_points = nothing,
)
sweep = as(wrapper, ContinuationSweep)
ix, iy = (var_as_index(sweep, v) for v in vars)
xs = [u[ix] for u in sweep.u]
ys = [u[iy] for u in sweep.u]
(xs, ys)
end

@recipe function f(sol::ContinuationSolution; vars = (0, 1))
ix, iy = vars
xs = sweeps_as_vectors(sol, ix)
Expand Down Expand Up @@ -130,16 +144,16 @@ end
(xs, ys)
end

@recipe function f(sol::Codim1Solution)
@recipe function f(sol::BifurcationSolution)
for sweep in sol.sweeps
@series begin
sweep
end
end
end

@recipe function f(solver::Codim1Solver;
resolve_points = true,
@recipe function f(solver::BifurcationSolver;
resolve_points = solver isa Codim1Solver,
include_points = true)
warn_include_points(include_points)

Expand Down

0 comments on commit ef74b51

Please sign in to comment.