This repository has been archived by the owner on Jul 19, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
50 additions
and
48 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# # Fast-Diffusion Problem | ||
# | ||
# This example demonstrates the use of 'NonLinearDiffusion' operator to solve time-dependent non-linear diffusion PDEs with coefficient having dependence on the unknown function. | ||
# Here we consider a fast diffusion problem with Dirichlet BCs on unit interval: | ||
# ∂ₜu = ∂ₓ(k*∂ₓu) | ||
# k = 1/u² | ||
# u(x=0,t) = exp(-t) | ||
# u(x=1,t) = 1/(1.0 + exp(2t)) | ||
# u(x, t=0) = u₀(x) | ||
using Test | ||
using DiffEqOperators, OrdinaryDiffEq | ||
|
||
@testset "1D Nonlinear fast diffusion equation" begin | ||
# The analytical solution for this is given by : | ||
|
||
u_analytic(x, t) = 1 / sqrt(x^2 + exp(2*t)) | ||
|
||
# | ||
# Reproducing it numerically | ||
# | ||
|
||
|
||
nknots = 100 | ||
h = 1.0/(nknots+1) | ||
knots = range(h, step=h, length=nknots) | ||
n = 1 # Outer differential order | ||
m = 1 # Inner differential order | ||
approx_ord = 2 | ||
|
||
u0 = u_analytic.(knots,0.0) | ||
du = similar(u0) | ||
t0 = 0.0 | ||
t1 = 1.0 | ||
|
||
function f(du,u,p,t) | ||
bc = DirichletBC(exp(-t),(1.0 + exp(2*t))^(-0.5)) | ||
l = bc*u | ||
k = l.^(-2) # Diffusion Coefficient | ||
NonLinearDiffusion!(du,n,m,approx_ord,k,l,h,nknots) | ||
end | ||
|
||
prob = ODEProblem(f, u0, (t0, t1)) | ||
alg = KenCarp4() | ||
sol = solve(prob,alg) | ||
|
||
for t in t0:0.1:t1 | ||
@test u_analytic.(knots, t) ≈ sol(t) rtol=1e-3 | ||
end | ||
|
||
end |