Skip to content

Some instability in solving 1-d Fisher-KPP equation  #115

@00krishna

Description

@00krishna

Hey @xtalax , so I was doing a little test for solving the Fisher-KPP equation. I am seeing a little instability or dispersion on the left side of the attached GIF file. It does not seem too bad, but I was wondering if there was a way to fix it. Do you think this is an artifact of plotting, or something to do with the solver?

The code is below.

# 1D Fisher Kolmogorov-Petrovsky-Piskunov equation 

# Packages and inclusions
using ModelingToolkit, MethodOfLines, LinearAlgebra, DomainSets
using DifferentialEquations
using ModelingToolkit: Differential
using Plots

# Variables, parameters, and derivatives
@parameters t x
@variables u(..)
Dx = Differential(x)
Dxx = Differential(x)^2
Dt = Differential(t)

t_min= 0.
t_max = 1.
x_min = 0.
x_max = 1.
D = 1.0
s = 6.0

# Equation
eq = Dt(u(t,x)) ~ D*Dxx(u(t,x)) + s*u(t,x)*(1 - u(t, x)) 

# Initial and boundary conditions
bcs = [u(t_min,x) ~ 1/(1 + exp(x))^2,
        u(t,x_min) ~ 1/(1 + exp(5*t))^2,
        u(t,x_max) ~ 1/(1 + exp(1 - 5*t))^2]

# Space and time domains
domains = [t ∈ Interval(t_min,t_max),
            x ∈ Interval(x_min,x_max)]

# PDE system
@named pdesys = PDESystem([eq],bcs,domains,[t,x],[u(t,x)])

# Method of lines discretization
dx = 0.01
discretization = MOLFiniteDifference([x=>dx],t)
prob = ModelingToolkit.discretize(pdesys,discretization)

# Solution of the ODE system

sol = solve(prob,Rosenbrock32())

anim = @animate for i ∈ 1:last(size(sol))
    plot(sol'[i, :])
end

gif(anim, "fisher_kpp_equation.mp4", fps=30)
fisher_kpp_equation.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions