I am solving a 1D diffusion-type equation with the finite-difference Crank-Nicolson (CN) scheme, and I need to densify the spatial grid around the central point. One could change the spatial variable and re-derive the whole equation in terms of the new variable. Alternatively, in principle it should be possible to do something simpler, that is to re-write all the CN coefficients without assuming a uniform spacing. For example, for the advection term: $$ \frac{\partial f}{\partial t} = - \, u\, \frac{\partial f}{\partial x} $$ this would correspond to replacing $$ f^{n+1}_i \left[ 1 + u_i \, \frac{\Delta t}{2 \Delta x} \right] - f^{n+1}_{i-1} \cdot u_i \, \frac{\Delta t}{2 \Delta x} = f^{n}_i \left[ 1 - u_i \, \frac{\Delta t}{2 \Delta x} \right] + f^{n}_{i-1} \cdot u_i \, \frac{\Delta t}{2 \Delta x} $$ with the expression: $$ f^{n+1}_i \left[ 1 + u_i \, \frac{\Delta t}{2 (x_i - x_{i-1})} \right] - f^{n+1}_{i-1} \cdot u_i \, \frac{\Delta t}{2 (x_i - x_{i-1})} = f^{n}_i \left[ 1 - u_i \, \frac{\Delta t}{2 (x_i - x_{i-1})} \right] + f^{n}_{i-1} \cdot u_i \, \frac{\Delta t}{2 (x_i - x_{i-1})}, $$ where $n$ is the time index and $i$ is the space index. The diffusion term changes accordingly, although with a longer and a bit more complicated expression.
This way, it should be easy to control the spacing as needed based on physical reasons, according to functions that are as smooth as possible. However, this approach does not seem to work. Is there any reason for that? Or some specific constraints that are necessary?
Update: considering the grid built with the spacing in figure 1
I obtain the following solutions, at different energies (figure 2), from where it shows that the low-energy solutions have problems: