Skip to content

Commit

Permalink
Update for ManifoldsBase 1.0 (#34)
Browse files Browse the repository at this point in the history
* Update for ManifoldsBase 1.0

* bump version
  • Loading branch information
mateuszbaran authored Feb 10, 2025
1 parent 2c13e02 commit e1a9ad7
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 13 additions & 17 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ManifoldDiffEq"
uuid = "1143c485-9b25-4e23-a65f-701df382ec90"
authors = ["Seth Axen <[email protected]>", "Mateusz Baran <[email protected]>", "Ronny Bergmann <[email protected]>", "Antoine Levitt <[email protected]>"]
version = "0.2.0"
version = "0.2.1"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions src/ManifoldDiffEq.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module ManifoldDiffEq

using ManifoldsBase
using ManifoldsBase: retract_fused, retract_fused!
using Manifolds

using LinearAlgebra
Expand Down
73 changes: 40 additions & 33 deletions src/frozen_solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/lie_solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

2 comments on commit e1a9ad7

@mateuszbaran
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/124712

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.1 -m "<description of version>" e1a9ad772c261c2555107c046a962dfc33874a3c
git push origin v0.2.1

Please sign in to comment.