Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/OrdinaryDiffEqRosenbrock/src/OrdinaryDiffEqRosenbrock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ function rosenbrock_wolfbrandt_docstring(
ForwardDiff default function-specific tags. For more information, see
[this blog post](https://www.stochasticlifestyle.com/improved-forwarddiff-jl-stacktraces-with-package-tags/).
Defaults to `Val{true}()`.
- `autodiff`: Uses [ADTypes.jl](https://sciml.github.io/ADTypes.jl/stable/)
- `autodiff`: Uses [ADTypes.jl](https://sciml.github.io/ADTypes.jl/stable/)
to specify whether to use automatic differentiation via
[ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl) or finite
differencing via [FiniteDiff.jl](https://github.com/JuliaDiff/FiniteDiff.jl).
differencing via [FiniteDiff.jl](https://github.com/JuliaDiff/FiniteDiff.jl).
Defaults to `AutoForwardDiff()` for automatic differentiation, which by default uses
`chunksize = 0`, and thus uses the internal ForwardDiff.jl algorithm for the choice.
To use `FiniteDiff.jl`, the `AutoFiniteDiff()` ADType can be used, which has a keyword argument
Expand Down Expand Up @@ -139,10 +139,10 @@ function rosenbrock_docstring(
ForwardDiff default function-specific tags. For more information, see
[this blog post](https://www.stochasticlifestyle.com/improved-forwarddiff-jl-stacktraces-with-package-tags/).
Defaults to `Val{true}()`.
- `autodiff`: Uses [ADTypes.jl](https://sciml.github.io/ADTypes.jl/stable/)
- `autodiff`: Uses [ADTypes.jl](https://sciml.github.io/ADTypes.jl/stable/)
to specify whether to use automatic differentiation via
[ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl) or finite
differencing via [FiniteDiff.jl](https://github.com/JuliaDiff/FiniteDiff.jl).
differencing via [FiniteDiff.jl](https://github.com/JuliaDiff/FiniteDiff.jl).
Defaults to `AutoForwardDiff()` for automatic differentiation, which by default uses
`chunksize = 0`, and thus uses the internal ForwardDiff.jl algorithm for the choice.
To use `FiniteDiff.jl`, the `AutoFiniteDiff()` ADType can be used, which has a keyword argument
Expand Down Expand Up @@ -216,6 +216,7 @@ include("alg_utils.jl")
include("generic_rosenbrock.jl")
include("rosenbrock_caches.jl")
include("rosenbrock_tableaus.jl")
include("generic_rosenbrock_runtime.jl")
include("interp_func.jl")
include("rosenbrock_interpolants.jl")
include("stiff_addsteps.jl")
Expand Down Expand Up @@ -296,6 +297,9 @@ export Rosenbrock23, Rosenbrock32, RosShamp4, Veldd4, Velds4, GRK4T, GRK4A,
Rodas5, Rodas5P, Rodas5Pe, Rodas5Pr, Rodas6P, HybridExplicitImplicitRK, Tsit5DA,
RosenbrockW6S4OS, ROS34PW1a, ROS34PW1b, ROS34PW2, ROS34PW3, ROS34PRw, ROS3PRL,
ROS3PRL2, ROK4a,
ROS2, ROS2PR, ROS2S, ROS3, ROS3PR, Scholz4_7
ROS2, ROS2PR, ROS2S, ROS3, ROS3PR, Scholz4_7,
GenericRosenbrock, RodasTableau,
constructRodas4, constructRodas42, constructRodas4P, constructRodas4P2,
constructRodas5, constructRodas5P, constructRodas6P

end
6 changes: 5 additions & 1 deletion lib/OrdinaryDiffEqRosenbrock/src/alg_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ function has_stiff_interpolation(
Rosenbrock23, Rosenbrock32, Rodas23W,
Rodas3P, Rodas4, Rodas4P, Rodas4P2, Rodas5,
Rodas5P, Rodas5Pe, Rodas5Pr, Rodas6P,
HybridExplicitImplicitRK,
HybridExplicitImplicitRK, GenericRosenbrock,
}
)
return true
end

only_diagonal_mass_matrix(alg::Union{Rosenbrock23, Rosenbrock32}) = true

# GenericRosenbrock alg_utils
alg_order(alg::GenericRosenbrock) = alg.order
isfsal(alg::GenericRosenbrock) = false
59 changes: 59 additions & 0 deletions lib/OrdinaryDiffEqRosenbrock/src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,62 @@ References:
arXiv:2511.21252, 2025.
"""
Tsit5DA(; kwargs...) = HybridExplicitImplicitRK(Tsit5DATableau; order = 5, kwargs...)

# ============================================================================
# GenericRosenbrock - Generic Rosenbrock solver with custom tableau
# ============================================================================

"""
GenericRosenbrock(; tableau, order = 5, kwargs...)

A generic Rosenbrock method that allows you to define a custom tableau.
This solver accepts any `RodasTableau` and uses the generic Rosenbrock stepping algorithm.

# Parameters
- `tableau`: A `RodasTableau{T, T2}` object defining the Rosenbrock tableau coefficients.
Can be constructed using functions like `constructRodas5P()`.
- `order`: The order of the method (default: 5)
- Other keyword arguments are passed to the underlying algorithm configuration.

# Example
```julia
using OrdinaryDiffEqRosenbrock
prob = ODEProblem((u, p, t) -> -u, 1.0, (0.0, 1.0))
sol = solve(prob, GenericRosenbrock(tableau = constructRodas5P()))
```

For most applications, prefer the named methods like `Rodas5P()`, `Rodas4P()`, etc.
"""
struct GenericRosenbrock{CS, AD, F, P, FDT, ST, CJ, TabType, StepLimiter, StageLimiter} <:
OrdinaryDiffEqRosenbrockAdaptiveAlgorithm{CS, AD, FDT, ST, CJ}
tableau::TabType
order::Int
num_solution_stages::Int
linsolve::F
precs::P
step_limiter!::StepLimiter
stage_limiter!::StageLimiter
autodiff::AD
end

function GenericRosenbrock(;
tableau, order = 5, num_solution_stages = size(tableau.A, 1),
chunk_size = Val{0}(), autodiff = AutoForwardDiff(),
standardtag = Val{true}(), concrete_jac = nothing,
diff_type = Val{:forward}(), linsolve = nothing,
precs = DEFAULT_PRECS, step_limiter! = trivial_limiter!,
stage_limiter! = trivial_limiter!
)
AD_choice, chunk_size, diff_type = _process_AD_choice(
autodiff, chunk_size, diff_type
)
return GenericRosenbrock{
_unwrap_val(chunk_size), typeof(AD_choice), typeof(linsolve),
typeof(precs), diff_type, _unwrap_val(standardtag),
_unwrap_val(concrete_jac), typeof(tableau), typeof(step_limiter!),
typeof(stage_limiter!),
}(
tableau, order, num_solution_stages, linsolve, precs, step_limiter!,
stage_limiter!, AD_choice
)
end
Loading