Skip to content

Commit 2aeab00

Browse files
Merge pull request #163 from abhro/doc-backslash
Use `@doc_str` macro for docstrings
2 parents 96ca21d + dce75b2 commit 2aeab00

File tree

4 files changed

+109
-105
lines changed

4 files changed

+109
-105
lines changed

lib/ODEProblemLibrary/src/brusselator_prob.jl

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,32 @@ function init_brusselator_2d(xyd)
5555
end
5656
xyd_brusselator = range(0, stop = 1, length = 32)
5757

58-
"""
58+
@doc doc"""
5959
2D Brusselator
6060
6161
```math
62-
\\frac{\\partial u}{\\partial t} = 1 + u^2v - 4.4u + \\alpha(\\frac{\\partial^2 u}{\\partial x^2} + \\frac{\\partial^2 u}{\\partial y^2}) + f(x, y, t)
62+
\frac{\partial u}{\partial t} = 1 + u^2v - 4.4u + \alpha(\frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2}) + f(x, y, t)
6363
```
6464
```math
65-
\\frac{\\partial v}{\\partial t} = 3.4u - u^2v + \\alpha(\\frac{\\partial^2 u}{\\partial x^2} + \\frac{\\partial^2 u}{\\partial y^2})
65+
\frac{\partial v}{\partial t} = 3.4u - u^2v + \alpha(\frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2})
6666
```
6767
6868
where
6969
70-
``f(x, y, t) = \\begin{cases} 5 & \\quad \\text{if } (x-0.3)^2+(y-0.6)^2 ≤ 0.1^2 \\text{ and } t ≥ 1.1 \\\\ 0 & \\quad \\text{else} \\end{cases}``
70+
```math
71+
f(x, y, t) = \begin{cases}
72+
5 & \text{if } (x-0.3)^2+(y-0.6)^2 ≤ 0.1^2 \text{ and } t ≥ 1.1 \\
73+
0 & \text{else}
74+
\end{cases}
75+
```
7176
7277
and the initial conditions are
7378
7479
```math
75-
u(x, y, 0) = 22\\cdot y(1-y)^{3/2}
80+
u(x, y, 0) = 22\cdot y(1-y)^{3/2}
7681
```
7782
```math
78-
v(x, y, 0) = 27\\cdot x(1-x)^{3/2}
83+
v(x, y, 0) = 27\cdot x(1-x)^{3/2}
7984
```
8085
8186
with the periodic boundary condition
@@ -121,20 +126,20 @@ function init_brusselator_1d(N)
121126
u
122127
end
123128

