-
Notifications
You must be signed in to change notification settings - Fork 17
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
Improvements on the adaptive time step calculation #884
Conversation
CI is fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! See few minor comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I included your comments, and incorporated a few additional changes:
- Replace MPI Wait/Notify with Bcast
- Clean up behavior in the first few time steps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the effort! Looking forward to the convergence scans and new defaults..
This PR proposes 2 improvements of the adaptive time step algorithm:
it
are used to predict the time step at the next iteration performed by the current rank, which isit+nranks
. This can be a problem for largely parallel simulations, as the beam energy and local density can be quite off. Here, we use current Lorentz factor and accelerating field to estimate the beam position and energy atit+nranks
, and use it to calculate the adaptive time step. This should make both the beam energy and local density evaluations more accurate. Addresses Improve adaptive time step #883.dt
is corrected if needed to resolve the gradient. The newdt
is chosen such that the resulting phase advance equals the default one in a uniform plasma (1/nt_per_betatron
), to a certain tolerance level.The figure below shows the physical time and time step for a z-dependent density using the dev version (old), the new code with both features above turned off (off, right on top of dev), only the phase correction on, only the prediction method on, both on, and both on with a 3x larger tolerance on the phase advance error (3x tol). As expected, the phase feature changes the behavior in the upramp. With prediction, the time step is modified in the density bumps, rather than after them.
This input file can be useful to test further improvements on the time step. Few python lines for the analysis are below.