Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Commit

Permalink
Test set added
Browse files Browse the repository at this point in the history
  • Loading branch information
mjsheikh committed Feb 7, 2021
1 parent 61366b5 commit a48d7a8
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 48 deletions.
46 changes: 0 additions & 46 deletions examples/Fast_Diffusion.jl

This file was deleted.

2 changes: 0 additions & 2 deletions src/derivative_operators/derivative_operator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ struct DerivativeOperator{T<:Real,N,Wind,T2,S1,S2<:SArray,T3,F} <: AbstractDeriv
coeff_func :: F
end

struct NonLinearDiffusion! end

function NonLinearDiffusion!(du::AbstractVector{T}, second_differential_order::Int, first_differential_order::Int, approx_order::Int,
p::AbstractVector{T}, q::AbstractVector{T}, dx::Union{T , AbstractVector{T} , Real},
nknots::Int) where {T<:Real, N}
Expand Down
50 changes: 50 additions & 0 deletions test/Fast_Diffusion.jl
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

0 comments on commit a48d7a8

Please sign in to comment.