Skip to content

Commit a5d5a63

Browse files
committed
set p in alg_cache
1 parent 8376041 commit a5d5a63

File tree

4 files changed

+35
-31
lines changed

4 files changed

+35
-31
lines changed

lib/OrdinaryDiffEqDifferentiation/src/linsolve_utils.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ function dolinsolve(integrator, linsolve; A = nothing, linu = nothing, b = nothi
1111
_alg = unwrap_alg(integrator, true)
1212
if !isnothing(A)
1313
(;du, u, p, t) = integrator
14-
p = isnothing(integrator) ? nothing : (du, u, p, t)
15-
reinit!(linsolve; A, p)
14+
if isnothing(integrator)
15+
reinit!(linsolve; A)
16+
else
17+
p = (du, u, p, t)
18+
reinit!(linsolve; A, p)
19+
end
1620
end
1721

1822
linres = solve!(linsolve; reltol)

lib/OrdinaryDiffEqNonlinearSolve/src/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ function build_nlsolver(
191191
end
192192
jac_config = build_jac_config(alg, nf, uf, du1, uprev, u, ztmp, dz)
193193
end
194-
linprob = LinearProblem(W, _vec(k); u0 = _vec(dz))
194+
linprob = LinearProblem(W, _vec(k), (isdae ? du1 : nothing,u,p,t); u0 = _vec(dz))
195195
Pl, Pr = wrapprecs(
196196
alg.precs(W, nothing, u, p, t, nothing, nothing, nothing,
197197
nothing)...,
198198
weight, dz)
199-
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
199+
linsolve = init(linprob, alg.linsolve, (isdae ? du1 : nothing,u,p,t); alias_A = true, alias_b = true,
200200
Pl = Pl, Pr = Pr,
201201
assumptions = LinearSolve.OperatorAssumptions(true))
202202

lib/OrdinaryDiffEqRosenbrock/src/generic_rosenbrock.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ function gen_algcache(cacheexpr::Expr,constcachename::Symbol,algname::Symbol,tab
247247
tf = TimeGradientWrapper(f,uprev,p)
248248
uf = UJacobianWrapper(f,t,p)
249249
linsolve_tmp = zero(rate_prototype)
250-
linprob = LinearProblem(W,_vec(linsolve_tmp); u0=_vec(tmp))
250+
linprob = LinearProblem(W,_vec(linsolve_tmp), (nothing, u, p, t); u0=_vec(tmp))
251251
linsolve = init(linprob,alg.linsolve,alias_A=true,alias_b=true,
252252
Pl = LinearSolve.InvPreconditioner(Diagonal(_vec(weight))),
253253
Pr = Diagonal(_vec(weight)))
@@ -995,7 +995,7 @@ references = """
995995
""",
996996
"Rodas3",
997997
references = """
998-
- Steinebach G. Construction of Rosenbrock–Wanner method Rodas5P and numerical benchmarks
998+
- Steinebach G. Construction of Rosenbrock–Wanner method Rodas5P and numerical benchmarks
999999
within the Julia Differential Equations package.
10001000
In: BIT Numerical Mathematics, 63(2), 2023
10011001
""",
@@ -1056,7 +1056,7 @@ lower if not corrected).
10561056
""",
10571057
"Rodas4P",
10581058
references = """
1059-
- Steinebach G., Rodas23W / Rodas32P - a Rosenbrock-type method for DAEs with additional error estimate
1059+
- Steinebach G., Rodas23W / Rodas32P - a Rosenbrock-type method for DAEs with additional error estimate
10601060
for dense output and Julia implementation,
10611061
In progress.
10621062
""",
@@ -1070,7 +1070,7 @@ of Roadas4P and in case of inexact Jacobians a second order W method.
10701070
""",
10711071
"Rodas4P2",
10721072
references = """
1073-
- Steinebach G., Rodas23W / Rodas32P - a Rosenbrock-type method for DAEs with additional error estimate
1073+
- Steinebach G., Rodas23W / Rodas32P - a Rosenbrock-type method for DAEs with additional error estimate
10741074
for dense output and Julia implementation,
10751075
In progress.
10761076
""",
@@ -1095,7 +1095,7 @@ Has improved stability in the adaptive time stepping embedding.
10951095
""",
10961096
"Rodas5P",
10971097
references = """
1098-
- Steinebach G. Construction of Rosenbrock–Wanner method Rodas5P and numerical benchmarks
1098+
- Steinebach G. Construction of Rosenbrock–Wanner method Rodas5P and numerical benchmarks
10991099
within the Julia Differential Equations package.
11001100
In: BIT Numerical Mathematics, 63(2), 2023
11011101
""",
@@ -1225,10 +1225,10 @@ references = """
12251225
ROS2PRTableau()
12261226
12271227
2nd order stiffly accurate Rosenbrock method with 3 internal stages with (Rinf=0).
1228-
For problems with medium stiffness the convergence behaviour is very poor and it is recommended to use
1228+
For problems with medium stiffness the convergence behaviour is very poor and it is recommended to use
12291229
[`ROS2S`](@ref) instead.
12301230
1231-
Rang, Joachim (2014): The Prothero and Robinson example:
1231+
Rang, Joachim (2014): The Prothero and Robinson example:
12321232
Convergence studies for Runge-Kutta and Rosenbrock-Wanner methods. https://doi.org/10.24355/dbbs.084-201408121139-0
12331233
"""
12341234
function ROS2PRTableau() # 2nd order
@@ -1248,7 +1248,7 @@ end
12481248
@doc rosenbrock_docstring(
12491249
"""
12501250
2nd order stiffly accurate Rosenbrock method with 3 internal stages with (Rinf=0).
1251-
For problems with medium stiffness the convergence behaviour is very poor and it is recommended to use
1251+
For problems with medium stiffness the convergence behaviour is very poor and it is recommended to use
12521252
[`ROS2S`](@ref) instead.
12531253
""",
12541254
"ROS2PR",
@@ -1267,7 +1267,7 @@ ROS2PR
12671267
2nd order stiffly accurate Rosenbrock-Wanner W-method with 3 internal stages with B_PR consistent of order 2 with (Rinf=0).
12681268
More Information at https://doi.org/10.24355/dbbs.084-201408121139-0
12691269
1270-
Rang, Joachim (2014): The Prothero and Robinson example:
1270+
Rang, Joachim (2014): The Prothero and Robinson example:
12711271
Convergence studies for Runge-Kutta and Rosenbrock-Wanner methods. https://doi.org/10.24355/dbbs.084-201408121139-0
12721272
"""
12731273
function ROS2STableau() # 2nd order
@@ -1335,7 +1335,7 @@ references = """
13351335
13361336
3nd order stiffly accurate Rosenbrock-Wanner method with 3 internal stages with B_PR consistent of order 3, which is strongly A-stable with Rinf~=-0.73.
13371337
1338-
Rang, Joachim (2014): The Prothero and Robinson example:
1338+
Rang, Joachim (2014): The Prothero and Robinson example:
13391339
Convergence studies for Runge-Kutta and Rosenbrock-Wanner methods. https://doi.org/10.24355/dbbs.084-201408121139-0
13401340
"""
13411341
function ROS3PRTableau() # 3rd order
@@ -1371,7 +1371,7 @@ references = """
13711371
3nd order stiffly accurate Rosenbrock method with 3 internal stages with B_PR consistent of order 3, which is strongly A-stable with Rinf~=-0.73
13721372
Convergence with order 4 for the stiff case, but has a poor accuracy.
13731373
1374-
Rang, Joachim (2014): The Prothero and Robinson example:
1374+
Rang, Joachim (2014): The Prothero and Robinson example:
13751375
Convergence studies for Runge-Kutta and Rosenbrock-Wanner methods. https://doi.org/10.24355/dbbs.084-201408121139-0
13761376
"""
13771377
function Scholz4_7Tableau() # 3rd order
@@ -1599,7 +1599,7 @@ references = """
15991599
B_PR consistent of order 2 with Rinf=0.
16001600
The order of convergence decreases if medium stiff problems are considered, but it has good results for very stiff cases.
16011601
1602-
Rang, Joachim (2014): The Prothero and Robinson example:
1602+
Rang, Joachim (2014): The Prothero and Robinson example:
16031603
Convergence studies for Runge-Kutta and Rosenbrock-Wanner methods. https://doi.org/10.24355/dbbs.084-201408121139-0
16041604
"""
16051605
function ROS3PRLTableau() # 3rd order
@@ -1639,7 +1639,7 @@ references = """
16391639
B_PR consistent of order 3.
16401640
The order of convergence does NOT decreases if medium stiff problems are considered as it does for [`ROS3PRL`](@ref).
16411641
1642-
Rang, Joachim (2014): The Prothero and Robinson example:
1642+
Rang, Joachim (2014): The Prothero and Robinson example:
16431643
Convergence studies for Runge-Kutta and Rosenbrock-Wanner methods. https://doi.org/10.24355/dbbs.084-201408121139-0
16441644
"""
16451645
function ROS3PRL2Tableau() # 3rd order
@@ -1677,7 +1677,7 @@ references = """
16771677
16781678
4rd order L-stable Rosenbrock-Krylov method with 4 internal stages,
16791679
with a 3rd order embedded method which is strongly A-stable with Rinf~=0.55. (when using exact Jacobians)
1680-
Tranquilli, Paul and Sandu, Adrian (2014): Rosenbrock--Krylov Methods for Large Systems of Differential Equations
1680+
Tranquilli, Paul and Sandu, Adrian (2014): Rosenbrock--Krylov Methods for Large Systems of Differential Equations
16811681
https://doi.org/10.1137/130923336
16821682
"""
16831683
function ROK4aTableau() # 4rd order
@@ -1703,7 +1703,7 @@ with a 3rd order embedded method which is strongly A-stable with Rinf~=0.55. (wh
17031703
""",
17041704
"ROK4a",
17051705
references = """
1706-
- Tranquilli, Paul and Sandu, Adrian (2014):
1706+
- Tranquilli, Paul and Sandu, Adrian (2014):
17071707
Rosenbrock--Krylov Methods for Large Systems of Differential Equations
17081708
https://doi.org/10.1137/130923336
17091709
""") ROK4a

lib/OrdinaryDiffEqRosenbrock/src/rosenbrock_caches.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function alg_cache(alg::Rosenbrock23, u, rate_prototype, ::Type{uEltypeNoUnits},
9999
uf = UJacobianWrapper(f, t, p)
100100
linsolve_tmp = zero(rate_prototype)
101101

102-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
102+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
103103
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
104104
assumptions = LinearSolve.OperatorAssumptions(true))
105105

@@ -140,7 +140,7 @@ function alg_cache(alg::Rosenbrock32, u, rate_prototype, ::Type{uEltypeNoUnits},
140140
tf = TimeGradientWrapper(f, uprev, p)
141141
uf = UJacobianWrapper(f, t, p)
142142
linsolve_tmp = zero(rate_prototype)
143-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
143+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
144144

145145
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
146146
assumptions = LinearSolve.OperatorAssumptions(true))
@@ -285,7 +285,7 @@ function alg_cache(alg::ROS3P, u, rate_prototype, ::Type{uEltypeNoUnits},
285285
tf = TimeGradientWrapper(f, uprev, p)
286286
uf = UJacobianWrapper(f, t, p)
287287
linsolve_tmp = zero(rate_prototype)
288-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
288+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
289289
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
290290
assumptions = LinearSolve.OperatorAssumptions(true))
291291
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -367,7 +367,7 @@ function alg_cache(alg::Rodas3, u, rate_prototype, ::Type{uEltypeNoUnits},
367367
tf = TimeGradientWrapper(f, uprev, p)
368368
uf = UJacobianWrapper(f, t, p)
369369
linsolve_tmp = zero(rate_prototype)
370-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
370+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
371371
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
372372
assumptions = LinearSolve.OperatorAssumptions(true))
373373
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -556,7 +556,7 @@ function alg_cache(alg::Rodas23W, u, rate_prototype, ::Type{uEltypeNoUnits},
556556
tf = TimeGradientWrapper(f, uprev, p)
557557
uf = UJacobianWrapper(f, t, p)
558558
linsolve_tmp = zero(rate_prototype)
559-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
559+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
560560
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
561561
assumptions = LinearSolve.OperatorAssumptions(true))
562562
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -596,7 +596,7 @@ function alg_cache(alg::Rodas3P, u, rate_prototype, ::Type{uEltypeNoUnits},
596596
tf = TimeGradientWrapper(f, uprev, p)
597597
uf = UJacobianWrapper(f, t, p)
598598
linsolve_tmp = zero(rate_prototype)
599-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
599+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
600600
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
601601
assumptions = LinearSolve.OperatorAssumptions(true))
602602
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -715,7 +715,7 @@ function alg_cache(alg::Rodas4, u, rate_prototype, ::Type{uEltypeNoUnits},
715715
tf = TimeGradientWrapper(f, uprev, p)
716716
uf = UJacobianWrapper(f, t, p)
717717
linsolve_tmp = zero(rate_prototype)
718-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
718+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
719719
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
720720
assumptions = LinearSolve.OperatorAssumptions(true))
721721
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -771,7 +771,7 @@ function alg_cache(alg::Rodas42, u, rate_prototype, ::Type{uEltypeNoUnits},
771771
tf = TimeGradientWrapper(f, uprev, p)
772772
uf = UJacobianWrapper(f, t, p)
773773
linsolve_tmp = zero(rate_prototype)
774-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
774+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
775775
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
776776
assumptions = LinearSolve.OperatorAssumptions(true))
777777
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -827,7 +827,7 @@ function alg_cache(alg::Rodas4P, u, rate_prototype, ::Type{uEltypeNoUnits},
827827
tf = TimeGradientWrapper(f, uprev, p)
828828
uf = UJacobianWrapper(f, t, p)
829829
linsolve_tmp = zero(rate_prototype)
830-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
830+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
831831
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
832832
assumptions = LinearSolve.OperatorAssumptions(true))
833833
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -883,7 +883,7 @@ function alg_cache(alg::Rodas4P2, u, rate_prototype, ::Type{uEltypeNoUnits},
883883
tf = TimeGradientWrapper(f, uprev, p)
884884
uf = UJacobianWrapper(f, t, p)
885885
linsolve_tmp = zero(rate_prototype)
886-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
886+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
887887
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
888888
assumptions = LinearSolve.OperatorAssumptions(true))
889889
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -996,7 +996,7 @@ function alg_cache(alg::Rodas5, u, rate_prototype, ::Type{uEltypeNoUnits},
996996
tf = TimeGradientWrapper(f, uprev, p)
997997
uf = UJacobianWrapper(f, t, p)
998998
linsolve_tmp = zero(rate_prototype)
999-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
999+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
10001000
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
10011001
assumptions = LinearSolve.OperatorAssumptions(true))
10021002
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -1056,7 +1056,7 @@ function alg_cache(
10561056
tf = TimeGradientWrapper(f, uprev, p)
10571057
uf = UJacobianWrapper(f, t, p)
10581058
linsolve_tmp = zero(rate_prototype)
1059-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
1059+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
10601060
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
10611061
assumptions = LinearSolve.OperatorAssumptions(true))
10621062
grad_config = build_grad_config(alg, f, tf, du1, t)

0 commit comments

Comments
 (0)