From a9c4378f592049363c1c0061f2a2c8b96b0d9a29 Mon Sep 17 00:00:00 2001 From: Gabriel Gerlero Date: Fri, 6 Sep 2024 14:08:04 -0300 Subject: [PATCH] Use BandedMatrices for jac_prototype with FiniteReservoirProblem --- Project.toml | 2 ++ src/Fronts.jl | 1 + src/finite.jl | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 44c5fe4..916cab5 100644 --- a/Project.toml +++ b/Project.toml @@ -5,6 +5,7 @@ version = "2.6.1" [deps] ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197" +BandedMatrices = "aae01518-5342-5314-be14-df237901396f" DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" @@ -22,6 +23,7 @@ ToeplitzMatrices = "c751599d-da0a-543b-9d20-d0a503d91d24" [compat] ArgCheck = "2" +BandedMatrices = "1" DifferentiationInterface = "=0.5.5" ForwardDiff = "0.10" LinearAlgebra = "1" diff --git a/src/Fronts.jl b/src/Fronts.jl index 3b2e99e..04c40b4 100644 --- a/src/Fronts.jl +++ b/src/Fronts.jl @@ -13,6 +13,7 @@ using DifferentiationInterface: value_and_derivative, value_derivative_and_second_derivative, AutoForwardDiff using ArgCheck: @argcheck using StaticArrays: @SVector, @SMatrix +using BandedMatrices: BandedMatrix using RecursiveArrayTools: ArrayPartition using PCHIPInterpolation: Interpolator, integrate import NumericalIntegration diff --git a/src/finite.jl b/src/finite.jl index 8f73491..6b32dd6 100644 --- a/src/finite.jl +++ b/src/finite.jl @@ -349,7 +349,8 @@ function solve(prob::FiniteReservoirProblem{<:DiffusionEquation{1}}, end end - f! = ODEFunction(f!) + f! = ODEFunction(f!, + jac_prototype = BandedMatrix{eltype(u)}(undef, (length(u), length(u)), (1, 2))) steady_state = DiscreteCallback( (u, t, integrator) -> all(u[(begin + 1):end] .≈ u[end]),