Skip to content

Commit c23a805

Browse files
committed
fix: documentation
1 parent 9bfa568 commit c23a805

File tree

6 files changed

+53
-51
lines changed

6 files changed

+53
-51
lines changed

.github/workflows/CI_NonlinearSolve.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
directories: src,ext,lib/SciMLJacobianOperators/src,lib/BracketingNonlinearSolve/src,lib/NonlinearSolveBase/src,lib/NonlinearSolveBase/ext,lib/SimpleNonlinearSolve/src,lib/NonlinearSolveFirstOrder/src,lib/NonlinearSolveSpectralMethods/src,lib/NonlinearSolveQuasiNewton/src
8686
- uses: codecov/codecov-action@v5
8787
with:
88-
file: lcov.info
88+
files: lcov.info
8989
token: ${{ secrets.CODECOV_TOKEN }}
9090
verbose: true
9191
fail_ci_if_error: false

.github/workflows/Documentation.yml

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,27 @@ on:
44
push:
55
branches:
66
- master
7-
- 'release-'
8-
tags: '*'
7+
- "release-"
8+
tags: ["*"]
99
pull_request:
1010

1111
jobs:
1212
build:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v4
16-
- uses: julia-actions/setup-julia@latest
16+
- uses: julia-actions/setup-julia@v2
1717
with:
18-
version: '1.10'
19-
- name: Install dependencies
20-
run: |
21-
import Pkg
22-
Pkg.Registry.update()
23-
# Install packages present in subdirectories
24-
dev_pks = Pkg.PackageSpec[]
25-
for path in ("lib/SciMLJacobianOperators", ".", "lib/SimpleNonlinearSolve", "lib/NonlinearSolveBase", "lib/BracketingNonlinearSolve", "lib/NonlinearSolveFirstOrder", "lib/NonlinearSolveQuasiNewton", "lib/NonlinearSolveSpectralMethods", "lib/NonlinearSolveHomotopyContinuation")
26-
push!(dev_pks, Pkg.PackageSpec(; path))
27-
end
28-
Pkg.develop(dev_pks)
29-
Pkg.instantiate()
30-
shell: julia --color=yes --project=docs/ {0}
31-
- name: Build and deploy
18+
version: "1"
19+
- uses: julia-actions/cache@v2
20+
- uses: julia-actions/julia-buildpkg@v1
21+
- uses: julia-actions/julia-docdeploy@v1
3222
env:
33-
JULIA_DEBUG: "Documenter"
34-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
35-
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key
36-
run: julia --project=docs/ --code-coverage=user --color=yes docs/make.jl
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
3725
- uses: julia-actions/julia-processcoverage@v1
3826
- uses: codecov/codecov-action@v5
3927
with:
40-
file: lcov.info
28+
files: lcov.info
4129
token: ${{ secrets.CODECOV_TOKEN }}
4230
fail_ci_if_error: false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ docs/src/assets/Project.toml
2626

2727
.vscode
2828
wip
29+
.CondaPkg

docs/Project.toml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
1111
DocumenterInterLinks = "d12716ef-a0f6-4df4-a9f1-a5a34e75c656"
1212
IncompleteLU = "40713840-3770-5561-ab4c-a76e7d0d7895"
1313
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
14-
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
1514
LineSearch = "87fe0de2-c867-4266-b59a-2f0a94fc965b"
15+
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
1616
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
1717
NonlinearSolveBase = "be0214bd-f91f-a760-ac4e-3421ce2b2da0"
1818
NonlinearSolveFirstOrder = "5959db7a-ea39-4486-b5fe-2dd0bf03d60d"
@@ -28,10 +28,23 @@ SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
2828
SciMLJacobianOperators = "19f34311-ddf3-4b8b-af20-060888a46c0e"
2929
SimpleNonlinearSolve = "727e6d20-b764-4bd8-a329-72de5adea6c7"
3030
SparseConnectivityTracer = "9f842d2f-2579-4b1d-911e-f412cf18a3f5"
31+
SparseMatrixColorings = "0a514795-09f3-496d-8182-132a7b665d35"
3132
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
3233
SteadyStateDiffEq = "9672c7b4-1e72-59bd-8a11-6ac3964bc41f"
3334
Sundials = "c3572dad-4567-51f8-b174-8c6c989267f4"
3435

