Skip to content

Commit

Permalink
correct bugs tutorials stemming from Setfield being not imported
Browse files Browse the repository at this point in the history
  • Loading branch information
rveltz committed Jul 13, 2024
1 parent 08381a0 commit 7c0748a
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 19 deletions.
6 changes: 3 additions & 3 deletions docs/src/tutorials/Langmuir.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ opts_cont = ContinuationPar(
p_min = -0.01, p_max = 10.1,
dsmin = 1e-5, dsmax = 0.04, ds= -0.001,
a = 0.75, max_steps = 600,
newton_options = setproperties(opt_new; verbose = false),
newton_options = NewtonPar(opt_new; verbose = false),
nev = 10, save_eigenvectors = true, tol_stability = 1e-5, detect_bifurcation = 3,
dsmin_bisection = 1e-8, max_bisection_steps = 15, n_inversion = 6, tol_bisection_eigenvalue = 1e-9, save_sol_every_step = 50)
Expand Down Expand Up @@ -215,7 +215,7 @@ opt_po = NewtonPar(tol = 1e-10, verbose = true, max_iterations = 50)
# parameters for continuation
opts_po_cont = ContinuationPar(dsmin = 1e-5, dsmax = 0.35, ds= -0.001,
p_max = 1.0, max_steps = 3, detect_bifurcation = 0,
newton_options = setproperties(opt_po; max_iterations = 15, tol = 1e-6), plot_every_step = 1)
newton_options = NewtonPar(opt_po; max_iterations = 15, tol = 1e-6), plot_every_step = 1)

