Skip to content

Conversation

@SKopecz
Copy link
Collaborator

@SKopecz SKopecz commented May 22, 2025

This implements Sandu's projection method, see #124.

@SKopecz SKopecz marked this pull request as draft May 22, 2025 13:50
@JoshuaLampert
Copy link
Member

Would it make sense and be feasible to put JuMP.jl in an extension as it is not very lightweight and not necessary for every user, such that we save the additional loading time if no Sandu projection is used?

@SKopecz
Copy link
Collaborator Author

SKopecz commented May 22, 2025

Is 25a8127 what you had in mind?

@JoshuaLampert
Copy link
Member

Yes, looks good. Thanks!

@codecov
Copy link

codecov bot commented May 22, 2025

Codecov Report

❌ Patch coverage is 98.75000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ext/JuMPExt.jl 97.77% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@coveralls
Copy link

coveralls commented May 22, 2025

Pull Request Test Coverage Report for Build 18007485686

Details

  • 79 of 80 (98.75%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 97.805%

Changes Missing Coverage Covered Lines Changed/Added Lines %
ext/JuMPExt.jl 44 45 97.78%
Totals Coverage Status
Change from base Build 17996129247: 0.04%
Covered Lines: 2050
Relevant Lines: 2096

💛 - Coveralls

There are two independent linear invariants. The function `linear_invariants_stratreac_scaled` returns the invariance matrix.``.
"""
prob_ode_stratreac_scaled = ODEProblem(f_stratreac_scaled, u0, (4.32e4, 3.024e5))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a scaled version of the stratospheric reaction problem and can be solved using SanduProjection and Clarabel with default settings.

Unfortunately, scaling destroys the "conservation structure" of a PDS, i.e. terms that canceled before scaling, do not afterwards. I was not able to find a PDS representation of the scaled statospheric problem, which could be solved as good as the original one by MPRK schemes. That's why there is only an ODE version of this problem.

@@ -0,0 +1,127 @@
module SanduProjectionExt

using StaticArrays: StaticArray, SVector # Why do we need this here,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would have expected that using StaticArrays is not necessary in the extension, as it is used in the parent package.

@SKopecz
Copy link
Collaborator Author

SKopecz commented Aug 22, 2025

The code

using PositiveIntegrators
using OrdinaryDiffEqRosenbrock: ROS2
using JuMP: Model
using Clarabel
using Profile

AT = linear_invariants_stratreac_scaled()
b = AT * prob_ode_stratreac_scaled.u0
cb = SanduProjection(Model(Clarabel.Optimizer), AT, b, 1.0; save = false)

function doit(args...; n = 1)
    for _ in 1:n
        solve(prob_ode_stratreac_scaled, ROS2();
              save_everystep = false, callback = cb)
    end
end

@profview doit(1)
@profview doit(10^6)

generates the following flame graph.

Bildschirmfoto zu 2025-08-22 16-18-22

There seems to be quite some runtime dispatch. But most of it does not seem to be related to SanduProjection. Zooming into the discrete callback section, we see:

Bildschirmfoto zu 2025-08-22 16-20-13

As I see it, the runtime dispatch is a problem of Clarabel.

What do you think?

@SKopecz SKopecz marked this pull request as ready for review September 4, 2025 18:29
Copy link
Member

@JoshuaLampert JoshuaLampert left a comment

Choose a reason for hiding this comment

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

Thanks! I left some comments and suggestions below.

SKopecz and others added 2 commits September 5, 2025 10:38
Co-authored-by: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com>
Co-authored-by: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com>
Copy link
Member

@JoshuaLampert JoshuaLampert left a comment

Choose a reason for hiding this comment

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

Thanks!

@SKopecz SKopecz changed the title WIP: Sandu projection Sandu projection Sep 23, 2025
SKopecz and others added 2 commits September 25, 2025 09:10
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
SKopecz and others added 2 commits September 25, 2025 14:29
Co-authored-by: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com>
Co-authored-by: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com>
Copy link
Member

@JoshuaLampert JoshuaLampert left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

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

Thanks

@ranocha ranocha enabled auto-merge (squash) September 25, 2025 14:45
@ranocha ranocha merged commit 887df1c into main Sep 25, 2025
11 checks passed
@ranocha ranocha deleted the sk/sandu_projection branch September 25, 2025 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants