Skip to content
Open
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
21 changes: 19 additions & 2 deletions lib/OrdinaryDiffEqDifferentiation/src/linsolve_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ function dolinsolve(integrator, linsolve; A = nothing, linu = nothing, b = nothi

_alg = unwrap_alg(integrator, true)

_Pl,
_Pr = _alg.precs(linsolve.A, du, u, p, t, A !== nothing, Plprev, Prprev,
_Pl, _Pr = _alg.precs(linsolve.A, du, u, p, t, A !== nothing, Plprev, Prprev,
solverdata)
if (_Pl !== nothing || _Pr !== nothing)
__Pl = _Pl === nothing ? SciMLOperators.IdentityOperator(length(integrator.u)) : _Pl
Expand Down Expand Up @@ -58,4 +57,22 @@ function wrapprecs(_Pl, _Pr, weight, u)
Pl, Pr
end

function wrapprecs(alg, W, weight, u, p, t)
linsolver = alg.linsolve
if hasproperty(linsolver, :precs) && isnothing(linsolver.precs)

if alg.precs != OrdinaryDiffEqCore.DEFAULT_PRECS
@warn "passing precs via the ODE solver is deprecated. Pass precs via the Linear Solver"
precs = Returns(wrapprecs(alg.precs(W, nothing, u, p, t, nothing, nothing, nothing, nothing)..., weight, u))
return remake(linsolver; precs)
end
Pl = LinearSolve.InvPreconditioner(Diagonal(_vec(weight)))
Pr = Diagonal(_vec(weight))
precs = Returns((Pl, Pr))
return remake(linsolver; precs)
else
return linsolver
end
end

Base.resize!(p::LinearSolve.LinearCache, i) = p
11 changes: 3 additions & 8 deletions lib/OrdinaryDiffEqNonlinearSolve/src/newton.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,9 @@ end
reltol = eps(eltype(dz))
end

if is_always_new(nlsolver) || (iter == 1 && new_W)
linres = dolinsolve(integrator, linsolve; A = W, b = _vec(b), linu = _vec(dz),
reltol = reltol)
else
linres = dolinsolve(
integrator, linsolve; A = nothing, b = _vec(b), linu = _vec(dz),
reltol = reltol)
end
make_new_W = is_always_new(nlsolver) || (iter == 1 && new_W)
linres = dolinsolve(integrator, linsolve; A = make_new_W ? W : nothing, b = _vec(b),
linu = _vec(dz), reltol)

if !SciMLBase.successful_retcode(linres.retcode) &&
linres.retcode != SciMLBase.ReturnCode.Default
Expand Down
9 changes: 2 additions & 7 deletions lib/OrdinaryDiffEqNonlinearSolve/src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,9 @@ function build_nlsolver(
jac_config = build_jac_config(alg, nf, uf, du1, uprev, u, ztmp, dz)
end
J, W = build_J_W(alg, u, uprev, p, t, dt, f, jac_config, uEltypeNoUnits, Val(true))
linprob = LinearProblem(W, _vec(k); u0 = _vec(dz))
Pl, Pr = wrapprecs(
alg.precs(W, nothing, u, p, t, nothing, nothing, nothing,
nothing)...,
weight, dz)
linsolve = init(linprob, alg.linsolve,
linprob = LinearProblem(W, _vec(k), (isdae ? du1 : nothing,u,p,t); u0 = _vec(dz))
linsolve = init(linprob, wrapprecs(alg, W, weight, u, p, t),
alias = LinearAliasSpecifier(alias_A = true, alias_b = true),
Pl = Pl, Pr = Pr,
assumptions = LinearSolve.OperatorAssumptions(true))

tType = typeof(t)
Expand Down
96 changes: 47 additions & 49 deletions lib/OrdinaryDiffEqRosenbrock/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,75 +4,73 @@ authors = ["ParamThakkar123 <[email protected]>"]
version = "1.18.1"

[deps]
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
FastBroadcast = "7034ab61-46d4-4ed7-9d0f-46aef9175898"
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
MuladdMacro = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221"
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
MuladdMacro = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221"
OrdinaryDiffEqCore = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
OrdinaryDiffEqDifferentiation = "4302a76b-040a-498a-8c04-15b101fed76b"
Polyester = "f517fe37-dbe3-4b94-8317-1923a5111588"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
OrdinaryDiffEqDifferentiation = "4302a76b-040a-498a-8c04-15b101fed76b"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
OrdinaryDiffEqCore = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
DiffEqDevTools = "f3b72e0c-5b89-59e1-b016-84e28bfd966d"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
ODEProblemLibrary = "fdc4e326-1af4-4b90-96e7-779fcce2daa5"
OrdinaryDiffEqNonlinearSolve = "127b3ac7-2247-4354-8eb6-78cf4e7c58e8"
AllocCheck = "9b6a8646-10ed-4001-bbdc-1d2f46dfbb1a"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
[sources]
OrdinaryDiffEqCore = {path = "../OrdinaryDiffEqCore"}
OrdinaryDiffEqDifferentiation = {path = "../OrdinaryDiffEqDifferentiation"}

[compat]
ForwardDiff = "0.10.38, 1"
Test = "<0.0.1, 1"
FastBroadcast = "0.3"
Random = "<0.0.1, 1"
ADTypes = "1.16"
AllocCheck = "0.2"
Aqua = "0.8.11"
DiffEqBase = "6.176"
DiffEqDevTools = "2.44.4"
FiniteDiff = "2.27"
MuladdMacro = "0.2"
DifferentiationInterface = "0.6.54, 0.7"
Enzyme = "0.13"
FastBroadcast = "0.3"
FiniteDiff = "2.27"
ForwardDiff = "0.10.38, 1"
JET = "0.9.18, 0.10.4"
LinearAlgebra = "1.10"
LinearSolve = "3.26"
MacroTools = "0.5"
MuladdMacro = "0.2"
ODEProblemLibrary = "0.1.8"
OrdinaryDiffEqCore = "1.29.0"
OrdinaryDiffEqDifferentiation = "1.12.0"
OrdinaryDiffEqNonlinearSolve = "1.13.0"
Polyester = "0.7"
PrecompileTools = "1.2"
LinearAlgebra = "1.10"
OrdinaryDiffEqDifferentiation = "1.12.0"
SciMLBase = "2.99"
OrdinaryDiffEqCore = "1.29.0"
Static = "1.2"
Aqua = "0.8.11"
Preferences = "1.4"
Enzyme = "0.13"
MacroTools = "0.5"
julia = "1.10"
JET = "0.9.18, 0.10.4"
ADTypes = "1.16"
Random = "<0.0.1, 1"
RecursiveArrayTools = "3.36"
ODEProblemLibrary = "0.1.8"
OrdinaryDiffEqNonlinearSolve = "1.13.0"
AllocCheck = "0.2"
DiffEqBase = "6.176"
Reexport = "1.2"
SafeTestsets = "0.1.0"
SciMLBase = "2.120.0"
Static = "1.2"
Test = "<0.0.1, 1"
julia = "1.10"

[extras]
AllocCheck = "9b6a8646-10ed-4001-bbdc-1d2f46dfbb1a"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
DiffEqDevTools = "f3b72e0c-5b89-59e1-b016-84e28bfd966d"
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
ODEProblemLibrary = "fdc4e326-1af4-4b90-96e7-779fcce2daa5"
OrdinaryDiffEqNonlinearSolve = "127b3ac7-2247-4354-8eb6-78cf4e7c58e8"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["DiffEqDevTools", "Random", "OrdinaryDiffEqNonlinearSolve", "SafeTestsets", "Test", "ODEProblemLibrary", "Enzyme", "JET", "Aqua", "AllocCheck"]

[sources.OrdinaryDiffEqDifferentiation]
path = "../OrdinaryDiffEqDifferentiation"

[sources.OrdinaryDiffEqCore]
path = "../OrdinaryDiffEqCore"
11 changes: 4 additions & 7 deletions lib/OrdinaryDiffEqRosenbrock/src/generic_rosenbrock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function gen_algcache(cacheexpr::Expr,constcachename::Symbol,algname::Symbol,tab
function alg_cache(alg::$algname,u,rate_prototype,uEltypeNoUnits,uBottomEltypeNoUnits,tTypeNoUnits,uprev,uprev2,f,t,dt,reltol,p,calck,::Val{false})
tf = TimeDerivativeWrapper(f,u,p)
uf = UDerivativeWrapper(f,t,p)
J,W = build_J_W(alg,u,uprev,p,t,dt,f, nothing, uEltypeNoUnits,Val(false))
J,W = build_J_W(alg,u,uprev,p,t,dt,f,nothing, uEltypeNoUnits,Val(false))
$constcachename(tf,uf,$tabname(constvalue(uBottomEltypeNoUnits),constvalue(tTypeNoUnits)),J,W,nothing)
end
function alg_cache(alg::$algname,u,rate_prototype,uEltypeNoUnits,uBottomEltypeNoUnits,tTypeNoUnits,uprev,uprev2,f,t,dt,reltol,p,calck,::Val{true})
Expand All @@ -238,6 +238,7 @@ function gen_algcache(cacheexpr::Expr,constcachename::Symbol,algname::Symbol,tab
fsalfirst = zero(rate_prototype)
fsallast = zero(rate_prototype)
dT = zero(rate_prototype)

tmp = zero(rate_prototype)
atmp = similar(u, uEltypeNoUnits)
weight = similar(u, uEltypeNoUnits)
Expand All @@ -250,11 +251,8 @@ function gen_algcache(cacheexpr::Expr,constcachename::Symbol,algname::Symbol,tab
grad_config = build_grad_config(alg,f,tf,du1,t)
jac_config = build_jac_config(alg,f,uf,du1,uprev,u,tmp,du2)
J, W = build_J_W(alg, u, uprev, p, t, dt, f, jac_config, uEltypeNoUnits, Val(true))

linprob = LinearProblem(W,_vec(linsolve_tmp); u0=_vec(tmp))
linsolve = init(linprob,alg.linsolve,alias = LinearAliasSpecifier(alias_A=true,alias_b=true),
Pl = LinearSolve.InvPreconditioner(Diagonal(_vec(weight))),
Pr = Diagonal(_vec(weight)))
linprob = LinearProblem(W,_vec(linsolve_tmp), (nothing, u, p, t); u0=_vec(tmp))
linsolve = init(linprob, wrapprecs(alg, W, weight, u, p, t), alias = LinearAliasSpecifier(alias_A=true,alias_b=true))
$cachename($(valsyms...))
end
end
Expand Down Expand Up @@ -915,7 +913,6 @@ end




"""
@ROS2(part)

Expand Down
Loading
Loading