Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to mitigate ringing?

34 views
Skip to first unread message

nathan magnan

unread,
Oct 28, 2024, 10:02:05 AM10/28/24
to Dedalus Users
Hello everyone,

I'm working on a 1D problem with a background flow that has a sort of "smooth square function" shape.

I've tried to represent it in Dedalus. 
Unfortunately, I run into 3 problems, which I think are all connected:
1) The mode amplitude declines very slowly with mode number (it's still an exponential, but a very slow one: I would need to include 1024 modes to get good precision).
2) I see some ringing for the derivative in the plateau of the square function
3) I see some ringing for the derivative at the boundaries of the domain

Screenshot 2024-10-28 145527.png

I suppose it makes sense that a spectral code would struggle to represent something with sharp features. However, my issues persist even when I smooth the sides of the square to the point where they each occupy 25% of the domain.

I was wondering if someone has encoutered a similar issue before, and found a workaround?

Thanks for your help !
Nathan

PS: I attach a minimal working example, so you can play around.

MWE.py

Jeffrey S. Oishi

unread,
Oct 28, 2024, 10:09:46 AM10/28/24
to dedalu...@googlegroups.com
Hi Nathan,

I've only looked quite quickly, but it looks like you're only smoothing the slopes of the transition regions, leaving the point-wise jumps. This will never converge well as it still has singular derivatives. You should consider building your entire shape out of C-infinity functions. I'd suggest erf(); we use it to build smoothed versions of sharp structures with good results all the time.

Jeff

--
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/3e07aa01-6695-4baa-adb3-3f111d0c25b3n%40googlegroups.com.

nathan magnan

unread,
Oct 28, 2024, 10:13:45 AM10/28/24
to Dedalus Users
Hi Jeff,

Thanks for the quick answer.

I'll have a look at erf, but I did try to to match every derivative to create a C-infinity function.
Specifically, I used integral(ds, a -> x, 1 / (s - a)(b - s)) / integral(ds, a -> b, 1 / (s - a)(b - s)) as my smoothing function.

Best regards,
Nathan

nathan magnan

unread,
Oct 28, 2024, 10:33:34 AM10/28/24
to Dedalus Users
Hi Jeff,

I've run a test with erf, and I see the same thing:
Screenshot 2024-10-28 152756.png
There is one difference however: the ringing disappears above a certain smoothness, and the transition seems pretty sharp:
Screenshot 2024-10-28 152934.png
Between those two pictures, I only doubled the width of the transition region.
Equivalently, I can make the ringing disappear by increasing resolution by a factor two, but I'd prefer not to pay that cost.
And to be clear, there is still a bit of ringing, but the amplitude of the main oscillation is 10^(-8), which I can work with.

Best regards,
Nathan

Jeffrey S. Oishi

unread,
Oct 28, 2024, 10:42:23 AM10/28/24
to dedalu...@googlegroups.com
Hi Nathan,

Another issue is boundary conditions. You also need enough space in your domain for erf to be zero to machine precision, assuming you enforce zero boundary conditions.
 
There is one difference however: the ringing disappears above a certain smoothness, and the transition seems pretty sharp:
 Yes, that's expected for spectral accuracy.

Equivalently, I can make the ringing disappear by increasing resolution by a factor two, but I'd prefer not to pay that cost.
Alas, this is the fundamental tragedy of computational science.

Jeff
Reply all
Reply to author
Forward
0 new messages