Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Jul 19, 2024
1 parent 5fe46e6 commit 7627ebb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/src/tutorials/initialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ long enough you will see that `λ = 0` is required for this equation, but since
`λ = 1` we end up with a set of equations that are impossible to satisfy.

!!! note

If you would prefer to have an error instead of a warning in the context of non-fully
determined systems, pass the keyword argument `fully_determined = true` into the
problem constructor. Additionally, any warning about not being fully determined can
Expand Down Expand Up @@ -278,7 +278,7 @@ sol = solve(iprob)
```

!!! note

For more information on solving NonlinearProblems and NonlinearLeastSquaresProblems,
check out the [NonlinearSolve.jl tutorials!](https://docs.sciml.ai/NonlinearSolve/stable/tutorials/getting_started/).

Expand Down
12 changes: 8 additions & 4 deletions test/initializationsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ sol = solve(initprob)
@test SciMLBase.successful_retcode(sol)
@test maximum(abs.(sol[conditions])) < 1e-14

@test_throws ModelingToolkit.ExtraVariablesSystemException ModelingToolkit.InitializationProblem(pend, 0.0, [], [g => 1];
@test_throws ModelingToolkit.ExtraVariablesSystemException ModelingToolkit.InitializationProblem(
pend, 0.0, [], [g => 1];
guesses = [ModelingToolkit.missing_variable_defaults(pend); x => 1; y => 0.2],
fully_determined = true)

Expand Down Expand Up @@ -55,7 +56,8 @@ sol = solve(prob.f.initializeprob)
sol = solve(prob, Rodas5P())
@test maximum(abs.(sol[conditions][1])) < 1e-14

@test_throws ModelingToolkit.ExtraVariablesSystemException ODEProblem(pend, [x => 1], (0.0, 1.5), [g => 1],
@test_throws ModelingToolkit.ExtraVariablesSystemException ODEProblem(
pend, [x => 1], (0.0, 1.5), [g => 1],
guesses = ModelingToolkit.missing_variable_defaults(pend),
fully_determined = true)

Expand Down Expand Up @@ -237,7 +239,8 @@ initsol = solve(initprob, reltol = 1e-12, abstol = 1e-12)
@test SciMLBase.successful_retcode(initsol)
@test maximum(abs.(initsol[conditions])) < 1e-14

@test_throws ModelingToolkit.ExtraEquationsSystemException ModelingToolkit.InitializationProblem(sys, 0.0, fully_determined = true)
@test_throws ModelingToolkit.ExtraEquationsSystemException ModelingToolkit.InitializationProblem(
sys, 0.0, fully_determined = true)

allinit = unknowns(sys) .=> initsol[unknowns(sys)]
prob = ODEProblem(sys, allinit, (0, 0.1))
Expand All @@ -249,7 +252,8 @@ sol = solve(prob, Rodas5P(), initializealg = BrownFullBasicInit())
prob = ODEProblem(sys, allinit, (0, 0.1))
prob = ODEProblem(sys, [], (0, 0.1), check = false)

@test_throws ModelingToolkit.ExtraEquationsSystemException ODEProblem(sys, [], (0, 0.1), fully_determined = true)
@test_throws ModelingToolkit.ExtraEquationsSystemException ODEProblem(
sys, [], (0, 0.1), fully_determined = true)

sol = solve(prob, Rodas5P())
# If initialized incorrectly, then it would be InitialFailure
Expand Down

0 comments on commit 7627ebb

Please sign in to comment.