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

Newton's method programmed manually for parabolic PDE

0 votes

Hello,
this is a question arising from this post: Newton method programmed manually. I implemented Newton's method manually as well, but the error of my solution and the solution coming from using the NonlinearVariationalSolver seems unreasonable big to me, I would expect a lot smaller error.
The definition for Newton's method is

m_old = Function(V)
m_old = interpolate(u_start,V)
m = Function(V)
m = interpolate(u_start,V)
dm = TrialFunction(V)
n = TestFunction(V)

F_M = inner(m-m_old,n)*dx + dt*dot(grad(m), grad(n))*dx - inner(dt*rhs(m),n)*dx #- dt*g_N*n*dss(2)
dF_M = derivative(F_M, m, dm)

bcs_dm = homogenize(bcs)

m_inc = Function(V)

so in each timestep I'm solving

while eps > 1e-10 and nIter < 10:
  nIter += 1
  A, b = assemble_system(dF_M, -F_M, bcs_dm)
  solve(A, m_inc.vector(), b)
  eps = norm(m_inc, 'L2')

  a = assemble(F_M)

  m.vector()[:] += m_inc.vector()

for bc in bcs:
  bc.apply(m.vector())

My output of the error error = errornorm(m, z,'l2',5) of the solution z computed by the NonlinearVariationalSolver and m reads as follows:

9.695553e-01
6.230350e-02
6.855936e-03
1.097282e-03
2.078610e-04
4.086099e-05
8.083590e-06
1.600816e-06
3.170657e-07
6.280131e-08
1.243910e-08
2.463825e-09
4.880022e-10
9.666648e-11
1.340765e-10
1.415156e-10
1.429961e-10
1.432783e-10
1.433123e-10
1.433216e-10

Am I wrong expecting a smaller error?
Thanks for your help.

closed with the note: issue solved by comment
asked Mar 6, 2014 by bobby53 FEniCS User (1,260 points)
closed Mar 10, 2014 by bobby53

You haven't said what make you think the error is large, and you haven't said how you generated the sequence of errors that you report.

Hey Garth,
I used error = errornorm(m, z,'l2',5), where m is the solution of my own Newton method and z the one of the NonlinearVariationalSolver. I compared the two solutions with a given problem with analytic solution, and the error was much smaller. So I guess it what just an unlucky pick for an example which lead to this "large" error.
With large I meant that I expected the error to be around something E-12, which, as you can see, wasn't the case.

Try reducing the tolerance for the Newton solver.

...