Skip to content

Commit

Permalink
Merge pull request #395 from SciML/myb/wfact_fix
Browse files Browse the repository at this point in the history
Fix Wfact(_t) calculation
  • Loading branch information
YingboMa authored May 25, 2020
2 parents 470610e + 910b6a4 commit ee79407
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ModelingToolkit"
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
authors = ["Chris Rackauckas <[email protected]>"]
version = "3.6.3"
version = "3.6.4"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
5 changes: 3 additions & 2 deletions src/systems/diffeqs/abstractodesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,17 @@ function calculate_factorized_W(sys::AbstractODESystem, simplify=true)
isempty(sys.Wfact[]) || return (sys.Wfact[],sys.Wfact_t[])

jac = calculate_jacobian(sys)
M = calculate_massmatrix(sys)
gam = Variable(:__MTKWgamma)()

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

if simplify
Wfact = ModelingToolkit.simplify.(Wfact)
end

W_t = - LinearAlgebra.I/gam + jac
W_t = - M/gam + jac
Wfact_t = lu(W_t, Val(false), check=false).factors
if simplify
Wfact_t = ModelingToolkit.simplify.(Wfact_t)
Expand Down
3 changes: 1 addition & 2 deletions test/odesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,8 @@ p = [k₁ => 0.04,
tspan = (0.0,100000.0)
prob1 = ODEProblem(sys,u0,tspan,p)
prob2 = ODEProblem(sys,u0,tspan,p,jac=true)
# Wfact version is not very stable because of the lack of pivoting
prob3 = ODEProblem(sys,u0,tspan,p,Wfact=true,Wfact_t=true)
for (prob, atol) in [(prob1, 1e-12), (prob2, 1e-12), (prob3, 0.1)]
for (prob, atol) in [(prob1, 1e-12), (prob2, 1e-12), (prob3, 1e-12)]
sol = solve(prob, Rodas5())
@test all(x->(sum(x), 1.0, atol=atol), sol.u)
end

2 comments on commit ee79407

@YingboMa
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/15331

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v3.6.4 -m "<description of version>" ee794078f8c33916b597454399c296da02b65dcb
git push origin v3.6.4

Please sign in to comment.