1D EVP string with piecewise propagation speed

43 views
Skip to first unread message

Ramon Oliver

unread,
Jul 7, 2025, 7:35:36 AMJul 7
to Dedalus Users
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

 
EVP_piecewise_string.ipynb
eigenfunctions_ci1_ce3_Nx128.png
eigenfunctions_ci1_ce2_Nx128.png
eigenvalue_error_ci1_ce2_Nx128.png

Ramon Oliver

unread,
Jul 14, 2025, 10:46:21 AMJul 14
to Dedalus Users
Hi again,

Any ideas about this problem?

Something I did not mention in my previous message: the eigenfunctions in continuous and dashed lines with circles are the analytical and the Dedalus solutions.

Cheers,

Ramon

Daniel Lecoanet

unread,
Jul 14, 2025, 11:26:57 AMJul 14
to Dedalus Users
Hi Ramon,

Since the sound speed is not differentiable, I do not believe the solution will be differentiable, which means that a global spectral expansion will converge very slowly to the correct answer. Instead you might want to make multiple Chebyshev bases for x<-x0, -x0<x<x0, and x>x0 and solve the equation over each of those domains, subject to appropriate boundary conditions at the interfaces. That should give more accurate eigenvalues/eigenfunctions. That is, you could define ul, uc, and ur as three variables defined over the different subdomains and then you would need to add three equations, “s*ul+c2*ulxx = 0”, “s*uc + c2*ucxx = 0”, “s*ul + c2*ulxx = 0”, etc.

Daniel

-- 
You received this message because you are subscribed to the Google Groups "Dedalus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dedalus-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/dedalus-users/2f7023b2-2ab1-4668-95ab-578e304541e7n%40googlegroups.com.

Message has been deleted

Ramon Oliver

unread,
Jul 18, 2025, 9:54:53 AMJul 18
to Dedalus Users
Hi Daniel,

Thanks a lot for this solution! It works extremely well with a small number of coefficients even for very large (or very small) ratios of the two sound speeds. I checked the accuracy of the eigenvalues and eigenfunctions of the first few harmonics and it is excellent.

Btw, the eigenfunctions are differentiable at the sound speed discontinuities. In fact, at these positions one imposes four BCs, namely the continuity of u and of dx(u). I am just mentioning, in case this can be of some use to other Dedalus users.

Cheers,

Ramon

Reply all
Reply to author
Forward
0 new messages