-
Notifications
You must be signed in to change notification settings - Fork 14
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
Predictor-corrector loop to compute transverse magnetic fields #133
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ated field, this makes the code diverge
…lated differently than before)
SeverinDiederichs
added
component: plasma
About the plasma species
component: fields
About 3D fields and slices, field solvers etc.
labels
Aug 31, 2020
MaxThevenet
requested changes
Aug 31, 2020
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.
Great, thanks for this big PR! Here are a few general comments:
- Could you instrument the code (i.e., add
BL_PROFILE
in main functions)? - Since this predictor-corrector loop is particularly error-prone, could you describe, for each function used in there, which exact fields it updates?
- For cleanliness, could you update benchmarks in a separate commit, and use
git commit -m "reset benchmark because ..." --author="Tools <hipace.tools@desy.de>"
Co-authored-by: MaxThevenet <maxence.thevenet@desy.de>
SeverinDiederichs
changed the title
[WIP] Predictor-corrector loop to compute transverse magnetic fields
Predictor-corrector loop to compute transverse magnetic fields
Aug 31, 2020
…rector loop was reduced, resulting in different fields
MaxThevenet
approved these changes
Aug 31, 2020
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.
Yay!
9 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
component: fields
About 3D fields and slices, field solvers etc.
component: plasma
About the plasma species
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR resolves #105 .
So far, the transverse magnet fields were calculated via
Laplacian(Bx) = -mu_0* d_y(jz)
Laplacian(By) = mu_0d_x(jz)
However, they should be calculated via
Laplacian(Bx) = mu_0(- d_y(jz) + d_z(jy) )
Laplacian(By) = mu_0*( d_x(jz) - d_z(jx) )
To calculate the longitudinal derivative of jx and jy, a predictor-corrector loop is required, which works as follows:
InitialBfieldGuess
.The guess is calculated by B_guess = (1+c)B_previous_slice -cB_one_before_previous_slice
The mixing is done via Bx = aBx + (1-a)( cBx_iter + dBx_prev_iter). The mixing coefficients a, c, d are hard-coded at the moment.
For this PR, the current deposition had to be updated, because it was not capable of depositing a current to the next slice correctly before.
All benchmarks needed to be reset, because all field values differ (even for the beam in vacuum, as Bx and By are differently calculated).
Below some results:
Linear regime:
The field does not perfectly agree with the HiPACE-C solution, because the Dirichlet boundary conditions are missing (see #130). This can be seen in the Ez_zx snapshot: the field should be 0 at the boundaries of the box.
Quasi-linear regime:
It should be noted that the introduction of the predictor-corrector loop makes the code unstable.
A badly chosen input script will result in non-physical fields, leading to self-enhanced currents, causing segmentation fault crashes.
const
isconst
)