From e1a9ad772c261c2555107c046a962dfc33874a3c Mon Sep 17 00:00:00 2001 From: Mateusz Baran Date: Mon, 10 Feb 2025 15:12:13 +0100 Subject: [PATCH] Update for ManifoldsBase 1.0 (#34) * Update for ManifoldsBase 1.0 * bump version --- .github/workflows/ci.yml | 2 +- .github/workflows/format.yml | 30 +++++++-------- NEWS.md | 10 +++++ Project.toml | 4 +- docs/Project.toml | 2 +- src/ManifoldDiffEq.jl | 1 + src/frozen_solvers.jl | 73 ++++++++++++++++++++---------------- src/lie_solvers.jl | 2 +- 8 files changed, 69 insertions(+), 55 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6351584..bd2cf49 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - julia-version: ["1.10", "~1.11.0-0"] + julia-version: ["1", "lts", "pre"] os: [ubuntu-latest, macOS-latest, windows-latest] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 3a7e8f9..3f32a71 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -13,22 +13,18 @@ jobs: - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v2 with: - version: 1.4 + version: 1 + - uses: julia-actions/cache@v2 - name: Install JuliaFormatter and format run: | - julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))' - julia -e 'using JuliaFormatter; format(".")' - - name: Check format - run: | - julia -e ' - out = Cmd(`git diff --name-only`) |> read |> String - if out == "" - exit(0) - else - @error "The following files have not been formatted:" - write(stdout, out) - out_diff = Cmd(`git diff`) |> read |> String - @error "Diff:" - write(stdout, out_diff) - exit(1) - end' + using Pkg + Pkg.add(PackageSpec(name="JuliaFormatter", version="1")) + using JuliaFormatter + format("."; verbose=true) + shell: julia --color=yes {0} + - name: Suggest formatting changes + uses: reviewdog/action-suggester@v1 + if: github.event_name == 'pull_request' + with: + tool_name: JuliaFormatter + fail_on_error: true diff --git a/NEWS.md b/NEWS.md index 7a92565..bbb454f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.1] – 2025-02-10 + +### Changed + +* Increased `ManifoldsBase.jl` compatibility to 1.0. + +### Fixed + +* Added a few missing retraction methods in some solvers. + ## [0.2.0] – 2024-09-03 ### Changed diff --git a/Project.toml b/Project.toml index d2f475a..5f0bb69 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ManifoldDiffEq" uuid = "1143c485-9b25-4e23-a65f-701df382ec90" authors = ["Seth Axen ", "Mateusz Baran ", "Ronny Bergmann ", "Antoine Levitt "] -version = "0.2.0" +version = "0.2.1" [deps] Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" @@ -23,7 +23,7 @@ DiffEqBase = "6" DoubleFloats = ">= 0.9.2" LinearAlgebra = "1.6" Manifolds = "0.10" -ManifoldsBase = "0.15" +ManifoldsBase = "1" Markdown = "1.6" OrdinaryDiffEqCore = "1" RecursiveArrayTools = "2, 3" diff --git a/docs/Project.toml b/docs/Project.toml index d277e7e..c1c539c 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -11,5 +11,5 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Documenter = "1.0" DocumenterCitations = "1.2.1" Manifolds = "0.10" -ManifoldsBase = "0.15" +ManifoldsBase = "1" Plots = "1" diff --git a/src/ManifoldDiffEq.jl b/src/ManifoldDiffEq.jl index ebad339..368750e 100644 --- a/src/ManifoldDiffEq.jl +++ b/src/ManifoldDiffEq.jl @@ -1,6 +1,7 @@ module ManifoldDiffEq using ManifoldsBase +using ManifoldsBase: retract_fused, retract_fused! using Manifolds using LinearAlgebra diff --git a/src/frozen_solvers.jl b/src/frozen_solvers.jl index 8f95670..5214ed6 100644 --- a/src/frozen_solvers.jl +++ b/src/frozen_solvers.jl @@ -53,7 +53,14 @@ function perform_step!(integrator, ::ManifoldEulerCache, repeat_step = false) alg = integrator.alg integrator.k[1] = integrator.f(u, integrator.p, t) - retract!(alg.manifold, u, u, integrator.k[1], integrator.dt, alg.retraction_method) + retract_fused!( + alg.manifold, + u, + u, + integrator.k[1], + integrator.dt, + alg.retraction_method, + ) return integrator.stats.nf += 1 end @@ -144,10 +151,10 @@ function perform_step!(integrator, cache::CG2Cache, repeat_step = false) M = alg.manifold f(cache.X1, u, p, t) dt2 = dt / 2 - retract!(M, cache.X2u, u, cache.X1, dt2, alg.retraction_method) + retract_fused!(M, cache.X2u, u, cache.X1, dt2, alg.retraction_method) f(cache.X2, cache.X2u, p, t + dt2) k2t = f.f.operator_vector_transport(M, cache.X2u, cache.X2, u, p, t + dt2, t) - retract!(M, u, u, k2t, dt, alg.retraction_method) + retract_fused!(M, u, u, k2t, dt, alg.retraction_method) return integrator.stats.nf += 2 end @@ -255,29 +262,29 @@ function perform_step!(integrator, cache::CG2_3Cache, repeat_step = false) b1hat = (13 // 51) * dt b2hat = (-2 // 3) * dt b3hat = (24 // 17) * dt - retract!(M, cache.X2u, u, cache.X1, a21h, alg.retraction_method) + retract_fused!(M, cache.X2u, u, cache.X1, a21h, alg.retraction_method) f(cache.X2, cache.X2u, p, t + c2h) - retract!(M, cache.X3u, u, cache.X1, a31h) + retract_fused!(M, cache.X3u, u, cache.X1, a31h, alg.retraction_method) k2tk3u = f.f.operator_vector_transport(M, cache.X2u, cache.X2, cache.X3u, p, t, t + c2h) - retract!(M, cache.X3u, cache.X3u, k2tk3u, a32h) + retract_fused!(M, cache.X3u, cache.X3u, k2tk3u, a32h, alg.retraction_method) f(cache.X3, cache.X3u, p, t + c3h) if integrator.opts.adaptive copyto!(M, cache.uhat, u) end - retract!(M, u, u, cache.X1, b1, alg.retraction_method) + retract_fused!(M, u, u, cache.X1, b1, alg.retraction_method) X2tu = f.f.operator_vector_transport(M, cache.X2u, cache.X2, u, p, t + c2h, t) - retract!(M, u, u, X2tu, b2, alg.retraction_method) + retract_fused!(M, u, u, X2tu, b2, alg.retraction_method) X3tu = f.f.operator_vector_transport(M, cache.X3u, cache.X3, u, p, t + c3h, t) - retract!(M, u, u, X3tu, b3, alg.retraction_method) + retract_fused!(M, u, u, X3tu, b3, alg.retraction_method) if integrator.opts.adaptive uhat = cache.uhat - retract!(M, uhat, uhat, cache.X1, b1hat, alg.retraction_method) + retract_fused!(M, uhat, uhat, cache.X1, b1hat, alg.retraction_method) X2tu = f.f.operator_vector_transport(M, cache.X2u, cache.X2, uhat, p, t + c2h, t) - retract!(M, uhat, uhat, X2tu, b2hat, alg.retraction_method) + retract_fused!(M, uhat, uhat, X2tu, b2hat, alg.retraction_method) X3tu = f.f.operator_vector_transport(M, cache.X3u, cache.X3, uhat, p, t + c3h, t) - retract!(M, uhat, uhat, X3tu, b3hat, alg.retraction_method) + retract_fused!(M, uhat, uhat, X3tu, b3hat, alg.retraction_method) integrator.EEst = calculate_eest( M, @@ -374,18 +381,18 @@ function perform_step!(integrator, cache::CG3Cache, repeat_step = false) b1 = (13 // 51) * dt b2 = (-2 // 3) * dt b3 = (24 // 17) * dt - retract!(M, cache.X2u, u, cache.X1, a21h, alg.retraction_method) + retract_fused!(M, cache.X2u, u, cache.X1, a21h, alg.retraction_method) f(cache.X2, cache.X2u, p, t + c2h) - retract!(M, cache.X3u, u, cache.X1, a31h) + retract_fused!(M, cache.X3u, u, cache.X1, a31h, alg.retraction_method) k2tk3u = f.f.operator_vector_transport(M, cache.X2u, cache.X2, cache.X3u, p, t, t + c2h) - retract!(M, cache.X3u, cache.X3u, k2tk3u, a32h) + retract_fused!(M, cache.X3u, cache.X3u, k2tk3u, a32h, alg.retraction_method) f(cache.X3, cache.X3u, p, t + c3h) - retract!(M, u, u, cache.X1, b1, alg.retraction_method) + retract_fused!(M, u, u, cache.X1, b1, alg.retraction_method) X2tu = f.f.operator_vector_transport(M, cache.X2u, cache.X2, u, p, t + c2h, t) - retract!(M, u, u, X2tu, b2, alg.retraction_method) + retract_fused!(M, u, u, X2tu, b2, alg.retraction_method) X3tu = f.f.operator_vector_transport(M, cache.X3u, cache.X3, u, p, t + c3h, t) - retract!(M, u, u, X3tu, b3, alg.retraction_method) + retract_fused!(M, u, u, X3tu, b3, alg.retraction_method) return integrator.stats.nf += 3 end @@ -495,15 +502,15 @@ function perform_step!(integrator, cache::CG4aCache, repeat_step = false) b4 = Tdt(-0.1907142565505889) * dt b5 = Tdt(0.3322195591068374) * dt - retract!(M, cache.X2u, u, cache.X1, a21h, alg.retraction_method) + retract_fused!(M, cache.X2u, u, cache.X1, a21h, alg.retraction_method) f(cache.X2, cache.X2u, p, t + c2h) - retract!(M, cache.X3u, u, cache.X1, a31h) + retract_fused!(M, cache.X3u, u, cache.X1, a31h, alg.retraction_method) k2tk3u = f.f.operator_vector_transport(M, cache.X2u, cache.X2, cache.X3u, p, t, t + c2h) - retract!(M, cache.X3u, cache.X3u, k2tk3u, a32h) + retract_fused!(M, cache.X3u, cache.X3u, k2tk3u, a32h, alg.retraction_method) f(cache.X3, cache.X3u, p, t + c3h) - retract!(M, cache.X4u, u, cache.X1, a41h) + retract_fused!(M, cache.X4u, u, cache.X1, a41h, alg.retraction_method) k2tk4u = f.f.operator_vector_transport( M, cache.X2u, @@ -513,7 +520,7 @@ function perform_step!(integrator, cache::CG4aCache, repeat_step = false) t + c2h, t + c4h, ) - retract!(M, cache.X4u, cache.X4u, k2tk4u, a42h) + retract_fused!(M, cache.X4u, cache.X4u, k2tk4u, a42h, alg.retraction_method) k3tk4u = f.f.operator_vector_transport( M, cache.X3u, @@ -523,10 +530,10 @@ function perform_step!(integrator, cache::CG4aCache, repeat_step = false) t + c3h, t + c4h, ) - retract!(M, cache.X4u, cache.X4u, k3tk4u, a43h) + retract_fused!(M, cache.X4u, cache.X4u, k3tk4u, a43h, alg.retraction_method) f(cache.X4, cache.X4u, p, t + c4h) - retract!(M, cache.X5u, u, cache.X1, a51h) + retract_fused!(M, cache.X5u, u, cache.X1, a51h, alg.retraction_method) k2tk5u = f.f.operator_vector_transport( M, cache.X2u, @@ -536,7 +543,7 @@ function perform_step!(integrator, cache::CG4aCache, repeat_step = false) t + c2h, t + c5h, ) - retract!(M, cache.X5u, cache.X5u, k2tk5u, a52h) + retract_fused!(M, cache.X5u, cache.X5u, k2tk5u, a52h, alg.retraction_method) k3tk5u = f.f.operator_vector_transport( M, cache.X3u, @@ -546,7 +553,7 @@ function perform_step!(integrator, cache::CG4aCache, repeat_step = false) t + c3h, t + c5h, ) - retract!(M, cache.X5u, cache.X5u, k3tk5u, a53h) + retract_fused!(M, cache.X5u, cache.X5u, k3tk5u, a53h, alg.retraction_method) k4tk5u = f.f.operator_vector_transport( M, cache.X4u, @@ -556,18 +563,18 @@ function perform_step!(integrator, cache::CG4aCache, repeat_step = false) t + c4h, t + c5h, ) - retract!(M, cache.X5u, cache.X5u, k4tk5u, a54h) + retract_fused!(M, cache.X5u, cache.X5u, k4tk5u, a54h, alg.retraction_method) f(cache.X5, cache.X5u, p, t + c5h) - retract!(M, u, u, cache.X1, b1, alg.retraction_method) + retract_fused!(M, u, u, cache.X1, b1, alg.retraction_method) X2tu = f.f.operator_vector_transport(M, cache.X2u, cache.X2, u, p, t + c2h, t) - retract!(M, u, u, X2tu, b2, alg.retraction_method) + retract_fused!(M, u, u, X2tu, b2, alg.retraction_method) X3tu = f.f.operator_vector_transport(M, cache.X3u, cache.X3, u, p, t + c3h, t) - retract!(M, u, u, X3tu, b3, alg.retraction_method) + retract_fused!(M, u, u, X3tu, b3, alg.retraction_method) X4tu = f.f.operator_vector_transport(M, cache.X4u, cache.X4, u, p, t + c4h, t) - retract!(M, u, u, X4tu, b4, alg.retraction_method) + retract_fused!(M, u, u, X4tu, b4, alg.retraction_method) X5tu = f.f.operator_vector_transport(M, cache.X5u, cache.X5, u, p, t + c5h, t) - retract!(M, u, u, X5tu, b5, alg.retraction_method) + retract_fused!(M, u, u, X5tu, b5, alg.retraction_method) return integrator.stats.nf += 5 end diff --git a/src/lie_solvers.jl b/src/lie_solvers.jl index d0bb45b..ba9cf77 100644 --- a/src/lie_solvers.jl +++ b/src/lie_solvers.jl @@ -60,7 +60,7 @@ function perform_step!(integrator, cache::ManifoldLieEulerCache, repeat_step = f action = alg.action k = apply_diff_group(action, cache.id, X, u) - retract!(alg.manifold, u, u, k, dt, alg.retraction_method) + retract_fused!(alg.manifold, u, u, k, dt, alg.retraction_method) return integrator.stats.nf += 1 end