# spatio-temporal norm
normL2T(x; r = sqrt(par.Δx / L), M = 1) = norm(x, 2) * r * sqrt(1/M)
Expand All @@ -235,7 +235,7 @@ br_potrap = continuation(
alg = PALC(tangent = Bordered(), bls = BorderingBLS(solver = DefaultLS(), check_precision = false)),
verbosity = 3, plot = true,
record_from_solution = (x, p) -> normL2T(x[1:end-1], M = M),
plotSolution = (x, p; kwargs...) -> begin
plot_solution = (x, p; kwargs...) -> begin
heatmap!(reshape(x[1:end-1], N, M)'; ylabel="T=$(round(x[end]))", color=:viridis, kwargs...)
plot!(br, subplot=1, label="")
end,
Expand Down
2 changes: 1 addition & 1 deletion docs/src/tutorials/autocatalytic.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ end
optn = NewtonPar(tol = 1e-8, eigsolver = EigenWave())
opt_cont_br = ContinuationPar(p_min = 0.05, p_max = 1., newton_options = optn, ds= -0.001, plot_every_step = 2, detect_bifurcation = 3, nev = 10, n_inversion = 6)
br = continuation(probtw, PALC(), opt_cont_br)
br = continuation(probtw, PALC(), opt_cont_br)
plot(br)
```

Expand Down
2 changes: 1 addition & 1 deletion docs/src/tutorials/cgl1dwave.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ r_hopf, Th, orbitguess2, hopfpt, eigvec = guessFromHopfO2(br, 2, opt_newton.eigs
uold = copy(orbitguess2[1][1:2n])
# we create a TW problem
probTW = TWProblem(re_make(prob, params = setproperties(par_cgl; r = r_hopf - 0.01)), par_cgl.Db, uold; jacobian = :FullLU)
probTW = TWProblem(re_make(prob, params = (par_cgl..., r = r_hopf - 0.01)), par_cgl.Db, uold; jacobian = :FullLU)
# refine the guesss
wave = newton(probTW, vcat(uold, 0),
Expand Down
6 changes: 3 additions & 3 deletions docs/src/tutorials/detonationEngine.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ We are now ready to compute the bifurcation of the trivial (constant in space) s

```@example DETENGINE
# bifurcation problem
prob = BifurcationProblem(Fdet, U0, setproperties(par_det; q = 0.5), (@lens _.up);
prob = BifurcationProblem(Fdet, U0, (par_det..., q = 0.5), (@lens _.up);
J = JdetAD,
plot_solution = (x, p; k...) -> plotsol!(x; k...),
record_from_solution = (x, p) -> (u∞ = norminf(x[1:N]), n2 = norm(x)))
Expand All @@ -121,7 +121,7 @@ eig = EigArpack(0.2, :LM, tol = 1e-13, v0 = rand(2N))
# newton options
optnew = NewtonPar(verbose = true, eigsolver = eig)
solhomo = newton(prob, optnew; normN = norminf)
optcont = ContinuationPar(newton_options = setproperties(optnew, verbose = false),
optcont = ContinuationPar(newton_options = NewtonPar(optnew, verbose = false),
detect_bifurcation = 3, nev = 50, n_inversion = 8, max_bisection_steps = 25,
dsmax = 0.01, ds = 0.01, p_max = 1.4, max_steps = 1000, plot_every_step = 50)
Expand Down Expand Up @@ -159,7 +159,7 @@ function computeBranch(br, nb; δp = 0.005, max_steps = 190)
_p, sol = getGuess(br, nb)
# travelling wave problem
probTW = TWProblem(
re_make(br.prob, params = setproperties(getparams(br); up = _p)),
re_make(br.prob, params = (getparams(br)..., up = _p)),
getparams(br).Db,
copy(sol),
jacobian = :AutoDiff)
Expand Down
21 changes: 14 additions & 7 deletions docs/src/tutorials/ode/steinmetz.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ ns_po_sh = continuation(deepcopy(br_sh), 1, (@lens _.k7), opts_posh_ns;
```

```@example STEINMETZ
plot(ns_po_sh, fold_po_sh, branchlabel = ["NS","Fold"])
scene = plot(ns_po_sh)
plot!(scene, fold_po_sh)
scene
```

## Computation with collocation

```@example STEINMETZ
probcoll, cicoll = generate_ci_problem( PeriodicOrbitOCollProblem(50, 4), prob, sol, 16.)
probcoll, cicoll = generate_ci_problem( PeriodicOrbitOCollProblem(50, 4), prob, sol_ode, 16.)
opts_po_cont = ContinuationPar(p_min = 0., p_max = 2.0,
ds = 0.002, dsmax = 0.05,
Expand All @@ -154,8 +156,9 @@ scene = plot(br_coll)
### Curve of Fold points of periodic orbits

```@example STEINMETZ
opts_pocl_fold = ContinuationPar(br_coll.contparams, detect_bifurcation = 1, plot_every_step = 10, dsmax = 4e-2)
fold_po_cl = @time continuation(br_coll, 2, (@lens _.k7), opts_pocl_fold;
opts_pocl_fold = ContinuationPar(br_coll.contparams, detect_bifurcation = 1, plot_every_step = 10, dsmax = 4e-2, max_steps = 100)
@set! opts_pocl_fold.newton_options.verbose = true
fold_po_cl = @time continuation(deepcopy(br_coll), 2, (@lens _.k7), opts_pocl_fold;
# verbosity = 3, plot = true,
detect_codim2_bifurcation = 1,
update_minaug_every_step = 1,
Expand All @@ -165,14 +168,16 @@ fold_po_cl = @time continuation(br_coll, 2, (@lens _.k7), opts_pocl_fold;
normC = norminf,
callback_newton = BK.cbMaxNorm(1e1),
)
plot(fold_po_cl)
```

### Curve of NS points of periodic orbits

```@example STEINMETZ
opts_pocl_ns = ContinuationPar(br_coll.contparams, detect_bifurcation = 1, plot_every_step = 10, dsmax = 4e-2)
ns_po_cl = continuation(br_coll, 1, (@lens _.k7), opts_pocl_ns;
# verbosity = 3, plot = true,
ns_po_cl = continuation(deepcopy(br_coll), 1, (@lens _.k7), opts_pocl_ns;
verbosity = 1, plot = false,
detect_codim2_bifurcation = 2,
update_minaug_every_step = 1,
start_with_eigen = false,
Expand All @@ -183,5 +188,7 @@ ns_po_cl = continuation(br_coll, 1, (@lens _.k7), opts_pocl_ns;
```

```@example STEINMETZ
plot(ns_po_cl, fold_po_cl, branchlabel = ["NS","Fold"])
scene = plot(ns_po_cl)
plot!(scene, fold_po_cl)
scene
```
4 changes: 4 additions & 0 deletions docs/src/tutorials/ode/tutorialPP2.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ br_po = continuation(
min = minimum(xtt[1,:]),
period = x[end])
end,
plot_solution = (x,p;k...) -> begin
xtt = get_periodic_orbit(p.prob, x, p.p)
plot!(xtt.t, xtt[1,:]; k..., marker=:d, markersize=1, label = "")
end,
finalise_solution = (z, tau, step, contResult; prob = nothing, kwargs...) -> begin
# limit the period
getperiod(prob, z.u, nothing) < 50
Expand Down
4 changes: 2 additions & 2 deletions docs/src/tutorials/ode/tutorialsCodim2PO.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ opts_pocoll_fold = ContinuationPar(brpo_fold.contparams, detect_bifurcation = 3,
@set! opts_pocoll_fold.newton_options.tol = 1e-12
fold_po_coll2 = continuation(brpo_fold, 1, (@lens _.ϵ), opts_pocoll_fold;
verbosity = 2, plot = true,
# verbosity = 2, plot = true,
detect_codim2_bifurcation = 2,
jacobian_ma = :minaug,
start_with_eigen = false,
Expand Down Expand Up @@ -207,7 +207,7 @@ brpo_pd = continuation(prob2, ci, PALC(), ContinuationPar(opts_po_cont, dsmax =
opts_pocoll_pd = ContinuationPar(brpo_pd.contparams, max_steps = 40, p_min = 1.e-2, dsmax = 1e-2, ds = -1e-3)
@reset opts_pocoll_pd.newton_options.tol = 1e-12
pd_po_coll2 = continuation(brpo_pd, 2, (@optic _.b0), opts_pocoll_pd;
pd_po_coll2 = continuation(brpo_pd, 2, (@lens _.b0), opts_pocoll_pd;
detect_codim2_bifurcation = 1,
start_with_eigen = false,
jacobian_ma = :minaug,
Expand Down
4 changes: 2 additions & 2 deletions docs/src/tutorials/ode/tutorialsODE.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ opts_br = ContinuationPar(p_min = -2.0, p_max = -1.)
# continuation of equilibria
br = continuation(prob, PALC(tangent=Bordered()), opts_br; normC = norminf)
scene = plot(br, plotfold=false, markersize=3, legend=:topleft)
scene = plot(br, plotfold=false, markersize=4, legend=:topleft)
```

With detailed information:
Expand Down Expand Up @@ -118,7 +118,7 @@ Let us plot the periodic orbit close to the end of the branch

```@example TUTODE
sol = get_periodic_orbit(br_pocoll, 100)
plot(sol, title = "Periodic orbit")
plot(sol, title = "Periodic orbit", marker = :d, markersize=1)
```

## Periodic orbits with Parallel Standard Shooting
Expand Down
3 changes: 3 additions & 0 deletions docs/src/tutorials/tutorials.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ We also provide some alternative example(s):
Pages = ["ode/NME-MTK.md"]
Depth = 1
```
## Examples based on Catalyst

`Catalyst` provides a tailored interface to `BifurcationKit` and the user is encouraged to have a look at its specific [documentation](https://docs.sciml.ai/Catalyst/stable/steady_state_functionality/bifurcation_diagrams/)

## PDEs: bifurcations of equilibria
```@contents
Expand Down

0 comments on commit 7c0748a

Please sign in to comment.