-
Notifications
You must be signed in to change notification settings - Fork 1
Achromatic spectrometer #50
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
…nonlinear_thin to accomodate for changing the axis (x or Y) of the nonlinearity
…crete values in energy, and these values are defined by the user. No discretization in energy is also possible, where the energies are sampled from a uniform distribution.
…urce and a spectrometer.
| Parameters | ||
| ---------- | ||
| length : float, optional | ||
| Length of the source [m]. Default is 0. |
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 job adding the documentation! Just please put the unit on the first line of the parameter declaration. E.g. length : [m] float, optional.
| Parameters | ||
| ---------- | ||
| _ : None, optional | ||
| Placeholder parameter. Default is None. |
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.
Variables in text should be inside ````. E.g. Default is None.
| Returns | ||
| ------- | ||
| Beam | ||
| The tracked beam object. |
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.
Beam object
|
|
||
| # ================================================== | ||
| # Filter out particles whose z < z_cutoff for testing instability etc. | ||
| def z_filter(self, beam): |
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 looks strangely familiar. Is it copied from another file? If so, perhaps we should consider moving it to e.g. utilities to avoid duplication.
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.
Indeed here I just copied the source_basic.py and added the added input energy_comb_delta and the function reorder_particle_energies(self, beam, plot=False). Thinking about it more, I guess it would make sense to inherit from it and add these two things to the child only?
|
Looks great overall! Could you please also write some tests? There are already some tests under the tests folder for you to look at. Otherwise, there is also this pull request #49, which should be merged into main soon. |
|
I made together with @ben-c-2013 a PR to this branch: #51 The point is to undo some of the changes you did to whitespace in beam.py, which would make mergings to main unneccesarily complicated since many people are working on this file. Please consider merging this to your branch ASAP - but remember commit / push or drop or stash any uncommited local changes before merging that here on github. |
…er-whitespace_stays_put_for_now Acromatic spectrometer whitespace stays put for now
Merging because main was updated
| self.remove_charge_outside(beam, plot=False) | ||
|
|
||
| # drift half the distance | ||
| beam.transport(self.length/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.
In case of a "thick" plasma lens, where the beam position in the lens changes significantly as the particle passes through the lens, it is probably needed to have several slices. This is the case at CLEAR due to low beam energy.
I would strongly recommend to have a parameter for setting the number of kicks used to track, i.e. for approximating the change of position and momentum on the 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.
For quads there is some literature for how to optimally slice, I think this is a good reference:
https://cds.cern.ch/record/165372/files/p35.pdf
The TEAPOT algorithm is implemented in MadX's MAKETHIN command if I remember correctly. There has probably also been updates by Helmut Burkhardt since TEAPOT was originally written - I think there is an IPAC paper somewhere at least.
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.
However as a first go, I would just add a loop over the number of slices N, then for each slice do
- drift
- kick
- drift
where the drift length is L/N and the kick integral length is also L/N.
One can be slightly more clever and combine the "abutting" drifts, for slightly better performance, but I doubt it matters.
I implented something like this here, for JT model:
https://gitlab.cern.ch/CLEAR/CLEAR_DAN/-/blob/master/utilities/tracking_thick_JT.m?ref_type=heads#L79
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.
Also, is this somewhat overlapping with what @Hektor1201 is working on?
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, the idea is that Felipe does this simple one first, and then we switch it to using Hektor’s thick-lens implementation when that is ready. In the meantime, Felipe implements the achromatic spectrometer also in ImpactX.
|
Awesome! Just because this PR is still open, let me cross link our ImpactX example: We discussed (and implemented locally) at EAAC that we should add a dipedge element to make the sector bend a rectangular bend, for realism. |
|
@feliponelguapon what is the status of this one? |
I added some classes to be able to simulate an achromatic spectrometer. The tracking is done with the standard easy equations, I will work on another version which uses ImpactX.