This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Problems with solving Fisher's equation

+1 vote

Hi. I am trying to solve the Fisher's equation using the FEniCS library. Here is the code I am using:

from fenics import *

mesh = UnitSquareMesh(32, 32)
V = FunctionSpace(mesh, "CG", 1)


g = Expression('1 - (x[0] - 0.5) * (x[0] - 0.5) - (x[1] - 0.5) * (x[1] - 0.5)', degree=2)

u = TrialFunction(V)
v = TestFunction(V)
u_k = interpolate(g, V)
u_k1 = Function(V)
dt = 0.1
a = u * v * dx + dt * inner(grad(u), grad(v)) * dx - dt * u * (1 - u) * v * dx
L = u_k * v * dx

t = 0.0
while t <= 1.8:
    solve(a == L, u_k1)
    u_k.assign(u_k1)
    t += float(dt)

plot(u_k)
interactive()

When run it throws the following exception:

ArityMismatch: Multiplying expressions with overlapping form argument number 1, argument is v_1.

The problem is with my definition of a:

a = u * v * dx + dt * inner(grad(u), grad(v)) * dx - dt * u * (1 - u) * v * dx

If I change it to something like

a = u * v * dx + dt * inner(grad(u), grad(v)) * dx - dt * u * v * dx

then it works (the program runs fine but this solution is obviously not the correct one). It ends with the same exception even if I change it to

a = u * v * dx + dt * inner(grad(u), grad(v)) * dx - dt * u * u * v * dx

So the problem arises if there is a term of form u * u or v * v or something equivalent. Why is this happening and how can I help it?

Thanks.

asked Feb 10, 2017 by f4bb FEniCS Novice (130 points)

1 Answer

+2 votes

Fisher's equation is nonlinear. You have set up your system as if it were a linear problem. You should examine the nonlinear Poisson demo as an example of using Newton's method to approximate the solution of such a system.

answered Feb 10, 2017 by nate FEniCS Expert (17,050 points)
...