Implement envelope tracker#112
Conversation
This will be used to set the correct particle mass and energy.
This method applies the linear transformation S -> M S M^T.
… into env-tracker
Replace these with identity matrix
Not working with x-z tilt when gamma >> 1
This fixes space charge kick for x and y when there are x-z or y-z correlations in the bunch ellipsoid.
|
|
Re: performance I commented out everything except setting up the envelope tracker and ran a profiler. On my system, tracking completes in less than 2 seconds and almost all of the time (63%) is spent just importing the PyORBIT C-extensions ( If I'm a bit more careful and only profile the tracking sections in isolation and also disable all logging/bunch stats calcs, this is what I get: Envelope TrackerRegular Tracker (Single Particle)So, the envelope tracker spends most of its time in |
|
Thanks! that's very helpful. If matrix multiplication is dominating then there's not all that much to do. I added some checks to skip the matrix multiplication tilt angle is zero in |
|
I've added a function to generate the matrix for RF gap nodes, copied from Each envelope tracking step needs to track the synchronous particle. For most elements this will just be increasing the time by |
|
One other thing you could try that may or may not be worth the effort is using Numba to do some JIT compilation where possible. You'll eat an initial cost to do the compilation the first time you run the tracker, but the byte code can be cached so that subsequent runs are faster (or have the potential to be). You would probably need to factor out types made accessible from bindings, e.g., the synchronous particle instance, and instead directly pass in the raw values you need to the kernels you want to be JIT compilable. |
Right now every unknown element will throw an error except MultipoleTEAPOT if all k are zero
|
WIth these small modifications: Envelope: Bunch (10,000 particles): |
|
With 2D space charge: Envelope: Bunch (100,000 particles, 64 x 64 x 1 grid): |
This PR implements an envelope/centroid tracker (Issue #51). We track the covariance matrix$\mathbf{\Sigma} = \langle \mathbf{x} \mathbf{x}^T \rangle$ and centroid $\mathbf{\mu} = \langle \mathbf{x} \rangle$ , where $\mathbf{x} = [x, x', y, y', z, \Delta E ]^T$ is the 6D phase space vector.
Evolution equations:
We track the$7 \times 7$ matrix $\mathbf{S} = \langle \mathbf{y} \mathbf{y}^T \rangle$ , where $\mathbf{y} = [x, x', y, y', z, dE, 1]^T$ :
Evolution equations for$\mathbf{y}$ :
where$\mathbf{N}$ is defined as
Accelerator nodes and child nodes are mapped to transfer matrices at the Python level. An error is raised if the node is not recognized. Space charge is handled by assuming a uniform charge density within an ellipsoid in the$x$ -$y$-$z$ plane (for 3D space charge) or within an ellipse in the $x$ -$y$ plane (for 2D space charge).