problem solving a simple system of nonlinear equations
I have a simple system of two equations, both with Dirichlet boundary conditions on a 1-D domain. This is part of a larger system of equations, but right now I just need to solve these two.
Eq1: del^2(conc) = 0
Eq2: grad(phi) - 2/conc*grad(conc) = 0
analytically,
conc = Ax + B
phi = 2*log(x + B/A) + C
I've tried to use the built-in Newton solver but no matter what I do, I can't get the solver to converge. Help will be much appreciated. Thank you!
mesh = Interval(100, 0, 1)
V = FunctionSpace(mesh, 'CG', 1)
ME = MixedFunctionSp
u = Function(ME)
du = TrialFunction(ME)
conc, phi2 = split(u)
dconc, dphi2 = split(du)
v3, v4 = TestFunctions(ME)
def left(x, on_boundary):
return near(x[0], 0.0)
def right(x, on_boundary):
return near(x[0], 1.0)
bc3a = DirichletBC(
bc3b = DirichletBC(
bc4 = DirichletBC(
bc = [bc3a, bc3b, bc4]
def q(conc):
return 2.0/conc
L3 = -inner(grad(conc), grad(v3))*dx
L4 = grad(phi2)*v4*dx - q(conc)
L = L3 + L4
# a3 = inner(grad(dconc), grad(v3))*dx
# a4 = grad(dphi2)*v4*dx + Constant(
a = derivative(L, u, du)
problem = NonlinearVariat
solver = NonlinearVariat
# solver.
# solver.
solver.solve()
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Marie Rognes
- Solved:
- Last query:
- Last reply: