0

Through my research I faced to the following equality and need to find $c_i^{t+1}$. Moreover, I found that it can be solved by Crank–Nicolson method (see here here: https://en.wikipedia.org/wiki/Crank%E2%80%93Nicolson_method). Unfortunately I could not understand how to use the method and I did not calculate the solutions. Any one can help me to calculate the solutions? Thanks in advance. \begin{align*} \frac{c_{i}^{t+1}-c_{i}^{t}}{\Delta t}&=\frac{D}{2}(\frac{c_{i+1}^{t}-2c_{i}^{t}+c_{i-1}^{t}}{{\Delta x}^{2}}+ \frac{c_{i+1}^{t+1}-2c_{i}^{t+1}+c_{i-1}^{t+1}}{{\Delta x}^{2}} ) \\&-\frac{V}{2}(\frac{c_{{\color{red}i} {\color{red}+}{\color{red}1}}^{t}-c_{i-1}^{t}}{2\Delta x}+ \frac{c_{i+1}^{t+1}-c_{i-1}^{t+1}}{2\Delta x} ) \end{align*}

My working on this problem:

The Crank–Nicolson method \begin{align}\label{1} \frac{\partial C}{\partial t} = D_x \frac{\partial^2 C}{\partial x^2} - U_x \frac{\partial C}{\partial x} \,(1) \end{align}

We know that: \begin{align}\label{2} \frac{\partial C}{\partial t} \Rightarrow \frac{C_i^{t+1} - C_i^t}{\Delta t},\,(2) \end{align}

\begin{align}\label{3} \frac{\partial^2 C}{\partial x^2} \Rightarrow \frac{1}{2 (\Delta x)^2}\left( (C_{i+1}^{t+1} - 2 C_i^{t+1} + C_{i-1}^{t+1}) + (C_{i+1}^t - 2 C_i^t + C_{i-1}^t) \right),\,(3) \end{align}

\begin{align}\label{4} \frac{\partial C}{\partial x} \Rightarrow \frac{1}{2}\left( \frac{(C_{i+1}^{t+1} - C_{i-1}^{t+1})}{2 (\Delta x)} + \frac{(C_{i+1}^t - C_{i-1}^t)}{2 (\Delta x)} \right),\,(4) \end{align} Now putting (2), (3), (4) in (1) and $D_x=D$ ,$U_x=V$ we get \begin{align*}\label{5} \frac{c_{i}^{t+1}-c_{i}^{t}}{\Delta t}&=\frac{D}{2}(\frac{c_{i+1}^{t}-2c_{i}^{t}+c_{i-1}^{t}}{{\Delta x}^{2}}+ \frac{c_{i+1}^{t+1}-2c_{i}^{t+1}+c_{i-1}^{t+1}}{{\Delta x}^{2}} ) \\&-\frac{V}{2}(\frac{c_{i+1}^{t}-c_{i-1}^{t}}{2\Delta x}+ \frac{c_{i+1}^{t+1}-c_{i-1}^{t+1}}{2\Delta x} ) \end{align*}

So it is obtained \begin{align} \frac{c_{i}^{t+1}-c_{i}^{t}}{\Delta t}&=\frac{D}{2{\Delta x}^{2}}({c_{i+1}^{t}-2c_{i}^{t}+c_{i-1}^{t}}{}+ {c_{i+1}^{t+1}-2c_{i}^{t+1}+c_{i-1}^{t+1}}{} ) -\frac{V}{4\Delta x}({c_{i+1}^{t}-c_{i-1}^{t}}{}+ {c_{i+1}^{t+1}-c_{i-1}^{t+1}} ) \end{align} $$\Rightarrow$$ \begin{align*} c_{i}^{t+1}=c_{i}^{t}+\frac{D\Delta t}{2{\Delta x}^{2}}({c_{i+1}^{t}-2c_{i}^{t}+c_{i-1}^{t}}{}+ {c_{i+1}^{t+1}-2c_{i}^{t+1}+c_{i-1}^{t+1}}{} ) -\frac{V\Delta t}{4\Delta x}({c_{i+1}^{t}-c_{i-1}^{t}}{}+ {c_{i+1}^{t+1}-c_{i-1}^{t+1}} ) \end{align*}

Now putting $\lambda = \frac{D \Delta t}{2 \Delta x^2}$ and $\sigma = \frac{V \Delta t}{4 \Delta x}$ we have;

\begin{align*} c_{i}^{t+1}=c_{i}^{t}+\lambda({c_{i+1}^{t}-2c_{i}^{t}+c_{i-1}^{t}}{}+ {c_{i+1}^{t+1}-2c_{i}^{t+1}+c_{i-1}^{t+1}} ) -{\sigma}({c_{i+1}^{t}-c_{i-1}^{t}}+ {c_{i+1}^{t+1}-c_{i-1}^{t+1}} ) \end{align*} $$\Rightarrow$$ \begin{align*} (1+2\lambda)c_{i}^{t+1}=(1-2\lambda)c_{i}^{t}+(\lambda-\sigma)c_{i+1}^{t}+(\lambda+\sigma)c_{i-1}^{t}+(\lambda-\sigma)c_{i+1}^{t+1}+(\lambda+\sigma)c_{i-1}^{t+1} \end{align*} $$\Rightarrow$$

\begin{align*} c_{i}^{t+1}=\frac{1}{(1+2\lambda)}\big((1-2\lambda)c_{i}^{t}+(\lambda-\sigma)c_{i+1}^{t}+(\lambda+\sigma)c_{i-1}^{t}+(\lambda-\sigma)c_{i+1}^{t+1}+(\lambda+\sigma)c_{i-1}^{t+1}\big) \end{align*}

Now I do not know coefficient matrixes cited here (https://en.wikipedia.org/wiki/Crank%E2%80%93Nicolson_method) how make and how the closed form for $c_{i}^{t+1}$ is obtained?

  • 1
    You get a system that looks mainly like $(I-A)c^{t+1}=(I+A)c^t$ that you have then to solve, preferably with a sparse linear solver. In the first and last rows the matrices may not follow that pattern, depending on the type of boundary conditions. – Lutz Lehmann May 12 '22 at 10:51
  • @Lutz Lehmann Firstly, thanks for your comment. Would you say that what you mean of A? – soodehMehboodi May 12 '22 at 13:31
  • Your space-discretized system has the form $\dot c = Ac+b$. Applying the trapezium method gives $c^{t+1}-\frac{Δt}{2}Ac^{t+1}=c^t+\frac{Δt}{2}Ac^t++\frac{Δt}{2}(b^{t+1}+b^t)$. The vector $b^t$ contains the constant elements of the boundary conditions. – Lutz Lehmann May 12 '22 at 14:50
  • 2
    In your last sentence, did you really express that you want to solve this in Microsoft Excel? There is a solver, but I'm not sure if that can be used for a linear system. One could probably solve the linear system in VBA, but most people would use the linear algebra capabilities or libraries of R, python or C++ or other languages in the background so that Excel is only used to present the results. – Lutz Lehmann May 12 '22 at 17:11
  • @Lutz Lehmann , you are right. – soodehMehboodi May 12 '22 at 17:23
  • 1
    See for instance https://stackoverflow.com/questions/71431404/heat-equation-with-the-crank-nicolson, https://math.stackexchange.com/questions/3307610/error-in-crank-nicolson-scheme for an implementation (without transport term), my comments in long in https://math.stackexchange.com/questions/1242362/need-help-with-a-crank-nicholson, – Lutz Lehmann May 13 '22 at 08:17

0 Answers0