Skip to content

Review BESSY II chromaticity measurement #142

Closed

Description

@TeresiaOlsson

I have started to review the example for the BESSY II chromaticity and will add what I find here.

Issues found that needs to be fixed before workshop (WIP):

  • Prefix of the twin is hardcoded in the yaml file. We need to modify the example somehow so people change that or it's automatically updated based on their user name.

  • Something seems wrong with the vertical tune. The fit seems to return the horizonal tune in the vertical plane. Also the fitted chromaticity values are not as close as I would expect.

    I get:

    horizontal: [1.6626, 0.8299]
    vertical: [2.8658, 0.8400]

    but expect more like:

    horizontal: [1.7510, 0.8481]
    vertical: [3.0176, 0.7268]

    To me it looks like it's not working correctly.

    For debugging purposes I switched to design mode but then the chromaticity is zero because 6D motion is disabled in the example. And turning it on breaks the calculation of the momentum compaction factor. I had to do:

    sr.design.get_lattice().disable_6d()
    # Retreive MCF from the model
    alphac = sr.design.get_lattice().get_mcf()
    print(f"Moment compaction factor: {alphac}")
    
    sr.design.get_lattice().enable_6d()
    

    I think that's a problem because the user shouldn't have to switch to 4D tracking anywhere. In MML the user doesn't have to care about this. You can just have 6D enabled and everything works. If it works in MML it must be possible to also have the same in pyAML.

Feedback for future development:

  • See Review BESSY II tune example #140

  • We need the possibility to extend the chromaticity measurement to include the longitudinal chromaticity without breaking applications that use this measurement since in BESSY II we always measure the three planes because of our low alpha mode. In MML adding the third parameter has caused problems for some applications because they haven't been written sufficiently general with this potential extension in mind.

  • We should add the possibility to get the momentum compaction factor from some config parameter for cases where the lattice model doesn't give a sufficiently good value. In BESSY II we can measure the momentum compaction factor using our spin-resonance energy measurement and we then would like to be able to put that value into the config overwriting the value that comes from the model like you can do in MML.

  • It needs to be possible to define the input for RF frequency change in Hz. It's too difficult to have to recalculate yourself from frequency change to energy to be able to input how much you can change the RF without losing the beam. Especially if you are trying to measure the chromaticity in some experimentally found mode like negative alpha where you don't have a lattice model yet.

Activity

  1. TeresiaOlsson commented on Jan 25, 2026

    @TeresiaOlsson
    MemberAuthor

    @JeanLucPons or @Amoutardier How can I use the tune monitor in this example? I tried to debug what is going on with the vertical tune and thought I could just read what the tunes are using sr.live.tune.readback() as in the tune example but I get the error:

    Traceback (most recent call last):
      File "/home/a3744/Documents/software/pyAML/bessy2-test/bessy2-chroma.py", line 9, in <module>
        print(sr.live.tune.readback())
              ^^^^^^^^^^^^
      File "/home/a3744/miniforge3/envs/bessy2-pyaml/lib/python3.11/site-packages/pyaml/common/element_holder.py", line 244, in tune
        return self.get_tune_tuning("DEFAULT_TUNE_CORRECTION")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/a3744/miniforge3/envs/bessy2-pyaml/lib/python3.11/site-packages/pyaml/common/element_holder.py", line 237, in get_tune_tuning
        return self.__get("Tune tuning tool", name, self.__TUNING_TOOLS)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/a3744/miniforge3/envs/bessy2-pyaml/lib/python3.11/site-packages/pyaml/common/element_holder.py", line 93, in __get
        raise PyAMLException(f"{what} {name} not defined")
    pyaml.common.exception.PyAMLException: Tune tuning tool DEFAULT_TUNE_CORRECTION not defined
    

    Why are settings for the tune correction needed if I just want to read the tune? What is the way to use the tune monitor if sr.live.tune.readback() is not the way?

    I tried to also read the design tune with sr.design.tune but same error.

  2. TeresiaOlsson commented on Jan 25, 2026

    @TeresiaOlsson
    MemberAuthor

    I know what is wrong with the measurement. The tune in the twin is wrong. I switched to the newer version of the twin and now I get the correct values :)

    I will update the README to use the newest version of the twin.

  3. JeanLucPons commented on Jan 26, 2026

    @JeanLucPons
    Member

    Concerning 6D and 4D this is a user choice.
    PyAML itself never affect these settings.
    If you want to keep 6D then you can do:

    sr.design.get_lattice().disable_6d()
    alphac = sr.design.get_lattice().get_mcf()
    sr.design.get_lattice().enable_6d()
  4. TeresiaOlsson commented on Jan 26, 2026

    @TeresiaOlsson
    MemberAuthor

    The problem seems to be the get_mcf() function that doesn't behave the same in pyAT and AT. In MML I use AT2 but can still get the momentum compaction factor from the model without having to disable 6D. But that doesn't seem to work in pyAT.

  5. TeresiaOlsson commented on Jan 29, 2026

    @TeresiaOlsson
    MemberAuthor

    I found one bug. The unit on the x axis in the plot was wrong. I added the fix in PR #157.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions