Search code examples
pythonfipy

Default boundary condition implementation for 1D diffusion equation equation in FiPy


I am trying to solve a 1D heat transfer equation using FiPy. The documentation states that If no boundary conditions are specified on exterior faces, the default boundary condition is equivalent to a zero gradient

If I want to apply a zero gradient to the left face should I eliminate the boundary condition code for the left face? Will the code code below automatically apply a zero constrain boundary condition for the left face?

# User defined Boundary Condition for the right face
valueRight = 100
phi.constrain(valueRight, mesh.facesRight)

This is my first time working in python and FiPy. Any help will be really appreciated.


Solution

  • The default boundary condition is zero flux. That often translates to zero gradient, but it doesn't have to and it can be misleading to assume they're the same thing.

    If all you specify is

    valueRight = 100
    phi.constrain(valueRight, mesh.facesRight)
    

    then you will have a Neumann (zero flux) condition on the left and a Dirichlet (fixed value) condition on the right.