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

openPMD: read input beam from HDF5 file #285

Merged
merged 15 commits into from
Jan 7, 2021
Merged

Conversation

AlexanderSinn
Copy link
Member

@AlexanderSinn AlexanderSinn commented Jan 6, 2021

Small tweaks: manly to use make_constants_SI() function instead of hard-coded variables.

This PR implements functionality to use a HDF5 file as a beam input.
To compile use:

-DHiPACE_OPENPMD=ON

Use the file (e.g. beam_00000.h5 ) with

beam.injection_type = from_file \
beam.input_file = beam_%T.h5 \

The Beam has to be in iteration 0 of the file. The physical quantities (r ,u ,q, m) can be named arbitrarily, however the corresponding units have to be correct. The coordinate Axis are assumed to be named x y z or X Y Z.
If not it is possible to specify new names with

beam.file_coordinates_xyz = x1 x2 x3 \

to map file coordinates x1 x2 x3 to Hipace coordinates x y z. This can also be used to swap coordinates (e.g. x and z)

beam.file_coordinates_xyz = z y x \ 

Since Beam Particle mass is currently not used it is optional in the file, but if specified the ratio Charge / Mass has to match that of Electrons.

In /tools the python script write_beam.py can be used to write a beam file which matches the Beam created by a fixed_weight Blowout wake from the examples.

If normalized Units are used then the plasma density must be specified:

beam.plasma_density = 2.8239587008591567e23 \
  • Small enough (< few 100s of lines), otherwise it should probably be split into smaller PRs
  • Tested (describe the tests in the PR description)
  • Runs on GPU (basic: the code compiles and run well with the new module)
  • Contains an automated test (checksum and/or comparison with theory)
  • Documented: all elements (classes and their members, functions, namespaces, etc.) are documented
  • Constified (All that can be const is const)
  • Code is clean (no unwanted comments, )
  • Style and code conventions are respected at the bottom of https://github.com/Hi-PACE/hipace
  • Proper label and GitHub project, if applicable

@AlexanderSinn AlexanderSinn changed the title Use beam from file openPMD: read input beam from HDF5 file Jan 6, 2021
Copy link
Member

@MaxThevenet MaxThevenet left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks! Just one formatting point: for the preprocessor directives, could you remove the indentation for all of them (I wrote a suggestion just for one of them)? Just to be consistent with the rest of the code.
git grep " #" will show you where these directives are indented.

@@ -289,10 +289,10 @@ InitBeamFromFileHelper (std::string input_file,
const amrex::Geometry& geom,
const amrex::Real n_0)
{
HIPACE_PROFILE("BeamParticleContainer::InitParticles");

#ifdef HIPACE_USE_OPENPMD
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#ifdef HIPACE_USE_OPENPMD
#ifdef HIPACE_USE_OPENPMD

Copy link
Member

@MaxThevenet MaxThevenet left a comment

Choose a reason for hiding this comment

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

Thanks for this PR!

@MaxThevenet MaxThevenet merged commit 26df647 into development Jan 7, 2021
@MaxThevenet MaxThevenet deleted the use_beam_from_file branch January 7, 2021 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants