Skip to content

Commit 025900d

Browse files
committed
set p in alg_cache
1 parent 791f557 commit 025900d

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
@@ -94,7 +94,7 @@ function alg_cache(alg::Rosenbrock23, u, rate_prototype, ::Type{uEltypeNoUnits},
9494
uf = UJacobianWrapper(f, t, p)
9595
linsolve_tmp = zero(rate_prototype)
9696

97-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
97+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
9898
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
9999
assumptions = LinearSolve.OperatorAssumptions(true))
100100

@@ -135,7 +135,7 @@ function alg_cache(alg::Rosenbrock32, u, rate_prototype, ::Type{uEltypeNoUnits},
135135
tf = TimeGradientWrapper(f, uprev, p)
136136
uf = UJacobianWrapper(f, t, p)
137137
linsolve_tmp = zero(rate_prototype)
138-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
138+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
139139

140140
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
141141
assumptions = LinearSolve.OperatorAssumptions(true))
@@ -280,7 +280,7 @@ function alg_cache(alg::ROS3P, u, rate_prototype, ::Type{uEltypeNoUnits},
280280
tf = TimeGradientWrapper(f, uprev, p)
281281
uf = UJacobianWrapper(f, t, p)
282282
linsolve_tmp = zero(rate_prototype)
283-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
283+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
284284
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
285285
assumptions = LinearSolve.OperatorAssumptions(true))
286286
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -362,7 +362,7 @@ function alg_cache(alg::Rodas3, u, rate_prototype, ::Type{uEltypeNoUnits},
362362
tf = TimeGradientWrapper(f, uprev, p)
363363
uf = UJacobianWrapper(f, t, p)
364364
linsolve_tmp = zero(rate_prototype)
365-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
365+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
366366
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
367367
assumptions = LinearSolve.OperatorAssumptions(true))
368368
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -551,7 +551,7 @@ function alg_cache(alg::Rodas23W, u, rate_prototype, ::Type{uEltypeNoUnits},
551551
tf = TimeGradientWrapper(f, uprev, p)
552552
uf = UJacobianWrapper(f, t, p)
553553
linsolve_tmp = zero(rate_prototype)
554-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
554+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
555555
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
556556
assumptions = LinearSolve.OperatorAssumptions(true))
557557
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -591,7 +591,7 @@ function alg_cache(alg::Rodas3P, u, rate_prototype, ::Type{uEltypeNoUnits},
591591
tf = TimeGradientWrapper(f, uprev, p)
592592
uf = UJacobianWrapper(f, t, p)
593593
linsolve_tmp = zero(rate_prototype)
594-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
594+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
595595
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
596596
assumptions = LinearSolve.OperatorAssumptions(true))
597597
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -710,7 +710,7 @@ function alg_cache(alg::Rodas4, u, rate_prototype, ::Type{uEltypeNoUnits},
710710
tf = TimeGradientWrapper(f, uprev, p)
711711
uf = UJacobianWrapper(f, t, p)
712712
linsolve_tmp = zero(rate_prototype)
713-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
713+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
714714
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
715715
assumptions = LinearSolve.OperatorAssumptions(true))
716716
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -766,7 +766,7 @@ function alg_cache(alg::Rodas42, u, rate_prototype, ::Type{uEltypeNoUnits},
766766
tf = TimeGradientWrapper(f, uprev, p)
767767
uf = UJacobianWrapper(f, t, p)
768768
linsolve_tmp = zero(rate_prototype)
769-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
769+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
770770
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
771771
assumptions = LinearSolve.OperatorAssumptions(true))
772772
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -822,7 +822,7 @@ function alg_cache(alg::Rodas4P, u, rate_prototype, ::Type{uEltypeNoUnits},
822822
tf = TimeGradientWrapper(f, uprev, p)
823823
uf = UJacobianWrapper(f, t, p)
824824
linsolve_tmp = zero(rate_prototype)
825-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
825+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
826826
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
827827
assumptions = LinearSolve.OperatorAssumptions(true))
828828
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -878,7 +878,7 @@ function alg_cache(alg::Rodas4P2, u, rate_prototype, ::Type{uEltypeNoUnits},
878878
tf = TimeGradientWrapper(f, uprev, p)
879879
uf = UJacobianWrapper(f, t, p)
880880
linsolve_tmp = zero(rate_prototype)
881-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
881+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
882882
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
883883
assumptions = LinearSolve.OperatorAssumptions(true))
884884
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -991,7 +991,7 @@ function alg_cache(alg::Rodas5, u, rate_prototype, ::Type{uEltypeNoUnits},
991991
tf = TimeGradientWrapper(f, uprev, p)
992992
uf = UJacobianWrapper(f, t, p)
993993
linsolve_tmp = zero(rate_prototype)
994-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
994+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
995995
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
996996
assumptions = LinearSolve.OperatorAssumptions(true))
997997
grad_config = build_grad_config(alg, f, tf, du1, t)
@@ -1051,7 +1051,7 @@ function alg_cache(
10511051
tf = TimeGradientWrapper(f, uprev, p)
10521052
uf = UJacobianWrapper(f, t, p)
10531053
linsolve_tmp = zero(rate_prototype)
1054-
linprob = LinearProblem(W, _vec(linsolve_tmp); u0 = _vec(tmp))
1054+
linprob = LinearProblem(W, _vec(linsolve_tmp), (nothing,u,p,t); u0 = _vec(tmp))
10551055
linsolve = init(linprob, alg.linsolve, alias_A = true, alias_b = true,
10561056
assumptions = LinearSolve.OperatorAssumptions(true))
10571057
grad_config = build_grad_config(alg, f, tf, du1, t)

0 commit comments

Comments
 (0)