Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type stabilities for FVMSystems #48

Merged
merged 67 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
44d012d
Some progress
DanielVandH Sep 12, 2023
8ba3322
Change order, add docs for LinearReactionDiffusionEquation
DanielVandH Sep 13, 2023
2aae560
pl_interpolate example
DanielVandH Sep 13, 2023
0f151cc
Order
DanielVandH Sep 13, 2023
b6d6ef4
Generalsied
DanielVandH Sep 13, 2023
dde6884
Poisson, and new files
DanielVandH Sep 13, 2023
df5ce39
Add SparseArrays
DanielVandH Sep 13, 2023
d3ca603
Electricity
DanielVandH Sep 13, 2023
11e5ccc
Excess
DanielVandH Sep 13, 2023
3043592
Electric field example
DanielVandH Sep 13, 2023
b229c3f
Missing using
DanielVandH Sep 13, 2023
6950209
1.6
DanielVandH Sep 13, 2023
8214c6e
Various changes
DanielVandH Sep 13, 2023
b29b517
Laplace's equation example
DanielVandH Sep 13, 2023
7cbaad8
Image
DanielVandH Sep 13, 2023
45777fa
Stash
DanielVandH Sep 13, 2023
cd40a9e
Typo
DanielVandH Sep 13, 2023
edca9d1
typo
DanielVandH Sep 14, 2023
3e1db60
Rm
DanielVandH Sep 14, 2023
2bead4d
ignore md
DanielVandH Sep 14, 2023
04767b0
Try this
DanielVandH Sep 14, 2023
3676a56
fix
DanielVandH Sep 14, 2023
7077952
yes
DanielVandH Sep 14, 2023
ec815a9
v2
DanielVandH Sep 14, 2023
3697185
Okay
DanielVandH Sep 14, 2023
774dd80
The semilinear case is not really needed
DanielVandH Sep 14, 2023
b250053
Removed these files
DanielVandH Sep 14, 2023
c4ae151
kwargie
DanielVandH Sep 14, 2023
f144872
Fix
DanielVandH Sep 14, 2023
9881d60
Finished the examples
DanielVandH Sep 14, 2023
1290425
Sundials
DanielVandH Sep 14, 2023
349fd12
Sundials
DanielVandH Sep 14, 2023
16884f0
Comments
DanielVandH Sep 14, 2023
49fd624
c
DanielVandH Sep 14, 2023
f990e19
semi
DanielVandH Sep 14, 2023
4cc536e
Merge branch 'linearex' of github.com:DanielVandH/FiniteVolumeMethod.…
DanielVandH Sep 14, 2023
ceaca7f
temp [no ci]
DanielVandH Sep 14, 2023
c6c463b
Try update
DanielVandH Sep 14, 2023
3d339d2
Merge branch 'linearex' of github.com:DanielVandH/FiniteVolumeMethod.…
DanielVandH Sep 14, 2023
60f7682
STS
DanielVandH Sep 14, 2023
a7857a9
try this
DanielVandH Sep 14, 2023
df4029e
oops
DanielVandH Sep 14, 2023
65186c2
Merge branch 'linearex' of github.com:DanielVandH/FiniteVolumeMethod.…
DanielVandH Sep 14, 2023
6658f7e
st
DanielVandH Sep 14, 2023
10a6f0f
Try removing threads
DanielVandH Sep 14, 2023
a38f1c2
try ubuntu
DanielVandH Sep 14, 2023
4dbee2d
Merge branch 'linearex' of github.com:DanielVandH/FiniteVolumeMethod.…
DanielVandH Sep 14, 2023
b4231e6
sts
DanielVandH Sep 14, 2023
532c2a0
maybe
DanielVandH Sep 14, 2023
97c92e5
Merge branch 'linearex' of github.com:DanielVandH/FiniteVolumeMethod.…
DanielVandH Sep 15, 2023
e174739
sts
DanielVandH Sep 15, 2023
4f9e312
how much space you need
DanielVandH Sep 15, 2023
e074b97
Merge branch 'linearex' of github.com:DanielVandH/FiniteVolumeMethod.…
DanielVandH Sep 15, 2023
2b2829c
sts
DanielVandH Sep 15, 2023
27c300e
Some improved coverage
DanielVandH Sep 15, 2023
0c30902
Merge branch 'linearex' of github.com:DanielVandH/FiniteVolumeMethod.…
DanielVandH Sep 15, 2023
a728bf8
st
DanielVandH Sep 15, 2023
df3041d
Update
DanielVandH Sep 15, 2023
6046bbb
sts
DanielVandH Sep 15, 2023
4926750
Merge branch 'main' of github.com:DanielVandH/FiniteVolumeMethod.jl i…
DanielVandH Sep 15, 2023
431a008
Fixes
DanielVandH Sep 15, 2023
4fb0c6a
add the problems fiedld
DanielVandH Sep 15, 2023
41eb335
Yes
DanielVandH Sep 15, 2023
f1e0e77
t
DanielVandH Sep 15, 2023
71ffbc3
Nono
DanielVandH Sep 15, 2023
6cf7a45
Also test system some more
DanielVandH Sep 15, 2023
b43fcc3
Merge branch 'main' into syseff
DanielVandH Sep 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,19 @@ jobs:
files: lcov.info
docs:
name: Documentation
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
permissions:
contents: write
statuses: write
steps:
- name: Increase swapfile
run: |
sudo swapoff -a
sudo fallocate -l 8G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/DocCleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Doc Preview Cleanup

