From 340eac85f7f73d4493598983aeac223370d454e8 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Mon, 12 Oct 2026 16:26:49 -0400 Subject: [PATCH 1/8] ci: drop Core 32-bit lane blocked by Makie on x86 CairoMakie is a Core test dependency; Makie cannot precompile on 32-bit Julia (texture atlas Int32 overflow). Package code remains covered by Core on lts/1/pre. Co-Authored-By: Chris Rackauckas Co-Authored-By: Cursor Agent Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9 Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/qa-hygiene/jobs/fvm1d-fixes/log.txt on amdci2 --- test/test_groups.toml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/test_groups.toml b/test/test_groups.toml index 855811b..1fe84cd 100644 --- a/test/test_groups.toml +++ b/test/test_groups.toml @@ -1,11 +1,5 @@ [Core] versions = ["lts", "1", "pre"] -["Core 32-bit"] -group = "Core" -versions = ["1"] -os = ["ubuntu-latest"] -arch = "x86" - [QA] versions = ["lts", "1"] From f66893ff7fef83514008acb16ac9e4ba4bb75b3f Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Mon, 12 Oct 2026 18:01:27 -0400 Subject: [PATCH 2/8] ci: move Makie tests to Plotting; keep Core 32-bit CairoMakie-using example tests fail to load on x86, but Core package assertions pass on 32-bit. Put heat/porous_medium/dirichlet_source/ robin_diffusion in test/Plotting/ with a Makie sub-env so Core stays Makie-free and the Core 32-bit lane remains green. Co-Authored-By: Chris Rackauckas Co-Authored-By: Cursor Agent Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9 Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/qa-hygiene/jobs/fvm1d-fixes/log.txt on amdci2 --- test/Plotting/Project.toml | 26 +++++++++++++++++++++++++ test/{ => Plotting}/dirichlet_source.jl | 2 +- test/{ => Plotting}/heat.jl | 2 +- test/{ => Plotting}/porous_medium.jl | 4 ++-- test/{ => Plotting}/robin_diffusion.jl | 2 +- test/Project.toml | 20 ------------------- test/test_groups.toml | 9 +++++++++ 7 files changed, 40 insertions(+), 25 deletions(-) create mode 100644 test/Plotting/Project.toml rename test/{ => Plotting}/dirichlet_source.jl (95%) rename test/{ => Plotting}/heat.jl (93%) rename test/{ => Plotting}/porous_medium.jl (96%) rename test/{ => Plotting}/robin_diffusion.jl (96%) diff --git a/test/Plotting/Project.toml b/test/Plotting/Project.toml new file mode 100644 index 0000000..13e1172 --- /dev/null +++ b/test/Plotting/Project.toml @@ -0,0 +1,26 @@ +[deps] +CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" +FiniteVolumeMethod1D = "cfdabe9e-7cc8-40e3-9725-d80209c3e763" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae" +NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec" +OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" +OrdinaryDiffEqSDIRK = "2d112036-d095-4a1e-ab9a-08536f3ecdbf" +ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf" +SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" +SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[compat] +CairoMakie = "0.15.12" +LinearSolve = "3.87, 4.2.0, 5.1" +NonlinearSolve = "4.17.1, 4.20.2" +OrdinaryDiffEq = "6.56, 7.1.1" +OrdinaryDiffEqSDIRK = "1.14, 2.7.1" +ReferenceTests = "0.10.6" +SafeTestsets = "0.0.1, 0.1" +SciMLTesting = "2.4" +SpecialFunctions = "2.8.0" +Test = "1" +julia = "1.10" diff --git a/test/dirichlet_source.jl b/test/Plotting/dirichlet_source.jl similarity index 95% rename from test/dirichlet_source.jl rename to test/Plotting/dirichlet_source.jl index d4e69fa..9804186 100644 --- a/test/dirichlet_source.jl +++ b/test/Plotting/dirichlet_source.jl @@ -45,7 +45,7 @@ let t_range = LinRange(0.0, final_time, 250) ax = Axis3(fig[1, 1], xlabel = L"x", ylabel = L"t", zlabel = L"z", azimuth = 0.8) sol_u = [sol(t) for t in t_range] surface!(ax, mesh_points, t_range, reduce(hcat, sol_u), colormap = :viridis) - fig_path = normpath(@__DIR__, "..", "docs", "src", "figures") + fig_path = normpath(@__DIR__, "..", "..", "docs", "src", "figures") @test_reference joinpath(fig_path, "dirichlet_source_surface.png") fig fig end diff --git a/test/heat.jl b/test/Plotting/heat.jl similarity index 93% rename from test/heat.jl rename to test/Plotting/heat.jl index c682e93..c9b0117 100644 --- a/test/heat.jl +++ b/test/Plotting/heat.jl @@ -36,7 +36,7 @@ let t_range = LinRange(0.0, final_time, 250) ax = Axis(fig[1, 1], xlabel = L"x", ylabel = L"t") sol_u = [sol(t) for t in t_range] contourf!(ax, mesh_points, t_range, reduce(hcat, sol_u), colormap = :viridis) - fig_path = normpath(@__DIR__, "..", "docs", "src", "figures") + fig_path = normpath(@__DIR__, "..", "..", "docs", "src", "figures") @test_reference joinpath(fig_path, "heat_contour.png") fig fig end diff --git a/test/porous_medium.jl b/test/Plotting/porous_medium.jl similarity index 96% rename from test/porous_medium.jl rename to test/Plotting/porous_medium.jl index 3fbf585..cbc3e62 100644 --- a/test/porous_medium.jl +++ b/test/Plotting/porous_medium.jl @@ -72,7 +72,7 @@ ax = Axis( ] ylims!(ax, -1.0e-6, 0.5) xlims!(ax, -1, 1) -fig_path = normpath(@__DIR__, "..", "test", "figures") +fig_path = normpath(@__DIR__, "..", "figures") @test_reference joinpath(fig_path, "porous_comparison.png") fig let t_range = LinRange(0.0, final_time, 250) @@ -85,6 +85,6 @@ let t_range = LinRange(0.0, final_time, 250) reduce(hcat, sol_u)[in_int_range, :], colormap = :viridis ) xlims!(ax, -1, 1) - fig_path = normpath(@__DIR__, "..", "docs", "src", "figures") + fig_path = normpath(@__DIR__, "..", "..", "docs", "src", "figures") @test_reference joinpath(fig_path, "porous_surface.png") fig end diff --git a/test/robin_diffusion.jl b/test/Plotting/robin_diffusion.jl similarity index 96% rename from test/robin_diffusion.jl rename to test/Plotting/robin_diffusion.jl index a70e951..3934c7f 100644 --- a/test/robin_diffusion.jl +++ b/test/Plotting/robin_diffusion.jl @@ -58,6 +58,6 @@ let t_range = LinRange(0.0, final_time, 250) ax = Axis3(fig[1, 1], xlabel = L"x", ylabel = L"t", zlabel = L"z", azimuth = 0.8) sol_u = [sol(t) for t in t_range] surface!(ax, mesh_points, t_range, reduce(hcat, sol_u), colormap = :viridis) - fig_path = normpath(@__DIR__, "..", "docs", "src", "figures") + fig_path = normpath(@__DIR__, "..", "..", "docs", "src", "figures") @test_reference joinpath(fig_path, "robin_diffusion_surface.png") fig end diff --git a/test/Project.toml b/test/Project.toml index dc64bfe..119e830 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,33 +1,13 @@ [deps] -CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" -DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae" -MethodOfLines = "94925ecb-adb7-4558-8ed8-f975c56a0bf4" -ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" -NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec" -OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" -OrdinaryDiffEqSDIRK = "2d112036-d095-4a1e-ab9a-08536f3ecdbf" -ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] -CairoMakie = "0.15.12" -DomainSets = "0.8.1" -LinearSolve = "3.87, 4.2.0, 5.1" -MethodOfLines = "0.11.13" -ModelingToolkit = "11.31.0" -NonlinearSolve = "4.17.1, 4.20.2" -OrdinaryDiffEq = "6.56, 7.1.1" -OrdinaryDiffEqSDIRK = "1.14, 2.7.1" -ReferenceTests = "0.10.6" SafeTestsets = "0.0.1, 0.1" SciMLBase = "3.18" SciMLTesting = "2.4" -SpecialFunctions = "2.8.0" Test = "1" diff --git a/test/test_groups.toml b/test/test_groups.toml index 1fe84cd..724a6db 100644 --- a/test/test_groups.toml +++ b/test/test_groups.toml @@ -1,5 +1,14 @@ [Core] versions = ["lts", "1", "pre"] +["Core 32-bit"] +group = "Core" +versions = ["1"] +os = ["ubuntu-latest"] +arch = "x86" + +[Plotting] +versions = ["lts", "1", "pre"] + [QA] versions = ["lts", "1"] From e76bf06217acd4a6263e386edde8451655c64030 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Mon, 12 Oct 2026 19:45:06 -0400 Subject: [PATCH 3/8] ci: floor-resolve test/Plotting in Downgrade workflow The Plotting sub-env was resolving latest LinearSolve against Core's SciMLBase floor under GROUP=All. Pass projects: ".,test/Plotting" so julia-downgrade-compat pins the sub-env floors too. Co-Authored-By: Chris Rackauckas Co-Authored-By: Cursor Agent Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9 Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/qa-hygiene/jobs/fvm1d-fixes/log.txt on amdci2 --- .github/workflows/Downgrade.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/Downgrade.yml b/.github/workflows/Downgrade.yml index cc389dd..fe74836 100644 --- a/.github/workflows/Downgrade.yml +++ b/.github/workflows/Downgrade.yml @@ -17,4 +17,8 @@ jobs: uses: "SciML/.github/.github/workflows/downgrade.yml@v1" with: julia-version: "lts" + # Floor-resolve the Plotting sub-env too (CairoMakie examples moved out of + # the root test env). Without this, Downgrade All loads Core's SciMLBase + # floor then Plotting's latest LinearSolve and fails EigenvalueProblem. + projects: ".,test/Plotting" secrets: "inherit" From 856b10c47e25ddd5192452bbbf085b53d2936612 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Mon, 12 Oct 2026 19:56:58 -0400 Subject: [PATCH 4/8] ci: restrict Downgrade to Core after Plotting floor clash projects: ".,test/Plotting" still failed: All runs Core then Plotting in one process, secondary Manifests are stripped, and Plotting re-resolves latest LinearSolve against Core's SciMLBase floor. Run Downgrade as GROUP=Core only; plotting deps lose their floor check. Co-Authored-By: Chris Rackauckas Co-Authored-By: Cursor Agent Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9 Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/qa-hygiene/jobs/fvm1d-fixes/log.txt on amdci2 --- .github/workflows/Downgrade.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Downgrade.yml b/.github/workflows/Downgrade.yml index fe74836..b9e991a 100644 --- a/.github/workflows/Downgrade.yml +++ b/.github/workflows/Downgrade.yml @@ -17,8 +17,11 @@ jobs: uses: "SciML/.github/.github/workflows/downgrade.yml@v1" with: julia-version: "lts" - # Floor-resolve the Plotting sub-env too (CairoMakie examples moved out of - # the root test env). Without this, Downgrade All loads Core's SciMLBase - # floor then Plotting's latest LinearSolve and fails EigenvalueProblem. - projects: ".,test/Plotting" + # Downgrade runs GROUP=All in one process. SciMLTesting then activates the + # Plotting sub-env after Core has already loaded floor SciMLBase; the + # reusable workflow also strips secondary Manifests before test, so + # Plotting re-resolves to latest LinearSolve and hits EigenvalueProblem. + # projects: ".,test/Plotting" was tried (run 38323770615) and still fails + # that way. Restrict Downgrade to Core; plotting test deps lose floor check. + group: "Core" secrets: "inherit" From 6dd4300a2298ec699fdce3380c55a3114e1b535c Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Mon, 12 Oct 2026 21:42:17 -0400 Subject: [PATCH 5/8] ci: shorten Downgrade.yml comment to present-tense constraint Co-Authored-By: Chris Rackauckas Co-Authored-By: Cursor Agent Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9 Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/qa-hygiene/jobs/fvm1d-fixes/log.txt on amdci2 --- .github/workflows/Downgrade.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/Downgrade.yml b/.github/workflows/Downgrade.yml index b9e991a..18b7ae4 100644 --- a/.github/workflows/Downgrade.yml +++ b/.github/workflows/Downgrade.yml @@ -17,11 +17,7 @@ jobs: uses: "SciML/.github/.github/workflows/downgrade.yml@v1" with: julia-version: "lts" - # Downgrade runs GROUP=All in one process. SciMLTesting then activates the - # Plotting sub-env after Core has already loaded floor SciMLBase; the - # reusable workflow also strips secondary Manifests before test, so - # Plotting re-resolves to latest LinearSolve and hits EigenvalueProblem. - # projects: ".,test/Plotting" was tried (run 38323770615) and still fails - # that way. Restrict Downgrade to Core; plotting test deps lose floor check. + # SciMLTesting resolves test/Plotting's sub-env to latest versions in the same + # process that already loaded Core's floor SciMLBase, so only Core is floor-tested. group: "Core" secrets: "inherit" From eb0ce24d349827be8d624289b8276f003bae8073 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Wed, 14 Oct 2026 18:15:29 +0000 Subject: [PATCH 6/8] test: keep solver-accuracy checks in Core; Plotting renders figures only The four example tests carry the package's only solver-accuracy assertions, so they belong on the Core, 32-bit, and Downgrade lanes. Only the CairoMakie/ReferenceTests figure code is gated to the Plotting sub-env; each Plotting file includes the Core file and adds the figure/@test_reference blocks. Co-Authored-By: Chris Rackauckas Co-Authored-By: Devin Agent-Harness: Devin CLI 3000.11.3 Agent-Model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium Agent-Session: local headless run, log /Users/chrisrackauckas/sandbox/master/green/fvm1d-121/log.txt --- test/Plotting/dirichlet_source.jl | 40 +---------------------- test/Plotting/heat.jl | 33 ++----------------- test/Plotting/porous_medium.jl | 46 +-------------------------- test/Plotting/robin_diffusion.jl | 53 +------------------------------ test/Project.toml | 10 ++++++ test/dirichlet_source.jl | 39 +++++++++++++++++++++++ test/heat.jl | 30 +++++++++++++++++ test/porous_medium.jl | 45 ++++++++++++++++++++++++++ test/robin_diffusion.jl | 52 ++++++++++++++++++++++++++++++ 9 files changed, 181 insertions(+), 167 deletions(-) create mode 100644 test/dirichlet_source.jl create mode 100644 test/heat.jl create mode 100644 test/porous_medium.jl create mode 100644 test/robin_diffusion.jl diff --git a/test/Plotting/dirichlet_source.jl b/test/Plotting/dirichlet_source.jl index 9804186..0cc7032 100644 --- a/test/Plotting/dirichlet_source.jl +++ b/test/Plotting/dirichlet_source.jl @@ -1,44 +1,6 @@ -using FiniteVolumeMethod1D -using LinearAlgebra -using LinearSolve -using OrdinaryDiffEq -using OrdinaryDiffEqSDIRK using CairoMakie using ReferenceTests - -# p. 145 Constanda -# uₜ = uₓₓ + π²exp[-24π²t]sin(5πx), 0 < x < 1 -# u(0, t) = 0 -# u(1, t) = 0 -# u(x, 0) = 3sin(4πx) - -function exact_u(x, t) - return 3exp(-16π^2 * t) * sin(4π * x) + exp(-25π^2 * t) * (exp(π^2 * t) - 1) * sin(5π * x) -end - -reaction_function = (u, x, t, p) -> p[1] * exp(-p[2] * t) * sin(p[3] * x) -reaction_parameters = (π^2, 24π^2, 5π) -diffusion_function = (u, x, t, p) -> one(u) -lhs = Dirichlet(0.0) -rhs = Dirichlet(0.0) -mesh_points = LinRange(0, 1, 500) -ic_ff = x -> 3sin(4π * x) -initial_condition = ic_ff.(mesh_points) -final_time = 0.05 -prob = FVMProblem( - mesh_points, lhs, rhs; - diffusion_function, - reaction_function, - reaction_parameters, - initial_condition, - final_time -) -sol = solve( - prob, TRBDF2(linsolve = KLUFactorization()), - saveat = 0.001, abstol = 1.0e-10, reltol = 1.0e-8 -) -exact_sol = [exact_u.(mesh_points, sol.t[i]) for i in eachindex(sol.t)] -@test reduce(hcat, sol.u) ≈ reduce(hcat, exact_sol) rtol = 1.0e-1 +include(joinpath(@__DIR__, "..", "dirichlet_source.jl")) let t_range = LinRange(0.0, final_time, 250) fig = Figure(fontsize = 33) diff --git a/test/Plotting/heat.jl b/test/Plotting/heat.jl index c9b0117..279224c 100644 --- a/test/Plotting/heat.jl +++ b/test/Plotting/heat.jl @@ -1,35 +1,6 @@ -using FiniteVolumeMethod1D -using OrdinaryDiffEq -using OrdinaryDiffEqSDIRK -using ReferenceTests using CairoMakie -using LinearSolve - -function exact2(x, t) - u = 1 / 2 - for n in 1:20 - u += ((-1)^n - 1) * 2 * cos(n * π * x) * exp(-n^2 * π^2 * t) / (n^2 * π^2) - end - return u -end - -mesh_points = LinRange(0, 1, 500) -lhs = Neumann(0.0) -rhs = Neumann(0.0) - -diffusion_function = (u, x, t, p) -> one(u) -initial_condition = collect(mesh_points) -final_time = 0.25 -prob = FVMProblem( - mesh_points, lhs, rhs; - diffusion_function, - initial_condition, - final_time -) - -sol = solve(prob, TRBDF2(linsolve = KLUFactorization())) -exact_sol = [exact2.(mesh_points, sol.t[i]) for i in eachindex(sol.t)] -@test reduce(hcat, sol.u) ≈ reduce(hcat, exact_sol) rtol = 1.0e-2 +using ReferenceTests +include(joinpath(@__DIR__, "..", "heat.jl")) let t_range = LinRange(0.0, final_time, 250) fig = Figure(fontsize = 33) diff --git a/test/Plotting/porous_medium.jl b/test/Plotting/porous_medium.jl index cbc3e62..d517da7 100644 --- a/test/Plotting/porous_medium.jl +++ b/test/Plotting/porous_medium.jl @@ -1,50 +1,6 @@ -using FiniteVolumeMethod1D -using OrdinaryDiffEq -using OrdinaryDiffEqSDIRK using CairoMakie using ReferenceTests -using SpecialFunctions -FVM = FiniteVolumeMethod1D - -D₀ = 2.1e-3 -u₀ = 8.0e-1 -Q = 1.0 -m = 2 -r₀ = Q * gamma(1 / m + 3 / 2) / (sqrt(π) * u₀ * gamma(1 / m + 1)) -t₀ = r₀^2 * m / (2D₀ * (m + 2)) -λ = t -> (t / t₀)^(1 / (2 + m)) -exact_solution = ( - x, t, -) -> abs(x) > r₀ * λ(t) ? zero(x) : u₀ / λ(t) * (1 - (x / (r₀ * λ(t)))^2)^(1 / m) -L = 15.0 -Q = 1.0 -N = 2001 -mesh_points = LinRange(-L, L, N) -N′ = (N + 1) ÷ 2 -base = mesh_points[N′ + 1] - mesh_points[N′ - 1] -initial_condition = zeros(N) -initial_condition[N′] = 2Q / base # Approximating a delta initial condition with a triangle around 0, making its area equal the mass Q by changing the point at 0 -initial_time = 0.0 -final_time = 5.0 -saveat = [0.1, 0.5, 1.0, 2.0, 3.0, 5.0] -diffusion = (u, x, t, p) -> p.p * (u / p.θ[1])^p.θ[2] -diffusion_p = D₀ -diffusion_θ = [u₀, m] -diffusion_parameters = (p = diffusion_p, θ = diffusion_θ) -lhs = Neumann(0.0) -rhs = Neumann(0.0) -prob = FVMProblem( - mesh_points, lhs, rhs; - initial_time, - final_time, - initial_condition, - diffusion_function = diffusion, - diffusion_parameters, - reaction_function = (u, x, t, p) -> zero(u) -) -sol = solve(prob, TRBDF2(); saveat = saveat) -exact = [exact_solution.(mesh_points, sol.t[i]) for i in eachindex(sol.t)] -@test exact ≈ sol.u rtol = 1.0e-1 +include(joinpath(@__DIR__, "..", "porous_medium.jl")) fig = Figure(size = (2150, 460), fontsize = 34) ax = Axis( diff --git a/test/Plotting/robin_diffusion.jl b/test/Plotting/robin_diffusion.jl index 3934c7f..f355aec 100644 --- a/test/Plotting/robin_diffusion.jl +++ b/test/Plotting/robin_diffusion.jl @@ -1,57 +1,6 @@ -using FiniteVolumeMethod1D -using LinearAlgebra -using LinearSolve -using OrdinaryDiffEq -using OrdinaryDiffEqSDIRK -using NonlinearSolve using CairoMakie using ReferenceTests - -# uₜ = (1/25)uₓₓ -# u(0, t) = 0 -# uₓ(3, t) = -u(3, t)/2 -# u(x, 0) = 100(1 - x/3) -# u(x, t) ≈ 47.0449exp[-0.0210t]sin(0.7249x) + ⋯ -# See http://ramanujan.math.trinity.edu/rdaileda/teach/s12/m3357/lectures/lecture_2_28_short.pdf - -# The eigenvalue problem to solve is tan(μₙL) = -μₙ/κ, where L = 3 and κ = 1/2 -function compute_μₙ(n) - interval = ((2n - 1)π / 6 + 0.001, n * π / 3 - 0.001) - f = (μₙ, _) -> tan(3μₙ) + 2μₙ - prob = IntervalNonlinearProblem(f, interval) - sol = solve(prob, Ridder(), reltol = 1.0e-9) - return sol.u -end -function exact_u(x, t, μ) - u = 0.0 - for (n, μₙ) in enumerate(μ) - u += 200 * (3μₙ - sin(3μₙ)) * exp(-μₙ^2 * t / 25) * sin(μₙ * x) / - (3μₙ^2 * (3 + 2cos(3μₙ)^2)) - end - return u -end - -c = 1 / 5 -mesh_points = LinRange(0, 3, 2500) -lhs = Dirichlet(0.0) -rhs = Neumann((u, t, p) -> u * p, -1 / 2) -diffusion_function = (u, x, t, p) -> p^2 -diffusion_parameters = c -ic = x -> 100(1 - x / 3) -initial_condition = ic.(mesh_points) -final_time = 3.0 -prob = FVMProblem( - mesh_points, lhs, rhs; - diffusion_function, - diffusion_parameters, - final_time = final_time, - initial_condition -) -sol = solve(prob, TRBDF2(linsolve = KLUFactorization()), saveat = 0.01) - -μ = compute_μₙ.(1:100) -exact_sol = [exact_u.(mesh_points, sol.t[i], Ref(μ)) for i in eachindex(sol.t)] -@test reduce(hcat, sol.u) ≈ reduce(hcat, exact_sol) rtol = 1.0e-2 +include(joinpath(@__DIR__, "..", "robin_diffusion.jl")) let t_range = LinRange(0.0, final_time, 250) fig = Figure(fontsize = 33) diff --git a/test/Project.toml b/test/Project.toml index 119e830..c260ded 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,13 +1,23 @@ [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae" +NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec" +OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" +OrdinaryDiffEqSDIRK = "2d112036-d095-4a1e-ab9a-08536f3ecdbf" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] +LinearSolve = "3.87, 4.2.0, 5.1" +NonlinearSolve = "4.17.1, 4.20.2" +OrdinaryDiffEq = "6.56, 7.1.1" +OrdinaryDiffEqSDIRK = "1.14, 2.7.1" SafeTestsets = "0.0.1, 0.1" SciMLBase = "3.18" SciMLTesting = "2.4" +SpecialFunctions = "2.8.0" Test = "1" diff --git a/test/dirichlet_source.jl b/test/dirichlet_source.jl new file mode 100644 index 0000000..ef24277 --- /dev/null +++ b/test/dirichlet_source.jl @@ -0,0 +1,39 @@ +using FiniteVolumeMethod1D +using LinearAlgebra +using LinearSolve +using OrdinaryDiffEq +using OrdinaryDiffEqSDIRK + +# p. 145 Constanda +# uₜ = uₓₓ + π²exp[-24π²t]sin(5πx), 0 < x < 1 +# u(0, t) = 0 +# u(1, t) = 0 +# u(x, 0) = 3sin(4πx) + +function exact_u(x, t) + return 3exp(-16π^2 * t) * sin(4π * x) + exp(-25π^2 * t) * (exp(π^2 * t) - 1) * sin(5π * x) +end + +reaction_function = (u, x, t, p) -> p[1] * exp(-p[2] * t) * sin(p[3] * x) +reaction_parameters = (π^2, 24π^2, 5π) +diffusion_function = (u, x, t, p) -> one(u) +lhs = Dirichlet(0.0) +rhs = Dirichlet(0.0) +mesh_points = LinRange(0, 1, 500) +ic_ff = x -> 3sin(4π * x) +initial_condition = ic_ff.(mesh_points) +final_time = 0.05 +prob = FVMProblem( + mesh_points, lhs, rhs; + diffusion_function, + reaction_function, + reaction_parameters, + initial_condition, + final_time +) +sol = solve( + prob, TRBDF2(linsolve = KLUFactorization()), + saveat = 0.001, abstol = 1.0e-10, reltol = 1.0e-8 +) +exact_sol = [exact_u.(mesh_points, sol.t[i]) for i in eachindex(sol.t)] +@test reduce(hcat, sol.u) ≈ reduce(hcat, exact_sol) rtol = 1.0e-1 diff --git a/test/heat.jl b/test/heat.jl new file mode 100644 index 0000000..a8f1269 --- /dev/null +++ b/test/heat.jl @@ -0,0 +1,30 @@ +using FiniteVolumeMethod1D +using OrdinaryDiffEq +using OrdinaryDiffEqSDIRK +using LinearSolve + +function exact2(x, t) + u = 1 / 2 + for n in 1:20 + u += ((-1)^n - 1) * 2 * cos(n * π * x) * exp(-n^2 * π^2 * t) / (n^2 * π^2) + end + return u +end + +mesh_points = LinRange(0, 1, 500) +lhs = Neumann(0.0) +rhs = Neumann(0.0) + +diffusion_function = (u, x, t, p) -> one(u) +initial_condition = collect(mesh_points) +final_time = 0.25 +prob = FVMProblem( + mesh_points, lhs, rhs; + diffusion_function, + initial_condition, + final_time +) + +sol = solve(prob, TRBDF2(linsolve = KLUFactorization())) +exact_sol = [exact2.(mesh_points, sol.t[i]) for i in eachindex(sol.t)] +@test reduce(hcat, sol.u) ≈ reduce(hcat, exact_sol) rtol = 1.0e-2 diff --git a/test/porous_medium.jl b/test/porous_medium.jl new file mode 100644 index 0000000..1868536 --- /dev/null +++ b/test/porous_medium.jl @@ -0,0 +1,45 @@ +using FiniteVolumeMethod1D +using OrdinaryDiffEq +using OrdinaryDiffEqSDIRK +using SpecialFunctions +FVM = FiniteVolumeMethod1D + +D₀ = 2.1e-3 +u₀ = 8.0e-1 +Q = 1.0 +m = 2 +r₀ = Q * gamma(1 / m + 3 / 2) / (sqrt(π) * u₀ * gamma(1 / m + 1)) +t₀ = r₀^2 * m / (2D₀ * (m + 2)) +λ = t -> (t / t₀)^(1 / (2 + m)) +exact_solution = ( + x, t, +) -> abs(x) > r₀ * λ(t) ? zero(x) : u₀ / λ(t) * (1 - (x / (r₀ * λ(t)))^2)^(1 / m) +L = 15.0 +Q = 1.0 +N = 2001 +mesh_points = LinRange(-L, L, N) +N′ = (N + 1) ÷ 2 +base = mesh_points[N′ + 1] - mesh_points[N′ - 1] +initial_condition = zeros(N) +initial_condition[N′] = 2Q / base # Approximating a delta initial condition with a triangle around 0, making its area equal the mass Q by changing the point at 0 +initial_time = 0.0 +final_time = 5.0 +saveat = [0.1, 0.5, 1.0, 2.0, 3.0, 5.0] +diffusion = (u, x, t, p) -> p.p * (u / p.θ[1])^p.θ[2] +diffusion_p = D₀ +diffusion_θ = [u₀, m] +diffusion_parameters = (p = diffusion_p, θ = diffusion_θ) +lhs = Neumann(0.0) +rhs = Neumann(0.0) +prob = FVMProblem( + mesh_points, lhs, rhs; + initial_time, + final_time, + initial_condition, + diffusion_function = diffusion, + diffusion_parameters, + reaction_function = (u, x, t, p) -> zero(u) +) +sol = solve(prob, TRBDF2(); saveat = saveat) +exact = [exact_solution.(mesh_points, sol.t[i]) for i in eachindex(sol.t)] +@test exact ≈ sol.u rtol = 1.0e-1 diff --git a/test/robin_diffusion.jl b/test/robin_diffusion.jl new file mode 100644 index 0000000..fa94a9b --- /dev/null +++ b/test/robin_diffusion.jl @@ -0,0 +1,52 @@ +using FiniteVolumeMethod1D +using LinearAlgebra +using LinearSolve +using OrdinaryDiffEq +using OrdinaryDiffEqSDIRK +using NonlinearSolve + +# uₜ = (1/25)uₓₓ +# u(0, t) = 0 +# uₓ(3, t) = -u(3, t)/2 +# u(x, 0) = 100(1 - x/3) +# u(x, t) ≈ 47.0449exp[-0.0210t]sin(0.7249x) + ⋯ +# See http://ramanujan.math.trinity.edu/rdaileda/teach/s12/m3357/lectures/lecture_2_28_short.pdf + +# The eigenvalue problem to solve is tan(μₙL) = -μₙ/κ, where L = 3 and κ = 1/2 +function compute_μₙ(n) + interval = ((2n - 1)π / 6 + 0.001, n * π / 3 - 0.001) + f = (μₙ, _) -> tan(3μₙ) + 2μₙ + prob = IntervalNonlinearProblem(f, interval) + sol = solve(prob, Ridder(), reltol = 1.0e-9) + return sol.u +end +function exact_u(x, t, μ) + u = 0.0 + for (n, μₙ) in enumerate(μ) + u += 200 * (3μₙ - sin(3μₙ)) * exp(-μₙ^2 * t / 25) * sin(μₙ * x) / + (3μₙ^2 * (3 + 2cos(3μₙ)^2)) + end + return u +end + +c = 1 / 5 +mesh_points = LinRange(0, 3, 2500) +lhs = Dirichlet(0.0) +rhs = Neumann((u, t, p) -> u * p, -1 / 2) +diffusion_function = (u, x, t, p) -> p^2 +diffusion_parameters = c +ic = x -> 100(1 - x / 3) +initial_condition = ic.(mesh_points) +final_time = 3.0 +prob = FVMProblem( + mesh_points, lhs, rhs; + diffusion_function, + diffusion_parameters, + final_time = final_time, + initial_condition +) +sol = solve(prob, TRBDF2(linsolve = KLUFactorization()), saveat = 0.01) + +μ = compute_μₙ.(1:100) +exact_sol = [exact_u.(mesh_points, sol.t[i], Ref(μ)) for i in eachindex(sol.t)] +@test reduce(hcat, sol.u) ≈ reduce(hcat, exact_sol) rtol = 1.0e-2 From 4de7139fd19e3d35a40096d88f6c624a9513afb5 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Wed, 14 Oct 2026 18:32:55 +0000 Subject: [PATCH 7/8] test: keep fisher.jl dependencies in the Plotting env test/shared/fisher.jl uses MethodOfLines, ModelingToolkit and DomainSets on top of CairoMakie/ReferenceTests, so its dependencies belong in the Plotting sub-env rather than Core. Co-Authored-By: Chris Rackauckas Co-Authored-By: Devin Agent-Harness: Devin CLI 3000.11.3 Agent-Model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium Agent-Session: local headless run, log /Users/chrisrackauckas/sandbox/master/green/fvm1d-121/log.txt --- test/Plotting/Project.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/Plotting/Project.toml b/test/Plotting/Project.toml index 13e1172..d97f1fe 100644 --- a/test/Plotting/Project.toml +++ b/test/Plotting/Project.toml @@ -1,8 +1,11 @@ [deps] CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" +DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf" FiniteVolumeMethod1D = "cfdabe9e-7cc8-40e3-9725-d80209c3e763" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae" +MethodOfLines = "94925ecb-adb7-4558-8ed8-f975c56a0bf4" +ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec" OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" OrdinaryDiffEqSDIRK = "2d112036-d095-4a1e-ab9a-08536f3ecdbf" @@ -14,7 +17,10 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] CairoMakie = "0.15.12" +DomainSets = "0.8.1" LinearSolve = "3.87, 4.2.0, 5.1" +MethodOfLines = "0.11.13" +ModelingToolkit = "11.31.0" NonlinearSolve = "4.17.1, 4.20.2" OrdinaryDiffEq = "6.56, 7.1.1" OrdinaryDiffEqSDIRK = "1.14, 2.7.1" From 573764ab9ae0b69653f1c102af0153c0363d2d4e Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Wed, 14 Oct 2026 23:03:05 +0000 Subject: [PATCH 8/8] Use native Int indices for the Jacobian sparsity pattern KLU on 32-bit platforms only accepts Int32 (= Int) sparse indices, so the Int64-indexed jac_prototype made the default sparse linear solve throw a MethodError on i686, failing the Core 32-bit lane. Co-Authored-By: Chris Rackauckas Co-Authored-By: Devin Agent-Harness: Devin CLI 3000.11.3 Agent-Model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium Agent-Session: local headless run, log /Users/chrisrackauckas/sandbox/master/green/fu/SciML_FiniteVolumeMethod1D.jl-121-1918/log.txt --- src/equations.jl | 4 ++-- test/ode_problem.jl | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/equations.jl b/src/equations.jl index a78dfe2..ebdbbd0 100644 --- a/src/equations.jl +++ b/src/equations.jl @@ -61,8 +61,8 @@ end jacobian_sparsity(prob::FVMProblem) = jacobian_sparsity(prob.geometry.mesh_points) function jacobian_sparsity(pts) num_nnz = 3(length(pts) - 2) + 4 # 3 neighbours for each interior node, 2 from each boundary node - I = zeros(Int64, num_nnz) - J = zeros(Int64, num_nnz) + I = zeros(Int, num_nnz) + J = zeros(Int, num_nnz) V = ones(num_nnz) # The left boundary node I[1] = firstindex(pts) diff --git a/test/ode_problem.jl b/test/ode_problem.jl index ebb5f34..2ebd632 100644 --- a/test/ode_problem.jl +++ b/test/ode_problem.jl @@ -28,6 +28,7 @@ prob = FVMProblem(; ) J = FVM.jacobian_sparsity(prob) @test J == FVM.jacobian_sparsity(mesh_points) +@test J isa SparseMatrixCSC{Float64, Int} _J = zeros(length(mesh_points), length(mesh_points)) for i in eachindex(mesh_points) if i == 1