Skip to content

Commit dffa0b0

Browse files
Convert to example blocks
Co-authored-by: Joshua Lampert <[email protected]>
1 parent c488b4b commit dffa0b0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/src/tutorial.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Pkg.add("MeshIntegrals")
2727
Usage of **MeshIntegrals.jl** typically also involves using **Meshes.jl** and **Unitful.jl**,
2828
so all three packages will be used in this example.
2929

30-
```julia
30+
```@example tutorial
3131
using Meshes
3232
using MeshIntegrals
3333
using Unitful
@@ -56,7 +56,7 @@ f(x, y, z) = \frac{1}{\sqrt{1 + \cos^2(x/\text{m})}} ~ \Omega/\text{m}
5656
Integrand functions are expected to provide a method that takes a single
5757
`Meshes.Point` argument, so this can be written in Julia as
5858

59-
```julia
59+
```@example tutorial
6060
# Integrand function that outputs in units of Ohms/meter
6161
function f(p::Meshes.Point)
6262
x, y, z = Meshes.to(p)
@@ -65,7 +65,7 @@ end
6565
```
6666

6767
Alternatively, this could be written in the user-friendly notation
68-
```julia
68+
```@example tutorial
6969
f(x, y, z) = (1 / sqrt(1 + cos(x / u"m")^2)) * u"Ω/m"
7070
f(p::Meshes.Point) = f(Meshes.to(p)...)
7171
```
@@ -74,14 +74,14 @@ where the required `f(Meshes.Point)` method simply maps to the method `f(x, y, z
7474
### Integrating
7575

7676
This function can be integrated using recommended defaults simply by calling
77-
```julia
77+
```@example tutorial
7878
integral(f, curve) # -> Approximately 2π Ω
7979
```
8080

8181
The alias function `lineintegral` works for this geometry since it has one
8282
parametric dimension. However, the aliases `surfaceintegral` and `volumeintegral`
8383
will throw an `ArgumentError` since the geometry is not a surface or volume.
84-
```julia
84+
```@example tutorial
8585
lineintegral(f, curve) # -> Approximately 2π Ω
8686
8787
surfaceintegral(f, curve) # -> throws ArgumentError
@@ -93,7 +93,7 @@ An `IntegrationRule` with settings can also be manually specified. The following
9393
example uses the adaptive Gauss-Kronrod method with a loosened absolute tolerance
9494
setting of $10^{-4}~\Omega$, which speeds up integration by sacrificing some
9595
accuracy.
96-
```julia
96+
```@example tutorial
9797
integral(f, curve, GaussKronrod(atol = 1e-4u"Ω")) # -> Approximately (2π ± 1e-4) Ω
9898
```
9999

@@ -102,7 +102,7 @@ The `integral` function and its aliases also support Julia's
102102
code block to define a single-use anonymous function and then injects it as a
103103
first argument to the preceding call. This can be useful if the integrand
104104
function will not be used outside this integration call.
105-
```julia
105+
```@example tutorial
106106
integral(curve) do p
107107
x, y, z = Meshes.to(p)
108108
(1 / sqrt(1 + cos(x / u"m")^2)) * u"Ω/m"

0 commit comments

Comments
 (0)