My experience with BVProblem is becoming kaftaesque. I hope I’m just missing something.
My previous discourse 125374 on another aspect of the problem did not produce a solution.
So I investigated further, simplifying the example even more… Now it seems as if this
BVProblem code may never have worked. I note that many of its benchmarks on the web
have 404 links to the source code, and the “reference” links mention only 3 other languages,
not including Julia. So might BVProblem be just a place-holder during work-in progress?
I suspect my problem really needs the boundary conditions specified over various points
distributed over the tspan, and BVProblem with a FIRK solver seems like the only choice.
The only FIRK solver for Julia that I can find is RadauIIA5, which has performed well for others, but who knows if the version that was ported to Julia has been checked out?
Many other FIRK solvers are said to be included in the NSDERungeKutta package, which I installed only to see this:
Failed to precompile NSDERungeKutta [3978d399-9848-4322-9a48-ca26b732c7dc] to "/Users/andy 1/.julia/compiled/v1.11/NSDERungeKutta/jl_kXY7PR".
ERROR: LoadError: UndefVarError: `AbstractInitialValueSolver` not defined in `NSDERungeKutta`
~/Applications/Julia/NSDERungeKutta.jl-master/src/abstract.jl:1
but this AbstractInitialValueSolver
appears to be totally unknown to google.
Any suggestions? <<<<<<<<
So here’s my simplified yet diversified example from Kafka:
using BoundaryValueDiffEq, StaticArrays, LinearAlgebra, ArgCheck
function f!(dy_dt, y, par, t) ! Calculate derivatives
# It seems that t is not a vector.
# (A vector might be expected only for an "orthogonal collocation method".)
y1, y2 = y
par1, par2 = par
# Sign ambiguity of sqrt() should force use of boundary conditions, but nope...
dy_dt[1] = 2*y2 + sqrt(t*par1)
dy_dt[2] = 3*y1 - sqrt(t/par2)
dy_dt
end
function initialGuess(t)
# And here, t might be expected to be a vector (if it could be called without complaints).
# It seems necessary here to have access to parameters in par, as in bc! function.
# But the arguments of this function appear to be undocumented.
# A clue about work-in-progress?
guess1 = t.*2
guess2 = t.*3
(guess1, guess2)
end
function bc!(resid, y, par, t) # Boundary conditions
# And here, one might expect t to be a vector? Why not?
# The documentation says we can constrain the entire tspan.
# But bc never gets called! At least its arguments are documented.
# Someone wrote y[1,i] & y[2,i] can be expected to have been evaluated at t[i]
@argcheck 0>1 # Do we ever hit this tripwire? Nope. No matter what I do.
println("Argument t: type = $(typeof(t) ); length = $(length(t)) ; value = $(t)")
par1, par2 = par
resid[1] = abs(y[1,1] - par1)
resid[2] = abs(y[2,end] - par2)
end
tspan = (0.0, 50.0)
par = (1.0, 2.0)
# bvp = BVProblem(f!, bc!, initialGuess, tspan, par)
# Fails: can't "iterate" the function initialGuess. See discourse 125374.
# For this next work-around attempt with fixed numerical initGuess, I had to assume that
# the solver could accept the entire span to be covered by bc, but in my own uniform steps.
t1, t2 = tspan
initGuess = initialGuess([t for t = t1:0.1:t2])
# But nope...
# bvp = BVProblem(f!, bc!, initGuess, tspan, par)
# Fails -- can't zero(wrongType) for bc=[2,:] matrix,
# just like discourse 40395 -- with very nice discussion there, but I don't see
# how static arrays can work if dynamic grid refinement may be needed...
# ... or fails on bad state type as a 2-tuple of vectors
# ERROR: LoadError: Tuple type used as a state.
# Since a tuple does not have vector properties,
# it will not work as a state type in equation solvers.
# But if the problem is stripped down to useless...
bvp = BVProblem(f!, bc!, [1.0, 2.0], tspan, par)
# Reports "success", producing some nonzero result, but UNinfluenced by bc
# bvp = BVProblem(f!, bc!, nothing, tspan, par)
# Reports "success", producing "nothing"s, only at ends of tspan, incompatible with bc
sol = solve(bvp, RadauIIA5(); abstol=1e-2, reltol=1e-2)
The imbedded comments indicate the options tried (and failed or succeeded insignificantly).
So next I will try other FIRK solvers if they emerge.
Or if anyone know of other problem types allowing distributed boundary conditions,
please let me know.
thanks
Andy