diff --git a/src/Bifurcations.jl b/src/Bifurcations.jl index c41ba165..1e69c523 100644 --- a/src/Bifurcations.jl +++ b/src/Bifurcations.jl @@ -238,7 +238,7 @@ function locate_bifurcation!(iter::ContIterable, _state::ContState, verbose::Boo state.step > 0 && (interval = @set interval[indinterval] = getp(state)) # we call the finalizer - # iter.finalise_solution(state.z_old, state.tau, state.step, nothing; bisection = true) + # iter.finalise_solution(state.z_old, state.tau, state.step, nothing; ) if verbose ct0 = rightmost(state.eigvals) diff --git a/src/Continuation.jl b/src/Continuation.jl index 65b87438..cfff33c2 100644 --- a/src/Continuation.jl +++ b/src/Continuation.jl @@ -194,6 +194,7 @@ function Base.copyto!(dest::ContState, src::ContState) end # getters +@inline converged(::Nothing) = false @inline converged(state::AbstractContinuationState) = state.converged getsolution(state::AbstractContinuationState) = state.z getx(state::AbstractContinuationState) = state.z.u @@ -202,6 +203,7 @@ getx(state::AbstractContinuationState) = state.z.u @inline is_stable(state::AbstractContinuationState) = state.n_unstable[1] == 0 @inline stepsizecontrol(state::AbstractContinuationState) = state.stepsizecontrol @inline in_bisection(state::AbstractContinuationState) = state.in_bisection +@inline in_bisection(::Nothing) = false #################################################################################################### # condition for halting the continuation procedure (i.e. when returning false) @inline done(it::ContIterable, state::ContState) = diff --git a/src/DeflatedContinuation.jl b/src/DeflatedContinuation.jl index cdd25a99..9110c466 100644 --- a/src/DeflatedContinuation.jl +++ b/src/DeflatedContinuation.jl @@ -410,13 +410,13 @@ end # _ps = getParamValues(brs) # display(_ps) # if δp > 0 -# @assert 1==1 "searchsorted?" +# @assert true "searchsorted?" # idp = findfirst(x -> x.p > startingpoint.p, _ps) # @show idp # pspan = (startingpoint.p, ~isnothing(idp) ? _ps[idp].p : pMax) # printstyled(color=:blue, "──▶ to the right\n") # else -# @assert 1==1 "searchsorted?" +# @assert true "searchsorted?" # idp = findfirst(x -> x.p < startingpoint.p, _ps) # pspan = (~isnothing(idp) ? _ps[idp].p : pMin, startingpoint.p) # printstyled(color=:green, "──▶ to the left\n") diff --git a/src/events/EventDetection.jl b/src/events/EventDetection.jl index 1fbe80b4..878a9420 100644 --- a/src/events/EventDetection.jl +++ b/src/events/EventDetection.jl @@ -146,7 +146,7 @@ function locate_event!(event::AbstractEvent, iter, _state, verbose::Bool = true) state.step > 0 && (@set! interval[indinterval] = getp(state)) # we call the finalizer - state.stopcontinuation = ~iter.finalise_solution(state.z, state.τ, state.step, nothing; bisection = true, state = state) + state.stopcontinuation = ~iter.finalise_solution(state.z, state.τ, state.step, nothing; state = state) if verbose printstyled(color=:blue, bold = true, "────> ", state.step, diff --git a/src/periodicorbit/PeriodicOrbitUtils.jl b/src/periodicorbit/PeriodicOrbitUtils.jl index b1ae274f..8726ed53 100644 --- a/src/periodicorbit/PeriodicOrbitUtils.jl +++ b/src/periodicorbit/PeriodicOrbitUtils.jl @@ -17,7 +17,7 @@ The arguments are - `M` number of time slices in the periodic orbit guess - `amplitude`: amplitude of the periodic orbit guess """ -function guess_from_hopf(br, ind_hopf, eigsolver::AbstractEigenSolver, M, amplitude; phase = 0) +function guess_from_hopf(br, ind_hopf, eigsolver::AbstractEigenSolver, M::Int, amplitude; phase = 0) hopfpoint = HopfPoint(br, ind_hopf) specialpoint = br.specialpoint[ind_hopf] @@ -29,7 +29,7 @@ function guess_from_hopf(br, ind_hopf, eigsolver::AbstractEigenSolver, M, amplit # vec_hopf is the eigenvector for the eigenvalues iω vec_hopf = geteigenvector(eigsolver, br.eig[specialpoint.idx][2], specialpoint.ind_ev-1) - vec_hopf ./= norm(vec_hopf) + vec_hopf ./= norm(vec_hopf) orbitguess = [real.(hopfpoint.u .+ amplitude .* vec_hopf .* exp(-2pi * complex(0, 1) .* (ii/(M-1) - phase))) for ii in 0:M-1] @@ -53,12 +53,14 @@ function modify_po_finalise(prob, kwargs, updateSectionEveryStep) return Finaliser(prob, get(kwargs, :finalise_solution, nothing), updateSectionEveryStep) end -function (finalizer::Finaliser{ <: AbstractPeriodicOrbitProblem})(z, tau, step, contResult; bisection = false, kF...) +function (finalizer::Finaliser{ <: AbstractPeriodicOrbitProblem})(z, tau, step, contResult; kF...) updateSectionEveryStep = finalizer.updateSectionEveryStep # we first check that the continuation step was successful # if not, we do not update the problem with bad information - success = converged(get(kF, :state, nothing)) - if success && mod_counter(step, updateSectionEveryStep) == 1 && ~bisection + state = get(kF, :state, nothing) + success = converged(state) + bisection = in_bisection(state) + if success && mod_counter(step, updateSectionEveryStep) == 1 && bisection == false @debug "[Periodic orbit] update section" # Trapezoid and Shooting need the parameters for section update: updatesection!(finalizer.prob, z.u, setparam(contResult, z.p)) @@ -72,15 +74,16 @@ end # version specific to collocation. Handle mesh adaptation function (finalizer::Finaliser{ <: Union{ <: PeriodicOrbitOCollProblem, - <: WrapPOColl}})(z, tau, step, contResult; bisection = false, kF...) + <: WrapPOColl}})(z, tau, step, contResult; kF...) updateSectionEveryStep = finalizer.updateSectionEveryStep coll = finalizer.prob # we first check that the continuation step was successful # if not, we do not update the problem with bad information state = get(kF, :state, nothing) - success = isnothing(state) ? false : converged(state) + success = converged(state) + bisection = in_bisection(state) # mesh adaptation - if success && coll.meshadapt && ~bisection + if success && coll.meshadapt && bisection == false @debug "[Collocation] update mesh" oldsol = _copy(z) # avoid possible overwrite in compute_error! oldmesh = get_times(coll) .* getperiod(coll, oldsol.u, nothing) @@ -92,7 +95,7 @@ function (finalizer::Finaliser{ <: Union{ <: PeriodicOrbitOCollProblem, return false end end - if success && mod_counter(step, updateSectionEveryStep) == 1 && ~bisection + if success && mod_counter(step, updateSectionEveryStep) == 1 && bisection == false @debug "[collocation] update section" updatesection!(coll, z.u, setparam(contResult, z.p)) end diff --git a/src/periodicorbit/PoincareRM.jl b/src/periodicorbit/PoincareRM.jl index ed539dcc..5f5587c1 100644 --- a/src/periodicorbit/PoincareRM.jl +++ b/src/periodicorbit/PoincareRM.jl @@ -114,7 +114,7 @@ function _solve(Π::PoincaréMap{ <: WrapPOSh}, xₛ, par) x₀ = Π.po[N+1:end] x₀[end] = sh.ds[end] mapΠ(x, p) = poincaré_functional(Π, x, p, xₛ) - # @assert 1==0 "needs a jacobian" + # @assert false "needs a jacobian" probΠ = BifurcationProblem(mapΠ, x₀, par) diff --git a/src/periodicorbit/PoincareShooting.jl b/src/periodicorbit/PoincareShooting.jl index 4a2d8f2f..67ab67b3 100644 --- a/src/periodicorbit/PoincareShooting.jl +++ b/src/periodicorbit/PoincareShooting.jl @@ -338,7 +338,7 @@ function (psh::PoincareShootingProblem)(x_bar::AbstractVector, par, dx_bar::Abst @views outc[:, ii] .= dxc[:, ii] .- diff_poincare_map(psh, xc[:, im1], par, dxc[:, im1], im1) end else - @assert 1==0 "Analytical Jacobian for parallel Poincare Shooting not implemented yet. Please use the option δ > 0 to use Matrix-Free jacobian or chose `:FiniteDifferencesDense` to compute jacobian based on finite differences." + @assert false "Analytical Jacobian for parallel Poincare Shooting not implemented yet. Please use the option δ > 0 to use Matrix-Free jacobian or chose `:FiniteDifferencesDense` to compute jacobian based on finite differences." end # build the array to be returned diff --git a/src/periodicorbit/StandardShooting.jl b/src/periodicorbit/StandardShooting.jl index 580f0a03..1c234de7 100644 --- a/src/periodicorbit/StandardShooting.jl +++ b/src/periodicorbit/StandardShooting.jl @@ -183,7 +183,7 @@ function (sh::ShootingProblem)(x::BorderedArray, par) copyto!(out.u[ii], evolve(sh.flow, xc[ii], par, sh.ds[ii] * T).u .- xc[ip1]) end else - @assert 1==0 "Not implemented yet. Try to use an AbstractVector instead" + @assert false "Not implemented yet. Try to use an AbstractVector instead" end # add constraint @@ -245,7 +245,7 @@ function (sh::ShootingProblem)(x::BorderedArray, par, dx::BorderedArray; δ = co copyto!(out.u[ii], tmp.du .+ vf(sh.flow, tmp.u, par) .* sh.ds[ii] .* dT .- dx.u[ip1]) end else - @assert 1==0 "Not implemented yet. Try using AbstractVectors instead" + @assert false "Not implemented yet. Try using AbstractVectors instead" end # add constraint diff --git a/src/periodicorbit/codim2/MinAugNS.jl b/src/periodicorbit/codim2/MinAugNS.jl index f32645a9..d2bf35e1 100644 --- a/src/periodicorbit/codim2/MinAugNS.jl +++ b/src/periodicorbit/codim2/MinAugNS.jl @@ -27,7 +27,7 @@ end function apply_jacobian_neimark_sacker(pb, x, par, ω, dx, _transpose = false) if _transpose == false - @assert 1==0 + @assert false return jacobian_adjoint_neimark_sacker_matrix_free(pb, x, par, ω, dx) else # if matrix-free: @@ -197,7 +197,7 @@ function NSMALinearSolver(x, p::𝒯, ω::𝒯, 𝐍𝐒::NeimarkSackerProblemMi return x1 .- dp .* x2, dp, dω, true, it1 + it2 + sum(itv) + sum(itw) else - @assert 1==0 "WIP. Please select another jacobian method like :autodiff or :finiteDifferences. You can also pass the option usehessian = false." + @assert false "WIP. Please select another jacobian method like :autodiff or :finiteDifferences. You can also pass the option usehessian = false." end return dX, dsig, true, sum(it) + sum(itv) + sum(itw) diff --git a/src/periodicorbit/codim2/MinAugPD.jl b/src/periodicorbit/codim2/MinAugPD.jl index f2f4f3a1..ddd306c3 100644 --- a/src/periodicorbit/codim2/MinAugPD.jl +++ b/src/periodicorbit/codim2/MinAugPD.jl @@ -18,7 +18,7 @@ function apply_jacobian_period_doubling(pb, x, par, dx, _transpose = false) # else # return apply(jacobian_period_doubling(pb, x, par), dx) # end - @assert 1==0 "Please report to the website of BifurcationKit" + @assert false "Please report to the website of BifurcationKit" else # if matrix-free: if has_adjoint(pb) diff --git a/src/periodicorbit/codim2/StandardShooting.jl b/src/periodicorbit/codim2/StandardShooting.jl index 1c85a937..bf78c016 100644 --- a/src/periodicorbit/codim2/StandardShooting.jl +++ b/src/periodicorbit/codim2/StandardShooting.jl @@ -67,7 +67,7 @@ function jacobian_pd_nf_matrix_free(pbwrap::WrapPOSh{ <: ShootingProblem }, x, p end end else - @assert 1==0 "WIP! No parallel matrix-free shooting for curve of PD/NS" + @assert false "WIP! No parallel matrix-free shooting for curve of PD/NS" # call jacobian of the flow, jacobian-vector product solOde = jvp(sh.flow, xc, par, dxc, sh.ds .* T) for ii in 1:M @@ -110,7 +110,7 @@ function jacobian_adjoint_pd_nf_matrix_free(pbwrap::WrapPOSh{ <: ShootingProblem end end else - @assert 1==0 + @assert false # call jacobian of the flow, jacobian-vector product solOde = jvp(sh.flow, xc, par, dxc, sh.ds .* T) for ii in 1:M diff --git a/src/periodicorbit/codim2/codim2.jl b/src/periodicorbit/codim2/codim2.jl index ad8bced3..8dda8403 100644 --- a/src/periodicorbit/codim2/codim2.jl +++ b/src/periodicorbit/codim2/codim2.jl @@ -136,8 +136,10 @@ function (finalizer::Finaliser{<: AbstractMABifurcationProblem})(z, tau, step, c updateSectionEveryStep = finalizer.updateSectionEveryStep # we first check that the continuation step was successful # if not, we do not update the problem with bad information - success = converged(get(kF, :state, nothing)) - if success && mod_counter(step, updateSectionEveryStep) == 1 && ~bisection + state = get(kF, :state, nothing) + success = converged(state) + bisection = in_bisection(state) + if success && mod_counter(step, updateSectionEveryStep) == 1 && bisection == false # we get the MA problem wrap_ma = finalizer.prob 𝐏𝐛 = wrap_ma.prob @@ -159,7 +161,7 @@ function (finalizer::Finaliser{<: AbstractMABifurcationProblem})(z, tau, step, c end end -function (finalizer::Finaliser{<: AbstractMABifurcationProblem{ <: AbstractProblemMinimallyAugmented{ <: WrapPOColl}}})(Z, tau, step, contResult; bisection = false, kF...) +function (finalizer::Finaliser{<: AbstractMABifurcationProblem{ <: AbstractProblemMinimallyAugmented{ <: WrapPOColl}}})(Z, tau, step, contResult; kF...) updateSectionEveryStep = finalizer.updateSectionEveryStep 𝐏𝐛 = finalizer.prob.prob coll = 𝐏𝐛.prob_vf.prob @@ -168,9 +170,10 @@ function (finalizer::Finaliser{<: AbstractMABifurcationProblem{ <: AbstractProbl # we first check that the continuation step was successful # if not, we do not update the problem with bad information state = get(kF, :state, nothing) - success = isnothing(state) ? false : converged(state) + success = converged(state) + bisection = in_bisection(state) # mesh adaptation - if success && coll.meshadapt && ~bisection + if success && coll.meshadapt && bisection == false @debug "[Collocation] update mesh" oldsol = _copy(x) # avoid possible overwrite in compute_error! oldmesh = get_times(coll) .* getperiod(coll, oldsol, nothing) @@ -182,7 +185,7 @@ function (finalizer::Finaliser{<: AbstractMABifurcationProblem{ <: AbstractProbl return false end end - if success && mod_counter(step, updateSectionEveryStep) == 1 && ~bisection + if success && mod_counter(step, updateSectionEveryStep) == 1 && bisection == false @debug "[collocation] update section" updatesection!(coll, x, nothing) # collocation does not need the parameter for updatesection! end