36+
[sources]
37+
BracketingNonlinearSolve = {path = "../lib/BracketingNonlinearSolve"}
38+
NonlinearSolve = {path = ".."}
39+
NonlinearSolveBase = {path = "../lib/NonlinearSolveBase"}
40+
NonlinearSolveFirstOrder = {path = "../lib/NonlinearSolveFirstOrder"}
41+
NonlinearSolveHomotopyContinuation = {path = "../lib/NonlinearSolveHomotopyContinuation"}
42+
NonlinearSolveQuasiNewton = {path = "../lib/NonlinearSolveQuasiNewton"}
43+
NonlinearSolveSciPy = {path = "../lib/NonlinearSolveSciPy"}
44+
NonlinearSolveSpectralMethods = {path = "../lib/NonlinearSolveSpectralMethods"}
45+
SciMLJacobianOperators = {path = "../lib/SciMLJacobianOperators"}
46+
SimpleNonlinearSolve = {path = "../lib/SimpleNonlinearSolve"}
47+
3548
[compat]
3649
ADTypes = "1.9.0"
3750
AlgebraicMultigrid = "0.5, 0.6, 1"
@@ -45,8 +58,8 @@ DocumenterCitations = "1"
4558
DocumenterInterLinks = "1.0.0"
4659
IncompleteLU = "0.2"
4760
InteractiveUtils = "<0.0.1, 1"
48-
LinearSolve = "2, 3"
4961
LineSearch = "0.1"
62+
LinearSolve = "2, 3"
5063
NonlinearSolve = "4"
5164
NonlinearSolveBase = "1"
5265
NonlinearSolveFirstOrder = "1"

docs/src/tutorials/large_systems.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
This tutorial is for getting into the extra features of using NonlinearSolve.jl. Solving
44
ill-conditioned nonlinear systems requires specializing the linear solver on properties of
5-
the Jacobian in order to cut down on the ``\mathcal{O}(n^3)`` linear solve and the
6-
``\mathcal{O}(n^2)`` back-solves. This tutorial is designed to explain the advanced usage of
5+
the Jacobian in order to cut down on the `\mathcal{O}(n^3)` linear solve and the
6+
`\mathcal{O}(n^2)` back-solves. This tutorial is designed to explain the advanced usage of
77
NonlinearSolve.jl by solving the steady state stiff Brusselator partial differential
88
equation (BRUSS) using NonlinearSolve.jl.
99

1010
## Definition of the Brusselator Equation
1111

1212
!!! note
13-
13+
1414
Feel free to skip this section: it simply defines the example problem.
1515

1616
The Brusselator PDE is defined as follows:
@@ -123,38 +123,38 @@ However, if you know the sparsity of your problem, then you can pass a different
123123
type. For example, a `SparseMatrixCSC` will give a sparse matrix. Other sparse matrix types
124124
include:
125125

126-
- Bidiagonal
127-
- Tridiagonal
128-
- SymTridiagonal
129-
- BandedMatrix ([BandedMatrices.jl](https://github.com/JuliaLinearAlgebra/BandedMatrices.jl))
130-
- BlockBandedMatrix ([BlockBandedMatrices.jl](https://github.com/JuliaLinearAlgebra/BlockBandedMatrices.jl))
126+
- Bidiagonal
127+
- Tridiagonal
128+
- SymTridiagonal
129+
- BandedMatrix ([BandedMatrices.jl](https://github.com/JuliaLinearAlgebra/BandedMatrices.jl))
130+
- BlockBandedMatrix ([BlockBandedMatrices.jl](https://github.com/JuliaLinearAlgebra/BlockBandedMatrices.jl))
131131

132132
## Approximate Sparsity Detection & Sparse Jacobians
133133

134134
In the next section, we will show how to specify `sparsity` to trigger automatic sparsity
135135
detection.
136136

137137
```@example ill_conditioned_nlprob
138-
import BenchmarkTools # for @btime
138+
import BenchmarkTools: @btime # for @btime
139139
140-
BenchmarkTools.BenchmarkTools.@btime NLS.solve(prob_brusselator_2d, NLS.NewtonRaphson());
140+
@btime NLS.solve(prob_brusselator_2d, NLS.NewtonRaphson());
141141
nothing # hide
142142
```
143143

144144
```@example ill_conditioned_nlprob
145-
import SparseConnectivityTracer
145+
import SparseConnectivityTracer, SparseMatrixColorings
146146
147147
prob_brusselator_2d_autosparse = NLS.NonlinearProblem(
148148
NLS.NonlinearFunction(brusselator_2d_loop; sparsity = SparseConnectivityTracer.TracerSparsityDetector()),
149149
u0, p; abstol = 1e-10, reltol = 1e-10
150150
)
151151
152-
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d_autosparse,
152+
@btime NLS.solve(prob_brusselator_2d_autosparse,
153153
NLS.NewtonRaphson(; autodiff = ADTypes.AutoForwardDiff(; chunksize = 12)));
154-
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d_autosparse,
154+
@btime NLS.solve(prob_brusselator_2d_autosparse,
155155
NLS.NewtonRaphson(; autodiff = ADTypes.AutoForwardDiff(; chunksize = 12),
156156
linsolve = LS.KLUFactorization()));
157-
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d_autosparse,
157+
@btime NLS.solve(prob_brusselator_2d_autosparse,
158158
NLS.NewtonRaphson(; autodiff = ADTypes.AutoForwardDiff(; chunksize = 12),
159159
linsolve = LS.KrylovJL_GMRES()));
160160
nothing # hide
@@ -176,7 +176,7 @@ arguments, and it will kick out a sparse matrix with our pattern, that we can tu
176176
`jac_prototype`.
177177

178178
!!! tip
179-
179+
180180
External packages like `SparseConnectivityTracer.jl` and `Symbolics.jl` provide the
181181
actual implementation of sparsity detection.
182182

@@ -205,9 +205,9 @@ prob_brusselator_2d_sparse = NLS.NonlinearProblem(ff, u0, p; abstol = 1e-10, rel
205205
Now let's see how the version with sparsity compares to the version without:
206206

207207
```@example ill_conditioned_nlprob
208-
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d, NLS.NewtonRaphson());
209-
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d_sparse, NLS.NewtonRaphson());
210-
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d_sparse, NLS.NewtonRaphson(linsolve = LS.KLUFactorization()));
208+
@btime NLS.solve(prob_brusselator_2d, NLS.NewtonRaphson());
209+
@btime NLS.solve(prob_brusselator_2d_sparse, NLS.NewtonRaphson());
210+
@btime NLS.solve(prob_brusselator_2d_sparse, NLS.NewtonRaphson(linsolve = LS.KLUFactorization()));
211211
nothing # hide
212212
```
213213

@@ -223,7 +223,7 @@ Krylov method. To swap the linear solver out, we use the `linsolve` command and
223223
GMRES linear solver.
224224

225225
```@example ill_conditioned_nlprob
226-
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d, NLS.NewtonRaphson(linsolve = LS.KrylovJL_GMRES()));
226+
@btime NLS.solve(prob_brusselator_2d, NLS.NewtonRaphson(linsolve = LS.KrylovJL_GMRES()));
227227
nothing # hide
228228
```
229229

@@ -234,7 +234,7 @@ choices, see the
234234
`linsolve` choices are any valid [LinearSolve.jl](https://linearsolve.sciml.ai/dev/) solver.
235235

236236
!!! note
237-
237+
238238
Switching to a Krylov linear solver will automatically change the nonlinear problem
239239
solver into Jacobian-free mode, dramatically reducing the memory required. This can be
240240
overridden by adding `concrete_jac=true` to the algorithm.
@@ -254,7 +254,7 @@ import IncompleteLU
254254

255255
incompletelu(W, p = nothing) = IncompleteLU.ilu(W, τ = 50.0), LinearAlgebra.I
256256

257-
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d_sparse,
257+
@btime NLS.solve(prob_brusselator_2d_sparse,
258258
NLS.NewtonRaphson(linsolve = LS.KrylovJL_GMRES(precs = incompletelu), concrete_jac = true)
259259
);
260260
nothing # hide
@@ -284,7 +284,7 @@ function algebraicmultigrid(W, p = nothing)
284284
LinearAlgebra.I
285285
end
286286
287-
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d_sparse,
287+
@btime NLS.solve(prob_brusselator_2d_sparse,
288288
NLS.NewtonRaphson(
289289
linsolve = LS.KrylovJL_GMRES(; precs = algebraicmultigrid), concrete_jac = true
290290
)
@@ -304,7 +304,7 @@ function algebraicmultigrid2(W, p = nothing)
304304
return Pl, LinearAlgebra.I
305305
end
306306
307-
BenchmarkTools.@btime NLS.solve(
307+
@btime NLS.solve(
308308
prob_brusselator_2d_sparse,
309309
NLS.NewtonRaphson(
310310
linsolve = LS.KrylovJL_GMRES(precs = algebraicmultigrid2), concrete_jac = true
@@ -331,8 +331,8 @@ prob_brusselator_2d_approx_di = NLS.NonlinearProblem(
331331
sparsity = DifferentiationInterface.DenseSparsityDetector(ADTypes.AutoForwardDiff(); atol = 1e-4)),
332332
u0, p; abstol = 1e-10, reltol = 1e-10)
333333
334-
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d_exact_tracer, NLS.NewtonRaphson());
335-
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d_approx_di, NLS.NewtonRaphson());
334+
@btime NLS.solve(prob_brusselator_2d_exact_tracer, NLS.NewtonRaphson());
335+
@btime NLS.solve(prob_brusselator_2d_approx_di, NLS.NewtonRaphson());
336336
nothing # hide
337337
```
338338

lib/SciMLJacobianOperators/src/SciMLJacobianOperators.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ function Base.copy(J::StatefulJacobianOperator)
419419
return StatefulJacobianOperator(
420420
copy(J.jac_op),
421421
J.u === nothing ? nothing : copy(J.u),
422-
J.p === nothing ? nothing : copy(J.p)
422+
applicable(copy, J.p) ? copy(J.p) : J.p
423423
)
424424
end
425425

0 commit comments

Comments
 (0)