Skip to content

Resolving Issue: Errors in Simple Handwritten PDEs as ODEs #1291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

GodotMisogi
Copy link

@GodotMisogi GodotMisogi commented Jul 7, 2025

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

This merges changes to resolve issue #1284 on the benchmarks of handwritten PDEs as ODEs via finite-difference and pseudo-spectral methods.

The package dependencies have been updated to remove unused ones, and the compat entries have been updated for Julia v1.10. The implementations have been tested on local machines (Macbook Pro M1 Pro on MacOS Sequoia and a beefier CPU running Ubuntu 22.04 LTS) by running SciMLBenchmarks.weave_file on the relevant .jmd files.

At present, changes have been implemented for the following PDEs in one spatial and one time dimension:

  1. Allen-Cahn equation
  2. Burgers' equation
  3. Kortewreg-de Vries equation
  4. Kuramoto-Sivashinsky equation

The following changes have been implemented to the finite-difference method benchmarks:

  1. The implementation errors in the PDEs have been corrected; some have been updated to reflect their particular characteristics.
  2. Sparse matrices are constructed using SparseArrays.
  3. The MatrixOperator interfaces are used from the updated SciMLOperators for SplitODEProblem.
  4. Sketches of the equations have been added (but require upcoming refinements and updates).
  5. Space-time heatmaps of the solutions instead of line plots.

These are functioning for certain solver algorithm choices (IMEXEuler, CNAB2, CLAF2, ETDRK2, SBDF2)

Commits will be progressively added in this pull (such as pseudo-spectral method updates), including revisions based on comments from the reviewers (@ChrisRackauckas).

@ChrisRackauckas
Copy link
Member

For the psuedospectral, see the comment in #929. The ApproxFun dev mentioned we should change to OrthogonalPolynomials.jl for this part so we should take that recommendation.

@GodotMisogi
Copy link
Author

GodotMisogi commented Jul 12, 2025

@ChrisRackauckas Could you please run the workflow so I can check the logs for errors?

  1. Allen-Cahn and Burgers' equations via Chebyshev pseudo-spectral methods have been implemented using ClassicalOrthogonalPolynomials.jl. These have been tested with some mass matrix solvers (Rodas3, Rodas4, Rodas5, GRK4T, GRK4A).
  2. The Kuramoto-Sivashinsky and Korteweg-De Vries equations via Fourier pseudo-spectral methods are now working with ApproxFun.jl. These two cases will likely need to be reformulated to utilize Chebyshev interpolants with Neumann boundary conditions, allowing for the use of mass matrix solvers.

@ChrisRackauckas
Copy link
Member

allowing for the use of mass matrix solvers

Why are mass matrices required here? Most of these should resolve to not have any algebraic constraints if the right spectral discretization is chosen. (Singular) Mass matrices (DAEs) would prohibit most of the solvers from being used. Though if that's a requirement for one of them, then so bit and that changes the solvers that should be chosen there (and would be an interesting contrast)

L = 2.0 # Domain length
xs, prob = allen_cahn(N, L)
# @time sol = solve(prob, AutoVern7(RadauIIA5(autodiff=false)); dt=1e-2, abstol=1e-14, reltol=1e-14, adaptive=true)
@time sol = solve(prob, Tsit5(); abstol=1e-14, reltol=1e-14, adaptive=true)
Copy link
Member

Choose a reason for hiding this comment

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

Explicit methods usually have issues with convergence due to order loss. I'm not sure changing to an explicit method for these for the reference will work out well. Though you'll see the in the work-precision diagram if you have a problem with the convergence, since all of the other methods will hit a wall and only converge to the error of the reference solution.

Copy link
Author

Choose a reason for hiding this comment

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

Good catch, I commented the wrong line in this commit. Thanks!

reltols = 0.1 .^ (1:3)
multipliers = 0.5 .^ (0:3)
setups = [
Dict(:alg => IMEXEuler(), :dts => 1e-4 * multipliers),
Copy link
Member

Choose a reason for hiding this comment

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

I'd keep the same sets as above. A set showing all of the exponential integrators, all of the IMEX methods, all of the normal methods, and then a comparison of the best between the families.

Copy link
Author

Choose a reason for hiding this comment

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

Understood, planning to reincorporate the complete tests for the server builds as I can only prototype a few sets with the current local resources. Should these still be fixed time-steps or use adaptive time-stepping?

Dict(:alg => Rodas4(), :dts => 1e-4 * multipliers),
Dict(:alg => Rodas5(), :dts => 1e-4 * multipliers),
Dict(:alg => GRK4T(), :dts => 1e-4 * multipliers),
Dict(:alg => GRK4A(), :dts => 1e-4 * multipliers),
Copy link
Member

Choose a reason for hiding this comment

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

the main ones to add to the mass matrices comparisons would be FBDF and QNDF. Also a DAEProblem formulation testing DASKR.jl and Sundials.IDA. You can benchmark multiple simultaneous problem implementations using the prob_choice setup, see the DAE benchmarks for how this is done.

Copy link
Author

Choose a reason for hiding this comment

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

Great to know; thanks for the tips!

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.

2 participants