Neumann and Dirichlet BCs for a PDE system

Hi there, I am trying to solve a system of 4 coupled PDEs on a square. The boundary is divided into 4 edges:

def C1(x):

return x[0] > 1.0-DOLFIN_EPS

def C2(x):

return x[1] > 1.0-DOLFIN_EPS

def C3(x):

return x[0] < -1.0+DOLFIN_EPS

def C4(x):

return x[1] < -1.0+DOLFIN_EPS

The system of equations are given by

F1 = inner(grad(f1),grad(v1))*dx + ((f1*f1+f2*f2-1.0)*f1 - (f3*f3-f4*f4))*v1*dx
F2 = inner(grad(f2),grad(v2))*dx + ((f1*f1+f2*f2-1.0)*f2 - f3*f4)*v2*dx
F3 = inner(grad(f3),grad(v3))*dx + ((f3*f3+f4*f4-1.0)*f3 - (f1*f3+f2*f4))*v3*dx
F4 = inner(grad(f4),grad(v4))*dx + ((f3*f3+f4*f4-1.0)*f4 - (f2*f3-f1*f4))*v4*dx

F = F1 + F2 + F3 + F4

The variational solver outputs 4 functions (f_1,f_2,f_3,f_4) and I want to know how to implement the following boundary conditions.
f_1=-1, \, f_2=0,\, \frac{\partial f_3}{\partial x}=0,\, \frac{\partial f_4}{\partial x}=0 on C_1,
f_1=1,\, f_2=0,\, \frac{\partial f_3}{\partial x}=0, \,\frac{\partial f_4}{\partial x}=0 on C_2,
f_1=-1,\, f_2=0,\, \frac{\partial f_3}{\partial y}=0,\, \frac{\partial f_4}{\partial y}=0 on C_3,
f_1=1,\, f_2=0,\, \frac{\partial f_3}{\partial y}=0,\, \frac{\partial f_4}{\partial y}=0 on C_1.

Please format code by encapsulating it with ```
And latex with $ to make the problem readable.
To add boundary conditions to the corresponding PDEs, these needs to be stated as well.

1 Like

You weak formulation looks like several Poisson type equations with an Extra coupling term per PDE. The boundary condition only stem from integration by parts or strong imposition of Dirichlet conditions, as shown here: https://bitbucket.org/fenics-project/dolfin/src/master/python/demo/documented/poisson/demo_poisson.py.rst

As all the neumann conditions are 0, they dissapear from the variational form (as has happened in your weak form above). This you only Need to add Dirichlet conditions

That makes sense, any advice on how to implement that?
Iā€™m getting the following error:

*** Error:   Unable to define nonlinear variational problem F(u; v) = 0 for all v.
*** Reason:  Expecting the boundary conditions to to live on (a subspace of) the trial space.

You Need to supply a minimal working example, with the function space and corresponding sub spaces for f1,f2,f3 and f4 defined for anyone to help you further.
The minimal example should produce the error message, and be reduced to a small a code as possible (i would start with only coupling two equations, as when you Get the correct implementation, it is easy to abstract.)