# How are boundary conditions considered in PDEs?

I'm new to numerical modeling and trying to figure out how things work inside business codes.

Consider a 1D domain divided into small cells of width $$dx$$ and at the East and West a Neumann conditions boundary is affected (zero flow in the East and constant in the West). In the center, we have an upward outgoing flow. Here is an illustration image: The PDE governing this problem is given by the following: Questions

1. The model is in 1D and the flow $$w$$ is done along the fictitious axis $$y$$. How do we define it as a boundary condition in our model?

2. Are the defined boundary conditions calculated independently of the PDEP or should they be incorporated into the discrete form of the EDP as below (example with q2)? 1. I also question the correctness of the formulation of the condition on qa. Indeed, it is an outgoing flow towards the outside (thus according to the fictitious axis $$y$$). Is my way of writing it correct?

A popular method is called finite difference. This explains it clearly.

Essentially, we first divide the line (or plane or space in higher dimensions) into a preset number of subdivisions of grid-length $$\Delta$$x each. We can then define an analog for the first derivative (for example) as follows:

$$\frac{\Delta f}{\Delta x} := \frac{f(i+1) - f(i-1)}{2\Delta x}$$

The boundary condition is then enforced by presetting the initial value and then simply skipping the update for the zeroth-index i and the last index i along the grid. When we time-update, we update only the index range

for (i=1; i<N-1; i++) {...} for array with index starting at 0.


This leaves the 0th i and the last i along our predefined grid array unchanged forever, which gives us the practical definition of a boundary condition.

More ref on here.

• @Ruslan thank you!
– user315366
Oct 23, 2021 at 23:11