I'm using a Runge-Kutta second-order solver (more specifically, this with $\alpha = 1$) and I'm trying to approximate the solution of the nonlinear system
$$\begin{cases} T'(r)=S(r) \\ S'(r)=-\frac{S(r)}{r}-\beta e^{T(r)} \end{cases}$$
with initial values $T(1)$ and $S(1)$. Moreover, I'm interested in the solution in the interval $[h, 1]$, where $h$ is the step size used in the solver. Notice that to go back in time I'm using a negative step $h_-=-h$ to run the algorithm. The solutions look correct and I'm computing the convergence order with the formula
$$\log_2\left(\frac{\text{mean}(|T_h - T_{h/2}|)}{\text{mean}(|T_{h/2} - T_{h/4}|)}\right)$$
where $h$ is the step size used to compute the solution $T$ (I'm only interested in finding $T$, not $S$, for this specific problem). This expression gives values of about 2 for the first 4 values of $h$ starting from $0.05$, although they are dropping to $\approx 1.95$ after 4 iterations. After $15$ iterations, it seems to stabilize to $\approx 1$.
I'm fairly certain that this is not due to the implementation of the method since I tried the same code with other non-singular at $r=0$ systems and, with those systems, obtained values approaching the correct (theoretical) value of $2$.
Is there anything more to this than roundoff errors in the division $\frac{S}{r}$ in the $S'$ term? When $h$ is very small then $r$ can be very small near the origin. Can this behaviour be somewhat diminished while still using this R-K method to solve the system of equations?
Edit: one more interesting thing about this problem is that if we only compute the convergence order using values of $T_h$ far from the singularity, we obtain the correct convergence order of $\approx 2$.
Edit 2 (more information): I didn't want to give out too many details about this problem, but here goes the full thing. I'm interested in solving the BVP
$$T''(r) + \frac{1}{r}T'(r) + \beta e^{T(r)} = 0$$
with boundary conditions $T(1)=0$ and $T'(0)=0$. Originally I used the Newton method together with the power series approximation $T(h) - T(0) = -\frac{\beta e^{T(0)}}{4}h^2$ to avoid the singularity and this gave me a convergence order of $2$. Now I'm interested in solving this with a shooting method using the trapezoidal method which I mentioned in the first paragraph of the post.
The difficulty here is dealing with the singularity, hence I solved the problem in $[h, 1]$ using a negative step as I described above. Now I'll describe my current algorithm:
- let $s_1$, $s_2$ be such that $S(0) > 0$ for $S(1) = s_1$ and $S(0) < 0$ for $S(1) = s_2$.
- compute $T(0)$ using the power series approximation for $S(1) = \frac12 (s_1 + s_2)$. That is, find $T(0)$ using Newton's method with a specified tolerance, I used $10^{-12}$. This converges very fast since the starting value I'm giving the method is $T(h)$.
- approximate $T'(0)$ using a second order forward finite difference (that is, depending on $T(0)$, $T(h)$ and $T(2h)$). I call this a "compatibility condition", since the power series forces the first order finite difference to be very close to $0$.
- depending on the sign of the approximation obtained, rerun the program with $\frac12 (s_1 + s_2)$ as one of either $s_1$ or $s_2$. Essentially, we're using the bisection method over $[s_1, s_2]$ to find a value of $s$ that gives good values for $T'(0)$. Stop running if $s_2 - s_1$ is below a specified tolerance (e.g. $10^{-12}$), and classify the average of these two as the correct approximation for $s$.
I've worked on this for some time after originally posting this question, and this method seems to be giving good (and fast) convergence. The values I'm getting while using the formula given above in the post are all around $2$.
There might exist some theoretical problems with this method, but it seems to work well in practice.
Originally, I was experiencing problems with the convergence order running the program with a fixed $s$ right from the first value of $h$ for which I computed an approximation. I figured this can be partly explained by the paper I posted in one of my comments.
Notice that example 1 in section 4 is this exact problem! Now I'm even more confused as to how you managed to get the correct convergence orders. The first 10 values I'm getting are [2.00174681, 1.9968536, 1.98806133, 1.97286816, 1.94525955, 1.89537815, 1.81062822, 1.68245844, 1.51943556, 1.35336385].
– user401936 Jan 13 '20 at 17:53If my current edit is still not very clear, I am given $T(1)$ and must find $S(1)$ s.t. $S(0) = 0;(=T'(0))$.
– user401936 Jan 21 '20 at 16:45