Skip to content

Commit b3da813

Browse files
committed
up
1 parent d95e4a7 commit b3da813

File tree

1 file changed

+23
-41
lines changed

1 file changed

+23
-41
lines changed

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 23 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,17 @@ function DiffEqBase.ODEFunction{iip, specialize}(sys::AbstractODESystem,
469469
initializeprobpmap = initializeprobpmap)
470470
end
471471

472+
"""
473+
```julia
474+
SciMLBase.BVPFunction{iip}(sys::AbstractODESystem, u0map, tspan,
475+
parammap = DiffEqBase.NullParameters();
476+
version = nothing, tgrad = false,
477+
jac = true, sparse = true,
478+
simplify = false,
479+
kwargs...) where {iip}
480+
```
481+
"""
482+
472483
"""
473484
```julia
474485
SciMLBase.BVProblem{iip}(sys::AbstractODESystem, u0map, tspan,
@@ -481,7 +492,7 @@ SciMLBase.BVProblem{iip}(sys::AbstractODESystem, u0map, tspan,
481492
482493
Create a `BVProblem` from the [`ODESystem`](@ref). The arguments `dvs` and
483494
`ps` are used to set the order of the dependent variable and parameter vectors,
484-
respectively.
495+
respectively. `u0` should be either the initial condition, a vector of values `u(t_i)` for collocation methods, or a function returning one or the other.
485496
"""
486497
function SciMLBase.BVProblem(sys::AbstractODESystem, args...; kwargs...)
487498
BVProblem{true}(sys, args...; kwargs...)
@@ -502,12 +513,13 @@ function SciMLBase.BVProblem{false}(sys::AbstractODESystem, args...; kwargs...)
502513
BVProblem{false, SciMLBase.FullSpecialize}(sys, args...; kwargs...)
503514
end
504515

516+
# figure out what's going on when we try to set `sparse`?
517+
505518
function SciMLBase.BVProblem{iip, specialize}(sys::AbstractODESystem, u0map = [],
506519
tspan = get_tspan(sys),
507520
parammap = DiffEqBase.NullParameters();
508521
version = nothing, tgrad = false,
509522
jac = true, sparse = true,
510-
sparsity = true,
511523
callback = nothing,
512524
check_length = true,
513525
warn_initialize_determined = true,
@@ -521,57 +533,27 @@ function SciMLBase.BVProblem{iip, specialize}(sys::AbstractODESystem, u0map = []
521533

522534
f, u0, p = process_SciMLProblem(ODEFunction{iip, specialize}, sys, u0map, parammap;
523535
t = tspan !== nothing ? tspan[1] : tspan,
524-
check_length, warn_initialize_determined, eval_expression, eval_module, jac, sparse, sparsity, kwargs...)
525-
526-
# if jac
527-
# jac_gen = generate_jacobian(sys, dvs, ps;
528-
# simplify = simplify, sparse = sparse,
529-
# expression = Val{true},
530-
# expression_module = eval_module,
531-
# checkbounds = checkbounds, kwargs...)
532-
# jac_oop, jac_iip = eval_or_rgf.(jac_gen; eval_expression, eval_module)
533-
534-
# _jac(u, p, t) = jac_oop(u, p, t)
535-
# _jac(J, u, p, t) = jac_iip(J, u, p, t)
536-
# _jac(u, p::Tuple{Vararg{Number}}, t) = jac_oop(u, p, t)
537-
# _jac(J, u, p::Tuple{Vararg{Number}}, t) = jac_iip(J, u, p, t)
538-
# _jac(u, p::Tuple, t) = jac_oop(u, p..., t)
539-
# _jac(J, u, p::Tuple, t) = jac_iip(J, u, p..., t)
540-
# _jac(u, p::MTKParameters, t) = jac_oop(u, p..., t)
541-
# _jac(J, u, p::MTKParameters, t) = jac_iip(J, u, p..., t)
542-
# else
543-
# _jac = nothing
544-
# end
545-
546-
# jac_prototype = if sparse
547-
# uElType = u0 === nothing ? Float64 : eltype(u0)
548-
# if jac
549-
# similar(calculate_jacobian(sys, sparse = sparse), uElType)
550-
# else
551-
# similar(jacobian_sparsity(sys), uElType)
552-
# end
553-
# else
554-
# nothing
555-
# end
556-
557-
# f.jac = _jac
558-
# f.jac_prototype = jac_prototype
559-
# f.sparsity = jac ? jacobian_sparsity(sys) : nothing
536+
check_length, warn_initialize_determined, eval_expression, eval_module, jac, kwargs...)
560537

561538
cbs = process_events(sys; callback, eval_expression, eval_module, kwargs...)
562-
563539
kwargs = filter_kwargs(kwargs)
564540

565541
kwargs1 = (;)
566542
if cbs !== nothing
567543
kwargs1 = merge(kwargs1, (callback = cbs,))
568544
end
545+
546+
# Construct initial conditions
547+
_u0 = prepare_initial_state(u0)
548+
__u0 = if _u0 isa Function
549+
_u0(t_i)
550+
end
569551

570552
# Define the boundary conditions
571553
bc = if iip
572-
(residual, u, p, t) -> (residual = u[1] - u0)
554+
(residual, u, p, t) -> (residual = u[1] - __u0)
573555
else
574-
(u, p, t) -> (u[1] - u0)
556+
(u, p, t) -> (u[1] - __u0)
575557
end
576558

577559
return BVProblem{iip}(f, bc, u0, tspan, p; kwargs1..., kwargs...)

0 commit comments

Comments
 (0)