Let's say I have
mesh = UnitIntervalMesh(10)
Q = FunctionSpace(mesh,'CG',1)
u = Function(Q) #potential
V = Constant(1.0) #bias
mu = Constant(1.0)
R = Constant(1.0) #contact resistance
n = Function(Q) # but n is usually a complicated ufl form of u
J = mu*n*grad(u) #current
I want to write a form to solve
J(0) = (V-u(0))/R
I tried something like
v = TestFunction(Q)
du = TrialFunction(Q)
facet_normal = FacetNormal(mesh)
F = (V-u)/R -inner(J,facet_normal)
F = F*v*ds(marker_0)
dF = derivative(F,u,du)
problem = NonlinearVariationalProblem(F=F, u=u, bcs=[], J=dF)
solver = NonlinearVariationalSolver(problem)
solver.solve()
But this does not solve and gives me
Solving nonlinear variational problem.
Solving linear system of size 269 x 269 using Epetra LU solver (Amesos_Klu).
Newton iteration 0: r (abs) = 0.000e+00 (tol = 1.000e-06) r (rel) = -nan (tol = 1.000e-30)
Newton solver finished in 1 iterations and -22 linear solver iterations.
Obviously I am not using the right form so maybe someone has a better idea.