-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #857 from AayushSabharwal/as/get-nlsolve
feat: add fields to `OverrideInit`, better `nlsolve_alg` handling
- Loading branch information
Showing
8 changed files
with
241 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,4 +85,4 @@ jobs: | |
with: | ||
file: lcov.info | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
fail_ci_if_error: true | ||
fail_ci_if_error: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,3 @@ struct ODE_NLProbData{NLProb, UNLProb, NLProbMap, NLProbPmap} | |
""" | ||
nlprobpmap::NLProbPmap | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using OrdinaryDiffEq, Sundials, SciMLBase, Test | ||
|
||
@testset "CheckInit" begin | ||
abstol = 1e-10 | ||
@testset "Sundials + ODEProblem" begin | ||
function rhs(u, p, t) | ||
return [u[1] * t, u[1]^2 - u[2]^2] | ||
end | ||
function rhs!(du, u, p, t) | ||
du[1] = u[1] * t | ||
du[2] = u[1]^2 - u[2]^2 | ||
end | ||
|
||
oopfn = ODEFunction{false}(rhs, mass_matrix = [1 0; 0 0]) | ||
iipfn = ODEFunction{true}(rhs!, mass_matrix = [1 0; 0 0]) | ||
|
||
@testset "Inplace = $(SciMLBase.isinplace(f))" for f in [oopfn, iipfn] | ||
prob = ODEProblem(f, [1.0, 1.0], (0.0, 1.0)) | ||
integ = init(prob, Sundials.ARKODE()) | ||
u0, _, success = SciMLBase.get_initial_values( | ||
prob, integ, f, SciMLBase.CheckInit(), Val(SciMLBase.isinplace(f)); abstol) | ||
@test success | ||
@test u0 == prob.u0 | ||
|
||
integ.u[2] = 2.0 | ||
@test_throws SciMLBase.CheckInitFailureError SciMLBase.get_initial_values( | ||
prob, integ, f, SciMLBase.CheckInit(), Val(SciMLBase.isinplace(f)); abstol) | ||
end | ||
end | ||
|
||
@testset "Sundials + DAEProblem" begin | ||
function daerhs(du, u, p, t) | ||
return [du[1] - u[1] * t - p, u[1]^2 - u[2]^2] | ||
end | ||
function daerhs!(resid, du, u, p, t) | ||
resid[1] = du[1] - u[1] * t - p | ||
resid[2] = u[1]^2 - u[2]^2 | ||
end | ||
|
||
oopfn = DAEFunction{false}(daerhs) | ||
iipfn = DAEFunction{true}(daerhs!) | ||
|
||
@testset "Inplace = $(SciMLBase.isinplace(f))" for f in [oopfn, iipfn] | ||
prob = DAEProblem(f, [1.0, 0.0], [1.0, 1.0], (0.0, 1.0), 1.0) | ||
integ = init(prob, Sundials.IDA()) | ||
u0, _, success = SciMLBase.get_initial_values( | ||
prob, integ, f, SciMLBase.CheckInit(), Val(SciMLBase.isinplace(f)); abstol) | ||
@test success | ||
@test u0 == prob.u0 | ||
|
||
integ.u[2] = 2.0 | ||
@test_throws SciMLBase.CheckInitFailureError SciMLBase.get_initial_values( | ||
prob, integ, f, SciMLBase.CheckInit(), Val(SciMLBase.isinplace(f)); abstol) | ||
|
||
integ.u[2] = 1.0 | ||
integ.du[1] = 2.0 | ||
@test_throws SciMLBase.CheckInitFailureError SciMLBase.get_initial_values( | ||
prob, integ, f, SciMLBase.CheckInit(), Val(SciMLBase.isinplace(f)); abstol) | ||
end | ||
end | ||
end |
Oops, something went wrong.