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

Align openPMD field diagnostic with what pywarpx.picmi.LoadInitialField expects #5668

Open
jwestern opened this issue Feb 13, 2025 · 1 comment
Assignees
Labels
component: electrostatic electrostatic solver component: Python Python layer enhancement New feature or request

Comments

@jwestern
Copy link
Contributor

jwestern commented Feb 13, 2025

I'm using the PICMI interface. I have a need to freeze the electrostatic fields in a WarpX run, because they aren't changing much and the Poisson solve is too expensive. There are a few ways to do this:

Option 1) output an openPMD field diagnostic, then read it in as an applied field using pywarpx.picmi.LoadInitialField
Option 2) come up with an analytic fit of the fields, then impose applied fields using pywarpx.picmi.AnalyticAppliedField
Option 3) ask the electrostatic solver to update rarely

Option 1 is potentially the most convenient, as one could e.g. time-average the fields before reading them in as an applied field. I tried Option 1, but pywarpx.picmi.LoadInitialField does not accept the structure of the field diagnostic. E.g. it expects axis labels to be ordered x, y, z, whereas the field diagnostic is ordered in reverse. I tried to perform surgery on the openPMD file by reshaping the data to align with the expected order, but then another problem occurs (missing 'position' attribute). So it looks like option 1 is quite awkward and error-prone because it seems to require manual surgery of the field diagnostic output.

Option 2 is a lengthy process, and thus not suitable if one needs to repeatedly redo this procedure.

Option 3, to my knowledge, is not an available functionality. It would be very easy, but would preclude modifying the field (e.g. by applying a time average).

It seems to me that Option 1 should be the intended usage of pywarpx.picmi.LoadInitialField, but it doesn't work. So this feature request is to align the field diagnostic with what pywarpx.picmi.LoadInitialField expects.

Let me know if I'm missing something.

Thanks!

@jwestern jwestern added the enhancement New feature or request label Feb 13, 2025
@dpgrote
Copy link
Member

dpgrote commented Feb 14, 2025

This is an interesting use case. I think option 3 would be straight-forward. Small changes would be needed in WarpX to have the Poisson solver skipped if max_iters is set to zero, and also to allow this parameter to be set during runtime from the Python interface. Note that you can modify the field since you have access to it from Python via the fields module.

@ax3l ax3l added component: electrostatic electrostatic solver component: Python Python layer labels Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: electrostatic electrostatic solver component: Python Python layer enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants