I am currently numerically solving the following partial differential equation using finite differences:
$$ C {\partial ^2v \over \partial t^2} = {\partial ^2v \over \partial r^2} + { 1\over r}{\partial v \over \partial r} - { 1\over r^2} v + (2C^2-1){\partial ^2v \over \partial z^2} \tag 1$$
with the boundary condition:
$$ {\partial v \over \partial r} \Bigg |_{r=1} = {2C^2-1 \over2(C^2-1)}f \tag 2$$
where $C$ is a constant and both $v$ and $f$ are functions of $r$, $z$ and $t$. I am having stability issues at the radial boundary, so I wanted to try out coordinate transformation to see if I might get a more stable result. However, I don't quite understand how to do that transformation, so I am hoping someone here can help me with that.
I used the following radial to exponential coordinate transformation:
$$ x = \ln (r) \tag 3$$ $$ e^x = r \tag 4$$ $$ e^{-x} = {1 \over r} \tag 5$$ $$ {dx \over dr} = {1 \over r} \tag 6$$ $$ {dx \over dr} = e^{-x} \tag 7$$
Using the chain rule I derived:
$$ {\partial v \over \partial r} = e^{-x}{\partial v \over \partial x} \tag 8$$
$$ {\partial ^2 v \over \partial r^2} = e^{-2x}\Bigg( {\partial ^2 v \over \partial x^2} -{\partial v \over \partial x} \Bigg) \tag 9$$
This transformed equation $(1)$ and the boundary condition $(2)$ into:
$$ C \cdot {\partial ^2v \over \partial t^2} = e^{-2x} \Bigg( {\partial ^2 v \over \partial x^2} - {v} \Bigg) + (2C^2-1){\partial ^2v \over \partial z^2} \tag {10} $$
$$ {\partial v \over \partial x} \Bigg |_{x=0} = {2C^2-1 \over2(C^2-1)}f \tag {11}$$
From Taylor's expansion, we get:
$$ v(r + h_r) = v(r) + h_r {\partial v(r) \over \partial r} + {1 \over 2} (h_r)^2 {\partial ^2 v(r) \over \partial r^2} \tag {12}$$
$$ v(r - h_l) = v(r) - h_l {\partial v(r) \over \partial r} + {1 \over 2} (h_l)^2 {\partial ^2 v(r) \over \partial r^2} \tag {13}$$
where $h_r = (r + \Delta r) - r$ and $h_l = r - (r - \Delta r)$. When we subtract equation $(13)$ from $(12)$ we get the central difference expression:
$$ {\partial v(r) \over \partial r} = { v(r + h_r) - v(r - h_l) \over h_r + h_l} \tag {14}$$
Similarly, adding $(13)$ and $(12)$ yields the central difference expression:
$$ {\partial ^2 v(r) \over \partial r^2} = { v(r + h_r) + v(r - h_l) - 2v(r) \over {1 \over 2}((h_r)^2 + (h_l)^2)} \tag {15}$$
Because $h_r = h_l$, expressions $(14)$ and $(15)$ can be simplified to:
$$ {\partial v(r) \over \partial r} = { v(r + \Delta r) - v(r - \Delta r) \over 2 \Delta r} \tag {16}$$
$$ {\partial ^2 v(r) \over \partial r^2} = { v(r + \Delta r) + v(r - \Delta r) - 2v(r) \over \Delta r^2} \tag {17}$$
Here is where I get confused. The value of $\Delta r = r(j+1)-r(j)=r(j)-r(j-1)$ is constant since I am using an evenly spaced grid for the radial coordinate system (note that $j$ is the grid point index). However, it seems that $\Delta x$ is actually not constant. Here is what I mean.
I want to calculate the left $\Delta x$ and right $\Delta x$. Note that:
$$x(j-1) = \ln \Big( r(j-1) \Big) \tag {18}$$ $$x(j) = \ln \Big( r(j) \Big) \tag {19}$$ $$x(j+1) = \ln \Big( r(j+1) \Big) \tag {20}$$
If I calculate it from the left I get:
$$ \Delta x = x(j) - x(j - 1) \tag {21}$$ $$ \Delta x = \ln \Big( r(j ) \Big) - \ln \Big( r(j-1) \Big) \tag {22}$$ $$ \Delta x = \ln \Big( r(j ) \Big) - \ln \Big( r(j) - \Delta r \Big) \tag {23}$$ $$ \Delta x = \ln \Bigg( {r(j) \over r(j) - \Delta r} \Bigg) = d_l \tag {24}$$
But if I calculate it from the right I get:
$$ \Delta x = x(j + 1) - x(j) \tag {25}$$ $$ \Delta x = \ln \Big( r(j + 1) \Big) - \ln \Big( r(j) \Big) \tag {26}$$ $$ \Delta x = \ln \Big( r(j) + \Delta r \Big) - \ln \Big( r(j)\Big) \tag {27}$$ $$ \Delta x = \ln \Bigg( {r(j) + \Delta r \over r(j)} \Bigg) = d_r\tag {28}$$
So it appears that $d_l$ and $d_r$ are not equal! Does this mean I can not use the following central difference approximations at the boundary:
$$ {\partial v(x) \over \partial x} = { v(x + \Delta x) - v(x - \Delta x) \over 2 \Delta x} \tag {29}$$
$$ {\partial ^2 v(x) \over \partial x^2} = { v(x + \Delta x) + v(x - \Delta x) - 2v(x) \over \Delta x^2} \tag {30}$$
and that I should instead use:
$$ {\partial v(x) \over \partial x} = { v(x + d_r) - v(x - d_l) \over d_r + d_l} \tag {31}$$
$$ {\partial ^2 v(x) \over \partial x^2} = { v(x + d_r) + v(x - d_l) - 2v(x) \over {1 \over 2}((d_r)^2 + (d_l)^2)} \tag {32}$$
Also, am I right to assume the following statements are correct:
$$ v(x + d_l) = v(r + h_l) \tag {33} $$ $$ v(x) = v(r) \tag {34} $$ $$ v(x + d_r) = v(r + h_r) \tag {35} $$
In summary, I am confused if I should use expressions $(29)$ and $(30)$ or $(31)$ and $(32)$ to approximate the partial derivatives at the boundary of my problem and I'm also not sure if the statements $(33)$, $(34)$ and $(35)$ are correct. An answer with an explanation would be of great help to me.