Skip to content

Commit

Permalink
update for [email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
rveltz committed Jul 2, 2024
1 parent 3912546 commit b36e3db
Show file tree
Hide file tree
Showing 21 changed files with 168 additions and 139 deletions.
16 changes: 8 additions & 8 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"


[compat]
julia = "1.7"
BifurcationKit = "0.3"
DocStringExtensions = "0.9"
ForwardDiff = "0.10.36"
NonlinearEigenproblems = "1.1.1"
BifurcationKit = "^0.3.5"
DocStringExtensions = "^0.9"
ForwardDiff = "^0.10"
NonlinearEigenproblems = "^1.0.1"
Parameters = "0.12.3"
RecursiveArrayTools = "2.38.10"
SciMLBase = "1.98.1"
Setfield = "^1.1"
RecursiveArrayTools = "^2.3, ^2.4, ^2.8, ^2.9, ^3"
SciMLBase = "^1, ^2"
julia = "1.9"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
12 changes: 3 additions & 9 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
[deps]
BifurcationKit = "0f109fa4-8a5d-4b75-95aa-f515264e7665"
DDEBifurcationKit = "954e4062-bdb8-4e3f-9eee-d47105dd3e65"
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
BifurcationKit = "0.3"
DifferentialEquations = "6.19.0, 7.1.0"
Documenter = "0.27"
Setfield = "0.5.0, 0.7.0, 0.8.0, 1"
julia = "1"
BifurcationKit = "^0.3.4"
Documenter = "^1.0"
julia = "1.10"
13 changes: 10 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
using Pkg
cd(@__DIR__)
pkg" activate ."

using Documenter, DDEBifurcationKit, Setfield, BifurcationKit
pkg"dev DDEBifurcationKit BifurcationKit"
# using DocThemeIndigo
ENV["GKSwstype"] = "100"

using Documenter, DDEBifurcationKit, BifurcationKit

# to display progress
# ENV["JULIA_DEBUG"] = Documenter

makedocs(doctest = false,
makedocs(
modules = [DDEBifurcationKit],
doctest = false,
sitename = "Bifurcation Analysis of DDEs in Julia",
format = Documenter.HTML(collapselevel = 1,assets = ["assets/indigo.css"]),
format = Documenter.HTML(collapselevel = 1, assets = ["assets/indigo.css"]),
# format = DocumenterLaTeX.LaTeX(),
authors = "Romain Veltz",
pages = Any[
Expand Down Expand Up @@ -51,5 +57,6 @@ makedocs(doctest = false,

deploydocs(
repo = "github.com/bifurcationkit/DDEBifurcationKit.jl.git",
push_preview = true,
devbranch = "main"
)
6 changes: 3 additions & 3 deletions docs/src/tutorials/dde/Humphries.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ $$x^{\prime}(t)=-\gamma x(t)-\kappa_1 x\left(t-a_1-c x(t)\right)-\kappa_2 x\left
We first instantiate the model

```@example TUTHumphries
using Revise, DDEBifurcationKit, Parameters, Plots
using Revise, DDEBifurcationKit, Plots
using BifurcationKit
const BK = BifurcationKit
function humpriesVF(x, xd, p)
@unpack κ1,κ2,γ,a1,a2,c = p
(;κ1,κ2,γ,a1,a2,c) = p
[
-γ * x[1] - κ1 * xd[1][1] - κ2 * xd[2][1]
]
Expand Down Expand Up @@ -60,7 +60,7 @@ We tell the solver to consider br.specialpoint[2] and continue it.

```@example TUTHumphries
brhopf = continuation(br, 2, (@lens _.κ2),
setproperties(br.contparams, detect_bifurcation = 2, dsmax = 0.04, max_steps = 230, p_max = 5., p_min = -1.,ds = -0.02);
ContinuationPar(br.contparams, detect_bifurcation = 2, dsmax = 0.04, max_steps = 230, p_max = 5., p_min = -1.,ds = -0.02);
verbosity = 0, plot = false,
# we disable detection of Bautin bifurcation as the
# Hopf normal form is not implemented for SD-DDE
Expand Down
24 changes: 7 additions & 17 deletions docs/src/tutorials/dde/HutchinsonDiff.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ $$\begin{aligned}
& \frac{\partial u(t, x)}{\partial x}=0, x=0, \pi
\end{aligned}$$

where $a>0,d>0$.
where $a>0, d>0$.

## Problem discretization

We start by discretizing the above PDE based on finite differences.

```@example TUTHut
using Revise, DDEBifurcationKit, Parameters, LinearAlgebra, Plots, SparseArrays
using Revise, DDEBifurcationKit, Plots, SparseArrays
using BifurcationKit
const BK = BifurcationKit
function Hutchinson(u, ud, p)
@unpack a,d,Δ = p
d .* (Δ*u) .- a .* ud[1] .* (1 .+ u)
(; a, d, Δ) = p
d .* (Δ * u) .- a .* ud[1] .* (1 .+ u)
end
delaysF(par) = [1.]
Expand All @@ -38,16 +38,8 @@ We can now instantiate the model
# discretisation
Nx = 200; Lx = pi/2;
X = -Lx .+ 2Lx/Nx*(0:Nx-1) |> collect
function DiffOp(N, lx; order = 2)
hx = 2lx/N
Δ = spdiagm(0 => -2ones(N), 1 => ones(N-1), -1 => ones(N-1) )
Δ[1,1]=-1; Δ[end,end]=-1
Δ = Δ / hx^2
return Δ
end
Δ = DiffOp(Nx, Lx)
h = 2Lx/Nx
Δ = spdiagm(0 => -2ones(Nx), 1 => ones(Nx-1), -1 => ones(Nx-1) ) / h^2; Δ[1,1]=Δ[end,end]=-1/h^2
nothing #hide
```

Expand Down Expand Up @@ -82,7 +74,7 @@ We show how to specify the jacobian and speed up the code a lot.
```@example TUTHut
# analytical jacobian
function JacHutchinson(u, p)
@unpack a,d,Δ = p
(;a, d, Δ) = p
# we compute the jacobian at the steady state
J0 = d * Δ .- a .* Diagonal(u)
J1 = -a .* Diagonal(1 .+ u)
Expand All @@ -98,6 +90,4 @@ br
```




## References
10 changes: 5 additions & 5 deletions docs/src/tutorials/dde/neuron.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ $$\left\{\begin{array}{l}
We first instantiate the model

```@example TUTneuron
using Revise, DDEBifurcationKit, Parameters, LinearAlgebra, Plots
using Revise, DDEBifurcationKit, Plots
using BifurcationKit
const BK = BifurcationKit
function neuronVF(x, xd, p)
@unpack κ, β, a12, a21, τs, τ1, τ2 = p
(; κ, β, a12, a21, τs, τ1, τ2) = p
[
-κ * x[1] + β * tanh(xd[3][1]) + a12 * tanh(xd[2][2]),
-κ * x[2] + β * tanh(xd[3][2]) + a21 * tanh(xd[1][1])
Expand Down Expand Up @@ -61,14 +61,14 @@ We follow the Hopf points in the parameter plane $(a_{21},\tau_s)$. We tell the
```@example TUTneuron
# continuation of the first Hopf point
brhopf = continuation(br, 3, (@lens _.a21),
setproperties(br.contparams, detect_bifurcation = 1, dsmax = 0.04, max_steps = 230, p_max = 15., p_min = -1.,ds = -0.02);
ContinuationPar(br.contparams, detect_bifurcation = 1, dsmax = 0.04, max_steps = 230, p_max = 15., p_min = -1.,ds = -0.02);
detect_codim2_bifurcation = 2,
# bothside = true,
start_with_eigen = true)
# continuation of the second Hopf point
brhopf2 = continuation(br, 2, (@lens _.a21),
setproperties(br.contparams, detect_bifurcation = 1, dsmax = 0.1, max_steps = 56, p_max = 15., p_min = -1.,ds = -0.01, n_inversion = 4);
ContinuationPar(br.contparams, detect_bifurcation = 1, dsmax = 0.1, max_steps = 56, p_max = 15., p_min = -1.,ds = -0.01, n_inversion = 4);
detect_codim2_bifurcation = 2,
start_with_eigen = true,
bothside=true)
Expand All @@ -82,7 +82,7 @@ We change the continuation parameter and study the bifurcations as function of $

```@example TUTneuron
prob2 = ConstantDDEBifProblem(neuronVF, delaysF, x0, pars, (@lens _.a21))
br2 = BK.continuation(prob2, PALC(), setproperties(opts, ds = 0.1, p_max = 3., n_inversion=8); verbosity = 0, plot = false, normC = norminf)
br2 = BK.continuation(prob2, PALC(), ContinuationPar(opts, ds = 0.1, p_max = 3., n_inversion=8); verbosity = 0, plot = false, normC = norminf)
```

We then compute the branch of periodic orbits from the Hopf bifurcation points using orthogonal collocation.
Expand Down
12 changes: 6 additions & 6 deletions docs/src/tutorials/dde/neuronV2.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ where $g(z)=[\tanh (z-1)+\tanh (1)] \cosh (1)^2$.
We first instantiate the model

```@example TUTneuron2
using Revise, DDEBifurcationKit, Parameters, Plots
using Revise, DDEBifurcationKit, Plots
using BifurcationKit
const BK = BifurcationKit
g(z) = (tanh(z − 1) + tanh(1))*cosh(1)^2
function neuron2VF(x, xd, p)
@unpack a,b,c,d = p
(; a,b,c,d) = p
[
-x[1] - a * g(b*xd[1][1]) + c * g(d*xd[2][2]),
-x[2] - a * g(b*xd[1][2]) + c * g(d*xd[2][1])
Expand Down Expand Up @@ -66,14 +66,14 @@ We follow the Hopf points in the parameter plane $(a,c)$. We tell the solver to
```@example TUTneuron2
# continuation of the first Hopf point
brhopf = continuation(br, 1, (@lens _.c),
setproperties(br.contparams, detect_bifurcation = 1, dsmax = 0.01, max_steps = 100, p_max = 1.1, p_min = -0.1,ds = 0.01, n_inversion = 2);
ContinuationPar(br.contparams, detect_bifurcation = 1, dsmax = 0.01, max_steps = 100, p_max = 1.1, p_min = -0.1,ds = 0.01, n_inversion = 2);
verbosity = 0,
detect_codim2_bifurcation = 2,
bothside = true,
start_with_eigen = true)
brhopf2 = continuation(br, 2, (@lens _.c),
setproperties(br.contparams, detect_bifurcation = 1, dsmax = 0.01, max_steps = 100, p_max = 1.1, p_min = -0.1,ds = -0.01);
ContinuationPar(br.contparams, detect_bifurcation = 1, dsmax = 0.01, max_steps = 100, p_max = 1.1, p_min = -0.1,ds = -0.01);
verbosity = 0,
detect_codim2_bifurcation = 2,
bothside = true,
Expand All @@ -89,15 +89,15 @@ We follow the Fold points in the parameter plane $(a, c)$. We tell the solver to

```@example TUTneuron2
prob2 = ConstantDDEBifProblem(neuron2VF, delaysF, x0, (@set pars.a = 0.12), (@lens _.c))
br2 = continuation(prob2, PALC(), setproperties(opts, p_max = 1.22);)
br2 = continuation(prob2, PALC(), ContinuationPar(opts, p_max = 1.22);)
# change tolerance for avoiding error computation of the EV
opts_fold = br.contparams
@set! opts_fold.newton_options.eigsolver.σ = 1e-7
brfold = continuation(br2, 3, (@lens _.a),
setproperties(opts_fold; detect_bifurcation = 1, dsmax = 0.01, max_steps = 70, p_max = 0.6, p_min = -0.6,ds = -0.01, n_inversion = 2, tol_stability = 1e-6);
ContinuationPar(opts_fold; detect_bifurcation = 1, dsmax = 0.01, max_steps = 70, p_max = 0.6, p_min = -0.6,ds = -0.01, n_inversion = 2, tol_stability = 1e-6);
verbosity = 1, plot = true,
detect_codim2_bifurcation = 2,
update_minaug_every_step = 1,
Expand Down
9 changes: 3 additions & 6 deletions examples/HutchinsonDiffusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ cd(@__DIR__)
cd("..")
# using Pkg, LinearAlgebra, Test
# pkg"activate ."
using Revise, DDEBifurcationKit, Parameters, Setfield, LinearAlgebra, Plots, SparseArrays
using Revise, DDEBifurcationKit, LinearAlgebra, Plots, SparseArrays
using BifurcationKit
const BK = BifurcationKit
const DDEBK = DDEBifurcationKit

# sup norm
norminf(x) = norm(x, Inf)

using DiffEqOperators

function Hutchinson(u, ud, p)
@unpack a,d,Δ = p
(;a,d,Δ) = p
d .**u) .- a .* ud[1] .* (1 .+ u)
end

Expand Down Expand Up @@ -42,7 +39,7 @@ hopfpt = BK.getNormalForm(br, 1)
################################################################################
# case where we specify the jacobian
function JacHutchinson(u, p)
@unpack a,d,Δ = p
(;a,d,Δ) = p
# we compute the jacobian at the steady state
J0 = d * Δ .- a .* Diagonal(u)
J1 = -a .* Diagonal(1 .+ u)
Expand Down
5 changes: 3 additions & 2 deletions examples/delayed-log.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ cd(@__DIR__)
cd("..")
# using Pkg, LinearAlgebra, Test
# pkg"activate ."
using Revise, DDEBifurcationKit, Parameters, Setfield, LinearAlgebra
using Revise, DDEBifurcationKit, LinearAlgebra
using BifurcationKit
const BK = BifurcationKit
const DDEBK = DDEBifurcationKit

using Plots

function delayedlogVF(x, xd, p)
@unpack λ = p
(;λ) = p
y = xd[1][1]
[
- y) * x[1]
Expand Down Expand Up @@ -54,6 +54,7 @@ args_po = ( record_from_solution = (x, p) -> begin
plot!(xtt.t, xtt[1,:]; label = "V1", k...)
plot!(br; subplot = 1, putspecialptlegend = false)
end,
normC = norminf)

probpo = PeriodicOrbitOCollProblem(40, 4; N = 1)
# probpo = PeriodicOrbitTrapProblem(M = 2000, jacobian = :DenseAD, N = 2)
Expand Down
17 changes: 9 additions & 8 deletions examples/humpries.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
cd(@__DIR__)
cd("..")
# using Pkg, LinearAlgebra, Test
# pkg"activate ."
# cd("..")
using Pkg, LinearAlgebra, Test
pkg"activate ."

# https://ddebiftool.sourceforge.net/demos/neuron/html/demo1_stst.html
using Revise, DDEBifurcationKit, Parameters, Setfield, LinearAlgebra, Plots
using Revise, DDEBifurcationKit, LinearAlgebra, Plots
using BifurcationKit
const BK = BifurcationKit
const DDEBK = DDEBifurcationKit

function humpriesVF(x, xd, p)
@unpack κ1,κ2,γ,a1,a2,c = p
(; κ1, κ2, γ, a1, a2, c) = p
[
-γ * x[1] - κ1 * xd[1][1] - κ2 * xd[2][1]
]
Expand All @@ -24,11 +24,12 @@ function delaysF(x, par)
end


pars = (κ1=0.,κ2=2.3,a1=1.3,a2=6=4.75,c=1.)
pars = (κ1=0., κ2=2.3, a1=1.3, a2=6, γ=4.75, c=1.)
x0 = zeros(1)

prob = DDEBK.SDDDEBifProblem(humpriesVF, delaysF, x0, pars, (@lens _.κ1))


optn = NewtonPar(verbose = true, eigsolver = DDE_DefaultEig())
opts = ContinuationPar(p_max = 13., p_min = 0., newton_options = optn, ds = -0.01, detect_bifurcation = 3, nev = 3, )

Expand All @@ -37,7 +38,7 @@ br = continuation(prob, PALC(), opts; verbosity = 1, plot = true, bothside = tru
plot(br)
################################################################################
brhopf = continuation(br, 2, (@lens _.κ2),
setproperties(br.contparams, detect_bifurcation = 2, dsmax = 0.04, max_steps = 230, p_max = 5., p_min = -1.,ds = -0.02);
ContinuationPar(br.contparams, detect_bifurcation = 2, dsmax = 0.04, max_steps = 230, p_max = 5., p_min = -1.,ds = -0.02);
verbosity = 2, plot = true,
detect_codim2_bifurcation = 0,
bothside = true,
Expand Down Expand Up @@ -103,7 +104,7 @@ function h0(p, t)
t 0 || error("history function is only implemented for t ≤ 0")
0 .+ 0.03sin(t)
end
prob_de = DDEProblem(humpriesVF_DE2,h0,(0.,10200.),setproperties(pars, κ1 = br.specialpoint[2].param + 0.01); dependent_lags=((x,par,t)->par.a1 + par.c * x, (x,par,t)->par.a2 + par.c * x))
prob_de = DDEProblem(humpriesVF_DE2,h0,(0.,10200.),ContinuationPar(pars, κ1 = br.specialpoint[2].param + 0.01); dependent_lags=((x,par,t)->par.a1 + par.c * x, (x,par,t)->par.a2 + par.c * x))
alg = MethodOfSteps(Rosenbrock23())
sol = solve(prob_de,alg)
plot(plot(sol, xlims = (sol.t[end]-30,sol.t[end])), plot(sol))
Expand Down
Loading

0 comments on commit b36e3db

Please sign in to comment.