Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielVandH committed Feb 27, 2023
1 parent 6ab2cd8 commit df1c286
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FiniteVolumeMethod"
uuid = "d4f04ab7-4f65-4d72-8a28-7087bc7f46f4"
authors = ["Daniel VandenHeuvel <danj.vandenheuvel@gmail.com>"]
version = "0.4.0"
version = "0.4.1"

[deps]
ChunkSplitters = "ae650224-84b6-46f8-82ea-d812ca08434e"
Expand Down
21 changes: 4 additions & 17 deletions docs/src/annulus.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

Please ensure you have read the List of Examples section before proceeding.

We now consider another diffusion problem, except now we demonstrate how we can solve a problem on a multiply-connected domain. The problem we consider comes from http://onelab.info/wiki/Tutorial/Heat_equation_with_Dirichlet_boundary_control, namely
We now consider another diffusion problem, except now we demonstrate how we can solve a problem on a multiply-connected domain. The problem we consider comes from [http://onelab.info/wiki/Tutorial/Heat_equation_with_Dirichlet_boundary_control](http://onelab.info/wiki/Tutorial/Heat_equation_with_Dirichlet_boundary_control), namely

```math
\begin{equation*}
\begin{array}{rcll}
\dfrac{\partial u}{\partial t} & = & \boldsymbol{\nabla}^2 u & \boldsymbol{x} \in \Omega, t>0, \\
\boldsymbol{\nabla} u \boldsymbol{\cdot} \hat{\boldsymbol n} = 0 & \boldsymbol{x} \in \mathcal D(0, 1), t>0, \\
\boldsymbol{\nabla} u \boldsymbol{\cdot} \hat{\boldsymbol n} &=& 0 & \boldsymbol{x} \in \mathcal D(0, 1), t>0, \\
u(x, y, t) & = & c(t) & \boldsymbol{x} \in \mathcal D(0, 0.2), t>0, \\
u(x, y, 0) & = & u_0(x, y) & \boldsymbol{x} \in \Omega,
\end{array}
Expand All @@ -21,7 +21,7 @@ where $\mathcal D(0, r)$ is a circle of radius $r$ centred at the origin, $\Omeg
u_0(x) =10\mathrm{e}^{-25\left(\left(x + \frac12\right)^2 + \left(y + \frac12\right)^2\right)} - 10\mathrm{e}^{-45\left(\left(x - \frac12\right)^2 + \left(y - \frac12\right)^2\right)} - 5\mathrm{e}^{-50\left(\left(x + \frac{3}{10}\right)^2 + \left(y + \frac12\right)^2\right)}.
```

To define this problem, we define the problem as we have been doing, but now we take special care to define the multiply-connected domain. In particular, we define the boundary nodes according to the specification in DelaunayTriangulation.jl (see the boundary nodes discussion here https://danielvandh.github.io/DelaunayTriangulation.jl/stable/interface/interface/). The complete code is below, where we generate the mesh, visualise the solution, and also animate it.
To define this problem, we define the problem as we have been doing, but now we take special care to define the multiply-connected domain. In particular, we define the boundary nodes according to the specification in DelaunayTriangulation.jl (see the boundary nodes discussion here [https://danielvandh.github.io/DelaunayTriangulation.jl/stable/interface/interface/](https://danielvandh.github.io/DelaunayTriangulation.jl/stable/interface/interface/)). The complete code is below, where we generate the mesh, and then visualise the solution.

```julia
## Generate the mesh.
Expand Down Expand Up @@ -75,19 +75,6 @@ mesh!(ax, pt_mat, T_mat, color=sol.u[6], colorrange=(-10, 20), colormap=:viridis
ax = Axis(fig[1, 3], width=600, height=600)
mesh!(ax, pt_mat, T_mat, color=sol.u[11], colorrange=(-10, 20), colormap=:viridis)
save("figures/annulus_test.png", fig)

fig = Figure()
t_rng = LinRange(0, 2, 361)
j = Observable(1)
ax = Axis(fig[1, 1], xlabel=L"x", ylabel=L"y",
title=Makie.lift(_j -> L"t = %$(rpad(round(t_rng[_j], digits = 5), 7, '0'))", j),
titlealign=:left)
mesh!(ax, pt_mat, T_mat, color=@lift(sol(t_rng[$j])), colorrange=(-10, 20), colormap=:viridis)
record(fig, "figures/annulus_test.mp4", eachindex(t_rng)) do _j
j[] = _j
end
```

![Annulus solution](https://github.com/DanielVandH/FiniteVolumeMethod.jl/blob/main/test/figures/annulus_test.png?raw=true)

![Annulus animation](https://github.com/DanielVandH/FiniteVolumeMethod.jl/blob/main/test/figures/annulus_test.mp4?raw=true)
![Annulus solution](https://github.com/DanielVandH/FiniteVolumeMethod.jl/blob/main/test/figures/annulus_test.png?raw=true)
8 changes: 4 additions & 4 deletions docs/src/example_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ The purpose of this example is to show how we can solve problems on a multiply-c
\begin{equation*}
\begin{array}{rcll}
\dfrac{\partial u}{\partial t} & = & \boldsymbol{\nabla}^2 u & \boldsymbol{x} \in \Omega, t>0, \\
\boldsymbol{\nabla} u \boldsymbol{\cdot} \hat{\boldsymbol n} = 0 & \boldsymbol{x} \in \mathcal D(0, 1), t>0, \\
\boldsymbol{\nabla} u \boldsymbol{\cdot} \hat{\boldsymbol n} & = & 0 & \boldsymbol{x} \in \mathcal D(0, 1), t>0, \\
u(x, y, t) & = & c(t) & \boldsymbol{x} \in \mathcal D(0, 0.2), t>0, \\
u(x, y, 0) & = & u_0(x, y) & \boldsymbol{x} \in \Omega,
\end{array}
Expand All @@ -144,8 +144,8 @@ The purpose of this example is to show how we can solve a steady problem. We sol
\begin{equation*}
\begin{array}{rcll}
\boldsymbol{\nabla}^2 u(x, y) & = & 0 & 0 < x, y < \pi, \\
u(x, 0) & = & \sinh(x) & 0 < x < \pi,
u(x, \pi) & = & -\sinh(x) & 0 < x < \pi,
u(x, 0) & = & \sinh(x) & 0 < x < \pi, \\
u(x, \pi) & = & -\sinh(x) & 0 < x < \pi, \\
u(0, y) & = & 0 & 0 < y < \pi, \\
u(\pi, y) & = & \sinh(\pi)\cos(y) & 0 < x < \pi,
\end{array}
Expand All @@ -166,4 +166,4 @@ D\boldsymbol{\nabla}^2 T & = & -1,
\end{equation*}
```

where the boundary conditions could be either absorbing, reflecting, or a combination of the two, and $T$ is the mean exit time of a particle with diffusivity $D$ out of the given domain. We cover many examples, reproducing some of the work in my papers at https://iopscience.iop.org/article/10.1088/1367-2630/abe60d and https://iopscience.iop.org/article/10.1088/1751-8121/ac4a1d.
where the boundary conditions could be either absorbing, reflecting, or a combination of the two, and $T$ is the mean exit time of a particle with diffusivity $D$ out of the given domain. We cover many examples, reproducing some of the work in my papers at [https://iopscience.iop.org/article/10.1088/1367-2630/abe60d](https://iopscience.iop.org/article/10.1088/1367-2630/abe60d) and [https://iopscience.iop.org/article/10.1088/1751-8121/ac4a1d](https://iopscience.iop.org/article/10.1088/1751-8121/ac4a1d).
6 changes: 3 additions & 3 deletions docs/src/laplace.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Now we consider Laplace's equaton. This is a steady problem, whereas all previou
\begin{equation*}
\begin{array}{rcll}
\boldsymbol{\nabla}^2 u(x, y) & = & 0 & 0 < x, y < \pi, \\
u(x, 0) & = & \sinh(x) & 0 < x < \pi,
u(x, \pi) & = & -\sinh(x) & 0 < x < \pi,
u(x, 0) & = & \sinh(x) & 0 < x < \pi,\\
u(x, \pi) & = & -\sinh(x) & 0 < x < \pi, \\
u(0, y) & = & 0 & 0 < y < \pi, \\
u(\pi, y) & = & \sinh(\pi)\cos(y) & 0 < x < \pi,
\end{array}
Expand All @@ -32,7 +32,7 @@ we are solving problems with $\partial u/\partial t = 0$ so that
\end{equation*}
```

For the reaction-diffusion formula, this is instead given by $0 = \boldsymbol\nabla[D\boldsymbol\nabla u] + R$. Moreover, the initial condition that we provide is now actually used as an initial estimate in the nonlinear solver that computes the steady state (defined via NonlinearSolve.jl). Lastly, the final time that we provide is replaced with infinity. With this in mind, the code for solving the above problem is given below.
For the reaction-diffusion formula, this is instead given by $0 = \boldsymbol\nabla\boldsymbol\cdot[D\boldsymbol\nabla u] + R$. Moreover, the initial condition that we provide is now actually used as an initial estimate in the nonlinear solver that computes the steady state (defined via NonlinearSolve.jl). Lastly, the final time that we provide is replaced with infinity. With this in mind, the code for solving the above problem is given below.

```julia
using FiniteVolumeMethod
Expand Down
6 changes: 3 additions & 3 deletions docs/src/mean_exit_time.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Example IX: Mean exit time problems

In this example, we will investigate some simple mean exit time problems. In particular, the aim is to reproduce some of the figures from the numerical solutions in my other work on mean exit time at https://iopscience.iop.org/article/10.1088/1367-2630/abe60d and https://iopscience.iop.org/article/10.1088/1751-8121/ac4a1d.
In this example, we will investigate some simple mean exit time problems. In particular, the aim is to reproduce some of the figures from the numerical solutions in my other work on mean exit time at [https://iopscience.iop.org/article/10.1088/1367-2630/abe60d](https://iopscience.iop.org/article/10.1088/1367-2630/abe60d) and [https://iopscience.iop.org/article/10.1088/1751-8121/ac4a1d](https://iopscience.iop.org/article/10.1088/1751-8121/ac4a1d).

Fistly, mean exit time problems with linear diffusion can be defined according to

Expand Down Expand Up @@ -254,7 +254,7 @@ resize_to_layout!(fig)

## Annulus

Now we consider mean exit time on an annulus. The paper https://iopscience.iop.org/article/10.1088/1751-8121/ac4a1d also considers heterogeneous annuli, but we will not do that here. We will consider a reflecting inner boundary condition with an absorbing outer boundary condition, so that $\boldsymbol{\nabla}^2 T = -1/D$ in the annulus, $\boldsymbol{\nabla} T \vdot \hat{\boldsymbol n} = 0$ on the inner ring, and $T = 0$ on the outer ring. The annulus we consider is $R_1 < r < R_2$ with $R_1 = 2$ and $R_2 = 3$, which corresponds to an exact solution $T(x, y) = (R_2^2 - r^2)/(4D) + R_1^2\log(r/R_2)/(2D)$, where $r = \sqrt{x^2 + y^2}$.
Now we consider mean exit time on an annulus. The paper [https://iopscience.iop.org/article/10.1088/1751-8121/ac4a1d](https://iopscience.iop.org/article/10.1088/1751-8121/ac4a1d) also considers heterogeneous annuli, but we will not do that here. We will consider a reflecting inner boundary condition with an absorbing outer boundary condition, so that $\boldsymbol{\nabla}^2 T = -1/D$ in the annulus, $\boldsymbol{\nabla} T \boldsymbol{\cdot} \hat{\boldsymbol n} = 0$ on the inner ring, and $T = 0$ on the outer ring. The annulus we consider is $R_1 < r < R_2$ with $R_1 = 2$ and $R_2 = 3$, which corresponds to an exact solution $T(x, y) = (R_2^2 - r^2)/(4D) + R_1^2\log(r/R_2)/(2D)$, where $r = \sqrt{x^2 + y^2}$.

```julia
using FiniteVolumeMethod
Expand Down Expand Up @@ -370,4 +370,4 @@ Colorbar(fig[1, 2], msh)
resize_to_layout!(fig)
```

![Perturbed annulus mean exit time](https://github.com/DanielVandH/FiniteVolumeMethod.jl/blob/main/test/figures/annulus_mean_exit_time.png?raw=true)
![Perturbed annulus mean exit time](https://github.com/DanielVandH/FiniteVolumeMethod.jl/blob/main/test/figures/perturbed_annulus_mean_exit_time.png?raw=true)
15 changes: 1 addition & 14 deletions test/annulus_example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,4 @@ ax = Axis(fig[1, 2], width=600, height=600)
mesh!(ax, pt_mat, T_mat, color=sol.u[6], colorrange=(-10, 20), colormap=:viridis)
ax = Axis(fig[1, 3], width=600, height=600)
mesh!(ax, pt_mat, T_mat, color=sol.u[11], colorrange=(-10, 20), colormap=:viridis)
SAVE_FIGURE && save("figures/annulus_test.png", fig)

if SAVE_FIGURE
fig = Figure()
t_rng = LinRange(0, 2, 361)
j = Observable(1)
ax = Axis(fig[1, 1], xlabel=L"x", ylabel=L"y",
title=Makie.lift(_j -> L"t = %$(rpad(round(t_rng[_j], digits = 5), 7, '0'))", j),
titlealign=:left)
mesh!(ax, pt_mat, T_mat, color=@lift(sol(t_rng[$j])), colorrange=(-10, 20), colormap=:viridis)
record(fig, "figures/annulus_test.mp4", eachindex(t_rng)) do _j
j[] = _j
end
end
SAVE_FIGURE && save("figures/annulus_test.png", fig)
Binary file removed test/figures/annulus_test.mp4
Binary file not shown.

2 comments on commit df1c286

@DanielVandH
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/78587

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.1 -m "<description of version>" df1c2868836f8ceba554e5c6cc8dc4278a46d2b9
git push origin v0.4.1

Please sign in to comment.