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: restart simulation and multiple Beams #325

Merged
merged 3 commits into from
Feb 3, 2021

Conversation

AlexanderSinn
Copy link
Member

This PR introduces the ability to restart simulations with:

beams.names = beam1
beam1.injection_type = restart
beam1.input_file = diags/h5/openpmd.h5
beam1.iteration = 100

To restart from iteration 100 (Default is 0).
Additionally, if the previous file had a different beam name beam1.species_name = beam0 can be used to read in beam0 and change the name to beam1.
Note: when restarting a simulation the other Settings in Hipace++ shouldn’t be changed.
This PR also adds the options beam.iteration and beam.species_name to beam.injection_type = from_file to allow to read multiple beams from the same file:

beams.names = beam1 beam2

beam1.injection_type = from_file
beam1.input_file = beam_%T.h5
beam1.iteration = 0
beam1.species_name = Electrons

beam2.injection_type = from_file
beam2.input_file = beam_%T.h5
beam2.iteration = 0
beam2.species_name = Positrons

and then

beams.names = beam1 beam2

beam1.injection_type = restart
beam1.input_file =diags/h5/openpmd.h5
beam1.iteration = 100

beam2.injection_type = restart
beam2.input_file = diags/h5/openpmd.h5
beam2.iteration = 100
  • 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 added the component: beam About the beam species label Jan 20, 2021
@SeverinDiederichs
Copy link
Member

Thanks for this PR, it already looks pretty good and the functionality will be helpful in the future. I tested that it works, but still have a few questions and with that probably suggestions:

In an example with 2 beams, I could restart the simulation using the restart with:

beams.names = beam beam2
beam.injection_type = restart
beam.input_file = diags_orig/h5/openpmd.h5
beam.iteration = 1

beam2.injection_type = restart
beam2.input_file = diags_orig/h5/openpmd.h5
beam2.iteration = 1

Additionally, I could restart the simulation now by hand with

beams.names = beam beam2
beam.injection_type = from_file
beam.input_file = diags_orig/h5/openpmd.h5
beam.iteration = 1
beam.species_name = beam

beam2.injection_type = from_file
beam2.input_file = diags_orig/h5/openpmd.h5
beam2.iteration = 1
beam2.species_name = beam2

Please correct me, if I missed something: it looks like the restart does exactly the same thing as the the read in from file, when one specifies the beam names. But also for the restart, the names need to be specified ( beams.names = beam beam2 needs to be the same as in the previous simulation). I think for restarting the simulation, it could be even simpler:

When restarting, the users should not need list each beam separately, but only that they want to restart a previous simulation at iteration x. So the flag for restart should probably be part of the multi beam container beams, not of a single beam beam. Then, the code should iterate over the beams in the openPMD file and generate each beam by calling the from file function (like if the users added all beams by hand). This would probably also reduce the amount of code and avoid duplication in the beam initialization.

Additionally, the physical time should be set in the restart. At each iteration, we write the time of the simulation (iteration.setTime(physical_time); to the openPMD file. When restarting, we should restart at the given time of the iteration, we are restarting from.

One last minor style suggestion by @MaxThevenet:
The naming of the species_name could be even more specific to avoid confusion with the name of the beam, e.g. openPMD_species_name so it is clear that this definitively describes the name in the openPMD file.

beams.names = beam1 beam2
beam1.species_name = Electrons

If you have any questions or would like to discuss anything, please let me know and keep up the good work!

Copy link
Member

@SeverinDiederichs SeverinDiederichs 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! I wanted to merge this a while ago.
The follow-up cleaning to merge the restart and read from file is already discussed and will be implemented in the short future.

@SeverinDiederichs SeverinDiederichs merged commit 76d302a into development Feb 3, 2021
@SeverinDiederichs SeverinDiederichs deleted the restart_simulation_2 branch February 3, 2021 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: beam About the beam species
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants