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.