# How to solve $y''(x) + \alpha = 0$ using the Finite volume method for one-dimensional steady state diffusion?

I am sharing something that I am seeing for the first time.

I must solve the following boundary value problem \begin{align} \begin{cases} &y''(x)+ \alpha = 0, \ x \in I = [0,1], \ \alpha:= \text{constant}\\ &y(0)=1, \ y(1)=0. \end{cases} \end{align} using the finite volume method. In particular, I am asked to:

1. Take a uniform partition of $$I$$ and use it to model the DE above using the finite volume method.
2. Explain the linear-algebraic system that arises from said modeling.
3. Under what conditions has the algebraic system only one solution?

Generally I know how to approach this. However I must use the $$1$$D finite volume method.

# OVERVIEW OF FINITE VOLUME METHOD

What I know is that we must bring the system to the form \begin{align} \begin{cases} &\dfrac{d}{dx} \left( \Gamma \dfrac{dy}{dx} \right) + S_y = 0, \ x \in [0,1]\\ &y(0) = y(L) = c \end{cases} \end{align} and we must split the section $$[0,1]$$ into uniform intervals like so: \begin{align} &\int_{CV}\dfrac{d}{dx} \left( \Gamma \dfrac{dy}{dx} \right)dx + \int_{CV}S dx=0\\ \implies &\Gamma \dfrac{dy}{dx}\bigg|_{\rho} - \Gamma \dfrac{dy}{dx} \bigg|_{\omega} + S \Delta x = 0\\ \implies &\Gamma_{\rho} \dfrac{dy}{dx}\bigg|_{\rho} - \Gamma_{\omega} \dfrac{dy}{dx} \bigg|_{\omega} + S \Delta x = 0\\ \implies &\Gamma_{\rho} \left(\dfrac{\Phi_{\epsilon} - \Phi_{\rho}}{\Delta x} \right) - \Gamma_{\omega} \left( \dfrac{\Phi_{\rho} - \Phi_{\omega}}{\Delta x} \right) + S \Delta x = 0. \end{align}

At this point we take $$\Gamma_{\rho} = \Gamma_{\omega} = \Gamma$$ and \begin{align} &\dfrac{\Gamma}{\Delta x} \left( \Phi_{\epsilon} -\Phi_{\rho} - \Phi_{\rho} + \Phi_{\omega} \right) + S \Delta x = 0\\ \implies &\dfrac{\Gamma}{\Delta x} \left( \Phi_{\epsilon} -2\Phi_{\rho} + \Phi_{\omega} \right) + S \Delta x = 0 \end{align} which creates a differential equation of differences as so: \begin{align} \alpha_{\rho}\Phi_{\rho} = \alpha_{\omega}\phi_{\omega}+ \alpha_{\epsilon} \phi_{\epsilon} + S_{u}. \end{align}

Now generally this should give us a linear system like so: \begin{align} &\alpha_1 \phi_1 - \alpha_2 \phi_2 - \alpha_0 \phi_0 = S_{\phi_1}\Delta x\\ &\alpha_2 \phi_2 - \alpha_3 \phi_3 - \alpha_1 \phi_1 = S_{\phi_2}\Delta x\\ &\alpha_3 \phi_3 - \alpha_4 \phi_4 - \alpha_2 \phi_2 = S_{\phi_3}\Delta x\\ &\alpha_4 \phi_4 - \alpha_1 \phi_1 - \alpha_3 \phi_3 = S_{\phi_4}\Delta x \end{align} where $$\alpha_0 \phi_0, \ \alpha_1 \phi_1$$ are known.

In linear equation form, we have \begin{align} \begin{pmatrix} \alpha_1 & -\alpha_2 & 0 & 0\\ -\alpha_1 & \alpha_2 & \alpha_3 & 0\\ 0 & -\alpha_2 & \alpha_3 & \alpha_4\\ 0 & 0 & -\alpha_3 & \alpha_4\\ \end{pmatrix} \begin{pmatrix} \phi_1 \\ \phi_2 \\ \phi_3 \\ \phi_4\\ \end{pmatrix} = \begin{pmatrix} S_{\phi_1}\Delta x + \alpha_0 \phi_0\\ S_{\phi_2}\Delta x\\ S_{\phi_3}\Delta x\\ S_{\phi_4}\Delta x + \alpha_1 \phi_1\\ \end{pmatrix} \end{align} where I can use already known linear algebra tools.

However what I outlined above is general and I need some help in applying it to the particular problem. I guess what I ask is for an example of finite volume method for 1D.

EDIT 1: I found that this method is called the Crank-Nicolson method, here. However I still have no idea how to approach this.

EDIT 2: I found that this method has been somewhat documented here in the wikipedia. However I still struggle in applying it to my problem.

• This seems like a really terrible way to solve $y''+\alpha=0$ ;) Commented Jan 21, 2023 at 17:09
• @FShrike maybe so, but that's what I am tasked to do. Commented Jan 21, 2023 at 17:11
• I know. I have +1 and I hope someone can help Commented Jan 21, 2023 at 17:12
• @FShrike thank you. Do you know of any way to find a simple 1D finite volume method example or something similar? Maybe a solved problem or something. Commented Jan 21, 2023 at 17:14
• I have never heard of the finite volume method, sorry. Commented Jan 21, 2023 at 17:15

The Crank-Nicholson method applied to ODEs can be resumed by the formula: given $$y(x_0)$$

$$y'(x) = f(x,y(x))\Rightarrow y_n = y_{n-1}+\frac{\Delta x}{2}(f(x_n,y_n)+f(x_{n-1},y_{n-1}))$$

now $$y''(x)+\alpha = 0$$ can be handled as

$$\left\{ \begin{array}{c} y'_1(x) &=& y_2(x)\\ y'_2(x) &=& -\alpha \end{array} \right.$$

so the discretization method furnishes

$$\cases{y_1(n) = y_1(n-1)+\frac{\Delta}{2}(y_2(n)+y_2(n-1))\\ y_2(n) = y_2(n-1) - \alpha\Delta }$$

and solving this recurrence we get

$$\cases{ y_1(n) = -\frac{1}{2} \alpha \Delta^2 n^2+c_2 \Delta n+c_1\\ y_2(n) = c_2-\alpha \Delta n }$$

Here $$\Delta = \frac 1N$$ and the boundary conditions are $$y_1(0) = y_1(N) = 0$$

etc.

• Good points, but how can we end up with a linear-algebraic system as outlined above? Commented Jan 22, 2023 at 16:06
• Considering variable $\Delta$'s with three or four internal points.... Commented Jan 22, 2023 at 16:08
• Excuse my ignorance but I do not understand what you say :( Commented Jan 22, 2023 at 16:10
• I applied the method for a fixed step width $\Delta$ but the method can be applied as well for variable steps like in finite element methods... Commented Jan 22, 2023 at 16:14
• Hmm I was hoping something like my linear system above could come out of it? Maybe setting step number to $4$ or something? Commented Jan 22, 2023 at 16:27