# Runtime error while trying to solve a non linear equation with periodic boundary condition

Hello All,
I am trying to solve the following non linear equation with Periodic boundary condition.

u" = u + 25/(1+exp(u)) on x ∈ [0, 2*pi].

Here is my code for the same

from fenics import *

mesh_size = 10000
mesh = IntervalMesh(mesh_size, 0, L)
plot(mesh)

class PeriodicBoundary(SubDomain):
def inside(self, x, on_boundary):
return bool(x < DOLFIN_EPS and x > L-DOLFIN_EPS and on_boundary)
def map(self, x, y):
y = x - L

pbc = PeriodicBoundary()

V = FunctionSpace(mesh, "CG", 1, constrained_domain=pbc)

u = Function(V)
v = TestFunction(V)

J = derivative(F,u)

solve(F == 0, u, J=J)


However when I run this I get the following error message

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In, line 7
5 J = derivative(F,u)
----> 7 solve(F == 0, u, J=J)

File /usr/lib/petsc/lib/python3/dist-packages/dolfin/fem/solving.py:233, in solve(*args, **kwargs)
230 # Call variational problem solver if we get an equation (but not a
231 # tolerance)
232 elif isinstance(args, ufl.classes.Equation):
--> 233     _solve_varproblem(*args, **kwargs)
235 # Default case, just call the wrapped C++ solve function
236 else:
237     if kwargs:

File /usr/lib/petsc/lib/python3/dist-packages/dolfin/fem/solving.py:314, in _solve_varproblem(*args, **kwargs)
312 solver = NonlinearVariationalSolver(problem)
313 solver.parameters.update(solver_parameters)
--> 314 solver.solve()

RuntimeError:

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error:   Unable to solve nonlinear system with NewtonSolver.
*** Reason:  Newton solver did not converge because maximum number of iterations reached.
*** Where:   This error was encountered inside NewtonSolver.cpp.
*** Process: 0
***
*** DOLFIN version: 2019.2.0.dev0
*** Git changeset:  ubuntu
*** --------------------------------------------------------------------