Skip to content
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

Species supercycling #4774

Open
wants to merge 18 commits into
base: development
Choose a base branch
from

Conversation

archermarx
Copy link
Contributor

@archermarx archermarx commented Mar 13, 2024

This PR adds the ability to advance different species at different multiples of the provided const_dt. It introduces two new parameters, <species>.do_supercycling and <species>.supercycling_interval, which determine whether the provided species is to be supercycled, and the interval (in terms of iterations) at which they are to be advanced. It also updates the PICMI species interface to support these parameters. This is useful in cases where the dynamics of interest are dominated by a lighter species which must be advanced at a much smaller timestep (i.e. electrons in an electron-ion plasma), while allowing ions or other heavier species to advance at a much larger timestep.

This is my first PR, so let me know if I'm missing anything critical or if there's a better way to handle this than how I implemented it!

@dpgrote
Copy link
Member

dpgrote commented Mar 13, 2024

Overall, this looks good. Is this intended for electrostatic or electromagnetic?
Note that for electrostatic, the charge is deposited elsewhere, so as you have it, the charge for all particles will still be deposited every step. For electromagnetic, this does skip the current deposition for the slower moving species, so the field advance each step will have only the current of the faster moving species. Is this what is intended?

@archermarx
Copy link
Contributor Author

Overall, this looks good. Is this intended for electrostatic or electromagnetic? Note that for electrostatic, the charge is deposited elsewhere, so as you have it, the charge for all particles will still be deposited every step. For electromagnetic, this does skip the current deposition for the slower moving species, so the field advance each step will have only the current of the faster moving species. Is this what is intended?

Thanks for taking a look! This is currently intended only for electrostatic. I added a check in ComputeDt to verify that a constant dt has been passed, but perhaps I should also update that to make sure we're using the electrostatic solver.

@archermarx
Copy link
Contributor Author

Note that for electrostatic, the charge is deposited elsewhere, so as you have it, the charge for all particles will still be deposited every step.

Thanks for pointing this out. I thought that was handled in MultiParticleContainer->Evolve but evidently that isn't correct. I'll see if i can fix this because we would ideally only deposit charge from the slower species on the iterations at which their positions actually change.

@archermarx
Copy link
Contributor Author

If I'm understanding the charge deposition for the electrostatic solver correctly (looking at WarpX::AddSpaceChargeField in ElectrostaticSolver.cpp), It looks like the space charge fields are accumulated onto a common value which is reset every iteration. This means that we have to deposit charge from all species at each timestep, regardless of supercycling, or else the fields would be massively wrong on the iterations where the slower species aren't pushed. It doesn't look like there's an easy way to store the computed fields/charge density from a previous iteration for use on the supercycled iterations.

If that's correct, then I think this PR is fine without that, and perhaps a future PR could address that part.

@archermarx
Copy link
Contributor Author

archermarx commented Mar 15, 2024

@dpgrote @lucafedeli88 I think I've addressed all the comments. Let me know if there's anything else you'd like me to change!

@archermarx
Copy link
Contributor Author

Looks like clang-tidy is still failing, but I don't think it's anything I've done, the error seems to be

/home/runner/work/WarpX/WarpX/Source/Utils/WarpXAlgorithmSelection.cpp:252:17: error: redundant string initialization [readability-redundant-string-init,-warnings-as-errors]
    std::string boundary_name = "";
Suppressed 120982 warnings (120917 in non-user code, 65 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
1 warning treated as error
                ^~~~~~~~~~~~~~~~~~
                boundary_name

Looks like this was introduced in this PR. I've fixed it in this one.

@ax3l ax3l added component: core Core WarpX functionality component: electrostatic electrostatic solver labels Mar 25, 2024
@ax3l
Copy link
Member

ax3l commented Mar 26, 2024

Comment by @jlvay in the developer meeting:
One can save even more by depositing the supercycled species (in a separate array) for the supercycling_interval forward in time and then interpolating every step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: core Core WarpX functionality component: electrostatic electrostatic solver
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants