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

Charge Deposition: Fix Sign #251

Merged
merged 1 commit into from
Sep 16, 2022

Conversation

ax3l
Copy link
Member

@ax3l ax3l commented Sep 16, 2022

This fixes the charge deposition. Electrons should deposit negative charge :-)

@ax3l ax3l added bug Something isn't working bug: affects latest release Bug also exists in latest release version component: space charge Space charge & potential solver labels Sep 16, 2022
@ax3l ax3l requested a review from cemitch99 September 16, 2022 21:13
@ax3l ax3l mentioned this pull request Sep 16, 2022
20 tasks
Copy link
Member

@cemitch99 cemitch99 left a comment

Choose a reason for hiding this comment

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

Great!

@RemiLehe RemiLehe enabled auto-merge (squash) September 16, 2022 21:46
@RemiLehe
Copy link
Contributor

@ax3l It seems that you will need to modify the test to replace:

assert math.isclose(beam_charge, 1.0e-9)

with

assert math.isclose(beam_charge, -1.0e-9)

This fixes the charge deposition. Electrons should deposit
negative charge :-)
@ax3l
Copy link
Member Author

ax3l commented Sep 16, 2022

correct, wanted to quickly see if this fails now as intended.

It does, but I also need to increase the tolerance a little now: beam_charge=-1.0000000087381137e-09

@cemitch99
Copy link
Member

@ax3l It seems that you will need to modify the test to replace:

assert math.isclose(beam_charge, 1.0e-9)

with

assert math.isclose(beam_charge, -1.0e-9)

This is a good point. In Impact-Z, the sign problem is avoided by treating all charges as positive. (So electrons are treated as positrons.) This makes life a bit easier, and it does not affect tracking in the external fields because the field strength is given in a normalized form (scaled by signed magnetic rigidity p/q). Either option is fine, as long as the sign of the pushed single-particle charge is the same as the sign of the deposited charge of the bunch.

@ax3l
Copy link
Member Author

ax3l commented Sep 16, 2022

I like that we have both, would allow us to do some (short beamline) tests with partly neutral beams as come out from some plasma sources.

@RemiLehe RemiLehe merged commit ba08e82 into BLAST-ImpactX:development Sep 16, 2022
@ax3l ax3l deleted the fix-charge-depos branch September 17, 2022 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: affects latest release Bug also exists in latest release version bug Something isn't working component: space charge Space charge & potential solver
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants