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

Energy and particle available to C integrators #368

Merged
merged 5 commits into from
Feb 17, 2022
Merged

Energy and particle available to C integrators #368

merged 5 commits into from
Feb 17, 2022

Conversation

lfarv
Copy link
Contributor

@lfarv lfarv commented Feb 15, 2022

This is the equivalent for Matlab of #367 for python:
The energy and particle properties (rest energy and charge) are made available to all the C integrators. The list of global parameters is now:

  • ring length,
  • ring revolution time,
  • turn number,
  • energy,
  • particle rest energy,
  • particle charge,
  • s coordinate

Since the parameters are now available in both python and Matlab, they can be used from now on in the integrators.
But for the moment, only relativistic tracking is still available (only RFCavityPass is involved in that). The behaviour is:

  • in python, the default particle is 'relativistic', but if it is modified, the particle properties are transmitted to the integrators (which at the moment ignore it). So a warning is issued when changing the particle type.
  • in Matlab, the same warning is issued, but the particle type is not yet transmitted to the C. So the integrators always see the properties of the 'relativistic' particle. The reason is the following: ring properties in Matlab are stored in the RingParam element. If it is absent, gathering the properties takes long, so that atpass (ringpass and linepass) would be too slow. A better solution is still to be found, possibly by providing the properties optionally , when the are necessary…

Update:

A better solution is found for Matlab: if a RingParam element is found (this is very fast, 0.2 ms if found, 4 ms if not), its properties are sent to atpass.c. Otherwise, nothings sent. For comparison, building the properties from the lattice takes 80 ms).

  • a lattice without RingParam therefore assumes 'relativistic': nothing is changed,
  • a lattice with a RingParam element is able to set energy and particle, ready for future use.

Conclusion:

Nothing new appears with this PR, but it is an important and necessary step before working on non-relativistic tracking. Additionally, having the energy available will also remove the necessity of having "Energy" as an element attribute.
This branch (and #367) bring significant modifications of atpass.c, and start minimising the differences between the Matlab and python versions.

Side remark: while working on C code, I saw that the detection of OpenMP presence which was still missing in Matlab. It is now operational:

>> getoption()

ans = 

  atoptions with properties:

             XYStep: 3.0000e-08
             DPStep: 3.0000e-06
     OrbConvergence: 1.0000e-12
         OrbMaxIter: 20
    omp_num_threads: 0
        WarningDp6D: 1
             openmp: 0

>> 

@lfarv lfarv added the Matlab For Matlab/Octave AT code label Feb 15, 2022
@lfarv
Copy link
Contributor Author

lfarv commented Feb 16, 2022

The behaviour now the expected one: the ring properties are available in the C integrators, if available.

@lfarv lfarv merged commit e4c06a4 into master Feb 17, 2022
@lfarv lfarv deleted the matlab_atpass branch February 17, 2022 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Matlab For Matlab/Octave AT code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant