Skip to content

Commit ee79407

Browse files
authored
Merge pull request #395 from SciML/myb/wfact_fix
Fix Wfact(_t) calculation
2 parents 470610e + 910b6a4 commit ee79407

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ModelingToolkit"
22
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
33
authors = ["Chris Rackauckas <[email protected]>"]
4-
version = "3.6.3"
4+
version = "3.6.4"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,17 @@ function calculate_factorized_W(sys::AbstractODESystem, simplify=true)
6363
isempty(sys.Wfact[]) || return (sys.Wfact[],sys.Wfact_t[])
6464

6565
jac = calculate_jacobian(sys)
66+
M = calculate_massmatrix(sys)
6667
gam = Variable(:__MTKWgamma)()
6768

68-
W = - LinearAlgebra.I + gam*jac
69+
W = - M + gam*jac
6970
Wfact = lu(W, Val(false), check=false).factors
7071

7172
if simplify
7273
Wfact = ModelingToolkit.simplify.(Wfact)
7374
end
7475

75-
W_t = - LinearAlgebra.I/gam + jac
76+
W_t = - M/gam + jac
7677
Wfact_t = lu(W_t, Val(false), check=false).factors
7778
if simplify
7879
Wfact_t = ModelingToolkit.simplify.(Wfact_t)

test/odesystem.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,8 @@ p = [k₁ => 0.04,
212212
tspan = (0.0,100000.0)
213213
prob1 = ODEProblem(sys,u0,tspan,p)
214214
prob2 = ODEProblem(sys,u0,tspan,p,jac=true)
215-
# Wfact version is not very stable because of the lack of pivoting
216215
prob3 = ODEProblem(sys,u0,tspan,p,Wfact=true,Wfact_t=true)
217-
for (prob, atol) in [(prob1, 1e-12), (prob2, 1e-12), (prob3, 0.1)]
216+
for (prob, atol) in [(prob1, 1e-12), (prob2, 1e-12), (prob3, 1e-12)]
218217
sol = solve(prob, Rodas5())
219218
@test all(x->(sum(x), 1.0, atol=atol), sol.u)
220219
end

0 commit comments

Comments
 (0)