Hi,
I am solving a problem based on the Dedalus example Waves on a string (1D EVP). I have substituted the square of the uniform propagation speed, c**2, of this example by this piecewise function:
c2 = dist.Field(name='cs2', bases=xbasis)
ci2 = ci * ci
ce2 = ce * ce
x = dist.local_grid(xbasis)
c2['g'] = np.piecewise(x, [x < -x0, (-x0 <= x) * (x <= x0), x > x0], [ce2, ci2, ce2])
The wave equation is:
problem.add_equation('s*u + c2 * uxx = 0')
The rest of the code, see attached file EVP_piecewise_string.ipynb, essentially follows that of the Dedalus example, although the calculation of the analytical values of the eigenvalue and eigenfuntions are a bit lengthier and non-physical eigensolutions must be discarded.
The code works well if the ratio of the "external" to the "internal" propagation speeds, ce/ci, is small; for example, for ce/ci = 2, see eigenvalue_error_ci1_ce2_Nx128.png and eigenfunctions_ci1_ce2_Nx128.png. However, when I increase this ratio slightly, some eigensolutions are wrong: see n = 4 in file eigenfunctions_ci1_ce3_Nx128.png. This eigenfunction in particular does not satisfy the boundary conditions!
Is there any way to improve the code to get reliable eigensolutions for larger values of ce/ci? I have run the code with values of Nx up to 2048 and it does not give good approximations to the eigenfunctions for the moderate value ce/ci = 10.
Thanks in advance,
Ramon