-
Notifications
You must be signed in to change notification settings - Fork 3
Description
I am studying the serialized magnets and I find some issues.
I am using the test configuration in "pyaml/tests/config/sr_serialized_magnets.yaml",
which links 5 quadrupoles of different lengths.
-
Just after initialization the strengths are not really related, because the quadrupoles were not intended to be in series. This is understandable but there is an inconsistency between what is in the lattice and what the pyaml SerializedMagnets element thinks is in the lattice. We should somehow catch these inconsistencies.
-
I tried setting the strength in the serialized magnet and the behavior is unclear. Out of the 5 quadrupoles, the first one has the correct strength. The rest of the 4 quadrupoles have a different strength that is the same for all of them, even though they have different lengths.
This the script I run (from pyaml folder)
from pyaml.accelerator import Accelerator
file = 'tests/config/sr_serialized_magnets.yaml'
sr = Accelerator.load(file)
sm = sr.design.get_serialized_magnet('mySeriesOfMagnets')
element_names = sm._SerializedMagnets__elements # I think we should abolish private variables with double underscores!!
lattice = sr.design.get_lattice()
indices = [ii for ii in range(len(lattice)) if lattice[ii].FamName in element_names]
print('Reading lattice strengths')
print('FamName K*L L')
for ii in indices:
el = lattice[ii]
print(el.FamName, el.K * el.Length, el.Length)
print()
print('Reading strengths from serialized magnets')
for ii in range(len(sm.strengths.elements)):
print(element_names[ii], sm.strengths.elements[ii].get())
print()
strength0 = sm.strengths.get()
print(f"sm.strengths.get() = {strength0}")
print()
sm.strengths.set(strength0)
print(f"Running sm.strengths.set({strength0})")
print()
print('Reading lattice strengths')
print('FamName K*L L')
for ii in indices:
el = lattice[ii]
print(el.FamName, el.K * el.Length, el.Length)
print()
print('Reading strengths from serialized magnets')
for ii in range(len(sm.strengths.elements)):
print(element_names[ii], sm.strengths.elements[ii].get())
and this is the output:
Reading lattice strengths
FamName K*L L
QF8B-C04 2.179201209044364 0.492637
QF8D-C04 2.179201209044364 0.492637
QF6D-C04 1.7791564394080177 0.398656
QD5D-C04 -0.6299881229900359 0.227687
QF4D-C04 0.5477306213822942 0.227687
Reading strengths from serialized magnets
QF8B-C04 2.179201209044364
QF8D-C04 2.179201209044364
QD5D-C04 -0.6299881229900359
QF6D-C04 1.7791564394080177
QF4D-C04 0.5477306213822942
sm.strengths.get() = 2.179201209044364
Running sm.strengths.set(2.179201209044364)
Reading lattice strengths
FamName K*L L
QF8B-C04 2.179201209044364 0.492637
QF8D-C04 0.9597096191757837 0.492637
QF6D-C04 0.9597096191757837 0.398656
QD5D-C04 0.9597096191757838 0.227687
QF4D-C04 0.9597096191757838 0.227687
Reading strengths from serialized magnets
QF8B-C04 2.179201209044364
QF8D-C04 0.9597096191757837
QD5D-C04 0.9597096191757838
QF6D-C04 0.9597096191757837
QF4D-C04 0.9597096191757838