- #1

- 1,798

- 33

- TL;DR Summary
- How does one implement the Robin condition for Crank-Nicholson?

I have the following PDE I wish to solve:

[tex]

\frac{\partial u}{\partial t}=D\frac{\partial^{2}u}{\partial x^{2}}

[/tex]

With the following boundary conditions:

[tex]

\frac{\partial u}{\partial x}(t,1)+u(t,1)=f(t),\quad u(t,0)=0

[/tex]

Now, I wish to do this via the Crank-Nicholson method and I would naively apply the method in the following way:

[tex]

\frac{u_{i,N}-u_{i,N-1}}{\delta r}+u_{i,N}=f(t_{i})\equiv f_{i}

[/tex]

Now the stencil for the CN method is:

[tex]

su_{i+1,j+1}-(2s+1)u_{i+1,j}+su_{i+1,j-1}=-(su_{i,j+1}-(2s+1)u_{i,j}+su_{i,j-1})

[/tex]

On the boundary this becomes:

[tex]

su_{i+1,N}-(2s+1)u_{i+1,N-1}+su_{i+1,N-2}=-(su_{i,N}-(2s+1)u_{i,N-1}+su_{i,N-2})

[/tex]

I can write the boundary term as:

[tex]

(1+\delta r)u_{i+1,N}=u_{i+1,N-1}+f_{i}\delta r

[/tex]

So I can then write:

[tex]

\left(\frac{s}{1+\delta r}-(2s+1)\right)u_{i+1,N-1}+su_{i+1,N-2}=-(su_{i,N}-(2s+1)u_{i,N-1}+su_{i,N-2})-\frac{s\delta r}{1+\delta r}f_{i+1}

[/tex]

The system of equations is then:

[tex]

A\mathbf{u}^{i+1}=-B\mathbf{u}^{i}=-\mathbf{b}

[/tex]

I've seen this done with a symmetric version of the first derivative, is that the right thing to do or is what I'm suggesting correct? I've got this coded up and it doesn't look the right sort of thing.

[tex]

\frac{\partial u}{\partial t}=D\frac{\partial^{2}u}{\partial x^{2}}

[/tex]

With the following boundary conditions:

[tex]

\frac{\partial u}{\partial x}(t,1)+u(t,1)=f(t),\quad u(t,0)=0

[/tex]

Now, I wish to do this via the Crank-Nicholson method and I would naively apply the method in the following way:

[tex]

\frac{u_{i,N}-u_{i,N-1}}{\delta r}+u_{i,N}=f(t_{i})\equiv f_{i}

[/tex]

Now the stencil for the CN method is:

[tex]

su_{i+1,j+1}-(2s+1)u_{i+1,j}+su_{i+1,j-1}=-(su_{i,j+1}-(2s+1)u_{i,j}+su_{i,j-1})

[/tex]

On the boundary this becomes:

[tex]

su_{i+1,N}-(2s+1)u_{i+1,N-1}+su_{i+1,N-2}=-(su_{i,N}-(2s+1)u_{i,N-1}+su_{i,N-2})

[/tex]

I can write the boundary term as:

[tex]

(1+\delta r)u_{i+1,N}=u_{i+1,N-1}+f_{i}\delta r

[/tex]

So I can then write:

[tex]

\left(\frac{s}{1+\delta r}-(2s+1)\right)u_{i+1,N-1}+su_{i+1,N-2}=-(su_{i,N}-(2s+1)u_{i,N-1}+su_{i,N-2})-\frac{s\delta r}{1+\delta r}f_{i+1}

[/tex]

The system of equations is then:

[tex]

A\mathbf{u}^{i+1}=-B\mathbf{u}^{i}=-\mathbf{b}

[/tex]

I've seen this done with a symmetric version of the first derivative, is that the right thing to do or is what I'm suggesting correct? I've got this coded up and it doesn't look the right sort of thing.