-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add particle species in Beam classes and update tracking methods #276
base: master
Are you sure you want to change the base?
Conversation
I just realized that I still need to take the particle charges into account for the cavities/elements with electric fields. So this should probably wait until #278 is merged. |
…lement species tests
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.
Few minor suggestions, but in principle no blocking issues.
:param voltage: Voltage of the cavity in volts. NOTE: This assumes the effective | ||
voltage. If the particle does not have unit charge, the voltage needs to be | ||
scaled properly. |
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.
This seems counterintuitive. Is this effect caused by us measuring energy in eV such that we cannot just set voltage = energy gain
for non-unit charge particles?
This might especially lead to issues if we import lattices from external files. In that case the converter would have to know the intended particle species and adjust all voltages.
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.
@cr-xu what do you think?
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.
Yes, I thought that confusing too at the beginning.
I went with this convention exactly due to the compatibility with the converters. Because Bmad also defines the voltage as the effective voltage for the ref. particle
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.
So @cr-xu you think we are fine as we are and won't run into problems when simulating other species?
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.
I think it's in the end a design choice... I see this convention (effective voltage rather than the physical one) as consistent with other normalized field strengths like
We can also just use the physical voltage,and just document/comment that extra caution is needed if they want to have non-unit charged particles.
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.
I have no opinion on this. I just want to know if this is okay to merge 😄
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.
@Hespe Actually now the voltage = total energy gain
for non-unit charged particles. Setting the voltage to physical voltage would mean that total energy gain = voltage * q
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.
Yes, that is what I meant. For non-unit charged particles, we would have to take the charge into account to calculate the energy gain.
I think your argument that the cavity is particle independent is what I would have thought before. Otherwise you would have to know the particle you are going to simulate the correctly configure the Cavity
element.
:param voltage: Voltage of the cavity in volts. NOTE: This assumes the effective | ||
voltage. If the particle does not have unit charge, the voltage needs to be | ||
scaled properly. |
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.
Same as above. At least for me, it would be more intuitive if this is the physical voltage of the cavity and the effective voltage would be an implementation detail.
@Hespe I just committed the unfinished changes ... in case you want to continue them |
I have no idea why the tests failed in the morning. I was unable to reproduce the failure and now it suddenly all works. |
Description
Add the option to track with different particle species.
Changes:
Species
class that tracks the name, charge and mass information of particles. Some basic species are pre-defined, with the possibility to define custom mass-to-charge ratio particles.transfer_map
methods and thecompute_relativistic_factors
take two arguments:[energy, particle_mass_eV]
to account for different species.species
property to keep track of the particle species.conda
. Windows tests are run without Bmad because that latter is not available for Windows.Motivation and Context
This was requested in #231 and #263.
Types of changes
Checklist
flake8
(required).pytest
tests pass (required).pytest
on a machine with a CUDA GPU and made sure all tests pass (required).Note: We are using a maximum length of 88 characters per line.