-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transient solvers are slow #2225
Comments
I investigated this a bit myself. I wrote myself a custom RK45 solver. The simulation time for my custom solver was similar but usually more). I tried with varying amounts of tolerance (see results below). The system I tried on was a fickian diffusion problem coupled with a fourier conductance problem with temperature dependent diffusivity. The domain was 10,000 pores. Also, when I used these RK45 solvers on the Nernst Planck system they were extremely slow! But I realized the issue was not with the solver but how the problem was defined. I was using the electroneutrality model for ionic conductance which admittedly has it's issues. But changing to poisson, the solvers worked much faster!! So sometimes it is just how the problem is defined. A poorly defined problem, convergence will be hard to reach, causing the solver to move very slow with very small time steps. In conclusion, two things the user can do to help with speed:
atol=1e-6, rtol=1e-6 atol=1e-6, rtol=2.220446049250313e-14 atol=1e-3, rtol=2.220446049250313e-14 atol=1e-3, rtol=1e-6 atol=1e-3, rtol=1e-3 atol=1e-2, rtol=1e-2 atol=1e-1, rtol=2.220446049250313e-14 |
Hey @mkaguer! Thanks for the thorough analysis. I think we could do better in problems where the A matrix is not changing (those without a nonlinear source term for instance). Currently, we're rebuilding A at every time step, but we could use a cached version instead. Could you maybe look into it and see if you get significant speed-ups this way? |
Hi @ma-sadeghi. Sure, I gave it a try. The previous problem I was testing was a multiphysics problem. That required A NOT to be cached since the conductance models needed to be updated. So for the purpose of comparing cached versus not cached, I wrote a new script for a transient fickian diffusion problem only. Geometry was kept the same, 10,000 pores. These are the results: Cached: NOT Cached: Speed up between 20 to 30% when A and b are cached. This is much faster then previous multiphysics problem. So, for interest sake, I increased the domain size to 20,000 pores. This will give us the same number of unknowns then as the multiphysics problem. Result: Cached: NOT Cached: Wow, still a lot faster then before. So what is making the solver slow must be the multiphysics! |
Interesting, although I was expecting much more speed up to be gained. How do you cache the A matrix? Could you post a little snippet of the code where you modified? |
I see. Could you time coo-to-csc conversion? OpenPNM/openpnm/algorithms/_transient_reactive_transport.py Lines 113 to 122 in 197f55a
You could add |
Hi @ma-sadeghi. Ok so I ran my Fickian diffusion simulation again (no multiphysics). I compared the conversation time to updating A and b time. I did this for cached and not cached. When cached When NOT cached |
@mkaguer Could you also report the timings for a larger network? |
Hi @ma-sadeghi. For a larger network of 1000 by 1000 pores these are the results. Previous network was 10,000 pores. Now the network is 1,000,000 pores. There is still something happening when updating A and b is called that seems to take a significant amount of time yet. When cached When NOT cached |
Ok @ma-sadeghi, also here are the results of scaling the temperature. The times did not vary much for the multiphysics problem. Temperature NOT scaled: Temperature scaled down by factor of 10 Temperature scaled down by factor of 100 Temperature scaled down by factor of 1000 Temperature scaled down by factor of 10000 |
@mkaguer Thanks for the comprehensive report! So, what's going on in the voltage problem that makes the simulation slower? |
No description provided.
The text was updated successfully, but these errors were encountered: