Skip to content

Commit 75d7aac

Browse files
committed
Update example and docs
1 parent da55380 commit 75d7aac

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

docs/src/index.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
# NewtonKrylov.jl
22

3+
4+
35
## API
46

57
```@docs
68
newton_krylov!
9+
newton_krylov
10+
```
11+
12+
### Parameters
13+
14+
```@docs
15+
NewtonKrylov.Forcing
16+
NewtonKrylov.Fixed
717
NewtonKrylov.EisenstatWalker
18+
```
19+
20+
### Internal
21+
22+
```@docs
23+
NewtonKrylov.JacobianOperator
824
```

examples/bratu.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# # 1D bratu equation
22

3+
# ## Necessary packages
34
using NewtonKrylov, Krylov
45
using KrylovPreconditioners
56
using SparseArrays, LinearAlgebra
67
using CairoMakie
78

9+
# ## 1D Bratu equations
10+
# $y′′ + λ * exp(y) = 0$
11+
812
function bratu!(res, y, Δx, λ)
913
N = length(y)
1014
for i in 1:N
@@ -23,21 +27,26 @@ function bratu(y, dx, λ)
2327
return res
2428
end
2529

30+
# ## Reference solution
2631
function true_sol_bratu(x)
2732
## for λ = 3.51382, 2nd sol θ = 4.8057
2833
θ = 4.79173
2934
return -2 * log(cosh* (x - 0.5) / 2) / (cosh/ 4)))
3035
end
3136

37+
# ## Choice of parameters
3238
const N = 10_000
3339
const λ = 3.51382
3440
const dx = 1 / (N + 1) # Grid-spacing
3541

42+
# ### Domain and Inital condition
3643
x = LinRange(0.0 + dx, 1.0 - dx, N)
3744
u₀ = sin.(x .* π)
3845

46+
# ## Reference solution evaluated over domain
3947
reference = true_sol_bratu.(x)
4048

49+
# ## Solving using inplace and out-of-place variants
4150
uₖ_1 = newton_krylov!(
4251
(res, u) -> bratu!(res, u, dx, λ),
4352
copy(u₀), similar(u₀);

0 commit comments

Comments
 (0)