From aa95a45dfabeaa85372f1575d0b00a653ab84663 Mon Sep 17 00:00:00 2001 From: romain veltz Date: Sat, 14 Dec 2024 23:41:03 +0100 Subject: [PATCH] correction constructor of BifProblem --- src/BifurcationPoints.jl | 2 +- src/Problems.jl | 3 +++ src/periodicorbit/PeriodicOrbitTrapeze.jl | 4 ++-- test/lorenz84.jl | 1 - test/test_linear.jl | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/BifurcationPoints.jl b/src/BifurcationPoints.jl index 27599bd1..5a555e78 100644 --- a/src/BifurcationPoints.jl +++ b/src/BifurcationPoints.jl @@ -66,7 +66,7 @@ $(TYPEDFIELDS) "Continuation step at which the special occurs" step::Int64 = 0 - "`status ∈ {:converged, :guess, :guessL}` indicates whether the bisection algorithm was successful in detecting the special (bifurcation) point. If `status == :guess`, the bissection algorithm failed to meet the requirements given in `::ContinuationPar`. Same for `status == :guessL` but the bissection algorithm stopped on the left of the bifurcation point." + "`status ∈ {:converged, :guess, :guessL}` indicates whether the bisection algorithm was successful in detecting the special (bifurcation) point. If `status == :guess`, the bisection algorithm failed to meet the requirements given in `::ContinuationPar`. Same for `status == :guessL` but the bisection algorithm stopped on the left of the bifurcation point." status::Symbol = :guess "`δ = (δr, δi)` where δr indicates the change in the number of unstable eigenvalues and δi indicates the change in the number of unstable eigenvalues with nonzero imaginary part. `abs(δr)` is thus an estimate of the dimension of the kernel of the Jacobian at the special (bifurcation) point." diff --git a/src/Problems.jl b/src/Problems.jl index ed330acb..d31347f4 100644 --- a/src/Problems.jl +++ b/src/Problems.jl @@ -282,6 +282,9 @@ for (op, at) in ( iip = _isinplace(_F) F = iip ? (x, p) -> _F(similar(x), x, p) : _F end + + Finp = nothing + J = isnothing(J) ? (x, p) -> ForwardDiff.jacobian(z -> F(z, p), x) : J jvp = isnothing(jvp) ? (x, p, dx) -> ForwardDiff.derivative(t -> F(x .+ t .* dx, p), zero(eltype(dx))) : dF diff --git a/src/periodicorbit/PeriodicOrbitTrapeze.jl b/src/periodicorbit/PeriodicOrbitTrapeze.jl index 691e489b..e5d1c9eb 100644 --- a/src/periodicorbit/PeriodicOrbitTrapeze.jl +++ b/src/periodicorbit/PeriodicOrbitTrapeze.jl @@ -376,7 +376,7 @@ function jacobian_potrap_block(pb::PeriodicOrbitTrapProblem, u0::AbstractVector, cylic_potrap_block!(pb, u0, par, Aγ) In = spdiagm( 0 => ones(N)) - Aγ[Block(M, 1)] = -γ * In + Aγ[Block(M, 1)] = (-γ) * In Aγ[Block(M, M)] = In return Aγ end @@ -535,7 +535,7 @@ end @. Jn = In - tmpJ * (h/2) # setblock!(Jc, Jn, ii, ii) - J0.nzval[indx[ii,ii]] .= Jn.nzval + J0.nzval[indx[ii, ii]] .= Jn.nzval end # setblock!(Aγ, -γ * In, M, 1) diff --git a/test/lorenz84.jl b/test/lorenz84.jl index cf9d7787..95d5d3e1 100644 --- a/test/lorenz84.jl +++ b/test/lorenz84.jl @@ -145,7 +145,6 @@ testEV(hp_codim2_test) @reset opts_br.newton_options.verbose = false sn_codim2 = nothing for _jac in (:autodiff, :minaug, :finiteDifferences, :MinAugMatrixBased) - @error "" _jac # be careful here, Bordered predictor not good for Fold continuation sn_codim2 = @time continuation((@set br.alg.tangent = Secant()), 5, (@optic _.T), ContinuationPar(opts_br, p_max = 3.2, p_min = -0.1, detect_bifurcation = 1, dsmin=1e-5, ds = -0.001, dsmax = 0.015, n_inversion = 10, save_sol_every_step = 1, max_steps = 30, max_bisection_steps = 55) ; verbosity = 0, normC = norminf, diff --git a/test/test_linear.jl b/test/test_linear.jl index f4a69ff3..ce6aed56 100644 --- a/test/test_linear.jl +++ b/test/test_linear.jl @@ -60,7 +60,7 @@ typeof(z_sim) == typeof(z_sim2) # test _axpy_op J0 = rand(100, 100) dx = rand(size(J0, 1)) -_o = dx = rand(size(J0, 1)) +_o = rand(ComplexF64, size(J0, 1)) a₀ = rand(ComplexF64) a₁ = -1.432 BK._axpy(J0, 0, a₁)