From 997cae3e39aa9d520dc63d616c65752cc4e8b4bf Mon Sep 17 00:00:00 2001 From: romain veltz Date: Fri, 22 Nov 2024 09:41:03 +0100 Subject: [PATCH] correction testNF --- src/continuation/Palc.jl | 10 +++++----- test/testNF.jl | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/continuation/Palc.jl b/src/continuation/Palc.jl index ed54d158..743a0c0d 100644 --- a/src/continuation/Palc.jl +++ b/src/continuation/Palc.jl @@ -388,7 +388,7 @@ function newton_palc(iter::AbstractContinuationIterable, 系 = getdelta(prob) paramlens = getlens(iter) contparams = getcontparams(iter) - T = eltype(iter) + 饾挴 = eltype(iter) 胃 = get胃(iter) z0 = getsolution(state) @@ -415,13 +415,13 @@ function newton_palc(iter::AbstractContinuationIterable, res_f = residual(prob, x, set(par, paramlens, p)); res_n = N(x, p) dX = _copy(res_f) - dp = zero(T) - up = zero(T) + dp = zero(饾挴) + up = zero(饾挴) # dFdp = (F(x, p + 系) - res_f) / 系 dFdp = _copy(residual(prob, x, set(par, paramlens, p + 系))) minus!(dFdp, res_f) # dFdp = dFdp - res_f - rmul!(dFdp, one(T) / 系) + rmul!(dFdp, one(饾挴) / 系) res = normAC(res_f, res_n) residuals = [res] @@ -436,7 +436,7 @@ function newton_palc(iter::AbstractContinuationIterable, while (step < max_iterations) && (res > tol) && line_step && compute # dFdp = (F(x, p + 系) - F(x, p)) / 系) copyto!(dFdp, residual(prob, x, set(par, paramlens, p + 系))) - minus!(dFdp, res_f); rmul!(dFdp, one(T) / 系) + minus!(dFdp, res_f); rmul!(dFdp, one(饾挴) / 系) # compute jacobian J = jacobian(prob, x, set(par, paramlens, p)) diff --git a/test/testNF.jl b/test/testNF.jl index d00d11f8..74d0ce42 100644 --- a/test/testNF.jl +++ b/test/testNF.jl @@ -156,19 +156,19 @@ let @test norm(bp2d.nf.b2, Inf) < 3e-6 @test norm(bp2d.nf.b1 - prob2d.params.伪 * 3.23 * I, Inf) < 1e-9 @test norm(bp2d.nf.a, Inf) < 1e-6 + + # same but when the eigenvalues are not saved in the branch but computed on the fly instead + br_noev = BK.continuation( prob2d, PALC(), ContinuationPar(opts_br; n_inversion = 2, save_eigenvectors = false); normC = norminf) + bp2d = BK.get_normal_form(br_noev, 1; 味s = [[1, 0, 0.], [0, 1, 0.]]); + @test abs(bp2d.nf.b3[1,1,1,1] / 6 - -prob2d.params.伪 * 0.123) < 1e-15 + @test abs(bp2d.nf.b3[1,1,2,2] / 2 - -prob2d.params.伪 * 0.234) < 1e-15 + @test abs(bp2d.nf.b3[1,1,1,2] / 2 - -prob2d.params.伪 * 0.0) < 1e-15 + @test abs(bp2d.nf.b3[2,1,1,2] / 2 - -prob2d.params.伪 * 0.456) < 1e-15 + @test norm(bp2d.nf.b2, Inf) < 3e-15 + @test norm(bp2d.nf.b1 - prob2d.params.伪 * 3.23 * I, Inf) < 1e-9 + @test norm(bp2d.nf.a, Inf) < 1e-15 end end -############################## -# same but when the eigenvalues are not saved in the branch but computed on the fly instead -br_noev = BK.continuation( prob2d, PALC(), ContinuationPar(opts_br; n_inversion = 2, save_eigenvectors = false); normC = norminf) -bp2d = BK.get_normal_form(br_noev, 1; 味s = [[1, 0, 0.], [0, 1, 0.]]); -@test abs(bp2d.nf.b3[1,1,1,1] / 6 - -prob2d.params.伪 * 0.123) < 1e-15 -@test abs(bp2d.nf.b3[1,1,2,2] / 2 - -prob2d.params.伪 * 0.234) < 1e-15 -@test abs(bp2d.nf.b3[1,1,1,2] / 2 - -prob2d.params.伪 * 0.0) < 1e-15 -@test abs(bp2d.nf.b3[2,1,1,2] / 2 - -prob2d.params.伪 * 0.456) < 1e-15 -@test norm(bp2d.nf.b2, Inf) < 3e-15 -@test norm(bp2d.nf.b1 - prob2d.params.伪 * 3.23 * I, Inf) < 1e-9 -@test norm(bp2d.nf.a, Inf) < 1e-15 #################################################################################################### # vector field to test nearby secondary bifurcations FbpSecBif(u, p) = @. -u * (p + u * (2-5u)) * (p -.15 - u * (2+20u))