Skip to content

Conversation

dpgrote
Copy link
Member

@dpgrote dpgrote commented Sep 9, 2025

This PR adds an example using the lower level Python interface for WarpX. Here, the input parameters are set directly instead of by using the PICMI interface. This uses a fairly straightforward example to demonstrate the basic method. More advanced capabilities can be setup this way as well, for instance adding call backs to Python routines.

Related to #6149 and #5283

@dpgrote dpgrote added the component: Python Python layer label Sep 9, 2025
particles.species_names = ("electrons",)

electrons = Particles.newspecies("electrons")
electrons.charge = -q_e
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be slightly different behavior since the -q_e will be evaluated in the input file rather than in the C++ parameter parsing. This could also be
electrons.charge = "-q_e"
which would be evaluated in C++.

amr.max_level = 0

# Geometry
geometry.dims = "3"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the way this parameter is parsed, this must be a string.

Copy link
Member

@ax3l ax3l Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could generalize libwarpx to assume Cartesian, if an integer is passed. We already do this assumption/convention in the ParmParse:

geometry.dims = 1  # Cartesian
geometry.dims = 2  # Cartesian
geometry.dims = 3  # Cartesian
geometry.dims = RCYLINDER
geometry.dims = RSPHERE
geometry.dims = RZ

@ax3l ax3l self-requested a review September 16, 2025 16:51
@ax3l
Copy link
Member

ax3l commented Sep 16, 2025

Discussed today in the developer meeting:

We like both and will merge both this and #6149 for now, follow-up ideas are:

  • Generalize (and rename) the Bucket to support nested ParmParse options by default – remove derived classes
  • With that, use the load file in 6154 to populate the nested ParmParse Bucket, so we can manipulate it.
  • Enable to update ParmParse interactively through changes to Parmparse Bucket, i.e., in WarpX interactive use

With those updates, the logic here will be a little less rough (e.g., see Diagnostics) and can then be documented for users together with the example in #6149 (i.e., load file and then change parameters on "ParmParse Bucket")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Python Python layer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants