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

How to write Neumann conditions with non-linear term of "u"?

0 votes

In the "Multiple Neumann, Robin, and Dirichlet Condition" of the tutorial.
It use a boundary condition that with "u":

$-\frac{\partial u}{\partial n}=p(u-q)$ on $\Gamma_R$

And the correspond code is :

a = inner(nabla_grad(u), nabla_grad(v))*dx + p*u*v*ds(0)
L = f*v*dx - g*v*ds(1) + p*q*v*ds(0)

Now i want a boundary condition that with nonlinear form of "u", for example:

$-\frac{\partial u}{\partial n}=p(u^2-q)$ on $\Gamma_R$

I changed the code to:

a = inner(nabla_grad(u), nabla_grad(v))*dx + p*u*u*v*ds(0)
L = f*v*dx - g*v*ds(1) + p*q*v*ds(0)

It cannot work. So what's the right way to do this? Thank you very much.

asked Jul 25, 2013 by Asymptote FEniCS Novice (150 points)

1 Answer

+4 votes
 
Best answer

This is no more linear problem - observe that a depends also on u*u. You can try

  • fixed-point iteration

    u0 = Function(V)
    a = inner(nabla_grad(u), nabla_grad(v))*dx + p*u0*u*v*ds(0)
    
    u = Function(V)
    until convergence:
         u0.assign(u)
         solve(a == L, u, bcs)
    

    where you need to supply convergence condition.

  • Newton method

    u = Function(V)
    F = inner(nabla_grad(u), nabla_grad(v))*dx + p*u*u*v*ds(0) \
        - f*v*dx - g*v*ds(1) + p*q*v*ds(0)
    J = derivative(F, u)
    solve(F == 0, u, bcs, J)
    
answered Jul 25, 2013 by Jan Blechta FEniCS Expert (51,420 points)
selected Aug 8, 2013 by Jan Blechta
...