# How to Set Up Boundary Conditions in your Simulation?

Choosing realistic **boundary conditions** is one of the most important and challenging parts of setting up a simulation. It is not necessarily a difficult task to find a combination, that works. But then we are producing random numbers instead of meaningful results.

This raises the question: what is the *right* boundary condition, and what kind of magic should I master to find it? In the following, we will review the basics you need to take informed decisions when it comes to boundary conditions.

**Dirichlet, Neumann or Robin? **

Quite expectedly, there is often not one right answer, but several boundary conditions that make sense. It is up to you to choose something that serves the purpose of the simulation best. Therefore, you first should answer what the expected behaviour in the real world is. Secondly, you should understand how such behaviour is modelled in the software you are using.

The challenge lies in the fact that there is never a one-to-one mapping between these two worlds. Therefore, it would be helpful to learn a bit more about the theory behind each type of boundary condition. Then you can establish a meaningful correlation between the phenomenon you want to simulate and what your software offers.

Boundary conditions bring the influence of the outside world into the simulation domain. On the theoretical level, they are constraints applied to the governing equations of the system and are categorized accordingly:

**Dirichlet boundary condition**specify the value of a variable at a boundary. It might also be called a fixed condition. Therefore, it is used when we want to impose a**value**at a boundary. For Example, a no-slip condition in fluid mechanics is a Dirichlet condition because it sets the value of the velocity to zero. In solid mechanics, prescribing a certain load or displacement, and in heat transfer, setting the temperature at a surface are other examples of this type of condition.**Neumann boundary condition**specify the derivative of a variable at a boundary. It is used when, rather than the actual value, we want to impose a certain**rate of change**in value for a variable. A common example in fluid mechanics is the fully developed condition at an outlet where the gradient of flow variables is set to zero. Traction conditions in solid mechanics and insulated surfaces in heat transfer are other examples.**Robin boundary condition**specify a combination of the value and the derivative of a variable at a boundary. Therefore, these conditions are suited for more complex behaviour. For example, in heat transfer, Robin conditions are used to model the Newton’s law of cooling, where heat flux (derivative) is proportional to temperature (value). However, Robin conditions are not the only class of boundary conditions that utilize value and derivative to specify a condition, but we will not get into that here.**There are other boundary****conditions**that exploit certain flow features. For example, in scenarios where the domain features spatial symmetry, the size of the domain, and therefore the computational effort, is reduced by using symmetry boundaries. Similarly, periodic conditions are used to simulate periodicity effects without having to run computations on the full domain. So you can use boundary conditions effectively to gain an advantage.

### Testing your Boundary Conditions Choice

It is now easier to approach the problem methodically. Once you have pinned down the type of condition you should use, it is time to test your hypothesis in detail. Here is an example: let us assume a simple case of incompressible pipe flow. Given a flow rate, we want to calculate the pressure drop between the inlet and outlet.

Would this problem have a unique answer? No. As you see in the following Figure, the choice of the velocity profile will affect pressure drop. In this case, the uniform velocity profile at inlet results in an 18% larger pressure drop.

Even though the boundary condition type is chosen correctly, your decision of inlet profile will change the result of the simulation noticeably. Therefore, make sure to examine all aspects of your setup thoroughly.

In the end, it is not always feasible to make a call without actually running any simulations. Therefore, it would be helpful to run your simulation with different combinations in a controlled setup and study the validity of each result.

Such a setup should be simple enough so the influence of the boundary condition choice could be meaningfully interpreted. Once a certain choice has proven successful, you can use it in the full simulation.

Finally, in addition to knowledge, an experienced analyst relies on the knowledge he gained from running multiple simulations. So, do not be afraid to experiment with your simulations, because practice makes the master!