I want to extend the Cahn Hilliard demo to include flux boundary conditions at the boundaries. I'm using it to model the diffusion of protons into a metal oxide and its reduction. The two phases would correspond to a "oxidesed" (starting) and "reduced" phase.
The boundary conditions are:
-Mc grad(mu) = J (Flux)
-Mc(dmu/dc)*grad(c) = J (Flux, again, but recast in the common Fick's law formulation). Correspondingly, the ONLY changes to the Cahn-Hilliard demo are adding the boundary integral Neumann boundary conditions and the free-energy functional and defining the function d\mu/dc:
f = 10*(c-0.10)**2*(c-0.90)**2
dfdc = diff(f,c)
dmudc = diff(dfdc, c)
#Weak statement of the equations
L0 = c*q*dx - c0*q*dx + dt*(-dot(grad(M*c),grad(mu_mid))*q + M*dot(grad(mu_mid),grad(c*q)) )*dx - dt*(-J_p*q*ds)
L1 = mu*v*dx - dfdc*v*dx - lmbda*dot(grad(c), grad(v))*dx + (lmbda*(-J_p/(M*c*dmudc)) *v*ds)
L = L0 + L1
I'm trying with very small values of J_p (1e-8, 1e-9 etc).The model runs for a very short time (~200 time steps or so) but crashes with a RuntimeError for the solver.solve call. I've not changed the solver parameters from the what was in the CahnHilliard demo.
The complete error message:
Traceback (most recent call last):
File "../Cahn_Hilliard_WithBC.py", line 177, in
solver.solve(problem, u.vector())
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
*** https://answers.launchpad.net/dolfin
*** 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. Bummer.
*** Where: This error was encountered inside NewtonSolver.cpp.
*** -------------------------------------------------------------------------
Dolfin version: 1.0.0.
Thanks,
Sumanth