-
Notifications
You must be signed in to change notification settings - Fork 1
Adding middle stage extraction for HiPACE. #138
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
base: main
Are you sure you want to change the base?
Conversation
|
Would it be possible to modify this to let the user specify the step number to extract? |
|
|
||
| if output_period is None: | ||
| output_period = int(num_steps) | ||
| output_period = int(num_steps/2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If output_period is set, this leads to Hipace not dumping the middle time step, so that __extract_initial_middle_and_final_step() will fail because it does not find the middle time step.
| self.initial.beam.density.rho = -jz0_beam.T/(SI.c*SI.e) | ||
|
|
||
| # extract middle beam density | ||
| jz0_beam, metadata0_beam = ts.get_field(field='jz_beam', iteration=int(max(ts.iterations)/2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check that this is actually valid before blindly trying (either try/except or verify before starting simulation or in constructor etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pick the middlemost timestep here, and include the actual location (s_stage value) in the plots for verification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Top comment: It's not possible to check before simulation as you extract these attributes from the h5 files at the end of the simulation, but I have been using this in my own working directory and it works. It would not work if we don't have any of the requested fields as requested output in our input file, but we have them in the input template as default and we dont have a flag in HiPACE++ to change the requested output fields yet.
| self.num_steps = np.ceil(self.length_flattop/dz) | ||
| self.num_steps = int(np.ceil(self.length_flattop / dz)) | ||
| # Adds 1 to make it even if odd | ||
| self.num_steps += self.num_steps % 2 # make it even (add 1 if odd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, this enforces there is never a time step in the middle :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are counting from 0 when extracting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does have to be even actually. Because we have h5 files from 0 up until num_steps, so if its even there is a step in the middle. num_steps is a bit misleading because its really number of steps + 1
kyrsjo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comments about "middle" wrt odd (1st / 2nd / 3rd / etc. step vs. numstep and counting from 0, and picking the closest), and being safe wrt to user selected output timestep.
…y the position in plot_wake
Modified stage, stage_hipace and hipace_wrapper to extract middle step field information aswell.