# 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:

problem illustration image

The PDE governing this problem is given by the following:

PDE governing the problem and BC conditions

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)?

BC at the Western coin

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?

EDIT: Pseudo-code

For all points contained in my domain except the well and boundary points:
Apply (1) S * du/dt = T * d2u/dx2 + w

At my well level (Neumann boundary condition)
Apply (2) S * du/dt = T * d2u/dx2 + q

At my boundary points (Left and rigth) -> Neumann condition
q = Tdu/dx -> discretize and replace it in (3)
(3) S * du/dt = T * d2u/dx2


Is it right?

• As a quick answer: 1) You divided your domain into cells; and the inflow of 'w' likely just corresponds to adding it (whatever it represents) to appropriate 'u_i' cell/node. Make sure that the units are correct when you do that. 2) They should definitely be incorporated into your discrete equations, as I notice you are solving an implicit FD problem which typically has no solution unless the boundary conditions are specified. 3) I don't understand your question (where does the formulation come from, what do you mean with 'qa', how does the fictitious y axis come into play?). Can you clarify?
– Erik
Oct 23, 2021 at 21:07
• Incidentally, if you look online for "implicit finite-difference for 1D heat equation" you'll find a lot of material to solve the same equation as you're solving.
– Erik
Oct 23, 2021 at 21:19
• @Erik thank you for your answer and also for the link. What I would like to know is: if I have a 1D aquifer that receives recharge everywhere and zero flow in the East and West boundaries as well as pumping in the middle, how should I represent my problem mathematically? Should I apply the discrete form of the equation in all cells without the source / sink terms and modify the discrete form to include the conditions imposed at the appropriate points? Oct 23, 2021 at 21:28
• the source/sink term should've been part of the PDE from the get-go, en.wikipedia.org/wiki/… , so the "receiving recharge everywhere and pumping in the middle" are all part of variable "G" at the Wikipedia link. So you can discretize the PDE form without modification (though I'm not sure what you mean with that exactly. BTW, if you share your current code, it'll be easier to discuss where you are more vs where you are less stuck. Does your code work? Does it not?).
– Erik
Oct 24, 2021 at 7:03
• @Erik I added a pseudo-code. Is it right to do that like presented above? Oct 24, 2021 at 13:00

In any solution to a PDE, whether analytical or numerical, you will always need as many BCs as the number of derivative steps. For examples:

$$dY/dt = k Y$$

needs one BC while

$$\partial Y/\partial t = k \nabla^2 Y$$

needs three BCs. The second case is germane to your problem. You will need one BC on time $$t$$ because one derivative is on time. You will need two independent BCs on position because two derivatives are applied on position.

We set BCs to make an otherwise general equation apply specifically to the physical system at hand. For heat transfer problems, viable conditions can include the following:

Time Domain

• temperature at a given time

Spatial Domain

• temperature at a given location
• heat flux at a given location

In regard to the spatial domain in a 1-D flow, one cannot set a heat flux BC at one point and set a heat flux BC at a second location. The two BCs are not independent. They are tied together by an energy balance on the overall system or across any spatial extent in the system.

1. The system as illustrated is being modeled in a way that is equivalent to a 1-D fin. The heat flow $$w$$ into the component is "lumped". The temperature gradient in the component along its axis is ignored. You could easily have one cell along that direction and simplify the analysis. You have no BCs on that direction. Your alternative is to switch to a 2-D model to include the heat flow in the component along the $$y$$ direction. The "topmost" cell takes $$w$$ in and distributes it along $$x$$ and $$y$$. The bottom-most cell takes heat from the topmost cell and distributes it along $$x$$ (presuming the bottom is insulated).