on:
pull_request:
types: [closed]

jobs:
doc-preview-cleanup:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v3
with:
ref: gh-pages
- name: Delete preview and history + push changes
run: |
if [ -d "previews/PR$PRNUM" ]; then
git config user.name "Documenter.jl"
git config user.email "[email protected]"
git rm -rf "previews/PR$PRNUM"
git commit -m "delete preview"
git branch gh-pages-new $(echo "delete history" | git commit-tree HEAD^{tree})
git push --force origin gh-pages-new:gh-pages
fi
env:
PRNUM: ${{ github.event.number }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ docs/src/tutorials/reaction_diffusion_equation_with_a_time_dependent_dirichlet_b
docs/src/tutorials/diffusion_equation_on_a_square_plate.md
docs/src/tutorials/equilibrium_temperature_distribution_with_mixed_boundary_conditions_and_using_ensembleproblems.md
docs/src/tutorials/diffusion_equation_in_a_wedge_with_mixed_boundary_conditions.md
docs/src/tutorials/gray_scott_model_turing_patterns_from_a_coupled_reaction_diffusion_system.md
docs/src/tutorials/solving_mazes_with_laplaces_equation.md
docs/src/wyos/laplaces_equation.md
docs/src/wyos/mean_exit_time.md
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ in two dimensions using the finite volume method, with support also provided for

1. `DiffusionEquation`s: $\partial_tu = \boldsymbol\nabla\boldsymbol\cdot[D(\boldsymbol x)\boldsymbol\nabla u]$.
2. `MeanExitTimeProblem`s: $\boldsymbol\nabla\boldsymbol\cdot[D(\boldsymbol x)\boldsymbol\nabla T(\boldsymbol x)] = -1$.
3. `LinearReactionDiffusionEquation`s: $\partial_tu= \boldsymbol\nabla\boldsymbol\cdot[D(\boldsymbol x)\boldsymbol\nabla u] +f(\boldsymbol x)u$.
3. `LinearReactionDiffusionEquation`s: $\partial_tu = \boldsymbol\nabla\boldsymbol\cdot[D(\boldsymbol x)\boldsymbol\nabla u] + f(\boldsymbol x)u$.
4. `PoissonsEquation`: $\boldsymbol\nabla\boldsymbol\cdot[D(\boldsymbol x)\boldsymbol\nabla u] = f(\boldsymbol x)$.
5. `LaplacesEquation`: $\boldsymbol\nabla\boldsymbol\cdot[D(\boldsymbol x)\boldsymbol\nabla u] = 0$.

Expand Down
Binary file modified docs/src/figures/gray_scott_patterns.mp4
Binary file not shown.
Binary file added docs/src/figures/gray_scott_patterns.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/src/figures/keller_segel_chemotaxis.mp4
Binary file not shown.
Binary file modified docs/src/figures/maze_solution_1.mp4
Binary file not shown.
Binary file modified docs/src/figures/temperature_animation.mp4
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ The [tutorials](tutorials/overview.md) in the sidebar demonstrate the many possi

1. `DiffusionEquation`s: $\partial_tu = \div[D(\vb x)\grad u]$.
2. `MeanExitTimeProblem`s: $\div[D(\vb x)\grad T(\vb x)] = -1$.
3. `LinearReactionDiffusionEquation`s: $\partial_tu + \div[D(\vb x)\grad u] + f(\vb x)u$.
4. `PoissonsEquation`: $\div[D(\vb x)\grad u] f(\vb x)$.
3. `LinearReactionDiffusionEquation`s: $\partial_tu = \div[D(\vb x)\grad u] + f(\vb x)u$.
4. `PoissonsEquation`: $\div[D(\vb x)\grad u] = f(\vb x)$.
5. `LaplacesEquation`: $\div[D(\vb x)\grad u] = 0$.

See the [Solvers for Specific Problems, and Writing Your Own](wyos/overview.md) section for more information on these templates.
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# # Gray-Scott Model: Turing Patterns from a Coupled Reaction-Diffusion System
#
# In this tutorial, we explore some pattern formation from the
# Gray-Scott model:
# ```math
# \begin{equation}
# \begin{aligned}
# \pdv{u}{t} &= \varepsilon_1\grad^2u+b(1-u)-uv^2, \\
# \pdv{v}{t} &= \varepsilon_2\grad^2 v - dv+uv^2,
# \end{aligned}
# \end{equation}
# ```
# where $u$ and $v$ are the concentrations of two chemical species. The
# initial conditions we use are:
# ```math
# \begin{align*}
# u(x, y, 0) &= 1 -\exp\left[-80\left(x^2 + y^2\right)\right], \\
# v(x, y, 0) &= \exp\left[-80\left(x^2+y^2\right)\right].
# \end{align*}
# ```
# The domain we use is $[-1, 1]^2$, and we use
# zero flux boundary conditions.
using FiniteVolumeMethod, DelaunayTriangulation
tri = triangulate_rectangle(-1, 1, -1, 1, 200, 200, single_boundary=true)
mesh = FVMGeometry(tri)

#-
bc = (x, y, t, (u, v), p) -> zero(u) * zero(v)
u_BCs = BoundaryConditions(mesh, bc, Neumann)
v_BCs = BoundaryConditions(mesh, bc, Neumann)

#-
ε₁ = 0.00002
ε₂ = 0.00001
b = 0.04
d = 0.1
u_q = (x, y, t, α, β, γ, _ε₁) -> (-α[1] * _ε₁, -β[1] * _ε₁)
v_q = (x, y, t, α, β, γ, _ε₂) -> (-α[2] * _ε₂, -β[2] * _ε₂)
u_S = (x, y, t, (u, v), _b) -> _b * (1 - u) - u * v^2
v_S = (x, y, t, (u, v), _d) -> -_d * v + u * v^2
u_qp = ε₁
v_qp = ε₂
u_Sp = b
v_Sp = d
u_icf = (x, y) -> 1 - exp(-80 * (x^2 + y^2))
v_icf = (x, y) -> exp(-80 * (x^ 2 + y^2))
u_ic = [u_icf(x, y) for (x, y) in each_point(tri)]
v_ic = [v_icf(x, y) for (x, y) in each_point(tri)]
u_prob = FVMProblem(mesh, u_BCs;
flux_function=u_q, flux_parameters=u_qp,
source_function=u_S, source_parameters=u_Sp,
initial_condition=u_ic, final_time=6000.0)
v_prob = FVMProblem(mesh, v_BCs;
flux_function=v_q, flux_parameters=v_qp,
source_function=v_S, source_parameters=v_Sp,
initial_condition=v_ic, final_time=6000.0)
prob = FVMSystem(u_prob, v_prob)

# Now that we have our system, we can solve.
using OrdinaryDiffEq, Sundials
sol = solve(prob, CVODE_BDF(linear_solver=:GMRES), saveat=10.0, parallel=Val(false))

# Here is an animation of the solution, looking only at the $v$ variable.
using CairoMakie
fig = Figure(fontsize=33)
ax = Axis(fig[1, 1], xlabel=L"x", ylabel=L"y")
tightlimits!(ax)
i = Observable(1)
u = map(i -> reshape(sol.u[i][2, :], 200, 200), i)
x = LinRange(-1, 1, 200)
y = LinRange(-1, 1, 200)
heatmap!(ax, x, y, u, colorrange=(0.0, 0.4))
hidedecorations!(ax)
record(fig, joinpath(@__DIR__, "../figures", "gray_scott_patterns.mp4"), eachindex(sol);
framerate=60) do _i
i[] = _i
end

# ![Animation of the Gray-Scott model](../figures/gray_scott_patterns.mp4)

using ReferenceTests #src
fig = Figure(fontsize=66) #src
times = [0,1000,2000,3000,4000,5000,6000] #src
t_idx = [findlast(≤(τ), sol.t) for τ in times] #src
plotij = [(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1)] #src
for (i, j) in enumerate(t_idx) #src
ax = Axis(fig[plotij[i]...], width=600,height=600, xlabel=L"x", ylabel=L"y", title="t = $(sol.t[j])") #src
heatmap!(ax, x, y, reshape(sol.u[j][2,:],200,200), colorrange=(0.0, 0.4)) #src
tightlimits!(ax) #src
end #src
plotij = [(4,1),(4,2),(4,3),(5,1),(5,2),(5,3),(6,1)] #src
for (i, j) in enumerate(t_idx) #src
ax = Axis(fig[plotij[i]...], width=600,height=600, xlabel=L"x", ylabel=L"y", title="t = $(sol.t[j])") #src
heatmap!(ax, x, y, reshape(sol.u[j][1,:],200,200), colorrange=(0.0, 1)) #src
tightlimits!(ax) #src
end #src
resize_to_layout!(fig) #src
fig #src
@test_reference joinpath(@__DIR__, "../figures", "gray_scott_patterns.png") fig #src
2 changes: 1 addition & 1 deletion docs/src/literate_wyos/diffusion_equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ fvm_prob = FVMProblem(mesh, BCs;
initial_condition,
final_time)

using LinearSolve #src
using LinearSolve

#-
# ```@example
Expand Down

This file was deleted.

Loading
Loading