Skip to content

Commit

Permalink
Update core_tests.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas authored Nov 15, 2024
1 parent d737b84 commit bf3c193
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/SCCNonlinearSolve/test/core_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,38 @@ end
sol = solve(prob, NewtonRaphson())

u0 = zeros(2)
cache = zeros(3)
p = zeros(3)

function f1(du, u, (cache, p))
du[1] = cos(u[2]) - u[1]
du[2] = sin(u[1] + u[2]) + u[2]
end
explicitfun1(cache, sols) = nothing
prob1 = NonlinearProblem(
NonlinearFunction{true, SciMLBase.NoSpecialize}(f1), zeros(2), cache)
NonlinearFunction{true, SciMLBase.NoSpecialize}(f1), zeros(2), p)
sol1 = solve(prob1, NewtonRaphson())

function f2(du, u, (cache, p))
function f2(du, u, p)
du[1] = 2u[2] + u[1] + 1.0
du[2] = u[3]^2 + u[2]
du[3] = u[1]^2 + u[3]
end
explicitfun2(cache, sols) = nothing
prob2 = NonlinearProblem(
NonlinearFunction{true, SciMLBase.NoSpecialize}(f2), zeros(3), cache)
NonlinearFunction{true, SciMLBase.NoSpecialize}(f2), zeros(3), p)
sol2 = solve(prob2, NewtonRaphson())

function f3(du, u, (cache, p))
du[1] = cache[1] + 2.0u[1] + 2.5u[2] + 1.5u[3]
du[2] = cache[2] + 4.0u[1] - 1.5u[2] + 1.5u[3]
du[3] = cache[3] + +u[1] - u[2] - u[3]
function f3(du, u, p)
du[1] = p[1] + 2.0u[1] + 2.5u[2] + 1.5u[3]
du[2] = p[2] + 4.0u[1] - 1.5u[2] + 1.5u[3]
du[3] = p[3] + +u[1] - u[2] - u[3]
end
prob3 = NonlinearProblem(
NonlinearFunction{true, SciMLBase.NoSpecialize}(f3), zeros(3), cache)
function explicitfun3(cache, sols)
cache[1] = sols[1][1] + sols[1][2] + sols[2][1] + sols[2][2] + sols[2][3]
cache[2] = sols[1][1] + sols[1][2] + sols[2][1] + 2.0sols[2][2] + sols[2][3]
cache[3] = sols[1][1] + 2.0sols[1][2] + 3.0sols[2][1] + 5.0sols[2][2] +
NonlinearFunction{true, SciMLBase.NoSpecialize}(f3), zeros(3), p)
function explicitfun3(p, sols)
p[1] = sols[1][1] + sols[1][2] + sols[2][1] + sols[2][2] + sols[2][3]
p[2] = sols[1][1] + sols[1][2] + sols[2][1] + 2.0sols[2][2] + sols[2][3]
p[3] = sols[1][1] + 2.0sols[1][2] + 3.0sols[2][1] + 5.0sols[2][2] +
6.0sols[2][3]
end
explicitfun3(cache, [sol1, sol2])
Expand Down

0 comments on commit bf3c193

Please sign in to comment.