124-
"""
129+
@doc doc"""
125130
1D Brusselator
126131
127132
```math
128-
\\frac{\\partial u}{\\partial t} = A + u^2v - (B+1)u + \\alpha\\frac{\\partial^2 u}{\\partial x^2}
133+
\frac{\partial u}{\partial t} = A + u^2v - (B+1)u + \alpha\frac{\partial^2 u}{\partial x^2}
129134
```
130135
```math
131-
\\frac{\\partial v}{\\partial t} = Bu - u^2v + \\alpha\\frac{\\partial^2 u}{\\partial x^2}
136+
\frac{\partial v}{\partial t} = Bu - u^2v + \alpha\frac{\partial^2 u}{\partial x^2}
132137
```
133138
134139
and the initial conditions are
135140
136141
```math
137-
u(x,0) = 1+\\sin(2π x)
142+
u(x,0) = 1+\sin(2π x)
138143
```
139144
```math
140145
v(x,0) = 3

lib/ODEProblemLibrary/src/ode_simple_nonlinear_prob.jl

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ function lotka(du, u, p, t)
77
du[2] = -p[3] * y + p[4] * x * y
88
end
99

10-
"""
10+
@doc doc"""
1111
Lotka-Volterra Equations (Non-stiff)
1212
1313
```math
14-
\\frac{dx}{dt} = ax - bxy
14+
\frac{dx}{dt} = ax - bxy
1515
```
1616
```math
17-
\\frac{dy}{dt} = -cy + dxy
17+
\frac{dy}{dt} = -cy + dxy
1818
```
1919
2020
with initial condition ``x=y=1``
@@ -33,14 +33,14 @@ function fitz(du, u, p, t)
3333
du[1] = v - v^3 / 3 - w + l
3434
du[2] = τinv * (v + a - b * w)
3535
end
36-
"""
36+
@doc doc"""
3737
Fitzhugh-Nagumo (Non-stiff)
3838
3939
```math
40-
\\frac{dv}{dt} = v - \\frac{v^3}{3} - w + I_{est}
40+
\frac{dv}{dt} = v - \frac{v^3}{3} - w + I_{est}
4141
```
4242
```math
43-
τ \\frac{dw}{dt} = v + a -bw
43+
τ \frac{dw}{dt} = v + a -bw
4444
```
4545
4646
with initial condition ``v=w=1``
@@ -68,34 +68,34 @@ function vanderpol_jac(J, u, p, t)
6868
J[2,2] = μ * (1 - x^2)
6969
end
7070

71-
"""
71+
@doc doc"""
7272
Van der Pol Equations
7373
7474
```math
75-
\\frac{dx}{dt} = y
75+
\frac{dx}{dt} = y
7676
```
7777
```math
78-
\\frac{dy}{dt} = μ((1-x^2)y -x)
78+
\frac{dy}{dt} = μ ((1-x^2)y - x)
7979
```
8080
81-
with ``μ=1.0`` and ``u_0=[\\sqrt{3}, 0]`` (where ``u[1] = x``, ``u[2] = y``)
81+
with ``μ=1.0`` and ``u_0=[\sqrt{3}, 0]`` (where ``u[1] = x``, ``u[2] = y``)
8282
8383
Non-stiff parameters.
8484
"""
85-
prob_ode_vanderpol = ODEProblem(ODEFunction(vanderpol, jac=vanderpol_jac),
85+
prob_ode_vanderpol = ODEProblem(ODEFunction(vanderpol, jac=vanderpol_jac),
8686
[sqrt(3), 0.0], (0.0, 1.0), [1.0])
8787

88-
"""
88+
@doc doc"""
8989
Van der Pol Equations
9090
9191
```math
92-
\\frac{dx}{dt} = y
92+
\frac{dx}{dt} = y
9393
```
9494
```math
95-
\\frac{dy}{dt} = μ((1-x^2)y -x)
95+
\frac{dy}{dt} = μ ((1-x^2)y - x)
9696
```
9797
98-
with ``μ=10^6`` and ``u_0=[\\sqrt{3}, 0]`` (where ``u[1] = x``, ``u[2] = y``)
98+
with ``μ=10^6`` and ``u_0=[\sqrt{3}, 0]`` (where ``u[1] = x``, ``u[2] = y``)
9999
100100
Stiff parameters.
101101
"""
@@ -115,20 +115,20 @@ function rober(du, u, p, t)
115115
du[3] = k₂ * y₂^2
116116
end
117117

118-
"""
118+
@doc doc"""
119119
The Robertson biochemical reactions: (Stiff)
120120
121121
```math
122-
\\frac{dy₁}{dt} = -k₁y₁+k₃y₂y₃
122+
\frac{dy₁}{dt} = -k₁y₁+k₃y₂y₃
123123
```
124124
```math
125-
\\frac{dy₂}{dt} = k₁y₁-k₂y₂^2-k₃y₂y₃
125+
\frac{dy₂}{dt} = k₁y₁-k₂y₂^2-k₃y₂y₃
126126
```
127127
```math
128-
\\frac{dy₃}{dt} = k₂y₂^2
128+
\frac{dy₃}{dt} = k₂y₂^2
129129
```
130130
131-
where ``k₁=0.04``, ``k₂=3\\times10^7``, ``k₃=10^4``. For details, see:
131+
where ``k₁=0.04``, ``k₂=3\times10^7``, ``k₃=10^4``. For details, see:
132132
133133
Hairer Norsett Wanner Solving Ordinary Differential Equations I - Nonstiff Problems Page 129
134134
@@ -202,17 +202,17 @@ function rigidbody(du, u, p, t)
202202
du[3] = I₃ * y₁ * y₂
203203
end
204204

205-
"""
205+
@doc doc"""
206206
Rigid Body Equations (Non-stiff)
207207
208208
```math
209-
\\frac{dy₁}{dt} = I₁y₂y₃
209+
\frac{dy₁}{dt} = I₁y₂y₃
210210
```
211211
```math
212-
\\frac{dy₂}{dt} = I₂y₁y₃
212+
\frac{dy₂}{dt} = I₂y₁y₃
213213
```
214214
```math
215-
\\frac{dy₃}{dt} = I₃y₁y₂
215+
\frac{dy₃}{dt} = I₃y₁y₂
216216
```
217217
218218
with ``I₁=-2``, ``I₂=1.25``, and ``I₃=-1/2``.
@@ -240,7 +240,6 @@ pleiades = (du, u, p, t) -> begin
240240
du[i] = zero(eltype(u))
241241
end
242242
for i in 1:7, j in 1:7
243-
244243
if i != j
245244
r = ((x[i] - x[j])^2 + (y[i] - y[j])^2)^(3 / 2)
246245
du[14 + i] += j * (x[j] - x[i]) / r
@@ -376,7 +375,7 @@ prob_ode_mm_linear = ODEProblem(mm_f, rand(4), (0.0, 1.0))
376375
function hires(du, u, p, t)
377376
y1, y2, y3, y4, y5, y6, y7, y8 = u
378377
p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12 = p
379-
378+
380379
du[1] = -p1 * y1 + p2 * y2 + p3 * y3 + p4
381380
du[2] = p1 * y1 - p5 * y2
382381
du[3] = -p6 * y3 + p2 * y4 + p7 * y5
@@ -393,24 +392,24 @@ u0[8] = 0.0057
393392

394393
p = (1.71, 0.43, 8.32, 0.0007, 8.75, 10.03, 0.035, 1.12, 1.745, 280.0, 0.69, 1.81)
395394

396-
"""
395+
@doc doc"""
397396
Hires Problem (Stiff)
398397
399398
It is in the form of
400399
401400
```math
402-
\\frac{dy}{dt} = f(y)
401+
\frac{dy}{dt} = f(y)
403402
```
404403
405404
with
406405
407406
```math
408-
y(0)=y_0, \\quad y \\in ℝ^8, \\quad 0 ≤ t ≤ 321.8122
407+
y(0)=y_0, \quad y \in ℝ^8, \quad 0 ≤ t ≤ 321.8122
409408
```
410409
411410
where ``f`` is defined by
412411
413-
``f(y) = \\begin{pmatrix} −1.71y_1 & +0.43y_2 & +8.32y_3 & +0.0007y_4 & \\\\ 1.71y_1 & −8.75y_2 & & & \\\\ −10.03y_3 & +0.43y_4 & +0.035y_5 & & \\\\ 8.32y_2 & +1.71y_3 & −1.12y_4 & & \\\\ −1.745y_5 & +0.43y_6 & +0.43y_7 & & \\\\ −280y_6y_8 & +0.69y_4 & +1.71y_5 & −0.43y_6 & +0.69y_7 \\\\ 280y_6y_8 & −1.81y_7 & & & \\\\ −280y_6y_8 & +1.81y_7 & & & \\end{pmatrix}``
412+
``f(y) = \begin{pmatrix} −1.71y_1 & +0.43y_2 & +8.32y_3 & +0.0007y_4 & \\ 1.71y_1 & −8.75y_2 & & & \\ −10.03y_3 & +0.43y_4 & +0.035y_5 & & \\ 8.32y_2 & +1.71y_3 & −1.12y_4 & & \\ −1.745y_5 & +0.43y_6 & +0.43y_7 & & \\ −280y_6y_8 & +0.69y_4 & +1.71y_5 & −0.43y_6 & +0.69y_7 \\ 280y_6y_8 & −1.81y_7 & & & \\ −280y_6y_8 & +1.81y_7 & & & \end{pmatrix}``
414413
415414
Reference: [demohires.pdf](http://www.radford.edu/~thompson/vodef90web/problems/demosnodislin/Demos_Pitagora/DemoHires/demohires.pdf)
416415
Notebook: [Hires.ipynb](http://nbviewer.jupyter.org/github/JuliaDiffEq/DiffEqBenchmarks.jl/blob/master/StiffODE/Hires.ipynb)
@@ -422,24 +421,24 @@ prob_ode_hires = ODEProblem(hires, u0, (0.0, 321.8122), p)
422421
function orego(du, u, p, t)
423422
y1, y2, y3 = u
424423
p1, p2, p3 = p
425-
424+
426425
du[1] = p1 * (y2 + y1 * (1 - p2 * y1 - y2))
427426
du[2] = (y3 - (1 + y1) * y2) / p1
428427
du[3] = p3 * (y1 - y3)
429428
end
430429

431-
"""
430+
@doc doc"""
432431
Orego Problem (Stiff)
433432
434-
It is in the form of ``\\frac{dy}{dt}=f(y), \\quad y(0)=y0,`` with
433+
It is in the form of ``\frac{dy}{dt}=f(y), \quad y(0)=y_0,`` with
435434
436435
```math
437-
y \\in ℝ^3, \\quad 0 ≤ t ≤ 360
436+
y \in ℝ^3, \quad 0 ≤ t ≤ 360
438437
```
439438
440439
where ``f`` is defined by
441440
442-
``f(y) = \\begin{pmatrix} s(y_2 - y_1(1-qy_1-y_2)) \\\\ (y_3 - y_2(1+y_1))/s \\\\ w(y_1-y_3) \\end{pmatrix}``
441+
``f(y) = \begin{pmatrix} s(y_2 - y_1(1-qy_1-y_2)) \\ (y_3 - y_2(1+y_1))/s \\ w(y_1-y_3) \end{pmatrix}``
443442
444443
where ``s=77.27``, ``w=0.161`` and ``q=8.375⋅10^{-6}``.
445444

lib/ODEProblemLibrary/src/pollution_prob.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,24 +188,24 @@ u0[8] = 0.3
188188
u0[9] = 0.01
189189
u0[17] = 0.007
190190

191-
"""
191+
@doc doc"""
192192
Pollution Problem (Stiff)
193193
194-
This IVP is a stiff system of 20 non-linear Ordinary Differential Equations. It is in the form of
194+
This IVP is a stiff system of 20 non-linear Ordinary Differential Equations. It is in the form of
195195
196196
```math
197-
\\frac{dy}{dt}=f(y)
197+
\frac{dy}{dt}=f(y)
198198
```
199199
200200
with
201201
202202
```math
203-
y(0)=y0, \\quad y \\in ℝ^20, \\quad 0 ≤ t ≤ 60
203+
y(0)=y_0, \quad y \in ℝ^{20}, \quad 0 ≤ t ≤ 60
204204
```
205205
206206
where ``f`` is defined by
207207
208-
``f(y) = \\begin{pmatrix} -\\sum_{j∈{1,10,14,23,24}} r_j + \\sum_{j∈{2,3,9,11,12,22,25}} r_j \\\\ -r_2 - r_3 - r_9 - r_12 + r_1 + r_{21} \\\\ -r_{15} + r_1 + r_{17} + r_{19} + r_{22} \\\\ -r_2 - r_{16} - r_{17} - r_{23} + r_{15} \\\\ -r_3 + 2r_4 + r_6 + r_7 + r_{13} + r_{20} \\\\ -r_6 - r_8 - r_{14} - r_{20} + r_3 + 2r_{18} \\\\ -r_4 - r_5 - r_6 + r_{13} \\\\ r_4 + r_5 + r_6 + r_7 \\\\ -r_7 - r_8 \\\\ -r_{12} + r_7 + r_9 \\\\ -r_9 - r_{10} + r_8 + r_{11} \\\\ r_9 \\\\ -r_{11} + r_{10} \\\\ -r_{13} + r_{12} \\\\ r_{14} \\\\ -r_{18} - r_{19} + r_{16} \\\\ -r_{20} \\\\ r_{20} \\\\ -r{21} - r_{22} - r_{24} + r_{23} + r_{25} \\\\ -r_{25} + r_{24} \\end{pmatrix}``
208+
``f(y) = \begin{pmatrix} -\sum_{j∈{1,10,14,23,24}} r_j + \sum_{j∈{2,3,9,11,12,22,25}} r_j \\ -r_2 - r_3 - r_9 - r_12 + r_1 + r_{21} \\ -r_{15} + r_1 + r_{17} + r_{19} + r_{22} \\ -r_2 - r_{16} - r_{17} - r_{23} + r_{15} \\ -r_3 + 2r_4 + r_6 + r_7 + r_{13} + r_{20} \\ -r_6 - r_8 - r_{14} - r_{20} + r_3 + 2r_{18} \\ -r_4 - r_5 - r_6 + r_{13} \\ r_4 + r_5 + r_6 + r_7 \\ -r_7 - r_8 \\ -r_{12} + r_7 + r_9 \\ -r_9 - r_{10} + r_8 + r_{11} \\ r_9 \\ -r_{11} + r_{10} \\ -r_{13} + r_{12} \\ r_{14} \\ -r_{18} - r_{19} + r_{16} \\ -r_{20} \\ r_{20} \\ -r{21} - r_{22} - r_{24} + r_{23} + r_{25} \\ -r_{25} + r_{24} \end{pmatrix}``
209209
210210
with the initial condition of
211211

0 commit comments

Comments
 (0)