|
| 1 | +@testitem "Linear systems" begin |
| 2 | + using BoundaryValueDiffEq |
| 3 | + using OptimizationMOI, Ipopt |
| 4 | +end |
| 5 | + |
| 6 | +@testitem "Rocket launch" begin |
| 7 | + using BoundaryValueDiffEq |
| 8 | + using OptimizationMOI, Ipopt |
| 9 | + |
| 10 | + tspan = (0.0, pi / 2) |
| 11 | + function simplependulum!(du, u, p, t) |
| 12 | + θ = u[1] |
| 13 | + dθ = u[2] |
| 14 | + du[1] = dθ |
| 15 | + du[2] = -9.81 * sin(θ) |
| 16 | + end |
| 17 | + function bc!(residual, u, p, t) |
| 18 | + residual[1] = u(pi / 4)[1] + big(pi / 2) |
| 19 | + residual[2] = u(pi / 2)[1] - big(pi / 2) |
| 20 | + end |
| 21 | + u0 = BigFloat.([pi / 2, pi / 2]) |
| 22 | + multi_point_bvp = BVProblem(simplependulum!, bc!, u0, tspan) |
| 23 | + |
| 24 | + @testset "BigFloat compatibility with Multi-point BVP" begin |
| 25 | + for solver in [MIRK4(), RadauIIa5(), LobattoIIIa4(nested_nlsolve = true)] |
| 26 | + sol = solve(multi_point_bvp, solver, dt = 0.05) |
| 27 | + @test SciMLBase.successful_retcode(sol.retcode) |
| 28 | + end |
| 29 | + end |
| 30 | + |
| 31 | + function f!(du, u, p, t) |
| 32 | + du[1] = u[2] |
| 33 | + du[2] = u[1] |
| 34 | + end |
| 35 | + function bca!(resid_a, u_a, p) |
| 36 | + resid_a[1] = u_a[1] - 1 |
| 37 | + end |
| 38 | + function bcb!(resid_b, u_b, p) |
| 39 | + resid_b[1] = u_b[1] |
| 40 | + end |
| 41 | + bvp_function = BVPFunction(f!, (bca!, bcb!), bcresid_prototype = (zeros(1), zeros(1)), twopoint = Val(true)) |
| 42 | + tspan = (0.0, 1.0) |
| 43 | + two_point_bvp = BVProblem(bvp_function, BigFloat.([1.0, 0.0]), tspan) |
| 44 | + |
| 45 | + @testset "BigFloat compatibility with Two-point BVP" begin |
| 46 | + for solver in [MIRK4(), RadauIIa5(), LobattoIIIa4(nested_nlsolve = true)] |
| 47 | + sol = solve(two_point_bvp, solver, dt = 0.05) |
| 48 | + @test SciMLBase.successful_retcode(sol.retcode) |
| 49 | + end |
| 50 | + end |
| 51 | + |
| 52 | + function second_f!(ddu, du, u, p, t) |
| 53 | + ϵ = 0.1 |
| 54 | + ddu[1] = u[2] |
| 55 | + ddu[2] = (-u[1] * du[2] - u[3] * du[3]) / ϵ |
| 56 | + ddu[3] = (du[1] * u[3] - u[1] * du[3]) / ϵ |
| 57 | + end |
| 58 | + function second_bc!(res, du, u, p, t) |
| 59 | + res[1] = u(0.0)[1] |
| 60 | + res[2] = u(1.0)[1] |
| 61 | + res[3] = u(0.0)[3] + 1 |
| 62 | + res[4] = u(1.0)[3] - 1 |
| 63 | + res[5] = du(0.0)[1] |
| 64 | + res[6] = du(1.0)[1] |
| 65 | + end |
| 66 | + u0 = BigFloat.([1.0, 1.0, 1.0]) |
| 67 | + tspan = (0.0, 1.0) |
| 68 | + prob = SecondOrderBVProblem(second_f!, second_bc!, u0, tspan) |
| 69 | + @test_broken sol4 = solve(prob, MIRKN4(), dt = 0.01) |
| 70 | + @test_broken SciMLBase.successful_retcode(sol4.retcode) |
| 71 | +end |
0 commit comments