<p>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:</p>
<p><span class="math-container">$$dY/dt = k Y$$</span></p>
<p>needs one BC while</p>
<p><span class="math-container">$$\partial Y/\partial t = k \nabla^2 Y$$</span></p>
<p>needs three BCs. The second case is germane to your problem. You will need one BC on time <span class="math-container">$t$</span> because one derivative is on time. You will need two <em>independent</em> BCs on position because two derivatives are applied on position.</p>
<p>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:</p>
<p><strong>Time Domain</strong></p>
<ul>
<li>temperature at a given time</li>
</ul>
<p><strong>Spatial Domain</strong></p>
<ul>
<li>temperature at a given location</li>
<li>heat flux at a given location</li>
</ul>
<p>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.</p>
<p>Now, specifically to your questions.</p>
<ol>
<li><p>The system as illustrated is being modeled in a way that is equivalent to a 1-D fin. The heat flow <span class="math-container">$w$</span> into the component is &quot;lumped&quot;. 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 <span class="math-container">$y$</span> direction. The &quot;topmost&quot; cell takes <span class="math-container">$w$</span> in and distributes it along <span class="math-container">$x$</span> and <span class="math-container">$y$</span>. The bottom-most cell takes heat from the topmost cell and distributes it along <span class="math-container">$x$</span> (presuming the bottom is insulated).</p>
</li>
<li><p>The BCs are defined independently of the equations. In analytical evaluations, they are used to obtain the constants in the general integrations steps to the partial differential equation. In the numerical evaluations, they are used to initialize the computational routines or to pass solutions from one cell to another properly.</p>
</li>
<li><p>We apply a BC on heat flow after the first spatial integration. We apply a spatial BC on temperature after the second spatial integration. We apply a temporal BC on temperature after the integration on time. You seem to be trying to incorporate the BCs directly into the general equation.</p>
</li>
</ol>

CC BY-SA 4.0
2021-10-27T15:14:10.777Z
Thank you for your detailed answer. So it's a bad idea to incorporate BCs directly into the equation? Isn't it ever done to incorporate them?
narutoArea51
CC BY-SA 4.0
2021-10-27T15:53:49.137Z
Use BCs to obtain the specific values for the constants to the general analytical solutions when integrating a PDE. Use BCs to set initial numerical values or to match numerical values at boundaries of a cell during numerical integrations of a PDE.
Jeffrey J Weimer
CC BY-SA 4.0
2021-10-25T13:48:22.193Z
2021-10-25T13:48:22.193Z
Jeffrey J Weimer
<p>I'm new to numerical modeling and trying to figure out how things work inside business codes.</p>
<p>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:</p>
<p><a href="https://i.sstatic.net/X9uQ4.png" rel="nofollow noreferrer">problem illustration image</a></p>
<p>The PDE governing this problem is given by the following:</p>
<p><a href="https://i.sstatic.net/u9F5x.png" rel="nofollow noreferrer">PDE governing the problem and BC conditions</a></p>
<p>Questions</p>
<ol>
<li><p>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?</p>
</li>
<li><p>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)?</p>
</li>
</ol>
<p><a href="https://i.sstatic.net/VERN4.png" rel="nofollow noreferrer">BC at the Western coin</a></p>
<ol start="3">
<li>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?</li>
</ol>
<p>Thank you in advance!</p>
<p><strong>EDIT: Pseudo-code</strong></p>
<pre><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) -&gt; Neumann condition
    q = Tdu/dx -&gt; discretize and replace it in (3)
    (3) S * du/dt = T * d2u/dx2
</code></pre>
<p>Is it right?</p>

CC BY-SA 4.0
2021-10-23T21:07:15.647Z
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
CC BY-SA 4.0
2021-10-23T21:19:03.880Z
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
CC BY-SA 4.0
2021-10-23T21:28:34.767Z
@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?
narutoArea51
CC BY-SA 4.0
2021-10-24T07:03:49.827Z
the source/sink term should've been part of the PDE from the get-go, https://en.wikipedia.org/wiki/Groundwater_flow_equation#Diffusion_equation_(transient_flow) , 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
CC BY-SA 4.0
2021-10-24T13:00:42.737Z
@Erik I added a pseudo-code. Is it right to do that like presented above?
narutoArea51
<hydrology><numerical-modelling><hydrogeology>
How are boundary conditions considered in PDEs?
narutoArea51
# How are boundary conditions considered in PDEs?

(Asked by: username_0 on 2021-10-23)

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](https://i.sstatic.net/X9uQ4.png)

The PDE governing this problem is given by the following:

[PDE governing the problem and BC conditions](https://i.sstatic.net/u9F5x.png)

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](https://i.sstatic.net/VERN4.png)

3. 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?

Thank you in advance!

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

**Tags:** hydrology, numerical-modelling, hydrogeology

> **Comments:**
> **username_1**: 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?  
> **username_1**: 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.  
> **username_0**: @username_1 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?  
> **username_1**: the source/sink term should've been part of the PDE from the get-go, https://en.wikipedia.org/wiki/Groundwater_flow_equation#Diffusion_equation_(transient_flow) , 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?).  
> **username_0**: @username_1 I added a pseudo-code. Is it right to do that like presented above?  

---

## 1 answers

### Answer by username_2 on 2021-10-25. Score: 6 | Accepted answer

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.

Now, specifically to your questions.

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).
2. The BCs are defined independently of the equations. In analytical evaluations, they are used to obtain the constants in the general integrations steps to the partial differential equation. In the numerical evaluations, they are used to initialize the computational routines or to pass solutions from one cell to another properly.
3. We apply a BC on heat flow after the first spatial integration. We apply a spatial BC on temperature after the second spatial integration. We apply a temporal BC on temperature after the integration on time. You seem to be trying to incorporate the BCs directly into the general equation.

> **Comments:**
> **username_0**: Thank you for your detailed answer. So it's a bad idea to incorporate BCs directly into the equation? Isn't it ever done to incorporate them?  
> **username_2**: Use BCs to obtain the specific values for the constants to the general analytical solutions when integrating a PDE. Use BCs to set initial numerical values or to match numerical values at boundaries of a cell during numerical integrations of a PDE.  

---

