Hi Adrian,
I took a look at your scripts and I have a few notes to offer. TLDR: I wonder if the issue is the choice of initial timestep size (in the d3 script) being precisely 1/lambda_opt?
Main notes:
- The d3 script takes the initial timestep size to be max_timestep = 1/lambda_opt (this is specified on the line below # Main loop, and also as an argument passed to your CFL setup if you had used that instead). Conversely, in the d2 script, you currently specify an initial timestep size of 0.25*max_dt.
- When I change the initial timestep size in d2 to be max_dt, then I get the Factor is exactly singular error you mentioned.
- When I use basically any other choice of initial timestep size, I don’t get the error and the simulation proceeds to take many steps. For instance, if I perturb the max_timestep by 1e-14, the error goes away.
My reasoning is that the choice of dt = 1/lambda_opt is giving rise to a zero eigenvalue in at least one of the subproblems (I + dt*L) matrices. I would guess it is probably the R*w term because when I move that to the RHS the error goes away. Staying away from this dt will hopefully do the trick.
Other notes:
- I also happened to try R = 1.9 and I again got the Factor is exactly singular error on the first step (in both d2 and d3). So R = 2 is not the only time this problem occurs.
- When I tried R = 1.99 and 2.01 I don't recall the solution blowing up (the loop seemed to keep going for a while), although I wasn't checking the quality of the solution by plotting the grid data or anything.
- In a few places in the d3 script you use a variable called dt (instead of the variable called timestep). I would recommend not using dt, since this can confuse the dedalus equation parser on terms like “dt(u)” if you are not careful.
I hope this helps. Let me know if this checks out or if you are still experiencing issues.
Ben