-
Notifications
You must be signed in to change notification settings - Fork 34
/
BifurcationKit.jl
182 lines (141 loc) · 5.73 KB
/
BifurcationKit.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
module BifurcationKit
using Printf, Dates, LinearMaps, BlockArrays, RecipesBase, StructArrays, Requires
using Setfield: setproperties, @set, @set!, Lens, get, set, @lens
using Parameters: @with_kw, @unpack, @with_kw_noshow
using RecursiveArrayTools: VectorOfArray
using DocStringExtensions
using DataStructures: CircularBuffer
using ForwardDiff
# we put this here to be used in LinearBorderSolver
abstract type AbstractContinuationIterable end
abstract type AbstractContinuationState end
include("BorderedArrays.jl")
include("LinearSolver.jl")
include("EigSolver.jl")
include("LinearBorderSolver.jl")
include("Preconditioner.jl")
include("Newton.jl")
include("ContParameters.jl")
include("Results.jl")
include("events/Event.jl")
include("Continuation.jl")
include("events/EventDetection.jl")
include("events/BifurcationDetection.jl")
include("Bifurcations.jl")
include("Predictor.jl")
include("DeflationOperator.jl")
include("BorderedProblem.jl")
include("Utils.jl")
include("codim2/codim2.jl")
include("codim2/MinAugFold.jl")
include("codim2/MinAugHopf.jl")
include("BifurcationPoints.jl")
include("bifdiagram/BranchSwitching.jl")
include("NormalForms.jl")
include("codim2/BifurcationPoints.jl")
include("codim2/NormalForms.jl")
include("bifdiagram/BifurcationDiagram.jl")
include("DeflatedContinuation.jl")
include("periodicorbit/Sections.jl")
include("periodicorbit/PeriodicOrbits.jl")
include("periodicorbit/PeriodicOrbitTrapeze.jl")
include("periodicorbit/PeriodicOrbitCollocation.jl")
# include("periodicorbit/PeriodicOrbitMIRK.jl")
# include("periodicorbit/PeriodicOrbitFDAdapt.jl")
include("periodicorbit/PeriodicOrbitUtils.jl")
include("periodicorbit/Flow.jl")
include("periodicorbit/FlowDE.jl")
include("periodicorbit/StandardShooting.jl")
include("periodicorbit/PoincareShooting.jl")
include("periodicorbit/ShootingDE.jl")
include("periodicorbit/Floquet.jl")
include("wave/WaveProblem.jl")
include("wave/EigSolver.jl")
include("plotting/Recipes.jl")
include("Diffeqwrap.jl")
using Requires
function __init__()
# if Plots.jl is available, then we allow plotting of solutions
@require Plots="91a5bcdd-55d7-5caf-9e0b-520d859cae80" begin
using .Plots
include("plotting/PlotCont.jl")
end
@require AbstractPlotting="537997a7-5e4e-5d89-9595-2241ea00577e" begin
using .AbstractPlotting: @recipe, inline!, layoutscene, Figure, Axis, lines!
include("plotting/RecipesMakie.jl")
end
@require GLMakie="e9467ef8-e4e7-5192-8a1a-b1aee30e663a" begin
@info "Loading GLMakie code"
using .GLMakie: @recipe, inline!, layoutscene, Figure, Axis, lines!, PointBased, Point2f0, scatter!
include("plotting/RecipesMakie.jl")
end
@require JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" begin
using .JLD2
"""
Save solution / data in JLD2 file
- `filename` is for example "example.jld2"
- `sol` is the solution
- `p` is the parameter
- `i` is the index of the solution to be saved
"""
function saveToFile(iter::AbstractContinuationIterable, sol, p, i::Int64, br::ContResult)
if iter.contParams.saveToFile == false; return nothing; end
filename = iter.filename
try
# create a group in the JLD format
jldopen(filename*".jld2", "a+") do file
mygroup = JLD2.Group(file, "sol-$i")
mygroup["sol"] = sol
mygroup["param"] = p
end
jldopen(filename*"-branch.jld2", "w") do file
file["branch"] = br
end
catch
@error "Could not save branch in the jld2 file"
end
end
end
end
# linear solvers
export DefaultLS, GMRESIterativeSolvers, GMRESKrylovKit,
DefaultEig, EigArpack, EigIterativeSolvers, EigKrylovKit, EigArnoldiMethod, geteigenvector, AbstractEigenSolver
# bordered nonlinear problems
export BorderedProblem, JacobianBorderedProblem, LinearSolverBorderedProblem
# preconditioner based on deflation
export PrecPartialSchurKrylovKit, PrecPartialSchurArnoldiMethod
# bordered linear problems
export MatrixBLS, BorderingBLS, MatrixFreeBLS, LSFromBLS, BorderedArray
# nonlinear deflation
export DeflationOperator, DeflatedProblem, DeflatedLinearSolver, scalardM
# predictors for continuation
export SecantPred, BorderedPred, NaturalPred, MultiplePred, PolynomialPred
# newton methods
export NewtonPar, newton, newtonDeflated, newtonPALC, newtonFold, newtonHopf, newtonBordered
# continuation methods
export ContinuationPar, ContResult, GenericBifPoint, continuation, continuation!, continuationFold, continuationHopf, continuationPOTrap, continuationBordered, eigenvec, eigenvals, getSolx, getSolp
# events
export ContinuousEvent, DiscreteEvent, PairOfEvents, SetOfEvents, SaveAtEvent, FoldDetectEvent, BifDetectEvent
# iterators for continuation
export ContIterable, iterate, ContState, solution, getx, getp
# codim2 Fold continuation
export FoldPoint, FoldProblemMinimallyAugmented, FoldLinearSolveMinAug, foldPoint
# codim2 Hopf continuation
export HopfPoint, HopfProblemMinimallyAugmented, HopfLinearSolveMinAug
# normal form
export computeNormalForm, predictor
# automatic bifurcation diagram
export bifurcationdiagram, bifurcationdiagram!, Branch, BifDiagNode, getBranch, getBranchesFromBP
# Periodic orbit computation
export generateSolution, getPeriod, getAmplitude, getMaximum, getPeriodicOrbit, sectionSS, sectionPS, guessFromHopf
# Periodic orbit computation based on Trapeze method
export PeriodicOrbitTrapProblem, continuationPOTrap, continuationPOTrapBPFromPO
# Periodic orbit computation based on Shooting
export Flow, ShootingProblem, PoincareShootingProblem, continuationPOShooting, AbstractShootingProblem, SectionPS, SectionSS
# Periodic orbit computation based on Collocation
export PeriodicOrbitOCollProblem
# Floquet multipliers computation
export FloquetQaD
# waves
export TWProblem
end