ULB-Metronu / zgoubidoo

Python interface for Zgoubi
https://ulb-metronu.github.io/zgoubidoo/
GNU General Public License v3.0
7 stars 6 forks source link

Filtering elements by name #41

Open rtesse opened 2 years ago

rtesse commented 2 years ago

If I try to filter the line by the name of an element, it doesn't work. For example, let's define the following Input:

import zgoubidoo
from zgoubidoo.commands import *
from zgoubidoo import ureg as _ureg

# Beam definition
k = zgoubidoo.Kinematics(2 * _ureg.GeV)

qf = Multipole('QF', XL=1*_ureg.m, B1=1 * _ureg.tesla, ALE=10*_ureg.degrees, XCE=10*_ureg.cm, YCE=10*_ureg.cm, KPOS=2)
qd = Multipole('QD', XL=1*_ureg.m, B1=-1 * _ureg.tesla, KPOS=2)

zi = zgoubidoo.Input(name='FODO', line=[
    Objet2('BUNCH', BORO=k.brho),
    Proton(),
    Drift(XL=1 * _ureg.m),
    qf,
    Drift(XL=1 * _ureg.m),
    qd,
    Drift(XL=1 * _ureg.m),
])

If I type the command zi.QF, I get the correct definition of the element.

'MULTIPOL' QF
        0
        1.000000000000e+02 1.000000000000e+01 1.000000000000e+01 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00
        0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 1.000000000000e+00 1.000000000000e+00 1.000000000000e+00 1.000000000000e+00 1.000000000000e+00 1.000000000000e+00 1.000000000000e+00 1.000000000000e+00
        6 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00
        0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 1.000000000000e+00 1.000000000000e+00 1.000000000000e+00 1.000000000000e+00 1.000000000000e+00 1.000000000000e+00 1.000000000000e+00 1.000000000000e+00
        6 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00
        0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00
        1.0
        2 1.000000000000e+01 1.000000000000e+01 1.745329251994e-01

However, the command zi['QF'] returns nothing.

FODO_filtered_by_QF
        'END' 2448f1a91fef4cc4ab24 

I think the issue is coming from lines 330 - 336 of input.py