Boundary conditions¶
PyFVTool uses a unified Robin boundary condition form for all boundaries:
where \(\mathbf{e}\) is the unit vector in the direction of the coordinate axis at the specific boundary. By choosing \(a\), \(b\) and \(c\) (taking into account the direction of the axis), all common boundary condition types are recovered:
BC type |
\(a\) |
\(b\) |
\(c\) |
|---|---|---|---|
Dirichlet (fixed value \(\phi_0\)) |
|
|
|
Neumann (fixed flux \(q\)) |
|
|
|
No-flux (closed boundary) |
|
|
|
Robin |
any |
any |
any |
The default boundary condition on all faces is no-flux (\(a=1\), \(b=0\), \(c=0\)).
Setting boundary conditions¶
Boundary conditions are stored on the CellVariable object, in its .BCs attribute.
c = pf.CellVariable(mesh, initial_value)
For a 1D mesh, the available boundaries are .left and .right, and their \(a\), \(b\) and \(c\) coefficients can be set explicitly:
# Dirichlet: fix concentration to 5.0 at the left boundary
c.BCs.left.a = 0.0
c.BCs.left.b = 1.0
c.BCs.left.c = 5.0
# Neumann: fixed gradient of 0.5 at the right boundary
c.BCs.right.a = 1.0
c.BCs.right.b = 0.0
c.BCs.right.c = 0.5
For 2D meshes, the available boundaries are .left, .right, .bottom, .top.
For 3D meshes, .back and .front are added.
Convenient utility methods for setting BCs¶
There are convenient utility methods for directly setting Dirichlet (fixedValue) and Neumann (fixedGradient) boundary conditions.
# Dirichlet: fix concentration to 5.0 at the left boundary
c.BCs.fixedValue(5.0)
# Neumann: fixed gradient of 0.5 at the right boundary
c.BCs.fixedGradient(0.5)
Another utility method, newtonCooling sets the specific Robin BCs corresponding to Newton’s law of cooling in heat transfer modeling.
Periodic boundary conditions¶
Periodic BCs can be specified where appropriate. Consult the examples notebooks for details.