Skip to content

Use JuliaFormatter v2 #339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/pages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

pages = ["index.md",
"Getting Started with BVP solving in Julia" => "tutorials/getting_started.md",
"Tutorials" => Any[
"tutorials/continuation.md", "tutorials/solve_nlls_bvp.md", "tutorials/extremum.md"],
"Tutorials" => Any["tutorials/continuation.md",
"tutorials/solve_nlls_bvp.md", "tutorials/extremum.md"],
"Basics" => Any["basics/bvp_problem.md", "basics/bvp_functions.md",
"basics/solve.md", "basics/autodiff.md", "basics/error_control.md"],
"Solver Summaries and Recommendations" => Any[
Expand Down
15 changes: 11 additions & 4 deletions ext/BoundaryValueDiffEqODEInterfaceExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,17 @@ function SciMLBase.__solve(prob::BVProblem, alg::BVPM2; dt = 0.0, reltol = 1e-3,
@closure (t, u, du) -> du .= vec(prob.f(reshape(u, u0_size), prob.p, t))
end
bvp2m_bc = if SciMLBase.isinplace(prob)
@closure (ya, yb, bca, bcb) -> begin
@closure (ya,
yb,
bca,
bcb) -> begin
prob.f.bc[1](reshape(bca, left_bc_size), reshape(ya, u0_size), prob.p)
prob.f.bc[2](reshape(bcb, right_bc_size), reshape(yb, u0_size), prob.p)
return nothing
end
else
@closure (ya, yb, bca, bcb) -> begin
@closure (
ya, yb, bca, bcb) -> begin
bca .= vec(prob.f.bc[1](reshape(ya, u0_size), prob.p))
bcb .= vec(prob.f.bc[2](reshape(yb, u0_size), prob.p))
return nothing
Expand Down Expand Up @@ -140,15 +144,18 @@ function SciMLBase.__solve(prob::BVProblem, alg::BVPSOL; maxiters = 1000,
end

bvpsol_bc = if SciMLBase.isinplace(prob)
@closure (ya, yb, r) -> begin
@closure (ya, yb,
r) -> begin
left_bc = reshape(@view(r[1:no_left_bc]), left_bc_size)
right_bc = reshape(@view(r[(no_left_bc + 1):end]), right_bc_size)
prob.f.bc[1](left_bc, reshape(ya, u0_size), prob.p)
prob.f.bc[2](right_bc, reshape(yb, u0_size), prob.p)
return nothing
end
else
@closure (ya, yb, r) -> begin
@closure (ya,
yb,
r) -> begin
r[1:no_left_bc] .= vec(prob.f.bc[1](reshape(ya, u0_size), prob.p))
r[(no_left_bc + 1):end] .= vec(prob.f.bc[2](reshape(yb, u0_size), prob.p))
return nothing
Expand Down
6 changes: 2 additions & 4 deletions lib/BoundaryValueDiffEqAscher/src/adaptivity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,13 @@ function error_estimate!(cache::AscherCache)
# in valstr in case they prove to be needed later for an error estimate.
x = mesh[i] + (mesh_dt[i]) * 2.0 / 3.0
@views approx(cache, x, valstr[i][3])
error[i] .= wgterr .*
abs.(valstr[i][3] .-
error[i] .= wgterr .* abs.(valstr[i][3] .-
(isodd(i) ? valstr[Int((i + 1) / 2)][2] : valstr[Int(i / 2)][4]))

x = mesh[i] + (mesh_dt[i]) / 3.0
@views approx(cache, x, valstr[i][2])
error[i] .= error[i] .+
wgterr .*
abs.(valstr[i][2] .-
wgterr .* abs.(valstr[i][2] .-
(isodd(i) ? valstr[Int((i + 1) / 2)][1] : valstr[Int(i / 2)][3]))
end
return maximum(reduce(hcat, error), dims = 2)
Expand Down
10 changes: 6 additions & 4 deletions lib/BoundaryValueDiffEqAscher/src/ascher.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ function SciMLBase.__init(

iip = isinplace(prob)

f, bc = if prob.u0 isa AbstractVector
f,
bc = if prob.u0 isa AbstractVector
prob.f, prob.f.bc
elseif iip
vecf! = @closure (du, u, p, t) -> __vec_f!(du, u, p, t, prob.f, size(u0))
Expand Down Expand Up @@ -337,10 +338,11 @@ function __construct_nlproblem(cache::AscherCache{iip, T}) where {iip, T}
end

jac = if iip
@closure (J, u, p) -> __ascher_mpoint_jacobian!(
J, u, diffmode, jac_cache, loss, lz, cache.p)
@closure (J, u,
p) -> __ascher_mpoint_jacobian!(J, u, diffmode, jac_cache, loss, lz, cache.p)
else
@closure (u, p) -> __ascher_mpoint_jacobian(
@closure (u,
p) -> __ascher_mpoint_jacobian(
jac_prototype, u, diffmode, jac_cache, loss, cache.p)
end

Expand Down
12 changes: 8 additions & 4 deletions lib/BoundaryValueDiffEqAscher/src/collocation.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function Φ!(cache::AscherCache{iip, T}, z, res, pt::StandardBVProblem) where {iip, T}
(; f, mesh, mesh_dt, ncomp, ny, bc, k, p, zeta, residual, zval, yval, gval, delz, dmz, deldmz, g, w, v, ipvtg, ipvtw, TU) = cache
(; f, mesh, mesh_dt, ncomp, ny, bc, k, p, zeta, residual, zval,
yval, gval, delz, dmz, deldmz, g, w, v, ipvtg, ipvtw, TU) = cache
(; acol, rho) = TU
ncy = ncomp + ny
n = length(mesh) - 1
Expand Down Expand Up @@ -156,7 +157,8 @@ function Φ!(cache::AscherCache{iip, T}, z, res, pt::StandardBVProblem) where {i
end

function Φ!(cache::AscherCache{iip, T}, z, res, pt::TwoPointBVProblem) where {iip, T}
(; f, mesh, mesh_dt, ncomp, ny, bc, k, p, zeta, bcresid_prototype, residual, zval, yval, gval, delz, dmz, deldmz, g, w, v, dmzo, ipvtg, ipvtw, TU) = cache
(; f, mesh, mesh_dt, ncomp, ny, bc, k, p, zeta, bcresid_prototype, residual,
zval, yval, gval, delz, dmz, deldmz, g, w, v, dmzo, ipvtg, ipvtw, TU) = cache
(; acol, rho) = TU
ncy = ncomp + ny
n = length(mesh) - 1
Expand Down Expand Up @@ -319,7 +321,8 @@ end
@inline __get_value(z) = isa(z, ForwardDiff.Dual) ? z.value : z

function Φ(cache::AscherCache{iip, T}, z, pt::StandardBVProblem) where {iip, T}
(; f, mesh, mesh_dt, ncomp, ny, bc, k, p, zeta, residual, zval, yval, gval, delz, dmz, deldmz, g, w, v, dmzo, ipvtg, ipvtw, TU) = cache
(; f, mesh, mesh_dt, ncomp, ny, bc, k, p, zeta, residual, zval, yval,
gval, delz, dmz, deldmz, g, w, v, dmzo, ipvtg, ipvtw, TU) = cache
(; acol, rho) = TU
ncy = ncomp + ny
n = length(mesh) - 1
Expand Down Expand Up @@ -476,7 +479,8 @@ function Φ(cache::AscherCache{iip, T}, z, pt::StandardBVProblem) where {iip, T}
end

function Φ(cache::AscherCache{iip, T}, z, pt::TwoPointBVProblem) where {iip, T}
(; f, mesh, mesh_dt, ncomp, ny, bc, k, p, zeta, residual, zval, yval, gval, delz, dmz, deldmz, g, w, v, dmzo, ipvtg, ipvtw, TU) = cache
(; f, mesh, mesh_dt, ncomp, ny, bc, k, p, zeta, residual, zval, yval,
gval, delz, dmz, deldmz, g, w, v, dmzo, ipvtg, ipvtw, TU) = cache
(; acol, rho) = TU
ncy = ncomp + ny
n = length(mesh) - 1
Expand Down
3 changes: 2 additions & 1 deletion lib/BoundaryValueDiffEqCore/src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
end

@inline __materialize_jacobian_algorithm(_, alg::BVPJacobianAlgorithm) = alg
@inline __materialize_jacobian_algorithm(_, alg::ADTypes.AbstractADType) = BVPJacobianAlgorithm(alg)
@inline __materialize_jacobian_algorithm(
_, alg::ADTypes.AbstractADType) = BVPJacobianAlgorithm(alg)
@inline __materialize_jacobian_algorithm(::Nothing, ::Nothing) = BVPJacobianAlgorithm()
@inline function __materialize_jacobian_algorithm(nlsolve::N, ::Nothing) where {N}
ad = hasfield(N, :jacobian_ad) ? nlsolve.jacobian_ad : missing
Expand Down
9 changes: 9 additions & 0 deletions lib/BoundaryValueDiffEqFIRK/src/BoundaryValueDiffEqFIRK.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ include("sparse_jacobians.jl")

@compile_workload begin
@sync for prob in probs, alg in algs

Threads.@spawn solve(prob, alg; dt = 0.2)
end
end
Expand All @@ -112,6 +113,7 @@ include("sparse_jacobians.jl")

@compile_workload begin
@sync for prob in probs, alg in algs

Threads.@spawn solve(prob, alg; dt = 0.2)
end
end
Expand All @@ -124,6 +126,7 @@ include("sparse_jacobians.jl")

@compile_workload begin
@sync for prob in probs, alg in algs

Threads.@spawn solve(prob, alg; dt = 0.2)
end
end
Expand All @@ -136,6 +139,7 @@ include("sparse_jacobians.jl")

@compile_workload begin
@sync for prob in probs, alg in algs

Threads.@spawn solve(prob, alg; dt = 0.2)
end
end
Expand Down Expand Up @@ -194,6 +198,7 @@ include("sparse_jacobians.jl")

@compile_workload begin
@sync for prob in probs, alg in algs

Threads.@spawn solve(prob, alg; dt = 0.2, abstol = 1e-2)
end
end
Expand All @@ -210,6 +215,7 @@ include("sparse_jacobians.jl")

@compile_workload begin
@sync for prob in probs, alg in algs

Threads.@spawn solve(prob, alg; dt = 0.2, abstol = 1e-2)
end
end
Expand All @@ -226,6 +232,7 @@ include("sparse_jacobians.jl")

@compile_workload begin
@sync for prob in probs, alg in algs

Threads.@spawn solve(prob, alg; dt = 0.2, abstol = 1e-2)
end
end
Expand All @@ -242,6 +249,7 @@ include("sparse_jacobians.jl")

@compile_workload begin
@sync for prob in probs, alg in algs

Threads.@spawn solve(prob, alg; dt = 0.2, abstol = 1e-2)
end
end
Expand All @@ -258,6 +266,7 @@ include("sparse_jacobians.jl")

@compile_workload begin
@sync for prob in probs, alg in algs

Threads.@spawn solve(prob, alg; dt = 0.2, abstol = 1e-2)
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/BoundaryValueDiffEqFIRK/src/adaptivity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ function s_constraints(M, h)
row_start = (i - 1) * M + 1
for k in 0:(M - 1)
for j in 1:6
A[row_start + k, j + k * 6] = j == 1.0 ? 0.0 :
(j - 1) * t[i + k * 6]^(j - 2)
A[row_start + k,
j + k * 6] = j == 1.0 ? 0.0 : (j - 1) * t[i + k * 6]^(j - 2)
end
end
end
Expand Down
40 changes: 32 additions & 8 deletions lib/BoundaryValueDiffEqFIRK/src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,14 @@ for stage in (1, 2, 3, 5, 7)
defect_threshold::T = 0.1
max_num_subintervals::Int = 3000
end
$(alg)(nlsolve::N, jac_alg::J; nested = false, nested_nlsolve_kwargs::NamedTuple = (;), defect_threshold::T = 0.1, max_num_subintervals::Int = 3000) where {N, J, T} = $(alg){
N, J, T}(nlsolve, jac_alg, nested, nested_nlsolve_kwargs,
$(alg)(nlsolve::N,
jac_alg::J;
nested = false,
nested_nlsolve_kwargs::NamedTuple = (;),
defect_threshold::T = 0.1,
max_num_subintervals::Int = 3000) where {N,
J,
T} = $(alg){N, J, T}(nlsolve, jac_alg, nested, nested_nlsolve_kwargs,
defect_threshold, max_num_subintervals)
end
end
Expand Down Expand Up @@ -194,8 +200,14 @@ for stage in (2, 3, 4, 5)
defect_threshold::T = 0.1
max_num_subintervals::Int = 3000
end
$(alg)(nlsolve::N, jac_alg::J; nested = false, nested_nlsolve_kwargs::NamedTuple = (;), defect_threshold::T = 0.1, max_num_subintervals::Int = 3000) where {N, J, T} = $(alg){
N, J, T}(nlsolve, jac_alg, nested, nested_nlsolve_kwargs,
$(alg)(nlsolve::N,
jac_alg::J;
nested = false,
nested_nlsolve_kwargs::NamedTuple = (;),
defect_threshold::T = 0.1,
max_num_subintervals::Int = 3000) where {N,
J,
T} = $(alg){N, J, T}(nlsolve, jac_alg, nested, nested_nlsolve_kwargs,
defect_threshold, max_num_subintervals)
end
end
Expand Down Expand Up @@ -295,8 +307,14 @@ for stage in (2, 3, 4, 5)
defect_threshold::T = 0.1
max_num_subintervals::Int = 3000
end
$(alg)(nlsolve::N, jac_alg::J; nested = false, nested_nlsolve_kwargs::NamedTuple = (;), defect_threshold::T = 0.1, max_num_subintervals::Int = 3000) where {N, J, T} = $(alg){
N, J, T}(nlsolve, jac_alg, nested, nested_nlsolve_kwargs,
$(alg)(nlsolve::N,
jac_alg::J;
nested = false,
nested_nlsolve_kwargs::NamedTuple = (;),
defect_threshold::T = 0.1,
max_num_subintervals::Int = 3000) where {N,
J,
T} = $(alg){N, J, T}(nlsolve, jac_alg, nested, nested_nlsolve_kwargs,
defect_threshold, max_num_subintervals)
end
end
Expand Down Expand Up @@ -396,8 +414,14 @@ for stage in (2, 3, 4, 5)
defect_threshold::T = 0.1
max_num_subintervals::Int = 3000
end
$(alg)(nlsolve::N, jac_alg::J; nested = false, nested_nlsolve_kwargs::NamedTuple = (;), defect_threshold::T = 0.1, max_num_subintervals::Int = 3000) where {N, J, T} = $(alg){
N, J, T}(nlsolve, jac_alg, nested, nested_nlsolve_kwargs,
$(alg)(nlsolve::N,
jac_alg::J;
nested = false,
nested_nlsolve_kwargs::NamedTuple = (;),
defect_threshold::T = 0.1,
max_num_subintervals::Int = 3000) where {N,
J,
T} = $(alg){N, J, T}(nlsolve, jac_alg, nested, nested_nlsolve_kwargs,
defect_threshold, max_num_subintervals)
end
end
Expand Down
Loading
Loading