Adaptive time stepping

350 views
Skip to first unread message

pouria behnoud

unread,
May 24, 2021, 1:00:56 PM5/24/21
to Dedalus Users
I intend to implement the Cahn-Hilliard problem. In the available tools of Dedalus, the CFL condition used to do the adaptive time step is a condition for fluids and it is based on the 'mesh velocity'. In my case, I will need to adapt the time step base on the error in the time integration. For example, this approach is very common for Runge-Kutta methods. Can anyone help me with it? 

Thanks

Daniel Vaughan

unread,
Apr 4, 2024, 5:04:44 PM4/4/24
to Dedalus Users
Hi,
 
I am looking to do something similar, did you manage to get this to work?

Thanks 

pouria behnoud

unread,
Apr 4, 2024, 10:27:40 PM4/4/24
to dedalu...@googlegroups.com
Hi Daniel, 

Yes, I managed to do it based on their available tools and not in a smarter way. 

cfl = flow_tools.CFL(solver, initial_dt=dt, cadence=1, safety=0.2, threshold=0., max_dt=dt)
cfl.add_velocities(('u','s'))
while solver.ok:
    dt = cfl.compute_dt()
    solver.step(dt)

Here, s is concentration and u is velocity. 
Please, let me know if I can hep more. 

Best;
Pouria

--
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 on the web visit https://groups.google.com/d/msgid/dedalus-users/3aa3c8a1-96c4-4176-8527-606a55a54da4n%40googlegroups.com.

Daniel Vaughan

unread,
Apr 8, 2024, 8:09:58 AM4/8/24
to Dedalus Users
Hi Pouria, 

Thanks for replying. 
Out of interest, did you manage to implement an adaptive step method without using the CFL condition?
If you decided to go with the CFL method was there a particular reason for this? 

Many thanks,
Daniel 

Daniel Lecoanet

unread,
Apr 9, 2024, 4:49:56 AM4/9/24
to Dedalus Users
Hi Daniel,

In Dedalus you write your own main integration loop, so you can use any method you’d like to calculate the timestep. I wouldn’t recommend using the CFL calculator because it sounds like it is not appropriate to calculate the timestep based off the CFL condition. It sounds like your main loop would look something like:

from mpi4py import MPI
comm = MPI.COMM_WORLD

while solver.proceed:
    local_error = calculate_error() # each core calculates the error in its local data arrays
    global_error = comm.allreduce(local_error, MPI.MAX) # calculate maximum error over all cores
    timestep = calculate_timestep_size(global_error) # calculate the timestep based off the global error
    solver.step(timestep)

Hope that helps,
Daniel

Daniel Vaughan

unread,
Apr 12, 2024, 6:01:29 AM4/12/24
to Dedalus Users
Hi Daniel,

Thanks for the suggestion. It works great. 

Thanks,
Daniel

Daniel Vaughan

unread,
Apr 22, 2024, 10:27:03 AM4/22/24
to Dedalus Users
Hi,

I need help with implementing initial conditions with my adaptive solver. 
Is there a way to obtain the local coordinates sent to each core? 
I would like the local coordinates to construct initial conditions that don't have a repeating structure.
I hope this makes sense and any help is greatly appreciated.

Many thanks,
Daniel  

On Tuesday 9 April 2024 at 09:49:56 UTC+1 daniel.lecoanet wrote:

Keaton Burns

unread,
Apr 22, 2024, 10:30:38 AM4/22/24
to dedalu...@googlegroups.com
Hi Daniel,

Yes this is described in the tutorial notebooks.

Best,
-Keaton


Reply all
Reply to author
Forward
0 new messages