Skip to content

Commit 9d56ae5

Browse files
committed
start docstring overhaul
1 parent 18ab2bc commit 9d56ae5

File tree

5 files changed

+55
-43
lines changed

5 files changed

+55
-43
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ Manifest.toml
77
.vscode
88
profile.pb.gz
99
.*.swp
10+
docs/build

docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
34

45
[compat]
56
Documenter = "0.27"

src/OrdinaryDiffEq.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ import Preferences
103103
DEFAULT_PRECS(W, du, u, p, t, newW, Plprev, Prprev, solverdata) = nothing, nothing
104104

105105
include("misc_utils.jl")
106+
106107
include("algorithms.jl")
108+
include("algorithms/explicit_rk.jl")
109+
107110
include("alg_utils.jl")
108111

109112
include("nlsolve/type.jl")

src/algorithms.jl

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -505,49 +505,6 @@ function Base.show(io::IO, alg::RK46NL)
505505
", thread = ", alg.thread, ")")
506506
end
507507

508-
"""
509-
Heun(; stage_limiter! = OrdinaryDiffEq.trivial_limiter!,
510-
step_limiter! = OrdinaryDiffEq.trivial_limiter!,
511-
thread = OrdinaryDiffEq.False())
512-
513-
Explicit Runge-Kutta Method
514-
The second order Heun's method. Uses embedded Euler method for adaptivity.
515-
516-
Like SSPRK methods, this method also takes optional arguments `stage_limiter!`
517-
and `step_limiter!`, where `stage_limiter!` and `step_limiter!` are functions
518-
of the form `limiter!(u, integrator, p, t)`.
519-
520-
The argument `thread` determines whether internal broadcasting on
521-
appropriate CPU arrays should be serial (`thread = OrdinaryDiffEq.False()`,
522-
default) or use multiple threads (`thread = OrdinaryDiffEq.True()`) when
523-
Julia is started with multiple threads.
524-
"""
525-
struct Heun{StageLimiter, StepLimiter, Thread} <: OrdinaryDiffEqAdaptiveAlgorithm
526-
stage_limiter!::StageLimiter
527-
step_limiter!::StepLimiter
528-
thread::Thread
529-
end
530-
531-
function Heun(; stage_limiter! = trivial_limiter!, step_limiter! = trivial_limiter!,
532-
thread = False())
533-
Heun{typeof(stage_limiter!), typeof(step_limiter!), typeof(thread)}(stage_limiter!,
534-
step_limiter!,
535-
thread)
536-
end
537-
538-
# for backwards compatibility
539-
function Heun(stage_limiter!, step_limiter! = trivial_limiter!)
540-
Heun{typeof(stage_limiter!), typeof(step_limiter!), False}(stage_limiter!,
541-
step_limiter!,
542-
False())
543-
end
544-
545-
function Base.show(io::IO, alg::Heun)
546-
print(io, "Heun(stage_limiter! = ", alg.stage_limiter!,
547-
", step_limiter! = ", alg.step_limiter!,
548-
", thread = ", alg.thread, ")")
549-
end
550-
551508
"""
552509
Ralston(; stage_limiter! = OrdinaryDiffEq.trivial_limiter!,
553510
step_limiter! = OrdinaryDiffEq.trivial_limiter!,

src/algorithms/explicit_rk.jl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
function explicit_rk_docstring(description::String)
2+
start_docstring = """
3+
```julia
4+
$FUNCTIONNAME(; stage_limiter! = OrdinaryDiffEq.trivial_limiter!,
5+
step_limiter! = OrdinaryDiffEq.trivial_limiter!,
6+
thread = OrdinaryDiffEq.False())
7+
```
8+
9+
Explicit Runge-Kutta Method.
10+
"""
11+
end_docstring = """
12+
13+
### Keyword Arguments
14+
15+
- `stage_limiter!`: function of the form `limiter!(u, integrator, p, t)`
16+
- `step_limiter!`: function of the form `limiter!(u, integrator, p, t)`
17+
- `thread`: determines whether internal broadcasting on
18+
appropriate CPU arrays should be serial (`thread = OrdinaryDiffEq.False()`,
19+
default) or use multiple threads (`thread = OrdinaryDiffEq.True()`) when
20+
Julia is started with multiple threads.
21+
"""
22+
start_docstring * description * end_docstring
23+
end
24+
25+
@doc explicit_rk_docstring("The second order Heun's method. Uses embedded Euler method for adaptivity.")
26+
struct Heun{StageLimiter, StepLimiter, Thread} <: OrdinaryDiffEqAdaptiveAlgorithm
27+
stage_limiter!::StageLimiter
28+
step_limiter!::StepLimiter
29+
thread::Thread
30+
end
31+
32+
function Heun(; stage_limiter! = trivial_limiter!, step_limiter! = trivial_limiter!,
33+
thread = False())
34+
Heun{typeof(stage_limiter!), typeof(step_limiter!), typeof(thread)}(stage_limiter!,
35+
step_limiter!,
36+
thread)
37+
end
38+
39+
# for backwards compatibility
40+
function Heun(stage_limiter!, step_limiter! = trivial_limiter!)
41+
Heun{typeof(stage_limiter!), typeof(step_limiter!), False}(stage_limiter!,
42+
step_limiter!,
43+
False())
44+
end
45+
46+
function Base.show(io::IO, alg::Heun)
47+
print(io, "Heun(stage_limiter! = ", alg.stage_limiter!,
48+
", step_limiter! = ", alg.step_limiter!,
49+
", thread = ", alg.thread, ")")
50+
end

0 commit comments

Comments
 (0)