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

Feature/end track marker+pyheadtail conversion #54

Open
wants to merge 57 commits into
base: master
Choose a base branch
from

Conversation

martinschwinzerl
Copy link

Based on PR #50, this one adds an end-of-tracking marker element which would

  • allow easier automatic setup of track_line from e.g. the MAD-X loader
  • allow simplifications to the tracking logic once we implement the Single-Particle tracking optimisation for SixTrackLib

Additionally, it adds a stub element for integrating with PyHEADTAIL which also could be placed programmatically before and after the end-of-tracking marker and allow to call the conversion functions from/to PyHEADTAIL data model from a GPU kernel in SixTrackLib.

In its current form, the PR is not intended to be merged but as a basis for reviewing code and a central point for discussions.

aoeftiger and others added 30 commits June 12, 2020 11:20
... to have the same layout in terms of number of particles as in SpaceChargeBunched
…le..

.. in view of the upgrade to arbitrary generalised Gaussian bunch profiles.
... SpaceChargeCoasting to new interface with number_of_particles
and circumference.
- add attribute for the interpolation method (0=linear, 1=cubic spline)
- implement tracking to use the interpolation method
- add fallback if no legal interpolation method is available -> this is
  consitent with the behaviour of SixTrackLib
martinschwinzerl and others added 27 commits September 1, 2020 23:34
…olation' into feature/sc-linedensity-interpolation
use q_parameter as parameter name, not q as in SixTrackLib
QGauss class no longer uses the `__call__` method to perform the actual evaluation, call `eval` instead
fixes typo / copy & paste error in `eval()` method
…nsity-interpolation

Feature/sc linedensity interpolation
This element can be inserted before and after an EndTrackingMarker
to take care of the conversion from/to PyHEADTAIL. The main purpose
for including this in pysixtrack is to facilitate use of such an
element in CObjects lattices / SixTrackLib.

TODO: This is a stub, implementation of the required conversions
stil missing
@aoeftiger
Copy link

Currently, the conversion is done in an explicit manner via python (which is slow, see https://github.com/aoeftiger/PySixHead/blob/main/tracker.py#L85 ):
PyHEADTAIL Particles (x, x', y, y', zeta, delta) --> SixTrackLib Particles

def pyht_to_stl(self, beam):
        stl_particles = self.trackjob.particles_buffer.get_object(0)
        n = beam.macroparticlenumber

        stl_particles.x[:n] = beam.x
        stl_particles.px[:n] = beam.xp
        stl_particles.y[:n] = beam.y
        stl_particles.py[:n] = beam.yp
        stl_particles.zeta[:n] = beam.z
        stl_particles.delta[:n] = beam.dp

        stl_particles.particle_id[:n] = beam.id
        stl_particles.state[:n] = beam.state
        stl_particles.at_turn[:n] = beam.at_turn
        stl_particles.at_element[:n] = beam.at_element
        stl_particles.s[:n] = beam.s

        # further longitudinal coordinates of SixTrackLib
        rpp = 1. / (beam.dp + 1)
        stl_particles.rpp[:n] = rpp

        restmass = beam.mass * c**2
        restmass_sq = restmass**2
        E0 = np.sqrt((beam.p0 * c)**2 + restmass_sq)
        p = beam.p0 * (1 + beam.dp)
        E = self.mathlib.sqrt((p * c) * (p * c) + restmass_sq)
        psigma =  (E - E0) / (beam.beta * beam.p0 * c)
        stl_particles.psigma[:n] = psigma

        gamma = E / restmass
        beta = self.mathlib.sqrt(1 - 1. / (gamma * gamma))
        rvv = beta / beam.beta
        stl_particles.rvv[:n] = rvv

        self.trackjob.push_particles()

--> this functionality is what would be required, but I'm unsure how this could be integrated as the track function seems unappropriate..?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants